1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124
|
/****************************************************************************************
* Copyright (c) 2012 Jasneet Singh Bhatti <jazneetbhatti@gmail.com> *
* This program is free software; you can redistribute it and/or modify it under *
* the terms of the GNU General Public License as published by the Free Software *
* Foundation; either version 2 of the License, or (at your option) any later *
* version. *
* *
* This program is distributed in the hope that it will be useful, but WITHOUT ANY *
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A *
* PARTICULAR PURPOSE. See the GNU General Public License for more details. *
* *
* You should have received a copy of the GNU General Public License along with *
* this program. If not, see <http://www.gnu.org/licenses/>. *
****************************************************************************************/
#include "TestMetaAlbumKey.h"
#include "amarokconfig.h"
#include "config-amarok-test.h"
#include "core/meta/Meta.h"
#include "core/meta/support/MetaKeys.h"
#include "core-impl/collections/support/CollectionManager.h"
#include <KLocalizedString>
QTEST_MAIN( TestMetaAlbumKey )
TestMetaAlbumKey::TestMetaAlbumKey()
{
KLocalizedString::setApplicationDomain("amarok-test");
}
TestMetaAlbumKey::~TestMetaAlbumKey()
{
}
void
TestMetaAlbumKey::initTestCase()
{
AmarokConfig::instance(QStringLiteral("amarokrc"));
// Artist Name - Amarok Album Name - Amarok Test Album
m_track1 = CollectionManager::instance()->trackForUrl( QUrl::fromLocalFile(dataPath( QStringLiteral("data/audio/album/Track01.ogg") )) );
// Artist Name - Amarok Album Name - Amarok Test Album 2
m_track2 = CollectionManager::instance()->trackForUrl( QUrl::fromLocalFile(dataPath( QStringLiteral("data/audio/album2/Track01.ogg") )) );
// Artist Name - Amarok 2 Album Name - Amarok Test Album 2
m_track3 = CollectionManager::instance()->trackForUrl( QUrl::fromLocalFile(dataPath( QStringLiteral("data/audio/album2/Track02.ogg") )) );
m_album1 = m_track1->album();
m_album2 = m_track2->album();
m_album3 = m_track3->album();
}
QString
TestMetaAlbumKey::dataPath( const QString &relPath )
{
return QDir::toNativeSeparators( QStringLiteral( AMAROK_TEST_DIR ) + QLatin1Char('/') + relPath );
}
void
TestMetaAlbumKey::testAlbumKey()
{
Meta::AlbumKey albumKey1( m_album1 );
QCOMPARE( albumKey1.m_albumName, m_album1->name() );
QCOMPARE( albumKey1.m_artistName, m_album1->albumArtist()->name() );
}
void
TestMetaAlbumKey::testOperatorAssignment()
{
// For Constructor : AlbumKey( const AlbumPtr &album )
Meta::AlbumKey albumKey1( m_album1 ), albumKey2( m_album2 ), tempAlbumKey;
QVERIFY( !( albumKey1 == albumKey2 ) );
tempAlbumKey = albumKey1;
QCOMPARE( albumKey1, tempAlbumKey );
// For Constructor : AlbumKey( const QString &name, const QString &artistName )
Meta::AlbumKey albumKey3( QStringLiteral("Artist 1"), QStringLiteral("Album 1") ), albumKey4( QStringLiteral("Artist 2"), QStringLiteral("Album 2") );
QVERIFY( !( albumKey1 == albumKey2 ) );
tempAlbumKey = albumKey1;
QCOMPARE( albumKey1, tempAlbumKey );
}
void
TestMetaAlbumKey::testOperatorLessThan()
{
// For Constructor : AlbumKey( const AlbumPtr &album )
Meta::AlbumKey albumKey1( m_album1 ), albumKey2( m_album2 ), albumKey3( m_album3 );
// Same artist name, different album name
QVERIFY( albumKey1 < albumKey2 );
// Same artist name, same album name
QVERIFY( !( albumKey1 < albumKey1 ) );
// Different artist name, same album name
QVERIFY( albumKey2 < albumKey3 );
// Different artist name, different album name
QVERIFY( albumKey1 < albumKey3 );
// For Constructor : AlbumKey( const QString &name, const QString &artistName )
Meta::AlbumKey albumKey4( QStringLiteral("Artist 1"), QStringLiteral("Album 1") ), albumKey5( QStringLiteral("Artist 1"), QStringLiteral("Album 2") ),
albumKey6( QStringLiteral("Artist 2"), QStringLiteral("Album 2") );
// Same artist name, different album name
QVERIFY( albumKey4 < albumKey5 );
// Same artist name, same album name
QVERIFY( !( albumKey4 < albumKey4 ) );
// Different artist name, same album name
QVERIFY( albumKey5 < albumKey6 );
// Different artist name, different album name
QVERIFY( albumKey4 < albumKey6 );
}
|