[glib] Test new gsettings api



commit 9a02cfd9142b9692116f828c402b115592e2256b
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Nov 28 02:01:48 2013 -0500

    Test new gsettings api
    
    g_settings_get_user_value and g_settings_get_default_value
    are now covered.

 gio/tests/gsettings.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)
---
diff --git a/gio/tests/gsettings.c b/gio/tests/gsettings.c
index 522e583..28f1568 100644
--- a/gio/tests/gsettings.c
+++ b/gio/tests/gsettings.c
@@ -2370,6 +2370,40 @@ test_read_descriptions (void)
 }
 
 static void
+test_default_value (void)
+{
+  GSettings *settings;
+  GVariant *v;
+  gchar *str;
+  gchar *default_value;
+
+  settings = g_settings_new ("org.gtk.test");
+
+  g_settings_set (settings, "greeting", "s", "goodbye world");
+
+  v = g_settings_get_user_value (settings, "greeting");
+  str = g_variant_get_string (v, NULL);
+  g_assert_cmpstr (str, ==, "goodbye world");
+  g_variant_unref (v);
+
+  v = g_settings_get_default_value (settings, "greeting");
+  str = g_variant_get_string (v, NULL);
+  g_assert_cmpstr (str, ==, "Hello, earthlings");
+  g_variant_unref (v);
+
+  g_settings_reset (settings, "greeting");
+
+  v = g_settings_get_user_value (settings, "greeting");
+  g_assert_null (v);
+
+  str = g_settings_get_string (settings, "greeting");
+  g_assert_cmpstr (str, ==, "Hello, earthlings");
+  g_free (str);
+
+  g_object_unref (settings);
+}
+
+static void
 test_extended_schema (void)
 {
   GSettings *settings;
@@ -2501,6 +2535,7 @@ main (int argc, char *argv[])
   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);
+  g_test_add_func ("/gsettings/default-value", test_default_value);
 
   result = g_test_run ();
 


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