summaryrefslogtreecommitdiff
path: root/tests/dbus/test-tpl-log-store-xml.c
diff options
context:
space:
mode:
authorNicolas Dufresne <nicolas.dufresne@collabora.co.uk>2011-05-05 14:59:57 -0400
committerNicolas Dufresne <nicolas.dufresne@collabora.co.uk>2011-05-05 15:31:29 -0400
commit260e43c90d77926327faad4488beb44e629b71a5 (patch)
treea3161a8dc2b43c07a13c2660dcb2e2d154120e73 /tests/dbus/test-tpl-log-store-xml.c
parentb7c0dac4ed3e3ba123f0b3f957d264194e990f73 (diff)
Test XML store get_events_for_date()
Diffstat (limited to 'tests/dbus/test-tpl-log-store-xml.c')
-rw-r--r--tests/dbus/test-tpl-log-store-xml.c111
1 files changed, 111 insertions, 0 deletions
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 ();
}