[Telepathy-commits] [telepathy-qt4/master] Changed tests/dbus/cm-basics.cpp to inherit Test.
Andre Moreira Magalhaes (andrunko)
andre.magalhaes at collabora.co.uk
Tue Jan 27 07:00:11 PST 2009
---
tests/dbus/cm-basics.cpp | 95 ++++++++++++++--------------------------------
1 files changed, 29 insertions(+), 66 deletions(-)
diff --git a/tests/dbus/cm-basics.cpp b/tests/dbus/cm-basics.cpp
index 02970c3..692ca7c 100644
--- a/tests/dbus/cm-basics.cpp
+++ b/tests/dbus/cm-basics.cpp
@@ -12,90 +12,61 @@
#include <telepathy-glib/debug.h>
#include <tests/lib/simple-manager.h>
+#include <tests/lib/test.h>
using namespace Telepathy::Client;
-class TestCmBasics : public QObject
+class TestCmBasics : public Test
{
Q_OBJECT
public:
- QEventLoop *mLoop;
- Telepathy::Client::ConnectionManager* mCM;
- TpBaseConnectionManager *mCmService;
-
-protected Q_SLOTS:
- void expectSuccessfulCall(Telepathy::Client::PendingOperation*);
+ TestCmBasics(QObject *parent = 0)
+ : Test(parent), mCMService(0), mCM(0)
+ { }
private Q_SLOTS:
void initTestCase();
- void init();
void testBasics();
- void cleanup();
void cleanupTestCase();
-};
+private:
+ TpBaseConnectionManager *mCMService;
+ Telepathy::Client::ConnectionManager *mCM;
+};
void TestCmBasics::initTestCase()
{
- Telepathy::registerTypes();
- Telepathy::enableDebug(true);
- Telepathy::enableWarnings(true);
-
- QVERIFY(QDBusConnection::sessionBus().isConnected());
+ initTestCaseImpl();
g_type_init();
g_set_prgname("cm-basics");
tp_debug_set_flags("all");
- mCmService = TP_BASE_CONNECTION_MANAGER(g_object_new(
+ mCMService = TP_BASE_CONNECTION_MANAGER(g_object_new(
SIMPLE_TYPE_CONNECTION_MANAGER,
NULL));
- QVERIFY(mCmService != NULL);
- QVERIFY(tp_base_connection_manager_register (mCmService));
-}
-
-
-void TestCmBasics::init()
-{
- mLoop = new QEventLoop(this);
-}
+ QVERIFY(mCMService != 0);
+ QVERIFY(tp_base_connection_manager_register(mCMService));
-
-void TestCmBasics::expectSuccessfulCall(PendingOperation* op)
-{
- qDebug() << "pending operation finished";
- if (op->isError()) {
- qWarning().nospace() << op->errorName()
- << ": " << op->errorMessage();
- mLoop->exit(1);
- return;
- }
-
- mLoop->exit(0);
+ mCM = new ConnectionManager("simple");
+ QCOMPARE(mCM->isReady(), false);
}
-
void TestCmBasics::testBasics()
{
- mCM = new ConnectionManager("simple");
- QCOMPARE(mCM->isReady(), false);
-
- connect(mCM->becomeReady(),
- SIGNAL(finished(Telepathy::Client::PendingOperation *)),
- this,
- SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation *)));
- qDebug() << "enter main loop";
+ QVERIFY(connect(mCM->becomeReady(),
+ SIGNAL(finished(Telepathy::Client::PendingOperation *)),
+ SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation *))));
QCOMPARE(mLoop->exec(), 0);
QCOMPARE(mCM->isReady(), true);
// calling becomeReady() twice is a no-op
- connect(mCM->becomeReady(),
- SIGNAL(finished(Telepathy::Client::PendingOperation *)),
- this,
- SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation *)));
+ QVERIFY(connect(mCM->becomeReady(),
+ SIGNAL(finished(Telepathy::Client::PendingOperation *)),
+ SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation *))));
QCOMPARE(mLoop->exec(), 0);
QCOMPARE(mCM->isReady(), true);
@@ -123,28 +94,20 @@ void TestCmBasics::testBasics()
QCOMPARE(mCM->supportedProtocols(), QStringList() << "simple");
}
-
-void TestCmBasics::cleanup()
+void TestCmBasics::cleanupTestCase()
{
- if (mCM != NULL) {
+ if (mCM) {
delete mCM;
- mCM = NULL;
+ mCM = 0;
}
- if (mLoop != NULL) {
- delete mLoop;
- mLoop = NULL;
- }
-}
-
-void TestCmBasics::cleanupTestCase()
-{
- if (mCmService != NULL) {
- g_object_unref(mCmService);
- mCmService = NULL;
+ if (mCMService) {
+ g_object_unref(mCMService);
+ mCMService = 0;
}
-}
+ cleanupTestCaseImpl();
+}
QTEST_MAIN(TestCmBasics)
#include "_gen/cm-basics.cpp.moc.hpp"
--
1.5.6.5
More information about the Telepathy-commits
mailing list