[Telepathy-commits] [telepathy-qt4/master] tests/pinocchio/cm-basics: new test verifying basic operation of ConnectionManager

Simon McVittie simon.mcvittie at collabora.co.uk
Mon Dec 8 07:32:00 PST 2008


---
 tests/pinocchio/Makefile.am   |    4 ++
 tests/pinocchio/cm-basics.cpp |   94 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 98 insertions(+), 0 deletions(-)
 create mode 100644 tests/pinocchio/cm-basics.cpp

diff --git a/tests/pinocchio/Makefile.am b/tests/pinocchio/Makefile.am
index 62d8497..595caf2 100644
--- a/tests/pinocchio/Makefile.am
+++ b/tests/pinocchio/Makefile.am
@@ -8,11 +8,13 @@ EXTRA_DIST = \
 
 TESTS = \
     test-chan-basics \
+    test-cm-basics \
     test-conn-basics \
     test-do-nothing
 
 BUILT_SOURCES = \
     _gen/chan-basics.cpp.moc.hpp \
+    _gen/cm-basics.cpp.moc.hpp \
     _gen/conn-basics.cpp.moc.hpp \
     _gen/do-nothing.cpp.moc.hpp \
     _gen/lib.h.moc.hpp
@@ -25,6 +27,8 @@ noinst_PROGRAMS = $(TESTS)
 
 test_chan_basics_SOURCES = chan-basics.cpp lib.cpp
 
+test_cm_basics_SOURCES = cm-basics.cpp lib.cpp
+
 test_conn_basics_SOURCES = conn-basics.cpp lib.cpp
 
 test_do_nothing_SOURCES = do-nothing.cpp lib.cpp
diff --git a/tests/pinocchio/cm-basics.cpp b/tests/pinocchio/cm-basics.cpp
new file mode 100644
index 0000000..80608f3
--- /dev/null
+++ b/tests/pinocchio/cm-basics.cpp
@@ -0,0 +1,94 @@
+#include <QtCore/QDebug>
+#include <QtCore/QTimer>
+
+#include <QtDBus/QtDBus>
+
+#include <TelepathyQt4/Client/ConnectionManager>
+
+#include <tests/pinocchio/lib.h>
+
+using namespace Telepathy::Client;
+
+class TestCmBasics : public PinocchioTest
+{
+    Q_OBJECT
+
+private:
+    Telepathy::Client::ConnectionManager* mCM;
+
+protected Q_SLOTS:
+    void onCmReady(ConnectionManager*);
+
+private Q_SLOTS:
+    void initTestCase();
+    void init();
+
+    void testBasics();
+
+    void cleanup();
+    void cleanupTestCase();
+};
+
+
+void TestCmBasics::initTestCase()
+{
+    initTestCaseImpl();
+
+    // Wait for the CM to start up
+    QVERIFY(waitForPinocchio(5000));
+}
+
+
+void TestCmBasics::init()
+{
+    initImpl();
+}
+
+
+void TestCmBasics::onCmReady(ConnectionManager* it)
+{
+    if (mCM != it) {
+        qWarning() << "Got the wrong CM pointer";
+        mLoop->exit(1);
+        return;
+    }
+
+    mLoop->exit(0);
+}
+
+
+void TestCmBasics::testBasics()
+{
+    mCM = new ConnectionManager("pinocchio");
+    QCOMPARE(mCM->isReady(), false);
+
+    connect(mCM, SIGNAL(ready(ConnectionManager*)),
+            SLOT(onCmReady(ConnectionManager*)));
+    QCOMPARE(mLoop->exec(), 0);
+    QCOMPARE(mCM->isReady(), true);
+    disconnect(mCM, SIGNAL(ready(ConnectionManager*)),
+            this, SLOT(onCmReady(ConnectionManager*)));
+
+    QCOMPARE(mCM->interfaces(), QStringList());
+    QCOMPARE(mCM->supportedProtocols(), QStringList() << "dummy");
+}
+
+
+void TestCmBasics::cleanup()
+{
+    if (mCM != NULL) {
+        delete mCM;
+        mCM = NULL;
+    }
+    cleanupImpl();
+}
+
+
+void TestCmBasics::cleanupTestCase()
+{
+    cleanupTestCaseImpl();
+}
+
+
+QTEST_MAIN(TestCmBasics)
+#include "_gen/cm-basics.cpp.moc.hpp"
-- 
1.5.6.5




More information about the Telepathy-commits mailing list