From af1a266670d040d2f4083ff309d732d648afba2a Mon Sep 17 00:00:00 2001 From: Angelos Mouzakitis Date: Tue, 10 Oct 2023 14:33:42 +0000 Subject: Add submodule dependency files Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec --- .../7 gnome/schemas/com.github.meson.gschema.xml | 12 ++++++ .../frameworks/7 gnome/schemas/meson.build | 7 ++++ .../frameworks/7 gnome/schemas/schemaprog.c | 47 ++++++++++++++++++++++ 3 files changed, 66 insertions(+) create mode 100644 meson/test cases/frameworks/7 gnome/schemas/com.github.meson.gschema.xml create mode 100644 meson/test cases/frameworks/7 gnome/schemas/meson.build create mode 100644 meson/test cases/frameworks/7 gnome/schemas/schemaprog.c (limited to 'meson/test cases/frameworks/7 gnome/schemas') diff --git a/meson/test cases/frameworks/7 gnome/schemas/com.github.meson.gschema.xml b/meson/test cases/frameworks/7 gnome/schemas/com.github.meson.gschema.xml new file mode 100644 index 000000000..741518dba --- /dev/null +++ b/meson/test cases/frameworks/7 gnome/schemas/com.github.meson.gschema.xml @@ -0,0 +1,12 @@ + + + + + "Hello" + A greeting + + Sample text to test schema compilation + + + + \ No newline at end of file diff --git a/meson/test cases/frameworks/7 gnome/schemas/meson.build b/meson/test cases/frameworks/7 gnome/schemas/meson.build new file mode 100644 index 000000000..9544a576e --- /dev/null +++ b/meson/test cases/frameworks/7 gnome/schemas/meson.build @@ -0,0 +1,7 @@ + +compiled = gnome.compile_schemas(build_by_default: true) +install_data('com.github.meson.gschema.xml', +install_dir : 'share/glib-2.0/schemas') + +schemaexe = executable('schemaprog', 'schemaprog.c', dependencies : gio) +test('schema test', schemaexe) diff --git a/meson/test cases/frameworks/7 gnome/schemas/schemaprog.c b/meson/test cases/frameworks/7 gnome/schemas/schemaprog.c new file mode 100644 index 000000000..17dab6514 --- /dev/null +++ b/meson/test cases/frameworks/7 gnome/schemas/schemaprog.c @@ -0,0 +1,47 @@ +#include +#include +#include + +int main(int argc, char **argv) { + GSettingsSchemaSource *src; + GSettingsSchema *schema; + GSettings *settings; + GVariant *value; + + GError *error = NULL; + src = g_settings_schema_source_new_from_directory("schemas", + g_settings_schema_source_get_default(), TRUE, &error); + if(error) { + fprintf(stderr, "Fail: %s\n", error->message); + g_error_free(error); + return 1; + } + + schema = g_settings_schema_source_lookup(src, "com.github.meson", FALSE); + if(!schema) { + fprintf(stderr, "Could not get schema from source.\n"); + return 2; + } + + settings = g_settings_new_full(schema, NULL, NULL); + if(!settings) { + fprintf(stderr, "Could not get settings object.\n"); + return 3; + } + + value = g_settings_get_value(settings, "greeting"); + if(!value) { + fprintf(stderr, "Could not get value from settings.\n"); + return 4; + } + + if(strcmp("Hello", g_variant_get_string(value, NULL)) != 0) { + fprintf(stderr, "Value of setting is incorrect.\n"); + return 5; + } + g_variant_unref(value); + g_object_unref(settings); + g_settings_schema_unref(schema); + g_settings_schema_source_unref(src); + return 0; +} -- cgit 1.2.3-korg