File: tst_join.cpp

package info (click to toggle)
musescore2 2.3.2%2Bdfsg4-16
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 170,464 kB
  • sloc: cpp: 262,612; xml: 176,707; sh: 3,377; ansic: 1,246; python: 356; makefile: 227; perl: 82; pascal: 78
file content (126 lines) | stat: -rw-r--r-- 3,599 bytes parent folder | download | duplicates (7)
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
//=============================================================================
//  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/measure.h"
#include "libmscore/segment.h"
#include "libmscore/chordrest.h"
#include "libmscore/chord.h"

#define DIR QString("libmscore/join/")

using namespace Ms;

//---------------------------------------------------------
//   TestJoin
//---------------------------------------------------------

class TestJoin : public QObject, public MTest
      {
      Q_OBJECT

      void join(const char* p1, const char* p2);
      void join(const char* p1, const char* p2, int);
      void join1(const char* p1);

   private slots:
      void initTestCase();
      void join01() { join("join01.mscx", "join01-ref.mscx"); }
      void join02() { join("join02.mscx", "join02-ref.mscx"); }
      void join03() { join("join03.mscx", "join03-ref.mscx"); }
      void join04() { join("join04.mscx", "join04-ref.mscx"); }
      void join05() { join("join05.mscx", "join05-ref.mscx"); }
      void join06() { join("join06.mscx", "join06-ref.mscx", 1); }
      void join07() { join("join07.mscx", "join07-ref.mscx"); }
      void join08() { join1("join08.mscx"); }
      };

//---------------------------------------------------------
//   initTestCase
//---------------------------------------------------------

void TestJoin::initTestCase()
      {
      initMTest();
      }

//---------------------------------------------------------
//   join
//---------------------------------------------------------

void TestJoin::join(const char* p1, const char* p2)
      {
      Score* score = readScore(DIR + p1);
      score->doLayout();
      Measure* m1 = score->firstMeasure();
      Measure* m2 = m1->nextMeasure();

      QVERIFY(m1 != 0);
      QVERIFY(m2 != 0);
      QVERIFY(m1 != m2);

      score->cmdJoinMeasure(m1, m2);

      QVERIFY(saveCompareScore(score, p1, DIR + p2));
      delete score;
      }

void TestJoin::join(const char* p1, const char* p2, int index)
      {
      Score* score = readScore(DIR + p1);
      score->doLayout();
      Measure* m1 = score->firstMeasure();
      for (int i = 0; i < index; ++i)
            m1 = m1->nextMeasure();
      Measure* m2 = m1->nextMeasure();

      QVERIFY(m1 != 0);
      QVERIFY(m2 != 0);
      QVERIFY(m1 != m2);

      score->cmdJoinMeasure(m1, m2);

      QVERIFY(saveCompareScore(score, p1, DIR + p2));
      delete score;
      }

void TestJoin::join1(const char* p1)
      {
      Score* score = readScore(DIR + p1);
      score->doLayout();
      Measure* m1 = score->firstMeasure();
      Measure* m2 = m1->nextMeasure();

      QVERIFY(m1 != 0);
      QVERIFY(m2 != 0);
      QVERIFY(m1 != m2);

      score->cmdJoinMeasure(m1, m2);

      // check if notes are still on line 6
      Segment* s = score->firstSegment(Segment::Type::ChordRest);

      for (int i = 0; i < 8; ++i) {
            Note* note = static_cast<Ms::Chord*>(s->element(0))->upNote();
            QVERIFY(note->line() == 6);
            s = s->next1(Segment::Type::ChordRest);
            }

      delete score;
      }

QTEST_MAIN(TestJoin)
#include "tst_join.moc"