diff --git a/src/test/looping_control_test.cpp b/src/test/looping_control_test.cpp index ef05bc79b1fc..0ed28d46fb0b 100644 --- a/src/test/looping_control_test.cpp +++ b/src/test/looping_control_test.cpp @@ -67,6 +67,10 @@ class LoopingControlTest : public MockedEngineBackendTest { m_pButtonBeatLoopActivate = std::make_unique( m_sGroup1, "beatloop_activate"); m_pBeatJumpSize = std::make_unique(m_sGroup1, "beatjump_size"); + m_pButtonBeatJumpSizeDouble = std::make_unique( + m_sGroup1, "beatjump_size_double"); + m_pButtonBeatJumpSizeHalve = std::make_unique( + m_sGroup1, "beatjump_size_halve"); m_pButtonBeatJumpForward = std::make_unique( m_sGroup1, "beatjump_forward"); m_pButtonBeatJumpBackward = std::make_unique( @@ -121,6 +125,8 @@ class LoopingControlTest : public MockedEngineBackendTest { std::unique_ptr m_pBeatLoopSize; std::unique_ptr m_pButtonBeatLoopActivate; std::unique_ptr m_pBeatJumpSize; + std::unique_ptr m_pButtonBeatJumpSizeHalve; + std::unique_ptr m_pButtonBeatJumpSizeDouble; std::unique_ptr m_pButtonBeatJumpForward; std::unique_ptr m_pButtonBeatJumpBackward; std::unique_ptr m_pButtonBeatLoopRoll1Activate; @@ -696,20 +702,43 @@ TEST_F(LoopingControlTest, BeatLoopSize_SetsNumberedControls) { EXPECT_TRUE(m_pLoopEnabled->toBool()); } -TEST_F(LoopingControlTest, BeatLoopSize_IsSetByNumberedControl) { - m_pTrack1->trySetBpm(120.0); - m_pBeatLoopSize->set(4.0); - m_pButtonBeatLoop2Activate->set(1.0); - m_pButtonBeatLoop2Activate->set(0.0); - EXPECT_TRUE(m_pBeatLoop2Enabled->toBool()); - EXPECT_TRUE(m_pLoopEnabled->toBool()); - EXPECT_EQ(2.0, m_pBeatLoopSize->get()); +TEST_F(LoopingControlTest, BeatLoopSize_SetRangeCheck) { + m_pBeatLoopSize->set(512.0); + EXPECT_EQ(512, m_pBeatLoopSize->get()); - m_pButtonBeatLoopActivate->set(1.0); - m_pButtonBeatLoopActivate->set(0.0); - EXPECT_FALSE(m_pBeatLoop2Enabled->toBool()); - EXPECT_FALSE(m_pLoopEnabled->toBool()); - EXPECT_EQ(2.0, 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) { @@ -814,6 +843,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);