diff options
author | Nicolas Dufresne <nicolas.dufresne@collabora.co.uk> | 2011-02-10 13:44:12 +0000 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.co.uk> | 2011-02-10 17:03:37 +0000 |
commit | 316f4e9fefe3a9fa2501ac9e1eb94a7889f4a323 (patch) | |
tree | f2773ecefbf3c657d3504dc8b24dd158b8cfe1c4 /tests/dbus/test-tpl-log-store-xml.c | |
parent | 6f8bc371ce28e125366dd0a7dca323c7ba5eddc2 (diff) |
Implement XML store test for clear_entity
Diffstat (limited to 'tests/dbus/test-tpl-log-store-xml.c')
-rw-r--r-- | tests/dbus/test-tpl-log-store-xml.c | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/tests/dbus/test-tpl-log-store-xml.c b/tests/dbus/test-tpl-log-store-xml.c index fa9faf5..5069ecd 100644 --- a/tests/dbus/test-tpl-log-store-xml.c +++ b/tests/dbus/test-tpl-log-store-xml.c @@ -154,6 +154,94 @@ test_clear_account (XmlTestCaseFixture *fixture, } +static void +test_clear_entity (XmlTestCaseFixture *fixture, + gconstpointer user_data) +{ + gboolean is_room = GPOINTER_TO_INT (user_data); + GList *hits; + TpAccount *account; + TplEntity *entity; + GError *error = NULL; + const gchar *always_kept, *kept, *cleared; + + always_kept = "1263405203"; + + if (is_room) + { + kept = "f95e605a3ae97c463b626a3538567bc90fc58730"; + cleared = "8957fb4064049e7a1f9d8f84234d3bf09fb6778c"; + } + else + { + kept = "8957fb4064049e7a1f9d8f84234d3bf09fb6778c"; + cleared = "f95e605a3ae97c463b626a3538567bc90fc58730"; + } + + hits = _tpl_log_store_search_new (TPL_LOG_STORE (fixture->store), + always_kept); + + g_assert_cmpint (g_list_length (hits), ==, 1); + + tpl_log_manager_search_free (hits); + + hits = _tpl_log_store_search_new (TPL_LOG_STORE (fixture->store), + kept); + + g_assert_cmpint (g_list_length (hits), ==, 1); + + tpl_log_manager_search_free (hits); + + hits = _tpl_log_store_search_new (TPL_LOG_STORE (fixture->store), + cleared); + + g_assert_cmpint (g_list_length (hits), ==, 1); + + tpl_log_manager_search_free (hits); + + account = tp_account_new (fixture->bus, + TP_ACCOUNT_OBJECT_PATH_BASE "gabble/jabber/test2_40collabora_2eco_2euk0", + &error); + + g_assert_no_error (error); + g_assert (account != NULL); + + if (is_room) + entity = g_object_new (TPL_TYPE_ENTITY, + "type", TPL_ENTITY_ROOM, + "identifier", "meego@conference.collabora.co.uk", + NULL); + else + entity = g_object_new (TPL_TYPE_ENTITY, + "type", TPL_ENTITY_CONTACT, + "identifier", "derek.foreman@collabora.co.uk", + NULL); + + _tpl_log_store_clear_entity (TPL_LOG_STORE (fixture->store), account, entity); + g_object_unref (account); + g_object_unref (entity); + + hits = _tpl_log_store_search_new (TPL_LOG_STORE (fixture->store), + always_kept); + + g_assert_cmpint (g_list_length (hits), ==, 1); + + tpl_log_manager_search_free (hits); + + hits = _tpl_log_store_search_new (TPL_LOG_STORE (fixture->store), + kept); + + g_assert_cmpint (g_list_length (hits), ==, 1); + + tpl_log_manager_search_free (hits); + + hits = _tpl_log_store_search_new (TPL_LOG_STORE (fixture->store), + cleared); + + g_assert_cmpint (g_list_length (hits), ==, 0); +} + + gint main (gint argc, gchar **argv) { g_type_init (); @@ -169,5 +257,13 @@ gint main (gint argc, gchar **argv) XmlTestCaseFixture, NULL, setup_for_writing, test_clear_account, teardown); + g_test_add ("/log-store-xml/clear-entity", + XmlTestCaseFixture, GINT_TO_POINTER (FALSE), + setup_for_writing, test_clear_entity, teardown); + + g_test_add ("/log-store-xml/clear-entity-room", + XmlTestCaseFixture, GINT_TO_POINTER (TRUE), + setup_for_writing, test_clear_entity, teardown); + return g_test_run (); } |