diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/genericfacadebenchmark.cpp | 3 | ||||
-rw-r--r-- | tests/genericfacadetest.cpp | 39 | ||||
-rw-r--r-- | tests/testimplementations.h | 26 |
3 files changed, 19 insertions, 49 deletions
diff --git a/tests/genericfacadebenchmark.cpp b/tests/genericfacadebenchmark.cpp index 29c91d7..94d6f41 100644 --- a/tests/genericfacadebenchmark.cpp +++ b/tests/genericfacadebenchmark.cpp | |||
@@ -56,8 +56,7 @@ private Q_SLOTS: | |||
56 | QBENCHMARK { | 56 | QBENCHMARK { |
57 | auto resultSet = QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Event::Ptr> >::create(); | 57 | auto resultSet = QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Event::Ptr> >::create(); |
58 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); | 58 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); |
59 | auto storage = QSharedPointer<EntityStorage<Akonadi2::ApplicationDomain::Event> >::create("identifier"); | 59 | TestResourceFacade facade(identifier, resourceAccess); |
60 | TestResourceFacade facade(identifier, storage, resourceAccess); | ||
61 | 60 | ||
62 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(resultSet->emitter()); | 61 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(resultSet->emitter()); |
63 | 62 | ||
diff --git a/tests/genericfacadetest.cpp b/tests/genericfacadetest.cpp index 67320c3..9e7500f 100644 --- a/tests/genericfacadetest.cpp +++ b/tests/genericfacadetest.cpp | |||
@@ -17,6 +17,7 @@ | |||
17 | * Test for the generic facade implementation. | 17 | * Test for the generic facade implementation. |
18 | * | 18 | * |
19 | * This test doesn't use the actual storage and thus only tests the update logic of the facade. | 19 | * This test doesn't use the actual storage and thus only tests the update logic of the facade. |
20 | * //FIXME this now uses the actual storage | ||
20 | */ | 21 | */ |
21 | class GenericFacadeTest : public QObject | 22 | class GenericFacadeTest : public QObject |
22 | { | 23 | { |
@@ -34,10 +35,9 @@ private Q_SLOTS: | |||
34 | query.liveQuery = false; | 35 | query.liveQuery = false; |
35 | 36 | ||
36 | auto resultSet = QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Event::Ptr> >::create(); | 37 | auto resultSet = QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Event::Ptr> >::create(); |
37 | auto storage = QSharedPointer<TestEntityStorage>::create("identifier"); | ||
38 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); | 38 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); |
39 | storage->mResults << Akonadi2::ApplicationDomain::Event::Ptr::create(); | 39 | // storage->mResults << Akonadi2::ApplicationDomain::Event::Ptr::create(); |
40 | TestResourceFacade facade("identifier", storage, resourceAccess); | 40 | TestResourceFacade facade("identifier", resourceAccess); |
41 | 41 | ||
42 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(resultSet->emitter()); | 42 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(resultSet->emitter()); |
43 | 43 | ||
@@ -56,10 +56,9 @@ private Q_SLOTS: | |||
56 | query.liveQuery = true; | 56 | query.liveQuery = true; |
57 | 57 | ||
58 | auto resultSet = QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Event::Ptr> >::create(); | 58 | auto resultSet = QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Event::Ptr> >::create(); |
59 | auto storage = QSharedPointer<TestEntityStorage>::create("identifier"); | ||
60 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); | 59 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); |
61 | storage->mResults << Akonadi2::ApplicationDomain::Event::Ptr::create(); | 60 | // storage->mResults << Akonadi2::ApplicationDomain::Event::Ptr::create(); |
62 | TestResourceFacade facade("identifier", storage, resourceAccess); | 61 | TestResourceFacade facade("identifier", resourceAccess); |
63 | 62 | ||
64 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(resultSet->emitter()); | 63 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(resultSet->emitter()); |
65 | 64 | ||
@@ -70,9 +69,9 @@ private Q_SLOTS: | |||
70 | QCOMPARE(result.size(), 1); | 69 | QCOMPARE(result.size(), 1); |
71 | 70 | ||
72 | //Enter a second result | 71 | //Enter a second result |
73 | storage->mResults.clear(); | 72 | // storage->mResults.clear(); |
74 | storage->mResults << QSharedPointer<Akonadi2::ApplicationDomain::Event>::create("resource", "id2", 0, QSharedPointer<Akonadi2::ApplicationDomain::BufferAdaptor>()); | 73 | // storage->mResults << QSharedPointer<Akonadi2::ApplicationDomain::Event>::create("resource", "id2", 0, QSharedPointer<Akonadi2::ApplicationDomain::BufferAdaptor>()); |
75 | storage->mLatestRevision = 2; | 74 | // storage->mLatestRevision = 2; |
76 | resourceAccess->emit revisionChanged(2); | 75 | resourceAccess->emit revisionChanged(2); |
77 | 76 | ||
78 | //Hack to get event loop in synclistresult to abort again | 77 | //Hack to get event loop in synclistresult to abort again |
@@ -88,12 +87,11 @@ private Q_SLOTS: | |||
88 | query.liveQuery = true; | 87 | query.liveQuery = true; |
89 | 88 | ||
90 | auto resultSet = QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Event::Ptr> >::create(); | 89 | auto resultSet = QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Event::Ptr> >::create(); |
91 | auto storage = QSharedPointer<TestEntityStorage>::create("identifier"); | ||
92 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); | 90 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); |
93 | auto entity = QSharedPointer<Akonadi2::ApplicationDomain::Event>::create("resource", "id2", 0, QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create()); | 91 | auto entity = QSharedPointer<Akonadi2::ApplicationDomain::Event>::create("resource", "id2", 0, QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create()); |
94 | entity->setProperty("test", "test1"); | 92 | entity->setProperty("test", "test1"); |
95 | storage->mResults << entity; | 93 | // storage->mResults << entity; |
96 | TestResourceFacade facade("identifier", storage, resourceAccess); | 94 | TestResourceFacade facade("identifier", resourceAccess); |
97 | 95 | ||
98 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(resultSet->emitter()); | 96 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(resultSet->emitter()); |
99 | 97 | ||
@@ -104,11 +102,11 @@ private Q_SLOTS: | |||
104 | QCOMPARE(result.size(), 1); | 102 | QCOMPARE(result.size(), 1); |
105 | 103 | ||
106 | //Modify the entity again | 104 | //Modify the entity again |
107 | storage->mResults.clear(); | 105 | // storage->mResults.clear(); |
108 | entity = QSharedPointer<Akonadi2::ApplicationDomain::Event>::create("resource", "id2", 0, QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create()); | 106 | entity = QSharedPointer<Akonadi2::ApplicationDomain::Event>::create("resource", "id2", 0, QSharedPointer<Akonadi2::ApplicationDomain::MemoryBufferAdaptor>::create()); |
109 | entity->setProperty("test", "test2"); | 107 | entity->setProperty("test", "test2"); |
110 | storage->mModifications << entity; | 108 | // storage->mModifications << entity; |
111 | storage->mLatestRevision = 2; | 109 | // storage->mLatestRevision = 2; |
112 | resourceAccess->emit revisionChanged(2); | 110 | resourceAccess->emit revisionChanged(2); |
113 | 111 | ||
114 | //Hack to get event loop in synclistresult to abort again | 112 | //Hack to get event loop in synclistresult to abort again |
@@ -125,11 +123,10 @@ private Q_SLOTS: | |||
125 | query.liveQuery = true; | 123 | query.liveQuery = true; |
126 | 124 | ||
127 | auto resultSet = QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Event::Ptr> >::create(); | 125 | auto resultSet = QSharedPointer<Akonadi2::ResultProvider<Akonadi2::ApplicationDomain::Event::Ptr> >::create(); |
128 | auto storage = QSharedPointer<TestEntityStorage>::create("identifier"); | ||
129 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); | 126 | auto resourceAccess = QSharedPointer<TestResourceAccess>::create(); |
130 | auto entity = QSharedPointer<Akonadi2::ApplicationDomain::Event>::create("resource", "id2", 0, QSharedPointer<Akonadi2::ApplicationDomain::BufferAdaptor>()); | 127 | auto entity = QSharedPointer<Akonadi2::ApplicationDomain::Event>::create("resource", "id2", 0, QSharedPointer<Akonadi2::ApplicationDomain::BufferAdaptor>()); |
131 | storage->mResults << entity; | 128 | // storage->mResults << entity; |
132 | TestResourceFacade facade("identifier", storage, resourceAccess); | 129 | TestResourceFacade facade("identifier", resourceAccess); |
133 | 130 | ||
134 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(resultSet->emitter()); | 131 | async::SyncListResult<Akonadi2::ApplicationDomain::Event::Ptr> result(resultSet->emitter()); |
135 | 132 | ||
@@ -140,9 +137,9 @@ private Q_SLOTS: | |||
140 | QCOMPARE(result.size(), 1); | 137 | QCOMPARE(result.size(), 1); |
141 | 138 | ||
142 | //Remove the entity again | 139 | //Remove the entity again |
143 | storage->mResults.clear(); | 140 | // storage->mResults.clear(); |
144 | storage->mRemovals << entity; | 141 | // storage->mRemovals << entity; |
145 | storage->mLatestRevision = 2; | 142 | // storage->mLatestRevision = 2; |
146 | resourceAccess->emit revisionChanged(2); | 143 | resourceAccess->emit revisionChanged(2); |
147 | 144 | ||
148 | //Hack to get event loop in synclistresult to abort again | 145 | //Hack to get event loop in synclistresult to abort again |
diff --git a/tests/testimplementations.h b/tests/testimplementations.h index 1436c68..c371456 100644 --- a/tests/testimplementations.h +++ b/tests/testimplementations.h | |||
@@ -21,13 +21,11 @@ | |||
21 | 21 | ||
22 | #include <Async/Async> | 22 | #include <Async/Async> |
23 | 23 | ||
24 | #include <common/entitystorage.h> | ||
25 | #include <common/domainadaptor.h> | 24 | #include <common/domainadaptor.h> |
26 | #include <common/resultprovider.h> | 25 | #include <common/resultprovider.h> |
27 | #include <common/synclistresult.h> | 26 | #include <common/synclistresult.h> |
28 | #include <common/resourceaccess.h> | 27 | #include <common/resourceaccess.h> |
29 | #include <common/facade.h> | 28 | #include <common/facade.h> |
30 | #include <common/entitystorage.h> | ||
31 | #include <common/genericresource.h> | 29 | #include <common/genericresource.h> |
32 | 30 | ||
33 | //Replace with something different | 31 | //Replace with something different |
@@ -44,30 +42,6 @@ public: | |||
44 | virtual ~TestEventAdaptorFactory() {}; | 42 | virtual ~TestEventAdaptorFactory() {}; |
45 | }; | 43 | }; |
46 | 44 | ||
47 | class TestEntityStorage : public EntityStorage<Akonadi2::ApplicationDomain::Event> | ||
48 | { | ||
49 | public: | ||
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 | |||
71 | class TestResourceAccess : public Akonadi2::ResourceAccessInterface | 45 | class TestResourceAccess : public Akonadi2::ResourceAccessInterface |
72 | { | 46 | { |
73 | Q_OBJECT | 47 | Q_OBJECT |