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 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
|
//=============================================================================
// MuseScore
// Music Composition & Notation
// $Id:$
//
// Copyright (C) 2012 Werner Schweer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================
#include <QtTest/QtTest>
#include "mtest/testutils.h"
#include "libmscore/score.h"
#include "libmscore/undo.h"
#include "libmscore/excerpt.h"
#include "libmscore/part.h"
#include "libmscore/measure.h"
#include "libmscore/segment.h"
#include "libmscore/chordrest.h"
#include "libmscore/harmony.h"
#include "libmscore/duration.h"
#include "libmscore/durationtype.h"
#define DIR QString("libmscore/chordsymbol/")
using namespace Ms;
//---------------------------------------------------------
// TestChordSymbol
//---------------------------------------------------------
class TestChordSymbol : public QObject, public MTest {
Q_OBJECT
Score* test_pre(const char* p);
void test_post(Score* score, const char* p);
private slots:
void initTestCase();
void testExtend();
void testClear();
void testAddLink();
void testAddPart();
void testNoSystem();
void testTranspose();
void testTransposePart();
};
//---------------------------------------------------------
// initTestCase
//---------------------------------------------------------
void TestChordSymbol::initTestCase()
{
initMTest();
}
//---------------------------------------------------------
// chordsymbol
//---------------------------------------------------------
Score* TestChordSymbol::test_pre(const char* p)
{
QString p1 = DIR + p + ".mscx";
Score* score = readScore(p1);
score->doLayout();
return score;
}
void TestChordSymbol::test_post(Score* score, const char* p)
{
QString p1 = p;
p1 += "-test.mscx";
QString p2 = DIR + p + "-ref.mscx";
QVERIFY(saveCompareScore(score, p1, p2));
delete score;
}
void TestChordSymbol::testExtend()
{
Score* score = test_pre("extend");
Measure* m = score->firstMeasure();
Segment* s = m->first(Segment::Type::ChordRest);
ChordRest* cr = s->cr(0);
score->changeCRlen(cr, TDuration::DurationType::V_WHOLE);
score->doLayout();
test_post(score, "extend");
}
void TestChordSymbol::testClear()
{
Score* score = test_pre("clear");
Measure* m = score->firstMeasure();
score->select(m, SelectType::SINGLE, 0);
score->cmdDeleteSelection();
score->doLayout();
test_post(score, "clear");
}
void TestChordSymbol::testAddLink()
{
Score* score = test_pre("add-link");
Segment* seg = score->firstSegment(Segment::Type::ChordRest);
ChordRest* cr = seg->cr(0);
Harmony* harmony = new Harmony(score);
harmony->setHarmony("C7");
harmony->setTrack(cr->track());
harmony->setParent(cr->segment());
score->undoAddElement(harmony);
score->doLayout();
test_post(score, "add-link");
}
void TestChordSymbol::testAddPart()
{
Score* score = test_pre("add-part");
Segment* seg = score->firstSegment(Segment::Type::ChordRest);
ChordRest* cr = seg->cr(0);
Harmony* harmony = new Harmony(score);
harmony->setHarmony("C7");
harmony->setTrack(cr->track());
harmony->setParent(cr->segment());
score->undoAddElement(harmony);
score->doLayout();
test_post(score, "add-part");
}
void TestChordSymbol::testNoSystem()
{
Score* score = test_pre("no-system");
//
// create first part
//
QList<Part*> parts;
parts.append(score->parts().at(0));
Score* nscore = new Score(score);
score->undo(new AddExcerpt(nscore));
{
Excerpt ex(score);
ex.setPartScore(nscore);
ex.setTitle(parts.front()->longName());
ex.setParts(parts);
::createExcerpt(&ex);
QVERIFY(nscore);
}
nscore->setName(parts.front()->partName());
nscore->style()->set(StyleIdx::createMultiMeasureRests, true);
//
// create second part
//
parts.clear();
parts.append(score->parts().at(1));
nscore = new Score(score);
score->undo(new AddExcerpt(nscore));
{
Excerpt ex(score);
ex.setTitle(parts.front()->longName());
ex.setParts(parts);
ex.setPartScore(nscore);
::createExcerpt(&ex);
QVERIFY(nscore);
}
nscore->setName(parts.front()->partName());
nscore->style()->set(StyleIdx::createMultiMeasureRests, true);
score->doLayout();
test_post(score, "no-system");
}
void TestChordSymbol::testTranspose()
{
Score* score = test_pre("transpose");
score->startCmd();
score->cmdSelectAll();
score->transpose(TransposeMode::BY_INTERVAL, TransposeDirection::UP, Key::C, 4, false, true, true);
score->endCmd();
test_post(score, "transpose");
}
void TestChordSymbol::testTransposePart()
{
Score* score = test_pre("transpose-part");
score->startCmd();
score->cmdSelectAll();
score->transpose(TransposeMode::BY_INTERVAL, TransposeDirection::UP, Key::C, 4, false, true, true);
score->endCmd();
test_post(score, "transpose-part");
}
QTEST_MAIN(TestChordSymbol)
#include "tst_chordsymbol.moc"
|