2019-08-25 23:55:59 -04:00
|
|
|
/*----------------------------------------------------------------------------*/
|
2020-09-27 13:27:53 -07:00
|
|
|
/* Copyright (c) 2019-2020 FIRST. All Rights Reserved. */
|
2019-08-25 23:55:59 -04:00
|
|
|
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
|
|
|
|
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
|
|
|
|
/* the project. */
|
|
|
|
|
/*----------------------------------------------------------------------------*/
|
|
|
|
|
|
2020-09-27 13:27:53 -07:00
|
|
|
#include <frc/simulation/SimHooks.h>
|
|
|
|
|
|
2019-08-25 23:55:59 -04:00
|
|
|
#include "CommandTestBase.h"
|
|
|
|
|
#include "frc2/command/NotifierCommand.h"
|
|
|
|
|
|
|
|
|
|
using namespace frc2;
|
2020-09-27 13:27:53 -07:00
|
|
|
using namespace std::chrono_literals;
|
|
|
|
|
|
2019-08-25 23:55:59 -04:00
|
|
|
class NotifierCommandTest : public CommandTestBase {};
|
|
|
|
|
|
|
|
|
|
TEST_F(NotifierCommandTest, NotifierCommandScheduleTest) {
|
|
|
|
|
CommandScheduler scheduler = GetScheduler();
|
|
|
|
|
|
2020-09-27 13:27:53 -07:00
|
|
|
frc::sim::PauseTiming();
|
2019-08-25 23:55:59 -04:00
|
|
|
|
2020-09-27 13:27:53 -07:00
|
|
|
int counter = 0;
|
|
|
|
|
NotifierCommand command([&] { counter++; }, 0.01_s, {});
|
2019-08-25 23:55:59 -04:00
|
|
|
|
|
|
|
|
scheduler.Schedule(&command);
|
2020-09-27 13:27:53 -07:00
|
|
|
for (int i = 0; i < 5; ++i) {
|
|
|
|
|
frc::sim::StepTiming(0.005_s);
|
|
|
|
|
}
|
2019-08-25 23:55:59 -04:00
|
|
|
scheduler.Cancel(&command);
|
|
|
|
|
|
2020-09-27 13:27:53 -07:00
|
|
|
frc::sim::ResumeTiming();
|
|
|
|
|
|
|
|
|
|
EXPECT_EQ(counter, 2);
|
2019-08-25 23:55:59 -04:00
|
|
|
}
|