mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
[commands] Move GroupedCommands to CommandScheduler (#4728)
Move the command group checking functionality from CommandGroupBase into CommandScheduler. Update references to grouping as composition for clarity (because explicitly grouping isn't the only way to do it). Deprecate the static factory methods parallel, race, and deadline in CommandGroupBase in favor of the identical ones in Commands.
This commit is contained in:
@@ -24,16 +24,15 @@ class CommandGroupErrorTest extends CommandTestBase {
|
||||
|
||||
@Test
|
||||
void commandInGroupExternallyScheduledTest() {
|
||||
try (CommandScheduler scheduler = new CommandScheduler()) {
|
||||
MockCommandHolder command1Holder = new MockCommandHolder(true);
|
||||
Command command1 = command1Holder.getMock();
|
||||
MockCommandHolder command2Holder = new MockCommandHolder(true);
|
||||
Command command2 = command2Holder.getMock();
|
||||
MockCommandHolder command1Holder = new MockCommandHolder(true);
|
||||
Command command1 = command1Holder.getMock();
|
||||
MockCommandHolder command2Holder = new MockCommandHolder(true);
|
||||
Command command2 = command2Holder.getMock();
|
||||
|
||||
new ParallelCommandGroup(command1, command2);
|
||||
new ParallelCommandGroup(command1, command2);
|
||||
|
||||
assertThrows(IllegalArgumentException.class, () -> scheduler.schedule(command1));
|
||||
}
|
||||
assertThrows(
|
||||
IllegalArgumentException.class, () -> CommandScheduler.getInstance().schedule(command1));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -42,7 +41,7 @@ class CommandGroupErrorTest extends CommandTestBase {
|
||||
|
||||
assertDoesNotThrow(() -> command.withTimeout(10).until(() -> false));
|
||||
assertThrows(IllegalArgumentException.class, () -> command.withTimeout(10));
|
||||
CommandGroupBase.clearGroupedCommand(command);
|
||||
CommandScheduler.getInstance().removeComposedCommand(command);
|
||||
assertDoesNotThrow(() -> command.withTimeout(10));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class CommandTestBase {
|
||||
CommandScheduler.getInstance().cancelAll();
|
||||
CommandScheduler.getInstance().enable();
|
||||
CommandScheduler.getInstance().getActiveButtonLoop().clear();
|
||||
CommandGroupBase.clearGroupedCommands();
|
||||
CommandScheduler.getInstance().clearComposedCommands();
|
||||
|
||||
setDSEnabled(true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user