File indexing completed on 2024-05-05 04:49:47

0001 /***************************************************************************
0002  *   Copyright (c) 2009 Sven Krohlas <sven@asbest-online.de>               *
0003  *                                                                         *
0004  *   This program is free software; you can redistribute it and/or modify  *
0005  *   it under the terms of the GNU General Public License as published by  *
0006  *   the Free Software Foundation; either version 2 of the License, or     *
0007  *   (at your option) any later version.                                   *
0008  *                                                                         *
0009  *   This program is distributed in the hope that it will be useful,       *
0010  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
0011  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
0012  *   GNU General Public License for more details.                          *
0013  *                                                                         *
0014  *   You should have received a copy of the GNU General Public License     *
0015  *   along with this program; if not, write to the                         *
0016  *   Free Software Foundation, Inc.,                                       *
0017  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.         *
0018  ***************************************************************************/
0019 
0020 #include "TestTimecodeTrackProvider.h"
0021 
0022 #include "config-amarok-test.h"
0023 #include "core/meta/Meta.h"
0024 #include "core-impl/meta/timecode/TimecodeTrackProvider.h"
0025 
0026 #include <QTest>
0027 
0028 QTEST_GUILESS_MAIN( TestTimecodeTrackProvider )
0029 
0030 TestTimecodeTrackProvider::TestTimecodeTrackProvider()
0031 {}
0032 
0033 void TestTimecodeTrackProvider::initTestCase()
0034 {
0035     m_testProvider = new TimecodeTrackProvider();
0036 }
0037 
0038 void TestTimecodeTrackProvider::cleanupTestCase()
0039 {
0040     delete m_testProvider;
0041 }
0042 
0043 QString
0044 TestTimecodeTrackProvider::dataPath( const QString &relPath )
0045 {
0046     return QDir::toNativeSeparators( QString( AMAROK_TEST_DIR ) + '/' + relPath );
0047 }
0048 
0049 void TestTimecodeTrackProvider::testPossiblyContainsTrack()
0050 {
0051     QVERIFY( !m_testProvider->possiblyContainsTrack( QUrl("file:///home/test/test.mp3") ) );
0052     QVERIFY( m_testProvider->possiblyContainsTrack( QUrl("file:///home/test/test.mp3:0-23") ) );
0053     QVERIFY( m_testProvider->possiblyContainsTrack( QUrl("file:///home/test/test.mp3:23-42") ) );
0054     QVERIFY( m_testProvider->possiblyContainsTrack( QUrl("file:///home/test/test.mp3:42-23") ) );
0055     QVERIFY( !m_testProvider->possiblyContainsTrack( QUrl("file:///home/test/test.mp3:-12-42") ) );
0056 }
0057 
0058 void TestTimecodeTrackProvider::testTrackForUrl()
0059 {
0060     QUrl testUrl;
0061     testUrl = QUrl::fromLocalFile(dataPath( "data/audio/album/" ));
0062     testUrl = testUrl.adjusted(QUrl::StripTrailingSlash);
0063     testUrl.setPath(testUrl.path() + '/' + ( "Track01.ogg:23-42" ));
0064 
0065     Meta::TrackPtr resultTrack = m_testProvider->trackForUrl( testUrl );
0066 
0067     QVERIFY( resultTrack );
0068 
0069     QCOMPARE( resultTrack->playableUrl().path(), dataPath( "data/audio/album/Track01.ogg" ) );
0070 }