gsettings tests: use g_settings_schema_list_keys()

Stop using g_settings_list_keys() because soon it will be deprecated.

https://bugzilla.gnome.org/show_bug.cgi?id=740308
This commit is contained in:
Ryan Lortie 2014-11-19 12:45:06 -05:00 committed by Matthias Clasen
parent bb8eea6148
commit 6cf867fb2a

View File

@ -2107,13 +2107,15 @@ strv_set_equal (gchar **strv, ...)
static void static void
test_list_items (void) test_list_items (void)
{ {
GSettingsSchema *schema;
GSettings *settings; GSettings *settings;
gchar **children; gchar **children;
gchar **keys; gchar **keys;
settings = g_settings_new ("org.gtk.test"); settings = g_settings_new ("org.gtk.test");
g_object_get (settings, "settings-schema", &schema, NULL);
children = g_settings_list_children (settings); children = g_settings_list_children (settings);
keys = g_settings_list_keys (settings); keys = g_settings_schema_list_keys (schema);
g_assert (strv_set_equal (children, "basic-types", "complex-types", "localized", NULL)); g_assert (strv_set_equal (children, "basic-types", "complex-types", "localized", NULL));
g_assert (strv_set_equal (keys, "greeting", "farewell", NULL)); g_assert (strv_set_equal (keys, "greeting", "farewell", NULL));
@ -2121,6 +2123,7 @@ test_list_items (void)
g_strfreev (children); g_strfreev (children);
g_strfreev (keys); g_strfreev (keys);
g_settings_schema_unref (schema);
g_object_unref (settings); g_object_unref (settings);
} }
@ -2321,6 +2324,27 @@ test_schema_source (void)
g_settings_schema_source_unref (source); g_settings_schema_source_unref (source);
} }
static void
test_schema_list_keys (void)
{
gchar **keys;
GSettingsSchemaSource *src = g_settings_schema_source_get_default ();
GSettingsSchema *schema = g_settings_schema_source_lookup (src, "org.gtk.test", TRUE);
g_assert (schema != NULL);
keys = g_settings_schema_list_keys (schema);
g_assert (strv_set_equal ((gchar **)keys,
"greeting",
"farewell",
NULL));
g_strfreev (keys);
g_settings_schema_unref (schema);
g_settings_schema_source_unref (src);
}
static void static void
test_actions (void) test_actions (void)
{ {
@ -2526,14 +2550,17 @@ test_default_value (void)
static void static void
test_extended_schema (void) test_extended_schema (void)
{ {
GSettingsSchema *schema;
GSettings *settings; GSettings *settings;
gchar **keys; gchar **keys;
settings = g_settings_new_with_path ("org.gtk.test.extends.extended", "/test/extendes/"); settings = g_settings_new_with_path ("org.gtk.test.extends.extended", "/test/extendes/");
keys = g_settings_list_keys (settings); g_object_get (settings, "settings-schema", &schema, NULL);
keys = g_settings_schema_list_keys (schema);
g_assert (strv_set_equal (keys, "int32", "string", "another-int32", NULL)); g_assert (strv_set_equal (keys, "int32", "string", "another-int32", NULL));
g_strfreev (keys); g_strfreev (keys);
g_object_unref (settings); g_object_unref (settings);
g_settings_schema_unref (schema);
} }
int int
@ -2646,6 +2673,7 @@ main (int argc, char *argv[])
g_test_add_func ("/gsettings/mapped", test_get_mapped); g_test_add_func ("/gsettings/mapped", test_get_mapped);
g_test_add_func ("/gsettings/get-range", test_get_range); g_test_add_func ("/gsettings/get-range", test_get_range);
g_test_add_func ("/gsettings/schema-source", test_schema_source); g_test_add_func ("/gsettings/schema-source", test_schema_source);
g_test_add_func ("/gsettings/schema-list-keys", test_schema_list_keys);
g_test_add_func ("/gsettings/actions", test_actions); g_test_add_func ("/gsettings/actions", test_actions);
g_test_add_func ("/gsettings/null-backend", test_null_backend); 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/memory-backend", test_memory_backend);