/***************************************************************************
 * 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 "trackpageviewtest.h"

#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"
#include "src/tablature/trackpos.h"

#include "src/track/trackpageview.h"
#include "src/track/trackpagelist.h"

const uint TrackPageViewTest::sDpi = 72;
const Cm TrackPageViewTest::sMargins = Cm(1.00, sDpi);
const QSizeCm TrackPageViewTest::sPageSize = QSizeCm(Cm(21.0, sDpi), Cm(29.7, sDpi));

void TrackPageViewTest::testSongProperties()
{
	TrackPageView pageView(sDpi);
	TabProperties* properties = new TabProperties;
	
	properties->setTitle("Pruple Haze");
	properties->setArtist("Jimi Hendrix");

	pageView.setSongProperties(properties);
	QCOMPARE( pageView.songProperties(), properties );
}

void TrackPageViewTest::testPageSize()
{
	TrackPageView pageView(sDpi);
	
	pageView.setPageSize(sPageSize);
	QCOMPARE( pageView.pageSize(), sPageSize );
}

void TrackPageViewTest::testMargins()
{
	TrackPageView pageView(sDpi);
	
	pageView.setLeftMargins(sMargins);
	QCOMPARE( pageView.leftMargins(), sMargins );
	
	pageView.setTopMargins(sMargins);
	QCOMPARE( pageView.topMargins(), sMargins );
	
	try {
		pageView.setLeftMargins(Cm(-1, sDpi));
	} catch (const ktabedit::ContractException& e) {
	}
	QCOMPARE( pageView.leftMargins(), sMargins );
	
	try {
		pageView.setTopMargins(Cm(-1, sDpi));
	} catch (const ktabedit::ContractException& e) {
	}
	QCOMPARE( pageView.topMargins(), sMargins );
}

QTEST_MAIN(TrackPageViewTest)
#include "trackpageviewtest.moc"
