Skip to content

Commit

Permalink
Test: add SetLoopAutoNoRedundantLoopCue
Browse files Browse the repository at this point in the history
  • Loading branch information
ronso0 committed Jan 26, 2024
1 parent 11ec4b5 commit 18d9af4
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/test/hotcuecontrol_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ class HotcueControlTest : public BaseSignalPathTest {
m_pHotcue1EndPosition = std::make_unique<ControlProxy>(m_sGroup1, "hotcue_1_endposition");
m_pHotcue1Enabled = std::make_unique<ControlProxy>(m_sGroup1, "hotcue_1_enabled");
m_pHotcue1Clear = std::make_unique<ControlProxy>(m_sGroup1, "hotcue_1_clear");
m_pHotcue2Activate = std::make_unique<ControlProxy>(m_sGroup1, "hotcue_2_activate");
m_pHotcue2Enabled = std::make_unique<ControlProxy>(m_sGroup1, "hotcue_2_enabled");
m_pHotcue2Position = std::make_unique<ControlProxy>(m_sGroup1, "hotcue_2_position");
m_pHotcue2EndPosition = std::make_unique<ControlProxy>(m_sGroup1, "hotcue_2_endposition");
m_pQuantizeEnabled = std::make_unique<ControlProxy>(m_sGroup1, "quantize");
}

Expand Down Expand Up @@ -110,6 +114,10 @@ class HotcueControlTest : public BaseSignalPathTest {
std::unique_ptr<ControlProxy> m_pHotcue1EndPosition;
std::unique_ptr<ControlProxy> m_pHotcue1Enabled;
std::unique_ptr<ControlProxy> m_pHotcue1Clear;
std::unique_ptr<ControlProxy> m_pHotcue2Activate;
std::unique_ptr<ControlProxy> m_pHotcue2Enabled;
std::unique_ptr<ControlProxy> m_pHotcue2Position;
std::unique_ptr<ControlProxy> m_pHotcue2EndPosition;
std::unique_ptr<ControlProxy> m_pQuantizeEnabled;
};

Expand Down Expand Up @@ -272,6 +280,38 @@ TEST_F(HotcueControlTest, SetLoopAuto) {
EXPECT_FRAMEPOS_EQ_CONTROL(loopEndPosition, m_pHotcue1EndPosition);
}

TEST_F(HotcueControlTest, SetLoopAutoNoRedundantLoopCue) {
createAndLoadFakeTrack();

EXPECT_DOUBLE_EQ(static_cast<double>(HotcueControl::Status::Empty), m_pHotcue1Enabled->get());
EXPECT_FALSE(mixxx::audio::FramePos::fromEngineSamplePosMaybeInvalid(
m_pHotcue1Position->get())
.isValid());
EXPECT_FALSE(mixxx::audio::FramePos::fromEngineSamplePosMaybeInvalid(
m_pHotcue1EndPosition->get())
.isValid());

constexpr mixxx::audio::FramePos loopStartPosition(100);
constexpr mixxx::audio::FramePos loopEndPosition(200);
m_pChannel1->getEngineBuffer()->setLoop(loopStartPosition, loopEndPosition, true);

m_pHotcue1Set->set(1);
m_pHotcue1Set->set(0);
EXPECT_DOUBLE_EQ(static_cast<double>(HotcueControl::Status::Active), m_pHotcue1Enabled->get());
EXPECT_FRAMEPOS_EQ_CONTROL(loopStartPosition, m_pHotcue1Position);
EXPECT_FRAMEPOS_EQ_CONTROL(loopEndPosition, m_pHotcue1EndPosition);

// setting another hotcue should create a regular hotcue,
// not a redundant loop cue.
m_pHotcue2Activate->set(1);
m_pHotcue2Activate->set(0);
EXPECT_DOUBLE_EQ(static_cast<double>(HotcueControl::Status::Active), m_pHotcue2Enabled->get());
EXPECT_FRAMEPOS_EQ_CONTROL(loopStartPosition, m_pHotcue2Position);
EXPECT_FALSE(mixxx::audio::FramePos::fromEngineSamplePosMaybeInvalid(
m_pHotcue2EndPosition->get())
.isValid());
}

TEST_F(HotcueControlTest, SetLoopManualWithLoop) {
createAndLoadFakeTrack();

Expand Down

0 comments on commit 18d9af4

Please sign in to comment.