Skip to content

Commit

Permalink
Added test cases for the loopsize / beatjumpsize range check
Browse files Browse the repository at this point in the history
  • Loading branch information
JoergAtGithub committed Feb 6, 2023
1 parent 8f35f9b commit 28d705d
Showing 1 changed file with 84 additions and 0 deletions.
84 changes: 84 additions & 0 deletions src/test/looping_control_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ class LoopingControlTest : public MockedEngineBackendTest {
m_pButtonBeatLoopActivate = std::make_unique<PollingControlProxy>(
m_sGroup1, "beatloop_activate");
m_pBeatJumpSize = std::make_unique<PollingControlProxy>(m_sGroup1, "beatjump_size");
m_pButtonBeatJumpSizeDouble = std::make_unique<PollingControlProxy>(
m_sGroup1, "beatjump_size_double");
m_pButtonBeatJumpSizeHalve = std::make_unique<PollingControlProxy>(
m_sGroup1, "beatjump_size_halve");
m_pButtonBeatJumpForward = std::make_unique<PollingControlProxy>(
m_sGroup1, "beatjump_forward");
m_pButtonBeatJumpBackward = std::make_unique<PollingControlProxy>(
Expand Down Expand Up @@ -121,6 +125,8 @@ class LoopingControlTest : public MockedEngineBackendTest {
std::unique_ptr<PollingControlProxy> m_pBeatLoopSize;
std::unique_ptr<PollingControlProxy> m_pButtonBeatLoopActivate;
std::unique_ptr<PollingControlProxy> m_pBeatJumpSize;
std::unique_ptr<PollingControlProxy> m_pButtonBeatJumpSizeHalve;
std::unique_ptr<PollingControlProxy> m_pButtonBeatJumpSizeDouble;
std::unique_ptr<PollingControlProxy> m_pButtonBeatJumpForward;
std::unique_ptr<PollingControlProxy> m_pButtonBeatJumpBackward;
std::unique_ptr<PollingControlProxy> m_pButtonBeatLoopRoll1Activate;
Expand Down Expand Up @@ -712,6 +718,45 @@ TEST_F(LoopingControlTest, BeatLoopSize_IsSetByNumberedControl) {
EXPECT_EQ(2.0, m_pBeatLoopSize->get());
}

TEST_F(LoopingControlTest, BeatLoopSize_SetRangeCheck) {
m_pBeatLoopSize->set(512.0);
EXPECT_EQ(512, m_pBeatLoopSize->get());

m_pBeatLoopSize->set(150.0);
EXPECT_EQ(150, m_pBeatLoopSize->get());

m_pBeatLoopSize->set(513.0);
EXPECT_EQ(150, m_pBeatLoopSize->get());

m_pButtonLoopDouble->set(1.0);
m_pButtonLoopDouble->set(0.0);
EXPECT_EQ(300.0, m_pBeatLoopSize->get());

m_pButtonLoopDouble->set(1.0);
m_pButtonLoopDouble->set(0.0);
EXPECT_EQ(300.0, m_pBeatLoopSize->get());

m_pBeatLoopSize->set(1 / 32.0);
EXPECT_EQ(1 / 32.0, m_pBeatLoopSize->get());

m_pBeatLoopSize->set(1 / 10.0);
EXPECT_EQ(1 / 10.0, m_pBeatLoopSize->get());

m_pBeatLoopSize->set(1 / 33.0);
EXPECT_EQ(1 / 10.0, m_pBeatLoopSize->get());

m_pBeatLoopSize->set(0);
EXPECT_EQ(1 / 10.0, m_pBeatLoopSize->get());

m_pButtonLoopHalve->set(1.0);
m_pButtonLoopHalve->set(0.0);
EXPECT_EQ(1 / 20.0, m_pBeatLoopSize->get());

m_pButtonLoopHalve->set(1.0);
m_pButtonLoopHalve->set(0.0);
EXPECT_EQ(1 / 20.0, m_pBeatLoopSize->get());
}

TEST_F(LoopingControlTest, BeatLoopSize_SetDoesNotStartLoop) {
m_pTrack1->trySetBpm(120.0);
m_pBeatLoopSize->set(16.0);
Expand Down Expand Up @@ -814,6 +859,45 @@ TEST_F(LoopingControlTest, LegacyBeatLoopControl) {
EXPECT_EQ(6.0, m_pBeatLoopSize->get());
}

TEST_F(LoopingControlTest, BeatjumpSize_SetRangeCheck) {
m_pBeatJumpSize->set(512.0);
EXPECT_EQ(512, m_pBeatJumpSize->get());

m_pBeatJumpSize->set(150.0);
EXPECT_EQ(150, m_pBeatJumpSize->get());

m_pBeatJumpSize->set(513.0);
EXPECT_EQ(150, m_pBeatJumpSize->get());

m_pButtonBeatJumpSizeDouble->set(1.0);
m_pButtonBeatJumpSizeDouble->set(0.0);
EXPECT_EQ(300.0, m_pBeatJumpSize->get());

m_pButtonBeatJumpSizeDouble->set(1.0);
m_pButtonBeatJumpSizeDouble->set(0.0);
EXPECT_EQ(300.0, m_pBeatJumpSize->get());

m_pBeatJumpSize->set(1 / 32.0);
EXPECT_EQ(1 / 32.0, m_pBeatJumpSize->get());

m_pBeatJumpSize->set(1 / 10.0);
EXPECT_EQ(1 / 10.0, m_pBeatJumpSize->get());

m_pBeatJumpSize->set(1 / 33.0);
EXPECT_EQ(1 / 10.0, m_pBeatJumpSize->get());

m_pBeatJumpSize->set(0);
EXPECT_EQ(1 / 10.0, m_pBeatJumpSize->get());

m_pButtonBeatJumpSizeHalve->set(1.0);
m_pButtonBeatJumpSizeHalve->set(0.0);
EXPECT_EQ(1 / 20.0, m_pBeatJumpSize->get());

m_pButtonBeatJumpSizeHalve->set(1.0);
m_pButtonBeatJumpSizeHalve->set(0.0);
EXPECT_EQ(1 / 20.0, m_pBeatJumpSize->get());
}

TEST_F(LoopingControlTest, Beatjump_JumpsByBeats) {
const auto bpm = mixxx::Bpm{120};
m_pTrack1->trySetBpm(bpm);
Expand Down

0 comments on commit 28d705d

Please sign in to comment.