[commands] Revamp Interruptible (#4192)

This commit is contained in:
Starlight220
2022-08-30 07:53:47 +03:00
committed by GitHub
parent f2a8d38d2a
commit c3a93fb995
26 changed files with 369 additions and 592 deletions

View File

@@ -10,6 +10,7 @@
#include <frc/simulation/DriverStationSim.h>
#include "frc2/command/CommandGroupBase.h"
#include "frc2/command/CommandHelper.h"
#include "frc2/command/CommandScheduler.h"
#include "frc2/command/SetUtilities.h"
#include "frc2/command/SubsystemBase.h"
@@ -26,7 +27,10 @@ class CommandTestBase : public ::testing::Test {
class TestSubsystem : public SubsystemBase {};
protected:
class MockCommand : public Command {
/**
* NOTE: Moving mock objects causes EXPECT_CALL to not work correctly!
*/
class MockCommand : public CommandHelper<CommandBase, MockCommand> {
public:
MOCK_CONST_METHOD0(GetRequirements, wpi::SmallSet<Subsystem*, 4>());
MOCK_METHOD0(IsFinished, bool());
@@ -65,7 +69,7 @@ class CommandTestBase : public ::testing::Test {
.WillRepeatedly(::testing::Return(m_requirements));
}
MockCommand(const MockCommand& other) : Command{other} {}
MockCommand(const MockCommand& other) : CommandHelper{other} {}
void SetFinished(bool finished) {
EXPECT_CALL(*this, IsFinished())
@@ -77,11 +81,6 @@ class CommandTestBase : public ::testing::Test {
scheduler.Cancel(this);
}
protected:
std::unique_ptr<Command> TransferOwnership() && { // NOLINT
return std::make_unique<MockCommand>(std::move(*this));
}
private:
wpi::SmallSet<Subsystem*, 4> m_requirements;
};