diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-10-13 00:04:05 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-10-13 00:04:05 +0200 |
commit | 2eb3810b66de3130f3e650627380c28a96acded7 (patch) | |
tree | 947716efcdfc0be52958e8659defbc19db9e6b6d /tests/genericfacadetest.cpp | |
parent | 1b39c149e1fe8705f7fcbd8840de85414c652dc1 (diff) | |
download | sink-2eb3810b66de3130f3e650627380c28a96acded7.tar.gz sink-2eb3810b66de3130f3e650627380c28a96acded7.zip |
Moved test implementations to central location.
Diffstat (limited to 'tests/genericfacadetest.cpp')
-rw-r--r-- | tests/genericfacadetest.cpp | 64 |
1 files changed, 2 insertions, 62 deletions
diff --git a/tests/genericfacadetest.cpp b/tests/genericfacadetest.cpp index e9c1a94..ae6a685 100644 --- a/tests/genericfacadetest.cpp +++ b/tests/genericfacadetest.cpp | |||
@@ -2,6 +2,8 @@ | |||
2 | 2 | ||
3 | #include <QString> | 3 | #include <QString> |
4 | 4 | ||
5 | #include "testimplementations.h" | ||
6 | |||
5 | #include <common/facade.h> | 7 | #include <common/facade.h> |
6 | #include <common/domainadaptor.h> | 8 | #include <common/domainadaptor.h> |
7 | #include <common/resultprovider.h> | 9 | #include <common/resultprovider.h> |
@@ -10,68 +12,6 @@ | |||
10 | //Replace with something different | 12 | //Replace with something different |
11 | #include "event_generated.h" | 13 | #include "event_generated.h" |
12 | 14 | ||
13 | class TestEventAdaptorFactory : public DomainTypeAdaptorFactory<Akonadi2::ApplicationDomain::Event, Akonadi2::ApplicationDomain::Buffer::Event, Akonadi2::ApplicationDomain::Buffer::EventBuilder> | ||
14 | { | ||
15 | public: | ||
16 | TestEventAdaptorFactory() | ||
17 | : DomainTypeAdaptorFactory() | ||
18 | { | ||
19 | } | ||
20 | |||
21 | virtual ~TestEventAdaptorFactory() {}; | ||
22 | }; | ||
23 | |||
24 | class TestEntityStorage : public EntityStorage<Akonadi2::ApplicationDomain::Event> | ||
25 | { | ||
26 | public: | ||
27 | using EntityStorage::EntityStorage; | ||
28 | virtual qint64 read(const Akonadi2::Query &query, qint64 oldRevision, const QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Event::Ptr> > &resultProvider) Q_DECL_OVERRIDE | ||
29 | { | ||
30 | for (const auto &res : mResults) { | ||
31 | resultProvider->add(res); | ||
32 | } | ||
33 | for (const auto &res : mModifications) { | ||
34 | resultProvider->modify(res); | ||
35 | } | ||
36 | for (const auto &res : mRemovals) { | ||
37 | resultProvider->remove(res); | ||
38 | } | ||
39 | return mLatestRevision; | ||
40 | } | ||
41 | |||
42 | QList<Akonadi2::ApplicationDomain::Event::Ptr> mResults; | ||
43 | QList<Akonadi2::ApplicationDomain::Event::Ptr> mModifications; | ||
44 | QList<Akonadi2::ApplicationDomain::Event::Ptr> mRemovals; | ||
45 | qint64 mLatestRevision; | ||
46 | }; | ||
47 | |||
48 | class TestResourceAccess : public Akonadi2::ResourceAccessInterface | ||
49 | { | ||
50 | Q_OBJECT | ||
51 | public: | ||
52 | virtual ~TestResourceAccess() {}; | ||
53 | KAsync::Job<void> sendCommand(int commandId) Q_DECL_OVERRIDE { return KAsync::null<void>(); } | ||
54 | KAsync::Job<void> sendCommand(int commandId, flatbuffers::FlatBufferBuilder &fbb) Q_DECL_OVERRIDE { return KAsync::null<void>(); } | ||
55 | KAsync::Job<void> synchronizeResource(bool remoteSync, bool localSync) Q_DECL_OVERRIDE { return KAsync::null<void>(); } | ||
56 | |||
57 | public Q_SLOTS: | ||
58 | void open() Q_DECL_OVERRIDE {} | ||
59 | void close() Q_DECL_OVERRIDE {} | ||
60 | }; | ||
61 | |||
62 | class TestResourceFacade : public Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Event> | ||
63 | { | ||
64 | public: | ||
65 | TestResourceFacade(const QByteArray &instanceIdentifier, const QSharedPointer<EntityStorage<Akonadi2::ApplicationDomain::Event> > storage, const QSharedPointer<Akonadi2::ResourceAccessInterface> resourceAccess) | ||
66 | : Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Event>(instanceIdentifier, QSharedPointer<TestEventAdaptorFactory>::create(), storage, resourceAccess) | ||
67 | { | ||
68 | |||
69 | } | ||
70 | virtual ~TestResourceFacade() | ||
71 | { | ||
72 | |||
73 | } | ||
74 | }; | ||
75 | 15 | ||
76 | class GenericFacadeTest : public QObject | 16 | class GenericFacadeTest : public QObject |
77 | { | 17 | { |