diff options
-rw-r--r-- | tests/accountstest.cpp | 10 | ||||
-rw-r--r-- | tests/resourcecommunicationtest.cpp | 20 |
2 files changed, 25 insertions, 5 deletions
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: | |||
94 | using namespace Sink::ApplicationDomain; | 94 | using namespace Sink::ApplicationDomain; |
95 | 95 | ||
96 | auto account = ApplicationDomainType::createEntity<SinkAccount>(); | 96 | auto account = ApplicationDomainType::createEntity<SinkAccount>(); |
97 | account.setProperty("type", "maildir"); | 97 | account.setAccountType("maildir"); |
98 | account.setProperty("name", "name"); | 98 | account.setName("name"); |
99 | Store::create(account).exec().waitForFinished(); | 99 | Store::create(account).exec().waitForFinished(); |
100 | 100 | ||
101 | Query query; | 101 | Query query; |
@@ -104,14 +104,14 @@ private slots: | |||
104 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); | 104 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); |
105 | 105 | ||
106 | auto account2 = ApplicationDomainType::createEntity<SinkAccount>(); | 106 | auto account2 = ApplicationDomainType::createEntity<SinkAccount>(); |
107 | account2.setProperty("type", "maildir"); | 107 | account2.setAccountType("maildir"); |
108 | account2.setProperty("name", "name"); | 108 | account2.setName("name"); |
109 | Store::create(account2).exec().waitForFinished(); | 109 | Store::create(account2).exec().waitForFinished(); |
110 | QTRY_COMPARE(model->rowCount(QModelIndex()), 2); | 110 | QTRY_COMPARE(model->rowCount(QModelIndex()), 2); |
111 | 111 | ||
112 | //Ensure the notifier only affects one type | 112 | //Ensure the notifier only affects one type |
113 | auto resource = ApplicationDomainType::createEntity<SinkResource>(); | 113 | auto resource = ApplicationDomainType::createEntity<SinkResource>(); |
114 | resource.setProperty("type", "org.kde.mailtransport"); | 114 | resource.setResourceType("org.kde.mailtransport"); |
115 | Store::create(resource).exec().waitForFinished(); | 115 | Store::create(resource).exec().waitForFinished(); |
116 | QTRY_COMPARE(model->rowCount(QModelIndex()), 2); | 116 | QTRY_COMPARE(model->rowCount(QModelIndex()), 2); |
117 | } | 117 | } |
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: | |||
92 | QTRY_COMPARE(complete, count); | 92 | QTRY_COMPARE(complete, count); |
93 | QVERIFY(!errors); | 93 | QVERIFY(!errors); |
94 | } | 94 | } |
95 | |||
96 | void testAccessFactory() | ||
97 | { | ||
98 | const QByteArray resourceIdentifier("test"); | ||
99 | Listener listener(resourceIdentifier, ""); | ||
100 | QWeakPointer<Sink::ResourceAccess> weakRef; | ||
101 | QTime time; | ||
102 | time.start(); | ||
103 | { | ||
104 | auto resourceAccess = Sink::ResourceAccessFactory::instance().getAccess(resourceIdentifier, ""); | ||
105 | weakRef = resourceAccess.toWeakRef(); | ||
106 | resourceAccess->open(); | ||
107 | resourceAccess->sendCommand(Sink::Commands::PingCommand).then<void>([resourceAccess]() { qDebug() << "Pind complete"; }).exec(); | ||
108 | } | ||
109 | QVERIFY(weakRef.toStrongRef()); | ||
110 | QTRY_VERIFY(!weakRef.toStrongRef()); | ||
111 | qDebug() << "time.elapsed " << time.elapsed(); | ||
112 | QVERIFY(time.elapsed() < 3500); | ||
113 | QVERIFY(time.elapsed() > 2500); | ||
114 | } | ||
95 | }; | 115 | }; |
96 | 116 | ||
97 | QTEST_MAIN(ResourceCommunicationTest) | 117 | QTEST_MAIN(ResourceCommunicationTest) |