diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-05-01 16:22:55 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-05-01 16:22:55 +0200 |
commit | 096d14f20f4dc39d20d35d605ca755b66bd48cf9 (patch) | |
tree | 4b28dd3b310ebcfa9cefa1b41992eeefa5456764 /tests/dummyresourcetest.cpp | |
parent | c1475df297975b403d991f69ef9436cd576c1e46 (diff) | |
download | sink-096d14f20f4dc39d20d35d605ca755b66bd48cf9.tar.gz sink-096d14f20f4dc39d20d35d605ca755b66bd48cf9.zip |
Account filter for resources and contains comparator in query
Diffstat (limited to 'tests/dummyresourcetest.cpp')
-rw-r--r-- | tests/dummyresourcetest.cpp | 38 |
1 files changed, 13 insertions, 25 deletions
diff --git a/tests/dummyresourcetest.cpp b/tests/dummyresourcetest.cpp index 33304e1..58df2da 100644 --- a/tests/dummyresourcetest.cpp +++ b/tests/dummyresourcetest.cpp | |||
@@ -12,6 +12,8 @@ | |||
12 | #include "pipeline.h" | 12 | #include "pipeline.h" |
13 | #include "log.h" | 13 | #include "log.h" |
14 | 14 | ||
15 | using namespace Sink; | ||
16 | |||
15 | /** | 17 | /** |
16 | * Test of complete system using the dummy resource. | 18 | * Test of complete system using the dummy resource. |
17 | * | 19 | * |
@@ -62,14 +64,12 @@ private slots: | |||
62 | event.setProperty("summary", "summaryValue"); | 64 | event.setProperty("summary", "summaryValue"); |
63 | Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec().waitForFinished(); | 65 | Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec().waitForFinished(); |
64 | 66 | ||
65 | Sink::Query query; | 67 | const auto query = Query::ResourceFilter("org.kde.dummy.instance1") ; |
66 | query.resources << "org.kde.dummy.instance1"; | ||
67 | 68 | ||
68 | // Ensure all local data is processed | 69 | // Ensure all local data is processed |
69 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 70 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
70 | 71 | ||
71 | query.propertyFilter.insert("uid", "testuid"); | 72 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query + Query::PropertyFilter("uid", "testuid")); |
72 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); | ||
73 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); | 73 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); |
74 | auto value = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Event::Ptr>(); | 74 | auto value = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Event::Ptr>(); |
75 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); | 75 | QCOMPARE(value->getProperty("uid").toByteArray(), QByteArray("testuid")); |
@@ -86,15 +86,12 @@ private slots: | |||
86 | event.setProperty("uid", "testuid2"); | 86 | event.setProperty("uid", "testuid2"); |
87 | Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec().waitForFinished(); | 87 | Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec().waitForFinished(); |
88 | 88 | ||
89 | Sink::Query query; | 89 | const auto query = Query::ResourceFilter("org.kde.dummy.instance1") ; |
90 | query.resources << "org.kde.dummy.instance1"; | ||
91 | 90 | ||
92 | // Ensure all local data is processed | 91 | // Ensure all local data is processed |
93 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 92 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
94 | 93 | ||
95 | query.propertyFilter.insert("uid", "testuid"); | 94 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query + Query::PropertyFilter("uid", "testuid")); |
96 | |||
97 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); | ||
98 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); | 95 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); |
99 | auto value = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Event::Ptr>(); | 96 | auto value = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Event::Ptr>(); |
100 | 97 | ||
@@ -114,15 +111,12 @@ private slots: | |||
114 | event.setProperty("summary", "summaryValue2"); | 111 | event.setProperty("summary", "summaryValue2"); |
115 | Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec().waitForFinished(); | 112 | Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec().waitForFinished(); |
116 | 113 | ||
117 | Sink::Query query; | 114 | const auto query = Query::ResourceFilter("org.kde.dummy.instance1") ; |
118 | query.resources << "org.kde.dummy.instance1"; | ||
119 | 115 | ||
120 | // Ensure all local data is processed | 116 | // Ensure all local data is processed |
121 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 117 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
122 | 118 | ||
123 | query.propertyFilter.insert("summary", "summaryValue2"); | 119 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query + Query::PropertyFilter("summary", "summaryValue2")); |
124 | |||
125 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); | ||
126 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); | 120 | QTRY_COMPARE(model->rowCount(QModelIndex()), 1); |
127 | auto value = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Event::Ptr>(); | 121 | auto value = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Event::Ptr>(); |
128 | 122 | ||
@@ -147,8 +141,7 @@ private slots: | |||
147 | 141 | ||
148 | void testSyncAndFacade() | 142 | void testSyncAndFacade() |
149 | { | 143 | { |
150 | Sink::Query query; | 144 | const auto query = Query::ResourceFilter("org.kde.dummy.instance1"); |
151 | query.resources << "org.kde.dummy.instance1"; | ||
152 | 145 | ||
153 | // Ensure all local data is processed | 146 | // Ensure all local data is processed |
154 | Sink::Store::synchronize(query).exec().waitForFinished(); | 147 | Sink::Store::synchronize(query).exec().waitForFinished(); |
@@ -164,8 +157,7 @@ private slots: | |||
164 | 157 | ||
165 | void testSyncAndFacadeMail() | 158 | void testSyncAndFacadeMail() |
166 | { | 159 | { |
167 | Sink::Query query; | 160 | const auto query = Query::ResourceFilter("org.kde.dummy.instance1"); |
168 | query.resources << "org.kde.dummy.instance1"; | ||
169 | 161 | ||
170 | // Ensure all local data is processed | 162 | // Ensure all local data is processed |
171 | Sink::Store::synchronize(query).exec().waitForFinished(); | 163 | Sink::Store::synchronize(query).exec().waitForFinished(); |
@@ -187,9 +179,7 @@ private slots: | |||
187 | event.setProperty("summary", "summaryValue"); | 179 | event.setProperty("summary", "summaryValue"); |
188 | Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec().waitForFinished(); | 180 | Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec().waitForFinished(); |
189 | 181 | ||
190 | Sink::Query query; | 182 | const auto query = Query::ResourceFilter("org.kde.dummy.instance1") + Query::PropertyFilter("uid", "testuid"); |
191 | query.resources << "org.kde.dummy.instance1"; | ||
192 | query.propertyFilter.insert("uid", "testuid"); | ||
193 | 183 | ||
194 | // Ensure all local data is processed | 184 | // Ensure all local data is processed |
195 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); | 185 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
@@ -238,11 +228,9 @@ private slots: | |||
238 | 228 | ||
239 | void testWriteModifyDeleteLive() | 229 | void testWriteModifyDeleteLive() |
240 | { | 230 | { |
241 | 231 | auto query = Query::ResourceFilter("org.kde.dummy.instance1"); | |
242 | Sink::Query query; | ||
243 | query.resources << "org.kde.dummy.instance1"; | ||
244 | query.liveQuery = true; | 232 | query.liveQuery = true; |
245 | query.propertyFilter.insert("uid", "testuid"); | 233 | query += Query::PropertyFilter("uid", "testuid"); |
246 | 234 | ||
247 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); | 235 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); |
248 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 236 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |