/***************************************************************************
 * tabnoteeffecttest.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 "tabnoteeffect.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/tabnoteeffect.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 TabNoteEffectTest::testAccentuated()
{
	TabNoteEffect effect;
	QCOMPARE( effect.isAccentuated(), false );
	
	effect.setAccentuated(true);
	QCOMPARE( effect.isAccentuated(), true );
}

void TabNoteEffectTest::testGhostNote()
{
	TabNoteEffect effect;
	QCOMPARE( effect.isGhostNote(), false );
	
	effect.setGhostNote(true);
	QCOMPARE( effect.isGhostNote(), true );
}

void TabNoteEffectTest::testTieNote()
{
	TabNoteEffect effect;
	QCOMPARE( effect.isTieNote(), false );
	
	effect.setTieNote(true);
	QCOMPARE( effect.isTieNote(), true );
}

void TabNoteEffectTest::testHammerOnPullOff()
{
	TabNoteEffect effect;
	QCOMPARE( effect.isHammerOnPullOff(), false );
	
	effect.setHammerOnPullOff(true);
	QCOMPARE( effect.isHammerOnPullOff(), true );
}

void TabNoteEffectTest::testSlide()
{
	TabNoteEffect effect;
	QCOMPARE( effect.isSlide(), false );
	QCOMPARE( effect.slide(), NoneSlide );
	
	effect.setSlide(true);
	QCOMPARE( effect.isSlide(), true );
	QCOMPARE( effect.slide(), ShiftSlide );
	
	effect.setSlide(false);
	QCOMPARE( effect.isSlide(), false );
	QCOMPARE( effect.slide(), NoneSlide );
	
	effect.setSlide(ShiftSlide);
	QCOMPARE( effect.isSlide(), true );
	QCOMPARE( effect.slide(), ShiftSlide );
}

void TabNoteEffectTest::testLetRing()
{
	TabNoteEffect effect;
	QCOMPARE( effect.isLetRing(), false );
	
	effect.setLetRing(true);
	QCOMPARE( effect.isLetRing(), true );
}

void TabNoteEffectTest::testDynamic()
{
	TabNoteEffect effect;
	QCOMPARE( effect.dynamic(), NoneDynamic );
	
	effect.setDynamic(PianoPianissimo);
	QCOMPARE( effect.dynamic(), PianoPianissimo );
}

void TabNoteEffectTest::testFingeringLeft()
{
	TabNoteEffect effect;
	QCOMPARE( effect.fingeringLeft(), NoneFingering );
	
	effect.setFingeringLeft(Thumb);
	QCOMPARE( effect.fingeringLeft(), Thumb );
}

void TabNoteEffectTest::testFingeringRight()
{
	TabNoteEffect effect;
	QCOMPARE( effect.fingeringRight(), NoneFingering );
	
	effect.setFingeringRight(Thumb);
	QCOMPARE( effect.fingeringRight(), Thumb );
}

void TabNoteEffectTest::testLeftHandVibrato()
{
	TabNoteEffect effect;
	QCOMPARE( effect.isLeftHandVibrato(), false );
	
	effect.setLeftHandVibrato(true);
	QCOMPARE( effect.isLeftHandVibrato(), true );
}

void TabNoteEffectTest::testPalmMute()
{
	TabNoteEffect effect;
	QCOMPARE( effect.isPalmMute(), false );
	
	effect.setPalmMute(true);
	QCOMPARE( effect.isPalmMute(), true );
}

void TabNoteEffectTest::testStaccato()
{
	TabNoteEffect effect;
	QCOMPARE( effect.isStaccato(), false );
	
	effect.setStaccato(true);
	QCOMPARE( effect.isStaccato(), true );
}

void TabNoteEffectTest::testTremoloPicking()
{
	TabNoteEffect effect;
	QCOMPARE( effect.tremoloPicking(), (char)0 );
	
	effect.setTremoloPicking(5);
	QCOMPARE( effect.tremoloPicking(), (char)5 );
}

void TabNoteEffectTest::testHarmonic()
{
	TabNoteEffect effect;
	QCOMPARE( effect.harmonic(), NoneHarmonic );
	
	effect.setHarmonic(Natural);
	QCOMPARE( effect.harmonic(), Natural );
}

void TabNoteEffectTest::testGraceNote()
{
	TabNoteEffect effect;
	TabGraceNote* grace = new TabGraceNote;
	QCOMPARE( *effect.graceNote(), TabGraceNote() );
	
	grace->setGraceNoteDuration(500);
	effect.setGraceNote(grace);
	QCOMPARE( effect.graceNote(), grace );
	
	effect.setGraceNoteDuration(1000);
	QCOMPARE( effect.graceNoteDuration(), 1000 );
	
	effect.setGraceNoteDynamic(MezzoPiano);
	QCOMPARE( effect.graceNoteDynamic(), MezzoPiano );
	
	effect.setGraceNoteFret(5);
	QCOMPARE( effect.graceNoteFret(), 5 );
	
	effect.setGraceNoteTransition(HammerTransition);
	QCOMPARE( effect.graceNoteTransition(), HammerTransition );
}

void TabNoteEffectTest::testBend()
{
	TabNoteEffect effect;
	TabBend* bend = new TabBend;
	QCOMPARE( *effect.bend(), TabBend() );
	
	bend->setBendValue(50);
	effect.setBend(bend);
	QCOMPARE( effect.bend(), bend );
	
	effect.setBendType(TabBend::Bend);
	QCOMPARE( effect.bendType(), TabBend::Bend );
	
	effect.setBendValue(25);
	QCOMPARE( effect.bendValue(), (int)25 );
	QCOMPARE( effect.bendValueToString(), QString("1/4") );
	
	QList<TabBendPoint> list;
	list.push_front(TabBendPoint());
	list.push_front(TabBendPoint());
	list.push_front(TabBendPoint());
	effect.setBendPoint(list);
	QCOMPARE( effect.bendPoint(), list );
}

void TabNoteEffectTest::testTrill()
{
	TabNoteEffect effect;
	TabTrill* trill = new TabTrill;
	QCOMPARE( *effect.trill(), TabTrill() );
	
	trill->setFretTrill(5);
	effect.setTrill(trill);
	QCOMPARE( effect.trill(), trill );
	
	effect.setFretTrill(10);
	QCOMPARE( effect.fretTrill(), (char)10 );
	
	effect.setPeriod(15);
	QCOMPARE( effect.period(), (char)15 );
}

void TabNoteEffectTest::testOperators()
{
	TabNoteEffect effect1;
	TabNoteEffect effect2;
	QCOMPARE( effect1 == effect2, true );
	QCOMPARE( effect1 != effect2, false );
	
	effect1.setTieNote(true);
	effect2.setLetRing(true);
	QCOMPARE( effect1 == effect2, false );
	QCOMPARE( effect1 != effect2, true );
}

QTEST_MAIN(TabNoteEffectTest)
#include "tabnoteeffect.moc"
