diff options
author | Andre Moreira Magalhaes (andrunko) <andre.magalhaes@collabora.co.uk> | 2011-09-28 15:35:11 -0300 |
---|---|---|
committer | Andre Moreira Magalhaes (andrunko) <andre.magalhaes@collabora.co.uk> | 2011-09-30 10:50:31 -0300 |
commit | b763bbf4274e200759c33ecbf0d6a19677ad1a08 (patch) | |
tree | 31b07cd83b01c08fb7b938e4278b28cb4a3667d0 /qt4/tests | |
parent | 5532b8e364ed473d0d813b32edb4c32bd3868344 (diff) |
contacts-conn example cm: Make RefreshContactInfo replaces the user info with the default info.
This is specially useful when checking that Contact::infoFieldsChanged was emitted in response of
Contact::refreshInfo.
Diffstat (limited to 'qt4/tests')
-rw-r--r-- | qt4/tests/dbus/contacts-info.cpp | 26 | ||||
-rw-r--r-- | qt4/tests/lib/glib/contacts-conn.c | 9 |
2 files changed, 29 insertions, 6 deletions
diff --git a/qt4/tests/dbus/contacts-info.cpp b/qt4/tests/dbus/contacts-info.cpp index 2f46cdd94..d5ec40dac 100644 --- a/qt4/tests/dbus/contacts-info.cpp +++ b/qt4/tests/dbus/contacts-info.cpp @@ -93,6 +93,21 @@ void TestContactsInfo::testInfo() SLOT(onContactInfoFieldsChanged(const Tp::Contact::InfoFields &)))); } + GPtrArray *info_default = (GPtrArray *) dbus_g_type_specialized_construct ( + TP_ARRAY_TYPE_CONTACT_INFO_FIELD_LIST); + { + const gchar * const field_values[2] = { + "FooBar", NULL + }; + g_ptr_array_add (info_default, tp_value_array_build (3, + G_TYPE_STRING, "n", + G_TYPE_STRV, NULL, + G_TYPE_STRV, field_values, + G_TYPE_INVALID)); + } + tp_tests_contacts_connection_set_default_contact_info(TP_TESTS_CONTACTS_CONNECTION(mConn->service()), + info_default); + GPtrArray *info_1 = (GPtrArray *) dbus_g_type_specialized_construct ( TP_ARRAY_TYPE_CONTACT_INFO_FIELD_LIST); { @@ -151,6 +166,7 @@ void TestContactsInfo::testInfo() QCOMPARE(contactBar->infoFields().allFields()[0].fieldName, QLatin1String("n")); QCOMPARE(contactBar->infoFields().allFields()[0].fieldValue[0], QLatin1String("Bar")); + mContactsInfoFieldsUpdated = 0; Q_FOREACH (const ContactPtr &contact, contacts) { PendingOperation *op = contact->refreshInfo(); QVERIFY(connect(op, @@ -159,8 +175,11 @@ void TestContactsInfo::testInfo() QCOMPARE(mLoop->exec(), 0); } - /* nothing changed */ - QCOMPARE(mContactsInfoFieldsUpdated, 0); + while (mContactsInfoFieldsUpdated != contacts.size()) { + mLoop->processEvents(); + } + + QCOMPARE(mContactsInfoFieldsUpdated, contacts.size()); for (int i = 0; i < contacts.size(); i++) { ContactPtr contact = contacts[i]; @@ -181,8 +200,9 @@ void TestContactsInfo::testInfo() QCOMPARE(pci->infoFields().isValid(), true); QCOMPARE(pci->infoFields().allFields().size(), 1); QCOMPARE(pci->infoFields().allFields()[0].fieldName, QLatin1String("n")); - QCOMPARE(pci->infoFields().allFields()[0].fieldValue[0], QLatin1String("Foo")); + QCOMPARE(pci->infoFields().allFields()[0].fieldValue[0], QLatin1String("FooBar")); + g_boxed_free(TP_ARRAY_TYPE_CONTACT_INFO_FIELD_LIST, info_default); g_boxed_free(TP_ARRAY_TYPE_CONTACT_INFO_FIELD_LIST, info_1); g_boxed_free(TP_ARRAY_TYPE_CONTACT_INFO_FIELD_LIST, info_2); } diff --git a/qt4/tests/lib/glib/contacts-conn.c b/qt4/tests/lib/glib/contacts-conn.c index 3491c1fa2..9b349db58 100644 --- a/qt4/tests/lib/glib/contacts-conn.c +++ b/qt4/tests/lib/glib/contacts-conn.c @@ -159,6 +159,8 @@ tp_tests_contacts_connection_init (TpTestsContactsConnection *self) g_direct_equal, NULL, (GDestroyNotify) free_rcc_list); self->priv->contact_info = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL, (GDestroyNotify) g_ptr_array_unref); + self->priv->default_contact_info = (GPtrArray *) dbus_g_type_specialized_construct ( + TP_ARRAY_TYPE_CONTACT_INFO_FIELD_LIST); } static void @@ -1159,11 +1161,12 @@ my_refresh_contact_info (TpSvcConnectionInterfaceContactInfo *obj, for (i = 0; i < contacts->len; i++) { TpHandle handle = g_array_index (contacts, guint, i); - GPtrArray *arr = lookup_contact_info (self, handle); + // actually update the info (if not using the default info) so there is an actual change + g_hash_table_insert (self->priv->contact_info, GUINT_TO_POINTER (handle), + g_ptr_array_ref (self->priv->default_contact_info)); tp_svc_connection_interface_contact_info_emit_contact_info_changed (self, - handle, arr); - g_ptr_array_unref (arr); + handle, self->priv->default_contact_info); } tp_svc_connection_interface_contact_info_return_from_refresh_contact_info ( |