[dconf] dbus mock: add some better API
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [dconf] dbus mock: add some better API
- Date: Mon, 25 Nov 2013 18:01:30 +0000 (UTC)
commit 16c8d985445a37f51f2a77c1f5c68366160e1da3
Author: Ryan Lortie <desrt desrt ca>
Date: Mon Nov 25 01:59:47 2013 -0500
dbus mock: add some better API
Add API for replying to async calls in the mock dbus backend and for
checking that there are no calls outstanding.
Use it from the engine test.
tests/dconf-mock-dbus.c | 21 +++++++++++++++++++++
tests/dconf-mock.h | 4 ++++
tests/engine.c | 24 ++++++++++++------------
3 files changed, 37 insertions(+), 12 deletions(-)
---
diff --git a/tests/dconf-mock-dbus.c b/tests/dconf-mock-dbus.c
index e20b61a..d20600c 100644
--- a/tests/dconf-mock-dbus.c
+++ b/tests/dconf-mock-dbus.c
@@ -42,6 +42,27 @@ dconf_engine_dbus_call_async_func (GBusType bus_type,
return TRUE;
}
+void
+dconf_mock_dbus_async_reply (GVariant *reply,
+ GError *error)
+{
+ DConfEngineCallHandle *handle;
+
+ g_assert (!g_queue_is_empty (&dconf_mock_dbus_outstanding_call_handles));
+ handle = g_queue_pop_head (&dconf_mock_dbus_outstanding_call_handles);
+
+ if (reply && handle)
+ g_assert (g_variant_is_of_type (reply, dconf_engine_call_handle_get_expected_type (handle)));
+
+ dconf_engine_call_handle_reply (handle, reply, error);
+}
+
+void
+dconf_mock_dbus_assert_no_aync (void)
+{
+ g_assert (g_queue_is_empty (&dconf_mock_dbus_outstanding_call_handles));
+}
+
DConfMockDBusSyncCallHandler dconf_mock_dbus_sync_call_handler;
GVariant *
diff --git a/tests/dconf-mock.h b/tests/dconf-mock.h
index 10e6095..26f5f3c 100644
--- a/tests/dconf-mock.h
+++ b/tests/dconf-mock.h
@@ -16,6 +16,10 @@ typedef GVariant * (* DConfMockDBusSyncCallHandler) (GBusTyp
extern DConfMockDBusSyncCallHandler dconf_mock_dbus_sync_call_handler;
extern GQueue dconf_mock_dbus_outstanding_call_handles;
+void dconf_mock_dbus_async_reply (GVariant *reply,
+ GError *error);
+void dconf_mock_dbus_assert_no_aync (void);
+
void dconf_mock_shm_reset (void);
gint dconf_mock_shm_flag (const gchar *name);
void dconf_mock_shm_assert_log (const gchar *expected_log);
diff --git a/tests/engine.c b/tests/engine.c
index 1b1731d..2b6405f 100644
--- a/tests/engine.c
+++ b/tests/engine.c
@@ -925,17 +925,17 @@ test_watch_fast (void)
b = dconf_engine_get_state (engine);
g_assert_cmpuint (a, ==, b);
/* both AddMatch results come back before shm is flagged */
- dconf_engine_call_handle_reply (g_queue_pop_head (&dconf_mock_dbus_outstanding_call_handles), triv, NULL);
- dconf_engine_call_handle_reply (g_queue_pop_head (&dconf_mock_dbus_outstanding_call_handles), triv, NULL);
- g_assert (g_queue_is_empty (&dconf_mock_dbus_outstanding_call_handles));
+ dconf_mock_dbus_async_reply (triv, NULL);
+ dconf_mock_dbus_async_reply (triv, NULL);
+ dconf_mock_dbus_assert_no_aync ();
dconf_mock_shm_flag ("user");
b = dconf_engine_get_state (engine);
g_assert_cmpuint (a, !=, b);
g_assert_cmpstr (change_log->str, ==, "");
dconf_engine_unwatch_fast (engine, "/a/b/c");
- dconf_engine_call_handle_reply (g_queue_pop_head (&dconf_mock_dbus_outstanding_call_handles), triv, NULL);
- dconf_engine_call_handle_reply (g_queue_pop_head (&dconf_mock_dbus_outstanding_call_handles), triv, NULL);
- g_assert (g_queue_is_empty (&dconf_mock_dbus_outstanding_call_handles));
+ dconf_mock_dbus_async_reply (triv, NULL);
+ dconf_mock_dbus_async_reply (triv, NULL);
+ dconf_mock_dbus_assert_no_aync ();
/* Establish a watch and fail the race. */
a = dconf_engine_get_state (engine);
@@ -945,17 +945,17 @@ test_watch_fast (void)
b = dconf_engine_get_state (engine);
g_assert_cmpuint (a, ==, b);
/* one AddMatch result comes back -after- shm is flagged */
- dconf_engine_call_handle_reply (g_queue_pop_head (&dconf_mock_dbus_outstanding_call_handles), triv, NULL);
+ dconf_mock_dbus_async_reply (triv, NULL);
dconf_mock_shm_flag ("user");
- dconf_engine_call_handle_reply (g_queue_pop_head (&dconf_mock_dbus_outstanding_call_handles), triv, NULL);
- g_assert (g_queue_is_empty (&dconf_mock_dbus_outstanding_call_handles));
+ dconf_mock_dbus_async_reply (triv, NULL);
+ dconf_mock_dbus_assert_no_aync ();
b = dconf_engine_get_state (engine);
g_assert_cmpuint (a, !=, b);
g_assert_cmpstr (change_log->str, ==, "/:1::nil;");
dconf_engine_unwatch_fast (engine, "/a/b/c");
- dconf_engine_call_handle_reply (g_queue_pop_head (&dconf_mock_dbus_outstanding_call_handles), triv, NULL);
- dconf_engine_call_handle_reply (g_queue_pop_head (&dconf_mock_dbus_outstanding_call_handles), triv, NULL);
- g_assert (g_queue_is_empty (&dconf_mock_dbus_outstanding_call_handles));
+ dconf_mock_dbus_async_reply (triv, NULL);
+ dconf_mock_dbus_async_reply (triv, NULL);
+ dconf_mock_dbus_assert_no_aync ();
dconf_mock_gvdb_install ("/HOME/.config/dconf/user", NULL);
dconf_mock_gvdb_install ("/etc/dconf/db/site", NULL);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]