[SCM] ktp-common-internals packaging branch, master, updated. debian/15.12.1-2-1839-gf0635e9
Maximiliano Curia
maxy at moszumanska.debian.org
Mon May 9 09:07:14 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=195d356
The following commit has been merged in the master branch:
commit 195d3562516fc9c2ad86e825de5477c68b8debde
Author: George Goldberg <george.goldberg at collabora.co.uk>
Date: Mon Jan 3 16:38:44 2011 +0000
Controller Test: Test adding new account to AM after the Controller is up and running.
---
kpeople/nepomuk-feeder/tests/controller-test.cpp | 93 ++++++++++++++++++++++--
kpeople/nepomuk-feeder/tests/controller-test.h | 30 ++++++--
2 files changed, 113 insertions(+), 10 deletions(-)
diff --git a/kpeople/nepomuk-feeder/tests/controller-test.cpp b/kpeople/nepomuk-feeder/tests/controller-test.cpp
index 9ec8a3e..44ea19f 100644
--- a/kpeople/nepomuk-feeder/tests/controller-test.cpp
+++ b/kpeople/nepomuk-feeder/tests/controller-test.cpp
@@ -32,18 +32,20 @@
#include <TelepathyQt4/PendingReady>
-FakeStorage::FakeStorage(ControllerTest *test)
+ConstructorDestructorFakeStorage::ConstructorDestructorFakeStorage(ControllerTest *test)
: m_test(test)
{
kDebug();
}
-FakeStorage::~FakeStorage()
+ConstructorDestructorFakeStorage::~ConstructorDestructorFakeStorage()
{
kDebug();
}
-void FakeStorage::createAccount(const QString &path, const QString &id, const QString &protocol)
+void ConstructorDestructorFakeStorage::createAccount(const QString &path,
+ const QString &id,
+ const QString &protocol)
{
Q_UNUSED(path);
Q_UNUSED(id);
@@ -51,13 +53,40 @@ void FakeStorage::createAccount(const QString &path, const QString &id, const QS
m_test->constructorDestructorOnAccountCreatedStorage();
}
-void FakeStorage::destroyAccount(const QString &path)
+void ConstructorDestructorFakeStorage::destroyAccount(const QString &path)
{
Q_UNUSED(path);
kDebug();
m_test->constructorDestructorOnAccountDestroyedStorage();
}
+OnNewAccountFakeStorage::OnNewAccountFakeStorage(ControllerTest *test)
+: m_test(test)
+{
+ kDebug();
+}
+
+OnNewAccountFakeStorage::~OnNewAccountFakeStorage()
+{
+ kDebug();
+}
+
+void OnNewAccountFakeStorage::createAccount(const QString &path,
+ const QString &id,
+ const QString &protocol)
+{
+ Q_UNUSED(path);
+ Q_UNUSED(id);
+ Q_UNUSED(protocol);
+ m_test->onNewAccountOnAccountCreatedStorage();
+}
+
+void OnNewAccountFakeStorage::destroyAccount(const QString &path)
+{
+ Q_UNUSED(path);
+ kDebug();
+}
+
ControllerTest::ControllerTest(QObject *parent)
: Test(parent)
@@ -87,7 +116,7 @@ void ControllerTest::testConstructorDestructor()
QCOMPARE(mLoop->exec(), 1);
// Now that we have an AM with an Account, we can instantiate the Storage and the Controller
- m_controller = new Controller(new FakeStorage(this));
+ m_controller = new Controller(new ConstructorDestructorFakeStorage(this));
QCOMPARE(mLoop->exec(), 2);
@@ -135,9 +164,63 @@ void ControllerTest::constructorDestructorOnControllerDestroyed()
mLoop->exit(3);
}
+void ControllerTest::testOnNewAccount()
+{
+ // Get an AM and get it ready.
+ m_accountManager = Tp::AccountManager::create();
+
+ connect(m_accountManager->becomeReady(Tp::Features() << Tp::AccountManager::FeatureCore),
+ SIGNAL(finished(Tp::PendingOperation*)),
+ SLOT(onNewAccountOnAccountManagerReady(Tp::PendingOperation*)));
+
+ QCOMPARE(mLoop->exec(), 1);
+
+ // Set up the Controller and Fake Storage
+ m_controller = new Controller(new OnNewAccountFakeStorage(this));
+
+ QVERIFY(m_controller);
+
+ // Add a new Account to the AM.
+ connect(m_accountManager->createAccount("test", "test", "test", QVariantMap()),
+ SIGNAL(finished(Tp::PendingOperation*)),
+ SLOT(onNewAccountOnAccountCreated(Tp::PendingOperation*)));
+
+ QCOMPARE(mLoop->exec(), 2);
+}
+
+void ControllerTest::onNewAccountOnAccountManagerReady(Tp::PendingOperation *op)
+{
+ QVERIFY(!op->isError());
+
+ mLoop->exit(1);
+}
+
+void ControllerTest::onNewAccountOnAccountCreated(Tp::PendingOperation *op)
+{
+ // Check that this actually succeeded.
+ QVERIFY(!op->isError());
+
+ // If it failed, exit the event loop.
+ if (op->isError()) {
+ mLoop->exit(0);
+ }
+}
+
+void ControllerTest::onNewAccountOnAccountCreatedStorage()
+{
+ mLoop->exit(2);
+}
+
void ControllerTest::cleanupTestCase()
{
cleanupTestCaseImpl();
+
+ // Clear re-used member variables.
+ if (m_controller) {
+ m_controller->deleteLater();
+ }
+
+ m_accountManager.reset();
}
diff --git a/kpeople/nepomuk-feeder/tests/controller-test.h b/kpeople/nepomuk-feeder/tests/controller-test.h
index f9481e9..4fd9da9 100644
--- a/kpeople/nepomuk-feeder/tests/controller-test.h
+++ b/kpeople/nepomuk-feeder/tests/controller-test.h
@@ -49,11 +49,15 @@ public Q_SLOTS:
void constructorDestructorOnAccountDestroyedStorage();
void constructorDestructorOnControllerDestroyed();
+ void onNewAccountOnAccountManagerReady(Tp::PendingOperation *op);
+ void onNewAccountOnAccountCreated(Tp::PendingOperation *op);
+ void onNewAccountOnAccountCreatedStorage();
+
private Q_SLOTS:
void initTestCase();
void testConstructorDestructor();
- // void testOnNewAccount();
+ void testOnNewAccount();
// void testSignalRelays();
void cleanupTestCase();
@@ -67,16 +71,32 @@ private:
};
/**
- * Fake subclass of the Storage class that we pass the controller in this unit
+ * Fake subclasses of the Storage class that we pass the controller in this unit
* test to be able to see what slots the controller is calling on it.
*/
-class FakeStorage : public AbstractStorage
+class ConstructorDestructorFakeStorage : public AbstractStorage
+{
+ Q_OBJECT
+
+public:
+ ConstructorDestructorFakeStorage(ControllerTest *test);
+ virtual ~ConstructorDestructorFakeStorage();
+
+public Q_SLOTS:
+ virtual void createAccount(const QString &path, const QString &id, const QString &protocol);
+ virtual void destroyAccount(const QString &path);
+
+private:
+ ControllerTest *m_test;
+};
+
+class OnNewAccountFakeStorage : public AbstractStorage
{
Q_OBJECT
public:
- FakeStorage(ControllerTest *test);
- virtual ~FakeStorage();
+ OnNewAccountFakeStorage(ControllerTest *test);
+ virtual ~OnNewAccountFakeStorage();
public Q_SLOTS:
virtual void createAccount(const QString &path, const QString &id, const QString &protocol);
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list