summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGustavo Pichorim Boiko <gustavo.boiko@collabora.co.uk>2011-08-16 09:47:37 -0700
committerGustavo Pichorim Boiko <gustavo.boiko@collabora.co.uk>2011-08-16 09:47:37 -0700
commit87731f8ec686a972a99a4d659c2658abd128283b (patch)
treec53350faef08d49a91ea1fc519b74b41be30f156
parentff7fd61a787594c5b5d3725a7b379172d92aed80 (diff)
Use TestConnHelper in the accounts test too
-rw-r--r--tests/dbus/accounts-model-accounts.cpp48
1 files changed, 10 insertions, 38 deletions
diff --git a/tests/dbus/accounts-model-accounts.cpp b/tests/dbus/accounts-model-accounts.cpp
index e018a48..f4fa426 100644
--- a/tests/dbus/accounts-model-accounts.cpp
+++ b/tests/dbus/accounts-model-accounts.cpp
@@ -1,4 +1,5 @@
+#include <tests/lib/glib-helpers/test-conn-helper.h>
#include <tests/lib/glib/echo2/conn.h>
#include <QtCore/QEventLoop>
#include <QtTest/QtTest>
@@ -54,9 +55,7 @@ private Q_SLOTS:
private:
Tp::AccountManagerPtr mAM;
- QString mConnName, mConnPath;
- ExampleEcho2Connection *mConnService;
- ConnectionPtr mConn;
+ TestConnHelper *mConn;
Tpy::AccountsModel *mAccountsModel;
bool mAccountCountChanged;
@@ -142,38 +141,13 @@ void TestAccountsModelAccounts::initTestCase()
g_set_prgname("accounts-model-basics");
tp_debug_set_flags("all");
dbus_g_bus_get(DBUS_BUS_STARTER, 0);
- gchar *name;
- gchar *connPath;
- GError *error = 0;
- mConnService = EXAMPLE_ECHO_2_CONNECTION(g_object_new(
+ mConn = new TestConnHelper(this,
EXAMPLE_TYPE_ECHO_2_CONNECTION,
"account", "me@example.com",
- "protocol", "foo",
- NULL));
- QVERIFY(mConnService != 0);
- QVERIFY(tp_base_connection_register(TP_BASE_CONNECTION(mConnService),
- "foo", &name, &connPath, &error));
- QVERIFY(error == 0);
-
- QVERIFY(name != 0);
- QVERIFY(connPath != 0);
-
- mConnName = QLatin1String(name);
- mConnPath = QLatin1String(connPath);
-
- mConn = Connection::create(mConnName, mConnPath,
- ChannelFactory::create(QDBusConnection::sessionBus()),
- ContactFactory::create());
- QVERIFY(connect(mConn->lowlevel()->requestConnect(),
- SIGNAL(finished(Tp::PendingOperation*)),
- SLOT(expectSuccessfulCall(Tp::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
- QCOMPARE(mConn->isReady(), true);
- QCOMPARE(mConn->status(), ConnectionStatusConnected);
-
- g_free(name);
- g_free(connPath);
+ "protocol", "echo2",
+ NULL);
+ QCOMPARE(mConn->connect(), true);
}
void TestAccountsModelAccounts::init()
@@ -255,7 +229,7 @@ void TestAccountsModelAccounts::testBasics()
accPropertiesInterface->Set(
QLatin1String(TELEPATHY_INTERFACE_ACCOUNT),
QLatin1String("Connection"),
- QDBusVariant(mConnPath)),
+ QDBusVariant(mConn->objectPath())),
accountPtr),
SIGNAL(finished(Tp::PendingOperation*)),
SLOT(expectSuccessfulCall(Tp::PendingOperation*))));
@@ -298,12 +272,10 @@ void TestAccountsModelAccounts::cleanup()
void TestAccountsModelAccounts::cleanupTestCase()
{
if (mConn) {
- // Disconnect and wait for invalidated
- QVERIFY(connect(mConn->lowlevel()->requestDisconnect(),
- SIGNAL(finished(Tp::PendingOperation*)),
- SLOT(expectSuccessfulCall(Tp::PendingOperation*))));
- QCOMPARE(mLoop->exec(), 0);
+ QCOMPARE(mConn->disconnect(), true);
+ delete mConn;
}
+
cleanupTestCaseImpl();
}