[Telepathy-commits] [telepathy-qt4/master] Added automated test for account-manager.

Andre Moreira Magalhaes (andrunko) andre.magalhaes at collabora.co.uk
Wed Jan 7 13:17:56 PST 2009


---
 tests/dbus/Makefile.am        |    4 ++
 tests/dbus/account-basics.cpp |   95 +++++++++++++++++++++++++++++++++++++++++
 2 files changed, 99 insertions(+), 0 deletions(-)
 create mode 100644 tests/dbus/account-basics.cpp

diff --git a/tests/dbus/Makefile.am b/tests/dbus/Makefile.am
index 915bc61..6054e18 100644
--- a/tests/dbus/Makefile.am
+++ b/tests/dbus/Makefile.am
@@ -1,9 +1,11 @@
 # Tests each run under their own temporary dbus-daemon.
 
 TESTS = \
+    test-account-basics \
     test-do-nothing
 
 BUILT_SOURCES = \
+    _gen/account-basics.moc.hpp \
     _gen/do-nothing.moc.hpp
 
 _gen/%.moc.hpp: %.cpp
@@ -12,6 +14,8 @@ _gen/%.moc.hpp: %.cpp
 
 noinst_PROGRAMS = $(TESTS)
 
+test_account_basics_SOURCES = account-basics.cpp
+
 test_do_nothing_SOURCES = do-nothing.cpp
 
 LDADD = \
diff --git a/tests/dbus/account-basics.cpp b/tests/dbus/account-basics.cpp
new file mode 100644
index 0000000..20cdadb
--- /dev/null
+++ b/tests/dbus/account-basics.cpp
@@ -0,0 +1,95 @@
+#include <QtCore/QEventLoop>
+#include <QtTest/QtTest>
+
+#include <TelepathyQt4/Debug>
+#include <TelepathyQt4/Types>
+#include <TelepathyQt4/Client/AccountManager>
+#include <TelepathyQt4/Client/PendingOperation>
+
+using namespace Telepathy;
+using namespace Telepathy::Client;
+
+class TestAccountBasics : public QObject
+{
+    Q_OBJECT
+
+public:
+    TestAccountBasics(QObject *parent = 0);
+    ~TestAccountBasics();
+
+protected Q_SLOTS:
+    void expectSuccessfulCall(Telepathy::Client::PendingOperation *);
+
+private Q_SLOTS:
+    void init();
+
+    void testBasics();
+
+    void cleanup();
+
+private:
+    QEventLoop *mLoop;
+    AccountManager *mAccount;
+};
+
+TestAccountBasics::TestAccountBasics(QObject *parent)
+    : QObject(parent),
+      mLoop(new QEventLoop(this)),
+      mAccount(0)
+{
+}
+
+TestAccountBasics::~TestAccountBasics()
+{
+    delete mLoop;
+}
+
+void TestAccountBasics::expectSuccessfulCall(PendingOperation *operation)
+{
+    if (operation->isError()) {
+        qWarning().nospace() << operation->errorName()
+            << ": " << operation->errorMessage();
+        mLoop->exit(1);
+        return;
+    }
+
+    mLoop->exit(0);
+}
+
+void TestAccountBasics::init()
+{
+    Telepathy::registerTypes();
+    Telepathy::enableDebug(true);
+    Telepathy::enableWarnings(true);
+}
+
+void TestAccountBasics::testBasics()
+{
+    mAccount = new AccountManager();
+    QCOMPARE(mAccount->isReady(), false);
+
+    connect(mAccount->becomeReady(),
+            SIGNAL(finished(Telepathy::Client::PendingOperation *)),
+            this,
+            SLOT(expectSuccessfulCall(Telepathy::Client::PendingOperation *)));
+    qDebug() << "enter main loop";
+    QCOMPARE(mLoop->exec(), 0);
+    QCOMPARE(mAccount->isReady(), true);
+
+    QCOMPARE(mAccount->interfaces(), QStringList());
+
+    QCOMPARE(mAccount->validAccountPaths(), ObjectPathList());
+    QCOMPARE(mAccount->invalidAccountPaths(), ObjectPathList());
+    QCOMPARE(mAccount->allAccountPaths(), ObjectPathList());
+}
+
+void TestAccountBasics::cleanup()
+{
+    if (mAccount) {
+        delete mAccount;
+        mAccount = 0;
+    }
+}
+
+QTEST_MAIN(TestAccountBasics)
+#include "_gen/account-basics.moc.hpp"
-- 
1.5.6.5



More information about the Telepathy-commits mailing list