summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-04-12 22:03:27 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-04-12 22:03:27 +0200
commit2cbbdaca7c6e96e40b17b6af4672af2b6735bf8e (patch)
tree1ecd446af60b78ac788f7873c8926ee283178d68 /tests
parent68fcd3e123e9c0e345d95728d0c8742e53be940a (diff)
downloadsink-2cbbdaca7c6e96e40b17b6af4672af2b6735bf8e.tar.gz
sink-2cbbdaca7c6e96e40b17b6af4672af2b6735bf8e.zip
Generalized LocalStorageFacade
Diffstat (limited to 'tests')
-rw-r--r--tests/accountstest.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/tests/accountstest.cpp b/tests/accountstest.cpp
index dc74d15..8062bc3 100644
--- a/tests/accountstest.cpp
+++ b/tests/accountstest.cpp
@@ -1,11 +1,13 @@
1#include <QTest> 1#include <QTest>
2#include <QDebug> 2#include <QDebug>
3#include <QSignalSpy> 3#include <QSignalSpy>
4#include <QAbstractItemModel>
4#include <functional> 5#include <functional>
5 6
6#include <test.h> 7#include <test.h>
7#include <store.h> 8#include <store.h>
8#include <log.h> 9#include <log.h>
10#include <configstore.h>
9 11
10class AccountsTest : public QObject 12class AccountsTest : public QObject
11{ 13{
@@ -18,6 +20,12 @@ private slots:
18 Sink::Log::setDebugOutputLevel(Sink::Log::Trace); 20 Sink::Log::setDebugOutputLevel(Sink::Log::Trace);
19 } 21 }
20 22
23 void init()
24 {
25 ConfigStore("accounts").clear();
26 ConfigStore("resources").clear();
27 }
28
21 void testLoad() 29 void testLoad()
22 { 30 {
23 using namespace Sink; 31 using namespace Sink;
@@ -64,6 +72,32 @@ private slots:
64 }) 72 })
65 .exec().waitForFinished(); 73 .exec().waitForFinished();
66 } 74 }
75
76 void testLiveQuery()
77 {
78 using namespace Sink;
79 using namespace Sink::ApplicationDomain;
80
81 auto account = ApplicationDomainType::createEntity<SinkAccount>();
82 account.setProperty("type", "maildir");
83 account.setProperty("name", "name");
84 Store::create(account).exec().waitForFinished();
85
86 Query query;
87 query.liveQuery = true;
88 auto model = Store::loadModel<SinkAccount>(query);
89 QSignalSpy spy(model.data(), &QAbstractItemModel::rowsInserted);
90 QTRY_COMPARE(spy.count(), 1);
91 Store::create(account).exec().waitForFinished();
92 QTRY_COMPARE(spy.count(), 2);
93
94 //Ensure the notifier only affects one type
95 auto resource = ApplicationDomainType::createEntity<SinkResource>();
96 resource.setProperty("type", "org.kde.mailtransport");
97 Store::create(resource).exec().waitForFinished();
98 QTRY_COMPARE(spy.count(), 2);
99 }
100
67}; 101};
68 102
69QTEST_GUILESS_MAIN(AccountsTest) 103QTEST_GUILESS_MAIN(AccountsTest)