From 8e9d4d0dc8f9a60353497f64c710f988685e21db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= <daschuer@mixxx.org> Date: Sun, 15 Oct 2023 07:42:00 +0200 Subject: [PATCH] Addes the test SoftTakeoverTest, CatchOutOfBounds --- src/test/softtakeover_test.cpp | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/test/softtakeover_test.cpp b/src/test/softtakeover_test.cpp index cc52ad4a14d..d481cece6d3 100644 --- a/src/test/softtakeover_test.cpp +++ b/src/test/softtakeover_test.cpp @@ -562,6 +562,32 @@ TEST_F(SoftTakeoverTest, PrevFarMore_NewFarMore_Late) { EXPECT_TRUE(st_control.ignore(co.get(), co->getParameterForValue(100))); } +TEST_F(SoftTakeoverTest, CatchOutOfBounds) { + auto co = std::make_unique<ControlPotmeter>( + ConfigKey("[Channel1]", "test_pot"), -250, 250, true); + + co->set(50); + SoftTakeoverCtrl st_control; + st_control.enable(co.get()); + + // First is always ignored. + EXPECT_TRUE(st_control.ignore(co.get(), co->getParameterForValue(45))); + // Cross the original value to take over + EXPECT_FALSE(st_control.ignore(co.get(), co->getParameterForValue(55))); + + // Set value to an out of bounds value + co->set(300); + mixxx::Time::setTestElapsedTime(SoftTakeover::TestAccess::getTimeThreshold() * 2); + // Actions in the same direction shall be ignored + EXPECT_TRUE(st_control.ignore(co.get(), co->getParameterForValue(60))); + // actions in the other edirection shall be ignored + EXPECT_TRUE(st_control.ignore(co.get(), co->getParameterForValue(40))); + // reaching the lower border should be ignored + EXPECT_TRUE(st_control.ignore(co.get(), co->getParameterForValue(-250))); + // reaching the upper border near the out of bounds value should not be ignored. + EXPECT_FALSE(st_control.ignore(co.get(), co->getParameterForValue(250))); +} + // For the ignore cases, check that they work correctly with various signed values // TODO