Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addes the test SoftTakeoverTest.CatchOutOfBounds #12114

Merged
merged 1 commit into from
Nov 12, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 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

Expand Down
Loading