diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/CMakeLists.txt | 4 | ||||
-rw-r--r-- | tests/clientapitest.cpp | 2 | ||||
-rw-r--r-- | tests/databasepopulationandfacadequerybenchmark.cpp | 15 | ||||
-rw-r--r-- | tests/domainadaptortest.cpp | 2 | ||||
-rw-r--r-- | tests/dummyresourcebenchmark.cpp | 47 | ||||
-rw-r--r-- | tests/dummyresourcetest.cpp | 38 | ||||
-rw-r--r-- | tests/dummyresourcewritebenchmark.cpp | 3 | ||||
-rw-r--r-- | tests/hawd/CMakeLists.txt | 2 | ||||
-rw-r--r-- | tests/hawd/dataset.cpp | 4 | ||||
-rw-r--r-- | tests/indextest.cpp | 2 | ||||
-rw-r--r-- | tests/inspectiontest.cpp | 18 | ||||
-rw-r--r-- | tests/maildirresourcetest.cpp | 157 | ||||
-rw-r--r-- | tests/messagequeuetest.cpp | 2 | ||||
-rw-r--r-- | tests/modelinteractivitytest.cpp | 11 | ||||
-rw-r--r-- | tests/pipelinetest.cpp | 14 | ||||
-rw-r--r-- | tests/querytest.cpp | 23 |
16 files changed, 212 insertions, 132 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index b01a329..b8ee5a5 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt | |||
@@ -15,7 +15,7 @@ macro(manual_tests) | |||
15 | add_executable(${_testname} ${_testname}.cpp testimplementations.cpp getrssusage.cpp) | 15 | add_executable(${_testname} ${_testname}.cpp testimplementations.cpp getrssusage.cpp) |
16 | generate_flatbuffers(${_testname} calendar) | 16 | generate_flatbuffers(${_testname} calendar) |
17 | qt5_use_modules(${_testname} Core Test Concurrent) | 17 | qt5_use_modules(${_testname} Core Test Concurrent) |
18 | target_link_libraries(${_testname} sinkcommon libhawd) | 18 | target_link_libraries(${_testname} sink libhawd) |
19 | endforeach(_testname) | 19 | endforeach(_testname) |
20 | endmacro(manual_tests) | 20 | endmacro(manual_tests) |
21 | 21 | ||
@@ -25,7 +25,7 @@ macro(auto_tests) | |||
25 | generate_flatbuffers(${_testname} calendar) | 25 | generate_flatbuffers(${_testname} calendar) |
26 | add_test(${_testname} ${_testname}) | 26 | add_test(${_testname} ${_testname}) |
27 | qt5_use_modules(${_testname} Core Test Concurrent) | 27 | qt5_use_modules(${_testname} Core Test Concurrent) |
28 | target_link_libraries(${_testname} sinkcommon libhawd) | 28 | target_link_libraries(${_testname} sink libhawd) |
29 | endforeach(_testname) | 29 | endforeach(_testname) |
30 | endmacro(auto_tests) | 30 | endmacro(auto_tests) |
31 | 31 | ||
diff --git a/tests/clientapitest.cpp b/tests/clientapitest.cpp index a85b03b..0e21ca6 100644 --- a/tests/clientapitest.cpp +++ b/tests/clientapitest.cpp | |||
@@ -2,7 +2,7 @@ | |||
2 | #include <QDebug> | 2 | #include <QDebug> |
3 | #include <functional> | 3 | #include <functional> |
4 | 4 | ||
5 | #include "clientapi.h" | 5 | #include "store.h" |
6 | #include "facade.h" | 6 | #include "facade.h" |
7 | #include "resourceconfig.h" | 7 | #include "resourceconfig.h" |
8 | #include "modelresult.h" | 8 | #include "modelresult.h" |
diff --git a/tests/databasepopulationandfacadequerybenchmark.cpp b/tests/databasepopulationandfacadequerybenchmark.cpp index 8581c49..63daebc 100644 --- a/tests/databasepopulationandfacadequerybenchmark.cpp +++ b/tests/databasepopulationandfacadequerybenchmark.cpp | |||
@@ -10,7 +10,10 @@ | |||
10 | #include <common/synclistresult.h> | 10 | #include <common/synclistresult.h> |
11 | #include <common/definitions.h> | 11 | #include <common/definitions.h> |
12 | #include <common/query.h> | 12 | #include <common/query.h> |
13 | #include <common/clientapi.h> | 13 | #include <common/store.h> |
14 | |||
15 | #include "hawd/dataset.h" | ||
16 | #include "hawd/formatter.h" | ||
14 | 17 | ||
15 | #include <iostream> | 18 | #include <iostream> |
16 | #include <math.h> | 19 | #include <math.h> |
@@ -31,6 +34,7 @@ class DatabasePopulationAndFacadeQueryBenchmark : public QObject | |||
31 | QByteArray identifier; | 34 | QByteArray identifier; |
32 | QList<double> mRssGrowthPerEntity; | 35 | QList<double> mRssGrowthPerEntity; |
33 | QList<double> mTimePerEntity; | 36 | QList<double> mTimePerEntity; |
37 | HAWD::State mHawdState; | ||
34 | 38 | ||
35 | void populateDatabase(int count) | 39 | void populateDatabase(int count) |
36 | { | 40 | { |
@@ -40,7 +44,7 @@ class DatabasePopulationAndFacadeQueryBenchmark : public QObject | |||
40 | { | 44 | { |
41 | Sink::Storage storage(Sink::storageLocation(), identifier, Sink::Storage::ReadWrite); | 45 | Sink::Storage storage(Sink::storageLocation(), identifier, Sink::Storage::ReadWrite); |
42 | auto transaction = storage.createTransaction(Sink::Storage::ReadWrite); | 46 | auto transaction = storage.createTransaction(Sink::Storage::ReadWrite); |
43 | auto db = transaction.openDatabase("event.main"); | 47 | auto db = Sink::Storage::mainDatabase(transaction, "event"); |
44 | 48 | ||
45 | int bufferSizeTotal = 0; | 49 | int bufferSizeTotal = 0; |
46 | int keysSizeTotal = 0; | 50 | int keysSizeTotal = 0; |
@@ -129,6 +133,13 @@ class DatabasePopulationAndFacadeQueryBenchmark : public QObject | |||
129 | std::cout << "Rss without db [kb]: " << rssWithoutDb/1024 << std::endl; | 133 | std::cout << "Rss without db [kb]: " << rssWithoutDb/1024 << std::endl; |
130 | std::cout << "Percentage error: " << percentageRssError << std::endl; | 134 | std::cout << "Percentage error: " << percentageRssError << std::endl; |
131 | 135 | ||
136 | HAWD::Dataset dataset("facade_query", mHawdState); | ||
137 | HAWD::Dataset::Row row = dataset.row(); | ||
138 | row.setValue("rows", list.size()); | ||
139 | row.setValue("queryTimePerResult", (qreal)list.size()/elapsed); | ||
140 | dataset.insertRow(row); | ||
141 | HAWD::Formatter::print(dataset); | ||
142 | |||
132 | mTimePerEntity << static_cast<double>(elapsed)/static_cast<double>(count); | 143 | mTimePerEntity << static_cast<double>(elapsed)/static_cast<double>(count); |
133 | mRssGrowthPerEntity << rssGrowthPerEntity; | 144 | mRssGrowthPerEntity << rssGrowthPerEntity; |
134 | 145 | ||
diff --git a/tests/domainadaptortest.cpp b/tests/domainadaptortest.cpp index ff8f639..f523173 100644 --- a/tests/domainadaptortest.cpp +++ b/tests/domainadaptortest.cpp | |||
@@ -5,7 +5,7 @@ | |||
5 | #include <QDebug> | 5 | #include <QDebug> |
6 | 6 | ||
7 | #include "dummyresource/resourcefactory.h" | 7 | #include "dummyresource/resourcefactory.h" |
8 | #include "clientapi.h" | 8 | #include "store.h" |
9 | 9 | ||
10 | #include "common/domainadaptor.h" | 10 | #include "common/domainadaptor.h" |
11 | #include "common/entitybuffer.h" | 11 | #include "common/entitybuffer.h" |
diff --git a/tests/dummyresourcebenchmark.cpp b/tests/dummyresourcebenchmark.cpp index e511613..9afc775 100644 --- a/tests/dummyresourcebenchmark.cpp +++ b/tests/dummyresourcebenchmark.cpp | |||
@@ -4,12 +4,15 @@ | |||
4 | 4 | ||
5 | #include "dummyresource/resourcefactory.h" | 5 | #include "dummyresource/resourcefactory.h" |
6 | #include "dummyresource/domainadaptor.h" | 6 | #include "dummyresource/domainadaptor.h" |
7 | #include "clientapi.h" | 7 | #include "store.h" |
8 | #include "notifier.h" | ||
9 | #include "resourcecontrol.h" | ||
8 | #include "commands.h" | 10 | #include "commands.h" |
9 | #include "entitybuffer.h" | 11 | #include "entitybuffer.h" |
10 | #include "pipeline.h" | 12 | #include "pipeline.h" |
11 | #include "log.h" | 13 | #include "log.h" |
12 | #include "resourceconfig.h" | 14 | #include "resourceconfig.h" |
15 | #include "notification_generated.h" | ||
13 | 16 | ||
14 | #include "hawd/dataset.h" | 17 | #include "hawd/dataset.h" |
15 | #include "hawd/formatter.h" | 18 | #include "hawd/formatter.h" |
@@ -71,9 +74,43 @@ private Q_SLOTS: | |||
71 | }); | 74 | }); |
72 | } | 75 | } |
73 | 76 | ||
77 | //Ensure we can process a command in less than 0.1s | ||
78 | void testCommandResponsiveness() | ||
79 | { | ||
80 | //Test responsiveness including starting the process. | ||
81 | Sink::Store::removeDataFromDisk("org.kde.dummy.instance1").exec().waitForFinished(); | ||
82 | |||
83 | QTime time; | ||
84 | time.start(); | ||
85 | |||
86 | Sink::ApplicationDomain::Event event("org.kde.dummy.instance1"); | ||
87 | event.setProperty("uid", "testuid"); | ||
88 | QCOMPARE(event.getProperty("uid").toByteArray(), QByteArray("testuid")); | ||
89 | event.setProperty("summary", "summaryValue"); | ||
90 | |||
91 | auto notifier = QSharedPointer<Sink::Notifier>::create("org.kde.dummy.instance1"); | ||
92 | bool gotNotification = false; | ||
93 | int duration = 0; | ||
94 | notifier->registerHandler([&gotNotification, &duration, &time](const Sink::Notification ¬ification) { | ||
95 | if (notification.type == Sink::Commands::NotificationType::NotificationType_RevisionUpdate) { | ||
96 | gotNotification = true; | ||
97 | duration = time.elapsed(); | ||
98 | } | ||
99 | }); | ||
100 | |||
101 | Sink::Store::create<Sink::ApplicationDomain::Event>(event).exec(); | ||
102 | |||
103 | //Wait for notification | ||
104 | QTRY_VERIFY(gotNotification); | ||
105 | |||
106 | QVERIFY2(duration < 100, QString::fromLatin1("Processing a create command took more than 100ms: %1").arg(duration).toLatin1()); | ||
107 | Sink::ResourceControl::shutdown("org.kde.dummy.instance1").exec().waitForFinished(); | ||
108 | qDebug() << "Single command took [ms]: " << duration; | ||
109 | } | ||
110 | |||
74 | void testWriteToFacade() | 111 | void testWriteToFacade() |
75 | { | 112 | { |
76 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | 113 | Sink::Store::removeDataFromDisk("org.kde.dummy.instance1").exec().waitForFinished(); |
77 | 114 | ||
78 | QTime time; | 115 | QTime time; |
79 | time.start(); | 116 | time.start(); |
@@ -92,7 +129,7 @@ private Q_SLOTS: | |||
92 | { | 129 | { |
93 | Sink::Query query; | 130 | Sink::Query query; |
94 | query.resources << "org.kde.dummy.instance1"; | 131 | query.resources << "org.kde.dummy.instance1"; |
95 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 132 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
96 | } | 133 | } |
97 | auto allProcessedTime = time.elapsed(); | 134 | auto allProcessedTime = time.elapsed(); |
98 | 135 | ||
@@ -138,7 +175,7 @@ private Q_SLOTS: | |||
138 | 175 | ||
139 | void testWriteInProcess() | 176 | void testWriteInProcess() |
140 | { | 177 | { |
141 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | 178 | Sink::Store::removeDataFromDisk("org.kde.dummy.instance1").exec().waitForFinished(); |
142 | QTime time; | 179 | QTime time; |
143 | time.start(); | 180 | time.start(); |
144 | 181 | ||
@@ -226,7 +263,7 @@ private Q_SLOTS: | |||
226 | //This allows to run individual parts without doing a cleanup, but still cleaning up normally | 263 | //This allows to run individual parts without doing a cleanup, but still cleaning up normally |
227 | void testCleanupForCompleteTest() | 264 | void testCleanupForCompleteTest() |
228 | { | 265 | { |
229 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | 266 | Sink::Store::removeDataFromDisk("org.kde.dummy.instance1").exec().waitForFinished(); |
230 | } | 267 | } |
231 | 268 | ||
232 | private: | 269 | private: |
diff --git a/tests/dummyresourcetest.cpp b/tests/dummyresourcetest.cpp index 82c713d..7d9ad24 100644 --- a/tests/dummyresourcetest.cpp +++ b/tests/dummyresourcetest.cpp | |||
@@ -3,10 +3,11 @@ | |||
3 | #include <QString> | 3 | #include <QString> |
4 | 4 | ||
5 | #include "dummyresource/resourcefactory.h" | 5 | #include "dummyresource/resourcefactory.h" |
6 | #include "clientapi.h" | 6 | #include "store.h" |
7 | #include "commands.h" | 7 | #include "commands.h" |
8 | #include "entitybuffer.h" | 8 | #include "entitybuffer.h" |
9 | #include "resourceconfig.h" | 9 | #include "resourceconfig.h" |
10 | #include "resourcecontrol.h" | ||
10 | #include "modelresult.h" | 11 | #include "modelresult.h" |
11 | #include "pipeline.h" | 12 | #include "pipeline.h" |
12 | #include "log.h" | 13 | #include "log.h" |
@@ -19,6 +20,9 @@ | |||
19 | class DummyResourceTest : public QObject | 20 | class DummyResourceTest : public QObject |
20 | { | 21 | { |
21 | Q_OBJECT | 22 | Q_OBJECT |
23 | |||
24 | QTime time; | ||
25 | |||
22 | private Q_SLOTS: | 26 | private Q_SLOTS: |
23 | void initTestCase() | 27 | void initTestCase() |
24 | { | 28 | { |
@@ -29,20 +33,18 @@ private Q_SLOTS: | |||
29 | ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); | 33 | ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); |
30 | } | 34 | } |
31 | 35 | ||
32 | void cleanup() | ||
33 | { | ||
34 | Sink::Store::shutdown(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | ||
35 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | ||
36 | auto factory = Sink::ResourceFactory::load("org.kde.dummy"); | ||
37 | QVERIFY(factory); | ||
38 | Sink::Store::start(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | ||
39 | } | ||
40 | |||
41 | void init() | 36 | void init() |
42 | { | 37 | { |
43 | qDebug(); | 38 | qDebug(); |
44 | qDebug() << "-----------------------------------------"; | 39 | qDebug() << "-----------------------------------------"; |
45 | qDebug(); | 40 | qDebug(); |
41 | time.start(); | ||
42 | } | ||
43 | |||
44 | void cleanup() | ||
45 | { | ||
46 | qDebug() << "Test took " << time.elapsed(); | ||
47 | Sink::Store::removeDataFromDisk(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | ||
46 | } | 48 | } |
47 | 49 | ||
48 | void testProperty() | 50 | void testProperty() |
@@ -64,7 +66,7 @@ private Q_SLOTS: | |||
64 | query.resources << "org.kde.dummy.instance1"; | 66 | query.resources << "org.kde.dummy.instance1"; |
65 | 67 | ||
66 | //Ensure all local data is processed | 68 | //Ensure all local data is processed |
67 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 69 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
68 | 70 | ||
69 | query.propertyFilter.insert("uid", "testuid"); | 71 | query.propertyFilter.insert("uid", "testuid"); |
70 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); | 72 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); |
@@ -88,7 +90,7 @@ private Q_SLOTS: | |||
88 | query.resources << "org.kde.dummy.instance1"; | 90 | query.resources << "org.kde.dummy.instance1"; |
89 | 91 | ||
90 | //Ensure all local data is processed | 92 | //Ensure all local data is processed |
91 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 93 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
92 | 94 | ||
93 | query.propertyFilter.insert("uid", "testuid"); | 95 | query.propertyFilter.insert("uid", "testuid"); |
94 | 96 | ||
@@ -116,7 +118,7 @@ private Q_SLOTS: | |||
116 | query.resources << "org.kde.dummy.instance1"; | 118 | query.resources << "org.kde.dummy.instance1"; |
117 | 119 | ||
118 | //Ensure all local data is processed | 120 | //Ensure all local data is processed |
119 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 121 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
120 | 122 | ||
121 | query.propertyFilter.insert("summary", "summaryValue2"); | 123 | query.propertyFilter.insert("summary", "summaryValue2"); |
122 | 124 | ||
@@ -150,7 +152,7 @@ private Q_SLOTS: | |||
150 | 152 | ||
151 | //Ensure all local data is processed | 153 | //Ensure all local data is processed |
152 | Sink::Store::synchronize(query).exec().waitForFinished(); | 154 | Sink::Store::synchronize(query).exec().waitForFinished(); |
153 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 155 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
154 | 156 | ||
155 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); | 157 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Event>(query); |
156 | QTRY_VERIFY(model->rowCount(QModelIndex()) >= 1); | 158 | QTRY_VERIFY(model->rowCount(QModelIndex()) >= 1); |
@@ -167,7 +169,7 @@ private Q_SLOTS: | |||
167 | 169 | ||
168 | //Ensure all local data is processed | 170 | //Ensure all local data is processed |
169 | Sink::Store::synchronize(query).exec().waitForFinished(); | 171 | Sink::Store::synchronize(query).exec().waitForFinished(); |
170 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 172 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
171 | 173 | ||
172 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); | 174 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
173 | QTRY_VERIFY(model->rowCount(QModelIndex()) >= 1); | 175 | QTRY_VERIFY(model->rowCount(QModelIndex()) >= 1); |
@@ -190,7 +192,7 @@ private Q_SLOTS: | |||
190 | query.propertyFilter.insert("uid", "testuid"); | 192 | query.propertyFilter.insert("uid", "testuid"); |
191 | 193 | ||
192 | //Ensure all local data is processed | 194 | //Ensure all local data is processed |
193 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 195 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
194 | 196 | ||
195 | //Test create | 197 | //Test create |
196 | Sink::ApplicationDomain::Event event2; | 198 | Sink::ApplicationDomain::Event event2; |
@@ -209,7 +211,7 @@ private Q_SLOTS: | |||
209 | Sink::Store::modify<Sink::ApplicationDomain::Event>(event2).exec().waitForFinished(); | 211 | Sink::Store::modify<Sink::ApplicationDomain::Event>(event2).exec().waitForFinished(); |
210 | 212 | ||
211 | //Ensure all local data is processed | 213 | //Ensure all local data is processed |
212 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 214 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
213 | 215 | ||
214 | //Test modify | 216 | //Test modify |
215 | { | 217 | { |
@@ -224,7 +226,7 @@ private Q_SLOTS: | |||
224 | Sink::Store::remove<Sink::ApplicationDomain::Event>(event2).exec().waitForFinished(); | 226 | Sink::Store::remove<Sink::ApplicationDomain::Event>(event2).exec().waitForFinished(); |
225 | 227 | ||
226 | //Ensure all local data is processed | 228 | //Ensure all local data is processed |
227 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 229 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
228 | 230 | ||
229 | //Test remove | 231 | //Test remove |
230 | { | 232 | { |
diff --git a/tests/dummyresourcewritebenchmark.cpp b/tests/dummyresourcewritebenchmark.cpp index 1a8893b..6c05a1e 100644 --- a/tests/dummyresourcewritebenchmark.cpp +++ b/tests/dummyresourcewritebenchmark.cpp | |||
@@ -6,7 +6,7 @@ | |||
6 | 6 | ||
7 | #include "dummyresource/resourcefactory.h" | 7 | #include "dummyresource/resourcefactory.h" |
8 | #include "dummyresource/domainadaptor.h" | 8 | #include "dummyresource/domainadaptor.h" |
9 | #include "clientapi.h" | 9 | #include "store.h" |
10 | #include "commands.h" | 10 | #include "commands.h" |
11 | #include "entitybuffer.h" | 11 | #include "entitybuffer.h" |
12 | #include "pipeline.h" | 12 | #include "pipeline.h" |
@@ -120,6 +120,7 @@ class DummyResourceWriteBenchmark : public QObject | |||
120 | resource.processCommand(Sink::Commands::CreateEntityCommand, command); | 120 | resource.processCommand(Sink::Commands::CreateEntityCommand, command); |
121 | } | 121 | } |
122 | auto appendTime = time.elapsed(); | 122 | auto appendTime = time.elapsed(); |
123 | Q_UNUSED(appendTime); | ||
123 | auto bufferSizeTotal = bufferSize * num; | 124 | auto bufferSizeTotal = bufferSize * num; |
124 | 125 | ||
125 | //Wait until all messages have been processed | 126 | //Wait until all messages have been processed |
diff --git a/tests/hawd/CMakeLists.txt b/tests/hawd/CMakeLists.txt index 268e7a9..d754726 100644 --- a/tests/hawd/CMakeLists.txt +++ b/tests/hawd/CMakeLists.txt | |||
@@ -26,7 +26,7 @@ set(SRCS | |||
26 | add_library(lib${PROJECT_NAME} SHARED ${lib_SRCS}) | 26 | add_library(lib${PROJECT_NAME} SHARED ${lib_SRCS}) |
27 | generate_export_header(lib${PROJECT_NAME} BASE_NAME HAWD EXPORT_FILE_NAME hawd_export.h) | 27 | generate_export_header(lib${PROJECT_NAME} BASE_NAME HAWD EXPORT_FILE_NAME hawd_export.h) |
28 | qt5_use_modules(lib${PROJECT_NAME} Core) | 28 | qt5_use_modules(lib${PROJECT_NAME} Core) |
29 | target_link_libraries(lib${PROJECT_NAME} sinkcommon) | 29 | target_link_libraries(lib${PROJECT_NAME} sink) |
30 | if (LIBGIT2_FOUND) | 30 | if (LIBGIT2_FOUND) |
31 | target_link_libraries(lib${PROJECT_NAME} ${LIBGIT2_LIBRARIES}) | 31 | target_link_libraries(lib${PROJECT_NAME} ${LIBGIT2_LIBRARIES}) |
32 | endif(LIBGIT2_FOUND) | 32 | endif(LIBGIT2_FOUND) |
diff --git a/tests/hawd/dataset.cpp b/tests/hawd/dataset.cpp index fd931e8..372a4b6 100644 --- a/tests/hawd/dataset.cpp +++ b/tests/hawd/dataset.cpp | |||
@@ -216,8 +216,8 @@ QString Dataset::Row::toString(const QStringList &cols, int standardCols, const | |||
216 | Dataset::Dataset(const QString &name, const State &state) | 216 | Dataset::Dataset(const QString &name, const State &state) |
217 | : m_definition(state.datasetDefinition(name)), | 217 | : m_definition(state.datasetDefinition(name)), |
218 | m_storage(state.resultsPath(), name, Sink::Storage::ReadWrite), | 218 | m_storage(state.resultsPath(), name, Sink::Storage::ReadWrite), |
219 | m_commitHash(state.commitHash()), | 219 | m_transaction(std::move(m_storage.createTransaction())), |
220 | m_transaction(std::move(m_storage.createTransaction())) | 220 | m_commitHash(state.commitHash()) |
221 | { | 221 | { |
222 | } | 222 | } |
223 | 223 | ||
diff --git a/tests/indextest.cpp b/tests/indextest.cpp index 7ec95ce..a435e97 100644 --- a/tests/indextest.cpp +++ b/tests/indextest.cpp | |||
@@ -3,7 +3,7 @@ | |||
3 | #include <QString> | 3 | #include <QString> |
4 | #include <QQueue> | 4 | #include <QQueue> |
5 | 5 | ||
6 | #include "clientapi.h" | 6 | #include "store.h" |
7 | #include "storage.h" | 7 | #include "storage.h" |
8 | #include "index.h" | 8 | #include "index.h" |
9 | 9 | ||
diff --git a/tests/inspectiontest.cpp b/tests/inspectiontest.cpp index c876aa9..79e5863 100644 --- a/tests/inspectiontest.cpp +++ b/tests/inspectiontest.cpp | |||
@@ -3,7 +3,8 @@ | |||
3 | #include <QString> | 3 | #include <QString> |
4 | 4 | ||
5 | #include "dummyresource/resourcefactory.h" | 5 | #include "dummyresource/resourcefactory.h" |
6 | #include "clientapi.h" | 6 | #include "store.h" |
7 | #include "resourcecontrol.h" | ||
7 | #include "resourceconfig.h" | 8 | #include "resourceconfig.h" |
8 | #include "log.h" | 9 | #include "log.h" |
9 | 10 | ||
@@ -21,17 +22,8 @@ private Q_SLOTS: | |||
21 | Sink::Log::setDebugOutputLevel(Sink::Log::Trace); | 22 | Sink::Log::setDebugOutputLevel(Sink::Log::Trace); |
22 | auto factory = Sink::ResourceFactory::load("org.kde.dummy"); | 23 | auto factory = Sink::ResourceFactory::load("org.kde.dummy"); |
23 | QVERIFY(factory); | 24 | QVERIFY(factory); |
24 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | ||
25 | ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); | 25 | ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); |
26 | } | 26 | Sink::Store::removeDataFromDisk(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); |
27 | |||
28 | void cleanup() | ||
29 | { | ||
30 | Sink::Store::shutdown(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | ||
31 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | ||
32 | auto factory = Sink::ResourceFactory::load("org.kde.dummy"); | ||
33 | QVERIFY(factory); | ||
34 | Sink::Store::start(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | ||
35 | } | 27 | } |
36 | 28 | ||
37 | void testInspection_data() | 29 | void testInspection_data() |
@@ -50,8 +42,8 @@ private Q_SLOTS: | |||
50 | Mail mail(QByteArray("org.kde.dummy.instance1"), QByteArray("identifier"), 0, QSharedPointer<MemoryBufferAdaptor::MemoryBufferAdaptor>::create()); | 42 | Mail mail(QByteArray("org.kde.dummy.instance1"), QByteArray("identifier"), 0, QSharedPointer<MemoryBufferAdaptor::MemoryBufferAdaptor>::create()); |
51 | 43 | ||
52 | //testInspection is a magic property that the dummyresource supports | 44 | //testInspection is a magic property that the dummyresource supports |
53 | auto inspectionCommand = Resources::Inspection::PropertyInspection(mail, "testInspection", success); | 45 | auto inspectionCommand = ResourceControl::Inspection::PropertyInspection(mail, "testInspection", success); |
54 | auto result = Resources::inspect<Mail>(inspectionCommand).exec(); | 46 | auto result = ResourceControl::inspect<Mail>(inspectionCommand).exec(); |
55 | result.waitForFinished(); | 47 | result.waitForFinished(); |
56 | if (success) { | 48 | if (success) { |
57 | QVERIFY(!result.errorCode()); | 49 | QVERIFY(!result.errorCode()); |
diff --git a/tests/maildirresourcetest.cpp b/tests/maildirresourcetest.cpp index 6ad6ca6..28a1d44 100644 --- a/tests/maildirresourcetest.cpp +++ b/tests/maildirresourcetest.cpp | |||
@@ -3,7 +3,8 @@ | |||
3 | #include <QString> | 3 | #include <QString> |
4 | 4 | ||
5 | #include "maildirresource/maildirresource.h" | 5 | #include "maildirresource/maildirresource.h" |
6 | #include "clientapi.h" | 6 | #include "store.h" |
7 | #include "resourcecontrol.h" | ||
7 | #include "commands.h" | 8 | #include "commands.h" |
8 | #include "entitybuffer.h" | 9 | #include "entitybuffer.h" |
9 | #include "resourceconfig.h" | 10 | #include "resourceconfig.h" |
@@ -68,7 +69,7 @@ private Q_SLOTS: | |||
68 | 69 | ||
69 | void cleanup() | 70 | void cleanup() |
70 | { | 71 | { |
71 | Sink::Store::shutdown(QByteArray("org.kde.maildir.instance1")).exec().waitForFinished(); | 72 | Sink::ResourceControl::shutdown(QByteArray("org.kde.maildir.instance1")).exec().waitForFinished(); |
72 | MaildirResource::removeFromDisk("org.kde.maildir.instance1"); | 73 | MaildirResource::removeFromDisk("org.kde.maildir.instance1"); |
73 | QDir dir(targetPath); | 74 | QDir dir(targetPath); |
74 | dir.removeRecursively(); | 75 | dir.removeRecursively(); |
@@ -80,7 +81,7 @@ private Q_SLOTS: | |||
80 | qDebug() << "-----------------------------------------"; | 81 | qDebug() << "-----------------------------------------"; |
81 | qDebug(); | 82 | qDebug(); |
82 | copyRecursively(TESTDATAPATH "/maildir1", targetPath); | 83 | copyRecursively(TESTDATAPATH "/maildir1", targetPath); |
83 | Sink::Store::start(QByteArray("org.kde.maildir.instance1")).exec().waitForFinished(); | 84 | Sink::ResourceControl::start(QByteArray("org.kde.maildir.instance1")).exec().waitForFinished(); |
84 | } | 85 | } |
85 | 86 | ||
86 | void testListFolders() | 87 | void testListFolders() |
@@ -90,7 +91,7 @@ private Q_SLOTS: | |||
90 | 91 | ||
91 | //Ensure all local data is processed | 92 | //Ensure all local data is processed |
92 | Sink::Store::synchronize(query).exec().waitForFinished(); | 93 | Sink::Store::synchronize(query).exec().waitForFinished(); |
93 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 94 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
94 | 95 | ||
95 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); | 96 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
96 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 97 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
@@ -105,7 +106,7 @@ private Q_SLOTS: | |||
105 | 106 | ||
106 | //Ensure all local data is processed | 107 | //Ensure all local data is processed |
107 | Sink::Store::synchronize(query).exec().waitForFinished(); | 108 | Sink::Store::synchronize(query).exec().waitForFinished(); |
108 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 109 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
109 | 110 | ||
110 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); | 111 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
111 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 112 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
@@ -123,7 +124,7 @@ private Q_SLOTS: | |||
123 | //Ensure all local data is processed | 124 | //Ensure all local data is processed |
124 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); | 125 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); |
125 | Store::synchronize(query).exec().waitForFinished(); | 126 | Store::synchronize(query).exec().waitForFinished(); |
126 | Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 127 | ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
127 | auto result = Store::fetchOne<Folder>( | 128 | auto result = Store::fetchOne<Folder>( |
128 | Query::ResourceFilter("org.kde.maildir.instance1") + Query::RequestedProperties(QByteArrayList() << "name") | 129 | Query::ResourceFilter("org.kde.maildir.instance1") + Query::RequestedProperties(QByteArrayList() << "name") |
129 | ) | 130 | ) |
@@ -149,7 +150,7 @@ private Q_SLOTS: | |||
149 | 150 | ||
150 | //Ensure all local data is processed | 151 | //Ensure all local data is processed |
151 | Sink::Store::synchronize(query).exec().waitForFinished(); | 152 | Sink::Store::synchronize(query).exec().waitForFinished(); |
152 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 153 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
153 | 154 | ||
154 | auto mailModel = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); | 155 | auto mailModel = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
155 | QTRY_VERIFY(mailModel->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 156 | QTRY_VERIFY(mailModel->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
@@ -158,6 +159,9 @@ private Q_SLOTS: | |||
158 | QVERIFY(!mail->getProperty("subject").toString().isEmpty()); | 159 | QVERIFY(!mail->getProperty("subject").toString().isEmpty()); |
159 | QVERIFY(!mail->getProperty("mimeMessage").toString().isEmpty()); | 160 | QVERIFY(!mail->getProperty("mimeMessage").toString().isEmpty()); |
160 | QVERIFY(mail->getProperty("date").toDateTime().isValid()); | 161 | QVERIFY(mail->getProperty("date").toDateTime().isValid()); |
162 | |||
163 | QFileInfo info(mail->getProperty("mimeMessage").toString()); | ||
164 | QVERIFY(info.exists()); | ||
161 | } | 165 | } |
162 | 166 | ||
163 | 167 | ||
@@ -169,7 +173,7 @@ private Q_SLOTS: | |||
169 | 173 | ||
170 | //Ensure all local data is processed | 174 | //Ensure all local data is processed |
171 | Sink::Store::synchronize(query).exec().waitForFinished(); | 175 | Sink::Store::synchronize(query).exec().waitForFinished(); |
172 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 176 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
173 | 177 | ||
174 | auto targetPath = tempDir.path() + "/maildir1/"; | 178 | auto targetPath = tempDir.path() + "/maildir1/"; |
175 | QDir dir(targetPath); | 179 | QDir dir(targetPath); |
@@ -177,7 +181,7 @@ private Q_SLOTS: | |||
177 | 181 | ||
178 | //Ensure all local data is processed | 182 | //Ensure all local data is processed |
179 | Sink::Store::synchronize(query).exec().waitForFinished(); | 183 | Sink::Store::synchronize(query).exec().waitForFinished(); |
180 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 184 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
181 | 185 | ||
182 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); | 186 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
183 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 187 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
@@ -193,11 +197,11 @@ private Q_SLOTS: | |||
193 | 197 | ||
194 | //Ensure all local data is processed | 198 | //Ensure all local data is processed |
195 | Sink::Store::synchronize(query).exec().waitForFinished(); | 199 | Sink::Store::synchronize(query).exec().waitForFinished(); |
196 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 200 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
197 | 201 | ||
198 | //Ensure all local data is processed | 202 | //Ensure all local data is processed |
199 | Sink::Store::synchronize(query).exec().waitForFinished(); | 203 | Sink::Store::synchronize(query).exec().waitForFinished(); |
200 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 204 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
201 | 205 | ||
202 | auto mailModel = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); | 206 | auto mailModel = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
203 | QTRY_VERIFY(mailModel->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 207 | QTRY_VERIFY(mailModel->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
@@ -212,7 +216,7 @@ private Q_SLOTS: | |||
212 | 216 | ||
213 | //Ensure all local data is processed | 217 | //Ensure all local data is processed |
214 | Sink::Store::synchronize(query).exec().waitForFinished(); | 218 | Sink::Store::synchronize(query).exec().waitForFinished(); |
215 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 219 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
216 | 220 | ||
217 | auto targetPath = tempDir.path() + "/maildir1/cur/1365777830.R28.localhost.localdomain:2,S"; | 221 | auto targetPath = tempDir.path() + "/maildir1/cur/1365777830.R28.localhost.localdomain:2,S"; |
218 | QFile file(targetPath); | 222 | QFile file(targetPath); |
@@ -220,7 +224,7 @@ private Q_SLOTS: | |||
220 | 224 | ||
221 | //Ensure all local data is processed | 225 | //Ensure all local data is processed |
222 | Sink::Store::synchronize(query).exec().waitForFinished(); | 226 | Sink::Store::synchronize(query).exec().waitForFinished(); |
223 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 227 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
224 | 228 | ||
225 | auto mailModel = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); | 229 | auto mailModel = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
226 | QTRY_VERIFY(mailModel->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 230 | QTRY_VERIFY(mailModel->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
@@ -233,7 +237,7 @@ private Q_SLOTS: | |||
233 | query.resources << "org.kde.maildir.instance1"; | 237 | query.resources << "org.kde.maildir.instance1"; |
234 | 238 | ||
235 | //Ensure all local data is processed | 239 | //Ensure all local data is processed |
236 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 240 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
237 | 241 | ||
238 | Sink::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); | 242 | Sink::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); |
239 | folder.setProperty("name", "testCreateFolder"); | 243 | folder.setProperty("name", "testCreateFolder"); |
@@ -241,7 +245,7 @@ private Q_SLOTS: | |||
241 | Sink::Store::create(folder).exec().waitForFinished(); | 245 | Sink::Store::create(folder).exec().waitForFinished(); |
242 | 246 | ||
243 | //Ensure all local data is processed | 247 | //Ensure all local data is processed |
244 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 248 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
245 | 249 | ||
246 | auto targetPath = tempDir.path() + "/maildir1/testCreateFolder"; | 250 | auto targetPath = tempDir.path() + "/maildir1/testCreateFolder"; |
247 | QFileInfo file(targetPath); | 251 | QFileInfo file(targetPath); |
@@ -259,7 +263,7 @@ private Q_SLOTS: | |||
259 | Sink::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); | 263 | Sink::ApplicationDomain::Folder folder("org.kde.maildir.instance1"); |
260 | folder.setProperty("name", "testCreateFolder"); | 264 | folder.setProperty("name", "testCreateFolder"); |
261 | Sink::Store::create(folder).exec().waitForFinished(); | 265 | Sink::Store::create(folder).exec().waitForFinished(); |
262 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 266 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
263 | QTRY_VERIFY(QFileInfo(targetPath).exists()); | 267 | QTRY_VERIFY(QFileInfo(targetPath).exists()); |
264 | 268 | ||
265 | Sink::Query folderQuery; | 269 | Sink::Query folderQuery; |
@@ -271,7 +275,7 @@ private Q_SLOTS: | |||
271 | auto createdFolder = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>(); | 275 | auto createdFolder = model->index(0, 0, QModelIndex()).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>(); |
272 | 276 | ||
273 | Sink::Store::remove(*createdFolder).exec().waitForFinished(); | 277 | Sink::Store::remove(*createdFolder).exec().waitForFinished(); |
274 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 278 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
275 | QTRY_VERIFY(!QFileInfo(targetPath).exists()); | 279 | QTRY_VERIFY(!QFileInfo(targetPath).exists()); |
276 | } | 280 | } |
277 | 281 | ||
@@ -281,15 +285,16 @@ private Q_SLOTS: | |||
281 | query.resources << "org.kde.maildir.instance1"; | 285 | query.resources << "org.kde.maildir.instance1"; |
282 | 286 | ||
283 | //Ensure all local data is processed | 287 | //Ensure all local data is processed |
284 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 288 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
285 | 289 | ||
286 | Sink::ApplicationDomain::Mail mail("org.kde.maildir.instance1"); | 290 | Sink::ApplicationDomain::Mail mail("org.kde.maildir.instance1"); |
287 | mail.setProperty("name", "testCreateMail"); | 291 | mail.setProperty("name", "testCreateMail"); |
292 | //FIXME instead of properties, ensure the mimeMessage property is used and the file is moved as expected | ||
288 | 293 | ||
289 | Sink::Store::create(mail).exec().waitForFinished(); | 294 | Sink::Store::create(mail).exec().waitForFinished(); |
290 | 295 | ||
291 | //Ensure all local data is processed | 296 | //Ensure all local data is processed |
292 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 297 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
293 | 298 | ||
294 | auto targetPath = tempDir.path() + "/maildir1/new"; | 299 | auto targetPath = tempDir.path() + "/maildir1/new"; |
295 | QDir dir(targetPath); | 300 | QDir dir(targetPath); |
@@ -304,29 +309,28 @@ private Q_SLOTS: | |||
304 | 309 | ||
305 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); | 310 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); |
306 | Store::synchronize(query).exec().waitForFinished(); | 311 | Store::synchronize(query).exec().waitForFinished(); |
307 | Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 312 | ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
308 | 313 | ||
309 | auto result = Store::fetchOne<Folder>( | 314 | auto result = Store::fetchOne<Folder>( |
310 | Query::ResourceFilter("org.kde.maildir.instance1") + Query::PropertyFilter("name", "maildir1") + Query::RequestedProperties(QByteArrayList() << "name") | 315 | Query::ResourceFilter("org.kde.maildir.instance1") + Query::PropertyFilter("name", "maildir1") + Query::RequestedProperties(QByteArrayList() << "name") |
316 | ) | ||
317 | .then<void, KAsync::Job<void>, Folder>([query](const Folder &folder) { | ||
318 | return Store::fetchAll<Mail>( | ||
319 | Query::PropertyFilter("folder", folder) + Query::RequestedProperties(QByteArrayList() << "folder" << "subject") | ||
311 | ) | 320 | ) |
312 | .then<void, KAsync::Job<void>, Folder>([query](const Folder &folder) { | 321 | .then<void, KAsync::Job<void>, QList<Mail::Ptr> >([query](const QList<Mail::Ptr> &mails) { |
313 | return Store::fetchAll<Mail>( | 322 | //Can't use QCOMPARE because it tries to return FIXME Implement ASYNCCOMPARE |
314 | Query::PropertyFilter("folder", folder) + Query::RequestedProperties(QByteArrayList() << "folder" << "subject") | 323 | if (mails.size() != 1) { |
315 | ) | 324 | return KAsync::error<void>(1, "Wrong number of mails."); |
316 | .then<void, KAsync::Job<void>, QList<Mail::Ptr> >([query](const QList<Mail::Ptr> &mails) { | 325 | } |
317 | //Can't use QCOMPARE because it tries to return FIXME Implement ASYNCCOMPARE | 326 | auto mail = mails.first(); |
318 | if (mails.size() != 1) { | 327 | |
319 | return KAsync::error<void>(1, "Wrong number of mails."); | 328 | return Store::remove(*mail) |
320 | } | 329 | .then(ResourceControl::flushReplayQueue(query.resources)) //The change needs to be replayed already |
321 | auto mail = mails.first(); | 330 | .then(ResourceControl::inspect<Mail>(ResourceControl::Inspection::ExistenceInspection(*mail, false))); |
322 | 331 | }); | |
323 | return Store::remove(*mail) | 332 | }) |
324 | .then(Store::flushReplayQueue(query.resources)) //The change needs to be replayed already | 333 | .exec(); |
325 | .then(Resources::inspect<Mail>(Resources::Inspection::ExistenceInspection(*mail, false))); | ||
326 | }) | ||
327 | .then<void>([](){}); | ||
328 | }) | ||
329 | .exec(); | ||
330 | result.waitForFinished(); | 334 | result.waitForFinished(); |
331 | QVERIFY(!result.errorCode()); | 335 | QVERIFY(!result.errorCode()); |
332 | } | 336 | } |
@@ -338,33 +342,64 @@ private Q_SLOTS: | |||
338 | 342 | ||
339 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); | 343 | auto query = Query::ResourceFilter("org.kde.maildir.instance1"); |
340 | Store::synchronize(query).exec().waitForFinished(); | 344 | Store::synchronize(query).exec().waitForFinished(); |
341 | Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 345 | ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
346 | |||
347 | Folder f; | ||
342 | 348 | ||
343 | auto result = Store::fetchOne<Folder>( | 349 | auto result = Store::fetchOne<Folder>( |
344 | Query::ResourceFilter("org.kde.maildir.instance1") + Query::PropertyFilter("name", "maildir1") + Query::RequestedProperties(QByteArrayList() << "name") | 350 | Query::ResourceFilter("org.kde.maildir.instance1") + Query::PropertyFilter("name", "maildir1") + Query::RequestedProperties(QByteArrayList() << "name") |
351 | ) | ||
352 | .then<void, KAsync::Job<void>, Folder>([query, &f](const Folder &folder) { | ||
353 | f = folder; | ||
354 | return Store::fetchAll<Mail>( | ||
355 | Query::ResourceFilter("org.kde.maildir.instance1") + Query::PropertyFilter("folder", folder) + Query::RequestedProperties(QByteArrayList() << "folder" << "subject") | ||
345 | ) | 356 | ) |
346 | .then<void, KAsync::Job<void>, Folder>([query](const Folder &folder) { | 357 | .then<void, KAsync::Job<void>, QList<Mail::Ptr> >([query](const QList<Mail::Ptr> &mails) { |
347 | Trace() << "Found a folder" << folder.identifier(); | 358 | //Can't use QCOMPARE because it tries to return FIXME Implement ASYNCCOMPARE |
348 | return Store::fetchAll<Mail>( | 359 | if (mails.size() != 1) { |
349 | Query::PropertyFilter("folder", folder) + Query::RequestedProperties(QByteArrayList() << "folder" << "subject") | 360 | return KAsync::error<void>(1, "Wrong number of mails."); |
350 | ) | 361 | } |
351 | .then<void, KAsync::Job<void>, QList<Mail::Ptr> >([query](const QList<Mail::Ptr> &mails) { | 362 | auto mail = mails.first(); |
352 | //Can't use QCOMPARE because it tries to return FIXME Implement ASYNCCOMPARE | 363 | mail->setProperty("unread", true); |
353 | if (mails.size() != 1) { | 364 | return Store::modify(*mail) |
354 | return KAsync::error<void>(1, "Wrong number of mails."); | 365 | .then<void>(ResourceControl::flushReplayQueue(query.resources)) //The change needs to be replayed already |
355 | } | 366 | .then(ResourceControl::inspect<Mail>(ResourceControl::Inspection::PropertyInspection(*mail, "unread", true))) |
356 | auto mail = mails.first(); | 367 | .then(ResourceControl::inspect<Mail>(ResourceControl::Inspection::PropertyInspection(*mail, "subject", mail->getProperty("subject")))); |
357 | mail->setProperty("unread", true); | 368 | }); |
358 | auto inspectionCommand = Resources::Inspection::PropertyInspection(*mail, "unread", true); | 369 | }) |
359 | return Store::modify(*mail) | 370 | .exec(); |
360 | .then<void>(Store::flushReplayQueue(query.resources)) //The change needs to be replayed already | ||
361 | .then(Resources::inspect<Mail>(inspectionCommand)); | ||
362 | }) | ||
363 | .then<void>([](){}); | ||
364 | }) | ||
365 | .exec(); | ||
366 | result.waitForFinished(); | 371 | result.waitForFinished(); |
367 | QVERIFY(!result.errorCode()); | 372 | QVERIFY(!result.errorCode()); |
373 | |||
374 | //Verify that we can still query for all relevant information | ||
375 | auto result2 = Store::fetchAll<Mail>( | ||
376 | Query::ResourceFilter("org.kde.maildir.instance1") + Query::PropertyFilter("folder", f) + Query::RequestedProperties(QByteArrayList() << "folder" << "subject" << "mimeMessage" << "unread") | ||
377 | ) | ||
378 | .then<void, KAsync::Job<void>, QList<Mail::Ptr> >([](const QList<Mail::Ptr> &mails) { | ||
379 | //Can't use QCOMPARE because it tries to return FIXME Implement ASYNCCOMPARE | ||
380 | if (mails.size() != 1) { | ||
381 | qWarning() << "Wrong number of mails"; | ||
382 | return KAsync::error<void>(1, "Wrong number of mails."); | ||
383 | } | ||
384 | auto mail = mails.first(); | ||
385 | if (mail->getProperty("subject").toString().isEmpty()) { | ||
386 | qWarning() << "Wrong subject"; | ||
387 | return KAsync::error<void>(1, "Wrong subject."); | ||
388 | } | ||
389 | if (mail->getProperty("unread").toBool() != true) { | ||
390 | qWarning() << "Not unread"; | ||
391 | return KAsync::error<void>(1, "Not unread."); | ||
392 | } | ||
393 | QFileInfo info(mail->getProperty("mimeMessage").toString()); | ||
394 | if (!info.exists()) { | ||
395 | qWarning() << "Wrong subject"; | ||
396 | return KAsync::error<void>(1, "Can't find mime message."); | ||
397 | } | ||
398 | return KAsync::null<void>(); | ||
399 | }) | ||
400 | .exec(); | ||
401 | result2.waitForFinished(); | ||
402 | QVERIFY(!result2.errorCode()); | ||
368 | } | 403 | } |
369 | 404 | ||
370 | }; | 405 | }; |
diff --git a/tests/messagequeuetest.cpp b/tests/messagequeuetest.cpp index c835b53..454ace2 100644 --- a/tests/messagequeuetest.cpp +++ b/tests/messagequeuetest.cpp | |||
@@ -3,7 +3,7 @@ | |||
3 | #include <QString> | 3 | #include <QString> |
4 | #include <QQueue> | 4 | #include <QQueue> |
5 | 5 | ||
6 | #include "clientapi.h" | 6 | #include "store.h" |
7 | #include "storage.h" | 7 | #include "storage.h" |
8 | #include "messagequeue.h" | 8 | #include "messagequeue.h" |
9 | #include "log.h" | 9 | #include "log.h" |
diff --git a/tests/modelinteractivitytest.cpp b/tests/modelinteractivitytest.cpp index 14c9fd0..3f6e697 100644 --- a/tests/modelinteractivitytest.cpp +++ b/tests/modelinteractivitytest.cpp | |||
@@ -4,7 +4,8 @@ | |||
4 | #include <iostream> | 4 | #include <iostream> |
5 | 5 | ||
6 | #include "dummyresource/resourcefactory.h" | 6 | #include "dummyresource/resourcefactory.h" |
7 | #include "clientapi.h" | 7 | #include "store.h" |
8 | #include "resourcecontrol.h" | ||
8 | #include "commands.h" | 9 | #include "commands.h" |
9 | #include "resourceconfig.h" | 10 | #include "resourceconfig.h" |
10 | #include "log.h" | 11 | #include "log.h" |
@@ -46,15 +47,13 @@ private Q_SLOTS: | |||
46 | void initTestCase() | 47 | void initTestCase() |
47 | { | 48 | { |
48 | Sink::Log::setDebugOutputLevel(Sink::Log::Warning); | 49 | Sink::Log::setDebugOutputLevel(Sink::Log::Warning); |
49 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | ||
50 | ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); | 50 | ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); |
51 | Sink::Store::removeDataFromDisk(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | ||
51 | } | 52 | } |
52 | 53 | ||
53 | void cleanup() | 54 | void cleanup() |
54 | { | 55 | { |
55 | Sink::Store::shutdown(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | 56 | Sink::Store::removeDataFromDisk(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); |
56 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | ||
57 | Sink::Store::start(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | ||
58 | } | 57 | } |
59 | 58 | ||
60 | void init() | 59 | void init() |
@@ -75,7 +74,7 @@ private Q_SLOTS: | |||
75 | query.resources << "org.kde.dummy.instance1"; | 74 | query.resources << "org.kde.dummy.instance1"; |
76 | query.liveQuery = true; | 75 | query.liveQuery = true; |
77 | 76 | ||
78 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 77 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
79 | 78 | ||
80 | //Test | 79 | //Test |
81 | QTime time; | 80 | QTime time; |
diff --git a/tests/pipelinetest.cpp b/tests/pipelinetest.cpp index c74d319..d6073dc 100644 --- a/tests/pipelinetest.cpp +++ b/tests/pipelinetest.cpp | |||
@@ -11,7 +11,7 @@ | |||
11 | #include "modifyentity_generated.h" | 11 | #include "modifyentity_generated.h" |
12 | #include "deleteentity_generated.h" | 12 | #include "deleteentity_generated.h" |
13 | #include "dummyresource/resourcefactory.h" | 13 | #include "dummyresource/resourcefactory.h" |
14 | #include "clientapi.h" | 14 | #include "store.h" |
15 | #include "commands.h" | 15 | #include "commands.h" |
16 | #include "entitybuffer.h" | 16 | #include "entitybuffer.h" |
17 | #include "resourceconfig.h" | 17 | #include "resourceconfig.h" |
@@ -52,7 +52,7 @@ static QByteArray getEntity(const QByteArray &dbEnv, const QByteArray &name, con | |||
52 | return result; | 52 | return result; |
53 | } | 53 | } |
54 | 54 | ||
55 | flatbuffers::FlatBufferBuilder &createEvent(flatbuffers::FlatBufferBuilder &entityFbb, const QString &s = QString("summary")) | 55 | flatbuffers::FlatBufferBuilder &createEvent(flatbuffers::FlatBufferBuilder &entityFbb, const QString &s = QString("summary"), const QString &d = QString()) |
56 | { | 56 | { |
57 | flatbuffers::FlatBufferBuilder eventFbb; | 57 | flatbuffers::FlatBufferBuilder eventFbb; |
58 | eventFbb.Clear(); | 58 | eventFbb.Clear(); |
@@ -66,9 +66,13 @@ flatbuffers::FlatBufferBuilder &createEvent(flatbuffers::FlatBufferBuilder &enti | |||
66 | { | 66 | { |
67 | auto uid = localFbb.CreateString("testuid"); | 67 | auto uid = localFbb.CreateString("testuid"); |
68 | auto summary = localFbb.CreateString(s.toStdString()); | 68 | auto summary = localFbb.CreateString(s.toStdString()); |
69 | auto description = localFbb.CreateString(d.toStdString()); | ||
69 | auto localBuilder = Sink::ApplicationDomain::Buffer::EventBuilder(localFbb); | 70 | auto localBuilder = Sink::ApplicationDomain::Buffer::EventBuilder(localFbb); |
70 | localBuilder.add_uid(uid); | 71 | localBuilder.add_uid(uid); |
71 | localBuilder.add_summary(summary); | 72 | localBuilder.add_summary(summary); |
73 | if (!d.isEmpty()) { | ||
74 | localBuilder.add_description(description); | ||
75 | } | ||
72 | auto location = localBuilder.Finish(); | 76 | auto location = localBuilder.Finish(); |
73 | Sink::ApplicationDomain::Buffer::FinishEventBuffer(localFbb, location); | 77 | Sink::ApplicationDomain::Buffer::FinishEventBuffer(localFbb, location); |
74 | } | 78 | } |
@@ -203,7 +207,7 @@ private Q_SLOTS: | |||
203 | void testModify() | 207 | void testModify() |
204 | { | 208 | { |
205 | flatbuffers::FlatBufferBuilder entityFbb; | 209 | flatbuffers::FlatBufferBuilder entityFbb; |
206 | auto command = createEntityCommand(createEvent(entityFbb)); | 210 | auto command = createEntityCommand(createEvent(entityFbb, "summary", "description")); |
207 | 211 | ||
208 | Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); | 212 | Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); |
209 | 213 | ||
@@ -233,7 +237,9 @@ private Q_SLOTS: | |||
233 | QVERIFY(!buffer.isEmpty()); | 237 | QVERIFY(!buffer.isEmpty()); |
234 | Sink::EntityBuffer entityBuffer(buffer.data(), buffer.size()); | 238 | Sink::EntityBuffer entityBuffer(buffer.data(), buffer.size()); |
235 | auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity()); | 239 | auto adaptor = adaptorFactory->createAdaptor(entityBuffer.entity()); |
236 | QCOMPARE(adaptor->getProperty("summary").toString(), QString("summary2")); | 240 | QVERIFY2(adaptor->getProperty("summary").toString() == QString("summary2"), "The modification isn't applied."); |
241 | //Ensure we didn't modify anything else | ||
242 | QVERIFY2(adaptor->getProperty("description").toString() == QString("description"), "The modification has sideeffects."); | ||
237 | 243 | ||
238 | //Both revisions are in the store at this point | 244 | //Both revisions are in the store at this point |
239 | QCOMPARE(getKeys("org.kde.pipelinetest.instance1", "event.main").size(), 2); | 245 | QCOMPARE(getKeys("org.kde.pipelinetest.instance1", "event.main").size(), 2); |
diff --git a/tests/querytest.cpp b/tests/querytest.cpp index 62db15b..16376b9 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp | |||
@@ -3,7 +3,8 @@ | |||
3 | #include <QString> | 3 | #include <QString> |
4 | 4 | ||
5 | #include "dummyresource/resourcefactory.h" | 5 | #include "dummyresource/resourcefactory.h" |
6 | #include "clientapi.h" | 6 | #include "store.h" |
7 | #include "resourcecontrol.h" | ||
7 | #include "commands.h" | 8 | #include "commands.h" |
8 | #include "resourceconfig.h" | 9 | #include "resourceconfig.h" |
9 | #include "log.h" | 10 | #include "log.h" |
@@ -23,17 +24,13 @@ private Q_SLOTS: | |||
23 | Sink::Log::setDebugOutputLevel(Sink::Log::Trace); | 24 | Sink::Log::setDebugOutputLevel(Sink::Log::Trace); |
24 | auto factory = Sink::ResourceFactory::load("org.kde.dummy"); | 25 | auto factory = Sink::ResourceFactory::load("org.kde.dummy"); |
25 | QVERIFY(factory); | 26 | QVERIFY(factory); |
26 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | ||
27 | ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); | 27 | ResourceConfig::addResource("org.kde.dummy.instance1", "org.kde.dummy"); |
28 | Sink::Store::removeDataFromDisk(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | ||
28 | } | 29 | } |
29 | 30 | ||
30 | void cleanup() | 31 | void cleanup() |
31 | { | 32 | { |
32 | Sink::Store::shutdown(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | 33 | Sink::Store::removeDataFromDisk(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); |
33 | DummyResource::removeFromDisk("org.kde.dummy.instance1"); | ||
34 | auto factory = Sink::ResourceFactory::load("org.kde.dummy"); | ||
35 | QVERIFY(factory); | ||
36 | Sink::Store::start(QByteArray("org.kde.dummy.instance1")).exec().waitForFinished(); | ||
37 | } | 34 | } |
38 | 35 | ||
39 | void init() | 36 | void init() |
@@ -90,7 +87,7 @@ private Q_SLOTS: | |||
90 | query.liveQuery = false; | 87 | query.liveQuery = false; |
91 | 88 | ||
92 | //Ensure all local data is processed | 89 | //Ensure all local data is processed |
93 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 90 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
94 | 91 | ||
95 | //We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data | 92 | //We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data |
96 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); | 93 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
@@ -165,7 +162,7 @@ private Q_SLOTS: | |||
165 | query.resources << "org.kde.dummy.instance1"; | 162 | query.resources << "org.kde.dummy.instance1"; |
166 | 163 | ||
167 | //Ensure all local data is processed | 164 | //Ensure all local data is processed |
168 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 165 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
169 | 166 | ||
170 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); | 167 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
171 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 168 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
@@ -185,7 +182,7 @@ private Q_SLOTS: | |||
185 | query.parentProperty = "parent"; | 182 | query.parentProperty = "parent"; |
186 | 183 | ||
187 | //Ensure all local data is processed | 184 | //Ensure all local data is processed |
188 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 185 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
189 | 186 | ||
190 | //We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data | 187 | //We fetch after the data is available and don't rely on the live query mechanism to deliver the actual data |
191 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); | 188 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
@@ -214,7 +211,7 @@ private Q_SLOTS: | |||
214 | query.propertyFilter.insert("uid", "test1"); | 211 | query.propertyFilter.insert("uid", "test1"); |
215 | 212 | ||
216 | //Ensure all local data is processed | 213 | //Ensure all local data is processed |
217 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 214 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
218 | 215 | ||
219 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data | 216 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data |
220 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); | 217 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |
@@ -234,7 +231,7 @@ private Q_SLOTS: | |||
234 | query.resources << "org.kde.dummy.instance1"; | 231 | query.resources << "org.kde.dummy.instance1"; |
235 | 232 | ||
236 | //Ensure all local data is processed | 233 | //Ensure all local data is processed |
237 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 234 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
238 | 235 | ||
239 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); | 236 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
240 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); | 237 | QTRY_VERIFY(model->data(QModelIndex(), Sink::Store::ChildrenFetchedRole).toBool()); |
@@ -255,7 +252,7 @@ private Q_SLOTS: | |||
255 | query.propertyFilter.insert("folder", folderEntity->identifier()); | 252 | query.propertyFilter.insert("folder", folderEntity->identifier()); |
256 | 253 | ||
257 | //Ensure all local data is processed | 254 | //Ensure all local data is processed |
258 | Sink::Store::flushMessageQueue(query.resources).exec().waitForFinished(); | 255 | Sink::ResourceControl::flushMessageQueue(query.resources).exec().waitForFinished(); |
259 | 256 | ||
260 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data | 257 | //We fetch before the data is available and rely on the live query mechanism to deliver the actual data |
261 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); | 258 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Mail>(query); |