[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=cd5f3db
The following commit has been merged in the master branch:
commit cd5f3db9001d29c6de26d8bd5d53856257d5eeb4
Author: George Goldberg <george.goldberg at collabora.co.uk>
Date: Fri Dec 10 22:38:29 2010 +0000
Start to reinstate the unit-tests - this adds ControllerTest class with constructor/destructor tests implemented.
---
kpeople/nepomuk-feeder/CMakeLists.txt | 2 +-
kpeople/nepomuk-feeder/tests/CMakeLists.txt | 26 ++--
kpeople/nepomuk-feeder/tests/controller-test.cpp | 148 +++++++++++++++++++++++
kpeople/nepomuk-feeder/tests/controller-test.h | 91 ++++++++++++++
4 files changed, 255 insertions(+), 12 deletions(-)
diff --git a/kpeople/nepomuk-feeder/CMakeLists.txt b/kpeople/nepomuk-feeder/CMakeLists.txt
index 9b67d60..c2f6660 100644
--- a/kpeople/nepomuk-feeder/CMakeLists.txt
+++ b/kpeople/nepomuk-feeder/CMakeLists.txt
@@ -111,5 +111,5 @@ install_ontology (telepathy telepathy)
find_package (KTelepathyTestLib)
if (KTelepathyTestLib_DIR)
- # add_subdirectory(tests)
+ add_subdirectory(tests)
endif (KTelepathyTestLib_DIR)
diff --git a/kpeople/nepomuk-feeder/tests/CMakeLists.txt b/kpeople/nepomuk-feeder/tests/CMakeLists.txt
index 1a64348..b86d5e8 100644
--- a/kpeople/nepomuk-feeder/tests/CMakeLists.txt
+++ b/kpeople/nepomuk-feeder/tests/CMakeLists.txt
@@ -6,20 +6,24 @@ include_directories(${KTELEPATHYTESTLIB_INCLUDE_DIR})
ktelepathy_setup_test_environment()
# Create our static base test library
-kde4_add_library(tid-base-tests STATIC tid-base-test.cpp)
-target_link_libraries(tid-base-tests
+#kde4_add_library(tid-base-tests STATIC tid-base-test.cpp)
+#target_link_libraries(tid-base-tests
+# ${KTELEPATHYTESTLIB_LIBRARIES}
+# ${QT_QTTEST_LIBRARY}
+# nepomuktelepathyservice-static)
+
+################################
+# Controller test
+kde4_add_executable(controller-test controller-test.cpp)
+target_link_libraries(controller-test
${KTELEPATHYTESTLIB_LIBRARIES}
${QT_QTTEST_LIBRARY}
nepomuktelepathyservice-static)
-
-################################
-# Account test
-kde4_add_executable(account-test account-test.cpp)
-target_link_libraries(account-test tid-base-tests)
-add_ktelepathy_nepomuk_test(AccountTest ${CMAKE_CURRENT_BINARY_DIR}/account-test)
+add_ktelepathy_dbus_test(ControllerTest ${CMAKE_CURRENT_BINARY_DIR}/controller-test)
################################
# Contact test
-kde4_add_executable(contact-test contact-test.cpp)
-target_link_libraries(contact-test tid-base-tests)
-add_ktelepathy_nepomuk_test(ContactTest ${CMAKE_CURRENT_BINARY_DIR}/contact-test)
+#kde4_add_executable(contact-test contact-test.cpp)
+#target_link_libraries(contact-test tid-base-tests)
+#add_ktelepathy_dbus_test(ContactTest ${CMAKE_CURRENT_BINARY_DIR}/contact-test)
+
diff --git a/kpeople/nepomuk-feeder/tests/controller-test.cpp b/kpeople/nepomuk-feeder/tests/controller-test.cpp
new file mode 100644
index 0000000..9ec8a3e
--- /dev/null
+++ b/kpeople/nepomuk-feeder/tests/controller-test.cpp
@@ -0,0 +1,148 @@
+/*
+ * This file is part of telepathy-nepomuk-service
+ *
+ * Copyright (C) 2010 Collabora Ltd. <info at collabora.co.uk>
+ * @author George Goldberg <george.goldberg at collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include "controller-test.h"
+
+#include "controller.h"
+#include "abstract-storage.h"
+
+#include <KDebug>
+
+#include <qtest_kde.h>
+
+#include <TelepathyQt4/PendingAccount>
+#include <TelepathyQt4/PendingReady>
+
+
+FakeStorage::FakeStorage(ControllerTest *test)
+ : m_test(test)
+{
+ kDebug();
+}
+
+FakeStorage::~FakeStorage()
+{
+ kDebug();
+}
+
+void FakeStorage::createAccount(const QString &path, const QString &id, const QString &protocol)
+{
+ Q_UNUSED(path);
+ Q_UNUSED(id);
+ Q_UNUSED(protocol);
+ m_test->constructorDestructorOnAccountCreatedStorage();
+}
+
+void FakeStorage::destroyAccount(const QString &path)
+{
+ Q_UNUSED(path);
+ kDebug();
+ m_test->constructorDestructorOnAccountDestroyedStorage();
+}
+
+
+ControllerTest::ControllerTest(QObject *parent)
+ : Test(parent)
+{
+ kDebug();
+}
+
+ControllerTest::~ControllerTest()
+{
+ kDebug();
+}
+
+void ControllerTest::initTestCase()
+{
+ initTestCaseImpl();
+}
+
+void ControllerTest::testConstructorDestructor()
+{
+ // First step of this test is to create an account on the AM already.
+ m_accountManager = Tp::AccountManager::create();
+
+ connect(m_accountManager->becomeReady(Tp::Features() << Tp::AccountManager::FeatureCore),
+ SIGNAL(finished(Tp::PendingOperation*)),
+ SLOT(constructorDestructorOnAccountManagerReady(Tp::PendingOperation*)));
+
+ 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));
+
+ QCOMPARE(mLoop->exec(), 2);
+
+ // Next test is to destroy the controller, and check the account is destroyed too.
+ constructorDestructorAccountDestroyed = false;
+ m_controller->shutdown();
+ m_controller->deleteLater();
+
+ connect(m_controller, SIGNAL(destroyed()), SLOT(constructorDestructorOnControllerDestroyed()));
+ QCOMPARE(mLoop->exec(), 3);
+ QVERIFY(constructorDestructorAccountDestroyed);
+}
+
+void ControllerTest::constructorDestructorOnAccountManagerReady(Tp::PendingOperation *op)
+{
+ QVERIFY(!op->isError());
+
+ // Now the AM is ready, create an Account on it.
+ connect(m_accountManager->createAccount("test", "test", "test", QVariantMap()),
+ SIGNAL(finished(Tp::PendingOperation*)),
+ SLOT(constructorDestructorOnAccountCreated(Tp::PendingOperation*)));
+}
+
+void ControllerTest::constructorDestructorOnAccountCreated(Tp::PendingOperation *op)
+{
+ QVERIFY(!op->isError());
+
+ // Done. Exit event loop.
+ mLoop->exit(1);
+}
+
+void ControllerTest::constructorDestructorOnAccountCreatedStorage()
+{
+ mLoop->exit(2);
+}
+
+void ControllerTest::constructorDestructorOnAccountDestroyedStorage()
+{
+ kDebug();
+ constructorDestructorAccountDestroyed = true;
+}
+
+void ControllerTest::constructorDestructorOnControllerDestroyed()
+{
+ mLoop->exit(3);
+}
+
+void ControllerTest::cleanupTestCase()
+{
+ cleanupTestCaseImpl();
+}
+
+
+QTEST_KDEMAIN(ControllerTest, GUI)
+
+
+#include "controller-test.moc"
+
diff --git a/kpeople/nepomuk-feeder/tests/controller-test.h b/kpeople/nepomuk-feeder/tests/controller-test.h
new file mode 100644
index 0000000..f9481e9
--- /dev/null
+++ b/kpeople/nepomuk-feeder/tests/controller-test.h
@@ -0,0 +1,91 @@
+/*
+ * This file is part of nepomuktelepathyservice
+ *
+ * Copyright (C) 2010 Collabora Ltd. <info at collabora.co.uk>
+ * @author George Goldberg <george.goldberg at collabora.co.uk>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef TELEPATHY_NEPOMUK_SERVICE_CONTROLLER_TEST_H
+#define TELEPATHY_NEPOMUK_SERVICE_CONTROLLER_TEST_H
+
+#include "abstract-storage.h"
+
+#include <KTelepathy/TestLib/Test>
+
+#include <TelepathyQt4/AccountManager>
+
+class Controller;
+
+namespace Telepathy {
+ class PendingOperation;
+}
+
+class ControllerTest : public Test
+{
+ Q_OBJECT
+
+public:
+ ControllerTest(QObject* parent = 0);
+ virtual ~ControllerTest();
+
+public Q_SLOTS:
+ void constructorDestructorOnAccountManagerReady(Tp::PendingOperation *op);
+ void constructorDestructorOnAccountCreated(Tp::PendingOperation *op);
+ void constructorDestructorOnAccountCreatedStorage();
+ void constructorDestructorOnAccountDestroyedStorage();
+ void constructorDestructorOnControllerDestroyed();
+
+private Q_SLOTS:
+ void initTestCase();
+
+ void testConstructorDestructor();
+ // void testOnNewAccount();
+ // void testSignalRelays();
+
+ void cleanupTestCase();
+
+private:
+ Controller *m_controller;
+
+ bool constructorDestructorAccountDestroyed;
+
+ Tp::AccountManagerPtr m_accountManager;
+};
+
+/**
+ * Fake subclass 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
+{
+ Q_OBJECT
+
+public:
+ FakeStorage(ControllerTest *test);
+ virtual ~FakeStorage();
+
+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;
+};
+
+
+#endif // Include guard
+
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list