Commit e87bc5dcad0c41bb4c8b94de75e5bd06af9494e4
- Diff rendering mode:
- inline
- side by side
src/App.cpp
(2 / 0)
|   | |||
| 90 | 90 | #ifdef DEBUG | |
| 91 | 91 | #include "TestAmarok.h" | |
| 92 | 92 | #include "TestCaseConverter.h" | |
| 93 | #include "TestDirectoryLoader.h" | ||
| 93 | 94 | #include "TestPlaylistManager.h" | |
| 94 | 95 | #include "TestSmartPointerList.h" | |
| 95 | 96 | #endif // DEBUG | |
| … | … | ||
| 586 | 586 | PERF_LOG( "Running Unit Tests" ) | |
| 587 | 587 | TestAmarok testAmarok ( testArgumentList ); | |
| 588 | 588 | TestCaseConverter testCaseConverter ( testArgumentList ); | |
| 589 | TestDirectoryLoader testDirectoryLoader ( testArgumentList ); | ||
| 589 | 590 | TestPlaylistManager testPlaylistManager ( testArgumentList ); | |
| 590 | 591 | TestSmartPointerList testSmartPointerList( testArgumentList ); | |
| 591 | 592 |
src/CMakeLists.txt
(1 / 0)
|   | |||
| 568 | 568 | ../tests/playlistmanager/TestPlaylistManager.cpp | |
| 569 | 569 | ../tests/TestAmarok.cpp | |
| 570 | 570 | ../tests/TestCaseConverter.cpp | |
| 571 | ../tests/TestDirectoryLoader.cpp | ||
| 571 | 572 | ../tests/TestSmartPointerList.cpp | |
| 572 | 573 | ) | |
| 573 | 574 |
src/DirectoryLoader.h
(3 / 4)
|   | |||
| 42 | 42 | DirectoryLoader(); | |
| 43 | 43 | ~DirectoryLoader(); | |
| 44 | 44 | ||
| 45 | void insertAtRow( int row ); //!call before init. Will insert the completed | ||
| 46 | // | ||
| 45 | void insertAtRow( int row ); // call before init to tell the loader the row to start inserting tracks | ||
| 47 | 46 | void init( const QList<KUrl>& urls ); //!list all | |
| 48 | 47 | void init( const QList<QUrl>& urls ); //!convience | |
| 49 | 48 | ||
| … | … | ||
| 51 | 51 | ||
| 52 | 52 | private slots: | |
| 53 | 53 | void directoryListResults( KIO::Job *job, const KIO::UDSEntryList &list ); | |
| 54 | void listJobFinished(KJob*); | ||
| 54 | void listJobFinished( KJob* ); | ||
| 55 | 55 | void doInsertAtRow(); | |
| 56 | 56 | ||
| 57 | 57 | private: | |
| 58 | 58 | void finishUrlList(); | |
| 59 | static bool directorySensitiveLessThan( const KFileItem& item1, const KFileItem& item2); | ||
| 59 | static bool directorySensitiveLessThan( const KFileItem& item1, const KFileItem& item2 ); | ||
| 60 | 60 | /** | |
| 61 | 61 | * the number of directory list operations. this is used so that | |
| 62 | 62 | * the last directory operations knows its the last */ |
tests/CMakeLists.txt
(1 / 0)
|   | |||
| 8 | 8 | ||
| 9 | 9 | QT4_AUTOMOC( TestAmarok.cpp ) | |
| 10 | 10 | QT4_AUTOMOC( TestCaseConverter.cpp ) | |
| 11 | QT4_AUTOMOC( TestDirectoryLoader.cpp ) | ||
| 11 | 12 | QT4_AUTOMOC( TestSmartPointerList.cpp ) | |
| 12 | 13 | ||
| 13 | 14 | add_subdirectory( data ) |
tests/TestDirectoryLoader.cpp
(67 / 0)
|   | |||
| 1 | /*************************************************************************** | ||
| 2 | * Copyright (c) 2009 Sven Krohlas <sven@getamarok.com> * | ||
| 3 | * * | ||
| 4 | * This program is free software; you can redistribute it and/or modify * | ||
| 5 | * it under the terms of the GNU General Public License as published by * | ||
| 6 | * the Free Software Foundation; either version 2 of the License, or * | ||
| 7 | * (at your option) any later version. * | ||
| 8 | * * | ||
| 9 | * This program is distributed in the hope that it will be useful, * | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
| 12 | * GNU General Public License for more details. * | ||
| 13 | * * | ||
| 14 | * You should have received a copy of the GNU General Public License * | ||
| 15 | * along with this program; if not, write to the * | ||
| 16 | * Free Software Foundation, Inc., * | ||
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * | ||
| 18 | ***************************************************************************/ | ||
| 19 | |||
| 20 | #include "DirectoryLoader.h" | ||
| 21 | #include "TestDirectoryLoader.h" | ||
| 22 | |||
| 23 | #include "playlist/PlaylistController.h" | ||
| 24 | #include "playlist/PlaylistModel.h" | ||
| 25 | |||
| 26 | #include <KStandardDirs> | ||
| 27 | |||
| 28 | /* This one is a bit ugly, as the results of the methods in DirectoryLoader can't * | ||
| 29 | * be checked directly there but only in the playlist. */ | ||
| 30 | |||
| 31 | TestDirectoryLoader::TestDirectoryLoader( QStringList testArgumentList ) | ||
| 32 | { | ||
| 33 | testArgumentList.replace( 2, testArgumentList.at( 2 ) + "DirectoryLoader.log" ); | ||
| 34 | QTest::qExec( this, testArgumentList ); | ||
| 35 | } | ||
| 36 | |||
| 37 | void TestDirectoryLoader::initTestCase() | ||
| 38 | { | ||
| 39 | The::playlistController()->clear(); // we need a clear playlist for those tests | ||
| 40 | |||
| 41 | DirectoryLoader *loader1 = new DirectoryLoader; | ||
| 42 | DirectoryLoader *loader2 = new DirectoryLoader; | ||
| 43 | QList<QUrl> testList; | ||
| 44 | QUrl testUrl; | ||
| 45 | |||
| 46 | testUrl = QUrl::fromLocalFile( KStandardDirs::installPath( "data" ) + "amarok/testdata/audio/" ); | ||
| 47 | testList.append( testUrl ); | ||
| 48 | |||
| 49 | loader1->insertAtRow( 1 ); // TODO: negative values always seem to append at the beginning. is that correct? | ||
| 50 | loader1->init( testList ); | ||
| 51 | // wait until finished... HOW? might only work with --nofork? | ||
| 52 | loader2->insertAtRow( 4 ); | ||
| 53 | loader2->init( testList ); | ||
| 54 | // here we should wait again | ||
| 55 | } | ||
| 56 | |||
| 57 | void TestDirectoryLoader::testInitAndInsertAtRow() | ||
| 58 | { | ||
| 59 | /* more uglyness: we test both methods at once... I don't see another way */ | ||
| 60 | QCOMPARE( The::playlistModel()->rowCount(), 20 ); | ||
| 61 | |||
| 62 | QCOMPARE( The::playlistModel()->trackAt( 1 )->prettyName(), QString( "" ) ); // TODO | ||
| 63 | QCOMPARE( The::playlistModel()->trackAt( 4 )->prettyName(), QString( "" ) ); | ||
| 64 | QCOMPARE( The::playlistModel()->trackAt( 5 )->prettyName(), QString( "" ) ); | ||
| 65 | QCOMPARE( The::playlistModel()->trackAt( 14 )->prettyName(), QString( "" ) ); | ||
| 66 | QCOMPARE( The::playlistModel()->trackAt( 20 )->prettyName(), QString( "" ) ); | ||
| 67 | } |
tests/TestDirectoryLoader.h
(37 / 0)
|   | |||
| 1 | /*************************************************************************** | ||
| 2 | * Copyright (c) 2009 Sven Krohlas <sven@getamarok.com> * | ||
| 3 | * * | ||
| 4 | * This program is free software; you can redistribute it and/or modify * | ||
| 5 | * it under the terms of the GNU General Public License as published by * | ||
| 6 | * the Free Software Foundation; either version 2 of the License, or * | ||
| 7 | * (at your option) any later version. * | ||
| 8 | * * | ||
| 9 | * This program is distributed in the hope that it will be useful, * | ||
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of * | ||
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | ||
| 12 | * GNU General Public License for more details. * | ||
| 13 | * * | ||
| 14 | * You should have received a copy of the GNU General Public License * | ||
| 15 | * along with this program; if not, write to the * | ||
| 16 | * Free Software Foundation, Inc., * | ||
| 17 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * | ||
| 18 | ***************************************************************************/ | ||
| 19 | |||
| 20 | #ifndef TESTDIRECTORYLOADER_H | ||
| 21 | #define TESTDIRECTORYLOADER_H | ||
| 22 | |||
| 23 | #include <QtTest> | ||
| 24 | |||
| 25 | class TestDirectoryLoader : public QObject | ||
| 26 | { | ||
| 27 | Q_OBJECT | ||
| 28 | |||
| 29 | public: | ||
| 30 | TestDirectoryLoader( QStringList testArgumentList ); | ||
| 31 | |||
| 32 | private slots: | ||
| 33 | void initTestCase(); | ||
| 34 | void testInitAndInsertAtRow(); | ||
| 35 | }; | ||
| 36 | |||
| 37 | #endif // TESTDIRECTORYLOADER_H |
tests/data/CMakeLists.txt
(1 / 0)
|   | |||
| 1 | add_subdirectory( audio ) | ||
| 1 | 2 | add_subdirectory( playlists ) |
tests/data/audio/CMakeLists.txt
(14 / 0)
|   | |||
| 1 | install( | ||
| 2 | FILES | ||
| 3 | Platz\ 01.mp3 | ||
| 4 | Platz\ 02.mp3 | ||
| 5 | Platz\ 03.mp3 | ||
| 6 | Platz\ 04.mp3 | ||
| 7 | Platz\ 05.mp3 | ||
| 8 | Platz\ 06.mp3 | ||
| 9 | Platz\ 07.mp3 | ||
| 10 | Platz\ 08.mp3 | ||
| 11 | Platz\ 09.mp3 | ||
| 12 | Platz\ 10.mp3 | ||
| 13 | DESTINATION ${DATA_INSTALL_DIR}/amarok/testdata/audio | ||
| 14 | ) |
tests/data/audio/Platz 01.mp3
(1441 / 0)
Binary files differ
tests/data/audio/Platz 02.mp3
(1267 / 0)
Binary files differ
tests/data/audio/Platz 03.mp3
(1419 / 0)
Binary files differ
tests/data/audio/Platz 04.mp3
(1956 / 0)
Binary files differ
tests/data/audio/Platz 05.mp3
(1223 / 0)
Binary files differ
tests/data/audio/Platz 06.mp3
(1751 / 0)
Binary files differ
tests/data/audio/Platz 07.mp3
(1744 / 0)
Binary files differ
tests/data/audio/Platz 08.mp3
(1890 / 0)
Binary files differ
tests/data/audio/Platz 09.mp3
(1906 / 0)
Binary files differ
tests/data/audio/Platz 10.mp3
(1949 / 0)
Binary files differ

