[libgdata/offline-testing] tests: General support for mock server traces in async tests
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgdata/offline-testing] tests: General support for mock server traces in async tests
- Date: Wed, 31 Jul 2013 07:21:54 +0000 (UTC)
commit 4f16f7177248bdd479f74d96a83aa1738af58996
Author: Philip Withnall <philip tecnocode co uk>
Date: Tue Jul 30 17:43:41 2013 +0200
tests: General support for mock server traces in async tests
gdata/tests/common.h | 12 ++++++++++++
1 files changed, 12 insertions(+), 0 deletions(-)
---
diff --git a/gdata/tests/common.h b/gdata/tests/common.h
index e894404..fd2b267 100644
--- a/gdata/tests/common.h
+++ b/gdata/tests/common.h
@@ -175,6 +175,10 @@ tear_down_##CLOSURE_NAME##_async (GDataAsyncTestData *async_data, gconstpointer
* <function>test_<replaceable>TEST_NAME</replaceable>_async</function> and
* <function>test_<replaceable>TEST_NAME</replaceable>_async_cancellation</function>.
*
+ * These functions assume the existence of a <varname>mock_server</varname> variable which points to the
current #GDataMockServer instance. They
+ * will automatically use traces <varname><replaceable>TEST_NAME</replaceable>-async</varname> and
+ * <varname><replaceable>TEST_NAME</replaceable>-async-cancellation</varname>.
+ *
* Since: 0.10.0
*/
#define GDATA_ASYNC_TEST_FUNCTIONS(TEST_NAME, TestStructType, TEST_BEGIN_CODE, TEST_END_CODE) \
@@ -221,11 +225,15 @@ test_##TEST_NAME##_async (GDataAsyncTestData *async_data, gconstpointer service)
\
g_test_message ("Running normal operation test…"); \
\
+ gdata_test_mock_server_start_trace (mock_server, G_STRINGIFY (TEST_NAME) "-async"); \
+ \
{ \
TEST_BEGIN_CODE; \
} \
\
g_main_loop_run (async_data->main_loop); \
+ \
+ gdata_mock_server_end_trace (mock_server); \
} \
\
static void \
@@ -233,6 +241,8 @@ test_##TEST_NAME##_async_cancellation (GDataAsyncTestData *async_data, gconstpoi
{ \
async_data->cancellation_timeout = 0; \
\
+ gdata_test_mock_server_start_trace (mock_server, G_STRINGIFY (TEST_NAME) "-async-cancellation"); \
+ \
/* Starting with a short timeout, repeatedly run the async. operation, cancelling it after the
timeout and increasing the timeout until
* the operation succeeds for the first time. We then finish the test. This guarantees that if, for
example, the test creates an entry on
* the server, it only ever creates one; because the test only ever succeeds once. (Of course, this
assumes that the server does not change
@@ -281,6 +291,8 @@ test_##TEST_NAME##_async_cancellation (GDataAsyncTestData *async_data, gconstpoi
if (async_data->cancellation_timeout_id != 0) { \
g_source_remove (async_data->cancellation_timeout_id); \
} \
+ \
+ gdata_mock_server_end_trace (mock_server); \
}
gboolean gdata_async_test_cancellation_cb (GDataAsyncTestData *async_data);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]