mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
Test new gsettings api
g_settings_get_user_value and g_settings_get_default_value are now covered.
This commit is contained in:
parent
49ea52e6a6
commit
9a02cfd914
@ -2369,6 +2369,40 @@ test_read_descriptions (void)
|
||||
g_object_unref (settings);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
@ -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 ();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user