[evolution-data-server/openismus-work] e-test-server-utils: Add support for testing Direct Read Access books.
- From: Tristan Van Berkom <tvb src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/openismus-work] e-test-server-utils: Add support for testing Direct Read Access books.
- Date: Thu, 21 Feb 2013 13:45:18 +0000 (UTC)
commit 298309f5c32d5c8afe3ab117c24fc268e9fd04f6
Author: Tristan Van Berkom <tristanvb openismus com>
Date: Tue Feb 19 22:54:45 2013 +0900
e-test-server-utils: Add support for testing Direct Read Access books.
Conflicts:
tests/test-server-utils/e-test-server-utils.c
tests/test-server-utils/e-test-server-utils.c | 21 ++++++++++++++++++---
tests/test-server-utils/e-test-server-utils.h | 4 ++++
2 files changed, 22 insertions(+), 3 deletions(-)
---
diff --git a/tests/test-server-utils/e-test-server-utils.c b/tests/test-server-utils/e-test-server-utils.c
index 48c6348..19f7ed1 100644
--- a/tests/test-server-utils/e-test-server-utils.c
+++ b/tests/test-server-utils/e-test-server-utils.c
@@ -99,6 +99,8 @@ static gboolean
e_test_server_utils_bootstrap_timeout (FixturePair *pair)
{
g_error ("Timed out while waiting for ESource creation from the registry");
+
+ pair->fixture->timeout_source_id = 0;
return FALSE;
}
@@ -111,11 +113,11 @@ e_test_server_utils_source_added (ESourceRegistry *registry,
switch (pair->closure->type) {
case E_TEST_SERVER_ADDRESS_BOOK:
+ case E_TEST_SERVER_DIRECT_ADDRESS_BOOK:
if (g_strcmp0 (e_source_get_uid (source), ADDRESS_BOOK_SOURCE_UID) != 0)
return;
- if (g_getenv ("DEBUG_DIRECT") != NULL) {
-
+ if (pair->closure->type == E_TEST_SERVER_DIRECT_ADDRESS_BOOK)
pair->fixture->service.book_client = (EBookClient *)
e_book_client_connect_direct_sync (pair->fixture->registry, source, NULL,
&error);
@@ -200,6 +202,7 @@ e_test_server_utils_bootstrap_idle (FixturePair *pair)
/* Create an address book */
switch (pair->closure->type) {
case E_TEST_SERVER_ADDRESS_BOOK:
+ case E_TEST_SERVER_DIRECT_ADDRESS_BOOK:
case E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK:
scratch = e_source_new_with_uid (ADDRESS_BOOK_SOURCE_UID, NULL, &error);
@@ -240,7 +243,8 @@ e_test_server_utils_bootstrap_idle (FixturePair *pair)
}
if (pair->closure->type != E_TEST_SERVER_NONE)
- g_timeout_add (20 * 1000, (GSourceFunc) e_test_server_utils_bootstrap_timeout, pair);
+ pair->fixture->timeout_source_id =
+ g_timeout_add (20 * 1000, (GSourceFunc) e_test_server_utils_bootstrap_timeout, pair);
else
g_main_loop_quit (pair->fixture->loop);
@@ -283,6 +287,16 @@ e_test_server_utils_setup (ETestServerFixture *fixture,
g_idle_add ((GSourceFunc)e_test_server_utils_bootstrap_idle, &pair);
g_main_loop_run (fixture->loop);
+
+ /* This needs to be explicitly removed, otherwise the timeout source
+ * stays in the default GMainContext and after running tests for 20 seconds
+ * in the same test suite... the tests bail out.
+ */
+ if (fixture->timeout_source_id) {
+ g_source_remove (fixture->timeout_source_id);
+ fixture->timeout_source_id = 0;
+ }
+
g_signal_handlers_disconnect_by_func (fixture->registry, e_test_server_utils_source_added, &pair);
}
@@ -302,6 +316,7 @@ e_test_server_utils_teardown (ETestServerFixture *fixture,
switch (closure->type) {
case E_TEST_SERVER_ADDRESS_BOOK:
+ case E_TEST_SERVER_DIRECT_ADDRESS_BOOK:
if (!e_client_remove_sync (E_CLIENT (fixture->service.book_client), NULL, &error)) {
g_message ("Failed to remove test book: %s (ignoring)", error->message);
g_clear_error (&error);
diff --git a/tests/test-server-utils/e-test-server-utils.h b/tests/test-server-utils/e-test-server-utils.h
index 8dd7ede..6851e24 100644
--- a/tests/test-server-utils/e-test-server-utils.h
+++ b/tests/test-server-utils/e-test-server-utils.h
@@ -63,6 +63,7 @@ typedef void (* ETestSourceCustomizeFunc) (ESource *scratch,
* ETestServiceType:
* @E_TEST_SERVER_NONE: Only the #ESourceRegistry will be created
* @E_TEST_SERVER_ADDRESS_BOOK: An #EBookCLient will be created and opened for the test
+ * @E_TEST_SERVER_DIRECT_ADDRESS_BOOK: An #EBookCLient in direct read access mode will be created and opened
for the test
* @E_TEST_SERVER_CALENDAR: An #ECalClient will be created and opened for the test
* @E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK: An #EBook will be created and opened for the test
*
@@ -71,6 +72,7 @@ typedef void (* ETestSourceCustomizeFunc) (ESource *scratch,
typedef enum {
E_TEST_SERVER_NONE = 0,
E_TEST_SERVER_ADDRESS_BOOK,
+ E_TEST_SERVER_DIRECT_ADDRESS_BOOK,
E_TEST_SERVER_CALENDAR,
E_TEST_SERVER_DEPRECATED_ADDRESS_BOOK,
E_TEST_SERVER_DEPRECATED_CALENDAR
@@ -119,6 +121,7 @@ typedef union {
* @dbus: The D-Bus test scaffold
* @registry: An #ESourceRegistry
* @service: The #ETestService
+ * @timeout_source_id: A private detail, tracks the idle source which times out if the registry cannot
create an ESource.
*
* A fixture for running tests on the Evolution Data Server
* components in an encapsulated D-Bus environment.
@@ -128,6 +131,7 @@ struct _ETestServerFixture {
ETestDBus *dbus;
ESourceRegistry *registry;
ETestService service;
+ guint timeout_source_id;
};
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]