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, 2013 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 #ifndef TESTSQLSCANMANAGER_H 0019 #define TESTSQLSCANMANAGER_H 0020 0021 #include <QSharedPointer> 0022 #include <QTest> 0023 0024 #include "core/meta/support/MetaConstants.h" 0025 0026 #include <QTemporaryDir> 0027 0028 class MySqlEmbeddedStorage; 0029 class GenericScanManager; 0030 0031 class QIODevice; 0032 0033 namespace Collections { 0034 class SqlCollection; 0035 } 0036 0037 /** Test the ScanManager, the SqlScanResultProcessor and the amarokcollectionscanner itself. 0038 Note: currently this test is using the installed amarokcollectionscanner and not 0039 the one from util/collectionscanner. 0040 */ 0041 class TestSqlScanManager : public QObject 0042 { 0043 Q_OBJECT 0044 public: 0045 TestSqlScanManager(); 0046 0047 Q_SIGNALS: 0048 void scanManagerResult(); 0049 0050 private Q_SLOTS: 0051 void initTestCase(); 0052 void cleanupTestCase(); 0053 0054 void init(); 0055 void cleanup(); 0056 /** 0057 * Check that a single insert really inserts all the information 0058 */ 0059 void testScanSingle(); 0060 0061 /** 0062 * Check that fully scanning a directory works 0063 */ 0064 void testScanDirectory(); 0065 0066 /** 0067 * Check that duplicate uids are handled correctly 0068 */ 0069 void testDuplicateUid(); 0070 0071 /** 0072 * Check that very long uids don't produce wrong sql queries 0073 */ 0074 void testLongUid(); 0075 0076 0077 /** 0078 * Check that detecting compilations works 0079 * Test also compilation/no compilation tags 0080 */ 0081 void testCompilation(); 0082 0083 /** 0084 * Check that a blocked scan really does nothing. 0085 */ 0086 void testBlock(); 0087 0088 /** 0089 * Test adding a whole directory (incremental scan) 0090 */ 0091 void testAddDirectory(); 0092 0093 /** 0094 * Test rescanning and detecting a removed directory (incremental) 0095 */ 0096 void testRemoveDir(); 0097 0098 /** 0099 * Test rescanning and detecting a removed track (incremental) 0100 * Will also check that the statistics are not deleted. 0101 */ 0102 void testRemoveTrack(); 0103 0104 /** 0105 * Test rescanning and detecting a moved track or directory 0106 */ 0107 void testMove(); 0108 0109 /** 0110 * Test "feat" artist and albums 0111 */ 0112 void testFeat(); 0113 0114 /** 0115 * Test images 0116 */ 0117 void testAlbumImage(); 0118 0119 /** 0120 * Test merging of the result with an incremental scan. 0121 * New files should be added to existing albums. 0122 * Existing files should be merged. 0123 */ 0124 void testMerges(); 0125 0126 void testLargeInsert(); 0127 0128 void testIdentifyCompilationInMultipleDirectories(); 0129 0130 void testUidChangeMoveDirectoryIncrementalScan(); 0131 0132 /** Test that Amarok respects the album artist from the tags. 0133 * (BR: 216759) 0134 */ 0135 void testAlbumArtistMerges(); 0136 0137 /** Test that two tracks getting their filename exchanged are still 0138 * handled correctly, ratings and all (BR: 272802) 0139 */ 0140 void testCrossRenaming(); 0141 0142 void slotCollectionUpdated(); 0143 0144 private: 0145 void fullScanAndWait(); 0146 void incrementalScanAndWait(); 0147 void importAndWait( QIODevice* import ); 0148 0149 void waitScannerFinished(); 0150 0151 /** 0152 Creates a track in the m_tmpCollectionDir with the given values. 0153 Meta::valUrl gives the relative path to the target track. 0154 */ 0155 void createTrack( const Meta::FieldHash &values ); 0156 void createSingleTrack(); 0157 0158 /** Creates a default album. 0159 Meaning that album artist tag is not set, all songs are in one directory and the artist is the same for all the tracks. 0160 */ 0161 void createAlbum(); 0162 void createCompilation(); 0163 void createCompilationTrack(); 0164 0165 /** 0166 * Album that looks alike compilation: various track's artists 0167 * but single album artist and no compilation flag. 0168 */ 0169 void createCompilationLookAlikeAlbum(); 0170 0171 int m_collectionUpdatedCount; 0172 0173 QSharedPointer<MySqlEmbeddedStorage> m_storage; 0174 QTemporaryDir *m_tmpDatabaseDir; 0175 QTemporaryDir *m_tmpCollectionDir; 0176 QString m_sourcePath; // the path to the template .mp3 file 0177 bool m_autoGetCoverArt; 0178 0179 Collections::SqlCollection *m_collection; 0180 GenericScanManager *m_scanManager; 0181 }; 0182 0183 #endif // TESTSQLSCANMANAGER_H