diff options
author | Nicolas Dufresne <nicolas.dufresne@collabora.co.uk> | 2011-02-22 18:44:15 -0500 |
---|---|---|
committer | Nicolas Dufresne <nicolas.dufresne@collabora.co.uk> | 2011-02-22 18:44:15 -0500 |
commit | 2fc6dc7fe60e1ea689557d464f45ceea2119cd73 (patch) | |
tree | 19030a7503d9edb53b5ec1cd1e9c2d537c7c2ebf /tests | |
parent | b24f7974e6afb33e03b986339fab4595b07e4419 (diff) |
Make TplEntity constructors public
Implement a generic constructor along with making public all TplEntity
constructors. This is required now that the LogManager API require
TplEntity object instead of id/is_room pair.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/dbus/test-entity.c | 23 | ||||
-rw-r--r-- | tests/dbus/test-searches.c | 4 | ||||
-rw-r--r-- | tests/dbus/test-tpl-log-store-pidgin.c | 17 | ||||
-rw-r--r-- | tests/dbus/test-tpl-log-store-xml.c | 11 |
4 files changed, 23 insertions, 32 deletions
diff --git a/tests/dbus/test-entity.c b/tests/dbus/test-entity.c index 5877a5d..0f7cda4 100644 --- a/tests/dbus/test-entity.c +++ b/tests/dbus/test-entity.c @@ -11,12 +11,8 @@ test_entity_instantiation (void) { TplEntity *entity; - entity = g_object_new (TPL_TYPE_ENTITY, - "identifier", "my-identifier", - "type", TPL_ENTITY_CONTACT, - "alias", "my-alias", - "avatar-token", "my-token", - NULL); + entity = tpl_entity_new ("my-identifier", TPL_ENTITY_CONTACT, + "my-alias", "my-token"); g_assert_cmpstr (tpl_entity_get_identifier (entity), ==, "my-identifier"); g_assert (tpl_entity_get_entity_type (entity) == TPL_ENTITY_CONTACT); @@ -24,6 +20,15 @@ test_entity_instantiation (void) g_assert_cmpstr (tpl_entity_get_avatar_token (entity), ==, "my-token"); g_object_unref (entity); + + /* Check that identifier is copied in absence of ID */ + entity = tpl_entity_new ("my-identifier", TPL_ENTITY_CONTACT, + NULL, NULL); + + g_assert_cmpstr (tpl_entity_get_alias (entity), ==, "my-identifier"); + g_assert (tpl_entity_get_avatar_token (entity) == NULL); + + g_object_unref (entity); } static void @@ -31,7 +36,7 @@ test_entity_instantiation_from_room_id (void) { TplEntity *entity; - entity = _tpl_entity_new_from_room_id ("my-room-id"); + entity = tpl_entity_new_from_room_id ("my-room-id"); g_assert_cmpstr (tpl_entity_get_identifier (entity), ==, "my-room-id"); g_assert (tpl_entity_get_entity_type (entity) == TPL_ENTITY_ROOM); @@ -115,7 +120,7 @@ test_entity_instantiation_from_tp_contact (void) NULL, NULL); g_main_loop_run (result.loop); - entity = _tpl_entity_new_from_tp_contact (result.contacts[0], + entity = tpl_entity_new_from_tp_contact (result.contacts[0], TPL_ENTITY_SELF); g_assert_cmpstr (tpl_entity_get_identifier (entity), ==, "alice"); @@ -124,7 +129,7 @@ test_entity_instantiation_from_tp_contact (void) g_assert_cmpstr (tpl_entity_get_avatar_token (entity), ==, avatar_tokens[0]); g_object_unref (entity); - entity = _tpl_entity_new_from_tp_contact (result.contacts[1], + entity = tpl_entity_new_from_tp_contact (result.contacts[1], TPL_ENTITY_CONTACT); g_assert_cmpstr (tpl_entity_get_identifier (entity), ==, "bob"); diff --git a/tests/dbus/test-searches.c b/tests/dbus/test-searches.c index 422619b..dbf3f56 100644 --- a/tests/dbus/test-searches.c +++ b/tests/dbus/test-searches.c @@ -94,9 +94,7 @@ test_get_dates (TestCaseFixture *fixture, GList *ret, *loc; TplEntity *entity; - entity = g_object_new (TPL_TYPE_ENTITY, - "identifier", ID, - "type", TPL_ENTITY_CONTACT); + entity = tpl_entity_new (ID, TPL_ENTITY_CONTACT, NULL, NULL); ret = _tpl_log_manager_get_dates (fixture->manager, fixture->account, entity); g_object_unref (entity); diff --git a/tests/dbus/test-tpl-log-store-pidgin.c b/tests/dbus/test-tpl-log-store-pidgin.c index 2ff9e9b..0a6435f 100644 --- a/tests/dbus/test-tpl-log-store-pidgin.c +++ b/tests/dbus/test-tpl-log-store-pidgin.c @@ -174,20 +174,13 @@ setup (PidginTestCaseFixture* fixture, "testmode", TRUE, NULL); - fixture->room = g_object_new (TPL_TYPE_ENTITY, - "identifier", "test@conference.collabora.co.uk", - "type", TPL_ENTITY_ROOM, - NULL); + fixture->room = tpl_entity_new_from_room_id ( + "test@conference.collabora.co.uk"); - fixture->irc_room = g_object_new (TPL_TYPE_ENTITY, - "identifier", "#telepathy", - "type", TPL_ENTITY_ROOM, - NULL); + fixture->irc_room = tpl_entity_new_from_room_id ("#telepathy"); - fixture->contact = g_object_new (TPL_TYPE_ENTITY, - "identifier", "user2@collabora.co.uk", - "type", TPL_ENTITY_CONTACT, - NULL); + fixture->contact = tpl_entity_new ("user2@collabora.co.uk", + TPL_ENTITY_CONTACT, NULL, NULL); if (user_data != NULL) setup_service (fixture, user_data); diff --git a/tests/dbus/test-tpl-log-store-xml.c b/tests/dbus/test-tpl-log-store-xml.c index 5069ecd..7090584 100644 --- a/tests/dbus/test-tpl-log-store-xml.c +++ b/tests/dbus/test-tpl-log-store-xml.c @@ -207,15 +207,10 @@ test_clear_entity (XmlTestCaseFixture *fixture, 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); + entity = tpl_entity_new_from_room_id ("meego@conference.collabora.co.uk"); else - entity = g_object_new (TPL_TYPE_ENTITY, - "type", TPL_ENTITY_CONTACT, - "identifier", "derek.foreman@collabora.co.uk", - NULL); + entity = tpl_entity_new ("derek.foreman@collabora.co.uk", + TPL_ENTITY_CONTACT, NULL, NULL); _tpl_log_store_clear_entity (TPL_LOG_STORE (fixture->store), account, entity); g_object_unref (account); |