summaryrefslogtreecommitdiff
path: root/tests/dbus
diff options
context:
space:
mode:
authorDebarshi Ray <debarshir@freedesktop.org>2012-08-28 15:51:40 +0200
committerDebarshi Ray <debarshir@freedesktop.org>2012-08-28 19:37:59 +0200
commit0ccc2f7770b52edc131adda66ddf60b10ebee1a6 (patch)
tree800de3213fbcc2e3bdb03347ab6601280e8347dc /tests/dbus
parent7fe417ebfcf7e86d5b2db51f9b3cb19abe54a4af (diff)
tests: Add a test for log-walker/rewind
... to cover events coming from multiple stores spanning several days where multiple events might have the same timestamp. Fixes: https://bugs.freedesktop.org/41772
Diffstat (limited to 'tests/dbus')
-rw-r--r--tests/dbus/test-tpl-log-walker.c90
1 files changed, 90 insertions, 0 deletions
diff --git a/tests/dbus/test-tpl-log-walker.c b/tests/dbus/test-tpl-log-walker.c
index cde0f7f..1ef28dd 100644
--- a/tests/dbus/test-tpl-log-walker.c
+++ b/tests/dbus/test-tpl-log-walker.c
@@ -136,6 +136,33 @@ teardown (WalkerTestCaseFixture *fixture,
static void
+rewind_cb (GObject *source,
+ GAsyncResult *result,
+ gpointer user_data)
+{
+ WalkerTestCaseFixture *fixture = user_data;
+ GError *error = NULL;
+
+ tpl_log_walker_rewind_finish (TPL_LOG_WALKER (source),
+ result,
+ &error);
+ g_assert_no_error (error);
+
+ g_main_loop_quit (fixture->main_loop);
+}
+
+
+static void
+rewind (WalkerTestCaseFixture *fixture,
+ TplLogWalker *walker,
+ guint num_events)
+{
+ tpl_log_walker_rewind_async (walker, num_events, rewind_cb, fixture);
+ g_main_loop_run (fixture->main_loop);
+}
+
+
+static void
get_events_cb (GObject *source,
GAsyncResult *result,
gpointer user_data)
@@ -260,6 +287,65 @@ test_get_events (WalkerTestCaseFixture *fixture,
}
+static void
+test_rewind (WalkerTestCaseFixture *fixture,
+ gconstpointer user_data)
+{
+ TplEntity *user5;
+ TplLogWalker *walker;
+
+ user5 = tpl_entity_new ("user5@collabora.co.uk", TPL_ENTITY_CONTACT,
+ "User5", "");
+
+ walker = tpl_log_manager_walk_filtered_events (fixture->manager,
+ fixture->account,
+ user5,
+ TPL_EVENT_MASK_ANY,
+ NULL,
+ NULL);
+
+ rewind (fixture, walker, 8);
+ get_events (fixture, walker, 0);
+ rewind (fixture, walker, 8);
+ get_events (fixture, walker, 2);
+ rewind (fixture, walker, 8);
+ test_get_events_text (fixture, walker, 8, 1263427261, "I'''");
+ rewind (fixture, walker, 3);
+ test_get_events_text (fixture, walker, 5, 1263427261, "I'");
+ rewind (fixture, walker, 1);
+ test_get_events_text (fixture, walker, 7, 1263427202, "11");
+ rewind (fixture, walker, 2);
+ test_get_events_call (fixture, walker, 5, 1263404881, 1);
+ rewind (fixture, walker, 2);
+ get_events (fixture, walker, 0);
+ test_get_events_text (fixture, walker, 1, 1263404950, "9");
+ rewind (fixture, walker, 0);
+ test_get_events_text (fixture, walker, 5, 1263254401, "5''");
+ rewind (fixture, walker, 1);
+ test_get_events_text (fixture, walker, 8, 1263168065, "G'''");
+ rewind (fixture, walker, 7);
+ test_get_events_text (fixture, walker, 7, 1263168065, "G'''");
+ test_get_events_text (fixture, walker, 7, 1263168063, "E");
+ rewind (fixture, walker, 2);
+ test_get_events_text (fixture, walker, 6, 1263168061, "C");
+ rewind (fixture, walker, 10);
+ rewind (fixture, walker, 0);
+ rewind (fixture, walker, 5);
+ test_get_events_text (fixture, walker, 16, 1263168005, "4''");
+ rewind (fixture, walker, 3);
+ test_get_events_text (fixture, walker, 6, 1263168004, "3");
+ rewind (fixture, walker, 1);
+ test_get_events_text (fixture, walker, 6, 1263081661, "A");
+
+ tpl_log_walker_get_events_async (walker, 2, get_events_cb, fixture);
+ g_main_loop_run (fixture->main_loop);
+ g_assert (fixture->events == NULL);
+
+ g_object_unref (walker);
+ g_object_unref (user5);
+}
+
+
gint main (gint argc, gchar **argv)
{
GHashTable *params;
@@ -285,6 +371,10 @@ gint main (gint argc, gchar **argv)
WalkerTestCaseFixture, params,
setup, test_get_events, teardown);
+ g_test_add ("/log-walker/rewind",
+ WalkerTestCaseFixture, params,
+ setup, test_rewind, teardown);
+
retval = g_test_run ();
g_hash_table_unref (params);