1 /**************************************************************************************** 2 * Copyright (c) 2009 Maximilian Kossick <maximilian.kossick@googlemail.com> * 3 * Copyright (c) 2010-2013 Ralf Engels <ralf-engels@gmx.de> * 4 * * 5 * This program is free software; you can redistribute it and/or modify it under * 6 * the terms of the GNU General Public License as published by the Free Software * 7 * Foundation; either version 2 of the License, or (at your option) any later * 8 * version. * 9 * * 10 * This program is distributed in the hope that it will be useful, but WITHOUT ANY * 11 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 12 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 13 * * 14 * You should have received a copy of the GNU General Public License along with * 15 * this program. If not, see <http://www.gnu.org/licenses/>. * 16 ****************************************************************************************/ 17 18 #ifndef TESTGENERICSCANMANAGER_H 19 #define TESTGENERICSCANMANAGER_H 20 21 #include "scanner/GenericScanManager.h" 22 #include "core/meta/support/MetaConstants.h" 23 24 #include <QSignalSpy> 25 #include <QTemporaryDir> 26 27 #include <QTest> 28 29 /** Test the GenericScanManager and the scanner job 30 */ 31 class TestGenericScanManager : public QObject 32 { 33 Q_OBJECT 34 35 public: 36 TestGenericScanManager(); 37 38 private Q_SLOTS: 39 void initTestCase(); 40 void cleanupTestCase(); 41 42 void init(); 43 void cleanup(); 44 45 /** 46 * Check that a single insert really inserts all the information 47 */ 48 void testScanSingle(); 49 50 /** 51 * Check that fully scanning a directory works 52 */ 53 void testScanDirectory(); 54 55 /** 56 * Check that the scanner continues if crashed 57 */ 58 void testRestartScanner(); 59 60 /** 61 * Test images 62 */ 63 void testAlbumImage(); 64 65 66 public Q_SLOTS: 67 void slotStarted( GenericScanManager::ScanType type ); 68 void slotDirectoryCount( int count ); 69 void slotDirectoryScanned( QSharedPointer<CollectionScanner::Directory> dir ); 70 void slotSucceeded(); 71 void slotFailed( const QString& message ); 72 73 private: 74 void fullScanAndWait(); 75 void waitScannerFinished( QSignalSpy &spy ); 76 77 /** 78 Creates a track in the m_tmpCollectionDir with the given values. 79 Meta::valUrl gives the relative path to the target track. 80 */ 81 void createTrack( const Meta::FieldHash &values ); 82 void createSingleTrack(); 83 void createAlbum(); 84 85 bool m_started; 86 bool m_finished; 87 88 int m_scannedDirsCount; 89 int m_scannedTracksCount; 90 int m_scannedCoversCount; 91 92 QTemporaryDir *m_tmpCollectionDir; 93 QString m_sourcePath; // the path to the template .mp3 file 94 95 GenericScanManager *m_scanManager; 96 }; 97 98 #endif // TESTGENERICSCANMANAGER_H 99