diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-01-03 10:41:36 +0100 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2018-01-03 10:41:36 +0100 |
commit | 5eb014833160d0dbd1c27742a7fcddb0ede31859 (patch) | |
tree | 34c967e1a73c90abb9b16a5a46acb73bc865b5a4 /tests | |
parent | 067bdf2c55d6459ed7bd93e295fdf32deae12158 (diff) | |
download | sink-5eb014833160d0dbd1c27742a7fcddb0ede31859.tar.gz sink-5eb014833160d0dbd1c27742a7fcddb0ede31859.zip |
Demonstrate the problem with child indexes entering before parent
indexes
Diffstat (limited to 'tests')
-rw-r--r-- | tests/clientapitest.cpp | 35 |
1 files changed, 34 insertions, 1 deletions
diff --git a/tests/clientapitest.cpp b/tests/clientapitest.cpp index 2ebef5f..6e8403f 100644 --- a/tests/clientapitest.cpp +++ b/tests/clientapitest.cpp | |||
@@ -198,6 +198,7 @@ private slots: | |||
198 | void testModelNested() | 198 | void testModelNested() |
199 | { | 199 | { |
200 | auto facade = setupFacade<Sink::ApplicationDomain::Folder>("dummyresource.instance1"); | 200 | auto facade = setupFacade<Sink::ApplicationDomain::Folder>("dummyresource.instance1"); |
201 | facade->runAsync = true; | ||
201 | auto folder = QSharedPointer<Sink::ApplicationDomain::Folder>::create("resource", "id", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | 202 | auto folder = QSharedPointer<Sink::ApplicationDomain::Folder>::create("resource", "id", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
202 | auto subfolder = QSharedPointer<Sink::ApplicationDomain::Folder>::create("resource", "subId", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | 203 | auto subfolder = QSharedPointer<Sink::ApplicationDomain::Folder>::create("resource", "subId", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); |
203 | subfolder->setParent("id"); | 204 | subfolder->setParent("id"); |
@@ -209,11 +210,43 @@ private slots: | |||
209 | query.requestTree("parent"); | 210 | query.requestTree("parent"); |
210 | 211 | ||
211 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); | 212 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); |
213 | QObject::connect(model.data(), &QAbstractItemModel::rowsInserted, [&] (const QModelIndex &parent, int first, int last) { | ||
214 | for (int row = first; row <= last; row++) { | ||
215 | auto index = model->index(row, 0, parent); | ||
216 | QVERIFY(index.isValid()); | ||
217 | QVERIFY(index.data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>()); | ||
218 | } | ||
219 | }); | ||
212 | QTRY_COMPARE(model->rowCount(), 1); | 220 | QTRY_COMPARE(model->rowCount(), 1); |
213 | model->fetchMore(model->index(0, 0)); | ||
214 | QTRY_COMPARE(model->rowCount(model->index(0, 0)), 1); | 221 | QTRY_COMPARE(model->rowCount(model->index(0, 0)), 1); |
215 | } | 222 | } |
216 | 223 | ||
224 | void testModelNestedReverse() | ||
225 | { | ||
226 | auto facade = setupFacade<Sink::ApplicationDomain::Folder>("dummyresource.instance1"); | ||
227 | facade->runAsync = true; | ||
228 | auto folder = QSharedPointer<Sink::ApplicationDomain::Folder>::create("resource", "id", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | ||
229 | auto subfolder = QSharedPointer<Sink::ApplicationDomain::Folder>::create("resource", "subId", 0, QSharedPointer<Sink::ApplicationDomain::MemoryBufferAdaptor>::create()); | ||
230 | subfolder->setParent("id"); | ||
231 | facade->results << subfolder << folder; | ||
232 | |||
233 | // Test | ||
234 | Sink::Query query; | ||
235 | query.resourceFilter("dummyresource.instance1"); | ||
236 | query.requestTree("parent"); | ||
237 | |||
238 | auto model = Sink::Store::loadModel<Sink::ApplicationDomain::Folder>(query); | ||
239 | QObject::connect(model.data(), &QAbstractItemModel::rowsInserted, [&] (const QModelIndex &parent, int first, int last) { | ||
240 | for (int row = first; row <= last; row++) { | ||
241 | auto index = model->index(row, 0, parent); | ||
242 | QVERIFY(index.isValid()); | ||
243 | QVERIFY(index.data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>()); | ||
244 | } | ||
245 | }); | ||
246 | QTRY_COMPARE(model->rowCount(), 1); | ||
247 | QVERIFY(model->index(0, 0).data(Sink::Store::DomainObjectRole).value<Sink::ApplicationDomain::Folder::Ptr>()); | ||
248 | QTRY_COMPARE(model->rowCount(model->index(0, 0)), 1); | ||
249 | } | ||
217 | 250 | ||
218 | void testModelNestedLive() | 251 | void testModelNestedLive() |
219 | { | 252 | { |