diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-05-28 00:24:53 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2016-05-28 00:24:53 +0200 |
commit | e9c75177590d8546ebd9425f16c4269a9c92f517 (patch) | |
tree | 8a953631e467d9df50657e22bd90954b7b71c990 /tests | |
parent | 8f01eb530262d1442fc4fa0782a41e052412d43b (diff) | |
download | sink-e9c75177590d8546ebd9425f16c4269a9c92f517.tar.gz sink-e9c75177590d8546ebd9425f16c4269a9c92f517.zip |
Refactored the generic resource to use separate classes for
changereplay and synchronization.
This cleans up the API and avoids the excessive passing around of
transactions. It also provides more flexibility in eventually using
different synchronization strategies for different resources.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/dummyresourcetest.cpp | 2 | ||||
-rw-r--r-- | tests/mailquerybenchmark.cpp | 5 | ||||
-rw-r--r-- | tests/pipelinebenchmark.cpp | 6 | ||||
-rw-r--r-- | tests/pipelinetest.cpp | 14 | ||||
-rw-r--r-- | tests/querytest.cpp | 2 | ||||
-rw-r--r-- | tests/testimplementations.h | 2 |
6 files changed, 18 insertions, 13 deletions
diff --git a/tests/dummyresourcetest.cpp b/tests/dummyresourcetest.cpp index 58df2da..d41f235 100644 --- a/tests/dummyresourcetest.cpp +++ b/tests/dummyresourcetest.cpp | |||
@@ -11,6 +11,7 @@ | |||
11 | #include "modelresult.h" | 11 | #include "modelresult.h" |
12 | #include "pipeline.h" | 12 | #include "pipeline.h" |
13 | #include "log.h" | 13 | #include "log.h" |
14 | #include "test.h" | ||
14 | 15 | ||
15 | using namespace Sink; | 16 | using namespace Sink; |
16 | 17 | ||
@@ -28,6 +29,7 @@ class DummyResourceTest : public QObject | |||
28 | private slots: | 29 | private slots: |
29 | void initTestCase() | 30 | void initTestCase() |
30 | { | 31 | { |
32 | Sink::Test::initTest(); | ||
31 | Sink::Log::setDebugOutputLevel(Sink::Log::Trace); | 33 | Sink::Log::setDebugOutputLevel(Sink::Log::Trace); |
32 | auto factory = Sink::ResourceFactory::load("org.kde.dummy"); | 34 | auto factory = Sink::ResourceFactory::load("org.kde.dummy"); |
33 | QVERIFY(factory); | 35 | QVERIFY(factory); |
diff --git a/tests/mailquerybenchmark.cpp b/tests/mailquerybenchmark.cpp index 20ee63c..4e58899 100644 --- a/tests/mailquerybenchmark.cpp +++ b/tests/mailquerybenchmark.cpp | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <common/pipeline.h> | 33 | #include <common/pipeline.h> |
34 | #include <common/index.h> | 34 | #include <common/index.h> |
35 | #include <common/indexupdater.h> | 35 | #include <common/indexupdater.h> |
36 | #include <common/adaptorfactoryregistry.h> | ||
36 | 37 | ||
37 | #include "hawd/dataset.h" | 38 | #include "hawd/dataset.h" |
38 | #include "hawd/formatter.h" | 39 | #include "hawd/formatter.h" |
@@ -59,12 +60,11 @@ class MailQueryBenchmark : public QObject | |||
59 | TestResource::removeFromDisk(resourceIdentifier); | 60 | TestResource::removeFromDisk(resourceIdentifier); |
60 | 61 | ||
61 | auto pipeline = QSharedPointer<Sink::Pipeline>::create(resourceIdentifier); | 62 | auto pipeline = QSharedPointer<Sink::Pipeline>::create(resourceIdentifier); |
63 | pipeline->setResourceType("test"); | ||
62 | 64 | ||
63 | auto mailFactory = QSharedPointer<TestMailAdaptorFactory>::create(); | ||
64 | auto indexer = QSharedPointer<DefaultIndexUpdater<Sink::ApplicationDomain::Mail>>::create(); | 65 | auto indexer = QSharedPointer<DefaultIndexUpdater<Sink::ApplicationDomain::Mail>>::create(); |
65 | 66 | ||
66 | pipeline->setPreprocessors("mail", QVector<Sink::Preprocessor *>() << indexer.data()); | 67 | pipeline->setPreprocessors("mail", QVector<Sink::Preprocessor *>() << indexer.data()); |
67 | pipeline->setAdaptorFactory("mail", mailFactory); | ||
68 | 68 | ||
69 | auto domainTypeAdaptorFactory = QSharedPointer<TestMailAdaptorFactory>::create(); | 69 | auto domainTypeAdaptorFactory = QSharedPointer<TestMailAdaptorFactory>::create(); |
70 | 70 | ||
@@ -149,6 +149,7 @@ private slots: | |||
149 | void init() | 149 | void init() |
150 | { | 150 | { |
151 | resourceIdentifier = "org.kde.test.instance1"; | 151 | resourceIdentifier = "org.kde.test.instance1"; |
152 | Sink::AdaptorFactoryRegistry::instance().registerFactory<Sink::ApplicationDomain::Mail, TestMailAdaptorFactory>("test"); | ||
152 | } | 153 | } |
153 | 154 | ||
154 | void test50k() | 155 | void test50k() |
diff --git a/tests/pipelinebenchmark.cpp b/tests/pipelinebenchmark.cpp index 0133a6c..51481fd 100644 --- a/tests/pipelinebenchmark.cpp +++ b/tests/pipelinebenchmark.cpp | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <common/pipeline.h> | 33 | #include <common/pipeline.h> |
34 | #include <common/index.h> | 34 | #include <common/index.h> |
35 | #include <common/indexupdater.h> | 35 | #include <common/indexupdater.h> |
36 | #include <common/adaptorfactoryregistry.h> | ||
36 | 37 | ||
37 | #include "hawd/dataset.h" | 38 | #include "hawd/dataset.h" |
38 | #include "hawd/formatter.h" | 39 | #include "hawd/formatter.h" |
@@ -83,10 +84,8 @@ class PipelineBenchmark : public QObject | |||
83 | TestResource::removeFromDisk(resourceIdentifier); | 84 | TestResource::removeFromDisk(resourceIdentifier); |
84 | 85 | ||
85 | auto pipeline = QSharedPointer<Sink::Pipeline>::create(resourceIdentifier); | 86 | auto pipeline = QSharedPointer<Sink::Pipeline>::create(resourceIdentifier); |
86 | |||
87 | auto mailFactory = QSharedPointer<TestMailAdaptorFactory>::create(); | ||
88 | pipeline->setPreprocessors("mail", preprocessors); | 87 | pipeline->setPreprocessors("mail", preprocessors); |
89 | pipeline->setAdaptorFactory("mail", mailFactory); | 88 | pipeline->setResourceType("test"); |
90 | 89 | ||
91 | QTime time; | 90 | QTime time; |
92 | time.start(); | 91 | time.start(); |
@@ -131,6 +130,7 @@ private slots: | |||
131 | void init() | 130 | void init() |
132 | { | 131 | { |
133 | Sink::Log::setDebugOutputLevel(Sink::Log::Warning); | 132 | Sink::Log::setDebugOutputLevel(Sink::Log::Warning); |
133 | Sink::AdaptorFactoryRegistry::instance().registerFactory<Sink::ApplicationDomain::Mail, TestMailAdaptorFactory>("test"); | ||
134 | resourceIdentifier = "org.kde.test.instance1"; | 134 | resourceIdentifier = "org.kde.test.instance1"; |
135 | } | 135 | } |
136 | 136 | ||
diff --git a/tests/pipelinetest.cpp b/tests/pipelinetest.cpp index 9290050..6ea2041 100644 --- a/tests/pipelinetest.cpp +++ b/tests/pipelinetest.cpp | |||
@@ -19,6 +19,7 @@ | |||
19 | #include "log.h" | 19 | #include "log.h" |
20 | #include "domainadaptor.h" | 20 | #include "domainadaptor.h" |
21 | #include "definitions.h" | 21 | #include "definitions.h" |
22 | #include "adaptorfactoryregistry.h" | ||
22 | 23 | ||
23 | static void removeFromDisk(const QString &name) | 24 | static void removeFromDisk(const QString &name) |
24 | { | 25 | { |
@@ -185,6 +186,7 @@ private slots: | |||
185 | void initTestCase() | 186 | void initTestCase() |
186 | { | 187 | { |
187 | Sink::Log::setDebugOutputLevel(Sink::Log::Trace); | 188 | Sink::Log::setDebugOutputLevel(Sink::Log::Trace); |
189 | Sink::AdaptorFactoryRegistry::instance().registerFactory<Sink::ApplicationDomain::Event, TestEventAdaptorFactory>("test"); | ||
188 | } | 190 | } |
189 | 191 | ||
190 | void init() | 192 | void init() |
@@ -198,9 +200,7 @@ private slots: | |||
198 | auto command = createEntityCommand(createEvent(entityFbb)); | 200 | auto command = createEntityCommand(createEvent(entityFbb)); |
199 | 201 | ||
200 | Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); | 202 | Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); |
201 | 203 | pipeline.setResourceType("test"); | |
202 | auto adaptorFactory = QSharedPointer<TestEventAdaptorFactory>::create(); | ||
203 | pipeline.setAdaptorFactory("event", adaptorFactory); | ||
204 | 204 | ||
205 | pipeline.startTransaction(); | 205 | pipeline.startTransaction(); |
206 | pipeline.newEntity(command.constData(), command.size()); | 206 | pipeline.newEntity(command.constData(), command.size()); |
@@ -216,9 +216,9 @@ private slots: | |||
216 | auto command = createEntityCommand(createEvent(entityFbb, "summary", "description")); | 216 | auto command = createEntityCommand(createEvent(entityFbb, "summary", "description")); |
217 | 217 | ||
218 | Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); | 218 | Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); |
219 | pipeline.setResourceType("test"); | ||
219 | 220 | ||
220 | auto adaptorFactory = QSharedPointer<TestEventAdaptorFactory>::create(); | 221 | auto adaptorFactory = QSharedPointer<TestEventAdaptorFactory>::create(); |
221 | pipeline.setAdaptorFactory("event", adaptorFactory); | ||
222 | 222 | ||
223 | // Create the initial revision | 223 | // Create the initial revision |
224 | pipeline.startTransaction(); | 224 | pipeline.startTransaction(); |
@@ -265,9 +265,9 @@ private slots: | |||
265 | auto command = createEntityCommand(createEvent(entityFbb)); | 265 | auto command = createEntityCommand(createEvent(entityFbb)); |
266 | 266 | ||
267 | Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); | 267 | Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); |
268 | pipeline.setResourceType("test"); | ||
268 | 269 | ||
269 | auto adaptorFactory = QSharedPointer<TestEventAdaptorFactory>::create(); | 270 | auto adaptorFactory = QSharedPointer<TestEventAdaptorFactory>::create(); |
270 | pipeline.setAdaptorFactory("event", adaptorFactory); | ||
271 | 271 | ||
272 | // Create the initial revision | 272 | // Create the initial revision |
273 | pipeline.startTransaction(); | 273 | pipeline.startTransaction(); |
@@ -309,7 +309,7 @@ private slots: | |||
309 | flatbuffers::FlatBufferBuilder entityFbb; | 309 | flatbuffers::FlatBufferBuilder entityFbb; |
310 | auto command = createEntityCommand(createEvent(entityFbb)); | 310 | auto command = createEntityCommand(createEvent(entityFbb)); |
311 | Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); | 311 | Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); |
312 | pipeline.setAdaptorFactory("event", QSharedPointer<TestEventAdaptorFactory>::create()); | 312 | pipeline.setResourceType("test"); |
313 | 313 | ||
314 | // Create the initial revision | 314 | // Create the initial revision |
315 | pipeline.startTransaction(); | 315 | pipeline.startTransaction(); |
@@ -346,9 +346,9 @@ private slots: | |||
346 | TestProcessor testProcessor; | 346 | TestProcessor testProcessor; |
347 | 347 | ||
348 | Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); | 348 | Sink::Pipeline pipeline("org.kde.pipelinetest.instance1"); |
349 | pipeline.setResourceType("test"); | ||
349 | pipeline.setPreprocessors("event", QVector<Sink::Preprocessor *>() << &testProcessor); | 350 | pipeline.setPreprocessors("event", QVector<Sink::Preprocessor *>() << &testProcessor); |
350 | pipeline.startTransaction(); | 351 | pipeline.startTransaction(); |
351 | pipeline.setAdaptorFactory("event", QSharedPointer<TestEventAdaptorFactory>::create()); | ||
352 | 352 | ||
353 | // Actual test | 353 | // Actual test |
354 | { | 354 | { |
diff --git a/tests/querytest.cpp b/tests/querytest.cpp index a654931..6d7746e 100644 --- a/tests/querytest.cpp +++ b/tests/querytest.cpp | |||
@@ -9,6 +9,7 @@ | |||
9 | #include "resourceconfig.h" | 9 | #include "resourceconfig.h" |
10 | #include "log.h" | 10 | #include "log.h" |
11 | #include "modelresult.h" | 11 | #include "modelresult.h" |
12 | #include "test.h" | ||
12 | 13 | ||
13 | /** | 14 | /** |
14 | * Test of the query system using the dummy resource. | 15 | * Test of the query system using the dummy resource. |
@@ -21,6 +22,7 @@ class QueryTest : public QObject | |||
21 | private slots: | 22 | private slots: |
22 | void initTestCase() | 23 | void initTestCase() |
23 | { | 24 | { |
25 | Sink::Test::initTest(); | ||
24 | Sink::Log::setDebugOutputLevel(Sink::Log::Trace); | 26 | Sink::Log::setDebugOutputLevel(Sink::Log::Trace); |
25 | auto factory = Sink::ResourceFactory::load("org.kde.dummy"); | 27 | auto factory = Sink::ResourceFactory::load("org.kde.dummy"); |
26 | QVERIFY(factory); | 28 | QVERIFY(factory); |
diff --git a/tests/testimplementations.h b/tests/testimplementations.h index 688875d..197602c 100644 --- a/tests/testimplementations.h +++ b/tests/testimplementations.h | |||
@@ -107,7 +107,7 @@ public: | |||
107 | class TestResource : public Sink::GenericResource | 107 | class TestResource : public Sink::GenericResource |
108 | { | 108 | { |
109 | public: | 109 | public: |
110 | TestResource(const QByteArray &instanceIdentifier, QSharedPointer<Sink::Pipeline> pipeline) : Sink::GenericResource(instanceIdentifier, pipeline) | 110 | TestResource(const QByteArray &instanceIdentifier, QSharedPointer<Sink::Pipeline> pipeline) : Sink::GenericResource("test", instanceIdentifier, pipeline, QSharedPointer<Sink::ChangeReplay>(), QSharedPointer<Sink::Synchronizer>()) |
111 | { | 111 | { |
112 | } | 112 | } |
113 | 113 | ||