[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:15 UTC 2016
Gitweb-URL: http://git.debian.org/?p=pkg-kde/applications/ktp-common-internals.git;a=commitdiff;h=af89dda
The following commit has been merged in the master branch:
commit af89ddae84a2a031608e4bc2a037fd0dd45921fd
Author: George Goldberg <george.goldberg at collabora.co.uk>
Date: Tue Jan 4 14:20:28 2011 +0000
Storage Test: add contact alias and presence tests, and fix bug in NepomukStorage that was exposed by these tests.
---
kpeople/nepomuk-feeder/nepomuk-storage.cpp | 8 +-
kpeople/nepomuk-feeder/tests/storage-test.cpp | 169 ++++++++++++++++++++++++++
kpeople/nepomuk-feeder/tests/storage-test.h | 4 +-
3 files changed, 178 insertions(+), 3 deletions(-)
diff --git a/kpeople/nepomuk-feeder/nepomuk-storage.cpp b/kpeople/nepomuk-feeder/nepomuk-storage.cpp
index 4442a9c..7c4a25e 100644
--- a/kpeople/nepomuk-feeder/nepomuk-storage.cpp
+++ b/kpeople/nepomuk-feeder/nepomuk-storage.cpp
@@ -441,7 +441,13 @@ void NepomukStorage::setContactPresence(const QString &path,
// Set the contact presence.
imAccount.setImStatus(presence.status);
imAccount.setStatusTypes(QList<long long int>() << presence.type);
- imAccount.setImStatusMessages(QStringList() << presence.statusMessage);
+
+ QStringList statusMessage;
+ if (!presence.statusMessage.isEmpty()) {
+ statusMessage.append(presence.statusMessage);
+ }
+
+ imAccount.setImStatusMessages(statusMessage);
}
void NepomukStorage::addContactToGroup(const QString &path, const QString &id, const QString &group)
diff --git a/kpeople/nepomuk-feeder/tests/storage-test.cpp b/kpeople/nepomuk-feeder/tests/storage-test.cpp
index 929aaee..4a7a0e4 100644
--- a/kpeople/nepomuk-feeder/tests/storage-test.cpp
+++ b/kpeople/nepomuk-feeder/tests/storage-test.cpp
@@ -555,6 +555,175 @@ void StorageTest::testDestroyContact()
pC2.remove();
}
+void StorageTest::testSetContactAlias()
+{
+ // Create the Storage.
+ m_storage = new NepomukStorage(this);
+ QVERIFY(m_storage);
+
+ QHash<QString, Nepomuk::IMAccount> *accounts = TestBackdoors::nepomukStorageAccounts(m_storage);
+ QHash<ContactIdentifier, ContactResources> *contacts = TestBackdoors::nepomukStorageContacts(m_storage);
+
+ // Create an account on 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);
+
+ // And in Nepomuk...
+ Nepomuk::IMAccount imAcc1 = accounts->value(QLatin1String("/foo/bar/baz"));
+ QVERIFY(imAcc1.exists());
+ QCOMPARE(imAcc1.isAccessedByOf().size(), 0);
+
+ // Create a contact
+ m_storage->createContact(QLatin1String("/foo/bar/baz"),
+ QLatin1String("test at remote-contact.com"));
+
+ // Check the Contact is created.
+ QCOMPARE(TestBackdoors::nepomukStorageAccounts(m_storage)->size(), 1);
+ QCOMPARE(TestBackdoors::nepomukStorageContacts(m_storage)->size(), 1);
+
+ // Check its identifier is correct.
+ ContactIdentifier cId2(QLatin1String("/foo/bar/baz"), QLatin1String("test at remote-contact.com"));
+ QVERIFY(contacts->contains(cId2));
+
+ // Check the Nepomuk resources are created correctly.
+ ContactResources cRes2 = contacts->value(cId2);
+ Nepomuk::IMAccount imAcc2 = cRes2.imAccount();
+ Nepomuk::PersonContact pC2 = cRes2.personContact();
+ QVERIFY(imAcc2.exists());
+ QVERIFY(pC2.exists());
+
+ // Check the Alias is empty.
+ QCOMPARE(imAcc2.imNicknames().size(), 0);
+
+ // Set the alias of the contact.
+ m_storage->setContactAlias(QLatin1String("/foo/bar/baz"),
+ QLatin1String("test at remote-contact.com"),
+ QLatin1String("Test Alias 1"));
+
+ // Check the alias now.
+ QCOMPARE(imAcc2.imNicknames().size(), 1);
+ QCOMPARE(imAcc2.imNicknames().first(), QLatin1String("Test Alias 1"));
+
+ // Change the alias of the contact.
+ m_storage->setContactAlias(QLatin1String("/foo/bar/baz"),
+ QLatin1String("test at remote-contact.com"),
+ QLatin1String("Test Alias 2"));
+
+ // Check the alias now.
+ QCOMPARE(imAcc2.imNicknames().size(), 1);
+ QCOMPARE(imAcc2.imNicknames().first(), QLatin1String("Test Alias 2"));
+
+ // Cleanup the Nepomuk resources used in this test.
+ imAcc1.remove();
+ imAcc2.remove();
+ pC2.remove();
+}
+
+void StorageTest::testSetContactPresence()
+{
+ // Create the Storage.
+ m_storage = new NepomukStorage(this);
+ QVERIFY(m_storage);
+
+ QHash<QString, Nepomuk::IMAccount> *accounts = TestBackdoors::nepomukStorageAccounts(m_storage);
+ QHash<ContactIdentifier, ContactResources> *contacts = TestBackdoors::nepomukStorageContacts(m_storage);
+
+ // Create an account on 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);
+
+ // And in Nepomuk...
+ Nepomuk::IMAccount imAcc1 = accounts->value(QLatin1String("/foo/bar/baz"));
+ QVERIFY(imAcc1.exists());
+ QCOMPARE(imAcc1.isAccessedByOf().size(), 0);
+
+ // Create a contact
+ m_storage->createContact(QLatin1String("/foo/bar/baz"),
+ QLatin1String("test at remote-contact.com"));
+
+ // Check the Contact is created.
+ QCOMPARE(TestBackdoors::nepomukStorageAccounts(m_storage)->size(), 1);
+ QCOMPARE(TestBackdoors::nepomukStorageContacts(m_storage)->size(), 1);
+
+ // Check its identifier is correct.
+ ContactIdentifier cId2(QLatin1String("/foo/bar/baz"), QLatin1String("test at remote-contact.com"));
+ QVERIFY(contacts->contains(cId2));
+
+ // Check the Nepomuk resources are created correctly.
+ ContactResources cRes2 = contacts->value(cId2);
+ Nepomuk::IMAccount imAcc2 = cRes2.imAccount();
+ Nepomuk::PersonContact pC2 = cRes2.personContact();
+ QVERIFY(imAcc2.exists());
+ QVERIFY(pC2.exists());
+
+ // Check the Presence is default.
+ QCOMPARE(imAcc2.imStatus(), QLatin1String("unknown"));
+ QCOMPARE(imAcc2.imStatusMessages().size(), 0);
+ QCOMPARE(imAcc2.statusTypes().size(), 1);
+ QCOMPARE(imAcc2.statusTypes().first(), (long long)Tp::ConnectionPresenceTypeUnknown);
+
+ // Set the presence of the contact.
+ Tp::SimplePresence p1;
+ p1.status = QLatin1String("available");
+ p1.statusMessage = QLatin1String("foo");
+ p1.type = Tp::ConnectionPresenceTypeAvailable;
+ m_storage->setContactPresence(QLatin1String("/foo/bar/baz"),
+ QLatin1String("test at remote-contact.com"),
+ p1);
+
+ // Check the presence now.
+ QCOMPARE(imAcc2.imStatus(), QLatin1String("available"));
+ QCOMPARE(imAcc2.imStatusMessages().size(), 1);
+ QCOMPARE(imAcc2.imStatusMessages().first(), QLatin1String("foo"));
+ QCOMPARE(imAcc2.statusTypes().size(), 1);
+ QCOMPARE(imAcc2.statusTypes().first(), (long long)Tp::ConnectionPresenceTypeAvailable);
+
+ // Change the presence of the contact.
+ Tp::SimplePresence p2;
+ p2.status = QLatin1String("away");
+ p2.statusMessage = QLatin1String("bar");
+ p2.type = Tp::ConnectionPresenceTypeAway;
+ m_storage->setContactPresence(QLatin1String("/foo/bar/baz"),
+ QLatin1String("test at remote-contact.com"),
+ p2);
+
+ // Check the presence now.
+ QCOMPARE(imAcc2.imStatus(), QLatin1String("away"));
+ QCOMPARE(imAcc2.imStatusMessages().size(), 1);
+ QCOMPARE(imAcc2.imStatusMessages().first(), QLatin1String("bar"));
+ QCOMPARE(imAcc2.statusTypes().size(), 1);
+ QCOMPARE(imAcc2.statusTypes().first(), (long long)Tp::ConnectionPresenceTypeAway);
+
+ // Change the presence to one without a message
+ Tp::SimplePresence p3;
+ p3.status = QLatin1String("offline");
+ p3.type = Tp::ConnectionPresenceTypeOffline;
+ m_storage->setContactPresence(QLatin1String("/foo/bar/baz"),
+ QLatin1String("test at remote-contact.com"),
+ p3);
+
+ // Check the presence now.
+ QCOMPARE(imAcc2.imStatus(), QLatin1String("offline"));
+ QCOMPARE(imAcc2.imStatusMessages().size(), 0);
+ QCOMPARE(imAcc2.statusTypes().size(), 1);
+ QCOMPARE(imAcc2.statusTypes().first(), (long long)Tp::ConnectionPresenceTypeOffline);
+
+ // Cleanup the Nepomuk resources used in this test.
+ imAcc1.remove();
+ imAcc2.remove();
+ pC2.remove();
+}
+
void StorageTest::cleanupTestCase()
{
cleanupTestCaseImpl();
diff --git a/kpeople/nepomuk-feeder/tests/storage-test.h b/kpeople/nepomuk-feeder/tests/storage-test.h
index aced8ac..0540d59 100644
--- a/kpeople/nepomuk-feeder/tests/storage-test.h
+++ b/kpeople/nepomuk-feeder/tests/storage-test.h
@@ -46,8 +46,8 @@ private Q_SLOTS:
void testSetAccountCurrentPresence();
void testCreateContact();
void testDestroyContact();
-// void testSetContactAlias();
-// void testSetContactPresence();
+ void testSetContactAlias();
+ void testSetContactPresence();
// void testSetContactBlockedStatus();
// void testSetContactPublishState();
// void testSetContactSubscriptionState();
--
ktp-common-internals packaging
More information about the pkg-kde-commits
mailing list