summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/CMakeLists.txt4
-rw-r--r--tests/genericfacadebenchmark.cpp39
-rw-r--r--tests/genericfacadetest.cpp64
-rw-r--r--tests/genericresourcebenchmark.cpp27
-rw-r--r--tests/genericresourcetest.cpp17
-rw-r--r--tests/pipelinetest.cpp13
-rw-r--r--tests/testimplementations.cpp23
-rw-r--r--tests/testimplementations.h111
8 files changed, 146 insertions, 152 deletions
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index b2201ff..5629cdb 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -10,7 +10,7 @@ include_directories(
10 10
11macro(manual_tests) 11macro(manual_tests)
12 foreach(_testname ${ARGN}) 12 foreach(_testname ${ARGN})
13 add_executable(${_testname} ${_testname}.cpp) 13 add_executable(${_testname} ${_testname}.cpp testimplementations.cpp)
14 generate_flatbuffers(${_testname} calendar) 14 generate_flatbuffers(${_testname} calendar)
15 qt5_use_modules(${_testname} Core Test Concurrent) 15 qt5_use_modules(${_testname} Core Test Concurrent)
16 target_link_libraries(${_testname} akonadi2common libhawd) 16 target_link_libraries(${_testname} akonadi2common libhawd)
@@ -19,7 +19,7 @@ endmacro(manual_tests)
19 19
20macro(auto_tests) 20macro(auto_tests)
21 foreach(_testname ${ARGN}) 21 foreach(_testname ${ARGN})
22 add_executable(${_testname} ${_testname}.cpp) 22 add_executable(${_testname} ${_testname}.cpp testimplementations.cpp)
23 generate_flatbuffers(${_testname} calendar) 23 generate_flatbuffers(${_testname} calendar)
24 add_test(${_testname} ${_testname}) 24 add_test(${_testname} ${_testname})
25 qt5_use_modules(${_testname} Core Test Concurrent) 25 qt5_use_modules(${_testname} Core Test Concurrent)
diff --git a/tests/genericfacadebenchmark.cpp b/tests/genericfacadebenchmark.cpp
index 7cd6c75..3e98fce 100644
--- a/tests/genericfacadebenchmark.cpp
+++ b/tests/genericfacadebenchmark.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>
@@ -9,44 +11,7 @@
9 11
10#include "event_generated.h" 12#include "event_generated.h"
11 13
12class TestEventAdaptorFactory : public DomainTypeAdaptorFactory<Akonadi2::ApplicationDomain::Event, Akonadi2::ApplicationDomain::Buffer::Event, Akonadi2::ApplicationDomain::Buffer::EventBuilder>
13{
14public:
15 TestEventAdaptorFactory()
16 : DomainTypeAdaptorFactory()
17 {
18 }
19
20 virtual ~TestEventAdaptorFactory() {};
21};
22
23class TestResourceAccess : public Akonadi2::ResourceAccessInterface
24{
25 Q_OBJECT
26public:
27 virtual ~TestResourceAccess() {};
28 KAsync::Job<void> sendCommand(int commandId) Q_DECL_OVERRIDE { return KAsync::null<void>(); }
29 KAsync::Job<void> sendCommand(int commandId, flatbuffers::FlatBufferBuilder &fbb) Q_DECL_OVERRIDE { return KAsync::null<void>(); }
30 KAsync::Job<void> synchronizeResource(bool remoteSync, bool localSync) Q_DECL_OVERRIDE { return KAsync::null<void>(); }
31
32public Q_SLOTS:
33 void open() Q_DECL_OVERRIDE {}
34 void close() Q_DECL_OVERRIDE {}
35};
36
37class TestResourceFacade : public Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Event>
38{
39public:
40 TestResourceFacade(const QByteArray &instanceIdentifier, const QSharedPointer<EntityStorage<Akonadi2::ApplicationDomain::Event> > storage, const QSharedPointer<Akonadi2::ResourceAccessInterface> resourceAccess)
41 : Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Event>(instanceIdentifier, QSharedPointer<TestEventAdaptorFactory>::create(), storage, resourceAccess)
42 {
43 14
44 }
45 virtual ~TestResourceFacade()
46 {
47
48 }
49};
50 15
51class GenericFacadeBenchmark : public QObject 16class GenericFacadeBenchmark : public QObject
52{ 17{
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
13class TestEventAdaptorFactory : public DomainTypeAdaptorFactory<Akonadi2::ApplicationDomain::Event, Akonadi2::ApplicationDomain::Buffer::Event, Akonadi2::ApplicationDomain::Buffer::EventBuilder>
14{
15public:
16 TestEventAdaptorFactory()
17 : DomainTypeAdaptorFactory()
18 {
19 }
20
21 virtual ~TestEventAdaptorFactory() {};
22};
23
24class TestEntityStorage : public EntityStorage<Akonadi2::ApplicationDomain::Event>
25{
26public:
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
48class TestResourceAccess : public Akonadi2::ResourceAccessInterface
49{
50 Q_OBJECT
51public:
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
57public Q_SLOTS:
58 void open() Q_DECL_OVERRIDE {}
59 void close() Q_DECL_OVERRIDE {}
60};
61
62class TestResourceFacade : public Akonadi2::GenericFacade<Akonadi2::ApplicationDomain::Event>
63{
64public:
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
76class GenericFacadeTest : public QObject 16class GenericFacadeTest : public QObject
77{ 17{
diff --git a/tests/genericresourcebenchmark.cpp b/tests/genericresourcebenchmark.cpp
index 50d0c67..1776c81 100644
--- a/tests/genericresourcebenchmark.cpp
+++ b/tests/genericresourcebenchmark.cpp
@@ -2,6 +2,8 @@
2 2
3#include <QString> 3#include <QString>
4 4
5#include "testimplementations.h"
6
5#include "event_generated.h" 7#include "event_generated.h"
6#include "createentity_generated.h" 8#include "createentity_generated.h"
7#include "commands.h" 9#include "commands.h"
@@ -15,31 +17,6 @@
15#include "hawd/dataset.h" 17#include "hawd/dataset.h"
16#include "hawd/formatter.h" 18#include "hawd/formatter.h"
17 19
18class TestResource : public Akonadi2::GenericResource
19{
20public:
21 TestResource(const QByteArray &instanceIdentifier, QSharedPointer<Akonadi2::Pipeline> pipeline)
22 : Akonadi2::GenericResource(instanceIdentifier, pipeline)
23 {
24 }
25
26 KAsync::Job<void> synchronizeWithSource() Q_DECL_OVERRIDE
27 {
28 return KAsync::null<void>();
29 }
30};
31
32class TestEventAdaptorFactory : public DomainTypeAdaptorFactory<Akonadi2::ApplicationDomain::Event, Akonadi2::ApplicationDomain::Buffer::Event, Akonadi2::ApplicationDomain::Buffer::EventBuilder>
33{
34public:
35 TestEventAdaptorFactory()
36 : DomainTypeAdaptorFactory()
37 {
38 }
39
40 virtual ~TestEventAdaptorFactory() {};
41};
42
43 20
44static void removeFromDisk(const QString &name) 21static void removeFromDisk(const QString &name)
45{ 22{
diff --git a/tests/genericresourcetest.cpp b/tests/genericresourcetest.cpp
index fa6da22..60b1dab 100644
--- a/tests/genericresourcetest.cpp
+++ b/tests/genericresourcetest.cpp
@@ -2,6 +2,8 @@
2 2
3#include <QString> 3#include <QString>
4 4
5#include "testimplementations.h"
6
5#include "event_generated.h" 7#include "event_generated.h"
6#include "entity_generated.h" 8#include "entity_generated.h"
7#include "metadata_generated.h" 9#include "metadata_generated.h"
@@ -12,21 +14,6 @@
12#include "genericresource.h" 14#include "genericresource.h"
13#include "definitions.h" 15#include "definitions.h"
14 16
15class TestResource : public Akonadi2::GenericResource
16{
17public:
18 TestResource(const QByteArray &instanceIdentifier, QSharedPointer<Akonadi2::Pipeline> pipeline)
19 : Akonadi2::GenericResource(instanceIdentifier, pipeline)
20 {
21 }
22
23 KAsync::Job<void> synchronizeWithSource() Q_DECL_OVERRIDE
24 {
25 return KAsync::null<void>();
26 }
27};
28
29
30static void removeFromDisk(const QString &name) 17static void removeFromDisk(const QString &name)
31{ 18{
32 Akonadi2::Storage store(Akonadi2::storageLocation(), name, Akonadi2::Storage::ReadWrite); 19 Akonadi2::Storage store(Akonadi2::storageLocation(), name, Akonadi2::Storage::ReadWrite);
diff --git a/tests/pipelinetest.cpp b/tests/pipelinetest.cpp
index 4cff511..9aa7024 100644
--- a/tests/pipelinetest.cpp
+++ b/tests/pipelinetest.cpp
@@ -2,6 +2,8 @@
2 2
3#include <QString> 3#include <QString>
4 4
5#include "testimplementations.h"
6
5#include "event_generated.h" 7#include "event_generated.h"
6#include "entity_generated.h" 8#include "entity_generated.h"
7#include "metadata_generated.h" 9#include "metadata_generated.h"
@@ -18,17 +20,6 @@
18#include "log.h" 20#include "log.h"
19#include "domainadaptor.h" 21#include "domainadaptor.h"
20 22
21class TestEventAdaptorFactory : public DomainTypeAdaptorFactory<Akonadi2::ApplicationDomain::Event, Akonadi2::ApplicationDomain::Buffer::Event, Akonadi2::ApplicationDomain::Buffer::EventBuilder>
22{
23public:
24 TestEventAdaptorFactory()
25 : DomainTypeAdaptorFactory()
26 {
27 }
28
29 virtual ~TestEventAdaptorFactory() {};
30};
31
32static void removeFromDisk(const QString &name) 23static void removeFromDisk(const QString &name)
33{ 24{
34 Akonadi2::Storage store(Akonadi2::Store::storageLocation(), name, Akonadi2::Storage::ReadWrite); 25 Akonadi2::Storage store(Akonadi2::Store::storageLocation(), name, Akonadi2::Storage::ReadWrite);
diff --git a/tests/testimplementations.cpp b/tests/testimplementations.cpp
new file mode 100644
index 0000000..1040956
--- /dev/null
+++ b/tests/testimplementations.cpp
@@ -0,0 +1,23 @@
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
21#include "testimplementations.h"
22
23#include "testimplementations.moc"
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};