File indexing completed on 2024-11-10 04:22:08
0001 /**************************************************************************************** 0002 * Copyright (c) 2009 Maximilian Kossick <maximilian.kossick@googlemail.com> * 0003 * Copyright (c) 2010 Ralf Engels <ralf-engels@gmx.de> * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify it under * 0006 * the terms of the GNU General Public License as published by the Free Software * 0007 * Foundation; either version 2 of the License, or (at your option) any later * 0008 * version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 0011 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 0012 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 0013 * * 0014 * You should have received a copy of the GNU General Public License along with * 0015 * this program. If not, see <http://www.gnu.org/licenses/>. * 0016 ****************************************************************************************/ 0017 0018 #include "TestSqlScanManager.h" 0019 0020 #include "amarokconfig.h" 0021 #include "MetaTagLib.h" 0022 #include "scanner/GenericScanManager.h" 0023 #include "core-impl/collections/db/sql/SqlCollection.h" 0024 #include "core-impl/collections/db/sql/SqlQueryMaker.h" 0025 #include "core-impl/collections/db/sql/SqlRegistry.h" 0026 #include "core-impl/storage/sql/mysqlestorage/MySqlEmbeddedStorage.h" 0027 0028 #include "config-amarok-test.h" 0029 #include "SqlMountPointManagerMock.h" 0030 0031 #include <QBuffer> 0032 #include <QScopedPointer> 0033 #include <QSignalSpy> 0034 #include <QTest> 0035 0036 #include <KLocalizedString> 0037 #include <ThreadWeaver/Queue> 0038 0039 0040 QTEST_GUILESS_MAIN( TestSqlScanManager ) 0041 0042 TestSqlScanManager::TestSqlScanManager() 0043 : QObject() 0044 { 0045 QString help = i18n("Amarok"); // prevent a bug when the scanner is the first thread creating a translator 0046 } 0047 0048 void 0049 TestSqlScanManager::initTestCase() 0050 { 0051 AmarokConfig::instance("amarokrc"); 0052 m_autoGetCoverArt = AmarokConfig::autoGetCoverArt(); 0053 AmarokConfig::setAutoGetCoverArt( false ); 0054 0055 // setenv( "LC_ALL", "", 1 ); // this breaks the test 0056 // Amarok does not force LC_ALL=C but obviously the test does it which 0057 // will prevent scanning of files with umlauts. 0058 0059 //Tell GenericScanManager that we want to use the recently built scanner, not an installed version. 0060 const QString overridePath = QString( AMAROK_OVERRIDE_UTILITIES_PATH ); 0061 qApp->setProperty( "overrideUtilitiesPath", overridePath ); 0062 0063 // that is the original mp3 file that we use to generate the "real" tracks 0064 m_sourcePath = QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + "/data/audio/Platz 01.mp3" ); 0065 QVERIFY( QFile::exists( m_sourcePath ) ); 0066 0067 m_tmpDatabaseDir = new QTemporaryDir(); 0068 QVERIFY( m_tmpDatabaseDir->isValid() ); 0069 m_storage = QSharedPointer<MySqlEmbeddedStorage>( new MySqlEmbeddedStorage() ); 0070 QVERIFY( m_storage->init( m_tmpDatabaseDir->path() ) ); 0071 0072 m_collection = new Collections::SqlCollection( m_storage ); 0073 connect( m_collection, &Collections::SqlCollection::updated, this, &TestSqlScanManager::slotCollectionUpdated ); 0074 0075 // TODO: change the mock mount point manager so that it doesn't pull 0076 // in all the devices. Not much of a mock like this. 0077 SqlMountPointManagerMock *mock = new SqlMountPointManagerMock( this, m_storage ); 0078 m_collection->setMountPointManager( mock ); 0079 m_scanManager = m_collection->scanManager(); 0080 0081 AmarokConfig::setScanRecursively( true ); 0082 AmarokConfig::setMonitorChanges( false ); 0083 0084 // switch on writing back so that we can create the test files with all the information 0085 AmarokConfig::setWriteBack( true ); 0086 AmarokConfig::setWriteBackStatistics( true ); 0087 AmarokConfig::setWriteBackCover( true ); 0088 0089 // I just need the table and not the whole playlist manager 0090 /* 0091 m_storage->query( QString( "CREATE TABLE playlist_tracks (" 0092 " id " + m_storage->idType() + 0093 ", playlist_id INTEGER " 0094 ", track_num INTEGER " 0095 ", url " + m_storage->exactTextColumnType() + 0096 ", title " + m_storage->textColumnType() + 0097 ", album " + m_storage->textColumnType() + 0098 ", artist " + m_storage->textColumnType() + 0099 ", length INTEGER " 0100 ", uniqueid " + m_storage->textColumnType(128) + ") ENGINE = MyISAM;" ) ); 0101 */ 0102 } 0103 0104 void 0105 TestSqlScanManager::cleanupTestCase() 0106 { 0107 // aborts a ThreadWeaver job that would otherwise cause next statement to stall 0108 delete m_collection; 0109 0110 // we cannot simply call WeaverInterface::finish(), it stops event loop 0111 // QSignalSpy spy( ThreadWeaver::Queue::instance(), &ThreadWeaver::Queue::finished ); 0112 // if( !ThreadWeaver::Queue::instance()->isIdle() ) 0113 // QVERIFY2( spy.wait( 5000 ), "threads did not finish in timeout" ); 0114 0115 delete m_tmpDatabaseDir; 0116 0117 AmarokConfig::setAutoGetCoverArt( m_autoGetCoverArt ); 0118 } 0119 0120 void 0121 TestSqlScanManager::init() 0122 { 0123 m_tmpCollectionDir = new QTemporaryDir(); 0124 QVERIFY( m_tmpCollectionDir->isValid() ); 0125 0126 QStringList collectionFolders; 0127 collectionFolders << m_tmpCollectionDir->path(); 0128 m_collection->mountPointManager()->setCollectionFolders( collectionFolders ); 0129 } 0130 0131 void 0132 TestSqlScanManager::cleanup() 0133 { 0134 m_scanManager->abort(); 0135 0136 m_storage->query( "BEGIN" ); 0137 m_storage->query( "TRUNCATE TABLE tracks;" ); 0138 m_storage->query( "TRUNCATE TABLE albums;" ); 0139 m_storage->query( "TRUNCATE TABLE artists;" ); 0140 m_storage->query( "TRUNCATE TABLE composers;" ); 0141 m_storage->query( "TRUNCATE TABLE genres;" ); 0142 m_storage->query( "TRUNCATE TABLE years;" ); 0143 m_storage->query( "TRUNCATE TABLE urls;" ); 0144 m_storage->query( "TRUNCATE TABLE statistics;" ); 0145 m_storage->query( "TRUNCATE TABLE directories;" ); 0146 m_storage->query( "COMMIT" ); 0147 m_collection->registry()->emptyCache(); 0148 0149 delete m_tmpCollectionDir; 0150 } 0151 0152 void 0153 TestSqlScanManager::testScanSingle() 0154 { 0155 m_collectionUpdatedCount = 0; 0156 createSingleTrack(); 0157 fullScanAndWait(); 0158 0159 QVERIFY( m_collectionUpdatedCount > 0 ); 0160 0161 // -- check the commit 0162 Meta::TrackPtr track = m_collection->registry()->getTrack( 1 ); 0163 QVERIFY( track ); 0164 QCOMPARE( track->name(), QString("Theme From Armageddon") ); 0165 QVERIFY( track->artist() ); 0166 QCOMPARE( track->artist()->name(), QString("Soundtrack & Theme Orchestra") ); 0167 QVERIFY( track->album() ); 0168 QCOMPARE( track->album()->name(), QString("Big Screen Adventures") ); 0169 QVERIFY( track->album()->albumArtist() ); 0170 QCOMPARE( track->album()->albumArtist()->name(), QString("Theme Orchestra") ); 0171 QVERIFY( !track->album()->isCompilation() ); // One single track is not compilation 0172 QCOMPARE( track->composer()->name(), QString("Unknown Composer") ); 0173 QCOMPARE( track->comment(), QString("Amazon.com Song ID: 210541237") ); 0174 QCOMPARE( track->year()->year(), 2009 ); 0175 QCOMPARE( track->type(), QString("mp3") ); 0176 QCOMPARE( track->trackNumber(), 28 ); 0177 QCOMPARE( track->bitrate(), 257 ); // TagLib reports 257 kbit/s 0178 QCOMPARE( track->length(), qint64(12000) ); 0179 QCOMPARE( track->sampleRate(), 44100 ); 0180 QCOMPARE( track->filesize(), 389679 ); 0181 QDateTime aDate = QDateTime::currentDateTime(); 0182 QVERIFY( track->createDate().secsTo( aDate ) < 5 ); // I just imported the file 0183 QVERIFY( track->createDate().secsTo( aDate ) >= 0 ); 0184 QVERIFY( track->modifyDate().secsTo( aDate ) < 5 ); // I just wrote the file 0185 QVERIFY( track->modifyDate().secsTo( aDate ) >= 0 ); 0186 Meta::StatisticsPtr statistics = track->statistics(); 0187 QVERIFY( qFuzzyCompare( statistics->score(), 0.875 ) ); 0188 QCOMPARE( statistics->playCount(), 5 ); 0189 QVERIFY( !statistics->firstPlayed().isValid() ); 0190 QVERIFY( !statistics->lastPlayed().isValid() ); 0191 QVERIFY( track->createDate().isValid() ); 0192 0193 // -- check that a further scan doesn't change anything 0194 m_collectionUpdatedCount = 0; 0195 0196 fullScanAndWait(); 0197 0198 QCOMPARE( m_collectionUpdatedCount, 0 ); 0199 } 0200 0201 void 0202 TestSqlScanManager::testScanDirectory() 0203 { 0204 createAlbum(); 0205 fullScanAndWait(); 0206 0207 // -- check the commit 0208 Meta::AlbumPtr album; 0209 album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); 0210 QVERIFY( album ); 0211 QCOMPARE( album->name(), QString("Thriller") ); 0212 QCOMPARE( album->tracks().count(), 9 ); 0213 QVERIFY( !album->isCompilation() ); 0214 QVERIFY( !album->hasImage() ); 0215 } 0216 0217 void 0218 TestSqlScanManager::testDuplicateUid() 0219 { 0220 Meta::FieldHash values; 0221 0222 // create two tracks with same uid 0223 values.clear(); 0224 values.insert( Meta::valUniqueId, QVariant("c6c29f50279ab9523a0f44928bc1e96b") ); 0225 values.insert( Meta::valUrl, QVariant("track1.mp3") ); 0226 values.insert( Meta::valTitle, QVariant("Track 1") ); 0227 createTrack( values ); 0228 0229 values.clear(); 0230 values.insert( Meta::valUniqueId, QVariant("c6c29f50279ab9523a0f44928bc1e96b") ); 0231 values.insert( Meta::valUrl, QVariant("track2.mp3") ); 0232 values.insert( Meta::valTitle, QVariant("Track 2") ); 0233 createTrack( values ); 0234 0235 fullScanAndWait(); 0236 0237 // -- check the commit (the database needs to have been updated correctly) 0238 m_collection->registry()->emptyCache(); 0239 0240 // -- both tracks should be present 0241 Meta::AlbumPtr album; 0242 album = m_collection->registry()->getAlbum( 1 ); 0243 QVERIFY( album ); 0244 QVERIFY( album->tracks().count() >= 1 ); 0245 } 0246 0247 void 0248 TestSqlScanManager::testLongUid() 0249 { 0250 Meta::FieldHash values; 0251 0252 // create two tracks with different very long 0253 values.clear(); 0254 values.insert( Meta::valUniqueId, QVariant("c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96bbbbbbbbbbbbbbc6c29f50279ab9523a0f44928bc1e96b1") ); 0255 values.insert( Meta::valUrl, QVariant("track1.mp3") ); 0256 values.insert( Meta::valTitle, QVariant("Track 1") ); 0257 createTrack( values ); 0258 0259 values.clear(); 0260 values.insert( Meta::valUniqueId, QVariant("c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96c6c29f50279ab9523a0f44928bc1e96bbbbbbbbbbbbbbc6c29f50279ab9523a0f44928bc1e96b2") ); 0261 values.insert( Meta::valUrl, QVariant("track2.mp3") ); 0262 values.insert( Meta::valTitle, QVariant("Track 2") ); 0263 createTrack( values ); 0264 0265 fullScanAndWait(); 0266 0267 // -- check the commit (the database needs to have been updated correctly) 0268 m_collection->registry()->emptyCache(); 0269 0270 // both tracks should be present 0271 Meta::AlbumPtr album; 0272 album = m_collection->registry()->getAlbum( 1 ); 0273 QVERIFY( album ); 0274 QCOMPARE( album->tracks().count(), 2 ); 0275 } 0276 0277 0278 void 0279 TestSqlScanManager::testCompilation() 0280 { 0281 createAlbum(); 0282 createCompilation(); 0283 createCompilationLookAlikeAlbum(); 0284 0285 Meta::FieldHash values; 0286 0287 // create one compilation track 0288 values.clear(); 0289 values.insert( Meta::valUniqueId, QVariant("c6c29f50279ab9523a0f44928bc1e96b") ); 0290 values.insert( Meta::valUrl, QVariant("Amazon MP3/The Sum Of All Fears (O.S.T.)/The Sum of All Fears/01 - If We Could Remember (O.S.T. LP Version).mp3") ); 0291 values.insert( Meta::valTitle, QVariant("If We Could Remember (O.S.T. LP Version)") ); 0292 values.insert( Meta::valArtist, QVariant("The Sum Of All Fears (O.S.T.)/Yolanda Adams") ); 0293 values.insert( Meta::valAlbum, QVariant("The Sum of All Fears") ); 0294 values.insert( Meta::valCompilation, QVariant(true) ); 0295 createTrack( values ); 0296 0297 // create one various artists track 0298 values.clear(); 0299 values.insert( Meta::valUniqueId, QVariant("6ae759476c34256ff1d06f0b5c964d75") ); 0300 values.insert( Meta::valUrl, QVariant("The Cross Of Changes/06 - The Dream Of The Dolphin.mp3") ); 0301 values.insert( Meta::valTitle, QVariant("The Dream Of The Dolphin") ); 0302 values.insert( Meta::valArtist, QVariant("Various Artists") ); 0303 values.insert( Meta::valAlbum, QVariant("The Cross Of Changes") ); 0304 values.insert( Meta::valCompilation, QVariant(false) ); 0305 createTrack( values ); 0306 0307 // create two tracks in the same directory with different albums 0308 values.clear(); 0309 values.insert( Meta::valUniqueId, QVariant("7957bc25521c1dc91351d497321c27a6") ); 0310 values.insert( Meta::valUrl, QVariant("01 - Solid.mp3") ); 0311 values.insert( Meta::valTitle, QVariant("Solid") ); 0312 values.insert( Meta::valArtist, QVariant("Ashford & Simpson") ); 0313 values.insert( Meta::valAlbum, QVariant("Solid") ); 0314 createTrack( values ); 0315 0316 // create one none compilation track 0317 values.clear(); 0318 values.insert( Meta::valUniqueId, QVariant("b88c3405cfee64c50768b75eb6e3feea") ); 0319 values.insert( Meta::valUrl, QVariant("In-Mood feat. Juliette - The Last Unicorn (Elemental Radio Mix).mp3") ); 0320 values.insert( Meta::valTitle, QVariant("The Last Unicorn (Elemental Radio Mix)") ); 0321 values.insert( Meta::valArtist, QVariant("In-Mood") ); 0322 values.insert( Meta::valAlbum, QVariant("The Last Unicorn") ); 0323 createTrack( values ); 0324 0325 fullScanAndWait(); 0326 0327 // -- check the commit 0328 Meta::AlbumPtr album; 0329 0330 album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); 0331 QCOMPARE( album->tracks().count(), 9 ); 0332 QVERIFY( !album->isCompilation() ); 0333 0334 album = m_collection->registry()->getAlbum( "Top Gun", QString() ); 0335 QCOMPARE( album->name(), QString("Top Gun") ); 0336 QCOMPARE( album->tracks().count(), 10 ); 0337 QVERIFY( album->isCompilation() ); 0338 0339 album = m_collection->registry()->getAlbum( "The Sum of All Fears", QString() ); 0340 QCOMPARE( album->tracks().count(), 1 ); 0341 QVERIFY( album->isCompilation() ); 0342 0343 album = m_collection->registry()->getAlbum( "The Cross Of Changes", QString() ); 0344 QCOMPARE( album->tracks().count(), 1 ); 0345 QVERIFY( album->isCompilation() ); // the album is by various artists 0346 0347 album = m_collection->registry()->getAlbum( "Solid", "Ashford & Simpson" ); 0348 QCOMPARE( album->tracks().count(), 1 ); 0349 QVERIFY( !album->isCompilation() ); 0350 0351 album = m_collection->registry()->getAlbum( "The Last Unicorn", "In-Mood" ); 0352 QCOMPARE( album->tracks().count(), 1 ); 0353 QVERIFY( !album->isCompilation() ); 0354 0355 // this album is a little tricky because it has some nasty special characters in it. 0356 Meta::TrackPtr track = m_collection->registry()->getTrackFromUid( m_collection->uidUrlProtocol() + "://" + "0969ea6128444e128cfcac95207bd525" ); 0357 QVERIFY( track ); 0358 album = track->album(); 0359 QCOMPARE( album->tracks().count(), 13 ); 0360 QVERIFY( !album->isCompilation() ); 0361 } 0362 0363 void 0364 TestSqlScanManager::testBlock() 0365 { 0366 /** TODO: do we need blocking at all? 0367 0368 createSingleTrack(); 0369 Meta::TrackPtr track; 0370 0371 m_scanManager->blockScan(); // block the incremental scanning 0372 m_scanManager->requestFullScan(); 0373 0374 QTest::qWait( 100 ); 0375 track = m_collection->registry()->getTrack( 1 ); 0376 QVERIFY( !track ); 0377 QVERIFY( !m_scanManager->isRunning() ); 0378 0379 m_scanManager->unblockScan(); // block the incremental scanning 0380 // now the actual behaviour is not defined. 0381 // it might or might not continue with the old scan 0382 0383 waitScannerFinished(); // in case it does continue after all 0384 */ 0385 } 0386 0387 void 0388 TestSqlScanManager::testAddDirectory() 0389 { 0390 createAlbum(); 0391 fullScanAndWait(); 0392 0393 createCompilation(); 0394 fullScanAndWait(); 0395 0396 // -- check the commit 0397 Meta::AlbumPtr album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); 0398 QCOMPARE( album->tracks().count(), 9 ); 0399 QVERIFY( !album->isCompilation() ); 0400 0401 album = m_collection->registry()->getAlbum( "Top Gun", QString() ); 0402 QVERIFY( album ); 0403 QCOMPARE( album->tracks().count(), 10 ); 0404 QVERIFY( album->isCompilation() ); 0405 } 0406 0407 void 0408 TestSqlScanManager::testRemoveDir() 0409 { 0410 Meta::AlbumPtr album; 0411 0412 createAlbum(); 0413 createCompilation(); 0414 fullScanAndWait(); 0415 0416 // -- check the commit 0417 album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); 0418 QVERIFY( album ); 0419 QCOMPARE( album->tracks().count(), 9 ); 0420 QVERIFY( !album->isCompilation() ); 0421 0422 album = m_collection->registry()->getAlbum( "Top Gun", QString() ); 0423 QVERIFY( album ); 0424 QCOMPARE( album->tracks().count(), 10 ); 0425 QVERIFY( album->isCompilation() ); 0426 0427 // -- remove one album 0428 0429 album = m_collection->registry()->getAlbum( "Top Gun", QString() ); 0430 QVERIFY( album ); 0431 foreach( Meta::TrackPtr t, album->tracks() ) 0432 QVERIFY( QFile::remove( t->playableUrl().path() ) ); 0433 QVERIFY( QDir( m_tmpCollectionDir->path() ).rmdir( QFileInfo( album->tracks().first()->playableUrl().path() ).path() ) ); 0434 0435 fullScanAndWait(); 0436 0437 // this one is still here 0438 album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); 0439 QVERIFY( album ); 0440 QCOMPARE( album->tracks().count(), 9 ); 0441 QVERIFY( !album->isCompilation() ); 0442 0443 // this one is gone 0444 album = m_collection->registry()->getAlbum( "Top Gun", QString() ); 0445 QVERIFY( album ); 0446 QCOMPARE( album->tracks().count(), 0 ); 0447 0448 // -- remove the second album 0449 // this time it's a directory inside a directory 0450 album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); 0451 QVERIFY( album ); 0452 QCOMPARE( album->tracks().count(), 9 ); 0453 foreach( Meta::TrackPtr t, album->tracks() ) 0454 QVERIFY( QFile::remove( t->playableUrl().path() ) ); 0455 0456 QVERIFY( QDir( m_tmpCollectionDir->path() ).rmdir( QFileInfo( album->tracks().first()->playableUrl().path() ).path() ) ); 0457 0458 incrementalScanAndWait(); 0459 0460 // this time both are gone 0461 album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); 0462 QVERIFY( album ); 0463 QCOMPARE( album->tracks().count(), 0 ); 0464 album = m_collection->registry()->getAlbum( "Top Gun", QString() ); 0465 QVERIFY( album ); 0466 QCOMPARE( album->tracks().count(), 0 ); 0467 0468 } 0469 0470 void 0471 TestSqlScanManager::testUidChangeMoveDirectoryIncrementalScan() 0472 { 0473 createAlbum(); 0474 fullScanAndWait(); 0475 0476 Meta::AlbumPtr album; 0477 Meta::TrackList tracks; 0478 0479 // -- check the commit 0480 album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); 0481 QVERIFY( album ); 0482 tracks = album->tracks(); 0483 QCOMPARE( tracks.count(), 9 ); 0484 QCOMPARE( tracks.first()->uidUrl(), QString("amarok-sqltrackuid://1dc7022c52a3e4c51b46577da9b3c8ff") ); 0485 QVERIFY( !album->isCompilation() ); 0486 0487 // change all the track uids in a silly way 0488 QHash<int, QString> uidChanges; // uid hashed with track number 0489 foreach( const Meta::TrackPtr &track, tracks ) 0490 { 0491 Meta::FieldHash uidChange; 0492 QString uid = track->uidUrl().remove( QString("amarok-sqltrackuid://") ); 0493 QStringRef left = uid.leftRef( 10 ); 0494 QStringRef right = uid.rightRef( uid.size() - left.size() ); 0495 QString newUid = QString("%1%2").arg( right.toString(), left.toString() ); 0496 uidChange.insert( Meta::valUniqueId, newUid ); 0497 uidChanges.insert( track->trackNumber(), newUid ); 0498 0499 QUrl url = track->playableUrl(); 0500 QVERIFY( url.isLocalFile() ); 0501 Meta::Tag::writeTags( url.path(), uidChange, true ); 0502 } 0503 0504 // move album directory 0505 const QUrl oldUrl = tracks.first()->playableUrl(); 0506 const QString base = m_tmpCollectionDir->path() + "/Pop"; 0507 QVERIFY( QFile::rename( base, base + "Albums" ) ); 0508 0509 // do an incremental scan 0510 incrementalScanAndWait(); 0511 0512 // recheck album 0513 album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); 0514 QVERIFY( album ); 0515 tracks = album->tracks(); 0516 QCOMPARE( tracks.count(), 9 ); 0517 0518 // check changed uids 0519 foreach( const Meta::TrackPtr &track, tracks ) 0520 { 0521 QString uid = track->uidUrl().remove( QString("amarok-sqltrackuid://") ); 0522 QCOMPARE( uid, uidChanges.value( track->trackNumber() ) ); 0523 } 0524 } 0525 0526 void 0527 TestSqlScanManager::testRemoveTrack() 0528 { 0529 Meta::AlbumPtr album; 0530 Meta::TrackPtr track; 0531 QDateTime aDate = QDateTime::currentDateTime(); 0532 0533 createAlbum(); 0534 fullScanAndWait(); 0535 0536 // -- check the commit 0537 album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); 0538 QVERIFY( album ); 0539 QCOMPARE( album->tracks().count(), 9 ); 0540 QVERIFY( !album->isCompilation() ); 0541 track = album->tracks().first(); // the tracks are sorted, so this is always the same track 0542 QCOMPARE( track->trackNumber(), 1 ); 0543 QVERIFY( !track->statistics()->firstPlayed().isValid() ); 0544 static_cast<Meta::SqlTrack*>(track.data())->setFirstPlayed( aDate ); 0545 0546 // -- remove one track 0547 QVERIFY( QFile::remove( track->playableUrl().path() ) ); 0548 0549 fullScanAndWait(); 0550 0551 // -- check that the track is really gone 0552 QCOMPARE( album->tracks().count(), 8 ); 0553 } 0554 0555 void 0556 TestSqlScanManager::testMove() 0557 { 0558 createAlbum(); 0559 createCompilation(); 0560 0561 // we use the created and first played attributes for identifying the moved tracks. 0562 // currently those are not written back to the track 0563 0564 Meta::AlbumPtr album; 0565 Meta::TrackPtr track; 0566 QDateTime aDate = QDateTime::currentDateTime(); 0567 0568 fullScanAndWait(); 0569 if( qgetenv("AMAROK_RUN_LONG_TESTS").isNull() ) 0570 QSKIP( "takes too long to be run by default;\nDefine AMAROK_RUN_LONG_TESTS " 0571 "environment variable to run all tests.", SkipAll ); 0572 // -- check the commit 0573 album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); 0574 QVERIFY( album ); 0575 QCOMPARE( album->tracks().count(), 9 ); 0576 QVERIFY( !album->isCompilation() ); 0577 track = album->tracks().first(); 0578 QCOMPARE( track->trackNumber(), 1 ); 0579 QDateTime createDate = track->createDate(); 0580 QDateTime modifyDate = track->modifyDate(); 0581 0582 // --- move one track 0583 static_cast<Meta::SqlTrack*>(track.data())->setFirstPlayed( aDate ); 0584 const QString targetPath = m_tmpCollectionDir->path() + "/moved.mp3"; 0585 QVERIFY( QFile::rename( track->playableUrl().path(), targetPath ) ); 0586 0587 fullScanAndWait(); 0588 0589 // -- check that the track is moved 0590 QVERIFY( createDate == track->createDate() ); // create date should not have changed 0591 QVERIFY( modifyDate == track->modifyDate() ); // we just changed the track. it should have changed 0592 QCOMPARE( track->statistics()->firstPlayed(), aDate ); 0593 QCOMPARE( track->playableUrl().path(), targetPath ); 0594 0595 // --- move a directory 0596 album = m_collection->registry()->getAlbum( "Top Gun", QString() ); 0597 QVERIFY( album ); 0598 QCOMPARE( album->tracks().count(), 10 ); 0599 track = album->tracks().first(); 0600 QUrl oldUrl = track->playableUrl(); 0601 0602 QVERIFY( QFile::rename( m_tmpCollectionDir->path() + "/Top Gun", 0603 m_tmpCollectionDir->path() + "/Top Gun - Soundtrack" ) ); 0604 0605 // do an incremental scan 0606 incrementalScanAndWait(); 0607 0608 // check that the track is now moved (but still the old object) 0609 QCOMPARE( album->tracks().count(), 10 ); // no doublicate tracks 0610 QVERIFY( oldUrl != track->playableUrl() ); 0611 } 0612 0613 void 0614 TestSqlScanManager::testFeat() 0615 { 0616 Meta::FieldHash values; 0617 0618 // create one compilation track 0619 values.clear(); 0620 values.insert( Meta::valUniqueId, QVariant("b88c3405cfee64c50768b75eb6e3feea") ); 0621 values.insert( Meta::valUrl, QVariant("In-Mood feat. Juliette - The Last Unicorn (Elemental Radio Mix).mp3") ); 0622 values.insert( Meta::valTitle, QVariant("The Last Unicorn (Elemental Radio Mix)") ); 0623 values.insert( Meta::valArtist, QVariant("In-Mood feat. Juliette") ); 0624 values.insert( Meta::valAlbum, QVariant("The Last Unicorn") ); 0625 createTrack( values ); 0626 0627 fullScanAndWait(); 0628 0629 // -- check the commit 0630 Meta::AlbumPtr album; 0631 album = m_collection->registry()->getAlbum( "The Last Unicorn", "In-Mood" ); 0632 QVERIFY( album ); 0633 QCOMPARE( album->tracks().count(), 1 ); 0634 } 0635 0636 void 0637 TestSqlScanManager::testAlbumImage() 0638 { 0639 createSingleTrack(); 0640 createAlbum(); 0641 createCompilation(); 0642 0643 // put an image into the album directory 0644 QString imageSourcePath = QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + "/data/playlists/no-playlist.png" ); 0645 QVERIFY( QFile::exists( imageSourcePath ) ); 0646 QString targetPath; 0647 targetPath = m_tmpCollectionDir->path() + "/Pop/Thriller/cover.png"; 0648 QVERIFY( QFile::copy( m_sourcePath, targetPath ) ); 0649 0650 // put an image into the compilation directory 0651 targetPath = m_tmpCollectionDir->path() + "/Top Gun/front.png"; 0652 QVERIFY( QFile::copy( m_sourcePath, targetPath ) ); 0653 0654 // set an embedded image 0655 targetPath = m_tmpCollectionDir->path() + "/Various Artists/Big Screen Adventures/28 - Theme From Armageddon.mp3"; 0656 Meta::Tag::setEmbeddedCover( targetPath, QImage( 200, 200, QImage::Format_RGB32 ) ); 0657 0658 fullScanAndWait(); 0659 0660 // -- check the commit 0661 Meta::AlbumPtr album; 0662 0663 album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); 0664 QVERIFY( album ); 0665 QVERIFY( album->hasImage() ); 0666 0667 album = m_collection->registry()->getAlbum( "Top Gun", QString() ); 0668 QVERIFY( album ); 0669 QVERIFY( album->hasImage() ); 0670 0671 album = m_collection->registry()->getAlbum( "Big Screen Adventures", "Theme Orchestra" ); 0672 QVERIFY( album ); 0673 QVERIFY( album->hasImage() ); 0674 } 0675 0676 void 0677 TestSqlScanManager::testMerges() 0678 { 0679 // songs from same album but different directory 0680 // check that images are merged 0681 // check that old image is not overwritten 0682 0683 Meta::FieldHash values; 0684 0685 values.clear(); 0686 values.insert( Meta::valUniqueId, QVariant("123456d040d5dd9b5b45c1494d84cc82") ); 0687 values.insert( Meta::valUrl, QVariant("Various Artists/Big Screen Adventures/28 - Theme From Armageddon.mp3") ); 0688 values.insert( Meta::valFormat, QVariant("1") ); 0689 values.insert( Meta::valTitle, QVariant("Unnamed track") ); 0690 values.insert( Meta::valArtist, QVariant("Unknown artist") ); 0691 createTrack( values ); 0692 0693 // -- check the commit 0694 fullScanAndWait(); 0695 0696 Meta::TrackPtr track = m_collection->registry()->getTrack( 1 ); 0697 QVERIFY( track ); 0698 QCOMPARE( track->name(), QString("Unnamed track") ); 0699 0700 // -- now overwrite the track with changed information and a new uid 0701 // - remove one track 0702 QVERIFY( QFile::remove( track->playableUrl().path() ) ); 0703 0704 values.clear(); 0705 values.insert( Meta::valUniqueId, QVariant("794b1bd040d5dd9b5b45c1494d84cc82") ); 0706 values.insert( Meta::valUrl, QVariant("Various Artists/Big Screen Adventures/28 - Theme From Armageddon.mp3") ); 0707 values.insert( Meta::valFormat, QVariant("1") ); 0708 values.insert( Meta::valTitle, QVariant("Theme From Armageddon") ); 0709 values.insert( Meta::valArtist, QVariant("Soundtrack & Theme Orchestra") ); 0710 values.insert( Meta::valAlbum, QVariant("Big Screen Adventures") ); 0711 values.insert( Meta::valComposer, QVariant("Unknown Composer") ); 0712 values.insert( Meta::valComment, QVariant("Amazon.com Song ID: 210541237") ); 0713 values.insert( Meta::valGenre, QVariant("Broadway & Vocalists") ); 0714 values.insert( Meta::valYear, QVariant(2009) ); 0715 values.insert( Meta::valTrackNr, QVariant(28) ); 0716 values.insert( Meta::valScore, QVariant(0.875) ); 0717 values.insert( Meta::valPlaycount, QVariant(5) ); 0718 createTrack( values ); 0719 0720 fullScanAndWait(); 0721 0722 // -- check the commit 0723 QCOMPARE( track->name(), QString("Theme From Armageddon") ); 0724 QVERIFY( track->artist() ); 0725 QCOMPARE( track->artist()->name(), QString("Soundtrack & Theme Orchestra") ); 0726 QVERIFY( track->album() ); 0727 QCOMPARE( track->album()->name(), QString("Big Screen Adventures") );if( qgetenv("AMAROK_RUN_LONG_TESTS").isNull() ) 0728 QSKIP( "takes too long to be run by default;\nDefine AMAROK_RUN_LONG_TESTS " 0729 "environment variable to run all tests.", SkipAll ); 0730 QCOMPARE( track->composer()->name(), QString("Unknown Composer") ); 0731 QCOMPARE( track->comment(), QString("Amazon.com Song ID: 210541237") ); 0732 QCOMPARE( track->year()->year(), 2009 ); 0733 QCOMPARE( track->type(), QString("mp3") ); 0734 QCOMPARE( track->trackNumber(), 28 ); 0735 QCOMPARE( track->bitrate(), 257 ); 0736 QCOMPARE( track->length(), qint64(12000) ); 0737 QCOMPARE( track->sampleRate(), 44100 ); 0738 QCOMPARE( track->filesize(), 389679 ); 0739 Meta::StatisticsPtr statistics = track->statistics(); 0740 QVERIFY( qFuzzyCompare( statistics->score(), 0.875 ) ); 0741 QCOMPARE( statistics->playCount(), 5 ); 0742 QVERIFY( !statistics->firstPlayed().isValid() ); 0743 QVERIFY( !statistics->lastPlayed().isValid() ); 0744 QVERIFY( track->createDate().isValid() ); 0745 0746 0747 // -- now do an incremental scan 0748 createAlbum(); // add a new album 0749 incrementalScanAndWait(); 0750 0751 // -- check the commit 0752 Meta::AlbumPtr album; 0753 0754 // the old track is still there 0755 album = m_collection->registry()->getAlbum( "Big Screen Adventures", "Soundtrack & Theme Orchestra" ); 0756 QVERIFY( album ); 0757 QCOMPARE( album->tracks().count(), 1 ); 0758 0759 // the new album is now here 0760 album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); 0761 QVERIFY( album ); 0762 QCOMPARE( album->tracks().count(), 9 ); 0763 QVERIFY( !album->isCompilation() ); 0764 } 0765 0766 void 0767 TestSqlScanManager::testLargeInsert() 0768 { 0769 if( qgetenv("AMAROK_RUN_LONG_TESTS").isNull() ) 0770 QSKIP( "takes too long to be run by default;\nDefine AMAROK_RUN_LONG_TESTS " 0771 "environment variable to run all tests.", SkipAll ); 0772 // the old large insert test was misleading as the problems with 0773 // the insertion started upwards of 20000 tracks. 0774 // 0775 // For now here are the "ok" numbers on a sensible fast computer: 0776 // Scanning 10000 files <3 min 0777 // Committing 10000 files <30 sec 0778 // Scanning 50000 files <13 min 0779 // Committing 50000 files <1 min 0780 0781 QDateTime aDate = QDateTime::currentDateTime(); 0782 0783 // -- create the input data 0784 QByteArray byteArray; 0785 QBuffer *buffer = new QBuffer(&byteArray); 0786 buffer->open(QIODevice::ReadWrite); 0787 0788 QXmlStreamWriter writer( buffer ); 0789 0790 writer.writeStartElement( "scanner" ); 0791 0792 int trackCount = 0; 0793 0794 // some simulated normal albums 0795 for( int dirId = 0; dirId < 2000; dirId++ ) 0796 { 0797 writer.writeStartElement( "directory" ); 0798 writer.writeTextElement( "path", QString::number(dirId) ); 0799 writer.writeTextElement( "rpath", '/' + QString::number(dirId) ); 0800 writer.writeTextElement( "mtime", QString::number(aDate.toSecsSinceEpoch()) ); 0801 0802 for( int trackId = 0; trackId < 20; trackId++ ) 0803 { 0804 writer.writeStartElement( "track" ); 0805 writer.writeTextElement( "uniqueid", "uid" + QString::number(trackCount) ); 0806 writer.writeTextElement( "path", "/path" + QString::number(trackCount) ); 0807 writer.writeTextElement( "rpath", "path" + QString::number(trackCount) ); 0808 trackCount++; 0809 writer.writeTextElement( "title", "track" + QString::number(trackCount) ); 0810 writer.writeTextElement( "artist", "artist" + QString::number(dirId) ); 0811 writer.writeTextElement( "album", QString::number(dirId) ); 0812 writer.writeEndElement(); 0813 } 0814 0815 writer.writeEndElement(); 0816 } 0817 0818 // a simulated genre folders 0819 for( int dirId = 0; dirId < 7; dirId++ ) 0820 { 0821 writer.writeStartElement( "directory" ); 0822 writer.writeTextElement( "path", "genre" + QString::number(dirId) ); 0823 writer.writeTextElement( "rpath", "/genre" + QString::number(dirId) ); 0824 writer.writeTextElement( "mtime", QString::number(aDate.toSecsSinceEpoch()) ); 0825 0826 for( int albumId = 0; albumId < 1000; albumId++ ) 0827 { 0828 writer.writeStartElement( "track" ); 0829 writer.writeTextElement( "uniqueid", "uid" + QString::number(trackCount) ); 0830 writer.writeTextElement( "path", "/path" + QString::number(trackCount) ); 0831 writer.writeTextElement( "rpath", "path" + QString::number(trackCount) ); 0832 trackCount++; 0833 writer.writeTextElement( "title", "track" + QString::number(trackCount) ); 0834 writer.writeTextElement( "artist", 0835 "artist" + QString::number(dirId) + 0836 "xx" + QString::number(albumId) ); 0837 writer.writeTextElement( "album", 0838 "genre album" + QString::number(dirId) + 0839 "xx" + QString::number(albumId) ); 0840 writer.writeEndElement(); 0841 } 0842 0843 writer.writeEndElement(); 0844 } 0845 0846 // A simulated amarok 1.4 collection folder 0847 for( int dirId = 0; dirId < 3000; dirId++ ) 0848 { 0849 writer.writeStartElement( "directory" ); 0850 writer.writeTextElement( "path", "collection" + QString::number(dirId) ); 0851 writer.writeTextElement( "rpath", "/collection" + QString::number(dirId) ); 0852 writer.writeTextElement( "mtime", QString::number(aDate.toSecsSinceEpoch()) ); 0853 0854 writer.writeStartElement( "track" ); 0855 writer.writeTextElement( "uniqueid", "uid" + QString::number(trackCount) ); 0856 writer.writeTextElement( "path", "/path" + QString::number(trackCount) ); 0857 writer.writeTextElement( "rpath", "path" + QString::number(trackCount) ); 0858 trackCount++; 0859 writer.writeTextElement( "title", "track" + QString::number(trackCount) ); 0860 writer.writeTextElement( "artist", "album artist" + QString::number(dirId % 200) ); 0861 writer.writeTextElement( "album", "album" + QString::number(dirId % 300) ); 0862 writer.writeEndElement(); 0863 0864 writer.writeEndElement(); 0865 } 0866 0867 writer.writeEndElement(); 0868 0869 aDate = QDateTime::currentDateTime(); 0870 // -- feed the scanner in batch mode 0871 buffer->seek( 0 ); 0872 importAndWait( buffer ); 0873 0874 qDebug() << "performance test secs:"<< aDate.secsTo( QDateTime::currentDateTime() ); 0875 0876 QVERIFY( aDate.secsTo( QDateTime::currentDateTime() ) < 120 ); 0877 0878 // -- get all tracks 0879 Collections::SqlQueryMaker *qm = static_cast< Collections::SqlQueryMaker* >( m_collection->queryMaker() ); 0880 qm->setQueryType( Collections::QueryMaker::Track ); 0881 qm->setBlocking( true ); 0882 qm->run(); 0883 Meta::TrackList tracks = qm->tracks(); 0884 delete qm; 0885 0886 for( int i = 0; i < trackCount; i++ ) 0887 { 0888 Meta::TrackPtr track = m_collection->registry()->getTrackFromUid( m_collection->uidUrlProtocol() + "://uid" + QString::number(i) ); 0889 QVERIFY( track ); 0890 } 0891 0892 qDebug() << "performance test secs:"<< aDate.secsTo( QDateTime::currentDateTime() ) << "tracks:" << trackCount; 0893 QCOMPARE( tracks.count(), trackCount ); 0894 0895 // -- scan the input a second time. that should be a lot faster (but currently isn't) 0896 aDate = QDateTime::currentDateTime(); 0897 // -- feed the scanner in batch mode 0898 buffer = new QBuffer(&byteArray); // the old scanner deleted the old buffer. 0899 buffer->open(QIODevice::ReadWrite); 0900 importAndWait( buffer ); 0901 0902 qDebug() << "performance test secs:"<< aDate.secsTo( QDateTime::currentDateTime() ); 0903 0904 QVERIFY( aDate.secsTo( QDateTime::currentDateTime() ) < 80 ); 0905 } 0906 0907 void 0908 TestSqlScanManager::testIdentifyCompilationInMultipleDirectories() 0909 { 0910 // Compilations where each is track is from a different artist 0911 // are often stored as one track per directory, e.g. 0912 // /artistA/compilation/track1 0913 // /artistB/compilation/track2 0914 // 0915 // this is how Amarok 1 (after using Organize Collection) and iTunes are storing 0916 // these albums on disc 0917 // the bad thing is that Amarok 1 (as far as I know) didn't set the id3 tags 0918 0919 Meta::FieldHash values; 0920 0921 values.insert( Meta::valUniqueId, QVariant("5ef9fede5b3f98deb088b33428b0398e") ); 0922 values.insert( Meta::valUrl, QVariant("Kenny Loggins/Top Gun/Top Gun - 01 - Kenny Loggins - Danger Zone.mp3") ); 0923 values.insert( Meta::valFormat, QVariant("1") ); 0924 values.insert( Meta::valTitle, QVariant("Danger Zone") ); 0925 values.insert( Meta::valArtist, QVariant("Kenny Loggins") ); 0926 values.insert( Meta::valAlbum, QVariant("Top Gun") ); 0927 values.insert( Meta::valTrackNr, QVariant("1") ); 0928 createTrack( values ); 0929 0930 values.clear(); 0931 values.insert( Meta::valUniqueId, QVariant("3e3970f52b0eda3f2a8c1b3a8c8d39ea") ); 0932 values.insert( Meta::valUrl, QVariant("Cheap Trick/Top Gun/Top Gun - 02 - Cheap Trick - Mighty Wings.mp3") ); 0933 values.insert( Meta::valTitle, QVariant("Mighty Wings") ); 0934 values.insert( Meta::valArtist, QVariant("Cheap Trick") ); 0935 values.insert( Meta::valAlbum, QVariant("Top Gun") ); 0936 createTrack( values ); 0937 0938 values.clear(); 0939 values.insert( Meta::valUniqueId, QVariant("6ea0bbd97ad8068df58ad75a81f271f7") ); 0940 values.insert( Meta::valUrl, QVariant("Kenny Loggins/Top Gun/Top Gun - 03 - Kenny Loggins - Playing With The Boys.mp3") ); 0941 values.insert( Meta::valTitle, QVariant("Playing With The Boys") ); 0942 values.insert( Meta::valArtist, QVariant("Kenny Loggins") ); 0943 values.insert( Meta::valAlbum, QVariant("Top Gun") ); 0944 createTrack( values ); 0945 0946 values.clear(); 0947 values.insert( Meta::valUniqueId, QVariant("f3ac2e15288361d779a0ae813a2018ba") ); 0948 values.insert( Meta::valUrl, QVariant("Teena Marie/Top Gun/Top Gun - 04 - Teena Marie - Lead Me On.mp3") ); 0949 values.insert( Meta::valTitle, QVariant("Lead Me On") ); 0950 values.insert( Meta::valArtist, QVariant("Teena Marie") ); 0951 values.insert( Meta::valAlbum, QVariant("Top Gun") ); 0952 createTrack( values ); 0953 0954 fullScanAndWait(); 0955 0956 // -- check the commit 0957 Meta::AlbumPtr album = m_collection->registry()->getAlbum( "Top Gun", QString() ); 0958 QVERIFY( album ); 0959 QCOMPARE( album->name(), QString("Top Gun") ); 0960 QCOMPARE( album->tracks().count(), 4 ); 0961 QVERIFY( album->isCompilation() ); 0962 } 0963 0964 void 0965 TestSqlScanManager::testAlbumArtistMerges() 0966 { 0967 // three tracks with the same artist but different album artist. 0968 // (one is unset) 0969 // Those should end up in different albums. 0970 0971 Meta::FieldHash values; 0972 0973 values.insert( Meta::valUniqueId, QVariant("1ef9fede5b3f98deb088b33428b0398e") ); 0974 values.insert( Meta::valUrl, QVariant("test1/song1.mp3") ); 0975 values.insert( Meta::valTitle, QVariant("title1") ); 0976 values.insert( Meta::valArtist, QVariant("artist") ); 0977 values.insert( Meta::valAlbumArtist, QVariant("albumArtist1") ); 0978 values.insert( Meta::valAlbum, QVariant("test1") ); 0979 createTrack( values ); 0980 0981 values.clear(); 0982 values.insert( Meta::valUniqueId, QVariant("2ef9fede5b3f98deb088b33428b0398b") ); 0983 values.insert( Meta::valUrl, QVariant("test1/song2.mp3") ); 0984 values.insert( Meta::valTitle, QVariant("title2") ); 0985 values.insert( Meta::valArtist, QVariant("artist") ); 0986 values.insert( Meta::valAlbumArtist, QVariant("albumArtist2") ); 0987 values.insert( Meta::valAlbum, QVariant("test1") ); 0988 createTrack( values ); 0989 0990 values.clear(); 0991 values.insert( Meta::valUniqueId, QVariant("3ef9fede5b3f98deb088b33428b0398c") ); 0992 values.insert( Meta::valUrl, QVariant("test1/song3.mp3") ); 0993 values.insert( Meta::valTitle, QVariant("title3") ); 0994 values.insert( Meta::valArtist, QVariant("artist") ); 0995 values.insert( Meta::valAlbum, QVariant("test1") ); 0996 createTrack( values ); 0997 0998 fullScanAndWait(); 0999 1000 // -- check the commit 1001 Meta::AlbumPtr album; 1002 1003 album = m_collection->registry()->getAlbum( "test1", QString() ); 1004 QVERIFY( album ); 1005 QCOMPARE( album->name(), QString("test1") ); 1006 QCOMPARE( album->tracks().count(), 1 ); 1007 QVERIFY( album->isCompilation() ); 1008 1009 album = m_collection->registry()->getAlbum( "test1", QString("albumArtist1") ); 1010 QVERIFY( album ); 1011 QCOMPARE( album->name(), QString("test1") ); 1012 QCOMPARE( album->tracks().count(), 1 ); 1013 QVERIFY( !album->isCompilation() ); 1014 1015 album = m_collection->registry()->getAlbum( "test1", QString("albumArtist2") ); 1016 QVERIFY( album ); 1017 QCOMPARE( album->name(), QString("test1") ); 1018 QCOMPARE( album->tracks().count(), 1 ); 1019 QVERIFY( !album->isCompilation() ); 1020 } 1021 1022 void 1023 TestSqlScanManager::testCrossRenaming() 1024 { 1025 createAlbum(); 1026 1027 // we use the created and first played attributes for identifying the moved tracks. 1028 // currently those are not written back to the track 1029 1030 Meta::AlbumPtr album; 1031 Meta::TrackPtr track; 1032 1033 fullScanAndWait(); 1034 1035 // -- check the commit 1036 album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); 1037 QVERIFY( album ); 1038 QCOMPARE( album->tracks().count(), 9 ); 1039 QVERIFY( !album->isCompilation() ); 1040 1041 // --- cross-rename two track 1042 track = album->tracks().at( 0 ); 1043 static_cast<Meta::SqlTrack*>(track.data())->setRating( 1 ); 1044 QString path1 = track->playableUrl().path(); 1045 1046 track = album->tracks().at( 1 ); 1047 static_cast<Meta::SqlTrack*>(track.data())->setRating( 2 ); 1048 QString path2 = track->playableUrl().path(); 1049 1050 QString targetPath = m_tmpCollectionDir->path() + "moved.mp3"; 1051 QVERIFY( QFile::rename( path2, targetPath ) ); 1052 QVERIFY( QFile::rename( path1, path2 ) ); 1053 QVERIFY( QFile::rename( targetPath, path1 ) ); 1054 1055 fullScanAndWait(); 1056 1057 // -- check that the tracks are moved correctly 1058 album = m_collection->registry()->getAlbum( "Thriller", "Michael Jackson" ); 1059 QVERIFY( album ); 1060 QCOMPARE( album->tracks().count(), 9 ); 1061 1062 track = album->tracks().at( 0 ); 1063 QCOMPARE( track->statistics()->rating(), 1 ); 1064 QCOMPARE( track->playableUrl().path(), path2 ); 1065 1066 track = album->tracks().at( 1 ); 1067 QCOMPARE( track->statistics()->rating(), 2 ); 1068 QCOMPARE( track->playableUrl().path(), path1 ); 1069 } 1070 1071 1072 void 1073 TestSqlScanManager::slotCollectionUpdated() 1074 { 1075 m_collectionUpdatedCount++; 1076 } 1077 1078 void 1079 TestSqlScanManager::fullScanAndWait() 1080 { 1081 QScopedPointer<Capabilities::CollectionScanCapability> csc( m_collection->create<Capabilities::CollectionScanCapability>()); 1082 if( csc ) 1083 { 1084 csc->startFullScan(); 1085 waitScannerFinished(); 1086 } 1087 } 1088 1089 void 1090 TestSqlScanManager::incrementalScanAndWait() 1091 { 1092 // incremental scans use the modification time of the file system. 1093 // this time is only in seconds, so to be sure that the incremental scan 1094 // works we need to wait at least one second. 1095 QTest::qWait( 1000 ); 1096 1097 QScopedPointer<Capabilities::CollectionScanCapability> csc( m_collection->create<Capabilities::CollectionScanCapability>()); 1098 if( csc ) 1099 csc->startIncrementalScan(); 1100 1101 waitScannerFinished(); 1102 } 1103 1104 void 1105 TestSqlScanManager::importAndWait( QIODevice* input ) 1106 { 1107 QScopedPointer<Capabilities::CollectionImportCapability> csc( m_collection->create<Capabilities::CollectionImportCapability>()); 1108 if( csc ) 1109 csc->import( input, nullptr ); 1110 1111 waitScannerFinished(); 1112 } 1113 1114 void 1115 TestSqlScanManager::waitScannerFinished() 1116 { 1117 QVERIFY( m_scanManager->isRunning() ); 1118 QSignalSpy succeedSpy( m_scanManager, &GenericScanManager::succeeded ); 1119 QSignalSpy failSpy( m_scanManager, &GenericScanManager::failed ); 1120 QSignalSpy resultSpy( this, &TestSqlScanManager::scanManagerResult ); 1121 1122 // connect the result signal *after* the spies to ensure they are updated first 1123 connect( m_scanManager, &GenericScanManager::succeeded, this, &TestSqlScanManager::scanManagerResult ); 1124 connect( m_scanManager, &GenericScanManager::failed, this, &TestSqlScanManager::scanManagerResult); 1125 const bool ok = resultSpy.wait( 5000 ); 1126 disconnect( m_scanManager, &GenericScanManager::succeeded, this, &TestSqlScanManager::scanManagerResult ); 1127 disconnect( m_scanManager, &GenericScanManager::failed, this, &TestSqlScanManager::scanManagerResult ); 1128 QVERIFY2( ok, "Scan Manager timed out without a result" ); 1129 1130 if( failSpy.count() > 0 ) 1131 { 1132 QStringList errors; 1133 foreach( const QList<QVariant> &arguments, static_cast<QList<QList<QVariant> > >( failSpy ) ) 1134 errors << arguments.value( 0 ).toString(); 1135 // this will fire each time: 1136 qWarning() << "ScanManager failed with an error:" << errors.join( ", " ); 1137 } 1138 QCOMPARE( qMakePair( succeedSpy.count(), failSpy.count() ), qMakePair( 1, 0 ) ); 1139 1140 QVERIFY( !m_scanManager->isRunning() ); 1141 } 1142 1143 void 1144 TestSqlScanManager::createTrack( const Meta::FieldHash &values ) 1145 { 1146 // -- copy the file from our original 1147 QVERIFY( values.contains( Meta::valUrl ) ); 1148 const QString targetPath = m_tmpCollectionDir->path() + '/' + values.value( Meta::valUrl ).toString(); 1149 QVERIFY( QDir( m_tmpCollectionDir->path() ).mkpath( QFileInfo( values.value( Meta::valUrl ).toString() ).path() ) ); 1150 QVERIFY( QFile::copy( m_sourcePath, targetPath ) ); 1151 1152 // -- set all the values that we need 1153 Meta::Tag::writeTags( targetPath, values, true ); 1154 } 1155 1156 void 1157 TestSqlScanManager::createSingleTrack() 1158 { 1159 Meta::FieldHash values; 1160 1161 values.insert( Meta::valUniqueId, QVariant("794b1bd040d5dd9b5b45c1494d84cc82") ); 1162 values.insert( Meta::valUrl, QVariant("Various Artists/Big Screen Adventures/28 - Theme From Armageddon.mp3") ); 1163 values.insert( Meta::valFormat, QVariant("1") ); 1164 values.insert( Meta::valTitle, QVariant("Theme From Armageddon") ); 1165 values.insert( Meta::valArtist, QVariant("Soundtrack & Theme Orchestra") ); 1166 values.insert( Meta::valAlbumArtist, QVariant("Theme Orchestra") ); 1167 values.insert( Meta::valAlbum, QVariant("Big Screen Adventures") ); 1168 values.insert( Meta::valComposer, QVariant("Unknown Composer") ); 1169 values.insert( Meta::valComment, QVariant("Amazon.com Song ID: 210541237") ); 1170 values.insert( Meta::valGenre, QVariant("Broadway & Vocalists") ); 1171 values.insert( Meta::valYear, QVariant(2009) ); 1172 values.insert( Meta::valTrackNr, QVariant(28) ); 1173 // values.insert( Meta::valBitrate, QVariant(216) ); // the bitrate can not be set. it's computed 1174 // values.insert( Meta::valLength, QVariant(184000) ); // also can't be set 1175 // values.insert( Meta::valSamplerate, QVariant(44100) ); // again 1176 // values.insert( Meta::valFilesize, QVariant(5094892) ); // again 1177 values.insert( Meta::valScore, QVariant(0.875) ); 1178 values.insert( Meta::valPlaycount, QVariant(5) ); 1179 // TODO: set an embedded cover 1180 1181 createTrack( values ); 1182 } 1183 1184 void 1185 TestSqlScanManager::createAlbum() 1186 { 1187 Meta::FieldHash values; 1188 1189 values.insert( Meta::valUniqueId, QVariant("1dc7022c52a3e4c51b46577da9b3c8ff") ); 1190 values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 01 - Michael Jackson - Track01.mp3") ); 1191 values.insert( Meta::valTitle, QVariant("Wanna Be Startin' Somethin'") ); 1192 values.insert( Meta::valArtist, QVariant("Michael Jackson") ); 1193 values.insert( Meta::valAlbum, QVariant("Thriller") ); 1194 values.insert( Meta::valYear, QVariant(1982) ); 1195 values.insert( Meta::valTrackNr, QVariant(1) ); 1196 createTrack( values ); 1197 1198 values.clear(); 1199 values.insert( Meta::valUniqueId, QVariant("1dc708934a3e4c51b46577da9b3ab11") ); 1200 values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 02 - Michael Jackson - Track02.mp3") ); 1201 values.insert( Meta::valTitle, QVariant("Baby Be Mine") ); 1202 values.insert( Meta::valArtist, QVariant("Michael Jackson") ); 1203 values.insert( Meta::valAlbum, QVariant("Thriller") ); 1204 values.insert( Meta::valYear, QVariant(1982) ); 1205 values.insert( Meta::valTrackNr, QVariant(2) ); 1206 createTrack( values ); 1207 1208 values.clear(); 1209 values.insert( Meta::valUniqueId, QVariant("15a6b1bf79747fdc8e9c6b6f06203017") ); 1210 values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 03 - Michael Jackson - Track03.mp3") ); 1211 values.insert( Meta::valTitle, QVariant("The Girl Is Mine") ); 1212 values.insert( Meta::valArtist, QVariant("Michael Jackson") ); 1213 values.insert( Meta::valAlbum, QVariant("Thriller") ); 1214 values.insert( Meta::valYear, QVariant(1982) ); 1215 values.insert( Meta::valTrackNr, QVariant(3) ); 1216 createTrack( values ); 1217 1218 values.clear(); 1219 values.insert( Meta::valUniqueId, QVariant("4aba4c8b1d1893c03c112cc3c01221e9") ); 1220 values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 04 - Michael Jackson - Track04.mp3") ); 1221 values.insert( Meta::valTitle, QVariant("Thriller") ); 1222 values.insert( Meta::valArtist, QVariant("Michael Jackson") ); 1223 values.insert( Meta::valAlbum, QVariant("Thriller") ); 1224 values.insert( Meta::valYear, QVariant(1982) ); 1225 values.insert( Meta::valTrackNr, QVariant(4) ); 1226 createTrack( values ); 1227 1228 values.clear(); 1229 values.insert( Meta::valUniqueId, QVariant("cb44d2a3d8053829b04672723bf0bd6e") ); 1230 values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 05 - Michael Jackson - Track05.mp3") ); 1231 values.insert( Meta::valTitle, QVariant("Beat It") ); 1232 values.insert( Meta::valArtist, QVariant("Michael Jackson") ); 1233 values.insert( Meta::valAlbum, QVariant("Thriller") ); 1234 values.insert( Meta::valYear, QVariant(1982) ); 1235 values.insert( Meta::valTrackNr, QVariant(5) ); 1236 createTrack( values ); 1237 1238 values.clear(); 1239 values.insert( Meta::valUniqueId, QVariant("eba1858eeeb3c6d97fe3385200114d86") ); 1240 values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 06 - Michael Jackson - Track06.mp3") ); 1241 values.insert( Meta::valTitle, QVariant("Billy Jean") ); 1242 values.insert( Meta::valArtist, QVariant("Michael Jackson") ); 1243 values.insert( Meta::valAlbum, QVariant("Thriller") ); 1244 values.insert( Meta::valYear, QVariant(1982) ); 1245 values.insert( Meta::valTrackNr, QVariant(6) ); 1246 createTrack( values ); 1247 1248 values.clear(); 1249 values.insert( Meta::valUniqueId, QVariant("4623850290998486b0f7b39a2719904e") ); 1250 values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 07 - Michael Jackson - Track07.mp3") ); 1251 values.insert( Meta::valTitle, QVariant("Human Nature") ); 1252 values.insert( Meta::valArtist, QVariant("Michael Jackson") ); 1253 values.insert( Meta::valAlbum, QVariant("Thriller") ); 1254 values.insert( Meta::valYear, QVariant(1982) ); 1255 values.insert( Meta::valTrackNr, QVariant(7) ); 1256 createTrack( values ); 1257 1258 values.clear(); 1259 values.insert( Meta::valUniqueId, QVariant("6d9a7de13af1e16bb13a6208e44b046d") ); 1260 values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 08 - Michael Jackson - Track08.mp3") ); 1261 values.insert( Meta::valTitle, QVariant("P.Y.T. (Pretty Young Thing)") ); 1262 values.insert( Meta::valArtist, QVariant("Michael Jackson") ); 1263 values.insert( Meta::valAlbum, QVariant("Thriller") ); 1264 values.insert( Meta::valYear, QVariant(1982) ); 1265 values.insert( Meta::valTrackNr, QVariant(8) ); 1266 createTrack( values ); 1267 1268 values.clear(); 1269 values.insert( Meta::valUniqueId, QVariant("91cf9a7c0d255399f9f6babfacae432b") ); 1270 values.insert( Meta::valUrl, QVariant("Pop/Thriller/Thriller - 09 - Michael Jackson - Track09.mp3") ); 1271 values.insert( Meta::valTitle, QVariant("The Lady In My Life") ); 1272 values.insert( Meta::valArtist, QVariant("Michael Jackson") ); 1273 values.insert( Meta::valAlbum, QVariant("Thriller") ); 1274 values.insert( Meta::valYear, QVariant(1982) ); 1275 values.insert( Meta::valTrackNr, QVariant(9) ); 1276 createTrack( values ); 1277 } 1278 1279 void 1280 TestSqlScanManager::createCompilation() 1281 { 1282 // a compilation without the compilation flags values.insert( Meta::valCompilation, QVariant(true) ); 1283 Meta::FieldHash values; 1284 1285 values.insert( Meta::valUniqueId, QVariant("5ef9fede5b3f98deb088b33428b0398e") ); 1286 values.insert( Meta::valUrl, QVariant("Top Gun/Top Gun - 01 - Kenny Loggins - Danger Zone.mp3") ); 1287 values.insert( Meta::valFormat, QVariant("1") ); 1288 values.insert( Meta::valTitle, QVariant("Danger Zone") ); 1289 values.insert( Meta::valArtist, QVariant("Kenny Loggins") ); 1290 values.insert( Meta::valAlbum, QVariant("Top Gun") ); 1291 createTrack( values ); 1292 1293 values.clear(); 1294 values.insert( Meta::valUniqueId, QVariant("3e3970f52b0eda3f2a8c1b3a8c8d39ea") ); 1295 values.insert( Meta::valUrl, QVariant("Top Gun/Top Gun - 02 - Cheap Trick - Mighty Wings.mp3") ); 1296 values.insert( Meta::valTitle, QVariant("Mighty Wings") ); 1297 values.insert( Meta::valArtist, QVariant("Cheap Trick") ); 1298 values.insert( Meta::valAlbum, QVariant("Top Gun") ); 1299 createTrack( values ); 1300 1301 values.clear(); 1302 values.insert( Meta::valUniqueId, QVariant("6ea0bbd97ad8068df58ad75a81f271f7") ); 1303 values.insert( Meta::valUrl, QVariant("Top Gun/Top Gun - 03 - Kenny Loggins - Playing With The Boys.mp3") ); 1304 values.insert( Meta::valTitle, QVariant("Playing With The Boys") ); 1305 values.insert( Meta::valArtist, QVariant("Kenny Loggins") ); 1306 values.insert( Meta::valAlbum, QVariant("Top Gun") ); 1307 createTrack( values ); 1308 1309 values.clear(); 1310 values.insert( Meta::valUniqueId, QVariant("f3ac2e15288361d779a0ae813a2018ba") ); 1311 values.insert( Meta::valUrl, QVariant("Top Gun/Top Gun - 04 - Teena Marie - Lead Me On.mp3") ); 1312 values.insert( Meta::valTitle, QVariant("Lead Me On") ); 1313 values.insert( Meta::valArtist, QVariant("Teena Marie") ); 1314 values.insert( Meta::valAlbum, QVariant("Top Gun") ); 1315 createTrack( values ); 1316 1317 values.clear(); 1318 values.insert( Meta::valUniqueId, QVariant("ffe2bb3e6e2f698983c95e40937545ff") ); 1319 values.insert( Meta::valUrl, QVariant("Top Gun/Top Gun - 05 - Berlin - Take My Breath Away (Love Theme From _Top Gun_).mp3") ); 1320 values.insert( Meta::valTitle, QVariant("Take My Breath Away (Love Theme From "Top Gun")") ); 1321 values.insert( Meta::valArtist, QVariant("Berlin") ); 1322 values.insert( Meta::valAlbum, QVariant("Top Gun") ); 1323 createTrack( values ); 1324 1325 values.clear(); 1326 values.insert( Meta::valUniqueId, QVariant("c871dba16f92483898bcd6a1ed1bc14f") ); 1327 values.insert( Meta::valUrl, QVariant("Top Gun/Top Gun - 06 - Miami Sound Machine - Hot Summer Nights.mp3") ); 1328 values.insert( Meta::valTitle, QVariant("Hot Summer Nights") ); 1329 values.insert( Meta::valArtist, QVariant("Miami Sound Machine") ); 1330 values.insert( Meta::valAlbum, QVariant("Top Gun") ); 1331 createTrack( values ); 1332 1333 values.clear(); 1334 values.insert( Meta::valUniqueId, QVariant("80d157c36ed334192ed8df4c01bf0d4e") ); 1335 values.insert( Meta::valUrl, QVariant("Top Gun/Top Gun - 07 - Loverboy - Heaven In Your Eyes.mp3") ); 1336 values.insert( Meta::valTitle, QVariant("Heaven In Your Eyes") ); 1337 values.insert( Meta::valArtist, QVariant("Loverboy") ); 1338 values.insert( Meta::valAlbum, QVariant("Top Gun") ); 1339 createTrack( values ); 1340 1341 values.clear(); 1342 values.insert( Meta::valUniqueId, QVariant("1fe5897cdea860348c3a5eb40d47c382") ); 1343 values.insert( Meta::valUrl, QVariant("Top Gun/Top Gun - 08 - Larry Greene - Through The Fire.mp3") ); 1344 values.insert( Meta::valTitle, QVariant("Through The Fire") ); 1345 values.insert( Meta::valArtist, QVariant("Larry Greene") ); 1346 values.insert( Meta::valAlbum, QVariant("Top Gun") ); 1347 createTrack( values ); 1348 1349 values.clear(); 1350 values.insert( Meta::valUniqueId, QVariant("e0eacff604bfe38b5c275b45aa4f5323") ); 1351 values.insert( Meta::valUrl, QVariant("Top Gun/Top Gun - 09 - Marietta - Destination Unknown.mp3") ); 1352 values.insert( Meta::valTitle, QVariant("Destination Unknown") ); 1353 values.insert( Meta::valArtist, QVariant("Marietta") ); 1354 values.insert( Meta::valAlbum, QVariant("Top Gun") ); 1355 createTrack( values ); 1356 1357 values.clear(); 1358 values.insert( Meta::valUniqueId, QVariant("9f1b00dab2df7537b6c5b2be9f08b220") ); 1359 values.insert( Meta::valUrl, QVariant("Top Gun/Top Gun - 10 - Harold Faltermeyer & Steve Stevens - Top Gun Anthem.mp3") ); 1360 values.insert( Meta::valTitle, QVariant("Top Gun Anthem") ); 1361 values.insert( Meta::valArtist, QVariant("Harold Faltermeyer & Steve Stevens") ); 1362 values.insert( Meta::valAlbum, QVariant("Top Gun") ); 1363 createTrack( values ); 1364 } 1365 1366 void 1367 TestSqlScanManager::createCompilationLookAlikeAlbum() 1368 { 1369 Meta::FieldHash values; 1370 1371 // Some systems have problems with the umlauts in the file names. 1372 // That is the case where the system encoding when compiling does not 1373 // match the one of the file system. 1374 // the following is the original filename 1375 // values.insert( Meta::valUrl, QVariant( "Glen Hansard & Markéta Irglová/Once/01 Glen Hansard & Markéta Irglová - Falling Slowly.mp3" ) ); 1376 1377 values.insert( Meta::valUniqueId, QVariant( "8375aa24e0e0434ca0c36e382b6f188c" ) ); 1378 values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/01 Glen Hansard & Marketa Irglova - Falling Slowly.mp3" ) ); 1379 values.insert( Meta::valFormat, QVariant( "1" ) ); 1380 values.insert( Meta::valTitle, QVariant( "Falling Slowly" ) ); 1381 values.insert( Meta::valArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); 1382 values.insert( Meta::valAlbum, QVariant( "Once" ) ); 1383 values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); 1384 values.insert( Meta::valTrackNr, QVariant( "1" ) ); 1385 createTrack( values ); 1386 1387 values.insert( Meta::valUniqueId, QVariant( "ff3f82b1c2e1434d9d1a7b6aec67ac9c" ) ); 1388 values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/02 Glen Hansard & Marketa Irglova - If You Want Me.mp3" ) ); 1389 values.insert( Meta::valFormat, QVariant( "1" ) ); 1390 values.insert( Meta::valTitle, QVariant( "If You Want Me" ) ); 1391 values.insert( Meta::valArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); 1392 values.insert( Meta::valAlbum, QVariant( "Once" ) ); 1393 values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); 1394 values.insert( Meta::valTrackNr, QVariant( "2" ) ); 1395 createTrack( values ); 1396 1397 values.insert( Meta::valUniqueId, QVariant( "8fb2396f8d974f6196d2b2ef93ba2551" ) ); 1398 values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/03 Glen Hansard - Broken Hearted Hoover Fixer Sucker Guy.mp3" ) ); 1399 values.insert( Meta::valFormat, QVariant( "1" ) ); 1400 values.insert( Meta::valTitle, QVariant( "Broken Hearted Hoover Fixer Sucker Guy" ) ); 1401 values.insert( Meta::valArtist, QVariant( "Glen Hansard" ) ); 1402 values.insert( Meta::valAlbum, QVariant( "Once" ) ); 1403 values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); 1404 values.insert( Meta::valTrackNr, QVariant( "3" ) ); 1405 createTrack( values ); 1406 1407 values.insert( Meta::valUniqueId, QVariant( "3a211546b91c4bf7a4ec9d41325e5a01" ) ); 1408 values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/04 Glen Hansard & Marketa Irglova - When Your Mind's Made Up.mp3" ) ); 1409 values.insert( Meta::valFormat, QVariant( "1" ) ); 1410 values.insert( Meta::valTitle, QVariant( "When Your Mind's Made Up" ) ); 1411 values.insert( Meta::valArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); 1412 values.insert( Meta::valAlbum, QVariant( "Once" ) ); 1413 values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); 1414 values.insert( Meta::valTrackNr, QVariant( "4" ) ); 1415 createTrack( values ); 1416 1417 values.insert( Meta::valUniqueId, QVariant( "e7a1ed52777c437582a217cd29cc35f7" ) ); 1418 values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/05 Glen Hansard - Lies.mp3" ) ); 1419 values.insert( Meta::valFormat, QVariant( "1" ) ); 1420 values.insert( Meta::valTitle, QVariant( "Lies" ) ); 1421 values.insert( Meta::valArtist, QVariant( "Glen Hansard" ) ); 1422 values.insert( Meta::valAlbum, QVariant( "Once" ) ); 1423 values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); 1424 values.insert( Meta::valTrackNr, QVariant( "5" ) ); 1425 createTrack( values ); 1426 1427 values.insert( Meta::valUniqueId, QVariant( "e0c88a85884d40c899522cd733718d9e" ) ); 1428 values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/06 Interference - Gold.mp3" ) ); 1429 values.insert( Meta::valFormat, QVariant( "1" ) ); 1430 values.insert( Meta::valTitle, QVariant( "Gold" ) ); 1431 values.insert( Meta::valArtist, QVariant( "Interference" ) ); 1432 values.insert( Meta::valAlbum, QVariant( "Once" ) ); 1433 values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); 1434 values.insert( Meta::valTrackNr, QVariant( "6" ) ); 1435 createTrack( values ); 1436 1437 values.insert( Meta::valUniqueId, QVariant( "0969ea6128444e128cfcac95207bd525" ) ); 1438 values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/07 Marketa Irglova - The Hill.mp3" ) ); 1439 values.insert( Meta::valFormat, QVariant( "1" ) ); 1440 values.insert( Meta::valTitle, QVariant( "The Hill" ) ); 1441 values.insert( Meta::valArtist, QVariant( "Markéta Irglová" ) ); 1442 values.insert( Meta::valAlbum, QVariant( "Once" ) ); 1443 values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); 1444 values.insert( Meta::valTrackNr, QVariant( "7" ) ); 1445 createTrack( values ); 1446 1447 values.insert( Meta::valUniqueId, QVariant( "c1d6eff3cb6c42eaa0d63e186ef1b749" ) ); 1448 values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/08 Glen Hansard - Fallen From the Sky.mp3" ) ); 1449 values.insert( Meta::valFormat, QVariant( "1" ) ); 1450 values.insert( Meta::valTitle, QVariant( "Fallen From the Sky" ) ); 1451 values.insert( Meta::valArtist, QVariant( "Glen Hansard" ) ); 1452 values.insert( Meta::valAlbum, QVariant( "Once" ) ); 1453 values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); 1454 values.insert( Meta::valTrackNr, QVariant( "8" ) ); 1455 createTrack( values ); 1456 1457 values.insert( Meta::valUniqueId, QVariant( "b6611dbccd0e49bca8db5dc598b7bf4f" ) ); 1458 values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/09 Glen Hansard - Leave.mp3" ) ); 1459 values.insert( Meta::valFormat, QVariant( "1" ) ); 1460 values.insert( Meta::valTitle, QVariant( "Leave" ) ); 1461 values.insert( Meta::valArtist, QVariant( "Glen Hansard" ) ); 1462 values.insert( Meta::valAlbum, QVariant( "Once" ) ); 1463 values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); 1464 values.insert( Meta::valTrackNr, QVariant( "9" ) ); 1465 createTrack( values ); 1466 1467 values.insert( Meta::valUniqueId, QVariant( "46873076087f48dda553fc5ebd3c0fb6" ) ); 1468 values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/10 Glen Hansard - Trying to Pull Myself Away.mp3" ) ); 1469 values.insert( Meta::valFormat, QVariant( "1" ) ); 1470 values.insert( Meta::valTitle, QVariant( "Trying to Pull Myself Away" ) ); 1471 values.insert( Meta::valArtist, QVariant( "Glen Hansard" ) ); 1472 values.insert( Meta::valAlbum, QVariant( "Once" ) ); 1473 values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); 1474 values.insert( Meta::valTrackNr, QVariant( "10" ) ); 1475 createTrack( values ); 1476 1477 values.insert( Meta::valUniqueId, QVariant( "ea29de7b131c4cf28df177a8cda990ee" ) ); 1478 values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/11 Glen Hansard - All the Way Down.mp3" ) ); 1479 values.insert( Meta::valFormat, QVariant( "1" ) ); 1480 values.insert( Meta::valTitle, QVariant( "All the Way Down" ) ); 1481 values.insert( Meta::valArtist, QVariant( "Glen Hansard" ) ); 1482 values.insert( Meta::valAlbum, QVariant( "Once" ) ); 1483 values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); 1484 values.insert( Meta::valTrackNr, QVariant( "11" ) ); 1485 createTrack( values ); 1486 1487 values.insert( Meta::valUniqueId, QVariant( "66259801d8ba4d50a2dfdf0129bc8792" ) ); 1488 values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/12 Glen Hansard & Marketa Irglova - Once.mp3" ) ); 1489 values.insert( Meta::valFormat, QVariant( "1" ) ); 1490 values.insert( Meta::valTitle, QVariant( "Once" ) ); 1491 values.insert( Meta::valArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); 1492 values.insert( Meta::valAlbum, QVariant( "Once" ) ); 1493 values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); 1494 values.insert( Meta::valTrackNr, QVariant( "12" ) ); 1495 createTrack( values ); 1496 1497 values.insert( Meta::valUniqueId, QVariant( "a654e8c5afb14de7b55b6548ac02f724" ) ); 1498 values.insert( Meta::valUrl, QVariant( "Glen Hansard & Marketa Irglova/Once/13 Glen Hansard - Say It to Me Now.mp3" ) ); 1499 values.insert( Meta::valFormat, QVariant( "1" ) ); 1500 values.insert( Meta::valTitle, QVariant( "Say It to Me Now" ) ); 1501 values.insert( Meta::valArtist, QVariant( "Glen Hansard" ) ); 1502 values.insert( Meta::valAlbum, QVariant( "Once" ) ); 1503 values.insert( Meta::valAlbumArtist, QVariant( "Glen Hansard & Markéta Irglová" ) ); 1504 values.insert( Meta::valTrackNr, QVariant( "13" ) ); 1505 createTrack( values ); 1506 } 1507 1508 void 1509 TestSqlScanManager::createCompilationTrack() 1510 { 1511 Meta::FieldHash values; 1512 1513 values.insert( Meta::valUniqueId, QVariant("c6c29f50279ab9523a0f44928bc1e96b") ); 1514 values.insert( Meta::valUrl, QVariant("Amazon MP3/The Sum Of All Fears (O.S.T.)/The Sum of All Fears/01 - If We Could Remember (O.S.T. LP Version).mp3") ); 1515 values.insert( Meta::valFormat, QVariant("1") ); 1516 values.insert( Meta::valTitle, QVariant("If We Could Remember (O.S.T. LP Version)") ); 1517 values.insert( Meta::valArtist, QVariant("The Sum Of All Fears (O.S.T.)/Yolanda Adams") ); 1518 values.insert( Meta::valAlbumArtist, QVariant("The Sum Of All Fears (O.S.T.)") ); 1519 values.insert( Meta::valAlbum, QVariant("The Sum of All Fears") ); 1520 values.insert( Meta::valComment, QVariant("Amazon.com Song ID: 203452096") ); 1521 values.insert( Meta::valGenre, QVariant("Soundtracks") ); 1522 values.insert( Meta::valYear, QVariant("2002") ); 1523 values.insert( Meta::valTrackNr, QVariant("1") ); 1524 values.insert( Meta::valComposer, QVariant("Jerry Goldsmith") ); 1525 values.insert( Meta::valScore, QVariant("0.875") ); 1526 values.insert( Meta::valPlaycount, QVariant("6") ); 1527 createTrack( values ); 1528 1529 values.clear(); 1530 values.insert( Meta::valUniqueId, QVariant("2188afd457cd75a363905f411966b9a0") ); 1531 values.insert( Meta::valUrl, QVariant("The Cross Of Changes/01 - Second Chapter.mp3") ); 1532 values.insert( Meta::valFormat, QVariant(1) ); 1533 values.insert( Meta::valTitle, QVariant("Second Chapter") ); 1534 values.insert( Meta::valArtist, QVariant("Enigma") ); 1535 values.insert( Meta::valAlbumArtist, QVariant("Enigma") ); 1536 values.insert( Meta::valAlbum, QVariant("The Cross Of Changes") ); 1537 values.insert( Meta::valComment, QVariant("Amazon.com Song ID: 201985325") ); 1538 values.insert( Meta::valGenre, QVariant("Pop") ); 1539 values.insert( Meta::valYear, QVariant(2004) ); 1540 values.insert( Meta::valTrackNr, QVariant(1) ); 1541 values.insert( Meta::valComposer, QVariant("Curly M.C.") ); 1542 values.insert( Meta::valScore, QVariant("0.54") ); 1543 values.insert( Meta::valPlaycount, QVariant("2") ); 1544 1545 values.insert( Meta::valUniqueId, QVariant("637bee4fd456d2ff9eafe65c71ba192e") ); 1546 values.insert( Meta::valUrl, QVariant("The Cross Of Changes/02 - The Eyes Of Truth.mp3") ); 1547 values.insert( Meta::valFormat, QVariant("1") ); 1548 values.insert( Meta::valTitle, QVariant("The Eyes Of Truth") ); 1549 values.insert( Meta::valArtist, QVariant("Enigma") ); 1550 values.insert( Meta::valAlbumArtist, QVariant("Enigma") ); 1551 values.insert( Meta::valAlbum, QVariant("The Cross Of Changes") ); 1552 values.insert( Meta::valComment, QVariant("Amazon.com Song ID: 201985326") ); 1553 values.insert( Meta::valGenre, QVariant("Pop") ); 1554 values.insert( Meta::valYear, QVariant("2004") ); 1555 values.insert( Meta::valTrackNr, QVariant("2") ); 1556 values.insert( Meta::valComposer, QVariant("Curly M.C.") ); 1557 values.insert( Meta::valScore, QVariant("0.928572") ); 1558 values.insert( Meta::valPlaycount, QVariant("1286469632") ); 1559 1560 values.insert( Meta::valUniqueId, QVariant("b4206da4bc0335d76c2bbc5d4c1b164c") ); 1561 values.insert( Meta::valUrl, QVariant("The Cross Of Changes/03 - Return To Innocence.mp3") ); 1562 values.insert( Meta::valFormat, QVariant("1") ); 1563 values.insert( Meta::valTitle, QVariant("Return To Innocence") ); 1564 values.insert( Meta::valArtist, QVariant("Enigma") ); 1565 values.insert( Meta::valAlbumArtist, QVariant("Enigma") ); 1566 values.insert( Meta::valAlbum, QVariant("The Cross Of Changes") ); 1567 values.insert( Meta::valComment, QVariant("Amazon.com Song ID: 201985327") ); 1568 values.insert( Meta::valGenre, QVariant("Pop") ); 1569 values.insert( Meta::valYear, QVariant("2004") ); 1570 values.insert( Meta::valTrackNr, QVariant("3") ); 1571 values.insert( Meta::valComposer, QVariant("Curly M.C.") ); 1572 values.insert( Meta::valScore, QVariant("0.75") ); 1573 values.insert( Meta::valPlaycount, QVariant("1286469888") ); 1574 1575 values.insert( Meta::valUniqueId, QVariant("eb0061602f52d67140fd465dc275fbf2") ); 1576 values.insert( Meta::valUrl, QVariant("The Cross Of Changes/04 - I Love You...I'Ll Kill You.mp3") ); 1577 values.insert( Meta::valFormat, 1 ); 1578 values.insert( Meta::valTitle, QVariant("I Love You...I'Ll Kill You") ); 1579 values.insert( Meta::valArtist, QVariant("Enigma") ); 1580 values.insert( Meta::valAlbumArtist, QVariant("Enigma") ); 1581 values.insert( Meta::valAlbum, QVariant("The Cross Of Changes") ); 1582 values.insert( Meta::valComment, QVariant("Amazon.com Song ID: 201985328") ); 1583 values.insert( Meta::valGenre, QVariant("Pop") ); 1584 values.insert( Meta::valYear, QVariant(2004) ); 1585 values.insert( Meta::valTrackNr, QVariant(4) ); 1586 values.insert( Meta::valComposer, QVariant("Curly M.C.") ); 1587 values.insert( Meta::valScore, QVariant(0.5) ); 1588 values.insert( Meta::valPlaycount, QVariant(1286470656) ); 1589 1590 values.insert( Meta::valUniqueId, QVariant("94dabc09509379646458f62bee7e41ed") ); 1591 values.insert( Meta::valUrl, QVariant("The Cross Of Changes/05 - Silent Warrior.mp3") ); 1592 values.insert( Meta::valFormat, 1 ); 1593 values.insert( Meta::valTitle, QVariant("Silent Warrior") ); 1594 values.insert( Meta::valArtist, QVariant("Enigma") ); 1595 values.insert( Meta::valAlbumArtist, QVariant("Enigma") ); 1596 values.insert( Meta::valAlbum, QVariant("The Cross Of Changes") ); 1597 values.insert( Meta::valComment, QVariant("Amazon.com Song ID: 201985329") ); 1598 values.insert( Meta::valGenre, QVariant("Pop") ); 1599 values.insert( Meta::valYear, QVariant(2004) ); 1600 values.insert( Meta::valTrackNr, QVariant(5) ); 1601 values.insert( Meta::valComposer, QVariant("Curly M.C.") ); 1602 values.insert( Meta::valScore, QVariant(0.96875) ); 1603 values.insert( Meta::valPlaycount, QVariant(6) ); 1604 1605 values.insert( Meta::valUniqueId, QVariant("6ae759476c34256ff1d06f0b5c964d75") ); 1606 values.insert( Meta::valUrl, QVariant("The Cross Of Changes/06 - The Dream Of The Dolphin.mp3") ); 1607 values.insert( Meta::valTitle, QVariant("The Dream Of The Dolphin") ); 1608 values.insert( Meta::valArtist, QVariant("Enigma") ); 1609 values.insert( Meta::valAlbumArtist, QVariant("Enigma") ); 1610 values.insert( Meta::valAlbum, QVariant("The Cross Of Changes") ); 1611 values.insert( Meta::valComment, QVariant("Amazon.com Song ID: 201985330") ); 1612 values.insert( Meta::valGenre, QVariant("Pop") ); 1613 values.insert( Meta::valYear, QVariant("2004") ); 1614 values.insert( Meta::valTrackNr, QVariant(6) ); 1615 values.insert( Meta::valComposer, QVariant("Curly M.C.") ); 1616 values.insert( Meta::valScore, QVariant(0.5) ); 1617 values.insert( Meta::valPlaycount, QVariant(2) ); 1618 1619 values.insert( Meta::valUniqueId, QVariant("7957bc25521c1dc91351d497321c27a6") ); 1620 values.insert( Meta::valUrl, QVariant("Amazon MP3/Ashford & Simpson/Solid/01 - Solid.mp3") ); 1621 values.insert( Meta::valTitle, QVariant("Solid") ); 1622 values.insert( Meta::valArtist, QVariant("Ashford & Simpson") ); 1623 values.insert( Meta::valAlbumArtist, QVariant("Ashford & Simpson") ); 1624 values.insert( Meta::valAlbum, QVariant("Solid") ); 1625 values.insert( Meta::valComment, QVariant("Amazon.com Song ID: 202265871") ); 1626 values.insert( Meta::valGenre, QVariant("Pop") ); 1627 values.insert( Meta::valYear, QVariant(2007) ); 1628 values.insert( Meta::valTrackNr, QVariant(1) ); 1629 values.insert( Meta::valComposer, QVariant("Valerie Simpson") ); 1630 values.insert( Meta::valRating, QVariant(0.898438) ); 1631 values.insert( Meta::valScore, QVariant(0.875) ); 1632 values.insert( Meta::valPlaycount, QVariant(12) ); 1633 } 1634 1635