Beispiel #1
0
void TestMeasure::insertBfKeyChange()
      {
      MasterScore* score = readScore(DIR + "measure-insert_bf_key.mscx");
      // 4th measure
      Measure* m = score->firstMeasure()->nextMeasure();
      m = m->nextMeasure()->nextMeasure();
      score->startCmd();
      score->insertMeasure(ElementType::MEASURE, m);
      score->endCmd();
      QVERIFY(score->checkKeys());
      QVERIFY(saveCompareScore(score, "measure-insert_bf_key.mscx", DIR + "measure-insert_bf_key-ref.mscx"));
      score->undoRedo(true);
      QVERIFY(score->checkKeys());
      QVERIFY(saveCompareScore(score, "measure-insert_bf_key_undo.mscx", DIR + "measure-insert_bf_key.mscx"));
      m = score->firstMeasure()->nextMeasure()->nextMeasure()->nextMeasure()->nextMeasure()->nextMeasure();
      score->startCmd();
      score->insertMeasure(ElementType::MEASURE, m);
      score->endCmd();
      QVERIFY(score->checkKeys());
      QVERIFY(saveCompareScore(score, "measure-insert_bf_key-2.mscx", DIR + "measure-insert_bf_key-2-ref.mscx"));
      score->undoRedo(true);
      QVERIFY(score->checkKeys());
      QVERIFY(saveCompareScore(score, "measure-insert_bf_key_undo.mscx", DIR + "measure-insert_bf_key.mscx"));
      delete score;
      }
Beispiel #2
0
void TestSpanners::spanners13()
{
    DropData          dropData;
    LayoutBreak*      brk;

    MasterScore* score = readScore(DIR + "lyricsline06.mscx");
    QVERIFY(score);
    score->doLayout();

    // DROP A BREAK AT FIRST MEASURE AND VERIFY
    Measure*    msr   = score->firstMeasure();
    QVERIFY(msr);
    brk               = new LayoutBreak(score);
    brk->setLayoutBreakType(LayoutBreak::Type::LINE);
    dropData.pos      = msr->pagePos();
    dropData.element  = brk;
    score->startCmd();
    msr->drop(dropData);
    score->endCmd();
    // VERIFY SEGMENTS IN SYSTEMS AND THEN SCORE
    for (System* sys : score->systems())
        QVERIFY(sys->spannerSegments().size() == 1);
    QVERIFY(saveCompareScore(score, "lyricsline06.mscx", DIR + "lyricsline06-ref.mscx"));

    // UNDO AND VERIFY
    score->undoStack()->undo();
    score->doLayout();      // systems need to be re-computed
    QVERIFY(saveCompareScore(score, "lyricsline06.mscx", DIR + "lyricsline06.mscx"));
    delete score;
}
Beispiel #3
0
void TestTools::undoSlashFill()
{
    QString readFile(DIR + "undoSlashFill.mscx");
    QString writeFile1("undoSlashFill01-test.mscx");
    QString reference1(DIR  + "undoSlashFill01-ref.mscx");
    QString writeFile2("undoSlashFill02-test.mscx");
    QString reference2(DIR  + "undoSlashFill02-ref.mscx");

    MasterScore* score = readScore(readFile);

    // select
    Segment* s = score->firstMeasure()->findSegment(Segment::Type::ChordRest, MScore::division * 2);
    score->selection().setRange(s, score->lastSegment(), 0, 2);

    // do
    score->startCmd();
    score->cmdSlashFill();
    score->endCmd();
    QVERIFY(saveCompareScore(score, writeFile1, reference1));

    // undo
    score->undoStack()->undo();
    QVERIFY(saveCompareScore(score, writeFile2, reference2));

    delete score;
}
Beispiel #4
0
void TestMeasure::checkMeasure()
      {
      MasterScore* score = readScore(DIR + "checkMeasure.mscx");
      Element* tst       = 0;
      Measure* m         = score->firstMeasure()->nextMeasure();

      Segment* s = m->undoGetSegment(Segment::Type::ChordRest, 2880);
      tst = s->element(1);
      Q_ASSERT(tst);

      QVERIFY(tst->isRest() && toRest(tst)->isGap() && toRest(tst)->actualTicks() == 480/*&& toRest(tst)->durationType() == TDuration::DurationType::V_HALF*/);

      m = m->nextMeasure();
//      s = m->undoGetSegment(Segment::Type::ChordRest, 3840);
//      tst = s->element(2);
//      Q_ASSERT(tst);

//      QVERIFY(tst->isRest() && toRest(tst)->isGap() && toRest(tst)->actualTicks() == 480/*&& toRest(tst)->durationType() == TDuration::DurationType::V_HALF*/);

      m = m->nextMeasure();
      s = m->undoGetSegment(Segment::Type::ChordRest, 6240);
      tst = s->element(1);
      Q_ASSERT(tst);

      QVERIFY(tst->isRest() && toRest(tst)->isGap() && toRest(tst)->actualTicks() == 120/*&& toRest(tst)->durationType() == TDuration::DurationType::V_HALF*/);

      s = m->undoGetSegment(Segment::Type::ChordRest, 6480);
      tst = s->element(1);
      Q_ASSERT(tst);

      QVERIFY(tst->isRest() && toRest(tst)->isGap() && toRest(tst)->actualTicks() == 120/*&& toRest(tst)->durationType() == TDuration::DurationType::V_HALF*/);

      delete score;
      }
Beispiel #5
0
void TestSpanners::spanners07()
{
    DropData    dropData;
    Glissando*  gliss;

    MasterScore* score = readScore(DIR + "glissando-cloning04.mscx");
    QVERIFY(score);
    score->doLayout();

    // DROP A GLISSANDO ON FIRST NOTE
    Measure*    msr   = score->firstMeasure();
    QVERIFY(msr);
    Segment*    seg   = msr->findSegment(Segment::Type::ChordRest, 0);
    QVERIFY(seg);
    Ms::Chord*      chord = static_cast<Ms::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);
    dropData.pos      = note->pagePos();
    dropData.element  = gliss;
    note->drop(dropData);

    QVERIFY(saveCompareScore(score, "glissando-cloning04.mscx", DIR + "glissando-cloning04-ref.mscx"));
    delete score;
}
Beispiel #6
0
void TestMeasure::undoDelInitialVBox_269919()
      {
      MasterScore* score = readScore(DIR + "undoDelInitialVBox_269919.mscx");

      // 1. delete initial VBox
      score->startCmd();
      MeasureBase* initialVBox = score->measure(0);
      score->select(initialVBox);
      score->cmdDeleteSelection();
      score->endCmd();

      // 2. change duration of first chordrest
      score->startCmd();
      Measure* m = score->firstMeasure();
      ChordRest* cr = m->findChordRest(Fraction(0,1), 0);
      Fraction quarter(4, 1);
      score->changeCRlen(cr, quarter);
      score->endCmd();

      // 3. Undo to restore first chordrest
      score->undoRedo(true, 0);

      // 4. Undo to restore initial VBox resulted in assert failure crash
      score->undoRedo(true, 0);

      QVERIFY(saveCompareScore(score, "undoDelInitialVBox_269919.mscx", DIR + "undoDelInitialVBox_269919-ref.mscx"));
      delete score;
      }
void TestChordSymbol::testClear()
      {
      MasterScore* score = test_pre("clear");
      Measure* m = score->firstMeasure();
      score->select(m, SelectType::SINGLE, 0);
      score->cmdDeleteSelection();
      score->doLayout();
      test_post(score, "clear");
      }
void TestChordSymbol::testExtend()
      {
      MasterScore* 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 TestInstrumentChange::testDelete()
      {
      MasterScore* score = test_pre("delete");
      Measure* m = score->firstMeasure()->nextMeasure();
      Segment* s = m->first(Segment::Type::ChordRest);
      InstrumentChange* ic = toInstrumentChange(s->annotations()[0]);
      score->deleteItem(ic);
      score->doLayout();
      test_post(score, "delete");
      }
Beispiel #10
0
void TestMeasure::spanner_b()
      {
      MasterScore* score = readScore(DIR + "measure-4.mscx");

      Measure* m = score->firstMeasure();
      score->startCmd();
      score->insertMeasure(ElementType::MEASURE, m);
      score->endCmd();
      QVERIFY(saveCompareScore(score, "measure-5.mscx", DIR + "measure-5-ref.mscx"));
      delete score;
      }
Beispiel #11
0
void TestMeasure::spanner_A()
      {
      MasterScore* score = readScore(DIR + "measure-6.mscx");

      score->select(score->firstMeasure());
      score->startCmd();
      score->localTimeDelete();
      score->endCmd();
      score->doLayout();
      QVERIFY(saveCompareScore(score, "measure-6.mscx", DIR + "measure-6-ref.mscx"));
      delete score;
      }
Beispiel #12
0
void TestMeasure::insertMeasureBegin()
      {
      MasterScore* score = readScore(DIR + "measure-1.mscx");

      score->startCmd();
      Measure* m = score->firstMeasure();
      score->insertMeasure(Element::Type::MEASURE, m);
      score->endCmd();
      QVERIFY(saveCompareScore(score, "measure-2.mscx", DIR + "measure-2-ref.mscx"));

      delete score;
      }
Beispiel #13
0
void TestMeasure::gap()
      {
      MasterScore* score = readScore(DIR + "gaps.mscx");
      Element* tst       = 0;

      //Select and delete third quarter rest in first Measure (voice 2)
      score->startCmd();
      Measure* m  = score->firstMeasure();
      Segment* s  = m->undoGetSegment(SegmentType::ChordRest, Fraction::fromTicks(960));
      Element* el = s->element(1);
      score->select(el);
      score->cmdDeleteSelection();
      score->endCmd();

      tst = s->element(1);
      Q_ASSERT(tst);

      QVERIFY(tst->isRest() && toRest(tst)->isGap() /*&& toRest(tst)->durationType() == TDuration::DurationType::V_QUARTER*/);

      //Select and delete second quarter rest in third Measure (voice 4)
      score->startCmd();
      m  = m->nextMeasure()->nextMeasure();
      s  = m->undoGetSegment(SegmentType::ChordRest, Fraction::fromTicks(4320));
      el = s->element(3);
      score->select(el);
      score->cmdDeleteSelection();
      score->endCmd();

      tst = s->element(3);
      Q_ASSERT(tst);

      QVERIFY(tst->isRest() && toRest(tst)->isGap() /*&& toRest(tst)->durationType() == TDuration::DurationType::V_QUARTER*/);

      //Select and delete first quarter rest in third Measure (voice 4)
      score->startCmd();
      s  = m->undoGetSegment(SegmentType::ChordRest, Fraction::fromTicks(3840));
      el = s->element(3);
      score->select(el);
      score->cmdDeleteSelection();
      score->endCmd();

      tst = s->element(3);
      Q_ASSERT(tst);

      QVERIFY(tst->isRest() && toRest(tst)->isGap()
         && toRest(tst)->actualTicks() == Fraction::fromTicks(960)
         /*&& toRest(tst)->durationType() == TDuration::DurationType::V_HALF*/
         );


      delete score;
      }
void TestInstrumentChange::testAdd()
      {
      MasterScore* score = test_pre("add");
      Measure* m = score->firstMeasure()->nextMeasure();
      Segment* s = m->first(Segment::Type::ChordRest);
      InstrumentChange* ic = new InstrumentChange(score);
      ic->setParent(s);
      ic->setTrack(0);
      ic->setXmlText("Instrument");
      score->undoAddElement(ic);
      score->doLayout();
      test_post(score, "add");
      }
Beispiel #15
0
void TestKeySig::keysig_78216()
      {
      MasterScore* score = readScore(DIR + "keysig_78216.mscx");

      Measure* m1 = score->firstMeasure();
      Measure* m2 = m1->nextMeasure();
      Measure* m3 = m2->nextMeasure();

      // verify no keysig exists in segment of final tick of m1, m2, m3
      QVERIFY2(m1->findSegment(SegmentType::KeySig, m1->endTick()) == nullptr, "Should be no keysig at end of measure 1.");
      QVERIFY2(m2->findSegment(SegmentType::KeySig, m2->endTick()) == nullptr, "Should be no keysig at end of measure 2.");
      QVERIFY2(m3->findSegment(SegmentType::KeySig, m3->endTick()) == nullptr, "Should be no keysig at end of measure 3.");
      }
Beispiel #16
0
void TestMeasure::spanner_C()
      {
      MasterScore* score = readScore(DIR + "measure-8.mscx");

      Measure* m = score->firstMeasure()->nextMeasure();
      score->select(m);
      score->startCmd();
      score->localTimeDelete();
      score->endCmd();

      QVERIFY(saveCompareScore(score, "measure-8.mscx", DIR + "measure-8-ref.mscx"));
      delete score;
      }
void TestInstrumentChange::testChange()
      {
      MasterScore* score   = test_pre("change");
      Measure* m           = score->firstMeasure()->nextMeasure();
      Segment* s           = m->first(Segment::Type::ChordRest);
      InstrumentChange* ic = toInstrumentChange(s->annotations()[0]);
      Instrument* ni       = score->staff(1)->part()->instrument();
      ic->setInstrument(new Instrument(*ni));
      score->startCmd();
      ic->setXmlText("Instrument Oboe");
      score->undo(new ChangeInstrument(ic, ic->instrument()));
      score->endCmd();
      score->doLayout();
      test_post(score, "change");
      }
void TestInstrumentChange::testCopy()
      {
      MasterScore* score = test_pre("copy");
      Measure* m = score->firstMeasure()->nextMeasure();
      Segment* s = m->first(Segment::Type::ChordRest);
      InstrumentChange* ic = static_cast<InstrumentChange*>(s->annotations()[0]);
      m = m->nextMeasure();
      s = m->first(Segment::Type::ChordRest);
      InstrumentChange* nic = new InstrumentChange(*ic);
      nic->setParent(s);
      nic->setTrack(4);
      score->undoAddElement(nic);
      score->doLayout();
      test_post(score, "copy");
      }
Beispiel #19
0
void TestNote::grace()
      {
      MasterScore* score = readScore(DIR + "grace.mscx");
      score->doLayout();
      Ms::Chord* chord = score->firstMeasure()->findChord(0, 0);
      Note* note = chord->upNote();

      // create
      score->setGraceNote(chord, note->pitch(), NoteType::APPOGGIATURA, MScore::division/2);
      Ms::Chord* gc = chord->graceNotes().first();
      Note* gn = gc->notes().front();
//      Note* n = static_cast<Note*>(writeReadElement(gn));
//      QCOMPARE(n->noteType(), NoteType::APPOGGIATURA);
//      delete n;

      // tie
      score->select(gn);
      score->cmdAddTie();
//      n = static_cast<Note*>(writeReadElement(gn));
//      QVERIFY(n->tieFor() != 0);
//      delete n;

      // tremolo
      score->startCmd();
      Tremolo* tr = new Tremolo(score);
      tr->setTremoloType(TremoloType::R16);
      tr->setParent(gc);
      tr->setTrack(gc->track());
      score->undoAddElement(tr);
      score->endCmd();
//      Ms::Chord* c = static_cast<Ms::Chord*>(writeReadElement(gc));
//      QVERIFY(c->tremolo() != 0);
//      delete c;

      // articulation
      score->startCmd();
      Articulation* ar = new Articulation(SymId::articAccentAbove, score);
      ar->setParent(gc);
      ar->setTrack(gc->track());
      score->undoAddElement(ar);
      score->endCmd();
//      c = static_cast<Ms::Chord*>(writeReadElement(gc));
//      QVERIFY(c->articulations().size() == 1);
//      delete c;

      QVERIFY(saveCompareScore(score, "grace-test.mscx", DIR + "grace-ref.mscx"));
      }
Beispiel #20
0
void TestBarline::deleteSkipBarlines()
      {
      MasterScore* score = readScore(DIR + "barlinedelete.mscx");

      Measure* m1 = score->firstMeasure();
      QVERIFY(m1);

      score->startCmd();
      score->cmdSelectAll();
      score->cmdDeleteSelection();
      score->endCmd();

      score->doLayout();

      QVERIFY(saveCompareScore(score, QString("barlinedelete.mscx"),
         DIR + QString("barlinedelete-ref.mscx")));
      delete score;
      }
Beispiel #21
0
void TestSpanners::spanners08()
{
    MasterScore* score = readScore(DIR + "lyricsline01.mscx");
    QVERIFY(score);
    score->doLayout();

    // verify initial LyricsLine setup
    System* sys = score->systems().at(0);
    QVERIFY(sys->spannerSegments().size() == 1);
    QVERIFY(score->unmanagedSpanners().size() == 1);

    // DELETE LYRICS
    Measure*    msr   = score->firstMeasure();
    QVERIFY(msr);
    Segment*    seg   = msr->findSegment(Segment::Type::ChordRest, 0);
    QVERIFY(seg);
    Ms::Chord*      chord = static_cast<Ms::Chord*>(seg->element(0));
    QVERIFY(chord && chord->type() == Element::Type::CHORD);
    QVERIFY(chord->lyrics().size() > 0);
    Lyrics*     lyr   = chord->lyrics(0, Element::Placement::BELOW);
    score->startCmd();
    score->undoRemoveElement(lyr);
    score->endCmd();

    // verify setup after deletion
    QVERIFY(sys->spannerSegments().size() == 0);
    QVERIFY(score->unmanagedSpanners().size() == 0);

    // save and verify score after deletion
    QVERIFY(saveCompareScore(score, "lyricsline01.mscx", DIR + "lyricsline01-ref.mscx"));

    // UNDO
    score->undoStack()->undo();
    score->doLayout();

    // verify setup after undo
    QVERIFY(sys->spannerSegments().size() == 1);
    QVERIFY(score->unmanagedSpanners().size() == 1);

    // save and verify score after undo
    QVERIFY(saveCompareScore(score, "lyricsline01.mscx", DIR + "lyricsline01.mscx"));
    delete score;
}
void TestInstrumentChange::testMixer()
      {
      MasterScore* score = test_pre("mixer");
      Measure* m = score->firstMeasure()->nextMeasure();
      Segment* s = m->first(Segment::Type::ChordRest);
      InstrumentChange* ic = static_cast<InstrumentChange*>(s->annotations()[0]);
      int idx = score->staff(0)->channel(s->tick(), 0);
      Channel* c = score->staff(0)->part()->instrument(s->tick())->channel(idx);
      MidiPatch* mp = new MidiPatch;
      mp->bank = 0;
      mp->drum = false;
      mp->name = "Viola";
      mp->prog = 41;
      mp->synti = "Fluid";
      score->startCmd();
      ic->setXmlText("Mixer Viola");
      score->undo(new ChangePatch(score, c, mp));
      score->endCmd();
      score->doLayout();
      test_post(score, "mixer");
      }
Beispiel #23
0
void TestSpanners::spanners12()
{
    MasterScore* score = readScore(DIR + "lyricsline05.mscx");
    QVERIFY(score);
    score->doLayout();

    // DELETE SECOND MEASURE AND VERIFY
    Measure*    msr   = score->firstMeasure();
    QVERIFY(msr);
    msr = msr->nextMeasure();
    QVERIFY(msr);
    score->startCmd();
    score->select(msr);
    score->cmdTimeDelete();
    score->endCmd();
    QVERIFY(saveCompareScore(score, "lyricsline05.mscx", DIR + "lyricsline05-ref.mscx"));

    // UNDO AND VERIFY
    score->undoStack()->undo();
    QVERIFY(saveCompareScore(score, "lyricsline05.mscx", DIR + "lyricsline05.mscx"));
    delete score;
}
Beispiel #24
0
void TestNote::tpcTranspose()
      {
      MasterScore* score = readScore(DIR + "tpc-transpose.mscx");

      score->startCmd();
      Measure* m = score->firstMeasure();
      score->select(m, SelectType::SINGLE, 0);
      score->changeAccidental(AccidentalType::FLAT);
      score->endCmd();

      score->startCmd();
      m = m->nextMeasure();
      score->select(m, SelectType::SINGLE, 0);
      score->upDown(false, UpDownMode::CHROMATIC);
      score->endCmd();

      score->startCmd();
      score->cmdConcertPitchChanged(true, true);
      score->endCmd();

      QVERIFY(saveCompareScore(score, "tpc-transpose-test.mscx", DIR + "tpc-transpose-ref.mscx"));

      }
Beispiel #25
0
void TestSpanners::spanners03()
{
    DropData    dropData;
    Glissando*  gliss;

    MasterScore* 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);
    Ms::Chord*      chord = static_cast<Ms::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
    Ms::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<Ms::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<Ms::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;
}
Beispiel #26
0
void TestLinks::test5LinkedParts_94911()
      {
      MCursor c;
      c.setTimeSig(Fraction(4,4));
      c.createScore("test");
      c.addPart("electric-guitar");
      c.move(0, 0);     // move to track 0 tick 0

      c.addKeySig(Key(1));
      c.addTimeSig(Fraction(4,4));
      c.addChord(60, TDuration(TDuration::DurationType::V_WHOLE));

      MasterScore* score = c.score();
      score->addText("title", "Title");
      score->doLayout();
      // delete chord
      Measure* m = score->firstMeasure();
      Segment* s = m->first(Segment::Type::ChordRest);
      Element* e = s->element(0);
      QVERIFY(e->type() == ElementType::CHORD);
      score->select(e);
      score->cmdDeleteSelection();
      e = s->element(0);
      QVERIFY(e->type() == ElementType::REST);
      QVERIFY(e->links() == nullptr);

      // create parts//
      score->startCmd();
      QList<Part*> parts;
      parts.append(score->parts().at(0));
      Score* nscore = new Score(score);
      Excerpt ex(score);
      ex.setPartScore(nscore);
      ex.setTitle("Guitar");
      ex.setParts(parts);
      Excerpt::createExcerpt(&ex);
      QVERIFY(nscore);
      score->undo(new AddExcerpt(&ex));
      score->endCmd();

      // we should have now 1 staff and 2 linked rests
      QVERIFY(score->staves().size() == 1);
      e = s->element(0);
      QVERIFY(e->type() == ElementType::REST);
      QVERIFY(e->links()->size() == 2);

      // add a linked staff
      score->startCmd();
      Staff* oStaff = score->staff(0);
      Staff* staff       = new Staff(score);
      staff->setPart(oStaff->part());
      score->undoInsertStaff(staff, 1);
      Excerpt::cloneStaff(oStaff, staff);
      score->endCmd();

      // we should have now 2 staves and 3 linked rests
      QCOMPARE(score->staves().size(), 2);
      QCOMPARE(nscore->staves().size(), 1);
      QVERIFY(score->staves()[0]->linkedStaves()->staves().size() == 3);
      e = s->element(0);
      QVERIFY(e->type() == ElementType::REST);
      QVERIFY(e->links()->size() == 3);
      e = s->element(4);
      QVERIFY(e->type() == ElementType::REST);
      QVERIFY(e->links()->size() == 3);
      QVERIFY(score->excerpts().size() == 1);

      // undo
      score->undoStack()->undo();
      // we should have now 1 staves and 2 linked rests
      QVERIFY(score->staves().size() == 1);
      QVERIFY(score->staves()[0]->linkedStaves()->staves().size() == 2);
      e = s->element(0);
      QVERIFY(e->type() == ElementType::REST);
      QVERIFY(e->links()->size() == 2);
      QVERIFY(score->excerpts().size() == 1);

      // redo
      score->undoStack()->redo();
      // we should have now 2 staves and 3 linked rests
      QVERIFY(score->staves().size() == 2);
      QVERIFY(score->staves()[0]->linkedStaves()->staves().size() == 3);
      e = s->element(0);
      QVERIFY(e->type() == ElementType::REST);
      QVERIFY(e->links()->size() == 3);
      e = s->element(4);
      QVERIFY(e->type() == ElementType::REST);
      QVERIFY(e->links()->size() == 3);
      QVERIFY(score->excerpts().size() == 1);
      }