[glib] Add test for extended schemas



commit ef57996f44d57a3c6f7abda5a447ca8baf9dfbea
Author: Christian Persch <chpe gnome org>
Date:   Sun Oct 27 17:22:38 2013 -0700

    Add test for extended schemas
    
    The test checks that the keys of the base schema are all present in
    the extended schema.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=645453

 gio/tests/gsettings.c              |   16 ++++++++++++++++
 gio/tests/org.gtk.test.gschema.xml |   16 ++++++++++++++++
 2 files changed, 32 insertions(+), 0 deletions(-)
---
diff --git a/gio/tests/gsettings.c b/gio/tests/gsettings.c
index 35330b9..ab54ad4 100644
--- a/gio/tests/gsettings.c
+++ b/gio/tests/gsettings.c
@@ -2044,6 +2044,8 @@ test_list_schemas (void)
 
   g_assert (strv_set_equal ((gchar **)relocs,
                             "org.gtk.test.no-path",
+                            "org.gtk.test.extends.base",
+                            "org.gtk.test.extends.extended",
                             NULL));
 
   g_assert (strv_set_equal ((gchar **)schemas,
@@ -2368,6 +2370,19 @@ test_read_descriptions (void)
   g_object_unref (settings);
 }
 
+static void
+test_extended_schema (void)
+{
+  GSettings *settings;
+  gchar **keys;
+
+  settings = g_settings_new_with_path ("org.gtk.test.extends.extended", "/test/extendes/");
+  keys = g_settings_list_keys (settings);
+  g_assert (strv_set_equal (keys, "int32", "string", "another-int32", NULL));
+  g_strfreev (keys);
+  g_object_unref (settings);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -2482,6 +2497,7 @@ main (int argc, char *argv[])
   g_test_add_func ("/gsettings/null-backend", test_null_backend);
   g_test_add_func ("/gsettings/memory-backend", test_memory_backend);
   g_test_add_func ("/gsettings/read-descriptions", test_read_descriptions);
+  g_test_add_func ("/gsettings/test-extended-schema", test_extended_schema);
 
   result = g_test_run ();
 
diff --git a/gio/tests/org.gtk.test.gschema.xml b/gio/tests/org.gtk.test.gschema.xml
index 1ea8750..bda05a2 100644
--- a/gio/tests/org.gtk.test.gschema.xml
+++ b/gio/tests/org.gtk.test.gschema.xml
@@ -185,4 +185,20 @@
       <default>0</default>
     </key>
   </schema>
+
+  <schema id='org.gtk.test.extends.base'>
+    <key name='int32' type='i'>
+      <default>0</default>
+    </key>
+    <key name='string' type='s'>
+      <default>''</default>
+    </key>
+  </schema>
+  <schema id='org.gtk.test.extends.extended' extends='org.gtk.test.extends.base'>
+    <override name="int32">42</override>
+    <key name='another-int32' type='i'>
+      <default>0</default>
+    </key>
+  </schema>
+
 </schemalist>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]