2020-12-26 14:12:05 -08: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.
|
2019-08-25 17:47:07 -04:00
|
|
|
|
2025-11-07 19:55:43 -05:00
|
|
|
package org.wpilib.command2;
|
2019-08-25 17:47:07 -04:00
|
|
|
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertFalse;
|
|
|
|
|
import static org.junit.jupiter.api.Assertions.assertTrue;
|
|
|
|
|
|
2022-06-07 03:13:11 +03:00
|
|
|
import java.util.concurrent.atomic.AtomicBoolean;
|
2020-12-29 22:45:16 -08:00
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
|
|
2019-08-25 17:47:07 -04:00
|
|
|
class WaitUntilCommandTest extends CommandTestBase {
|
|
|
|
|
@Test
|
|
|
|
|
void waitUntilTest() {
|
2020-07-24 13:07:11 -07:00
|
|
|
try (CommandScheduler scheduler = new CommandScheduler()) {
|
2022-06-07 03:13:11 +03:00
|
|
|
AtomicBoolean condition = new AtomicBoolean();
|
2019-08-25 17:47:07 -04:00
|
|
|
|
2022-06-07 03:13:11 +03:00
|
|
|
Command command = new WaitUntilCommand(condition::get);
|
2019-08-25 17:47:07 -04:00
|
|
|
|
2020-07-24 13:07:11 -07:00
|
|
|
scheduler.schedule(command);
|
|
|
|
|
scheduler.run();
|
|
|
|
|
assertTrue(scheduler.isScheduled(command));
|
2022-06-07 03:13:11 +03:00
|
|
|
condition.set(true);
|
2020-07-24 13:07:11 -07:00
|
|
|
scheduler.run();
|
|
|
|
|
assertFalse(scheduler.isScheduled(command));
|
|
|
|
|
}
|
2019-08-25 17:47:07 -04:00
|
|
|
}
|
|
|
|
|
}
|