Skip to content

Commit 7fb84ce

Browse files
mike-spaJojo-Schmitz
authored andcommitted
Add unit test
incl. fixing a merge conflict
1 parent 88a1288 commit 7fb84ce

File tree

2 files changed

+221
-0
lines changed

2 files changed

+221
-0
lines changed
Lines changed: 192 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,192 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<museScore version="4.60">
3+
<programVersion>4.7.0</programVersion>
4+
<programRevision></programRevision>
5+
<Score>
6+
<eid>sFMlmwzzOnG_ILNRNamr+pG</eid>
7+
<Division>480</Division>
8+
<showInvisible>1</showInvisible>
9+
<showUnprintable>1</showUnprintable>
10+
<showFrames>1</showFrames>
11+
<showMargins>0</showMargins>
12+
<open>1</open>
13+
<metaTag name="arranger"></metaTag>
14+
<metaTag name="audioComUrl"></metaTag>
15+
<metaTag name="composer">Composer / arranger</metaTag>
16+
<metaTag name="copyright"></metaTag>
17+
<metaTag name="creationDate">2025-10-27</metaTag>
18+
<metaTag name="lyricist"></metaTag>
19+
<metaTag name="movementNumber"></metaTag>
20+
<metaTag name="movementTitle"></metaTag>
21+
<metaTag name="platform">Linux</metaTag>
22+
<metaTag name="source"></metaTag>
23+
<metaTag name="sourceRevisionId"></metaTag>
24+
<metaTag name="subtitle">Subtitle</metaTag>
25+
<metaTag name="translator"></metaTag>
26+
<metaTag name="workNumber"></metaTag>
27+
<metaTag name="workTitle">Untitled score</metaTag>
28+
<Order id="orchestral">
29+
<name>Orchestral</name>
30+
<instrument id="piano">
31+
<family id="keyboards">Keyboards</family>
32+
</instrument>
33+
<section id="woodwind" brackets="true" barLineSpan="true" thinBrackets="true">
34+
<family>flutes</family>
35+
<family>oboes</family>
36+
<family>clarinets</family>
37+
<family>saxophones</family>
38+
<family>bassoons</family>
39+
<unsorted group="woodwinds"/>
40+
</section>
41+
<section id="brass" brackets="true" barLineSpan="true" thinBrackets="true">
42+
<family>horns</family>
43+
<family>trumpets</family>
44+
<family>cornets</family>
45+
<family>flugelhorns</family>
46+
<family>trombones</family>
47+
<family>tubas</family>
48+
</section>
49+
<section id="timpani" brackets="true" barLineSpan="true" thinBrackets="true">
50+
<family>timpani</family>
51+
</section>
52+
<section id="percussion" brackets="true" barLineSpan="true" thinBrackets="true">
53+
<family>keyboard-percussion</family>
54+
<family>drums</family>
55+
<family>unpitched-metal-percussion</family>
56+
<family>unpitched-wooden-percussion</family>
57+
<family>other-percussion</family>
58+
</section>
59+
<family>keyboards</family>
60+
<family>harps</family>
61+
<family>organs</family>
62+
<family>synths</family>
63+
<soloists/>
64+
<section id="voices" brackets="true" barLineSpan="false" thinBrackets="true">
65+
<family>voices</family>
66+
<family>voice-groups</family>
67+
</section>
68+
<section id="strings" brackets="true" barLineSpan="true" thinBrackets="true">
69+
<family>orchestral-strings</family>
70+
</section>
71+
<unsorted/>
72+
</Order>
73+
<Part id="1">
74+
<Staff>
75+
<eid>yLTbtpuYjrL_2Upa4+LsM9L</eid>
76+
<StaffType group="pitched">
77+
<name>stdNormal</name>
78+
</StaffType>
79+
<bracket type="1" span="2" col="2" visible="1"/>
80+
<barLineSpan>1</barLineSpan>
81+
</Staff>
82+
<trackName>Piano</trackName>
83+
<Instrument id="piano">
84+
<longName>Piano</longName>
85+
<shortName>Pno.</shortName>
86+
<trackName>Piano</trackName>
87+
<minPitchP>21</minPitchP>
88+
<maxPitchP>108</maxPitchP>
89+
<minPitchA>21</minPitchA>
90+
<maxPitchA>108</maxPitchA>
91+
<instrumentId>keyboard.piano</instrumentId>
92+
<clef staff="2">F</clef>
93+
<Articulation>
94+
<velocity>100</velocity>
95+
<gateTime>95</gateTime>
96+
</Articulation>
97+
<Articulation name="staccatissimo">
98+
<velocity>100</velocity>
99+
<gateTime>33</gateTime>
100+
</Articulation>
101+
<Articulation name="staccato">
102+
<velocity>100</velocity>
103+
<gateTime>50</gateTime>
104+
</Articulation>
105+
<Articulation name="portato">
106+
<velocity>100</velocity>
107+
<gateTime>67</gateTime>
108+
</Articulation>
109+
<Articulation name="tenuto">
110+
<velocity>100</velocity>
111+
<gateTime>100</gateTime>
112+
</Articulation>
113+
<Articulation name="marcato">
114+
<velocity>120</velocity>
115+
<gateTime>67</gateTime>
116+
</Articulation>
117+
<Articulation name="sforzato">
118+
<velocity>150</velocity>
119+
<gateTime>100</gateTime>
120+
</Articulation>
121+
<Articulation name="sforzatoStaccato">
122+
<velocity>150</velocity>
123+
<gateTime>50</gateTime>
124+
</Articulation>
125+
<Articulation name="marcatoStaccato">
126+
<velocity>120</velocity>
127+
<gateTime>50</gateTime>
128+
</Articulation>
129+
<Articulation name="marcatoTenuto">
130+
<velocity>120</velocity>
131+
<gateTime>100</gateTime>
132+
</Articulation>
133+
<Channel>
134+
<program value="0"/>
135+
<synti>Fluid</synti>
136+
</Channel>
137+
</Instrument>
138+
</Part>
139+
<Staff id="1">
140+
<Measure>
141+
<eid>R0Ms9HgYTs_Z6F7QI7s5JN</eid>
142+
<voice>
143+
<KeySig>
144+
<eid>D/xXUPh7WdE_reZf5mJn+rN</eid>
145+
<concertKey>0</concertKey>
146+
</KeySig>
147+
<TimeSig>
148+
<eid>EFsX1i3AOML_g3rEJvJe0FL</eid>
149+
<sigN>4</sigN>
150+
<sigD>4</sigD>
151+
</TimeSig>
152+
<Chord>
153+
<eid>LhFBK1lGKgE_4Oqi75gCRpL</eid>
154+
<durationType>quarter</durationType>
155+
<Note>
156+
<eid>kEiL+JIyKaB_Br8MHf3MwqC</eid>
157+
<pitch>67</pitch>
158+
<tpc>15</tpc>
159+
</Note>
160+
</Chord>
161+
<Chord>
162+
<eid>NbZC+YdlrQE_aV2BwgrVuDN</eid>
163+
<durationType>quarter</durationType>
164+
<Note>
165+
<eid>BCUbEFHVj2M_gg/VFZrm7sO</eid>
166+
<pitch>67</pitch>
167+
<tpc>15</tpc>
168+
</Note>
169+
</Chord>
170+
<Chord>
171+
<eid>9XshPS74OBP_hssb+Zs/VLI</eid>
172+
<durationType>quarter</durationType>
173+
<Note>
174+
<eid>1Pe/TGT9rzK_VdIu9Juc2F</eid>
175+
<pitch>67</pitch>
176+
<tpc>15</tpc>
177+
</Note>
178+
</Chord>
179+
<Chord>
180+
<eid>UjXt9EC39YL_LJGi/kylO4C</eid>
181+
<durationType>quarter</durationType>
182+
<Note>
183+
<eid>nBCZaNYI51D_PXlNUGn76+N</eid>
184+
<pitch>67</pitch>
185+
<tpc>15</tpc>
186+
</Note>
187+
</Chord>
188+
</voice>
189+
</Measure>
190+
</Staff>
191+
</Score>
192+
</museScore>

src/engraving/tests/voiceswitching_tests.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
#include "dom/chord.h"
2626
#include "dom/note.h"
27+
#include "dom/rest.h"
2728

2829
#include "utils/scorerw.h"
2930

@@ -100,3 +101,31 @@ TEST_F(Engraving_VoiceSwitchingTests, voiceSwitching)
100101

101102
delete score;
102103
}
104+
105+
TEST_F(Engraving_VoiceSwitchingTests, voicesSwitchingGapRests)
106+
{
107+
Score* score = ScoreRW::readScore(VOICESWITCHING_DATA_DIR + "voiceswitching-2.mscx");
108+
EXPECT_TRUE(score);
109+
110+
Segment* segment = score->tick2segment(Fraction(3, 4), true, SegmentType::ChordRest);
111+
EXPECT_TRUE(segment);
112+
113+
//! [GIVEN] A measure with some notes in voice zero
114+
Chord* chord = toChord(segment->element(0));
115+
EXPECT_TRUE(chord);
116+
117+
//! [WHEN] The last note of the measure is selected and moved to voice one
118+
score->select(chord->upNote());
119+
score->startCmd(TranslatableString("undoableAction", "Change voice"));
120+
score->changeSelectedElementsVoice(1);
121+
score->endCmd();
122+
123+
//! [THEN] Voice 1 should be filled with gap rests from the start of the measure
124+
Segment* firstSeg = score->firstSegment(SegmentType::ChordRest);
125+
EXPECT_TRUE(firstSeg);
126+
127+
EngravingItem* item = firstSeg->element(1);
128+
EXPECT_TRUE(item && item->isRest() && toRest(item)->isGap());
129+
130+
delete score;
131+
}

0 commit comments

Comments
 (0)