MTESTS - Adds a test for glissando and grace notes

Tests that a glissando dropped unto a grace note or unto a note followed by a grace note works as intended.

Tests cases involving both before-graces and after-graces.

The tst check that the glissandi are added from/to the right element; visual layout is not involved.
This commit is contained in:
Maurizio M. Gavioli 2015-03-03 18:23:34 +01:00
parent e4926366e6
commit 4ffce0ec91
3 changed files with 448 additions and 2 deletions

View file

@ -0,0 +1,209 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="2.00">
<Score>
<LayerTag id="0" tag="default"></LayerTag>
<currentLayer>0</currentLayer>
<Division>480</Division>
<Style>
<page-layout>
<page-height>1683.78</page-height>
<page-width>1190.55</page-width>
<page-margins type="even">
<left-margin>56.6929</left-margin>
<right-margin>56.6929</right-margin>
<top-margin>56.6929</top-margin>
<bottom-margin>113.386</bottom-margin>
</page-margins>
<page-margins type="odd">
<left-margin>56.6929</left-margin>
<right-margin>56.6929</right-margin>
<top-margin>56.6929</top-margin>
<bottom-margin>113.386</bottom-margin>
</page-margins>
</page-layout>
<Spatium>1.76389</Spatium>
</Style>
<showInvisible>1</showInvisible>
<showUnprintable>1</showUnprintable>
<showFrames>1</showFrames>
<showMargins>0</showMargins>
<metaTag name="arranger"></metaTag>
<metaTag name="composer"></metaTag>
<metaTag name="copyright"></metaTag>
<metaTag name="lyricist"></metaTag>
<metaTag name="movementNumber"></metaTag>
<metaTag name="movementTitle"></metaTag>
<metaTag name="poet"></metaTag>
<metaTag name="source"></metaTag>
<metaTag name="translator"></metaTag>
<metaTag name="workNumber"></metaTag>
<metaTag name="workTitle"></metaTag>
<PageList>
<Page>
<System>
</System>
</Page>
</PageList>
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="-1" span="0"/>
</Staff>
<trackName>Flute</trackName>
<Instrument>
<longName pos="0">Flute</longName>
<shortName pos="0">Fl.</shortName>
<trackName>Flute</trackName>
<minPitchP>59</minPitchP>
<maxPitchP>98</maxPitchP>
<minPitchA>60</minPitchA>
<maxPitchA>93</maxPitchA>
<instrumentId>wind.flutes.flute</instrumentId>
<Articulation>
<velocity>100</velocity>
<gateTime>95</gateTime>
</Articulation>
<Articulation name="staccatissimo">
<velocity>100</velocity>
<gateTime>33</gateTime>
</Articulation>
<Articulation name="staccato">
<velocity>100</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="portato">
<velocity>100</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="tenuto">
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="marcato">
<velocity>120</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="sforzato">
<velocity>120</velocity>
<gateTime>100</gateTime>
</Articulation>
<Channel>
<program value="73"/>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<Measure number="1">
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
<showCourtesySig>1</showCourtesySig>
</TimeSig>
<Chord>
<offset x="-4" y="0"/>
<durationType>16th</durationType>
<Beam>1</Beam>
<grace16after/>
<Note>
<pitch>76</pitch>
<tpc>18</tpc>
<Glissando id="2">
<text>gliss.</text>
<subtype>0</subtype>
<diagonal>1</diagonal>
<lineWidth>0.15</lineWidth>
<anchor>3</anchor>
</Glissando>
</Note>
</Chord>
<Beam id="1">
<l1>-12</l1>
<l2>-9</l2>
</Beam>
<Chord>
<offset x="-4" y="0"/>
<durationType>16th</durationType>
<Beam>1</Beam>
<grace16after/>
<Note>
<pitch>79</pitch>
<tpc>15</tpc>
<endSpanner id="3"/>
</Note>
</Chord>
<Chord>
<durationType>half</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
<Glissando id="3">
<text>gliss.</text>
<subtype>0</subtype>
<diagonal>1</diagonal>
<lineWidth>0.15</lineWidth>
<anchor>3</anchor>
</Glissando>
</Note>
</Chord>
<Chord>
<durationType>eighth</durationType>
<appoggiatura/>
<Note>
<pitch>79</pitch>
<tpc>15</tpc>
<endSpanner id="2"/>
</Note>
</Chord>
<Chord>
<durationType>half</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
<Glissando id="4">
<text>gliss.</text>
<subtype>0</subtype>
<diagonal>1</diagonal>
<lineWidth>0.15</lineWidth>
<anchor>3</anchor>
</Glissando>
</Note>
</Chord>
</Measure>
<Measure number="2">
<Chord>
<durationType>eighth</durationType>
<appoggiatura/>
<Note>
<pitch>76</pitch>
<tpc>18</tpc>
<Glissando id="5">
<text>gliss.</text>
<subtype>0</subtype>
<diagonal>1</diagonal>
<lineWidth>0.15</lineWidth>
<anchor>3</anchor>
</Glissando>
<endSpanner id="4"/>
</Note>
</Chord>
<Chord>
<durationType>half</durationType>
<Note>
<pitch>79</pitch>
<tpc>15</tpc>
<endSpanner id="5"/>
</Note>
</Chord>
<Rest>
<durationType>half</durationType>
</Rest>
<BarLine>
<subtype>end</subtype>
<span>1</span>
</BarLine>
</Measure>
</Staff>
</Score>
</museScore>

View file

@ -0,0 +1,160 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="2.00">
<Score>
<LayerTag id="0" tag="default"></LayerTag>
<currentLayer>0</currentLayer>
<Division>480</Division>
<Style>
</Style>
<showInvisible>1</showInvisible>
<showUnprintable>1</showUnprintable>
<showFrames>1</showFrames>
<showMargins>0</showMargins>
<metaTag name="arranger"></metaTag>
<metaTag name="composer"></metaTag>
<metaTag name="copyright"></metaTag>
<metaTag name="lyricist"></metaTag>
<metaTag name="movementNumber"></metaTag>
<metaTag name="movementTitle"></metaTag>
<metaTag name="poet"></metaTag>
<metaTag name="source"></metaTag>
<metaTag name="translator"></metaTag>
<metaTag name="workNumber"></metaTag>
<metaTag name="workTitle"></metaTag>
<PageList>
<Page>
<System>
</System>
</Page>
</PageList>
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
<bracket type="-1" span="0"/>
</Staff>
<trackName>Flute</trackName>
<Instrument>
<longName pos="0">Flute</longName>
<shortName pos="0">Fl.</shortName>
<trackName>Flute</trackName>
<minPitchP>59</minPitchP>
<maxPitchP>98</maxPitchP>
<minPitchA>60</minPitchA>
<maxPitchA>93</maxPitchA>
<instrumentId>wind.flutes.flute</instrumentId>
<Articulation>
<velocity>100</velocity>
<gateTime>95</gateTime>
</Articulation>
<Articulation name="staccatissimo">
<velocity>100</velocity>
<gateTime>33</gateTime>
</Articulation>
<Articulation name="staccato">
<velocity>100</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="portato">
<velocity>100</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="tenuto">
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="marcato">
<velocity>120</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="sforzato">
<velocity>120</velocity>
<gateTime>100</gateTime>
</Articulation>
<Channel>
<program value="73"/>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<Measure number="1">
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
<showCourtesySig>1</showCourtesySig>
</TimeSig>
<Chord>
<offset x="-4" y="0"/>
<durationType>16th</durationType>
<Beam>0</Beam>
<grace16after/>
<Note>
<pitch>76</pitch>
<tpc>18</tpc>
</Note>
</Chord>
<Beam id="1">
<l1>-12</l1>
<l2>-9</l2>
</Beam>
<Chord>
<offset x="-4" y="0"/>
<durationType>16th</durationType>
<Beam>1</Beam>
<grace16after/>
<Note>
<pitch>79</pitch>
<tpc>15</tpc>
</Note>
</Chord>
<Chord>
<durationType>half</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
<Chord>
<durationType>eighth</durationType>
<appoggiatura/>
<Note>
<pitch>79</pitch>
<tpc>15</tpc>
</Note>
</Chord>
<Chord>
<durationType>half</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</Measure>
<Measure number="2">
<Chord>
<durationType>eighth</durationType>
<appoggiatura/>
<Note>
<pitch>76</pitch>
<tpc>18</tpc>
</Note>
</Chord>
<Chord>
<durationType>half</durationType>
<Note>
<pitch>79</pitch>
<tpc>15</tpc>
</Note>
</Chord>
<Rest>
<durationType>half</durationType>
</Rest>
<BarLine>
<subtype>end</subtype>
<span>1</span>
</BarLine>
</Measure>
</Staff>
</Score>
</museScore>

View file

@ -12,8 +12,9 @@
#include <QtTest/QtTest>
#include "mtest/testutils.h"
//#include "libmscore/barline.h"
//#include "libmscore/measure.h"
#include "libmscore/chord.h"
#include "libmscore/glissando.h"
#include "libmscore/measure.h"
#include "libmscore/score.h"
//#include "libmscore/system.h"
//#include "libmscore/undo.h"
@ -33,6 +34,7 @@ class TestSpanners : public QObject, public MTest
private slots:
void initTestCase();
void spanners01(); // cross-staff glissando from lower to higher staff
void spanners02(); // glissando from/to grace notes
};
//---------------------------------------------------------
@ -56,12 +58,87 @@ void TestSpanners::initTestCase()
void TestSpanners::spanners01()
{
Score* score = readScore(DIR + "glissando-crossstaff01.mscx");
QVERIFY(score);
score->doLayout();
QVERIFY(saveCompareScore(score, "glissando-crsossstaff01.mscx", DIR + "glissando-crossstaff01-ref.mscx"));
delete score;
}
//---------------------------------------------------------
/// spanners02
/// Loads a score with before- and after-grace notes and adds several glissandi from/to them.
//---------------------------------------------------------
void TestSpanners::spanners02()
{
DropData dropData;
Glissando* gliss;
Score* score = readScore(DIR + "glissando-graces01.mscx");
QVERIFY(score);
score->doLayout();
// GLISSANDO FROM MAIN NOTE TO AFTER-GRACE
// go to top note of first chord
Measure* msr = score->firstMeasure();
QVERIFY(msr);
Segment* seg = msr->findSegment(Segment::Type::ChordRest, 0);
QVERIFY(seg);
Chord* chord = static_cast<Chord*>(seg->element(0));
QVERIFY(chord && chord->type() == Element::Type::CHORD);
Note* note = chord->upNote();
QVERIFY(note);
// drop a glissando on note
gliss = new Glissando(score); // create a new element each time, as drop() will eventually delete it
dropData.pos = note->pagePos();
dropData.element = gliss;
note->drop(dropData);
// GLISSANDO FROM AFTER-GRACE TO BEFORE-GRACE OF NEXT CHORD
// go to last after-grace of chord and drop a glissando on it
Chord* grace = chord->graceNotesAfter().last();
QVERIFY(grace && grace->type() == Element::Type::CHORD);
note = grace->upNote();
QVERIFY(note);
gliss = new Glissando(score);
dropData.pos = note->pagePos();
dropData.element = gliss;
note->drop(dropData);
// GLISSANDO FROM MAIN NOTE TO BEFORE-GRACE OF NEXT CHORD
// go to next chord
seg = seg->nextCR(0);
QVERIFY(seg);
chord = static_cast<Chord*>(seg->element(0));
QVERIFY(chord && chord->type() == Element::Type::CHORD);
note = chord->upNote();
QVERIFY(note);
gliss = new Glissando(score);
dropData.pos = note->pagePos();
dropData.element = gliss;
note->drop(dropData);
// GLISSANDO FROM BEFORE-GRACE TO MAIN NOTE
// go to next chord
seg = seg->nextCR(0);
QVERIFY(seg);
chord = static_cast<Chord*>(seg->element(0));
QVERIFY(chord && chord->type() == Element::Type::CHORD);
// go to its last before-grace note
grace = chord->graceNotesBefore().last();
QVERIFY(grace && grace->type() == Element::Type::CHORD);
note = grace->upNote();
QVERIFY(note);
gliss = new Glissando(score);
dropData.pos = note->pagePos();
dropData.element = gliss;
note->drop(dropData);
QVERIFY(saveCompareScore(score, "glissando-graces01.mscx", DIR + "glissando-graces01-ref.mscx"));
delete score;
}
QTEST_MAIN(TestSpanners)
#include "tst_spanners.moc"