Changeset View
Changeset View
Standalone View
Standalone View
autotests/datamodeltest.cpp
Show First 20 Lines • Show All 73 Lines • ▼ Show 20 Line(s) | 56 | { | |||
---|---|---|---|---|---|
74 | QSignalSpy dataChangedSpy(&albumsModel, &DataModel::dataChanged); | 74 | QSignalSpy dataChangedSpy(&albumsModel, &DataModel::dataChanged); | ||
75 | 75 | | |||
76 | QCOMPARE(beginInsertRowsSpy.count(), 0); | 76 | QCOMPARE(beginInsertRowsSpy.count(), 0); | ||
77 | QCOMPARE(endInsertRowsSpy.count(), 0); | 77 | QCOMPARE(endInsertRowsSpy.count(), 0); | ||
78 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 78 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
79 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 79 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
80 | QCOMPARE(dataChangedSpy.count(), 0); | 80 | QCOMPARE(dataChangedSpy.count(), 0); | ||
81 | 81 | | |||
82 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("autoTest")); | 82 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
83 | 83 | | |||
84 | QCOMPARE(beginInsertRowsSpy.count(), 0); | 84 | QCOMPARE(beginInsertRowsSpy.count(), 0); | ||
85 | QCOMPARE(endInsertRowsSpy.count(), 0); | 85 | QCOMPARE(endInsertRowsSpy.count(), 0); | ||
86 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 86 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
87 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 87 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
88 | QCOMPARE(dataChangedSpy.count(), 0); | 88 | QCOMPARE(dataChangedSpy.count(), 0); | ||
89 | 89 | | |||
90 | albumsModel.initializeById(nullptr, nullptr, ElisaUtils::Track, | 90 | albumsModel.initializeById(nullptr, nullptr, ElisaUtils::Track, | ||
▲ Show 20 Lines • Show All 50 Lines • ▼ Show 20 Line(s) | 123 | { | |||
141 | QSignalSpy dataChangedSpy(&albumsModel, &DataModel::dataChanged); | 141 | QSignalSpy dataChangedSpy(&albumsModel, &DataModel::dataChanged); | ||
142 | 142 | | |||
143 | QCOMPARE(beginInsertRowsSpy.count(), 0); | 143 | QCOMPARE(beginInsertRowsSpy.count(), 0); | ||
144 | QCOMPARE(endInsertRowsSpy.count(), 0); | 144 | QCOMPARE(endInsertRowsSpy.count(), 0); | ||
145 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 145 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
146 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 146 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
147 | QCOMPARE(dataChangedSpy.count(), 0); | 147 | QCOMPARE(dataChangedSpy.count(), 0); | ||
148 | 148 | | |||
149 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("autoTest")); | 149 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
150 | 150 | | |||
151 | QCOMPARE(beginInsertRowsSpy.count(), 0); | 151 | QCOMPARE(beginInsertRowsSpy.count(), 0); | ||
152 | QCOMPARE(endInsertRowsSpy.count(), 0); | 152 | QCOMPARE(endInsertRowsSpy.count(), 0); | ||
153 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 153 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
154 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 154 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
155 | QCOMPARE(dataChangedSpy.count(), 0); | 155 | QCOMPARE(dataChangedSpy.count(), 0); | ||
156 | 156 | | |||
157 | albumsModel.initializeById(nullptr, nullptr, ElisaUtils::Track, | 157 | albumsModel.initializeById(nullptr, nullptr, ElisaUtils::Track, | ||
▲ Show 20 Lines • Show All 64 Lines • ▼ Show 20 Line(s) | 198 | { | |||
222 | QCOMPARE(dataChangedSpy.count(), 0); | 222 | QCOMPARE(dataChangedSpy.count(), 0); | ||
223 | 223 | | |||
224 | auto newFiles = QList<QUrl>(); | 224 | auto newFiles = QList<QUrl>(); | ||
225 | const auto &constNewTracks = mNewTracks; | 225 | const auto &constNewTracks = mNewTracks; | ||
226 | for (const auto &oneTrack : constNewTracks) { | 226 | for (const auto &oneTrack : constNewTracks) { | ||
227 | newFiles.push_back(oneTrack.resourceURI()); | 227 | newFiles.push_back(oneTrack.resourceURI()); | ||
228 | } | 228 | } | ||
229 | 229 | | |||
230 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("autoTest")); | 230 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
231 | 231 | | |||
232 | QCOMPARE(beginInsertRowsSpy.count(), 0); | 232 | QCOMPARE(beginInsertRowsSpy.count(), 0); | ||
233 | QCOMPARE(endInsertRowsSpy.count(), 0); | 233 | QCOMPARE(endInsertRowsSpy.count(), 0); | ||
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 | albumsModel.initializeById(nullptr, nullptr, ElisaUtils::Track, | 238 | albumsModel.initializeById(nullptr, nullptr, ElisaUtils::Track, | ||
Show All 23 Lines | |||||
262 | auto newTracks = QList<MusicAudioTrack>(); | 262 | auto newTracks = QList<MusicAudioTrack>(); | ||
263 | newTracks.push_back(newTrack); | 263 | newTracks.push_back(newTrack); | ||
264 | 264 | | |||
265 | auto newFiles2 = QList<QUrl>(); | 265 | auto newFiles2 = QList<QUrl>(); | ||
266 | for (const auto &oneTrack : newTracks) { | 266 | for (const auto &oneTrack : newTracks) { | ||
267 | newFiles2.push_back(oneTrack.resourceURI()); | 267 | newFiles2.push_back(oneTrack.resourceURI()); | ||
268 | } | 268 | } | ||
269 | 269 | | |||
270 | musicDb.insertTracksList(newTracks, mNewCovers, QStringLiteral("autoTest")); | 270 | musicDb.insertTracksList(newTracks, mNewCovers); | ||
271 | 271 | | |||
272 | QCOMPARE(albumsModel.rowCount(), 5); | 272 | QCOMPARE(albumsModel.rowCount(), 5); | ||
273 | QCOMPARE(beginInsertRowsSpy.count(), 2); | 273 | QCOMPARE(beginInsertRowsSpy.count(), 2); | ||
274 | QCOMPARE(endInsertRowsSpy.count(), 2); | 274 | QCOMPARE(endInsertRowsSpy.count(), 2); | ||
275 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 275 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
276 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 276 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
277 | QCOMPARE(dataChangedSpy.count(), 4); | 277 | QCOMPARE(dataChangedSpy.count(), 4); | ||
278 | 278 | | |||
Show All 11 Lines | |||||
290 | auto secondNewTracks = QList<MusicAudioTrack>(); | 290 | auto secondNewTracks = QList<MusicAudioTrack>(); | ||
291 | secondNewTracks.push_back(secondNewTrack); | 291 | secondNewTracks.push_back(secondNewTrack); | ||
292 | 292 | | |||
293 | auto newFiles3 = QList<QUrl>(); | 293 | auto newFiles3 = QList<QUrl>(); | ||
294 | for (const auto &oneTrack : secondNewTracks) { | 294 | for (const auto &oneTrack : secondNewTracks) { | ||
295 | newFiles3.push_back(oneTrack.resourceURI()); | 295 | newFiles3.push_back(oneTrack.resourceURI()); | ||
296 | } | 296 | } | ||
297 | 297 | | |||
298 | musicDb.insertTracksList(secondNewTracks, mNewCovers, QStringLiteral("autoTest")); | 298 | musicDb.insertTracksList(secondNewTracks, mNewCovers); | ||
299 | 299 | | |||
300 | QCOMPARE(albumsModel.rowCount(), 6); | 300 | QCOMPARE(albumsModel.rowCount(), 6); | ||
301 | QCOMPARE(beginInsertRowsSpy.count(), 3); | 301 | QCOMPARE(beginInsertRowsSpy.count(), 3); | ||
302 | QCOMPARE(endInsertRowsSpy.count(), 3); | 302 | QCOMPARE(endInsertRowsSpy.count(), 3); | ||
303 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 303 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
304 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 304 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
305 | QCOMPARE(dataChangedSpy.count(), 9); | 305 | QCOMPARE(dataChangedSpy.count(), 9); | ||
306 | 306 | | |||
Show All 31 Lines | 314 | { | |||
338 | QCOMPARE(dataChangedSpy.count(), 0); | 338 | QCOMPARE(dataChangedSpy.count(), 0); | ||
339 | 339 | | |||
340 | auto newFiles = QList<QUrl>(); | 340 | auto newFiles = QList<QUrl>(); | ||
341 | const auto &constNewTracks = mNewTracks; | 341 | const auto &constNewTracks = mNewTracks; | ||
342 | for (const auto &oneTrack : constNewTracks) { | 342 | for (const auto &oneTrack : constNewTracks) { | ||
343 | newFiles.push_back(oneTrack.resourceURI()); | 343 | newFiles.push_back(oneTrack.resourceURI()); | ||
344 | } | 344 | } | ||
345 | 345 | | |||
346 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("autoTest")); | 346 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
347 | 347 | | |||
348 | QCOMPARE(beginInsertRowsSpy.count(), 0); | 348 | QCOMPARE(beginInsertRowsSpy.count(), 0); | ||
349 | QCOMPARE(endInsertRowsSpy.count(), 0); | 349 | QCOMPARE(endInsertRowsSpy.count(), 0); | ||
350 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 350 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
351 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 351 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
352 | QCOMPARE(dataChangedSpy.count(), 0); | 352 | QCOMPARE(dataChangedSpy.count(), 0); | ||
353 | 353 | | |||
354 | albumsModel.initializeById(nullptr, nullptr, ElisaUtils::Track, | 354 | albumsModel.initializeById(nullptr, nullptr, ElisaUtils::Track, | ||
Show All 17 Lines | |||||
372 | auto modifiedTrack = MusicAudioTrack{ | 372 | auto modifiedTrack = MusicAudioTrack{ | ||
373 | true, QStringLiteral("$3"), QStringLiteral("0"), QStringLiteral("track3"), | 373 | true, QStringLiteral("$3"), QStringLiteral("0"), QStringLiteral("track3"), | ||
374 | QStringLiteral("artist3"), QStringLiteral("album1"), QStringLiteral("Various Artists"), 5, 3, | 374 | QStringLiteral("artist3"), QStringLiteral("album1"), QStringLiteral("Various Artists"), 5, 3, | ||
375 | QTime::fromMSecsSinceStartOfDay(3), {QUrl::fromLocalFile(QStringLiteral("/$3"))}, | 375 | QTime::fromMSecsSinceStartOfDay(3), {QUrl::fromLocalFile(QStringLiteral("/$3"))}, | ||
376 | QDateTime::fromMSecsSinceEpoch(23), | 376 | QDateTime::fromMSecsSinceEpoch(23), | ||
377 | QUrl::fromLocalFile(QStringLiteral("album1")), 5, true, | 377 | QUrl::fromLocalFile(QStringLiteral("album1")), 5, true, | ||
378 | {}, QStringLiteral("composer1"), QStringLiteral("lyricist1"), false}; | 378 | {}, QStringLiteral("composer1"), QStringLiteral("lyricist1"), false}; | ||
379 | 379 | | |||
380 | musicDb.insertTracksList({modifiedTrack}, mNewCovers, QStringLiteral("autoTest")); | 380 | musicDb.insertTracksList({modifiedTrack}, mNewCovers); | ||
381 | 381 | | |||
382 | QCOMPARE(albumsModel.rowCount(), 4); | 382 | QCOMPARE(albumsModel.rowCount(), 4); | ||
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(), 1); | 387 | QCOMPARE(dataChangedSpy.count(), 1); | ||
388 | 388 | | |||
Show All 34 Lines | 397 | { | |||
423 | tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track); | 423 | tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track); | ||
424 | 424 | | |||
425 | QCOMPARE(beginInsertRowsSpy.count(), 0); | 425 | QCOMPARE(beginInsertRowsSpy.count(), 0); | ||
426 | QCOMPARE(endInsertRowsSpy.count(), 0); | 426 | QCOMPARE(endInsertRowsSpy.count(), 0); | ||
427 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 427 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
428 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 428 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
429 | QCOMPARE(dataChangedSpy.count(), 0); | 429 | QCOMPARE(dataChangedSpy.count(), 0); | ||
430 | 430 | | |||
431 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("autoTest")); | 431 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
432 | 432 | | |||
433 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 433 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
434 | QCOMPARE(endInsertRowsSpy.count(), 1); | 434 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
435 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 435 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
436 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 436 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
437 | QCOMPARE(dataChangedSpy.count(), 0); | 437 | QCOMPARE(dataChangedSpy.count(), 0); | ||
438 | 438 | | |||
439 | QCOMPARE(tracksModel.rowCount(), 23); | 439 | QCOMPARE(tracksModel.rowCount(), 23); | ||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 458 | { | |||
484 | tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track); | 484 | tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track); | ||
485 | 485 | | |||
486 | QCOMPARE(beginInsertRowsSpy.count(), 0); | 486 | QCOMPARE(beginInsertRowsSpy.count(), 0); | ||
487 | QCOMPARE(endInsertRowsSpy.count(), 0); | 487 | QCOMPARE(endInsertRowsSpy.count(), 0); | ||
488 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 488 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
489 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 489 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
490 | QCOMPARE(dataChangedSpy.count(), 0); | 490 | QCOMPARE(dataChangedSpy.count(), 0); | ||
491 | 491 | | |||
492 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("autoTest")); | 492 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
493 | 493 | | |||
494 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 494 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
495 | QCOMPARE(endInsertRowsSpy.count(), 1); | 495 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
496 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 496 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
497 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 497 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
498 | QCOMPARE(dataChangedSpy.count(), 0); | 498 | QCOMPARE(dataChangedSpy.count(), 0); | ||
499 | 499 | | |||
500 | QCOMPARE(tracksModel.rowCount(), 23); | 500 | QCOMPARE(tracksModel.rowCount(), 23); | ||
▲ Show 20 Lines • Show All 51 Lines • ▼ Show 20 Line(s) | 526 | { | |||
552 | tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track); | 552 | tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track); | ||
553 | 553 | | |||
554 | QCOMPARE(beginInsertRowsSpy.count(), 0); | 554 | QCOMPARE(beginInsertRowsSpy.count(), 0); | ||
555 | QCOMPARE(endInsertRowsSpy.count(), 0); | 555 | QCOMPARE(endInsertRowsSpy.count(), 0); | ||
556 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 556 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
557 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 557 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
558 | QCOMPARE(dataChangedSpy.count(), 0); | 558 | QCOMPARE(dataChangedSpy.count(), 0); | ||
559 | 559 | | |||
560 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("autoTest")); | 560 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
561 | 561 | | |||
562 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 562 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
563 | QCOMPARE(endInsertRowsSpy.count(), 1); | 563 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
564 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 564 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
565 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 565 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
566 | QCOMPARE(dataChangedSpy.count(), 0); | 566 | QCOMPARE(dataChangedSpy.count(), 0); | ||
567 | 567 | | |||
568 | QCOMPARE(tracksModel.rowCount(), 23); | 568 | QCOMPARE(tracksModel.rowCount(), 23); | ||
569 | 569 | | |||
570 | auto newTrack = MusicAudioTrack{true, QStringLiteral("$23"), QStringLiteral("0"), QStringLiteral("track23"), | 570 | auto newTrack = MusicAudioTrack{true, QStringLiteral("$23"), QStringLiteral("0"), QStringLiteral("track23"), | ||
571 | QStringLiteral("artist2"), QStringLiteral("album4"), QStringLiteral("artist2"), 23, 1, QTime::fromMSecsSinceStartOfDay(23), | 571 | QStringLiteral("artist2"), QStringLiteral("album4"), QStringLiteral("artist2"), 23, 1, QTime::fromMSecsSinceStartOfDay(23), | ||
572 | {QUrl::fromLocalFile(QStringLiteral("/$23"))}, | 572 | {QUrl::fromLocalFile(QStringLiteral("/$23"))}, | ||
573 | QDateTime::fromMSecsSinceEpoch(23), | 573 | QDateTime::fromMSecsSinceEpoch(23), | ||
574 | {QUrl::fromLocalFile(QStringLiteral("file://image$23"))}, 5, true, | 574 | {QUrl::fromLocalFile(QStringLiteral("file://image$23"))}, 5, true, | ||
575 | {}, QStringLiteral("composer1"), QStringLiteral("lyricist1"), false}; | 575 | {}, QStringLiteral("composer1"), QStringLiteral("lyricist1"), false}; | ||
576 | auto newTracks = QList<MusicAudioTrack>(); | 576 | auto newTracks = QList<MusicAudioTrack>(); | ||
577 | newTracks.push_back(newTrack); | 577 | newTracks.push_back(newTrack); | ||
578 | 578 | | |||
579 | musicDb.insertTracksList(newTracks, mNewCovers, QStringLiteral("autoTest")); | 579 | musicDb.insertTracksList(newTracks, mNewCovers); | ||
580 | 580 | | |||
581 | QCOMPARE(beginInsertRowsSpy.count(), 2); | 581 | QCOMPARE(beginInsertRowsSpy.count(), 2); | ||
582 | QCOMPARE(endInsertRowsSpy.count(), 2); | 582 | QCOMPARE(endInsertRowsSpy.count(), 2); | ||
583 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 583 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
584 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 584 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
585 | QCOMPARE(dataChangedSpy.count(), 5); | 585 | QCOMPARE(dataChangedSpy.count(), 5); | ||
586 | 586 | | |||
587 | QCOMPARE(tracksModel.rowCount(), 24); | 587 | QCOMPARE(tracksModel.rowCount(), 24); | ||
Show All 35 Lines | 591 | { | |||
623 | QCOMPARE(dataChangedSpy.count(), 0); | 623 | QCOMPARE(dataChangedSpy.count(), 0); | ||
624 | 624 | | |||
625 | auto newFiles = QList<QUrl>(); | 625 | auto newFiles = QList<QUrl>(); | ||
626 | const auto &constNewTracks = mNewTracks; | 626 | const auto &constNewTracks = mNewTracks; | ||
627 | for (const auto &oneTrack : constNewTracks) { | 627 | for (const auto &oneTrack : constNewTracks) { | ||
628 | newFiles.push_back(oneTrack.resourceURI()); | 628 | newFiles.push_back(oneTrack.resourceURI()); | ||
629 | } | 629 | } | ||
630 | 630 | | |||
631 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("autoTest")); | 631 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
632 | 632 | | |||
633 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 633 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
634 | QCOMPARE(endInsertRowsSpy.count(), 1); | 634 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
635 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 635 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
636 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 636 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
637 | QCOMPARE(dataChangedSpy.count(), 0); | 637 | QCOMPARE(dataChangedSpy.count(), 0); | ||
638 | 638 | | |||
639 | QCOMPARE(tracksModel.rowCount(), 23); | 639 | QCOMPARE(tracksModel.rowCount(), 23); | ||
Show All 11 Lines | |||||
651 | auto newCovers = QHash<QString, QUrl>(); | 651 | auto newCovers = QHash<QString, QUrl>(); | ||
652 | newCovers[QStringLiteral("album5")] = newCover; | 652 | newCovers[QStringLiteral("album5")] = newCover; | ||
653 | 653 | | |||
654 | auto newFiles2 = QList<QUrl>(); | 654 | auto newFiles2 = QList<QUrl>(); | ||
655 | for (const auto &oneTrack : newTracks) { | 655 | for (const auto &oneTrack : newTracks) { | ||
656 | newFiles2.push_back(oneTrack.resourceURI()); | 656 | newFiles2.push_back(oneTrack.resourceURI()); | ||
657 | } | 657 | } | ||
658 | 658 | | |||
659 | musicDb.insertTracksList(newTracks, newCovers, QStringLiteral("autoTest")); | 659 | musicDb.insertTracksList(newTracks, newCovers); | ||
660 | 660 | | |||
661 | QCOMPARE(beginInsertRowsSpy.count(), 2); | 661 | QCOMPARE(beginInsertRowsSpy.count(), 2); | ||
662 | QCOMPARE(endInsertRowsSpy.count(), 2); | 662 | QCOMPARE(endInsertRowsSpy.count(), 2); | ||
663 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 663 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
664 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 664 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
665 | QCOMPARE(dataChangedSpy.count(), 5); | 665 | QCOMPARE(dataChangedSpy.count(), 5); | ||
666 | 666 | | |||
667 | QCOMPARE(tracksModel.rowCount(), 24); | 667 | QCOMPARE(tracksModel.rowCount(), 24); | ||
Show All 29 Lines | 671 | { | |||
697 | tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track); | 697 | tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track); | ||
698 | 698 | | |||
699 | QCOMPARE(beginInsertRowsSpy.count(), 0); | 699 | QCOMPARE(beginInsertRowsSpy.count(), 0); | ||
700 | QCOMPARE(endInsertRowsSpy.count(), 0); | 700 | QCOMPARE(endInsertRowsSpy.count(), 0); | ||
701 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 701 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
702 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 702 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
703 | QCOMPARE(dataChangedSpy.count(), 0); | 703 | QCOMPARE(dataChangedSpy.count(), 0); | ||
704 | 704 | | |||
705 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("autoTest")); | 705 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
706 | 706 | | |||
707 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 707 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
708 | QCOMPARE(endInsertRowsSpy.count(), 1); | 708 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
709 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 709 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
710 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 710 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
711 | QCOMPARE(dataChangedSpy.count(), 0); | 711 | QCOMPARE(dataChangedSpy.count(), 0); | ||
712 | 712 | | |||
713 | QCOMPARE(tracksModel.rowCount(), 23); | 713 | QCOMPARE(tracksModel.rowCount(), 23); | ||
714 | 714 | | |||
715 | auto newTrack = MusicAudioTrack{true, QStringLiteral("$1"), QStringLiteral("0"), QStringLiteral("track1"), | 715 | auto newTrack = MusicAudioTrack{true, QStringLiteral("$1"), QStringLiteral("0"), QStringLiteral("track1"), | ||
716 | QStringLiteral("artist1"), QStringLiteral("album1"), QStringLiteral("Various Artists"), | 716 | QStringLiteral("artist1"), QStringLiteral("album1"), QStringLiteral("Various Artists"), | ||
717 | 1, 1, QTime::fromMSecsSinceStartOfDay(1), {QUrl::fromLocalFile(QStringLiteral("/$1"))}, | 717 | 1, 1, QTime::fromMSecsSinceStartOfDay(1), {QUrl::fromLocalFile(QStringLiteral("/$1"))}, | ||
718 | QDateTime::fromMSecsSinceEpoch(1), | 718 | QDateTime::fromMSecsSinceEpoch(1), | ||
719 | {QUrl::fromLocalFile(QStringLiteral("file://image$1"))}, 5, true, | 719 | {QUrl::fromLocalFile(QStringLiteral("file://image$1"))}, 5, true, | ||
720 | {}, QStringLiteral("composer1"), QStringLiteral("lyricist1"), false}; | 720 | {}, QStringLiteral("composer1"), QStringLiteral("lyricist1"), false}; | ||
721 | auto newTracks = QList<MusicAudioTrack>(); | 721 | auto newTracks = QList<MusicAudioTrack>(); | ||
722 | newTracks.push_back(newTrack); | 722 | newTracks.push_back(newTrack); | ||
723 | 723 | | |||
724 | musicDb.insertTracksList(newTracks, mNewCovers, QStringLiteral("autoTest")); | 724 | musicDb.insertTracksList(newTracks, mNewCovers); | ||
725 | 725 | | |||
726 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 726 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
727 | QCOMPARE(endInsertRowsSpy.count(), 1); | 727 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
728 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 728 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
729 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 729 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
730 | QCOMPARE(dataChangedSpy.count(), 1); | 730 | QCOMPARE(dataChangedSpy.count(), 1); | ||
731 | 731 | | |||
732 | QCOMPARE(tracksModel.rowCount(), 23); | 732 | QCOMPARE(tracksModel.rowCount(), 23); | ||
▲ Show 20 Lines • Show All 68 Lines • ▼ Show 20 Line(s) | 775 | { | |||
801 | tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track); | 801 | tracksModel.initialize(nullptr, nullptr, ElisaUtils::Track); | ||
802 | 802 | | |||
803 | QCOMPARE(beginInsertRowsSpy.count(), 0); | 803 | QCOMPARE(beginInsertRowsSpy.count(), 0); | ||
804 | QCOMPARE(endInsertRowsSpy.count(), 0); | 804 | QCOMPARE(endInsertRowsSpy.count(), 0); | ||
805 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 805 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
806 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 806 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
807 | QCOMPARE(dataChangedSpy.count(), 0); | 807 | QCOMPARE(dataChangedSpy.count(), 0); | ||
808 | 808 | | |||
809 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("autoTest")); | 809 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
810 | 810 | | |||
811 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 811 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
812 | QCOMPARE(endInsertRowsSpy.count(), 1); | 812 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
813 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 813 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
814 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 814 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
815 | QCOMPARE(dataChangedSpy.count(), 0); | 815 | QCOMPARE(dataChangedSpy.count(), 0); | ||
816 | 816 | | |||
817 | QCOMPARE(tracksModel.rowCount(), 23); | 817 | QCOMPARE(tracksModel.rowCount(), 23); | ||
818 | 818 | | |||
819 | auto newTrack = MusicAudioTrack{true, QStringLiteral("$23"), QStringLiteral("0"), QStringLiteral("track23"), | 819 | auto newTrack = MusicAudioTrack{true, QStringLiteral("$23"), QStringLiteral("0"), QStringLiteral("track23"), | ||
820 | QStringLiteral("artist2"), QStringLiteral("album4"), QStringLiteral("artist2"), 23, 1, QTime::fromMSecsSinceStartOfDay(23), | 820 | QStringLiteral("artist2"), QStringLiteral("album4"), QStringLiteral("artist2"), 23, 1, QTime::fromMSecsSinceStartOfDay(23), | ||
821 | {QUrl::fromLocalFile(QStringLiteral("/$23"))}, | 821 | {QUrl::fromLocalFile(QStringLiteral("/$23"))}, | ||
822 | QDateTime::fromMSecsSinceEpoch(23), | 822 | QDateTime::fromMSecsSinceEpoch(23), | ||
823 | {QUrl::fromLocalFile(QStringLiteral("file://image$23"))}, 5, true, | 823 | {QUrl::fromLocalFile(QStringLiteral("file://image$23"))}, 5, true, | ||
824 | {}, QStringLiteral("composer1"), QStringLiteral("lyricist1"), false}; | 824 | {}, QStringLiteral("composer1"), QStringLiteral("lyricist1"), false}; | ||
825 | 825 | | |||
826 | auto newTracks = QList<MusicAudioTrack>(); | 826 | auto newTracks = QList<MusicAudioTrack>(); | ||
827 | newTracks.push_back(newTrack); | 827 | newTracks.push_back(newTrack); | ||
828 | 828 | | |||
829 | musicDb.insertTracksList(newTracks, mNewCovers, QStringLiteral("autoTest")); | 829 | musicDb.insertTracksList(newTracks, mNewCovers); | ||
830 | 830 | | |||
831 | QCOMPARE(beginInsertRowsSpy.count(), 2); | 831 | QCOMPARE(beginInsertRowsSpy.count(), 2); | ||
832 | QCOMPARE(endInsertRowsSpy.count(), 2); | 832 | QCOMPARE(endInsertRowsSpy.count(), 2); | ||
833 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 833 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
834 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 834 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
835 | QCOMPARE(dataChangedSpy.count(), 5); | 835 | QCOMPARE(dataChangedSpy.count(), 5); | ||
836 | 836 | | |||
837 | QCOMPARE(tracksModel.rowCount(), 24); | 837 | QCOMPARE(tracksModel.rowCount(), 24); | ||
Show All 29 Lines | 841 | { | |||
867 | albumsModel.initialize(nullptr, nullptr, ElisaUtils::Album); | 867 | albumsModel.initialize(nullptr, nullptr, ElisaUtils::Album); | ||
868 | 868 | | |||
869 | QCOMPARE(beginInsertRowsSpy.count(), 0); | 869 | QCOMPARE(beginInsertRowsSpy.count(), 0); | ||
870 | QCOMPARE(endInsertRowsSpy.count(), 0); | 870 | QCOMPARE(endInsertRowsSpy.count(), 0); | ||
871 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 871 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
872 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 872 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
873 | QCOMPARE(dataChangedSpy.count(), 0); | 873 | QCOMPARE(dataChangedSpy.count(), 0); | ||
874 | 874 | | |||
875 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("autoTest")); | 875 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
876 | 876 | | |||
877 | QCOMPARE(albumsModel.rowCount(), 5); | 877 | QCOMPARE(albumsModel.rowCount(), 5); | ||
878 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 878 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
879 | QCOMPARE(endInsertRowsSpy.count(), 1); | 879 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
880 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 880 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
881 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 881 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
882 | QCOMPARE(dataChangedSpy.count(), 0); | 882 | QCOMPARE(dataChangedSpy.count(), 0); | ||
883 | 883 | | |||
▲ Show 20 Lines • Show All 44 Lines • ▼ Show 20 Line(s) | 901 | { | |||
928 | albumsModel.initialize(nullptr, nullptr, ElisaUtils::Album); | 928 | albumsModel.initialize(nullptr, nullptr, ElisaUtils::Album); | ||
929 | 929 | | |||
930 | QCOMPARE(beginInsertRowsSpy.count(), 0); | 930 | QCOMPARE(beginInsertRowsSpy.count(), 0); | ||
931 | QCOMPARE(endInsertRowsSpy.count(), 0); | 931 | QCOMPARE(endInsertRowsSpy.count(), 0); | ||
932 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 932 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
933 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 933 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
934 | QCOMPARE(dataChangedSpy.count(), 0); | 934 | QCOMPARE(dataChangedSpy.count(), 0); | ||
935 | 935 | | |||
936 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("autoTest")); | 936 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
937 | 937 | | |||
938 | QCOMPARE(albumsModel.rowCount(), 5); | 938 | QCOMPARE(albumsModel.rowCount(), 5); | ||
939 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 939 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
940 | QCOMPARE(endInsertRowsSpy.count(), 1); | 940 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
941 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 941 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
942 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 942 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
943 | QCOMPARE(dataChangedSpy.count(), 0); | 943 | QCOMPARE(dataChangedSpy.count(), 0); | ||
944 | 944 | | |||
▲ Show 20 Lines • Show All 49 Lines • ▼ Show 20 Line(s) | 968 | { | |||
994 | albumsModel.initialize(nullptr, nullptr, ElisaUtils::Album); | 994 | albumsModel.initialize(nullptr, nullptr, ElisaUtils::Album); | ||
995 | 995 | | |||
996 | QCOMPARE(beginInsertRowsSpy.count(), 0); | 996 | QCOMPARE(beginInsertRowsSpy.count(), 0); | ||
997 | QCOMPARE(endInsertRowsSpy.count(), 0); | 997 | QCOMPARE(endInsertRowsSpy.count(), 0); | ||
998 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 998 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
999 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 999 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
1000 | QCOMPARE(dataChangedSpy.count(), 0); | 1000 | QCOMPARE(dataChangedSpy.count(), 0); | ||
1001 | 1001 | | |||
1002 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("autoTest")); | 1002 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
1003 | 1003 | | |||
1004 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 1004 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
1005 | QCOMPARE(endInsertRowsSpy.count(), 1); | 1005 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
1006 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 1006 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
1007 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 1007 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
1008 | QCOMPARE(dataChangedSpy.count(), 0); | 1008 | QCOMPARE(dataChangedSpy.count(), 0); | ||
1009 | 1009 | | |||
1010 | auto newTrack = MusicAudioTrack{true, QStringLiteral("$23"), QStringLiteral("0"), QStringLiteral("track23"), | 1010 | auto newTrack = MusicAudioTrack{true, QStringLiteral("$23"), QStringLiteral("0"), QStringLiteral("track23"), | ||
1011 | QStringLiteral("artist2"), QStringLiteral("album4"), QStringLiteral("artist2"), 23, 1, QTime::fromMSecsSinceStartOfDay(23), | 1011 | QStringLiteral("artist2"), QStringLiteral("album4"), QStringLiteral("artist2"), 23, 1, QTime::fromMSecsSinceStartOfDay(23), | ||
1012 | {QUrl::fromLocalFile(QStringLiteral("/$23"))}, | 1012 | {QUrl::fromLocalFile(QStringLiteral("/$23"))}, | ||
1013 | QDateTime::fromMSecsSinceEpoch(23), | 1013 | QDateTime::fromMSecsSinceEpoch(23), | ||
1014 | {QUrl::fromLocalFile(QStringLiteral("file://image$23"))}, 5, true, | 1014 | {QUrl::fromLocalFile(QStringLiteral("file://image$23"))}, 5, true, | ||
1015 | {}, QStringLiteral("composer1"), QStringLiteral("lyricist1"), false}; | 1015 | {}, QStringLiteral("composer1"), QStringLiteral("lyricist1"), false}; | ||
1016 | auto newTracks = QList<MusicAudioTrack>(); | 1016 | auto newTracks = QList<MusicAudioTrack>(); | ||
1017 | newTracks.push_back(newTrack); | 1017 | newTracks.push_back(newTrack); | ||
1018 | 1018 | | |||
1019 | musicDb.insertTracksList(newTracks, mNewCovers, QStringLiteral("autoTest")); | 1019 | musicDb.insertTracksList(newTracks, mNewCovers); | ||
1020 | 1020 | | |||
1021 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 1021 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
1022 | QCOMPARE(endInsertRowsSpy.count(), 1); | 1022 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
1023 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 1023 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
1024 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 1024 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
1025 | QCOMPARE(dataChangedSpy.count(), 1); | 1025 | QCOMPARE(dataChangedSpy.count(), 1); | ||
1026 | } | 1026 | } | ||
1027 | 1027 | | |||
Show All 33 Lines | 1029 | { | |||
1061 | QCOMPARE(dataChangedSpy.count(), 0); | 1061 | QCOMPARE(dataChangedSpy.count(), 0); | ||
1062 | 1062 | | |||
1063 | auto newFiles = QList<QUrl>(); | 1063 | auto newFiles = QList<QUrl>(); | ||
1064 | const auto &constNewTracks = mNewTracks; | 1064 | const auto &constNewTracks = mNewTracks; | ||
1065 | for (const auto &oneTrack : constNewTracks) { | 1065 | for (const auto &oneTrack : constNewTracks) { | ||
1066 | newFiles.push_back(oneTrack.resourceURI()); | 1066 | newFiles.push_back(oneTrack.resourceURI()); | ||
1067 | } | 1067 | } | ||
1068 | 1068 | | |||
1069 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("autoTest")); | 1069 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
1070 | 1070 | | |||
1071 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 1071 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
1072 | QCOMPARE(endInsertRowsSpy.count(), 1); | 1072 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
1073 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 1073 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
1074 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 1074 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
1075 | QCOMPARE(dataChangedSpy.count(), 0); | 1075 | QCOMPARE(dataChangedSpy.count(), 0); | ||
1076 | 1076 | | |||
1077 | auto newTrack = MusicAudioTrack{true, QStringLiteral("$23"), QStringLiteral("0"), QStringLiteral("track1"), | 1077 | auto newTrack = MusicAudioTrack{true, QStringLiteral("$23"), QStringLiteral("0"), QStringLiteral("track1"), | ||
1078 | QStringLiteral("artist2"), QStringLiteral("album5"), QStringLiteral("artist2"), 1, 1, | 1078 | QStringLiteral("artist2"), QStringLiteral("album5"), QStringLiteral("artist2"), 1, 1, | ||
1079 | QTime::fromMSecsSinceStartOfDay(23), {QUrl::fromLocalFile(QStringLiteral("/$23"))}, | 1079 | QTime::fromMSecsSinceStartOfDay(23), {QUrl::fromLocalFile(QStringLiteral("/$23"))}, | ||
1080 | QDateTime::fromMSecsSinceEpoch(23), | 1080 | QDateTime::fromMSecsSinceEpoch(23), | ||
1081 | {QUrl::fromLocalFile(QStringLiteral("file://image$23"))}, 5, true, | 1081 | {QUrl::fromLocalFile(QStringLiteral("file://image$23"))}, 5, true, | ||
1082 | {}, QStringLiteral("composer1"), QStringLiteral("lyricist1"), false}; | 1082 | {}, QStringLiteral("composer1"), QStringLiteral("lyricist1"), false}; | ||
1083 | auto newTracks = QList<MusicAudioTrack>(); | 1083 | auto newTracks = QList<MusicAudioTrack>(); | ||
1084 | newTracks.push_back(newTrack); | 1084 | newTracks.push_back(newTrack); | ||
1085 | 1085 | | |||
1086 | auto newCover = QUrl::fromLocalFile(QStringLiteral("album5")); | 1086 | auto newCover = QUrl::fromLocalFile(QStringLiteral("album5")); | ||
1087 | auto newCovers = QHash<QString, QUrl>(); | 1087 | auto newCovers = QHash<QString, QUrl>(); | ||
1088 | newCovers[QStringLiteral("album5")] = newCover; | 1088 | newCovers[QStringLiteral("album5")] = newCover; | ||
1089 | 1089 | | |||
1090 | musicDb.insertTracksList(newTracks, newCovers, QStringLiteral("autoTest")); | 1090 | musicDb.insertTracksList(newTracks, newCovers); | ||
1091 | 1091 | | |||
1092 | QCOMPARE(beginInsertRowsSpy.count(), 2); | 1092 | QCOMPARE(beginInsertRowsSpy.count(), 2); | ||
1093 | QCOMPARE(endInsertRowsSpy.count(), 2); | 1093 | QCOMPARE(endInsertRowsSpy.count(), 2); | ||
1094 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 1094 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
1095 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 1095 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
1096 | QCOMPARE(dataChangedSpy.count(), 0); | 1096 | QCOMPARE(dataChangedSpy.count(), 0); | ||
1097 | } | 1097 | } | ||
1098 | 1098 | | |||
Show All 28 Lines | 1100 | { | |||
1127 | QCOMPARE(dataChangedSpy.count(), 0); | 1127 | QCOMPARE(dataChangedSpy.count(), 0); | ||
1128 | 1128 | | |||
1129 | auto newFiles = QList<QUrl>(); | 1129 | auto newFiles = QList<QUrl>(); | ||
1130 | const auto &constNewTracks = mNewTracks; | 1130 | const auto &constNewTracks = mNewTracks; | ||
1131 | for (const auto &oneTrack : constNewTracks) { | 1131 | for (const auto &oneTrack : constNewTracks) { | ||
1132 | newFiles.push_back(oneTrack.resourceURI()); | 1132 | newFiles.push_back(oneTrack.resourceURI()); | ||
1133 | } | 1133 | } | ||
1134 | 1134 | | |||
1135 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("autoTest")); | 1135 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
1136 | 1136 | | |||
1137 | QCOMPARE(artistsModel.rowCount(), 7); | 1137 | QCOMPARE(artistsModel.rowCount(), 7); | ||
1138 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 1138 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
1139 | QCOMPARE(endInsertRowsSpy.count(), 1); | 1139 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
1140 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 1140 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
1141 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 1141 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
1142 | QCOMPARE(dataChangedSpy.count(), 0); | 1142 | QCOMPARE(dataChangedSpy.count(), 0); | ||
1143 | 1143 | | |||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 1159 | { | |||
1186 | QCOMPARE(dataChangedSpy.count(), 0); | 1186 | QCOMPARE(dataChangedSpy.count(), 0); | ||
1187 | 1187 | | |||
1188 | auto newFiles = QList<QUrl>(); | 1188 | auto newFiles = QList<QUrl>(); | ||
1189 | const auto &constNewTracks = mNewTracks; | 1189 | const auto &constNewTracks = mNewTracks; | ||
1190 | for (const auto &oneTrack : constNewTracks) { | 1190 | for (const auto &oneTrack : constNewTracks) { | ||
1191 | newFiles.push_back(oneTrack.resourceURI()); | 1191 | newFiles.push_back(oneTrack.resourceURI()); | ||
1192 | } | 1192 | } | ||
1193 | 1193 | | |||
1194 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("autoTest")); | 1194 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
1195 | 1195 | | |||
1196 | QCOMPARE(artistsModel.rowCount(), 7); | 1196 | QCOMPARE(artistsModel.rowCount(), 7); | ||
1197 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 1197 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
1198 | QCOMPARE(endInsertRowsSpy.count(), 1); | 1198 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
1199 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 1199 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
1200 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 1200 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
1201 | QCOMPARE(dataChangedSpy.count(), 0); | 1201 | QCOMPARE(dataChangedSpy.count(), 0); | ||
1202 | 1202 | | |||
1203 | auto newTrack = MusicAudioTrack{true, QStringLiteral("$23"), QStringLiteral("0"), QStringLiteral("track23"), | 1203 | auto newTrack = MusicAudioTrack{true, QStringLiteral("$23"), QStringLiteral("0"), QStringLiteral("track23"), | ||
1204 | QStringLiteral("artist6"), QStringLiteral("album4"), QStringLiteral("Various Artists"), 23, 1, QTime::fromMSecsSinceStartOfDay(23), | 1204 | QStringLiteral("artist6"), QStringLiteral("album4"), QStringLiteral("Various Artists"), 23, 1, QTime::fromMSecsSinceStartOfDay(23), | ||
1205 | {QUrl::fromLocalFile(QStringLiteral("/$23"))}, | 1205 | {QUrl::fromLocalFile(QStringLiteral("/$23"))}, | ||
1206 | QDateTime::fromMSecsSinceEpoch(23), | 1206 | QDateTime::fromMSecsSinceEpoch(23), | ||
1207 | {QUrl::fromLocalFile(QStringLiteral("file://image$23"))}, 5, true, | 1207 | {QUrl::fromLocalFile(QStringLiteral("file://image$23"))}, 5, true, | ||
1208 | {}, QStringLiteral("composer1"), QStringLiteral("lyricist1"), false}; | 1208 | {}, QStringLiteral("composer1"), QStringLiteral("lyricist1"), false}; | ||
1209 | auto newTracks = QList<MusicAudioTrack>(); | 1209 | auto newTracks = QList<MusicAudioTrack>(); | ||
1210 | newTracks.push_back(newTrack); | 1210 | newTracks.push_back(newTrack); | ||
1211 | 1211 | | |||
1212 | auto newFiles2 = QList<QUrl>(); | 1212 | auto newFiles2 = QList<QUrl>(); | ||
1213 | for (const auto &oneTrack : newTracks) { | 1213 | for (const auto &oneTrack : newTracks) { | ||
1214 | newFiles2.push_back(oneTrack.resourceURI()); | 1214 | newFiles2.push_back(oneTrack.resourceURI()); | ||
1215 | } | 1215 | } | ||
1216 | 1216 | | |||
1217 | musicDb.insertTracksList(newTracks, mNewCovers, QStringLiteral("autoTest")); | 1217 | musicDb.insertTracksList(newTracks, mNewCovers); | ||
1218 | 1218 | | |||
1219 | QCOMPARE(artistsModel.rowCount(), 8); | 1219 | QCOMPARE(artistsModel.rowCount(), 8); | ||
1220 | QCOMPARE(beginInsertRowsSpy.count(), 2); | 1220 | QCOMPARE(beginInsertRowsSpy.count(), 2); | ||
1221 | QCOMPARE(endInsertRowsSpy.count(), 2); | 1221 | QCOMPARE(endInsertRowsSpy.count(), 2); | ||
1222 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 1222 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
1223 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 1223 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
1224 | QCOMPARE(dataChangedSpy.count(), 0); | 1224 | QCOMPARE(dataChangedSpy.count(), 0); | ||
1225 | } | 1225 | } | ||
Show All 40 Lines | 1228 | { | |||
1266 | QCOMPARE(dataChangedSpy.count(), 0); | 1266 | QCOMPARE(dataChangedSpy.count(), 0); | ||
1267 | 1267 | | |||
1268 | auto newFiles = QList<QUrl>(); | 1268 | auto newFiles = QList<QUrl>(); | ||
1269 | const auto &constNewTracks = mNewTracks; | 1269 | const auto &constNewTracks = mNewTracks; | ||
1270 | for (const auto &oneTrack : constNewTracks) { | 1270 | for (const auto &oneTrack : constNewTracks) { | ||
1271 | newFiles.push_back(oneTrack.resourceURI()); | 1271 | newFiles.push_back(oneTrack.resourceURI()); | ||
1272 | } | 1272 | } | ||
1273 | 1273 | | |||
1274 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("AutomaticTests")); | 1274 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
1275 | 1275 | | |||
1276 | QCOMPARE(artistsModel.rowCount(), 1); | 1276 | QCOMPARE(artistsModel.rowCount(), 1); | ||
1277 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 1277 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
1278 | QCOMPARE(endInsertRowsSpy.count(), 1); | 1278 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
1279 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 1279 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
1280 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 1280 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
1281 | QCOMPARE(modelAboutToBeResetSpy.count(), 0); | 1281 | QCOMPARE(modelAboutToBeResetSpy.count(), 0); | ||
1282 | QCOMPARE(modelResetSpy.count(), 0); | 1282 | QCOMPARE(modelResetSpy.count(), 0); | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 1287 | { | |||
1325 | QCOMPARE(dataChangedSpy.count(), 0); | 1325 | QCOMPARE(dataChangedSpy.count(), 0); | ||
1326 | 1326 | | |||
1327 | auto newFiles = QList<QUrl>(); | 1327 | auto newFiles = QList<QUrl>(); | ||
1328 | const auto &constNewTracks = mNewTracks; | 1328 | const auto &constNewTracks = mNewTracks; | ||
1329 | for (const auto &oneTrack : constNewTracks) { | 1329 | for (const auto &oneTrack : constNewTracks) { | ||
1330 | newFiles.push_back(oneTrack.resourceURI()); | 1330 | newFiles.push_back(oneTrack.resourceURI()); | ||
1331 | } | 1331 | } | ||
1332 | 1332 | | |||
1333 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("AutomaticTests")); | 1333 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
1334 | 1334 | | |||
1335 | QCOMPARE(artistsModel.rowCount(), 4); | 1335 | QCOMPARE(artistsModel.rowCount(), 4); | ||
1336 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 1336 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
1337 | QCOMPARE(endInsertRowsSpy.count(), 1); | 1337 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
1338 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 1338 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
1339 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 1339 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
1340 | QCOMPARE(modelAboutToBeResetSpy.count(), 0); | 1340 | QCOMPARE(modelAboutToBeResetSpy.count(), 0); | ||
1341 | QCOMPARE(modelResetSpy.count(), 0); | 1341 | QCOMPARE(modelResetSpy.count(), 0); | ||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Line(s) | 1346 | { | |||
1384 | QCOMPARE(dataChangedSpy.count(), 0); | 1384 | QCOMPARE(dataChangedSpy.count(), 0); | ||
1385 | 1385 | | |||
1386 | auto newFiles = QList<QUrl>(); | 1386 | auto newFiles = QList<QUrl>(); | ||
1387 | const auto &constNewTracks = mNewTracks; | 1387 | const auto &constNewTracks = mNewTracks; | ||
1388 | for (const auto &oneTrack : constNewTracks) { | 1388 | for (const auto &oneTrack : constNewTracks) { | ||
1389 | newFiles.push_back(oneTrack.resourceURI()); | 1389 | newFiles.push_back(oneTrack.resourceURI()); | ||
1390 | } | 1390 | } | ||
1391 | 1391 | | |||
1392 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("AutomaticTests")); | 1392 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
1393 | 1393 | | |||
1394 | QCOMPARE(artistsModel.rowCount(), 2); | 1394 | QCOMPARE(artistsModel.rowCount(), 2); | ||
1395 | QCOMPARE(beginInsertRowsSpy.count(), 1); | 1395 | QCOMPARE(beginInsertRowsSpy.count(), 1); | ||
1396 | QCOMPARE(endInsertRowsSpy.count(), 1); | 1396 | QCOMPARE(endInsertRowsSpy.count(), 1); | ||
1397 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 1397 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
1398 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 1398 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
1399 | QCOMPARE(modelAboutToBeResetSpy.count(), 0); | 1399 | QCOMPARE(modelAboutToBeResetSpy.count(), 0); | ||
1400 | QCOMPARE(modelResetSpy.count(), 0); | 1400 | QCOMPARE(modelResetSpy.count(), 0); | ||
Show All 25 Lines | 1405 | { | |||
1426 | QCOMPARE(beginInsertRowsSpy.count(), 0); | 1426 | QCOMPARE(beginInsertRowsSpy.count(), 0); | ||
1427 | QCOMPARE(endInsertRowsSpy.count(), 0); | 1427 | QCOMPARE(endInsertRowsSpy.count(), 0); | ||
1428 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 1428 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
1429 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 1429 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
1430 | QCOMPARE(modelAboutToBeResetSpy.count(), 0); | 1430 | QCOMPARE(modelAboutToBeResetSpy.count(), 0); | ||
1431 | QCOMPARE(modelResetSpy.count(), 0); | 1431 | QCOMPARE(modelResetSpy.count(), 0); | ||
1432 | QCOMPARE(dataChangedSpy.count(), 0); | 1432 | QCOMPARE(dataChangedSpy.count(), 0); | ||
1433 | 1433 | | |||
1434 | musicDb.insertTracksList(mNewTracks, mNewCovers, QStringLiteral("AutomaticTests")); | 1434 | musicDb.insertTracksList(mNewTracks, mNewCovers); | ||
1435 | 1435 | | |||
1436 | QCOMPARE(artistsModel.rowCount(), 0); | 1436 | QCOMPARE(artistsModel.rowCount(), 0); | ||
1437 | QCOMPARE(beginInsertRowsSpy.count(), 0); | 1437 | QCOMPARE(beginInsertRowsSpy.count(), 0); | ||
1438 | QCOMPARE(endInsertRowsSpy.count(), 0); | 1438 | QCOMPARE(endInsertRowsSpy.count(), 0); | ||
1439 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 1439 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
1440 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 1440 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
1441 | QCOMPARE(modelAboutToBeResetSpy.count(), 0); | 1441 | QCOMPARE(modelAboutToBeResetSpy.count(), 0); | ||
1442 | QCOMPARE(modelResetSpy.count(), 0); | 1442 | QCOMPARE(modelResetSpy.count(), 0); | ||
Show All 31 Lines | 1470 | {true, QStringLiteral("$32"), QStringLiteral("0"), QStringLiteral("track13"), | |||
1474 | QDateTime::fromMSecsSinceEpoch(32), | 1474 | QDateTime::fromMSecsSinceEpoch(32), | ||
1475 | {QUrl::fromLocalFile(QStringLiteral("album3"))}, 4, true, | 1475 | {QUrl::fromLocalFile(QStringLiteral("album3"))}, 4, true, | ||
1476 | QStringLiteral("genre3"), QStringLiteral("composer3"), QStringLiteral("lyricist3"), false}}; | 1476 | QStringLiteral("genre3"), QStringLiteral("composer3"), QStringLiteral("lyricist3"), false}}; | ||
1477 | 1477 | | |||
1478 | auto newCovers = mNewCovers; | 1478 | auto newCovers = mNewCovers; | ||
1479 | newCovers[QStringLiteral("file:///$31")] = QUrl::fromLocalFile(QStringLiteral("album1")); | 1479 | newCovers[QStringLiteral("file:///$31")] = QUrl::fromLocalFile(QStringLiteral("album1")); | ||
1480 | newCovers[QStringLiteral("file:///$32")] = QUrl::fromLocalFile(QStringLiteral("album3")); | 1480 | newCovers[QStringLiteral("file:///$32")] = QUrl::fromLocalFile(QStringLiteral("album3")); | ||
1481 | 1481 | | |||
1482 | musicDb.insertTracksList(newTracks, newCovers, QStringLiteral("autoTest")); | 1482 | musicDb.insertTracksList(newTracks, newCovers); | ||
1483 | 1483 | | |||
1484 | QCOMPARE(artistsModel.rowCount(), 5); | 1484 | QCOMPARE(artistsModel.rowCount(), 5); | ||
1485 | QCOMPARE(beginInsertRowsSpy.count(), 2); | 1485 | QCOMPARE(beginInsertRowsSpy.count(), 2); | ||
1486 | QCOMPARE(endInsertRowsSpy.count(), 2); | 1486 | QCOMPARE(endInsertRowsSpy.count(), 2); | ||
1487 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | 1487 | QCOMPARE(beginRemoveRowsSpy.count(), 0); | ||
1488 | QCOMPARE(endRemoveRowsSpy.count(), 0); | 1488 | QCOMPARE(endRemoveRowsSpy.count(), 0); | ||
1489 | QCOMPARE(modelAboutToBeResetSpy.count(), 0); | 1489 | QCOMPARE(modelAboutToBeResetSpy.count(), 0); | ||
1490 | QCOMPARE(modelResetSpy.count(), 0); | 1490 | QCOMPARE(modelResetSpy.count(), 0); | ||
1491 | QCOMPARE(dataChangedSpy.count(), 4); | 1491 | QCOMPARE(dataChangedSpy.count(), 4); | ||
1492 | } | 1492 | } | ||
1493 | }; | 1493 | }; | ||
1494 | 1494 | | |||
1495 | QTEST_GUILESS_MAIN(DataModelTests) | 1495 | QTEST_GUILESS_MAIN(DataModelTests) | ||
1496 | 1496 | | |||
1497 | 1497 | | |||
1498 | #include "datamodeltest.moc" | 1498 | #include "datamodeltest.moc" |