Changeset View
Changeset View
Standalone View
Standalone View
autotests/libs/entitytreemodeltest.cpp
Show First 20 Lines • Show All 91 Lines • ▼ Show 20 Line(s) | 77 | private Q_SLOTS: | |||
---|---|---|---|---|---|
92 | void testItemAdded(); | 92 | void testItemAdded(); | ||
93 | void testItemRemoved_data(); | 93 | void testItemRemoved_data(); | ||
94 | void testItemRemoved(); | 94 | void testItemRemoved(); | ||
95 | void testItemChanged_data(); | 95 | void testItemChanged_data(); | ||
96 | void testItemChanged(); | 96 | void testItemChanged(); | ||
97 | void testRemoveCollectionOnChanged(); | 97 | void testRemoveCollectionOnChanged(); | ||
98 | 98 | | |||
99 | private: | 99 | private: | ||
100 | ExpectedSignal getExpectedSignal(SignalType type, int start, int end, const QVariantList newData) | | |||
101 | { | | |||
102 | return getExpectedSignal(type, start, end, QVariant(), newData); | | |||
103 | } | | |||
104 | | ||||
105 | ExpectedSignal getExpectedSignal(SignalType type, int start, int end, const QVariant &parentData = QVariant(), const QVariantList newData = QVariantList()) | | |||
106 | { | | |||
107 | ExpectedSignal expectedSignal; | | |||
108 | expectedSignal.signalType = type; | | |||
109 | expectedSignal.startRow = start; | | |||
110 | expectedSignal.endRow = end; | | |||
111 | expectedSignal.parentData = parentData; | | |||
112 | expectedSignal.newData = newData; | | |||
113 | return expectedSignal; | | |||
114 | } | | |||
115 | | ||||
116 | ExpectedSignal getExpectedSignal(SignalType type, int start, int end, const QVariant &sourceParentData, int destRow, const QVariant &destParentData, const QVariantList newData) | | |||
117 | { | | |||
118 | ExpectedSignal expectedSignal; | | |||
119 | expectedSignal.signalType = type; | | |||
120 | expectedSignal.startRow = start; | | |||
121 | expectedSignal.endRow = end; | | |||
122 | expectedSignal.sourceParentData = sourceParentData; | | |||
123 | expectedSignal.destRow = destRow; | | |||
124 | expectedSignal.parentData = destParentData; | | |||
125 | expectedSignal.newData = newData; | | |||
126 | return expectedSignal; | | |||
127 | } | | |||
128 | | ||||
129 | QPair<FakeServerData *, Akonadi::EntityTreeModel *> populateModel(const QString &serverContent, const QString &mimeType = QString()) | 100 | QPair<FakeServerData *, Akonadi::EntityTreeModel *> populateModel(const QString &serverContent, const QString &mimeType = QString()) | ||
130 | { | 101 | { | ||
131 | FakeMonitor *fakeMonitor = new FakeMonitor(this); | 102 | FakeMonitor *fakeMonitor = new FakeMonitor(this); | ||
132 | 103 | | |||
133 | fakeMonitor->setSession(m_fakeSession); | 104 | fakeMonitor->setSession(m_fakeSession); | ||
134 | fakeMonitor->setCollectionMonitored(Collection::root()); | 105 | fakeMonitor->setCollectionMonitored(Collection::root()); | ||
135 | if (!mimeType.isEmpty()) { | 106 | if (!mimeType.isEmpty()) { | ||
136 | fakeMonitor->setMimeTypeMonitored(mimeType); | 107 | fakeMonitor->setMimeTypeMonitored(mimeType); | ||
Show All 37 Lines | 139 | { | |||
174 | 145 | | |||
175 | FakeServerData *serverData = new FakeServerData(model, m_fakeSession, fakeMonitor); | 146 | FakeServerData *serverData = new FakeServerData(model, m_fakeSession, fakeMonitor); | ||
176 | QList<FakeAkonadiServerCommand *> initialFetchResponse = FakeJobResponse::interpret(serverData, serverContent1); | 147 | QList<FakeAkonadiServerCommand *> initialFetchResponse = FakeJobResponse::interpret(serverData, serverContent1); | ||
177 | serverData->setCommands(initialFetchResponse); | 148 | serverData->setCommands(initialFetchResponse); | ||
178 | 149 | | |||
179 | m_modelSpy = new ModelSpy{model, this}; | 150 | m_modelSpy = new ModelSpy{model, this}; | ||
180 | m_modelSpy->startSpying(); | 151 | m_modelSpy->startSpying(); | ||
181 | 152 | | |||
182 | QList<ExpectedSignal> expectedSignals; | 153 | const QList<ExpectedSignal> expectedSignals { | ||
183 | | ||||
184 | // First the model gets a signal about the first collection to be returned, which is not a top-level collection. | 154 | // First the model gets a signal about the first collection to be returned, which is not a top-level collection. | ||
185 | // It uses the parentCollection hierarchy to put placeholder collections in the model until the root is reached. | 155 | // It uses the parentCollection hierarchy to put placeholder collections in the model until the root is reached. | ||
186 | // Then it inserts only one row and emits the correct signals. After that, when the other collections | 156 | // Then it inserts only one row and emits the correct signals. After that, when the other collections | ||
187 | // arrive, dataChanged is emitted for them. | 157 | // arrive, dataChanged is emitted for them. | ||
188 | 158 | {RowsAboutToBeInserted, 0, 0}, | |||
dvratil: You may even be able to get rid of the type name, as that can be deduced from the initializer… | |||||
189 | expectedSignals << getExpectedSignal(RowsAboutToBeInserted, 0, 0); | 159 | {RowsInserted, 0, 0}, | ||
190 | expectedSignals << getExpectedSignal(RowsInserted, 0, 0); | 160 | {DataChanged, 0, 0, QVariantList{QStringLiteral("Col 4")}}, | ||
191 | expectedSignals << getExpectedSignal(DataChanged, 0, 0, QVariantList() << QStringLiteral("Col 4")); | 161 | {DataChanged, 0, 0, QVariantList{QStringLiteral("Col 3")}}, | ||
192 | expectedSignals << getExpectedSignal(DataChanged, 0, 0, QVariantList() << QStringLiteral("Col 3")); | | |||
193 | // New collections are prepended | 162 | // New collections are prepended | ||
194 | expectedSignals << getExpectedSignal(RowsAboutToBeInserted, 0, 0, QStringLiteral("Collection 1")); | 163 | {RowsAboutToBeInserted, 0, 0, QStringLiteral("Collection 1")}, | ||
195 | expectedSignals << getExpectedSignal(RowsInserted, 0, 0, QStringLiteral("Collection 1"), QVariantList() << QStringLiteral("Col 2")); | 164 | {RowsInserted, 0, 0, QStringLiteral("Collection 1"), QVariantList{QStringLiteral("Col 2")}}, | ||
196 | expectedSignals << getExpectedSignal(RowsAboutToBeInserted, 0, 0, QStringLiteral("Collection 1")); | 165 | {RowsAboutToBeInserted, 0, 0, QStringLiteral("Collection 1")}, | ||
197 | expectedSignals << getExpectedSignal(RowsInserted, 0, 0, QStringLiteral("Collection 1"), QVariantList() << QStringLiteral("Col 6")); | 166 | {RowsInserted, 0, 0, QStringLiteral("Collection 1"), QVariantList{QStringLiteral("Col 6")}}, | ||
198 | expectedSignals << getExpectedSignal(RowsAboutToBeInserted, 0, 0, QStringLiteral("Collection 1")); | 167 | {RowsAboutToBeInserted, 0, 0, QStringLiteral("Collection 1")}, | ||
199 | expectedSignals << getExpectedSignal(RowsInserted, 0, 0, QStringLiteral("Collection 1"), QVariantList() << QStringLiteral("Col 7")); | 168 | {RowsInserted, 0, 0, QStringLiteral("Collection 1"), QVariantList{QStringLiteral("Col 7")}}, | ||
200 | expectedSignals << getExpectedSignal(DataChanged, 0, 0, QVariantList() << QStringLiteral("Col 1")); | 169 | {DataChanged, 0, 0, QVariantList{QStringLiteral("Col 1")}}, | ||
201 | // The items in the collections are appended. | 170 | // The items in the collections are appended. | ||
202 | expectedSignals << getExpectedSignal(RowsAboutToBeInserted, 0, 3, QStringLiteral("Col 2")); | 171 | {RowsAboutToBeInserted, 0, 3, QStringLiteral("Col 2")}, | ||
203 | expectedSignals << getExpectedSignal(RowsInserted, 0, 3, QStringLiteral("Col 2")); | 172 | {RowsInserted, 0, 3, QStringLiteral("Col 2")}, | ||
204 | expectedSignals << getExpectedSignal(RowsAboutToBeInserted, 0, 1, QStringLiteral("Col 5")); | 173 | {RowsAboutToBeInserted, 0, 1, QStringLiteral("Col 5")}, | ||
205 | expectedSignals << getExpectedSignal(RowsInserted, 0, 1, QStringLiteral("Col 5")); | 174 | {RowsInserted, 0, 1, QStringLiteral("Col 5")}, | ||
206 | expectedSignals << getExpectedSignal(RowsAboutToBeInserted, 1, 1, QStringLiteral("Col 4")); | 175 | {RowsAboutToBeInserted, 1, 1, QStringLiteral("Col 4")}, | ||
207 | expectedSignals << getExpectedSignal(RowsInserted, 1, 1, QStringLiteral("Col 4")); | 176 | {RowsInserted, 1, 1, QStringLiteral("Col 4")}, | ||
208 | expectedSignals << getExpectedSignal(RowsAboutToBeInserted, 1, 2, QStringLiteral("Col 3")); | 177 | {RowsAboutToBeInserted, 1, 2, QStringLiteral("Col 3")}, | ||
209 | expectedSignals << getExpectedSignal(RowsInserted, 1, 2, QStringLiteral("Col 3")); | 178 | {RowsInserted, 1, 2, QStringLiteral("Col 3")}, | ||
210 | expectedSignals << getExpectedSignal(RowsAboutToBeInserted, 0, 1, QStringLiteral("Col 6")); | 179 | {RowsAboutToBeInserted, 0, 1, QStringLiteral("Col 6")}, | ||
211 | expectedSignals << getExpectedSignal(RowsInserted, 0, 1, QStringLiteral("Col 6")); | 180 | {RowsInserted, 0, 1, QStringLiteral("Col 6")}, | ||
212 | expectedSignals << getExpectedSignal(RowsAboutToBeInserted, 0, 3, QStringLiteral("Col 7")); | 181 | {RowsAboutToBeInserted, 0, 3, QStringLiteral("Col 7")}, | ||
213 | expectedSignals << getExpectedSignal(RowsInserted, 0, 3, QStringLiteral("Col 7")); | 182 | {RowsInserted, 0, 3, QStringLiteral("Col 7")}, | ||
214 | expectedSignals << getExpectedSignal(DataChanged, 0, 0, QVariantList() << QStringLiteral("Col 1")); | 183 | {DataChanged, 0, 0, QVariantList{QStringLiteral("Col 1")}}, | ||
215 | expectedSignals << getExpectedSignal(DataChanged, 3, 3, QVariantList() << QStringLiteral("Col 3")); | 184 | {DataChanged, 3, 3, QVariantList{QStringLiteral("Col 3")}}, | ||
216 | expectedSignals << getExpectedSignal(DataChanged, 0, 0, QVariantList() << QStringLiteral("Col 5")); | 185 | {DataChanged, 0, 0, QVariantList{QStringLiteral("Col 5")}}, | ||
217 | expectedSignals << getExpectedSignal(DataChanged, 0, 0, QVariantList() << QStringLiteral("Col 4")); | 186 | {DataChanged, 0, 0, QVariantList{QStringLiteral("Col 4")}}, | ||
218 | expectedSignals << getExpectedSignal(DataChanged, 2, 2, QVariantList() << QStringLiteral("Col 2")); | 187 | {DataChanged, 2, 2, QVariantList{QStringLiteral("Col 2")}}, | ||
219 | expectedSignals << getExpectedSignal(DataChanged, 1, 1, QVariantList() << QStringLiteral("Col 7")); | 188 | {DataChanged, 1, 1, QVariantList{QStringLiteral("Col 7")}}, | ||
220 | expectedSignals << getExpectedSignal(DataChanged, 0, 0, QVariantList() << QStringLiteral("Col 6")); | 189 | {DataChanged, 0, 0, QVariantList{QStringLiteral("Col 6")}} | ||
221 | 190 | }; | |||
222 | m_modelSpy->setExpectedSignals(expectedSignals); | 191 | m_modelSpy->setExpectedSignals(expectedSignals); | ||
223 | 192 | | |||
224 | // Give the model a chance to run the event loop to process the signals. | 193 | // Give the model a chance to run the event loop to process the signals. | ||
225 | QTest::qWait(10); | 194 | QTest::qWait(10); | ||
226 | 195 | | |||
227 | // We get all the signals we expected. | 196 | // We get all the signals we expected. | ||
228 | QTRY_VERIFY(m_modelSpy->expectedSignals().isEmpty()); | 197 | QTRY_VERIFY(m_modelSpy->expectedSignals().isEmpty()); | ||
229 | 198 | | |||
Show All 38 Lines | 225 | { | |||
268 | QString sourceCollection = movedIndex.parent().data().toString(); | 237 | QString sourceCollection = movedIndex.parent().data().toString(); | ||
269 | int sourceRow = movedIndex.row(); | 238 | int sourceRow = movedIndex.row(); | ||
270 | 239 | | |||
271 | FakeCollectionMovedCommand *moveCommand = new FakeCollectionMovedCommand(movedCollection, sourceCollection, targetCollection, serverData); | 240 | FakeCollectionMovedCommand *moveCommand = new FakeCollectionMovedCommand(movedCollection, sourceCollection, targetCollection, serverData); | ||
272 | 241 | | |||
273 | m_modelSpy->startSpying(); | 242 | m_modelSpy->startSpying(); | ||
274 | serverData->setCommands(QList<FakeAkonadiServerCommand *>() << moveCommand); | 243 | serverData->setCommands(QList<FakeAkonadiServerCommand *>() << moveCommand); | ||
275 | 244 | | |||
276 | QList<ExpectedSignal> expectedSignals; | 245 | const QList<ExpectedSignal> expectedSignals { | ||
277 | 246 | {RowsAboutToBeMoved, sourceRow, sourceRow, sourceCollection, 0, targetCollection, {movedCollection}}, | |||
278 | expectedSignals << getExpectedSignal(RowsAboutToBeMoved, sourceRow, sourceRow, sourceCollection, 0, targetCollection, QVariantList() << movedCollection); | 247 | {RowsMoved, sourceRow, sourceRow, sourceCollection, 0, targetCollection , {movedCollection}} | ||
279 | expectedSignals << getExpectedSignal(RowsMoved, sourceRow, sourceRow, sourceCollection, 0, targetCollection , QVariantList() << movedCollection); | 248 | }; | ||
280 | | ||||
281 | m_modelSpy->setExpectedSignals(expectedSignals); | 249 | m_modelSpy->setExpectedSignals(expectedSignals); | ||
282 | serverData->processNotifications(); | 250 | serverData->processNotifications(); | ||
283 | 251 | | |||
284 | // Give the model a change to run the event loop to process the signals. | 252 | // Give the model a change to run the event loop to process the signals. | ||
285 | QTest::qWait(0); | 253 | QTest::qWait(0); | ||
286 | 254 | | |||
287 | QVERIFY(m_modelSpy->isEmpty()); | 255 | QVERIFY(m_modelSpy->isEmpty()); | ||
288 | } | 256 | } | ||
Show All 22 Lines | 274 | { | |||
311 | QPair<FakeServerData *, Akonadi::EntityTreeModel *> testDrivers = populateModel(serverContent); | 279 | QPair<FakeServerData *, Akonadi::EntityTreeModel *> testDrivers = populateModel(serverContent); | ||
312 | FakeServerData *serverData = testDrivers.first; | 280 | FakeServerData *serverData = testDrivers.first; | ||
313 | 281 | | |||
314 | FakeCollectionAddedCommand *addCommand = new FakeCollectionAddedCommand(addedCollection, parentCollection, serverData); | 282 | FakeCollectionAddedCommand *addCommand = new FakeCollectionAddedCommand(addedCollection, parentCollection, serverData); | ||
315 | 283 | | |||
316 | m_modelSpy->startSpying(); | 284 | m_modelSpy->startSpying(); | ||
317 | serverData->setCommands(QList<FakeAkonadiServerCommand *>() << addCommand); | 285 | serverData->setCommands(QList<FakeAkonadiServerCommand *>() << addCommand); | ||
318 | 286 | | |||
319 | QList<ExpectedSignal> expectedSignals; | 287 | const QList<ExpectedSignal> expectedSignals { | ||
320 | 288 | {RowsAboutToBeInserted, 0, 0, parentCollection, QVariantList{addedCollection}}, | |||
321 | expectedSignals << getExpectedSignal(RowsAboutToBeInserted, 0, 0, parentCollection, QVariantList() << addedCollection); | 289 | {RowsInserted, 0, 0, parentCollection, QVariantList{addedCollection}}, | ||
322 | expectedSignals << getExpectedSignal(RowsInserted, 0, 0, parentCollection, QVariantList() << addedCollection); | | |||
323 | // The data changed signal comes from the item fetch job that is triggered because we have ImmediatePopulation enabled | 290 | // The data changed signal comes from the item fetch job that is triggered because we have ImmediatePopulation enabled | ||
324 | expectedSignals << getExpectedSignal(DataChanged, 0, 0, parentCollection, QVariantList() << addedCollection); | 291 | {DataChanged, 0, 0, parentCollection, QVariantList{addedCollection}} | ||
292 | }; | ||||
325 | 293 | | |||
326 | m_modelSpy->setExpectedSignals(expectedSignals); | 294 | m_modelSpy->setExpectedSignals(expectedSignals); | ||
327 | serverData->processNotifications(); | 295 | serverData->processNotifications(); | ||
328 | 296 | | |||
329 | // Give the model a chance to run the event loop to process the signals. | 297 | // Give the model a chance to run the event loop to process the signals. | ||
330 | QTest::qWait(0); | 298 | QTest::qWait(0); | ||
331 | 299 | | |||
332 | QVERIFY(m_modelSpy->isEmpty()); | 300 | QVERIFY(m_modelSpy->isEmpty()); | ||
Show All 29 Lines | 319 | { | |||
362 | QString parentCollection = removedIndex.parent().data().toString(); | 330 | QString parentCollection = removedIndex.parent().data().toString(); | ||
363 | int sourceRow = removedIndex.row(); | 331 | int sourceRow = removedIndex.row(); | ||
364 | 332 | | |||
365 | FakeCollectionRemovedCommand *removeCommand = new FakeCollectionRemovedCommand(removedCollection, parentCollection, serverData); | 333 | FakeCollectionRemovedCommand *removeCommand = new FakeCollectionRemovedCommand(removedCollection, parentCollection, serverData); | ||
366 | 334 | | |||
367 | m_modelSpy->startSpying(); | 335 | m_modelSpy->startSpying(); | ||
368 | serverData->setCommands(QList<FakeAkonadiServerCommand *>() << removeCommand); | 336 | serverData->setCommands(QList<FakeAkonadiServerCommand *>() << removeCommand); | ||
369 | 337 | | |||
370 | QList<ExpectedSignal> expectedSignals; | 338 | const QList<ExpectedSignal> expectedSignals { | ||
371 | 339 | {RowsAboutToBeRemoved, sourceRow, sourceRow, parentCollection, QVariantList{removedCollection}}, | |||
372 | expectedSignals << getExpectedSignal(RowsAboutToBeRemoved, sourceRow, sourceRow, parentCollection, QVariantList() << removedCollection); | 340 | {RowsRemoved, sourceRow, sourceRow, parentCollection , QVariantList{removedCollection}} | ||
373 | expectedSignals << getExpectedSignal(RowsRemoved, sourceRow, sourceRow, parentCollection , QVariantList() << removedCollection); | 341 | }; | ||
374 | 342 | | |||
375 | m_modelSpy->setExpectedSignals(expectedSignals); | 343 | m_modelSpy->setExpectedSignals(expectedSignals); | ||
376 | serverData->processNotifications(); | 344 | serverData->processNotifications(); | ||
377 | 345 | | |||
378 | // Give the model a chance to run the event loop to process the signals. | 346 | // Give the model a chance to run the event loop to process the signals. | ||
379 | QTest::qWait(0); | 347 | QTest::qWait(0); | ||
380 | 348 | | |||
381 | QVERIFY(m_modelSpy->isEmpty()); | 349 | QVERIFY(m_modelSpy->isEmpty()); | ||
Show All 33 Lines | 370 | { | |||
415 | qDebug() << parentCollection; | 383 | qDebug() << parentCollection; | ||
416 | int changedRow = changedIndex.row(); | 384 | int changedRow = changedIndex.row(); | ||
417 | 385 | | |||
418 | FakeCollectionChangedCommand *changeCommand = new FakeCollectionChangedCommand(collectionName, parentCollection, serverData); | 386 | FakeCollectionChangedCommand *changeCommand = new FakeCollectionChangedCommand(collectionName, parentCollection, serverData); | ||
419 | 387 | | |||
420 | m_modelSpy->startSpying(); | 388 | m_modelSpy->startSpying(); | ||
421 | serverData->setCommands(QList<FakeAkonadiServerCommand *>() << changeCommand); | 389 | serverData->setCommands(QList<FakeAkonadiServerCommand *>() << changeCommand); | ||
422 | 390 | | |||
423 | QList<ExpectedSignal> expectedSignals; | 391 | const QList<ExpectedSignal> expectedSignals { | ||
424 | 392 | {DataChanged, changedRow, changedRow, parentCollection, QVariantList{collectionName}} | |||
425 | expectedSignals << getExpectedSignal(DataChanged, changedRow, changedRow, parentCollection, QVariantList() << collectionName); | 393 | }; | ||
426 | 394 | | |||
427 | m_modelSpy->setExpectedSignals(expectedSignals); | 395 | m_modelSpy->setExpectedSignals(expectedSignals); | ||
428 | serverData->processNotifications(); | 396 | serverData->processNotifications(); | ||
429 | 397 | | |||
430 | // Give the model a chance to run the event loop to process the signals. | 398 | // Give the model a chance to run the event loop to process the signals. | ||
431 | QTest::qWait(0); | 399 | QTest::qWait(0); | ||
432 | 400 | | |||
433 | QVERIFY(m_modelSpy->isEmpty()); | 401 | QVERIFY(m_modelSpy->isEmpty()); | ||
Show All 34 Lines | 419 | { | |||
468 | QModelIndex targetIndex = targetList.first(); | 436 | QModelIndex targetIndex = targetList.first(); | ||
469 | int targetRow = model->rowCount(targetIndex); | 437 | int targetRow = model->rowCount(targetIndex); | ||
470 | 438 | | |||
471 | FakeItemMovedCommand *moveCommand = new FakeItemMovedCommand(movedItem, sourceCollection, targetCollection, serverData); | 439 | FakeItemMovedCommand *moveCommand = new FakeItemMovedCommand(movedItem, sourceCollection, targetCollection, serverData); | ||
472 | 440 | | |||
473 | m_modelSpy->startSpying(); | 441 | m_modelSpy->startSpying(); | ||
474 | serverData->setCommands(QList<FakeAkonadiServerCommand *>() << moveCommand); | 442 | serverData->setCommands(QList<FakeAkonadiServerCommand *>() << moveCommand); | ||
475 | 443 | | |||
476 | QList<ExpectedSignal> expectedSignals; | 444 | const QList<ExpectedSignal> expectedSignals { | ||
477 | | ||||
478 | //Currently moves are implemented as remove + insert in the ETM. | 445 | //Currently moves are implemented as remove + insert in the ETM. | ||
479 | expectedSignals << getExpectedSignal(RowsAboutToBeRemoved, sourceRow, sourceRow, sourceCollection, QVariantList() << movedItem); | 446 | {RowsAboutToBeRemoved, sourceRow, sourceRow, sourceCollection, QVariantList{movedItem}}, | ||
480 | expectedSignals << getExpectedSignal(RowsRemoved, sourceRow, sourceRow, sourceCollection, QVariantList() << movedItem); | 447 | {RowsRemoved, sourceRow, sourceRow, sourceCollection, QVariantList{movedItem}}, | ||
481 | expectedSignals << getExpectedSignal(RowsAboutToBeInserted, targetRow, targetRow, targetCollection, QVariantList() << movedItem); | 448 | {RowsAboutToBeInserted, targetRow, targetRow, targetCollection, QVariantList{movedItem}}, | ||
482 | expectedSignals << getExpectedSignal(RowsInserted, targetRow, targetRow, targetCollection, QVariantList() << movedItem); | 449 | {RowsInserted, targetRow, targetRow, targetCollection, QVariantList{movedItem}}, | ||
483 | // expectedSignals << getExpectedSignal( RowsAboutToBeMoved, sourceRow, sourceRow, sourceCollection, targetRow, targetCollection, QVariantList() << movedItem ); | 450 | // {RowsAboutToBeMoved, sourceRow, sourceRow, sourceCollection, targetRow, targetCollection, QVariantList{movedItem}}, | ||
484 | // expectedSignals << getExpectedSignal( RowsMoved, sourceRow, sourceRow, sourceCollection, targetRow, targetCollection, QVariantList() << movedItem ); | 451 | // {RowsMoved, sourceRow, sourceRow, sourceCollection, targetRow, targetCollection, QVariantList{movedItem}}, | ||
452 | }; | ||||
485 | 453 | | |||
486 | m_modelSpy->setExpectedSignals(expectedSignals); | 454 | m_modelSpy->setExpectedSignals(expectedSignals); | ||
487 | serverData->processNotifications(); | 455 | serverData->processNotifications(); | ||
488 | 456 | | |||
489 | // Give the model a chance to run the event loop to process the signals. | 457 | // Give the model a chance to run the event loop to process the signals. | ||
490 | QTest::qWait(0); | 458 | QTest::qWait(0); | ||
491 | 459 | | |||
492 | QVERIFY(m_modelSpy->isEmpty()); | 460 | QVERIFY(m_modelSpy->isEmpty()); | ||
Show All 29 Lines | 479 | { | |||
522 | QModelIndex parentIndex = list.first(); | 490 | QModelIndex parentIndex = list.first(); | ||
523 | int targetRow = model->rowCount(parentIndex); | 491 | int targetRow = model->rowCount(parentIndex); | ||
524 | 492 | | |||
525 | FakeItemAddedCommand *addedCommand = new FakeItemAddedCommand(addedItem, parentCollection, serverData); | 493 | FakeItemAddedCommand *addedCommand = new FakeItemAddedCommand(addedItem, parentCollection, serverData); | ||
526 | 494 | | |||
527 | m_modelSpy->startSpying(); | 495 | m_modelSpy->startSpying(); | ||
528 | 496 | | |||
529 | serverData->setCommands(QList<FakeAkonadiServerCommand *>() << addedCommand); | 497 | serverData->setCommands(QList<FakeAkonadiServerCommand *>() << addedCommand); | ||
530 | QList<ExpectedSignal> expectedSignals; | | |||
531 | | ||||
532 | expectedSignals << getExpectedSignal(RowsAboutToBeInserted, targetRow, targetRow, parentCollection, QVariantList() << addedItem); | | |||
533 | expectedSignals << getExpectedSignal(RowsInserted, targetRow, targetRow, parentCollection, QVariantList() << addedItem); | | |||
534 | 498 | | |||
499 | const QList<ExpectedSignal> expectedSignals { | ||||
500 | {RowsAboutToBeInserted, targetRow, targetRow, parentCollection, QVariantList{addedItem}}, | ||||
501 | {RowsInserted, targetRow, targetRow, parentCollection, QVariantList{addedItem}} | ||||
502 | }; | ||||
535 | m_modelSpy->setExpectedSignals(expectedSignals); | 503 | m_modelSpy->setExpectedSignals(expectedSignals); | ||
536 | serverData->processNotifications(); | 504 | serverData->processNotifications(); | ||
537 | 505 | | |||
538 | // Give the model a chance to run the event loop to process the signals. | 506 | // Give the model a chance to run the event loop to process the signals. | ||
539 | QTest::qWait(0); | 507 | QTest::qWait(0); | ||
540 | 508 | | |||
541 | QVERIFY(m_modelSpy->isEmpty()); | 509 | QVERIFY(m_modelSpy->isEmpty()); | ||
542 | } | 510 | } | ||
Show All 35 Lines | 535 | { | |||
578 | const QString sourceCollection = removedIndex.parent().data().toString(); | 546 | const QString sourceCollection = removedIndex.parent().data().toString(); | ||
579 | int sourceRow = removedIndex.row(); | 547 | int sourceRow = removedIndex.row(); | ||
580 | 548 | | |||
581 | FakeItemRemovedCommand *removeCommand = new FakeItemRemovedCommand(removedItem, sourceCollection, serverData); | 549 | FakeItemRemovedCommand *removeCommand = new FakeItemRemovedCommand(removedItem, sourceCollection, serverData); | ||
582 | 550 | | |||
583 | m_modelSpy->startSpying(); | 551 | m_modelSpy->startSpying(); | ||
584 | serverData->setCommands(QList<FakeAkonadiServerCommand *>() << removeCommand); | 552 | serverData->setCommands(QList<FakeAkonadiServerCommand *>() << removeCommand); | ||
585 | 553 | | |||
586 | QList<ExpectedSignal> expectedSignals; | 554 | const QList<ExpectedSignal> expectedSignals { | ||
587 | 555 | {RowsAboutToBeRemoved, sourceRow, sourceRow, sourceCollection, QVariantList{removedItem}}, | |||
588 | expectedSignals << getExpectedSignal(RowsAboutToBeRemoved, sourceRow, sourceRow, sourceCollection, QVariantList() << removedItem); | 556 | {RowsRemoved, sourceRow, sourceRow, sourceCollection, QVariantList{removedItem}} | ||
589 | expectedSignals << getExpectedSignal(RowsRemoved, sourceRow, sourceRow, sourceCollection, QVariantList() << removedItem); | 557 | }; | ||
dvratil: `const` | |||||
590 | 558 | | |||
591 | m_modelSpy->setExpectedSignals(expectedSignals); | 559 | m_modelSpy->setExpectedSignals(expectedSignals); | ||
592 | serverData->processNotifications(); | 560 | serverData->processNotifications(); | ||
593 | 561 | | |||
594 | // Give the model a chance to run the event loop to process the signals. | 562 | // Give the model a chance to run the event loop to process the signals. | ||
595 | QTest::qWait(0); | 563 | QTest::qWait(0); | ||
596 | 564 | | |||
597 | QVERIFY(m_modelSpy->isEmpty()); | 565 | QVERIFY(m_modelSpy->isEmpty()); | ||
Show All 36 Lines | 591 | { | |||
634 | QString parentCollection = changedIndex.parent().data().toString(); | 602 | QString parentCollection = changedIndex.parent().data().toString(); | ||
635 | int sourceRow = changedIndex.row(); | 603 | int sourceRow = changedIndex.row(); | ||
636 | 604 | | |||
637 | FakeItemChangedCommand *changeCommand = new FakeItemChangedCommand(changedItem, parentCollection, serverData); | 605 | FakeItemChangedCommand *changeCommand = new FakeItemChangedCommand(changedItem, parentCollection, serverData); | ||
638 | 606 | | |||
639 | m_modelSpy->startSpying(); | 607 | m_modelSpy->startSpying(); | ||
640 | serverData->setCommands(QList<FakeAkonadiServerCommand *>() << changeCommand); | 608 | serverData->setCommands(QList<FakeAkonadiServerCommand *>() << changeCommand); | ||
641 | 609 | | |||
642 | QList<ExpectedSignal> expectedSignals; | 610 | const QList<ExpectedSignal> expectedSignals { | ||
643 | 611 | {DataChanged, sourceRow, sourceRow, QVariantList{changedItem}} | |||
644 | expectedSignals << getExpectedSignal(DataChanged, sourceRow, sourceRow, QVariantList() << changedItem); | 612 | }; | ||
645 | 613 | | |||
646 | m_modelSpy->setExpectedSignals(expectedSignals); | 614 | m_modelSpy->setExpectedSignals(expectedSignals); | ||
647 | serverData->processNotifications(); | 615 | serverData->processNotifications(); | ||
648 | 616 | | |||
649 | // Give the model a chance to run the event loop to process the signals. | 617 | // Give the model a chance to run the event loop to process the signals. | ||
650 | QTest::qWait(0); | 618 | QTest::qWait(0); | ||
651 | 619 | | |||
652 | QVERIFY(m_modelSpy->isEmpty()); | 620 | QVERIFY(m_modelSpy->isEmpty()); | ||
Show All 19 Lines | 624 | { | |||
672 | changedCol.setContentMimeTypes(QStringList() << QStringLiteral("foobar")); | 640 | changedCol.setContentMimeTypes(QStringList() << QStringLiteral("foobar")); | ||
673 | QString parentCollection = changedIndex.parent().data().toString(); | 641 | QString parentCollection = changedIndex.parent().data().toString(); | ||
674 | 642 | | |||
675 | FakeCollectionChangedCommand *changeCommand = new FakeCollectionChangedCommand(changedCol, serverData); | 643 | FakeCollectionChangedCommand *changeCommand = new FakeCollectionChangedCommand(changedCol, serverData); | ||
676 | 644 | | |||
677 | m_modelSpy->startSpying(); | 645 | m_modelSpy->startSpying(); | ||
678 | serverData->setCommands(QList<FakeAkonadiServerCommand *>() << changeCommand); | 646 | serverData->setCommands(QList<FakeAkonadiServerCommand *>() << changeCommand); | ||
679 | 647 | | |||
680 | QList<ExpectedSignal> expectedSignals; | 648 | const QList<ExpectedSignal> expectedSignals { | ||
681 | expectedSignals << getExpectedSignal(RowsAboutToBeRemoved, changedIndex.row(), changedIndex.row(), parentCollection, QVariantList() << collectionName); | 649 | {RowsAboutToBeRemoved, changedIndex.row(), changedIndex.row(), parentCollection, QVariantList{collectionName}}, | ||
682 | expectedSignals << getExpectedSignal(RowsRemoved, changedIndex.row(), changedIndex.row(), parentCollection, QVariantList() << collectionName); | 650 | {RowsRemoved, changedIndex.row(), changedIndex.row(), parentCollection, QVariantList{collectionName}}, | ||
651 | }; | ||||
683 | 652 | | |||
684 | m_modelSpy->setExpectedSignals(expectedSignals); | 653 | m_modelSpy->setExpectedSignals(expectedSignals); | ||
685 | serverData->processNotifications(); | 654 | serverData->processNotifications(); | ||
686 | 655 | | |||
687 | // Give the model a chance to run the event loop to process the signals. | 656 | // Give the model a chance to run the event loop to process the signals. | ||
688 | QTest::qWait(0); | 657 | QTest::qWait(0); | ||
689 | 658 | | |||
690 | QVERIFY(m_modelSpy->isEmpty()); | 659 | QVERIFY(m_modelSpy->isEmpty()); | ||
691 | } | 660 | } | ||
692 | 661 | | |||
693 | #include "entitytreemodeltest.moc" | 662 | #include "entitytreemodeltest.moc" | ||
694 | 663 | | |||
695 | QTEST_MAIN(EntityTreeModelTest) | 664 | QTEST_MAIN(EntityTreeModelTest) | ||
696 | 665 | |
You may even be able to get rid of the type name, as that can be deduced from the initializer list type, or not?