File indexing completed on 2024-04-21 04:48:06

0001 /***************************************************************************
0002  *   Copyright (c) 2010 Casey Link <unnamedrambler@gmail.com>              *
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 "TestTagGuesser.h"
0021 
0022 #include "dialogs/TagGuesser.h"
0023 #include "MetaValues.h"
0024 
0025 #include <QMap>
0026 #include <QTest>
0027 
0028 
0029 QTEST_GUILESS_MAIN( TestTagGuesser )
0030 
0031 TestTagGuesser::TestTagGuesser()
0032 {
0033 }
0034 
0035 void TestTagGuesser::init()
0036 {
0037   mTagGuesser = new TagGuesser;
0038 }
0039 
0040 void TestTagGuesser::cleanup()
0041 {
0042   delete mTagGuesser;
0043 }
0044 
0045 
0046 void TestTagGuesser::testStandard()
0047 {
0048   mTagGuesser->setFilename( "01 - Artist - Title.mp3" );
0049   mTagGuesser->setSchema( "%track% - %artist% - %title%.%ignore%" );
0050   QVERIFY( mTagGuesser->guess() );
0051 
0052   QMap<qint64,QString> tags = mTagGuesser->tags();
0053   QCOMPARE( tags[Meta::valArtist], QString( "Artist" ) );
0054   QCOMPARE( tags[Meta::valTitle], QString( "Title" ) );
0055   QCOMPARE( tags[Meta::valTrackNr], QString( "01" ) );
0056 }
0057 
0058 void TestTagGuesser::testDotInFilename()
0059 {
0060   // based off bug 225743
0061   // https://bugs.kde.org/show_bug.cgi?id=225743
0062   mTagGuesser->setFilename( "03.Moloko - Sing It back.mp3" );
0063   mTagGuesser->setSchema( "%track%.%artist% - %title%.%ignore%" );
0064   QVERIFY( mTagGuesser->guess() );
0065 
0066   QMap<qint64,QString> tags = mTagGuesser->tags();
0067   QCOMPARE( tags[Meta::valArtist], QString( "Moloko" ) );
0068   QCOMPARE( tags[Meta::valTitle], QString( "Sing It back" ) );
0069   QCOMPARE( tags[Meta::valTrackNr], QString( "03" ) );
0070 }