/***************************************************************************
 * tabsongtest.cpp
 *
 * This file is part of KTabEdit, a KDE tabulature editor
 *
 * copyright (C) 2004-2007 the KTabEdit development team <mrgwen@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.
 *
 * See the file COPYING for more information.
 ***************************************************************************/

#include "tabsongtest.h"

#include <iostream>

#include "src/header.h"

#include "src/tablature/tabbeateffects.h"
#include "src/tablature/tabchord.h"
#include "src/tablature/tabduration.h"

#include "src/tablature/tabbend.h"
#include "src/tablature/tabdynamic.h"

#include "src/tablature/tabgracenotetransition.h"
#include "src/tablature/tabgracenote.h"

#include "src/tablature/tabharmonic.h"
#include "src/tablature/tabslide.h"
#include "src/tablature/tabtrill.h"
#include "src/tablature/tabnoteeffect.h"

#include "src/tablature/tabnote.h"

#include "src/tablature/tabmixtablechanges.h"
#include "src/tablature/tabtimes.h"
#include "src/tablature/tabbarproperties.h"

#include "src/tablature/tabbar.h"

#include "src/tablature/trackmidiproperties.h"
#include "src/tablature/timesignature.h"
#include "src/tablature/trackproperties.h"

#include "src/tablature/tabtrack.h"

#include "src/tablature/songkey.h"
#include "src/tablature/tablyrics.h"
#include "src/tablature/tabproperties.h"

#include "src/tablature/tabsong.h"

void TabSongTest::testCopyTabSong()
{
	TabSong tempSong("TITLE", 120);
	TabTrack* tempTrack = new TabTrack;
	
	tempSong.push_front(tempTrack);
	tempTrack = new TabTrack;
	tempTrack->setMode(DrumTab);
	tempSong.push_front(tempTrack);
	
	TabSong copySong(tempSong);
	
	QCOMPARE( tempSong.size(), copySong.size() );
}

void TabSongTest::testOperatorEqual()
{
	TabSong song1("Hello", 130);
	TabTrack* tempTrack = new TabTrack;
	
	song1.push_front(tempTrack);
	tempTrack = new TabTrack;
	tempTrack->setMode(DrumTab);
	song1.push_front(tempTrack);
	QCOMPARE( song1.title(), QString("Hello") );
	
	TabSong* song2 = new TabSong;
	
	song2->setTitle("Hello");
	QCOMPARE( song2->title(), QString("Hello") );
	
	song1.setTitle("HeyJoe");
	(*song2) = song1;
	QCOMPARE( song2->title(), QString("HeyJoe") );
	delete song2;
	
	TabSong song3(song1);
	QCOMPARE( song3.title(), QString("HeyJoe") );
}

void TabSongTest::testPushFront()
{
	TabSong tempSong("TITLE", 120);
	TabTrack* tempTrack = new TabTrack;
	
	tempSong.push_front(tempTrack);
	QCOMPARE( tempSong.front(), tempTrack );
	QCOMPARE( tempSong.size(), 1 );
	
	try {
		tempSong.push_front(0x0);
	} catch(const std::exception& e) {
	}
	
	QCOMPARE( tempSong.front(), tempTrack );
	QCOMPARE( tempSong.size(), 1 );
}

void TabSongTest::testAt()
{
	TabSong tempSong("TITLE", 120);
	TabTrack* tempTrack = new TabTrack;
	TabTrack* nullTrack;
	
	tempSong.push_front(tempTrack);
	QCOMPARE( tempSong.at(0), tempTrack );
	
	try {
		nullTrack = tempSong.at(1);
	} catch (const std::exception& e) {
		nullTrack = 0x0;
	}
	
	QCOMPARE( nullTrack, static_cast<TabTrack*>(0x0) );
}

void TabSongTest::testDrumTrack()
{
	TabSong tempSong("TITLE", 120);
	TabTrack* tempTrack = new TabTrack;
	
	tempSong.push_front(tempTrack);
	tempTrack = new TabTrack;
	tempTrack->setMode(DrumTab);
	tempSong.push_front(tempTrack);
	
	QCOMPARE( tempSong.isDrumTrack(), true );
	QCOMPARE( tempSong.drumTrack(), 1 );
}

QTEST_MAIN(TabSongTest)
#include "tabsongtest.moc"
