mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[hal,tests] Use waitForProgramStart in tests (#8429)
Change setProgramStarted to accept a boolean so it can be set back to false by tests. This allows properly waiting for program start in tests.
This commit is contained in:
@@ -19,7 +19,10 @@ using namespace wpi;
|
||||
namespace {
|
||||
class TimesliceRobotTest : public ::testing::Test {
|
||||
protected:
|
||||
void SetUp() override { wpi::sim::PauseTiming(); }
|
||||
void SetUp() override {
|
||||
wpi::sim::PauseTiming();
|
||||
wpi::sim::SetProgramStarted(false);
|
||||
}
|
||||
|
||||
void TearDown() override { wpi::sim::ResumeTiming(); }
|
||||
};
|
||||
@@ -51,10 +54,10 @@ TEST_F(TimesliceRobotTest, Schedule) {
|
||||
robot.Schedule([&] { callbackCount2++; }, 1_ms);
|
||||
|
||||
std::thread robotThread{[&] { robot.StartCompetition(); }};
|
||||
wpi::sim::WaitForProgramStart();
|
||||
|
||||
wpi::sim::DriverStationSim::SetEnabled(false);
|
||||
wpi::sim::DriverStationSim::NotifyNewData();
|
||||
wpi::sim::StepTiming(0_ms); // Wait for Notifiers
|
||||
|
||||
// Functions scheduled with addPeriodic() are delayed by one period before
|
||||
// their first run (5 ms for this test's callbacks here and 20 ms for
|
||||
|
||||
Reference in New Issue
Block a user