[Telepathy-commits] [telepathy-qt4/master] contacts test: Added fallback test for connection without Contacts interface.
Andre Moreira Magalhaes (andrunko)
andre.magalhaes at collabora.co.uk
Wed Mar 25 10:20:04 PDT 2009
---
tests/dbus/contacts.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 48 insertions(+), 1 deletions(-)
diff --git a/tests/dbus/contacts.cpp b/tests/dbus/contacts.cpp
index 986d7d0..c6d54ac 100644
--- a/tests/dbus/contacts.cpp
+++ b/tests/dbus/contacts.cpp
@@ -18,6 +18,7 @@
#include <telepathy-glib/debug.h>
#include <tests/lib/contacts-conn.h>
+#include <tests/lib/simple-conn.h>
#include <tests/lib/test.h>
using namespace Telepathy::Client;
@@ -48,6 +49,7 @@ private Q_SLOTS:
void testFeatures();
void testFeaturesNotRequested();
void testUpgrade();
+ void testSelfContactFallback();
void cleanup();
void cleanupTestCase();
@@ -138,7 +140,7 @@ void TestContacts::initTestCase()
"protocol", "simple",
0));
QVERIFY(mConnService != 0);
- QVERIFY(tp_base_connection_register(TP_BASE_CONNECTION(mConnService), "simple", &name,
+ QVERIFY(tp_base_connection_register(TP_BASE_CONNECTION(mConnService), "contacts", &name,
&connPath, &error));
QVERIFY(error == 0);
@@ -733,6 +735,51 @@ void TestContacts::testUpgrade()
QVERIFY(!tp_handle_is_valid(serviceRepo, handles[2], NULL));
}
+void TestContacts::testSelfContactFallback()
+{
+ gchar *name;
+ gchar *connPath;
+ GError *error = 0;
+
+ SimpleConnection *connService;
+ connService = SIMPLE_CONNECTION(g_object_new(
+ SIMPLE_TYPE_CONNECTION,
+ "account", "me at example.com",
+ "protocol", "simple",
+ 0));
+ QVERIFY(connService != 0);
+ QVERIFY(tp_base_connection_register(TP_BASE_CONNECTION(connService), "simple", &name,
+ &connPath, &error));
+ QVERIFY(error == 0);
+
+ QVERIFY(name != 0);
+ QVERIFY(connPath != 0);
+
+ Connection *conn = new Connection(name, connPath);
+ g_free(name);
+ g_free(connPath);
+
+ QCOMPARE(conn->isReady(), false);
+
+ conn->requestConnect();
+
+ Features features = Features() << Connection::FeatureSelfContact;
+ QVERIFY(connect(conn->becomeReady(features),
+ SIGNAL(finished(Telepathy::Client::PendingOperation*)),
+ SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation*))));
+ QCOMPARE(mLoop->exec(), 0);
+ QCOMPARE(conn->isReady(features), true);
+
+ ContactPtr selfContact = conn->selfContact();
+ QVERIFY(selfContact != 0);
+
+ QCOMPARE(selfContact->handle()[0], conn->selfHandle());
+ QCOMPARE(selfContact->id(), QString("me at example.com"));
+ QCOMPARE(selfContact->alias(), QString("me at example.com"));
+ QVERIFY(!selfContact->isAvatarTokenKnown());
+ QCOMPARE(selfContact->presenceStatus(), QString("unknown"));
+}
+
void TestContacts::cleanup()
{
cleanupImpl();
--
1.5.6.5
More information about the telepathy-commits
mailing list