Skip to content

Commit

Permalink
Addes the test SoftTakeoverTest, CatchOutOfBounds
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Oct 15, 2023
1 parent 00a6646 commit 425ec59
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions src/test/softtakeover_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 edirection 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

Expand Down

0 comments on commit 425ec59

Please sign in to comment.