[glib] Add a test for g_settings_get_child



commit 78ed401a5146ac1d2f83f19b6a6fcfe789d847cb
Author: Matthias Clasen <mclasen redhat com>
Date:   Wed Apr 21 21:03:53 2010 -0400

    Add a test for g_settings_get_child

 gio/tests/gsettings.c |   30 ++++++++++++++++++++++++++++++
 1 files changed, 30 insertions(+), 0 deletions(-)
---
diff --git a/gio/tests/gsettings.c b/gio/tests/gsettings.c
index 484efac..f9fb0f7 100644
--- a/gio/tests/gsettings.c
+++ b/gio/tests/gsettings.c
@@ -1140,6 +1140,35 @@ test_keyfile (void)
   g_object_unref (settings);
 }
 
+/* Test that getting child schemas works
+ */
+static void
+test_child_schema (void)
+{
+  GSettings *settings;
+  GSettings *child;
+  guint8 byte;
+
+  /* first establish some known conditions */
+  settings = g_settings_new ("org.gtk.test.basic-types");
+  g_settings_set (settings, "test-byte", "y", 36);
+
+  g_settings_get (settings, "test-byte", "y", &byte);
+  g_assert_cmpint (byte, ==, 36);
+
+  g_object_unref (settings);
+
+  settings = g_settings_new ("org.gtk.test");
+  child = g_settings_get_child (settings, "basic-types");
+  g_assert (child != NULL);
+
+  g_settings_get (child, "test-byte", "y", &byte);
+  g_assert_cmpint (byte, ==, 36);
+
+  g_object_unref (child);
+  g_object_unref (settings);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -1177,6 +1206,7 @@ main (int argc, char *argv[])
   g_test_add_func ("/gsettings/no-read-binding", test_no_read_binding);
   g_test_add_func ("/gsettings/no-write-binding", test_no_write_binding);
   g_test_add_func ("/gsettings/keyfile", test_keyfile);
+  g_test_add_func ("/gsettings/child-schema", test_child_schema);
 
   return g_test_run ();
 }



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