summaryrefslogtreecommitdiffstats
path: root/tests/testimplementations.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/testimplementations.h')
-rw-r--r--tests/testimplementations.h111
1 files changed, 111 insertions, 0 deletions
diff --git a/tests/testimplementations.h b/tests/testimplementations.h
new file mode 100644
index 0000000..eee78b0
--- /dev/null
+++ b/tests/testimplementations.h
@@ -0,0 +1,111 @@
1/*
2 * Copyright (C) 2015 Christian Mollekopf <chrigi_1@fastmail.fm>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) version 3, or any
8 * later version accepted by the membership of KDE e.V. (or its
9 * successor approved by the membership of KDE e.V.), which shall
10 * act as a proxy defined in Section 6 of version 3 of the license.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library. If not, see <http://www.gnu.org/licenses/>.
19 */
20#pragma once
21
22#include <Async/Async>
23
24#include <common/entitystorage.h>
25#include <common/domainadaptor.h>
26#include <common/resultprovider.h>
27#include <common/synclistresult.h>
28#include <common/resourceaccess.h>
29#include <common/facade.h>
30#include <common/entitystorage.h>
31#include <common/genericresource.h>
32
33//Replace with something different
34#include "event_generated.h"
35
36class TestEventAdaptorFactory : public DomainTypeAdaptorFactory<Akonadi2::ApplicationDomain::Event, Akonadi2::ApplicationDomain::Buffer::Event, Akonadi2::ApplicationDomain::Buffer::EventBuilder>
37{
38public:
39 TestEventAdaptorFactory()
40 : DomainTypeAdaptorFactory()
41 {
42 }
43
44 virtual ~TestEventAdaptorFactory() {};
45};
46
47class TestEntityStorage : public EntityStorage<Akonadi2::ApplicationDomain::Event>
48{
49public:
50 using EntityStorage::EntityStorage;
51 virtual qint64 read(const Akonadi2::Query &query, qint64 oldRevision, const QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Event::Ptr> > &resultProvider) Q_DECL_OVERRIDE
52 {
53 for (const auto &res : mResults) {
54 resultProvider->add(res);
55 }
56 for (const auto &res : mModifications) {
57 resultProvider->modify(res);
58 }
59 for (const auto &res : mRemovals) {
60 resultProvider->remove(res);
61 }
62 return mLatestRevision;
63 }
64
65 QList<Akonadi2::ApplicationDomain::Event::Ptr> mResults;
66 QList<Akonadi2::ApplicationDomain::Event::Ptr> mModifications;
67 QList<Akonadi2::ApplicationDomain::Event::Ptr> mRemovals;
68 qint64 mLatestRevision;
69};
70
71class TestResourceAccess : public Akonadi2::ResourceAccessInterface
72{
73 Q_OBJECT
74public:
75 virtual ~TestResourceAccess() {};
76 KAsync::Job<void> sendCommand(int commandId) Q_DECL_OVERRIDE { return KAsync::null<void>(); }
77 KAsync::Job<void> sendCommand(int commandId, flatbuffers::FlatBufferBuilder &fbb) Q_DECL_OVERRIDE { return KAsync::null<void>(); }
78 KAsync::Job<void> synchronizeResource(bool remoteSync, bool localSync) Q_DECL_OVERRIDE { return KAsync::null<void>(); }
79
80public Q_SLOTS:
81 void open() Q_DECL_OVERRIDE {}
82 void close() Q_DECL_OVERRIDE {}
83};
84
85class TestResourceFacade : public Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Event>
86{
87public:
88 TestResourceFacade(const QByteArray &instanceIdentifier, const QSharedPointer<EntityStorage<Akonadi2::ApplicationDomain::Event> > storage, const QSharedPointer<Akonadi2::ResourceAccessInterface> resourceAccess)
89 : Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Event>(instanceIdentifier, QSharedPointer<TestEventAdaptorFactory>::create(), storage, resourceAccess)
90 {
91
92 }
93 virtual ~TestResourceFacade()
94 {
95
96 }
97};
98
99class TestResource : public Akonadi2::GenericResource
100{
101public:
102 TestResource(const QByteArray &instanceIdentifier, QSharedPointer<Akonadi2::Pipeline> pipeline)
103 : Akonadi2::GenericResource(instanceIdentifier, pipeline)
104 {
105 }
106
107 KAsync::Job<void> synchronizeWithSource() Q_DECL_OVERRIDE
108 {
109 return KAsync::null<void>();
110 }
111};