diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-11-15 12:46:26 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2015-11-15 12:46:26 +0100 |
commit | 972f3a4e96876e4c36162a11062e40863d88a2a1 (patch) | |
tree | e5173c26f35895e8f3386822d47b7b0d93374db5 | |
parent | d4b10a3de396eebc6c815093e9e1725ece270e9e (diff) | |
download | sink-972f3a4e96876e4c36162a11062e40863d88a2a1.tar.gz sink-972f3a4e96876e4c36162a11062e40863d88a2a1.zip |
Cleanup
-rw-r--r-- | common/CMakeLists.txt | 1 | ||||
-rw-r--r-- | common/entitystorage.cpp | 74 | ||||
-rw-r--r-- | common/entitystorage.h | 126 | ||||
-rw-r--r-- | common/facade.h | 3 | ||||
-rw-r--r-- | common/resourceaccess.cpp | 2 | ||||
-rw-r--r-- | tests/genericfacadebenchmark.cpp | 3 | ||||
-rw-r--r-- | tests/genericfacadetest.cpp | 39 | ||||
-rw-r--r-- | tests/testimplementations.h | 26 |
8 files changed, 22 insertions, 252 deletions
diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index f24ec46..bdb9eac 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt | |||
@@ -15,7 +15,6 @@ set(command_SRCS | |||
15 | definitions.cpp | 15 | definitions.cpp |
16 | log.cpp | 16 | log.cpp |
17 | entitybuffer.cpp | 17 | entitybuffer.cpp |
18 | entitystorage.cpp | ||
19 | clientapi.cpp | 18 | clientapi.cpp |
20 | facadefactory.cpp | 19 | facadefactory.cpp |
21 | commands.cpp | 20 | commands.cpp |
diff --git a/common/entitystorage.cpp b/common/entitystorage.cpp deleted file mode 100644 index 5d4df9f..0000000 --- a/common/entitystorage.cpp +++ /dev/null | |||
@@ -1,74 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Christian Mollekopf <chrigi_1@fastmail.fm> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | |||
20 | #include "entitystorage.h" | ||
21 | |||
22 | ResultSet EntityStorageBase::filteredSet(const ResultSet &resultSet, const std::function<bool(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &domainObject)> &filter, const Akonadi2::Storage::Transaction &transaction, bool initialQuery) | ||
23 | { | ||
24 | auto resultSetPtr = QSharedPointer<ResultSet>::create(resultSet); | ||
25 | |||
26 | //Read through the source values and return whatever matches the filter | ||
27 | std::function<bool(std::function<void(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &, Akonadi2::Operation)>)> generator = [this, resultSetPtr, &transaction, filter, initialQuery](std::function<void(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &, Akonadi2::Operation)> callback) -> bool { | ||
28 | while (resultSetPtr->next()) { | ||
29 | readEntity(transaction, resultSetPtr->id(), [this, filter, callback, initialQuery](const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &domainObject, Akonadi2::Operation operation) { | ||
30 | //Always remove removals, they probably don't match due to non-available properties | ||
31 | if (filter(domainObject) || operation == Akonadi2::Operation_Removal) { | ||
32 | if (initialQuery) { | ||
33 | //We're not interested in removals during the initial query | ||
34 | if (operation != Akonadi2::Operation_Removal) { | ||
35 | callback(domainObject, Akonadi2::Operation_Creation); | ||
36 | } | ||
37 | } else { | ||
38 | callback(domainObject, operation); | ||
39 | } | ||
40 | } | ||
41 | }); | ||
42 | } | ||
43 | return false; | ||
44 | }; | ||
45 | return ResultSet(generator); | ||
46 | } | ||
47 | |||
48 | |||
49 | ResultSet EntityStorageBase::getResultSet(const Akonadi2::Query &query, Akonadi2::Storage::Transaction &transaction, qint64 baseRevision) | ||
50 | { | ||
51 | QSet<QByteArray> remainingFilters = query.propertyFilter.keys().toSet(); | ||
52 | ResultSet resultSet; | ||
53 | const bool initialQuery = (baseRevision == 1); | ||
54 | if (initialQuery) { | ||
55 | Trace() << "Initial result set update"; | ||
56 | resultSet = loadInitialResultSet(query, transaction, remainingFilters); | ||
57 | } else { | ||
58 | //TODO fallback in case the old revision is no longer available to clear + redo complete initial scan | ||
59 | Trace() << "Incremental result set update" << baseRevision; | ||
60 | resultSet = loadIncrementalResultSet(baseRevision, query, transaction, remainingFilters); | ||
61 | } | ||
62 | |||
63 | auto filter = [remainingFilters, query, baseRevision](const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &domainObject) -> bool { | ||
64 | for (const auto &filterProperty : remainingFilters) { | ||
65 | //TODO implement other comparison operators than equality | ||
66 | if (domainObject->getProperty(filterProperty) != query.propertyFilter.value(filterProperty)) { | ||
67 | return false; | ||
68 | } | ||
69 | } | ||
70 | return true; | ||
71 | }; | ||
72 | |||
73 | return filteredSet(resultSet, filter, transaction, initialQuery); | ||
74 | } | ||
diff --git a/common/entitystorage.h b/common/entitystorage.h deleted file mode 100644 index 8e73083..0000000 --- a/common/entitystorage.h +++ /dev/null | |||
@@ -1,126 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Christian Mollekopf <chrigi_1@fastmail.fm> | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | * | ||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | * | ||
14 | * You should have received a copy of the GNU General Public License | ||
15 | * along with this program; if not, write to the | ||
16 | * Free Software Foundation, Inc., | ||
17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
18 | */ | ||
19 | #pragma once | ||
20 | |||
21 | #include <QByteArray> | ||
22 | |||
23 | #include "query.h" | ||
24 | #include "domainadaptor.h" | ||
25 | #include "entitybuffer.h" | ||
26 | #include "log.h" | ||
27 | #include "storage.h" | ||
28 | #include "resultset.h" | ||
29 | #include "resultprovider.h" | ||
30 | #include "definitions.h" | ||
31 | |||
32 | /** | ||
33 | * Wraps storage, entity adaptor factory and indexes into one. | ||
34 | * | ||
35 | */ | ||
36 | class EntityStorageBase | ||
37 | { | ||
38 | public: | ||
39 | typedef std::function<ResultSet (const Akonadi2::Query &query, Akonadi2::Storage::Transaction &transaction, QSet<QByteArray> &remainingFilters)> InitialResultLoader; | ||
40 | typedef std::function<ResultSet (qint64 baseRevision, const Akonadi2::Query &query, Akonadi2::Storage::Transaction &transaction, QSet<QByteArray> &remainingFilters)> IncrementalResultLoader; | ||
41 | typedef std::function<void(const Akonadi2::Storage::Transaction &transaction, const QByteArray &key, const std::function<void(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &, Akonadi2::Operation)> &resultCallback)> EntityReader; | ||
42 | |||
43 | /** | ||
44 | * Returns the initial result set that still needs to be filtered. | ||
45 | * | ||
46 | * To make this efficient indexes should be chosen that are as selective as possible. | ||
47 | */ | ||
48 | InitialResultLoader loadInitialResultSet; | ||
49 | /** | ||
50 | * Returns the incremental result set that still needs to be filtered. | ||
51 | */ | ||
52 | IncrementalResultLoader loadIncrementalResultSet; | ||
53 | |||
54 | /** | ||
55 | * Loads a single entity by uid from storage. | ||
56 | */ | ||
57 | EntityReader readEntity; | ||
58 | |||
59 | protected: | ||
60 | EntityStorageBase(const QByteArray &instanceIdentifier) | ||
61 | : mResourceInstanceIdentifier(instanceIdentifier) | ||
62 | { | ||
63 | |||
64 | } | ||
65 | |||
66 | virtual Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr copy(const Akonadi2::ApplicationDomain::ApplicationDomainType &) = 0; | ||
67 | |||
68 | ResultSet getResultSet(const Akonadi2::Query &query, Akonadi2::Storage::Transaction &transaction, qint64 baseRevision); | ||
69 | |||
70 | QByteArray mResourceInstanceIdentifier; | ||
71 | |||
72 | private: | ||
73 | ResultSet filteredSet(const ResultSet &resultSet, const std::function<bool(const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &domainObject)> &filter, const Akonadi2::Storage::Transaction &transaction, bool isInitialQuery); | ||
74 | }; | ||
75 | |||
76 | template<typename DomainType> | ||
77 | class EntityStorage : public EntityStorageBase | ||
78 | { | ||
79 | |||
80 | public: | ||
81 | |||
82 | EntityStorage(const QByteArray &instanceIdentifier) | ||
83 | : EntityStorageBase(instanceIdentifier) | ||
84 | { | ||
85 | } | ||
86 | |||
87 | protected: | ||
88 | Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr copy(const Akonadi2::ApplicationDomain::ApplicationDomainType &object) Q_DECL_OVERRIDE | ||
89 | { | ||
90 | return Akonadi2::ApplicationDomain::ApplicationDomainType::getInMemoryRepresentation<DomainType>(object); | ||
91 | } | ||
92 | |||
93 | public: | ||
94 | |||
95 | virtual qint64 read(const Akonadi2::Query &query, qint64 baseRevision, const QSharedPointer<Akonadi2::ResultProvider<typename DomainType::Ptr> > &resultProvider) | ||
96 | { | ||
97 | Akonadi2::Storage storage(Akonadi2::storageLocation(), mResourceInstanceIdentifier); | ||
98 | storage.setDefaultErrorHandler([](const Akonadi2::Storage::Error &error) { | ||
99 | Warning() << "Error during query: " << error.store << error.message; | ||
100 | }); | ||
101 | |||
102 | auto transaction = storage.createTransaction(Akonadi2::Storage::ReadOnly); | ||
103 | |||
104 | Log() << "Querying" << baseRevision << Akonadi2::Storage::maxRevision(transaction); | ||
105 | auto resultSet = getResultSet(query, transaction, baseRevision); | ||
106 | while(resultSet.next([this, resultProvider](const Akonadi2::ApplicationDomain::ApplicationDomainType::Ptr &value, Akonadi2::Operation operation) -> bool { | ||
107 | switch (operation) { | ||
108 | case Akonadi2::Operation_Creation: | ||
109 | Trace() << "Got creation"; | ||
110 | resultProvider->add(copy(*value).template staticCast<DomainType>()); | ||
111 | break; | ||
112 | case Akonadi2::Operation_Modification: | ||
113 | Trace() << "Got modification"; | ||
114 | resultProvider->modify(copy(*value).template staticCast<DomainType>()); | ||
115 | break; | ||
116 | case Akonadi2::Operation_Removal: | ||
117 | Trace() << "Got removal"; | ||
118 | resultProvider->remove(copy(*value).template staticCast<DomainType>()); | ||
119 | break; | ||
120 | } | ||
121 | return true; | ||
122 | })){}; | ||
123 | return Akonadi2::Storage::maxRevision(transaction); | ||
124 | } | ||
125 | |||
126 | }; | ||
diff --git a/common/facade.h b/common/facade.h index 5be1c73..6e45e08 100644 --- a/common/facade.h +++ b/common/facade.h | |||
@@ -29,7 +29,8 @@ | |||
29 | #include "domainadaptor.h" | 29 | #include "domainadaptor.h" |
30 | #include "log.h" | 30 | #include "log.h" |
31 | #include "resultset.h" | 31 | #include "resultset.h" |
32 | #include "entitystorage.h" | 32 | #include "storage.h" |
33 | #include "definitions.h" | ||
33 | 34 | ||
34 | /** | 35 | /** |
35 | * A QueryRunner runs a query and updates the corresponding result set. | 36 | * A QueryRunner runs a query and updates the corresponding result set. |
diff --git a/common/resourceaccess.cpp b/common/resourceaccess.cpp index bd9e2c9..88f785f 100644 --- a/common/resourceaccess.cpp +++ b/common/resourceaccess.cpp | |||
@@ -340,7 +340,7 @@ KAsync::Job<void> ResourceAccess::sendRevisionReplayedCommand(qint64 revision) | |||
340 | void ResourceAccess::open() | 340 | void ResourceAccess::open() |
341 | { | 341 | { |
342 | if (d->socket && d->socket->isValid()) { | 342 | if (d->socket && d->socket->isValid()) { |
343 | log("Socket valid, so not opening again"); | 343 | Trace() << "Socket valid, so not opening again"; |
344 | return; | 344 | return; |
345 | } | 345 | } |
346 | if (d->openingSocket) { | 346 | if (d->openingSocket) { |
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 |