mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-24 01:31:46 +00:00
[wpilib] Reduce usage of NTSendable (#5434)
This commit is contained in:
@@ -11,6 +11,8 @@ import static org.mockito.Mockito.never;
|
||||
import static org.mockito.Mockito.times;
|
||||
import static org.mockito.Mockito.verify;
|
||||
|
||||
import edu.wpi.first.networktables.NetworkTableInstance;
|
||||
import edu.wpi.first.wpilibj.smartdashboard.SmartDashboard;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
class CommandScheduleTest extends CommandTestBase {
|
||||
@@ -116,4 +118,27 @@ class CommandScheduleTest extends CommandTestBase {
|
||||
assertDoesNotThrow(() -> scheduler.cancel(mockCommand));
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void smartDashboardCancelTest() {
|
||||
try (CommandScheduler scheduler = new CommandScheduler();
|
||||
var inst = NetworkTableInstance.create()) {
|
||||
SmartDashboard.setNetworkTableInstance(inst);
|
||||
SmartDashboard.putData("Scheduler", scheduler);
|
||||
SmartDashboard.updateValues();
|
||||
|
||||
MockCommandHolder holder = new MockCommandHolder(true);
|
||||
Command mockCommand = holder.getMock();
|
||||
scheduler.schedule(mockCommand);
|
||||
scheduler.run();
|
||||
SmartDashboard.updateValues();
|
||||
assertTrue(scheduler.isScheduled(mockCommand));
|
||||
|
||||
var table = inst.getTable("SmartDashboard");
|
||||
table.getEntry("Scheduler/Cancel").setIntegerArray(new long[] {mockCommand.hashCode()});
|
||||
SmartDashboard.updateValues();
|
||||
scheduler.run();
|
||||
assertFalse(scheduler.isScheduled(mockCommand));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user