summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorAllison Ryan Lortie <desrt@desrt.ca>2015-11-30 16:40:25 +0000
committerAllison Ryan Lortie <desrt@desrt.ca>2015-11-30 16:40:32 +0000
commitc6423fa1cacb9fb3178016e712be9323a743bce4 (patch)
treee26e41de0cee7d0eb5f9de82159fe37e73ba5674 /tests
parent4ef5a2a4c6ac349f51a1cd5f9013efe8c5f26f12 (diff)
downloaddconf-c6423fa1cacb9fb3178016e712be9323a743bce4.tar.gz
DConfChangeset: implement dir resets properly
If a dir is reset against a DConfChangeset then the result ought to be that all keys under that dir read as NULL (until such a time as they are set to a new value). This is consistent with the (existing) behaviour that a key will read as NULL if it, itself, was reset. In order to make that efficient, we create a separate GHashTable to serve as a cache of all of the directories that have been reset and iterate it whenever we do a key lookup that doesn't have a direct hit. We update (and expand) the test case to reflect this new reality -- the tests actually had a case that relied on the inconsistent behaviour. https://bugzilla.gnome.org/show_bug.cgi?id=744678
Diffstat (limited to 'tests')
-rw-r--r--tests/changeset.c27
1 files changed, 24 insertions, 3 deletions
diff --git a/tests/changeset.c b/tests/changeset.c
index 90b8de6..5f046df 100644
--- a/tests/changeset.c
+++ b/tests/changeset.c
@@ -281,37 +281,58 @@ static void
test_reset (void)
{
DConfChangeset *changeset;
+ GVariant *value;
changeset = dconf_changeset_new ();
g_assert (!dconf_changeset_get (changeset, "/value/a", NULL));
+ g_assert (!dconf_changeset_get (changeset, "/value/a", &value));
+ /* value was not set */
/* set a value */
dconf_changeset_set (changeset, "/value/a", g_variant_new_boolean (TRUE));
g_assert (dconf_changeset_get (changeset, "/value/a", NULL));
+ g_assert (dconf_changeset_get (changeset, "/value/a", &value));
+ g_assert (value != NULL);
+ g_variant_unref (value);
/* record the reset */
dconf_changeset_set (changeset, "/value/", NULL);
- g_assert (!dconf_changeset_get (changeset, "/value/a", NULL));
+ g_assert (dconf_changeset_get (changeset, "/value/a", NULL));
+ g_assert (dconf_changeset_get (changeset, "/value/a", &value));
+ g_assert (value == NULL);
/* write it back */
dconf_changeset_set (changeset, "/value/a", g_variant_new_boolean (TRUE));
g_assert (dconf_changeset_get (changeset, "/value/a", NULL));
+ g_assert (dconf_changeset_get (changeset, "/value/a", &value));
+ g_assert (value != NULL);
+ g_variant_unref (value);
/* reset again */
dconf_changeset_set (changeset, "/value/", NULL);
- g_assert (!dconf_changeset_get (changeset, "/value/a", NULL));
+ g_assert (dconf_changeset_get (changeset, "/value/a", NULL));
+ g_assert (dconf_changeset_get (changeset, "/value/a", &value));
+ g_assert (value == NULL);
/* write again */
dconf_changeset_set (changeset, "/value/a", g_variant_new_boolean (TRUE));
g_assert (dconf_changeset_get (changeset, "/value/a", NULL));
+ g_assert (dconf_changeset_get (changeset, "/value/a", &value));
+ g_assert (value != NULL);
+ g_variant_unref (value);
/* reset a different way */
- dconf_changeset_set (changeset, "/value/a", g_variant_new_boolean (TRUE));
+ dconf_changeset_set (changeset, "/value/a", NULL);
g_assert (dconf_changeset_get (changeset, "/value/a", NULL));
+ g_assert (dconf_changeset_get (changeset, "/value/a", &value));
+ g_assert (value == NULL);
/* write last time */
dconf_changeset_set (changeset, "/value/a", g_variant_new_boolean (TRUE));
g_assert (dconf_changeset_get (changeset, "/value/a", NULL));
+ g_assert (dconf_changeset_get (changeset, "/value/a", &value));
+ g_assert (value != NULL);
+ g_variant_unref (value);
dconf_changeset_unref (changeset);
}