[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:18 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=c87db85
The following commit has been merged in the master branch:
commit c87db85a3acfb295247da29df38f6ebd6393a20c
Author: George Goldberg <george.goldberg at collabora.co.uk>
Date: Mon Jan 3 20:19:06 2011 +0000
Storage Test: Add unit test for creating accounts.
---
kpeople/nepomuk-feeder/test-backdoors.cpp | 8 +-
kpeople/nepomuk-feeder/test-backdoors.h | 4 +-
kpeople/nepomuk-feeder/tests/storage-test.cpp | 109 +++++++++++++++++++++++++-
kpeople/nepomuk-feeder/tests/storage-test.h | 1 +
4 files changed, 112 insertions(+), 10 deletions(-)
diff --git a/kpeople/nepomuk-feeder/test-backdoors.cpp b/kpeople/nepomuk-feeder/test-backdoors.cpp
index b1a853d..0c124f6 100644
--- a/kpeople/nepomuk-feeder/test-backdoors.cpp
+++ b/kpeople/nepomuk-feeder/test-backdoors.cpp
@@ -29,20 +29,20 @@ TestBackdoors::nepomukStorageMePersonContact(NepomukStorage *storage)
return storage->m_mePersonContact;
}
-QHash<QString, Nepomuk::IMAccount> &
+QHash<QString, Nepomuk::IMAccount> *
TestBackdoors::nepomukStorageAccounts(NepomukStorage *storage)
{
Q_ASSERT(storage);
- return storage->m_accounts;
+ return &storage->m_accounts;
}
-QHash<ContactIdentifier, ContactResources> &
+QHash<ContactIdentifier, ContactResources> *
TestBackdoors::nepomukStorageContacts(NepomukStorage *storage)
{
Q_ASSERT(storage);
- return storage->m_contacts;
+ return &storage->m_contacts;
}
diff --git a/kpeople/nepomuk-feeder/test-backdoors.h b/kpeople/nepomuk-feeder/test-backdoors.h
index d6ec486..16ad681 100644
--- a/kpeople/nepomuk-feeder/test-backdoors.h
+++ b/kpeople/nepomuk-feeder/test-backdoors.h
@@ -27,8 +27,8 @@
class KDE_EXPORT TestBackdoors {
public:
static Nepomuk::PersonContact nepomukStorageMePersonContact(NepomukStorage *storage);
- static QHash<QString, Nepomuk::IMAccount>& nepomukStorageAccounts(NepomukStorage *storage);
- static QHash<ContactIdentifier, ContactResources>& nepomukStorageContacts(NepomukStorage *storage);
+ static QHash<QString, Nepomuk::IMAccount> *nepomukStorageAccounts(NepomukStorage *storage);
+ static QHash<ContactIdentifier, ContactResources> *nepomukStorageContacts(NepomukStorage *storage);
};
diff --git a/kpeople/nepomuk-feeder/tests/storage-test.cpp b/kpeople/nepomuk-feeder/tests/storage-test.cpp
index fca4b66..61b3f92 100644
--- a/kpeople/nepomuk-feeder/tests/storage-test.cpp
+++ b/kpeople/nepomuk-feeder/tests/storage-test.cpp
@@ -26,6 +26,7 @@
#include <KDebug>
#include <qtest_kde.h>
+#include </home/gberg/development/build/work/collabora/telepathy-kde/ontologies/person.h>
StorageTest::StorageTest(QObject *parent)
: Test(parent),
@@ -54,8 +55,8 @@ void StorageTest::testConstructorDestructor()
QVERIFY(TestBackdoors::nepomukStorageMePersonContact(m_storage).exists());
// Check that the PersonContact and IMAccount lists are empty
- QVERIFY(TestBackdoors::nepomukStorageAccounts(m_storage).isEmpty());
- QVERIFY(TestBackdoors::nepomukStorageContacts(m_storage).isEmpty());
+ QVERIFY(TestBackdoors::nepomukStorageAccounts(m_storage)->isEmpty());
+ QVERIFY(TestBackdoors::nepomukStorageContacts(m_storage)->isEmpty());
// Now destroy the NepomukStorage, running the event loop
// to make sure the destruction is completed.
@@ -71,8 +72,8 @@ void StorageTest::testConstructorDestructor()
QVERIFY(TestBackdoors::nepomukStorageMePersonContact(m_storage).exists());
// Check that the PersonContact and IMAccount lists are empty
- QVERIFY(TestBackdoors::nepomukStorageAccounts(m_storage).isEmpty());
- QVERIFY(TestBackdoors::nepomukStorageContacts(m_storage).isEmpty());
+ QVERIFY(TestBackdoors::nepomukStorageAccounts(m_storage)->isEmpty());
+ QVERIFY(TestBackdoors::nepomukStorageContacts(m_storage)->isEmpty());
// Now destroy the NepomukStorage, running the event loop
// to make sure the destruction is completed.
@@ -82,6 +83,106 @@ void StorageTest::testConstructorDestructor()
QCOMPARE(mLoop->exec(), 0);
}
+void StorageTest::testCreateAccount()
+{
+ m_storage = new NepomukStorage(this);
+ Nepomuk::PersonContact mePersonContact = TestBackdoors::nepomukStorageMePersonContact(m_storage);
+ QHash<QString, Nepomuk::IMAccount> *accounts = TestBackdoors::nepomukStorageAccounts(m_storage);
+
+ QVERIFY(m_storage);
+
+ QVERIFY(mePersonContact.exists());
+ QCOMPARE(mePersonContact.iMAccounts().size(), 0);
+
+ QCOMPARE(TestBackdoors::nepomukStorageAccounts(m_storage)->size(), 0);
+ QCOMPARE(TestBackdoors::nepomukStorageContacts(m_storage)->size(), 0);
+
+ // Test creating an account which is not already in Nepomuk.
+ // Issue the command to the storage
+ m_storage->createAccount(QLatin1String("/foo/bar/baz"),
+ QLatin1String("foo at bar.baz"),
+ QLatin1String("test"));
+
+ // Check the Account is created
+ QCOMPARE(TestBackdoors::nepomukStorageAccounts(m_storage)->size(), 1);
+ QCOMPARE(TestBackdoors::nepomukStorageContacts(m_storage)->size(), 0);
+
+ // Check its properties are correct
+ Nepomuk::IMAccount imAcc1 = accounts->value(QLatin1String("/foo/bar/baz"));
+ QVERIFY(imAcc1.exists());
+ QCOMPARE(imAcc1.imIDs().size(), 1);
+ QCOMPARE(imAcc1.imIDs().first(), QLatin1String("foo at bar.baz"));
+ QCOMPARE(imAcc1.accountIdentifiers().size(), 1);
+ QCOMPARE(imAcc1.accountIdentifiers().first(), QLatin1String("/foo/bar/baz"));
+ QCOMPARE(imAcc1.imAccountTypes().size(), 1);
+ QCOMPARE(imAcc1.imAccountTypes().first(), QLatin1String("test"));
+
+ // Check that it is correctly related to the mePersonContact.
+ QCOMPARE(mePersonContact.iMAccounts().size(), 1);
+
+ // Test creating an account which *is* already in Nepomuk.
+ // Add the account to Nepomuk.
+ Nepomuk::IMAccount imAcc2;
+ imAcc2.setAccountIdentifiers(QStringList() << QLatin1String("/foo/bar/baz/bong"));
+ imAcc2.setImIDs(QStringList() << QLatin1String("foo.bar at baz.bong"));
+ imAcc2.setImAccountTypes(QStringList() << QLatin1String("test"));
+ QVERIFY(imAcc2.exists());
+ mePersonContact.addIMAccount(imAcc2);
+
+ // Now tell the storage about that account.
+ m_storage->createAccount(QLatin1String("/foo/bar/baz/bong"),
+ QLatin1String("foo.bar at baz.bong"),
+ QLatin1String("test"));
+
+ // Check the account is found.
+ QCOMPARE(TestBackdoors::nepomukStorageAccounts(m_storage)->size(), 2);
+ QCOMPARE(TestBackdoors::nepomukStorageContacts(m_storage)->size(), 0);
+
+ // Check its properties are correct
+ Nepomuk::IMAccount imAcc3 = accounts->value(QLatin1String("/foo/bar/baz/bong"));
+ QVERIFY(imAcc3.exists());
+ QCOMPARE(imAcc3.imIDs().size(), 1);
+ QCOMPARE(imAcc3.imIDs().first(), QLatin1String("foo.bar at baz.bong"));
+ QCOMPARE(imAcc3.accountIdentifiers().size(), 1);
+ QCOMPARE(imAcc3.accountIdentifiers().first(), QLatin1String("/foo/bar/baz/bong"));
+ QCOMPARE(imAcc3.imAccountTypes().size(), 1);
+ QCOMPARE(imAcc3.imAccountTypes().first(), QLatin1String("test"));
+ QCOMPARE(imAcc2, imAcc3);
+
+ // Check that it is correctly related to the mePersonContact.
+ QCOMPARE(mePersonContact.iMAccounts().size(), 2);
+
+ // Test creating an account twice (by recreating the first account we created).
+ m_storage->createAccount(QLatin1String("/foo/bar/baz"),
+ QLatin1String("foo at bar.baz"),
+ QLatin1String("test"));
+
+ // Check the Account is created
+ QCOMPARE(TestBackdoors::nepomukStorageAccounts(m_storage)->size(), 2);
+ QCOMPARE(TestBackdoors::nepomukStorageContacts(m_storage)->size(), 0);
+
+ // Check its properties are correct
+ Nepomuk::IMAccount imAcc4 = accounts->value(QLatin1String("/foo/bar/baz"));
+ QVERIFY(imAcc4.exists());
+ QCOMPARE(imAcc4.imIDs().size(), 1);
+ QCOMPARE(imAcc4.imIDs().first(), QLatin1String("foo at bar.baz"));
+ QCOMPARE(imAcc4.accountIdentifiers().size(), 1);
+ QCOMPARE(imAcc4.accountIdentifiers().first(), QLatin1String("/foo/bar/baz"));
+ QCOMPARE(imAcc4.imAccountTypes().size(), 1);
+ QCOMPARE(imAcc4.imAccountTypes().first(), QLatin1String("test"));
+ QCOMPARE(imAcc4, imAcc1);
+
+ // Check that it is correctly related to the mePersonContact.
+ QCOMPARE(mePersonContact.iMAccounts().size(), 2);
+
+ // Question: Should we test for cases where there is data in Nepomuk that would
+ // partially match the query but shouldn't actually match because it is not a complete
+ // set of data wrt telepathy?
+ // Answer: for now, I don't think there's any point - but if an error in the query is found in
+ // the future, then of course we should add a test for that error here to avoid it
+ // regressing in the future (grundleborg).
+}
+
void StorageTest::cleanupTestCase()
{
cleanupTestCaseImpl();
diff --git a/kpeople/nepomuk-feeder/tests/storage-test.h b/kpeople/nepomuk-feeder/tests/storage-test.h
index 475377f..4f9e740 100644
--- a/kpeople/nepomuk-feeder/tests/storage-test.h
+++ b/kpeople/nepomuk-feeder/tests/storage-test.h
@@ -40,6 +40,7 @@ private Q_SLOTS:
void initTestCase();
void testConstructorDestructor();
+ void testCreateAccount();
void cleanupTestCase();
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list