Skip to content

Commit

Permalink
New unit test for property linking
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-spa committed Aug 29, 2023
1 parent 31e2a74 commit 424e4db
Show file tree
Hide file tree
Showing 4 changed files with 334 additions and 0 deletions.
83 changes: 83 additions & 0 deletions src/engraving/tests/parts_data/partPropertyLinking-part-0.mscx
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="4.20">
<Score>
<Division>480</Division>
<Style>
<Spatium>1.74978</Spatium>
</Style>
<showInvisible>1</showInvisible>
<showUnprintable>1</showUnprintable>
<showFrames>1</showFrames>
<showMargins>0</showMargins>
<metaTag name="partName">Flute</metaTag>
<Part id="1">
<Staff id="1">
<linkedTo>1</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>Flute</trackName>
<Instrument id="flute">
<longName>Flute</longName>
<shortName>Fl.</shortName>
<trackName>Flute</trackName>
<minPitchP>59</minPitchP>
<maxPitchP>98</maxPitchP>
<minPitchA>60</minPitchA>
<maxPitchA>93</maxPitchA>
<instrumentId>wind.flutes.flute</instrumentId>
<Channel>
<program value="73"/>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<VBox>
<height>10</height>
<excludeFromParts>0</excludeFromParts>
<Text>
<style>instrument_excerpt</style>
<text>Flute</text>
</Text>
</VBox>
<Measure>
<voice>
<KeySig>
<linked>
</linked>
<concertKey>0</concertKey>
</KeySig>
<TimeSig>
<linked>
<indexDiff>-1</indexDiff>
</linked>
<sigN>4</sigN>
<sigD>4</sigD>
</TimeSig>
<Dynamic>
<subtype>mf</subtype>
<velocity>80</velocity>
<linked>
<indexDiff>-2</indexDiff>
</linked>
</Dynamic>
<Chord>
<linked>
<indexDiff>-3</indexDiff>
</linked>
<durationType>whole</durationType>
<Note>
<linked>
<indexDiff>-4</indexDiff>
</linked>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
</Staff>
<name>Flute</name>
</Score>
</museScore>
89 changes: 89 additions & 0 deletions src/engraving/tests/parts_data/partPropertyLinking-part-1.mscx
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="4.20">
<Score>
<Division>480</Division>
<Style>
<Spatium>1.74978</Spatium>
</Style>
<showInvisible>1</showInvisible>
<showUnprintable>1</showUnprintable>
<showFrames>1</showFrames>
<showMargins>0</showMargins>
<metaTag name="partName">Flute</metaTag>
<Part id="1">
<Staff id="1">
<linkedTo>1</linkedTo>
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>Flute</trackName>
<Instrument id="flute">
<longName>Flute</longName>
<shortName>Fl.</shortName>
<trackName>Flute</trackName>
<minPitchP>59</minPitchP>
<maxPitchP>98</maxPitchP>
<minPitchA>60</minPitchA>
<maxPitchA>93</maxPitchA>
<instrumentId>wind.flutes.flute</instrumentId>
<Channel>
<program value="73"/>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<VBox>
<height>10</height>
<excludeFromParts>0</excludeFromParts>
<Text>
<style>instrument_excerpt</style>
<text>Flute</text>
</Text>
</VBox>
<Measure>
<voice>
<KeySig>
<linked>
</linked>
<concertKey>0</concertKey>
</KeySig>
<TimeSig>
<linked>
<indexDiff>-1</indexDiff>
</linked>
<sigN>4</sigN>
<sigD>4</sigD>
</TimeSig>
<Dynamic>
<subtype>mf</subtype>
<velocity>80</velocity>
<dynamicsSize>1.2</dynamicsSize>
<linked>
<indexDiff>-2</indexDiff>
</linked>
<placement>above</placement>
<positionLinkedToMaster>0</positionLinkedToMaster>
<appearanceLinkedToMaster>0</appearanceLinkedToMaster>
<placement>above</placement>
<dynamicsSize>1.2</dynamicsSize>
</Dynamic>
<Chord>
<linked>
<indexDiff>-3</indexDiff>
</linked>
<durationType>whole</durationType>
<Note>
<linked>
<indexDiff>-4</indexDiff>
</linked>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
</Staff>
<name>Flute</name>
</Score>
</museScore>
118 changes: 118 additions & 0 deletions src/engraving/tests/parts_data/partPropertyLinking.mscx
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="4.20">
<programVersion>4.2.0</programVersion>
<programRevision></programRevision>
<Score>
<Division>480</Division>
<showInvisible>1</showInvisible>
<showUnprintable>1</showUnprintable>
<showFrames>1</showFrames>
<showMargins>0</showMargins>
<open>1</open>
<metaTag name="arranger"></metaTag>
<metaTag name="composer">Composer / arranger</metaTag>
<metaTag name="copyright"></metaTag>
<metaTag name="creationDate">2023-08-28</metaTag>
<metaTag name="lyricist"></metaTag>
<metaTag name="movementNumber"></metaTag>
<metaTag name="movementTitle"></metaTag>
<metaTag name="platform">Linux</metaTag>
<metaTag name="poet"></metaTag>
<metaTag name="source"></metaTag>
<metaTag name="subtitle">Subtitle</metaTag>
<metaTag name="translator"></metaTag>
<metaTag name="workNumber"></metaTag>
<metaTag name="workTitle">Untitled score</metaTag>
<Order id="orchestral">
<name>Orchestral</name>
<instrument id="flute">
<family id="flutes">Flutes</family>
</instrument>
<section id="woodwind" brackets="true" barLineSpan="true" thinBrackets="true">
<family>flutes</family>
<family>oboes</family>
<family>clarinets</family>
<family>saxophones</family>
<family>bassoons</family>
<unsorted group="woodwinds"/>
</section>
<section id="brass" brackets="true" barLineSpan="true" thinBrackets="true">
<family>horns</family>
<family>trumpets</family>
<family>cornets</family>
<family>flugelhorns</family>
<family>trombones</family>
<family>tubas</family>
</section>
<section id="timpani" brackets="true" barLineSpan="true" thinBrackets="true">
<family>timpani</family>
</section>
<section id="percussion" brackets="true" barLineSpan="true" thinBrackets="true">
<family>keyboard-percussion</family>
<family>drums</family>
<family>unpitched-metal-percussion</family>
<family>unpitched-wooden-percussion</family>
<family>other-percussion</family>
</section>
<family>keyboards</family>
<family>harps</family>
<family>organs</family>
<family>synths</family>
<soloists/>
<section id="voices" brackets="true" barLineSpan="false" thinBrackets="true">
<family>voices</family>
<family>voice-groups</family>
</section>
<section id="strings" brackets="true" barLineSpan="true" thinBrackets="true">
<family>orchestral-strings</family>
</section>
<unsorted/>
</Order>
<Part id="1">
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>Flute</trackName>
<Instrument id="flute">
<longName>Flute</longName>
<shortName>Fl.</shortName>
<trackName>Flute</trackName>
<minPitchP>59</minPitchP>
<maxPitchP>98</maxPitchP>
<minPitchA>60</minPitchA>
<maxPitchA>93</maxPitchA>
<instrumentId>wind.flutes.flute</instrumentId>
<Channel>
<program value="73"/>
<synti>Fluid</synti>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<Measure>
<voice>
<KeySig>
<concertKey>0</concertKey>
</KeySig>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
</TimeSig>
<Dynamic>
<subtype>mf</subtype>
<velocity>80</velocity>
</Dynamic>
<Chord>
<durationType>whole</durationType>
<Note>
<pitch>72</pitch>
<tpc>14</tpc>
</Note>
</Chord>
</voice>
</Measure>
</Staff>
</Score>
</museScore>
44 changes: 44 additions & 0 deletions src/engraving/tests/parts_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "libmscore/breath.h"
#include "libmscore/chord.h"
#include "libmscore/chordline.h"
#include "libmscore/dynamic.h"
#include "libmscore/engravingitem.h"
#include "libmscore/excerpt.h"
#include "libmscore/factory.h"
Expand Down Expand Up @@ -1227,6 +1228,49 @@ TEST_F(Engraving_PartsTests, partExclusion)
EXPECT_TRUE(ScoreComp::saveCompareScore(partScore, u"partExclusion-part-0.mscx", PARTS_DATA_DIR + u"partExclusion-part-0.mscx"));
}

TEST_F(Engraving_PartsTests, partPropertyLinking)
{
MasterScore* masterScore = ScoreRW::readScore(PARTS_DATA_DIR + u"partPropertyLinking.mscx");

EXPECT_TRUE(masterScore);

createPart(masterScore);
Score* partScore;
for (Score* score : masterScore->scoreList()) {
if (score != masterScore) {
partScore = score;
break;
}
}
EXPECT_TRUE(partScore);

EXPECT_TRUE(ScoreComp::saveCompareScore(partScore, u"partPropertyLinking-part-0.mscx", PARTS_DATA_DIR + u"partPropertyLinking-part-0.mscx"));

Dynamic* dynamic = nullptr;
Measure* measure = masterScore->firstMeasure();
for (Segment& segment : measure->segments()) {
for (EngravingItem* annotation : segment.annotations()) {
if (annotation->isDynamic()) {
dynamic = toDynamic(annotation);
break;
}
}
}
Dynamic* testItem = toDynamic(dynamic->findLinkedInScore(partScore));
EXPECT_TRUE(testItem);

testItem->undoChangeProperty(Pid::PLACEMENT, PropertyValue::fromValue(PlacementV::ABOVE), PropertyFlags::NOSTYLE);
testItem->undoChangeProperty(Pid::DYNAMICS_SIZE, PropertyValue::fromValue(1.2), PropertyFlags::NOSTYLE);
EXPECT_FALSE(testItem->isPositionLinkedToMaster());
EXPECT_FALSE(testItem->isAppearanceLinkedToMaster());

EXPECT_TRUE(ScoreComp::saveCompareScore(partScore, u"partPropertyLinking-part-1.mscx", PARTS_DATA_DIR + u"partPropertyLinking-part-1.mscx"));

testItem->undoChangeProperty(Pid::POSITION_LINKED_TO_MASTER, true, PropertyFlags::NOSTYLE);
testItem->undoChangeProperty(Pid::APPEARANCE_LINKED_TO_MASTER, true, PropertyFlags::NOSTYLE);
EXPECT_TRUE(ScoreComp::saveCompareScore(partScore, u"partPropertyLinking-part-0.mscx", PARTS_DATA_DIR + u"partPropertyLinking-part-0.mscx"));
}

//---------------------------------------------------------
// staffStyles
//---------------------------------------------------------
Expand Down

0 comments on commit 424e4db

Please sign in to comment.