diff options
Diffstat (limited to 'tests/genericfacadetest.cpp')
-rw-r--r-- | tests/genericfacadetest.cpp | 47 |
1 files changed, 22 insertions, 25 deletions
diff --git a/tests/genericfacadetest.cpp b/tests/genericfacadetest.cpp index 67320c3..bb95f4e 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,14 +35,13 @@ 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 | ||
44 | facade.load(query, resultSet).exec().waitForFinished(); | 44 | facade.load(query, *resultSet).exec().waitForFinished(); |
45 | resultSet->initialResultSetComplete(); | 45 | resultSet->initialResultSetComplete(); |
46 | 46 | ||
47 | //We have to wait for the events that deliver the results to be processed by the eventloop | 47 | //We have to wait for the events that deliver the results to be processed by the eventloop |
@@ -56,23 +56,22 @@ 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 | ||
66 | facade.load(query, resultSet).exec().waitForFinished(); | 65 | facade.load(query, *resultSet).exec().waitForFinished(); |
67 | resultSet->initialResultSetComplete(); | 66 | resultSet->initialResultSetComplete(); |
68 | 67 | ||
69 | result.exec(); | 68 | result.exec(); |
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,27 +87,26 @@ 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 | ||
100 | facade.load(query, resultSet).exec().waitForFinished(); | 98 | facade.load(query, *resultSet).exec().waitForFinished(); |
101 | resultSet->initialResultSetComplete(); | 99 | resultSet->initialResultSetComplete(); |
102 | 100 | ||
103 | result.exec(); | 101 | result.exec(); |
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,24 +123,23 @@ 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 | ||
136 | facade.load(query, resultSet).exec().waitForFinished(); | 133 | facade.load(query, *resultSet).exec().waitForFinished(); |
137 | resultSet->initialResultSetComplete(); | 134 | resultSet->initialResultSetComplete(); |
138 | 135 | ||
139 | result.exec(); | 136 | result.exec(); |
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 |