diff options
Diffstat (limited to 'tests/accountstest.cpp')
-rw-r--r-- | tests/accountstest.cpp | 34 |
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 | ||
10 | class AccountsTest : public QObject | 12 | class 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 | ||
69 | QTEST_GUILESS_MAIN(AccountsTest) | 103 | QTEST_GUILESS_MAIN(AccountsTest) |