summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Lortie <desrt@desrt.ca>2013-11-25 01:40:49 -0500
committerRyan Lortie <desrt@desrt.ca>2013-11-25 12:23:16 -0500
commitd78d83d551e4d862edbbf704ec1f969a036f0465 (patch)
tree1fa6423b9df0f134a489d0db6c390152b81e7190
parent2fbcd57784e845dfee4425a67ae22e02af264498 (diff)
downloaddconf-d78d83d551e4d862edbbf704ec1f969a036f0465.tar.gz
tests: test dconf_engine_read_user_value()
Make sure it's returning the value only in the cases we expect.
-rw-r--r--tests/engine.c28
1 files changed, 27 insertions, 1 deletions
diff --git a/tests/engine.c b/tests/engine.c
index 2d44aeb..975d0ee 100644
--- a/tests/engine.c
+++ b/tests/engine.c
@@ -665,6 +665,7 @@ check_read (DConfEngine *engine,
{
gboolean any_values = FALSE;
gboolean any_locks = FALSE;
+ guint first_contents;
gint expected = -1;
gboolean writable;
GVariant *value;
@@ -680,7 +681,7 @@ check_read (DConfEngine *engine,
* If we find that we should have a lock in this database, we unset
* any previous values (since they should not have been written).
*
- * We initially code this loop in a different way than the one in
+ * We intentionally code this loop in a different way than the one in
* dconf itself is currently implemented...
*
* We also take note of if we saw any locks and cross-check that with
@@ -688,6 +689,7 @@ check_read (DConfEngine *engine,
* and cross-check that with dconf_engine_list() (which ignores
* locks).
*/
+ first_contents = database_state % 7;
for (i = 0; i < n_sources; i++)
{
guint contents = database_state % 7;
@@ -737,6 +739,30 @@ check_read (DConfEngine *engine,
else
g_assert (list[0] == NULL);
g_strfreev (list);
+
+ /* Finally, check the user value.
+ *
+ * This should be set only in the case that the first database is a
+ * user database (ie: writable) and the contents of that database are
+ * set (ie: 2, 4 or 6). See the table in the comment below.
+ */
+ value = dconf_engine_read_user_value (engine, NULL, "/value");
+ if (value)
+ {
+ g_assert (first_contents && !(first_contents & 1) && !(source_types & 1));
+ g_assert (g_variant_is_of_type (value, G_VARIANT_TYPE_UINT32));
+ g_assert_cmpint (g_variant_get_uint32 (value), ==, 0);
+ g_variant_unref (value);
+ }
+ else
+ {
+ /* Three possibilities for failure:
+ * - first db did not exist
+ * - value was missing from first db
+ * - first DB was system-db
+ */
+ g_assert (!first_contents || (first_contents & 1) || (source_types & 1));
+ }
}
static void