Changeset View
Changeset View
Standalone View
Standalone View
autotests/alltracksproxymodeltest.cpp
Show First 20 Lines • Show All 85 Lines • ▼ Show 20 Line(s) | 57 | { | |||
---|---|---|---|---|---|
86 | tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track); | 86 | tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track); | ||
87 | 87 | | |||
88 | QCOMPARE(beginInsertRowsSpy.count(), 0); | 88 | QCOMPARE(beginInsertRowsSpy.count(), 0); | ||
89 | QCOMPARE(endInsertRowsSpy.count(), 0); | 89 | QCOMPARE(endInsertRowsSpy.count(), 0); | ||
90 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 90 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
91 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 91 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
92 | QCOMPARE(dataChangedSpy.count(), 0); | 92 | QCOMPARE(dataChangedSpy.count(), 0); | ||
93 | 93 | | |||
94 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("autoTest")); | 94 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
95 | 95 | | |||
96 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 96 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
97 | QCOMPARE(endInsertRowsSpy.count(), 1); | 97 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
98 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 98 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
99 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 99 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
100 | QCOMPARE(dataChangedSpy.count(), 0); | 100 | QCOMPARE(dataChangedSpy.count(), 0); | ||
101 | 101 | | |||
102 | QCOMPARE(proxyTracksModel.rowCount(), 23); | 102 | QCOMPARE(proxyTracksModel.rowCount(), 23); | ||
▲ Show 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | 121 | { | |||
150 | tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track); | 150 | tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track); | ||
151 | 151 | | |||
152 | QCOMPARE(beginInsertRowsSpy.count(), 0); | 152 | QCOMPARE(beginInsertRowsSpy.count(), 0); | ||
153 | QCOMPARE(endInsertRowsSpy.count(), 0); | 153 | QCOMPARE(endInsertRowsSpy.count(), 0); | ||
154 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 154 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
155 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 155 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
156 | QCOMPARE(dataChangedSpy.count(), 0); | 156 | QCOMPARE(dataChangedSpy.count(), 0); | ||
157 | 157 | | |||
158 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("autoTest")); | 158 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
159 | 159 | | |||
160 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 160 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
161 | QCOMPARE(endInsertRowsSpy.count(), 1); | 161 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
162 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 162 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
163 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 163 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
164 | QCOMPARE(dataChangedSpy.count(), 0); | 164 | QCOMPARE(dataChangedSpy.count(), 0); | ||
165 | 165 | | |||
166 | QCOMPARE(proxyTracksModel.rowCount(), 23); | 166 | QCOMPARE(proxyTracksModel.rowCount(), 23); | ||
▲ Show 20 Lines • Show All 55 Lines • ▼ Show 20 Line(s) | 193 | { | |||
222 | tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track); | 222 | tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track); | ||
223 | 223 | | |||
224 | QCOMPARE(beginInsertRowsSpy.count(), 0); | 224 | QCOMPARE(beginInsertRowsSpy.count(), 0); | ||
225 | QCOMPARE(endInsertRowsSpy.count(), 0); | 225 | QCOMPARE(endInsertRowsSpy.count(), 0); | ||
226 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 226 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
227 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 227 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
228 | QCOMPARE(dataChangedSpy.count(), 0); | 228 | QCOMPARE(dataChangedSpy.count(), 0); | ||
229 | 229 | | |||
230 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("autoTest")); | 230 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
231 | 231 | | |||
232 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 232 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
233 | QCOMPARE(endInsertRowsSpy.count(), 1); | 233 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
234 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 234 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
235 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 235 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
236 | QCOMPARE(dataChangedSpy.count(), 0); | 236 | QCOMPARE(dataChangedSpy.count(), 0); | ||
237 | 237 | | |||
238 | QCOMPARE(proxyTracksModel.rowCount(), 23); | 238 | QCOMPARE(proxyTracksModel.rowCount(), 23); | ||
239 | 239 | | |||
240 | auto newTrack = MusicAudioTrack{true, QStringLiteral("$23"), QStringLiteral("0"), QStringLiteral("track23"), | 240 | auto newTrack = MusicAudioTrack{true, QStringLiteral("$23"), QStringLiteral("0"), QStringLiteral("track23"), | ||
241 | QStringLiteral("artist2"), QStringLiteral("album4"), QStringLiteral("artist2"), 23, 1, QTime::fromMSecsSinceStartOfDay(23), | 241 | QStringLiteral("artist2"), QStringLiteral("album4"), QStringLiteral("artist2"), 23, 1, QTime::fromMSecsSinceStartOfDay(23), | ||
242 | {QUrl::fromLocalFile(QStringLiteral("/$23"))}, | 242 | {QUrl::fromLocalFile(QStringLiteral("/$23"))}, | ||
243 | QDateTime::fromMSecsSinceEpoch(23), | 243 | QDateTime::fromMSecsSinceEpoch(23), | ||
244 | {QUrl::fromLocalFile(QStringLiteral("file://image$23"))}, 5, true, | 244 | {QUrl::fromLocalFile(QStringLiteral("file://image$23"))}, 5, true, | ||
245 | {}, QStringLiteral("composer1"), QStringLiteral("lyricist1"), false}; | 245 | {}, QStringLiteral("composer1"), QStringLiteral("lyricist1"), false}; | ||
246 | auto newTracks = QList<MusicAudioTrack>(); | 246 | auto newTracks = QList<MusicAudioTrack>(); | ||
247 | newTracks.push_back(newTrack); | 247 | newTracks.push_back(newTrack); | ||
248 | 248 | | |||
249 | musicDb.insertTracksList(newTracks, mNewCovers, QStringLiteral("autoTest")); | 249 | musicDb.insertTracksList(newTracks, mNewCovers); | ||
250 | 250 | | |||
251 | QCOMPARE(beginInsertRowsSpy.count(), 2); | 251 | QCOMPARE(beginInsertRowsSpy.count(), 2); | ||
252 | QCOMPARE(endInsertRowsSpy.count(), 2); | 252 | QCOMPARE(endInsertRowsSpy.count(), 2); | ||
253 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 253 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
254 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 254 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
255 | QCOMPARE(dataChangedSpy.count(), 5); | 255 | QCOMPARE(dataChangedSpy.count(), 5); | ||
256 | 256 | | |||
257 | QCOMPARE(proxyTracksModel.rowCount(), 24); | 257 | QCOMPARE(proxyTracksModel.rowCount(), 24); | ||
Show All 38 Lines | 261 | { | |||
296 | QCOMPARE(dataChangedSpy.count(), 0); | 296 | QCOMPARE(dataChangedSpy.count(), 0); | ||
297 | 297 | | |||
298 | auto newFiles = QList<QUrl>(); | 298 | auto newFiles = QList<QUrl>(); | ||
299 | const auto &constNewTracks = mNewTracks; | 299 | const auto &constNewTracks = mNewTracks; | ||
300 | for (const auto &oneTrack : constNewTracks) { | 300 | for (const auto &oneTrack : constNewTracks) { | ||
301 | newFiles.push_back(oneTrack.resourceURI()); | 301 | newFiles.push_back(oneTrack.resourceURI()); | ||
302 | } | 302 | } | ||
303 | 303 | | |||
304 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("autoTest")); | 304 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
305 | 305 | | |||
306 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 306 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
307 | QCOMPARE(endInsertRowsSpy.count(), 1); | 307 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
308 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 308 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
309 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 309 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
310 | QCOMPARE(dataChangedSpy.count(), 0); | 310 | QCOMPARE(dataChangedSpy.count(), 0); | ||
311 | 311 | | |||
312 | QCOMPARE(proxyTracksModel.rowCount(), 23); | 312 | QCOMPARE(proxyTracksModel.rowCount(), 23); | ||
Show All 11 Lines | |||||
324 | auto newCovers = QHash<QString, QUrl>(); | 324 | auto newCovers = QHash<QString, QUrl>(); | ||
325 | newCovers[QStringLiteral("album5")] = newCover; | 325 | newCovers[QStringLiteral("album5")] = newCover; | ||
326 | 326 | | |||
327 | auto newFiles2 = QList<QUrl>(); | 327 | auto newFiles2 = QList<QUrl>(); | ||
328 | for (const auto &oneTrack : newTracks) { | 328 | for (const auto &oneTrack : newTracks) { | ||
329 | newFiles2.push_back(oneTrack.resourceURI()); | 329 | newFiles2.push_back(oneTrack.resourceURI()); | ||
330 | } | 330 | } | ||
331 | 331 | | |||
332 | musicDb.insertTracksList(newTracks, newCovers, QStringLiteral("autoTest")); | 332 | musicDb.insertTracksList(newTracks, newCovers); | ||
333 | 333 | | |||
334 | QCOMPARE(beginInsertRowsSpy.count(), 2); | 334 | QCOMPARE(beginInsertRowsSpy.count(), 2); | ||
335 | QCOMPARE(endInsertRowsSpy.count(), 2); | 335 | QCOMPARE(endInsertRowsSpy.count(), 2); | ||
336 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 336 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
337 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 337 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
338 | QCOMPARE(dataChangedSpy.count(), 5); | 338 | QCOMPARE(dataChangedSpy.count(), 5); | ||
339 | 339 | | |||
340 | QCOMPARE(proxyTracksModel.rowCount(), 24); | 340 | QCOMPARE(proxyTracksModel.rowCount(), 24); | ||
Show All 32 Lines | 344 | { | |||
373 | tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track); | 373 | tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track); | ||
374 | 374 | | |||
375 | QCOMPARE(beginInsertRowsSpy.count(), 0); | 375 | QCOMPARE(beginInsertRowsSpy.count(), 0); | ||
376 | QCOMPARE(endInsertRowsSpy.count(), 0); | 376 | QCOMPARE(endInsertRowsSpy.count(), 0); | ||
377 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 377 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
378 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 378 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
379 | QCOMPARE(dataChangedSpy.count(), 0); | 379 | QCOMPARE(dataChangedSpy.count(), 0); | ||
380 | 380 | | |||
381 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("autoTest")); | 381 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
382 | 382 | | |||
383 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 383 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
384 | QCOMPARE(endInsertRowsSpy.count(), 1); | 384 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
385 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 385 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
386 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 386 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
387 | QCOMPARE(dataChangedSpy.count(), 0); | 387 | QCOMPARE(dataChangedSpy.count(), 0); | ||
388 | 388 | | |||
389 | QCOMPARE(proxyTracksModel.rowCount(), 23); | 389 | QCOMPARE(proxyTracksModel.rowCount(), 23); | ||
390 | 390 | | |||
391 | auto newTrack = MusicAudioTrack{true, QStringLiteral("$1"), QStringLiteral("0"), QStringLiteral("track1"), | 391 | auto newTrack = MusicAudioTrack{true, QStringLiteral("$1"), QStringLiteral("0"), QStringLiteral("track1"), | ||
392 | QStringLiteral("artist1"), QStringLiteral("album1"), QStringLiteral("Various Artists"), | 392 | QStringLiteral("artist1"), QStringLiteral("album1"), QStringLiteral("Various Artists"), | ||
393 | 1, 1, QTime::fromMSecsSinceStartOfDay(1), {QUrl::fromLocalFile(QStringLiteral("/$1"))}, | 393 | 1, 1, QTime::fromMSecsSinceStartOfDay(1), {QUrl::fromLocalFile(QStringLiteral("/$1"))}, | ||
394 | QDateTime::fromMSecsSinceEpoch(1), | 394 | QDateTime::fromMSecsSinceEpoch(1), | ||
395 | {QUrl::fromLocalFile(QStringLiteral("file://image$1"))}, 5, true, {}, QStringLiteral("composer1"), QStringLiteral("lyricist1"), false}; | 395 | {QUrl::fromLocalFile(QStringLiteral("file://image$1"))}, 5, true, {}, QStringLiteral("composer1"), QStringLiteral("lyricist1"), false}; | ||
396 | auto newTracks = QList<MusicAudioTrack>(); | 396 | auto newTracks = QList<MusicAudioTrack>(); | ||
397 | newTracks.push_back(newTrack); | 397 | newTracks.push_back(newTrack); | ||
398 | 398 | | |||
399 | musicDb.insertTracksList(newTracks, mNewCovers, QStringLiteral("autoTest")); | 399 | musicDb.insertTracksList(newTracks, mNewCovers); | ||
400 | 400 | | |||
401 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 401 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
402 | QCOMPARE(endInsertRowsSpy.count(), 1); | 402 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
403 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 403 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
404 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 404 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
405 | QCOMPARE(dataChangedSpy.count(), 1); | 405 | QCOMPARE(dataChangedSpy.count(), 1); | ||
406 | 406 | | |||
407 | QCOMPARE(proxyTracksModel.rowCount(), 23); | 407 | QCOMPARE(proxyTracksModel.rowCount(), 23); | ||
▲ Show 20 Lines • Show All 74 Lines • ▼ Show 20 Line(s) | 453 | { | |||
482 | tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track); | 482 | tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track); | ||
483 | 483 | | |||
484 | QCOMPARE(beginInsertRowsSpy.count(), 0); | 484 | QCOMPARE(beginInsertRowsSpy.count(), 0); | ||
485 | QCOMPARE(endInsertRowsSpy.count(), 0); | 485 | QCOMPARE(endInsertRowsSpy.count(), 0); | ||
486 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 486 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
487 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 487 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
488 | QCOMPARE(dataChangedSpy.count(), 0); | 488 | QCOMPARE(dataChangedSpy.count(), 0); | ||
489 | 489 | | |||
490 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("autoTest")); | 490 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
491 | 491 | | |||
492 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 492 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
493 | QCOMPARE(endInsertRowsSpy.count(), 1); | 493 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
494 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 494 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
495 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 495 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
496 | QCOMPARE(dataChangedSpy.count(), 0); | 496 | QCOMPARE(dataChangedSpy.count(), 0); | ||
497 | 497 | | |||
498 | QCOMPARE(proxyTracksModel.rowCount(), 23); | 498 | QCOMPARE(proxyTracksModel.rowCount(), 23); | ||
499 | 499 | | |||
500 | auto newTrack = MusicAudioTrack{true, QStringLiteral("$23"), QStringLiteral("0"), QStringLiteral("track23"), | 500 | auto newTrack = MusicAudioTrack{true, QStringLiteral("$23"), QStringLiteral("0"), QStringLiteral("track23"), | ||
501 | QStringLiteral("artist2"), QStringLiteral("album4"), QStringLiteral("artist2"), 23, 1, QTime::fromMSecsSinceStartOfDay(23), | 501 | QStringLiteral("artist2"), QStringLiteral("album4"), QStringLiteral("artist2"), 23, 1, QTime::fromMSecsSinceStartOfDay(23), | ||
502 | {QUrl::fromLocalFile(QStringLiteral("/$23"))}, | 502 | {QUrl::fromLocalFile(QStringLiteral("/$23"))}, | ||
503 | QDateTime::fromMSecsSinceEpoch(23), | 503 | QDateTime::fromMSecsSinceEpoch(23), | ||
504 | {QUrl::fromLocalFile(QStringLiteral("file://image$23"))}, 5, true, {}, QStringLiteral("composer1"), QStringLiteral("lyricist1"), false}; | 504 | {QUrl::fromLocalFile(QStringLiteral("file://image$23"))}, 5, true, {}, QStringLiteral("composer1"), QStringLiteral("lyricist1"), false}; | ||
505 | 505 | | |||
506 | auto newTracks = QList<MusicAudioTrack>(); | 506 | auto newTracks = QList<MusicAudioTrack>(); | ||
507 | newTracks.push_back(newTrack); | 507 | newTracks.push_back(newTrack); | ||
508 | 508 | | |||
509 | musicDb.insertTracksList(newTracks, mNewCovers, QStringLiteral("autoTest")); | 509 | musicDb.insertTracksList(newTracks, mNewCovers); | ||
510 | 510 | | |||
511 | QCOMPARE(beginInsertRowsSpy.count(), 2); | 511 | QCOMPARE(beginInsertRowsSpy.count(), 2); | ||
512 | QCOMPARE(endInsertRowsSpy.count(), 2); | 512 | QCOMPARE(endInsertRowsSpy.count(), 2); | ||
513 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 513 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
514 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 514 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
515 | QCOMPARE(dataChangedSpy.count(), 5); | 515 | QCOMPARE(dataChangedSpy.count(), 5); | ||
516 | 516 | | |||
517 | QCOMPARE(proxyTracksModel.rowCount(), 24); | 517 | QCOMPARE(proxyTracksModel.rowCount(), 24); | ||
518 | } | 518 | } | ||
519 | }; | 519 | }; | ||
520 | 520 | | |||
521 | QTEST_GUILESS_MAIN(AllTracksProxyModelTests) | 521 | QTEST_GUILESS_MAIN(AllTracksProxyModelTests) | ||
522 | 522 | | |||
523 | 523 | | |||
524 | #include "alltracksproxymodeltest.moc" | 524 | #include "alltracksproxymodeltest.moc" |