mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
[commands] Add property tests for command compositions (#4715)
This commit is contained in:
@@ -69,6 +69,10 @@ class SelectCommand : public CommandHelper<CommandBase, SelectCommand<Key>> {
|
||||
for (auto&& command : foo) {
|
||||
this->AddRequirements(command.second->GetRequirements());
|
||||
m_runsWhenDisabled &= command.second->RunsWhenDisabled();
|
||||
if (command.second->GetInterruptionBehavior() ==
|
||||
Command::InterruptionBehavior::kCancelSelf) {
|
||||
m_interruptBehavior = Command::InterruptionBehavior::kCancelSelf;
|
||||
}
|
||||
m_commands.emplace(std::move(command.first), std::move(command.second));
|
||||
}
|
||||
}
|
||||
@@ -86,6 +90,10 @@ class SelectCommand : public CommandHelper<CommandBase, SelectCommand<Key>> {
|
||||
for (auto&& command : commands) {
|
||||
this->AddRequirements(command.second->GetRequirements());
|
||||
m_runsWhenDisabled &= command.second->RunsWhenDisabled();
|
||||
if (command.second->GetInterruptionBehavior() ==
|
||||
Command::InterruptionBehavior::kCancelSelf) {
|
||||
m_interruptBehavior = Command::InterruptionBehavior::kCancelSelf;
|
||||
}
|
||||
m_commands.emplace(std::move(command.first), std::move(command.second));
|
||||
}
|
||||
}
|
||||
@@ -118,6 +126,10 @@ class SelectCommand : public CommandHelper<CommandBase, SelectCommand<Key>> {
|
||||
|
||||
bool RunsWhenDisabled() const override { return m_runsWhenDisabled; }
|
||||
|
||||
Command::InterruptionBehavior GetInterruptionBehavior() const override {
|
||||
return m_interruptBehavior;
|
||||
}
|
||||
|
||||
protected:
|
||||
std::unique_ptr<Command> TransferOwnership() && override {
|
||||
return std::make_unique<SelectCommand>(std::move(*this));
|
||||
@@ -129,6 +141,8 @@ class SelectCommand : public CommandHelper<CommandBase, SelectCommand<Key>> {
|
||||
std::function<Command*()> m_toRun;
|
||||
Command* m_selectedCommand;
|
||||
bool m_runsWhenDisabled = true;
|
||||
Command::InterruptionBehavior m_interruptBehavior{
|
||||
Command::InterruptionBehavior::kCancelIncoming};
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
|
||||
Reference in New Issue
Block a user