2020-12-26 14:12:05 -08:00
|
|
|
// Copyright (c) FIRST and other WPILib contributors.
|
|
|
|
|
// Open Source Software; you can modify and/or share it under the terms of
|
|
|
|
|
// the WPILib BSD license file in the root directory of this project.
|
2019-08-25 23:55:59 -04:00
|
|
|
|
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 {};
|
|
|
|
|
|
2021-09-17 22:51:51 -07:00
|
|
|
TEST_F(NotifierCommandTest, NotifierCommandSchedule) {
|
2019-08-25 23:55:59 -04:00
|
|
|
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
|
|
|
}
|