diff options
author | Nicolas Dufresne <nicolas.dufresne@collabora.co.uk> | 2011-02-24 09:56:49 -0500 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.co.uk> | 2011-02-24 09:56:49 -0500 |
commit | 0091145a98899dfc91e20312db9e53f6a5293c86 (patch) | |
tree | 98f40bf4ca3bfd72d8a4c2f65af3a6df0ad9cbab | |
parent | c0c21cf974aa0cdc1a59e2271a33306ef0b0beea (diff) | |
download | telepathy-logger-0091145a98899dfc91e20312db9e53f6a5293c86.tar.gz |
Move non-test code on top
-rw-r--r-- | tests/dbus/test-log-manager.c | 155 |
1 files changed, 78 insertions, 77 deletions
diff --git a/tests/dbus/test-log-manager.c b/tests/dbus/test-log-manager.c index 6b5b4d3..778d18d 100644 --- a/tests/dbus/test-log-manager.c +++ b/tests/dbus/test-log-manager.c @@ -86,83 +86,6 @@ log_handler (const gchar *log_domain, #endif /* ENABLE_DEBUG */ - -static void -test_get_dates (TestCaseFixture *fixture, - gconstpointer user_data) -{ - GList *ret, *loc; - TplEntity *entity; - - entity = tpl_entity_new (ID, TPL_ENTITY_CONTACT, NULL, NULL); - ret = _tpl_log_manager_get_dates (fixture->manager, fixture->account, entity, - TPL_EVENT_MASK_ANY); - g_object_unref (entity); - - /* it includes 1 date from libpurple logs, 5 from TpLogger. Empathy - * log-store date are the same of the TpLogger store, and wont' be present, - * being duplicates */ - g_assert_cmpint (g_list_length (ret), ==, 6); - - /* we do not want duplicates */ - ret = g_list_sort (ret, (GCompareFunc) g_strcmp0); - for (loc = ret; loc != NULL; loc = g_list_next (loc)) - if (loc->next) - g_assert (g_date_compare (loc->data, loc->next->data) != 0); - - g_list_foreach (ret, (GFunc) g_free, NULL); - g_list_free (ret); -} - -static void -test_get_entities (TestCaseFixture *fixture, - gconstpointer user_data) -{ - GList *ret, *loc; - - ret = _tpl_log_manager_get_entities (fixture->manager, fixture->account); - - g_assert_cmpint (g_list_length (ret), ==, 2); - - /* we do not want duplicates */ - ret = g_list_sort (ret, (GCompareFunc) _tpl_entity_compare); - for (loc = ret; loc != NULL; loc = g_list_next (loc)) - if (loc->next) - g_assert (_tpl_entity_compare (loc->data, loc->next->data) != 0); - - g_list_foreach (ret, (GFunc) g_object_unref, NULL); - g_list_free (ret); -} - - -static void -test_get_events_for_date (TestCaseFixture *fixture, - gconstpointer user_data) -{ - TplEntity *entity; - GDate *date; - GList *ret; - - entity = tpl_entity_new (ID, TPL_ENTITY_CONTACT, NULL, NULL); - date = g_date_new_dmy (13, 1, 2010); - - ret = _tpl_log_manager_get_events_for_date (fixture->manager, - fixture->account, - entity, - TPL_EVENT_MASK_TEXT, - date); - - g_object_unref (entity); - g_date_free (date); - - /* We got 6 events in old Empathy and 6 in new TpLogger storage */ - g_assert_cmpint (g_list_length (ret), ==, 12); - - g_list_foreach (ret, (GFunc) g_object_unref, NULL); - g_list_free (ret); -} - - static void teardown_service (TestCaseFixture* fixture, gconstpointer user_data) @@ -271,6 +194,7 @@ setup_service (TestCaseFixture* fixture, tp_g_value_slice_free (boxed_params); } + static void setup (TestCaseFixture* fixture, gconstpointer user_data) @@ -288,6 +212,7 @@ setup (TestCaseFixture* fixture, DEBUG ("set up finished"); } + static void setup_debug (void) { @@ -304,6 +229,82 @@ setup_debug (void) } +static void +test_get_dates (TestCaseFixture *fixture, + gconstpointer user_data) +{ + GList *ret, *loc; + TplEntity *entity; + + entity = tpl_entity_new (ID, TPL_ENTITY_CONTACT, NULL, NULL); + ret = _tpl_log_manager_get_dates (fixture->manager, fixture->account, entity, + TPL_EVENT_MASK_ANY); + g_object_unref (entity); + + /* it includes 1 date from libpurple logs, 5 from TpLogger. Empathy + * log-store date are the same of the TpLogger store, and wont' be present, + * being duplicates */ + g_assert_cmpint (g_list_length (ret), ==, 6); + + /* we do not want duplicates */ + ret = g_list_sort (ret, (GCompareFunc) g_strcmp0); + for (loc = ret; loc != NULL; loc = g_list_next (loc)) + if (loc->next) + g_assert (g_date_compare (loc->data, loc->next->data) != 0); + + g_list_foreach (ret, (GFunc) g_free, NULL); + g_list_free (ret); +} + +static void +test_get_entities (TestCaseFixture *fixture, + gconstpointer user_data) +{ + GList *ret, *loc; + + ret = _tpl_log_manager_get_entities (fixture->manager, fixture->account); + + g_assert_cmpint (g_list_length (ret), ==, 2); + + /* we do not want duplicates */ + ret = g_list_sort (ret, (GCompareFunc) _tpl_entity_compare); + for (loc = ret; loc != NULL; loc = g_list_next (loc)) + if (loc->next) + g_assert (_tpl_entity_compare (loc->data, loc->next->data) != 0); + + g_list_foreach (ret, (GFunc) g_object_unref, NULL); + g_list_free (ret); +} + + +static void +test_get_events_for_date (TestCaseFixture *fixture, + gconstpointer user_data) +{ + TplEntity *entity; + GDate *date; + GList *ret; + + entity = tpl_entity_new (ID, TPL_ENTITY_CONTACT, NULL, NULL); + date = g_date_new_dmy (13, 1, 2010); + + ret = _tpl_log_manager_get_events_for_date (fixture->manager, + fixture->account, + entity, + TPL_EVENT_MASK_TEXT, + date); + + g_object_unref (entity); + g_date_free (date); + + /* We got 6 events in old Empathy and 6 in new TpLogger storage */ + g_assert_cmpint (g_list_length (ret), ==, 12); + + g_list_foreach (ret, (GFunc) g_object_unref, NULL); + g_list_free (ret); +} + + int main (int argc, char **argv) { |