Commit e87bc5dcad0c41bb4c8b94de75e5bd06af9494e4

Tests for DirectoryLoader, but non functional: how to wait for a signal to appear in a test slot?
The test audio files are the jingles from the Free Music Charts show, licensed under http://creativecommons.org/licenses/by-nc-sa/3.0/de/
  
9090#ifdef DEBUG
9191#include "TestAmarok.h"
9292#include "TestCaseConverter.h"
93#include "TestDirectoryLoader.h"
9394#include "TestPlaylistManager.h"
9495#include "TestSmartPointerList.h"
9596#endif // DEBUG
586586 PERF_LOG( "Running Unit Tests" )
587587 TestAmarok testAmarok ( testArgumentList );
588588 TestCaseConverter testCaseConverter ( testArgumentList );
589 TestDirectoryLoader testDirectoryLoader ( testArgumentList );
589590 TestPlaylistManager testPlaylistManager ( testArgumentList );
590591 TestSmartPointerList testSmartPointerList( testArgumentList );
591592
  
568568 ../tests/playlistmanager/TestPlaylistManager.cpp
569569 ../tests/TestAmarok.cpp
570570 ../tests/TestCaseConverter.cpp
571 ../tests/TestDirectoryLoader.cpp
571572 ../tests/TestSmartPointerList.cpp
572573)
573574
  
4242 DirectoryLoader();
4343 ~DirectoryLoader();
4444
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
4746 void init( const QList<KUrl>& urls ); //!list all
4847 void init( const QList<QUrl>& urls ); //!convience
4948
5151
5252 private slots:
5353 void directoryListResults( KIO::Job *job, const KIO::UDSEntryList &list );
54 void listJobFinished(KJob*);
54 void listJobFinished( KJob* );
5555 void doInsertAtRow();
5656
5757 private:
5858 void finishUrlList();
59 static bool directorySensitiveLessThan( const KFileItem& item1, const KFileItem& item2);
59 static bool directorySensitiveLessThan( const KFileItem& item1, const KFileItem& item2 );
6060 /**
6161 * the number of directory list operations. this is used so that
6262 * the last directory operations knows its the last */
  
88
99QT4_AUTOMOC( TestAmarok.cpp )
1010QT4_AUTOMOC( TestCaseConverter.cpp )
11QT4_AUTOMOC( TestDirectoryLoader.cpp )
1112QT4_AUTOMOC( TestSmartPointerList.cpp )
1213
1314add_subdirectory( data )
  
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
31TestDirectoryLoader::TestDirectoryLoader( QStringList testArgumentList )
32{
33 testArgumentList.replace( 2, testArgumentList.at( 2 ) + "DirectoryLoader.log" );
34 QTest::qExec( this, testArgumentList );
35}
36
37void 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
57void 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}
  
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
25class TestDirectoryLoader : public QObject
26{
27Q_OBJECT
28
29public:
30 TestDirectoryLoader( QStringList testArgumentList );
31
32private slots:
33 void initTestCase();
34 void testInitAndInsertAtRow();
35};
36
37#endif // TESTDIRECTORYLOADER_H
  
1add_subdirectory( audio )
12add_subdirectory( playlists )
  
1install(
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)
Binary files differ
Binary files differ
Binary files differ
Binary files differ
Binary files differ
Binary files differ
Binary files differ
Binary files differ
Binary files differ
Binary files differ