From 9c50bfa96354f5e98375df3e89981f1e67a68cd8 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Wed, 6 Jul 2016 17:54:03 +0200 Subject: Test the resourcefactory --- tests/accountstest.cpp | 10 +++++----- tests/resourcecommunicationtest.cpp | 20 ++++++++++++++++++++ 2 files changed, 25 insertions(+), 5 deletions(-) (limited to 'tests') diff --git a/tests/accountstest.cpp b/tests/accountstest.cpp index be5e1a0..5a66305 100644 --- a/tests/accountstest.cpp +++ b/tests/accountstest.cpp @@ -94,8 +94,8 @@ private slots: using namespace Sink::ApplicationDomain; auto account = ApplicationDomainType::createEntity(); - account.setProperty("type", "maildir"); - account.setProperty("name", "name"); + account.setAccountType("maildir"); + account.setName("name"); Store::create(account).exec().waitForFinished(); Query query; @@ -104,14 +104,14 @@ private slots: QTRY_COMPARE(model->rowCount(QModelIndex()), 1); auto account2 = ApplicationDomainType::createEntity(); - account2.setProperty("type", "maildir"); - account2.setProperty("name", "name"); + account2.setAccountType("maildir"); + account2.setName("name"); Store::create(account2).exec().waitForFinished(); QTRY_COMPARE(model->rowCount(QModelIndex()), 2); //Ensure the notifier only affects one type auto resource = ApplicationDomainType::createEntity(); - resource.setProperty("type", "org.kde.mailtransport"); + resource.setResourceType("org.kde.mailtransport"); Store::create(resource).exec().waitForFinished(); QTRY_COMPARE(model->rowCount(QModelIndex()), 2); } diff --git a/tests/resourcecommunicationtest.cpp b/tests/resourcecommunicationtest.cpp index 2874457..1530f63 100644 --- a/tests/resourcecommunicationtest.cpp +++ b/tests/resourcecommunicationtest.cpp @@ -92,6 +92,26 @@ private slots: QTRY_COMPARE(complete, count); QVERIFY(!errors); } + + void testAccessFactory() + { + const QByteArray resourceIdentifier("test"); + Listener listener(resourceIdentifier, ""); + QWeakPointer weakRef; + QTime time; + time.start(); + { + auto resourceAccess = Sink::ResourceAccessFactory::instance().getAccess(resourceIdentifier, ""); + weakRef = resourceAccess.toWeakRef(); + resourceAccess->open(); + resourceAccess->sendCommand(Sink::Commands::PingCommand).then([resourceAccess]() { qDebug() << "Pind complete"; }).exec(); + } + QVERIFY(weakRef.toStrongRef()); + QTRY_VERIFY(!weakRef.toStrongRef()); + qDebug() << "time.elapsed " << time.elapsed(); + QVERIFY(time.elapsed() < 3500); + QVERIFY(time.elapsed() > 2500); + } }; QTEST_MAIN(ResourceCommunicationTest) -- cgit v1.2.3