Skip to content

Commit

Permalink
Fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sakertooth committed Nov 25, 2024
1 parent e34e2c9 commit 1c68859
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion tests/src/tracks/AutomationTrackTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,23 +95,31 @@ private slots:

auto song = Engine::getSong();
AutomationTrack track(song);
song->addTrack(&track);

AutomationClip c1(&track);
track.addClip(&c1);

c1.setProgressionType(AutomationClip::ProgressionType::Linear);
c1.putValue(0, 0.0, false);
c1.putValue(10, 1.0, false);
c1.movePosition(0);
c1.addObject(&model);

AutomationClip c2(&track);
track.addClip(&c2);

c2.setProgressionType(AutomationClip::ProgressionType::Linear);
c2.putValue(0, 0.0, false);
c2.putValue(100, 1.0, false);
c2.movePosition(100);
c2.addObject(&model);

AutomationClip c3(&track);
track.addClip(&c3);

c3.addObject(&model);

//XXX: Why is this even necessary?
c3.clear();

Expand All @@ -130,9 +138,13 @@ private slots:
FloatModel model;

auto song = Engine::getSong();

AutomationTrack track(song);
song->addTrack(&track);

AutomationClip c(&track);
track.addClip(&c);

c.setProgressionType(AutomationClip::ProgressionType::Linear);
c.addObject(&model);

Expand All @@ -157,9 +169,13 @@ private slots:
auto song = Engine::getSong();

InstrumentTrack instrumentTrack(song);
song->addTrack(&instrumentTrack);

MidiClip midiClip(&instrumentTrack);
instrumentTrack.addClip(&midiClip);

midiClip.changeLength(TimePos(4, 0));

Note* note = midiClip.addNote(Note(TimePos(4, 0)), false);
note->createDetuning();

Expand All @@ -181,8 +197,13 @@ private slots:

auto song = Engine::getSong();
auto patternStore = Engine::patternStore();

PatternTrack patternTrack(song);
song->addTrack(&patternTrack);

AutomationTrack automationTrack(patternStore);
patternStore->addTrack(&automationTrack);

automationTrack.createClipsForPattern(patternStore->numOfPatterns() - 1);

QVERIFY(automationTrack.numOfClips());
Expand All @@ -202,11 +223,14 @@ private slots:
QCOMPARE(patternStore->automatedValuesAt(50, patternTrack.patternIndex())[&model], 1.0f);

PatternTrack patternTrack2(song);
song->addTrack(&patternTrack2);

QCOMPARE(patternStore->automatedValuesAt(5, patternTrack.patternIndex())[&model], 0.5f);
QVERIFY(! patternStore->automatedValuesAt(5, patternTrack2.patternIndex()).size());

PatternClip clip(&patternTrack);
patternTrack.addClip(&clip);

clip.changeLength(TimePos::ticksPerBar() * 2);
clip.movePosition(0);

Expand All @@ -222,12 +246,16 @@ private slots:
// Global automation should not have priority, see https://github.com/LMMS/lmms/issues/4268
// Tests regression caused by 75077f6200a5aee3a5821aae48a3b8466ed8714a
auto song = Engine::getSong();

auto globalTrack = song->globalAutomationTrack();

AutomationClip globalClip(globalTrack);
globalTrack->addClip(&globalClip);

AutomationTrack localTrack(song);
song->addTrack(&localTrack);

AutomationClip localClip(&localTrack);
localTrack.addClip(&localClip);

FloatModel model;
globalClip.setProgressionType(AutomationClip::ProgressionType::Discrete);
Expand Down

0 comments on commit 1c68859

Please sign in to comment.