2023-11-14 17:54:43 -06: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.
|
|
|
|
|
|
2025-11-07 19:56:21 -05:00
|
|
|
#include "wpi/commands2/button/RobotModeTriggers.hpp"
|
2025-11-11 18:05:12 -08:00
|
|
|
|
|
|
|
|
#include "../CommandTestBase.hpp"
|
2025-11-07 19:56:21 -05:00
|
|
|
#include "wpi/commands2/button/Trigger.hpp"
|
2025-11-07 19:57:55 -05:00
|
|
|
#include "wpi/driverstation/DriverStation.hpp"
|
2025-12-12 21:25:57 -07:00
|
|
|
#include "wpi/hal/DriverStationTypes.h"
|
2025-11-07 19:57:55 -05:00
|
|
|
#include "wpi/simulation/DriverStationSim.hpp"
|
2023-11-14 17:54:43 -06:00
|
|
|
|
2025-11-07 20:00:05 -05:00
|
|
|
using namespace wpi::cmd;
|
|
|
|
|
using namespace wpi::sim;
|
2023-11-14 17:54:43 -06:00
|
|
|
class RobotModeTriggersTest : public CommandTestBase {};
|
|
|
|
|
|
|
|
|
|
TEST(RobotModeTriggersTest, Autonomous) {
|
|
|
|
|
DriverStationSim::ResetData();
|
2026-03-13 01:04:29 -07:00
|
|
|
DriverStationSim::SetRobotMode(HAL_ROBOT_MODE_AUTONOMOUS);
|
2023-11-14 17:54:43 -06:00
|
|
|
DriverStationSim::SetEnabled(true);
|
2024-02-18 14:30:40 -08:00
|
|
|
DriverStationSim::NotifyNewData();
|
2023-11-14 17:54:43 -06:00
|
|
|
Trigger autonomous = RobotModeTriggers::Autonomous();
|
|
|
|
|
EXPECT_TRUE(autonomous.Get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(RobotModeTriggersTest, Teleop) {
|
|
|
|
|
DriverStationSim::ResetData();
|
2026-03-13 01:04:29 -07:00
|
|
|
DriverStationSim::SetRobotMode(HAL_ROBOT_MODE_TELEOPERATED);
|
2023-11-14 17:54:43 -06:00
|
|
|
DriverStationSim::SetEnabled(true);
|
2024-02-18 14:30:40 -08:00
|
|
|
DriverStationSim::NotifyNewData();
|
2023-11-14 17:54:43 -06:00
|
|
|
Trigger teleop = RobotModeTriggers::Teleop();
|
|
|
|
|
EXPECT_TRUE(teleop.Get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(RobotModeTriggersTest, Disabled) {
|
|
|
|
|
DriverStationSim::ResetData();
|
|
|
|
|
DriverStationSim::SetEnabled(false);
|
2024-02-18 14:30:40 -08:00
|
|
|
DriverStationSim::NotifyNewData();
|
2023-11-14 17:54:43 -06:00
|
|
|
Trigger disabled = RobotModeTriggers::Disabled();
|
|
|
|
|
EXPECT_TRUE(disabled.Get());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
TEST(RobotModeTriggersTest, TestMode) {
|
|
|
|
|
DriverStationSim::ResetData();
|
2026-03-13 01:04:29 -07:00
|
|
|
DriverStationSim::SetRobotMode(HAL_ROBOT_MODE_TEST);
|
2023-11-14 17:54:43 -06:00
|
|
|
DriverStationSim::SetEnabled(true);
|
2024-02-18 14:30:40 -08:00
|
|
|
DriverStationSim::NotifyNewData();
|
2023-11-14 17:54:43 -06:00
|
|
|
Trigger test = RobotModeTriggers::Test();
|
|
|
|
|
EXPECT_TRUE(test.Get());
|
|
|
|
|
}
|