diff options
Diffstat (limited to 'tests')
4 files changed, 126 insertions, 1 deletions
diff --git a/tests/dbus/test-log-manager.c b/tests/dbus/test-log-manager.c index b018b62..0cb00eb 100644 --- a/tests/dbus/test-log-manager.c +++ b/tests/dbus/test-log-manager.c @@ -439,7 +439,7 @@ test_get_entities (TestCaseFixture *fixture, get_entities_cb, fixture); g_main_loop_run (fixture->main_loop); - g_assert_cmpint (g_list_length (fixture->ret), ==, 3); + g_assert_cmpint (g_list_length (fixture->ret), ==, 4); /* we do not want duplicates */ fixture->ret = g_list_sort (fixture->ret, (GCompareFunc) _tpl_entity_compare); diff --git a/tests/dbus/test-tpl-log-store-xml.c b/tests/dbus/test-tpl-log-store-xml.c index 28353b3..f2c8c1f 100644 --- a/tests/dbus/test-tpl-log-store-xml.c +++ b/tests/dbus/test-tpl-log-store-xml.c @@ -670,6 +670,113 @@ test_exists (XmlTestCaseFixture *fixture, g_object_unref (user3); } + +static void +test_get_events_for_date (XmlTestCaseFixture *fixture, + gconstpointer user_data) +{ + TpAccount *account; + TplEntity *user2, *user3, *user4; + GList *events; + GDate *date; + GError *error = NULL; + + account = tp_account_new (fixture->bus, + TP_ACCOUNT_OBJECT_PATH_BASE "gabble/jabber/user_40collabora_2eco_2euk", + &error); + g_assert_no_error (error); + g_assert (account != NULL); + + date = g_date_new_dmy (13, 1, 2010); + + user2 = tpl_entity_new ("user2@collabora.co.uk", TPL_ENTITY_CONTACT, + "User2", ""); + + user3 = tpl_entity_new ("user3@collabora.co.uk", TPL_ENTITY_CONTACT, + "User3", ""); + + user4 = tpl_entity_new ("user4@collabora.co.uk", TPL_ENTITY_CONTACT, + "User4", ""); + + events = _tpl_log_store_get_events_for_date (fixture->store, account, user4, + TPL_EVENT_MASK_ANY, date); + + g_assert_cmpint (g_list_length (events), ==, 6); + + g_assert (TPL_IS_TEXT_EVENT (g_list_nth_data (events, 0))); + g_assert_cmpstr ( + tpl_text_event_get_message (TPL_TEXT_EVENT (g_list_nth_data (events, 0))), + ==, "7"); + + g_assert (TPL_IS_CALL_EVENT (g_list_nth_data (events, 1))); + g_assert_cmpint ( + tpl_call_event_get_duration (TPL_CALL_EVENT (g_list_nth_data (events, 1))), + ==, 1); + + g_assert (TPL_IS_CALL_EVENT (g_list_nth_data (events, 2))); + g_assert_cmpint ( + tpl_call_event_get_duration (TPL_CALL_EVENT (g_list_nth_data (events, 2))), + ==, 2); + + g_assert (TPL_IS_CALL_EVENT (g_list_nth_data (events, 3))); + g_assert_cmpint ( + tpl_call_event_get_duration (TPL_CALL_EVENT (g_list_nth_data (events, 3))), + ==, 3); + + g_assert (TPL_IS_TEXT_EVENT (g_list_nth_data (events, 4))); + g_assert_cmpstr ( + tpl_text_event_get_message (TPL_TEXT_EVENT (g_list_nth_data (events, 4))), + ==, "8"); + + g_assert (TPL_IS_TEXT_EVENT (g_list_nth_data (events, 5))); + g_assert_cmpstr ( + tpl_text_event_get_message (TPL_TEXT_EVENT (g_list_nth_data (events, 5))), + ==, "9"); + + g_list_foreach (events, (GFunc) g_object_unref, NULL); + g_list_free (events); + + events = _tpl_log_store_get_events_for_date (fixture->store, account, user4, + TPL_EVENT_MASK_CALL, date); + + g_assert_cmpint (g_list_length (events), ==, 3); + g_assert (TPL_IS_CALL_EVENT (g_list_nth_data (events, 0))); + g_assert_cmpint ( + tpl_call_event_get_duration (TPL_CALL_EVENT (g_list_nth_data (events, 0))), + ==, 1); + + g_list_foreach (events, (GFunc) g_object_unref, NULL); + g_list_free (events); + + events = _tpl_log_store_get_events_for_date (fixture->store, account, user4, + TPL_EVENT_MASK_TEXT, date); + + g_assert_cmpint (g_list_length (events), ==, 3); + + g_assert (TPL_IS_TEXT_EVENT (g_list_nth_data (events, 0))); + g_assert_cmpstr ( + tpl_text_event_get_message (TPL_TEXT_EVENT (g_list_nth_data (events, 0))), + ==, "7"); + + g_list_foreach (events, (GFunc) g_object_unref, NULL); + g_list_free (events); + + events = _tpl_log_store_get_events_for_date (fixture->store, account, user2, + TPL_EVENT_MASK_CALL, date); + g_assert_cmpint (g_list_length (events), ==, 0); + + events = _tpl_log_store_get_events_for_date (fixture->store, account, user3, + TPL_EVENT_MASK_TEXT, date); + g_assert_cmpint (g_list_length (events), ==, 0); + + g_object_unref (account); + g_object_unref (user2); + g_object_unref (user3); + g_object_unref (user4); + g_date_free (date); +} + + gint main (gint argc, gchar **argv) { g_type_init (); @@ -705,5 +812,9 @@ gint main (gint argc, gchar **argv) XmlTestCaseFixture, NULL, setup, test_exists, teardown); + g_test_add ("/log-store-xml/get-events-for-date", + XmlTestCaseFixture, NULL, + setup, test_get_events_for_date, teardown); + return g_test_run (); } diff --git a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user4@collabora.co.uk/20100113.call.log b/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user4@collabora.co.uk/20100113.call.log new file mode 100644 index 0000000..2a0511c --- /dev/null +++ b/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user4@collabora.co.uk/20100113.call.log @@ -0,0 +1,7 @@ +<?xml version='1.0' encoding='utf-8'?> +<?xml-stylesheet type="text/xsl" href="empathy-log.xsl"?> +<log> +<call time='20100113T17:48:01' id='user@collabora.co.uk' name='Nicolas1' isuser='false' token='' duration='1' actor='user@collabora.co.uk' actortype='contact' actorname='User1' actortoken='' reason='user-requested' detail='org.freedesktop.Telepathy.Error.Cancelled' /> +<call time='20100113T17:48:01' id='user@collabora.co.uk' name='Nicolas1' isuser='false' token='' duration='2' actor='user@collabora.co.uk' actortype='contact' actorname='User1' actortoken='' reason='user-requested' detail='org.freedesktop.Telepathy.Error.Cancelled' /> +<call time='20100113T17:48:01' id='user@collabora.co.uk' name='Nicolas1' isuser='false' token='' duration='3' actor='user@collabora.co.uk' actortype='contact' actorname='User1' actortoken='' reason='user-requested' detail='org.freedesktop.Telepathy.Error.Cancelled' /> +</log> diff --git a/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user4@collabora.co.uk/20100113.log b/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user4@collabora.co.uk/20100113.log new file mode 100644 index 0000000..f3cbd00 --- /dev/null +++ b/tests/logs/TpLogger/logs/gabble_jabber_user_40collabora_2eco_2euk/user4@collabora.co.uk/20100113.log @@ -0,0 +1,7 @@ +<?xml version='1.0' encoding='utf-8'?> +<?xml-stylesheet type="text/xsl" href="empathy-log.xsl"?> +<log> +<message time='20100113T17:47:57' cm_id='234' id='user3@collabora.co.uk' name='User3' token='' isuser='true' type='normal'>7</message> +<message time='20100113T17:48:01' cm_id='345' id='user3@collabora.co.uk' name='User3' token='' isuser='true' type='normal'>8</message> +<message time='20100113T17:49:10' cm_id='456' id='user1@collabora.co.uk' name='User1' token='' isuser='false' type='normal'>9</message> +</log> |