mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-20 00:51:42 +00:00
Integrates tests for Commands
Change-Id: I972bdba167c9f305532067303b6faf1042940ab3
This commit is contained in:
@@ -34,7 +34,7 @@ public class MotorEncoderTest extends AbstractComsSetup {
|
||||
pairs.add(TestBench.getInstance().getTalonPair());
|
||||
pairs.add(TestBench.getInstance().getVictorPair());
|
||||
pairs.add(TestBench.getInstance().getJaguarPair());
|
||||
pairs.add(TestBench.getInstance().getCanJaguarPair());
|
||||
//pairs.add(TestBench.getInstance().getCanJaguarPair());
|
||||
|
||||
for(MotorEncoderFixture me : pairs){
|
||||
me.reset();
|
||||
@@ -47,7 +47,7 @@ public class MotorEncoderTest extends AbstractComsSetup {
|
||||
* @return true if this motor encoder has an encoder attached to it
|
||||
*/
|
||||
boolean shouldRunTest(MotorEncoderFixture me){
|
||||
return me.getType().equals(Victor.class.getSimpleName()) || me.getType().equals(Talon.class.getSimpleName());
|
||||
return true;//me.getType().equals(Victor.class.getSimpleName()) || me.getType().equals(Talon.class.getSimpleName());
|
||||
}
|
||||
|
||||
@Before
|
||||
|
||||
@@ -7,7 +7,10 @@
|
||||
package edu.wpi.first.wpilibj.command;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import edu.wpi.first.wpilibj.Timer;
|
||||
import static org.junit.Assert.fail;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
import edu.wpi.first.wpilibj.mocks.MockCommand;
|
||||
import edu.wpi.first.wpilibj.test.AbstractComsSetup;
|
||||
|
||||
@@ -16,8 +19,23 @@ import edu.wpi.first.wpilibj.test.AbstractComsSetup;
|
||||
*
|
||||
*/
|
||||
public abstract class AbstractCommandTest extends AbstractComsSetup {
|
||||
|
||||
@Before
|
||||
public void commandSetup(){
|
||||
Scheduler.getInstance().removeAll();
|
||||
Scheduler.getInstance().enable();
|
||||
}
|
||||
|
||||
public class ASubsystem extends Subsystem {
|
||||
Command command;
|
||||
protected void initDefaultCommand(){
|
||||
if(command != null){
|
||||
setDefaultCommand(command);
|
||||
}
|
||||
}
|
||||
|
||||
public void init(Command command) {
|
||||
this.command = command;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,6 +48,10 @@ public abstract class AbstractCommandTest extends AbstractComsSetup {
|
||||
}
|
||||
|
||||
public void sleep(int time){
|
||||
Timer.delay(time);
|
||||
try {
|
||||
Thread.sleep(time);
|
||||
} catch (InterruptedException ex) {
|
||||
fail("Sleep Interrupted!?!?!?!?");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,8 +18,9 @@ import edu.wpi.first.wpilibj.mocks.MockCommand;
|
||||
import edu.wpi.first.wpilibj.test.AbstractComsSetup;
|
||||
|
||||
/**
|
||||
* @author jonathanleitschuh
|
||||
*
|
||||
* Ported from the old CrioTest Classes
|
||||
* @author Mitchell
|
||||
* @author Jonathan Leitschuh
|
||||
*/
|
||||
public class CommandParallelGroupTest extends AbstractCommandTest {
|
||||
|
||||
|
||||
@@ -17,8 +17,9 @@ import org.junit.Test;
|
||||
import edu.wpi.first.wpilibj.mocks.MockCommand;
|
||||
|
||||
/**
|
||||
* @author jonathanleitschuh, mwills
|
||||
*
|
||||
* Ported from the old CrioTest Classes
|
||||
* @author Mitchell
|
||||
* @author Jonathan Leitschuh
|
||||
*/
|
||||
public class CommandScheduleTest extends AbstractCommandTest {
|
||||
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2008-2014. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
package edu.wpi.first.wpilibj.command;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
import edu.wpi.first.wpilibj.mocks.MockCommand;
|
||||
|
||||
/**
|
||||
* Ported from the old CrioTest Classes
|
||||
* @author Mitchell
|
||||
* @author Jonathan Leitschuh
|
||||
*/
|
||||
public class CommandSequentialGroupTest extends AbstractCommandTest {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(CommandSequentialGroupTest.class.getName());
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@BeforeClass
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@AfterClass
|
||||
public static void tearDownAfterClass() throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple Command Group With 3 commands that all depend on a subsystem. Some commands have a timeout
|
||||
*/
|
||||
//@Ignore("This currently hangs the tests, needs work")
|
||||
@Test(timeout = 20000)
|
||||
public void testThreeCommandOnSubSystem() {
|
||||
logger.fine("Begining Test");
|
||||
final ASubsystem subsystem = new ASubsystem();
|
||||
|
||||
logger.finest("Creating Mock Command1");
|
||||
MockCommand command1 = new MockCommand() {
|
||||
{
|
||||
requires(subsystem);
|
||||
}
|
||||
};
|
||||
logger.finest("Creating Mock Command2");
|
||||
MockCommand command2 = new MockCommand() {
|
||||
{
|
||||
requires(subsystem);
|
||||
}
|
||||
};
|
||||
logger.finest("Creating Mock Command3");
|
||||
MockCommand command3 = new MockCommand() {
|
||||
{
|
||||
requires(subsystem);
|
||||
}
|
||||
};
|
||||
|
||||
logger.finest("Creating Command Group");
|
||||
CommandGroup commandGroup = new CommandGroup();
|
||||
commandGroup.addSequential(command1, 1.0);
|
||||
commandGroup.addSequential(command2, 2.0);
|
||||
commandGroup.addSequential(command3);
|
||||
|
||||
|
||||
assertCommandState(command1, 0, 0, 0, 0, 0);
|
||||
assertCommandState(command2, 0, 0, 0, 0, 0);
|
||||
assertCommandState(command3, 0, 0, 0, 0, 0);
|
||||
logger.finest("Starting Command group");
|
||||
commandGroup.start();
|
||||
assertCommandState(command1, 0, 0, 0, 0, 0);
|
||||
assertCommandState(command2, 0, 0, 0, 0, 0);
|
||||
assertCommandState(command3, 0, 0, 0, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command1, 0, 0, 0, 0, 0);
|
||||
assertCommandState(command2, 0, 0, 0, 0, 0);
|
||||
assertCommandState(command3, 0, 0, 0, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command1, 1, 1, 1, 0, 0);
|
||||
assertCommandState(command2, 0, 0, 0, 0, 0);
|
||||
assertCommandState(command3, 0, 0, 0, 0, 0);
|
||||
sleep(1000);//command 1 timeout
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command1, 1, 1, 1, 0, 1);
|
||||
assertCommandState(command2, 1, 1, 1, 0, 0);
|
||||
assertCommandState(command3, 0, 0, 0, 0, 0);
|
||||
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command1, 1, 1, 1, 0, 1);
|
||||
assertCommandState(command2, 1, 2, 2, 0, 0);
|
||||
assertCommandState(command3, 0, 0, 0, 0, 0);
|
||||
sleep(2000);//command 2 timeout
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command1, 1, 1, 1, 0, 1);
|
||||
assertCommandState(command2, 1, 2, 2, 0, 1);
|
||||
assertCommandState(command3, 1, 1 ,1, 0, 0);
|
||||
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command1, 1, 1, 1, 0, 1);
|
||||
assertCommandState(command2, 1, 2, 2, 0, 1);
|
||||
assertCommandState(command3, 1, 2, 2, 0, 0);
|
||||
command3.setHasFinished(true);
|
||||
assertCommandState(command1, 1, 1, 1, 0, 1);
|
||||
assertCommandState(command2, 1, 2, 2, 0, 1);
|
||||
assertCommandState(command3, 1, 2, 2, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command1, 1, 1, 1, 0, 1);
|
||||
assertCommandState(command2, 1, 2, 2, 0, 1);
|
||||
assertCommandState(command3, 1, 3, 3, 1, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command1, 1, 1, 1, 0, 1);
|
||||
assertCommandState(command2, 1, 2, 2, 0, 1);
|
||||
assertCommandState(command3, 1, 3, 3, 1, 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2008-2014. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
package edu.wpi.first.wpilibj.command;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import edu.wpi.first.wpilibj.mocks.MockCommand;
|
||||
|
||||
/**
|
||||
* Ported from the old CrioTest Classes
|
||||
*
|
||||
* @author Mitchell
|
||||
* @author Jonathan Leitschuh
|
||||
*/
|
||||
public class CommandSupersedeTest extends AbstractCommandTest {
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@BeforeClass
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@AfterClass
|
||||
public static void tearDownAfterClass() throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing one command superseding another because of dependencies
|
||||
*/
|
||||
@Test
|
||||
public void testOneCommandSupersedingAnotherBecauseOfDependencies() {
|
||||
final ASubsystem subsystem = new ASubsystem();
|
||||
|
||||
MockCommand command1 = new MockCommand() {
|
||||
{
|
||||
requires(subsystem);
|
||||
}
|
||||
};
|
||||
|
||||
MockCommand command2 = new MockCommand() {
|
||||
{
|
||||
requires(subsystem);
|
||||
}
|
||||
};
|
||||
|
||||
assertCommandState(command1, 0, 0, 0, 0, 0);
|
||||
assertCommandState(command2, 0, 0, 0, 0, 0);
|
||||
command1.start();
|
||||
assertCommandState(command1, 0, 0, 0, 0, 0);
|
||||
assertCommandState(command2, 0, 0, 0, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command1, 0, 0, 0, 0, 0);
|
||||
assertCommandState(command2, 0, 0, 0, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command1, 1, 1, 1, 0, 0);
|
||||
assertCommandState(command2, 0, 0, 0, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command1, 1, 2, 2, 0, 0);
|
||||
assertCommandState(command2, 0, 0, 0, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command1, 1, 3, 3, 0, 0);
|
||||
assertCommandState(command2, 0, 0, 0, 0, 0);
|
||||
command2.start();
|
||||
assertCommandState(command1, 1, 3, 3, 0, 0);
|
||||
assertCommandState(command2, 0, 0, 0, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command1, 1, 4, 4, 0, 1);
|
||||
assertCommandState(command2, 0, 0, 0, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command1, 1, 4, 4, 0, 1);
|
||||
assertCommandState(command2, 1, 1, 1, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command1, 1, 4, 4, 0, 1);
|
||||
assertCommandState(command2, 1, 2, 2, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command1, 1, 4, 4, 0, 1);
|
||||
assertCommandState(command2, 1, 3, 3, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing one command failing superseding another because of dependencies
|
||||
* because the first command cannot be interrupted"
|
||||
*/
|
||||
@Test
|
||||
public void testCommandFailingSupersedingBecauseFirstCanNotBeInterrupted() {
|
||||
final ASubsystem subsystem = new ASubsystem();
|
||||
|
||||
MockCommand command1 = new MockCommand() {
|
||||
{
|
||||
requires(subsystem);
|
||||
setInterruptible(false);
|
||||
}
|
||||
};
|
||||
|
||||
MockCommand command2 = new MockCommand() {
|
||||
{
|
||||
requires(subsystem);
|
||||
}
|
||||
};
|
||||
|
||||
assertCommandState(command1, 0, 0, 0, 0, 0);
|
||||
assertCommandState(command2, 0, 0, 0, 0, 0);
|
||||
command1.start();
|
||||
assertCommandState(command1, 0, 0, 0, 0, 0);
|
||||
assertCommandState(command2, 0, 0, 0, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command1, 0, 0, 0, 0, 0);
|
||||
assertCommandState(command2, 0, 0, 0, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command1, 1, 1, 1, 0, 0);
|
||||
assertCommandState(command2, 0, 0, 0, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command1, 1, 2, 2, 0, 0);
|
||||
assertCommandState(command2, 0, 0, 0, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command1, 1, 3, 3, 0, 0);
|
||||
assertCommandState(command2, 0, 0, 0, 0, 0);
|
||||
command2.start();
|
||||
assertCommandState(command1, 1, 3, 3, 0, 0);
|
||||
assertCommandState(command2, 0, 0, 0, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command1, 1, 4, 4, 0, 0);
|
||||
assertCommandState(command2, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2008-2014. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
package edu.wpi.first.wpilibj.command;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import edu.wpi.first.wpilibj.mocks.MockCommand;
|
||||
|
||||
/**
|
||||
* @author jonathanleitschuh
|
||||
*
|
||||
*/
|
||||
public class CommandTimeoutTest extends AbstractCommandTest {
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@BeforeClass
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@AfterClass
|
||||
public static void tearDownAfterClass() throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* Command 2 second Timeout Test
|
||||
*/
|
||||
@Test
|
||||
public void testTwoSecondTimeout() {
|
||||
final ASubsystem subsystem = new ASubsystem();
|
||||
|
||||
|
||||
MockCommand command = new MockCommand() {
|
||||
{
|
||||
requires(subsystem);
|
||||
setTimeout(2);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFinished(){
|
||||
return super.isFinished() || isTimedOut();
|
||||
}
|
||||
};
|
||||
|
||||
command.start();
|
||||
assertCommandState(command, 0, 0, 0, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command, 0, 0, 0, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command, 1, 1, 1, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command, 1, 2, 2, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command, 1, 3, 3, 0, 0);
|
||||
sleep(2000);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command, 1, 4, 4, 1, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(command, 1, 4, 4, 1, 0);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,166 @@
|
||||
/*----------------------------------------------------------------------------*/
|
||||
/* Copyright (c) FIRST 2008-2014. All Rights Reserved. */
|
||||
/* Open Source Software - may be modified and shared by FRC teams. The code */
|
||||
/* must be accompanied by the FIRST BSD license file in the root directory of */
|
||||
/* the project. */
|
||||
/*----------------------------------------------------------------------------*/
|
||||
package edu.wpi.first.wpilibj.command;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import edu.wpi.first.wpilibj.mocks.MockCommand;
|
||||
|
||||
/**
|
||||
* @author jonathanleitschuh
|
||||
*
|
||||
*/
|
||||
public class DefaultCommandTest extends AbstractCommandTest {
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@BeforeClass
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@AfterClass
|
||||
public static void tearDownAfterClass() throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* @throws java.lang.Exception
|
||||
*/
|
||||
@After
|
||||
public void tearDown() throws Exception {
|
||||
}
|
||||
|
||||
/**
|
||||
* Testing of default commands where the interrupting command is ends itself
|
||||
*/
|
||||
@Test
|
||||
public void test() {
|
||||
final ASubsystem subsystem = new ASubsystem();
|
||||
|
||||
|
||||
MockCommand defaultCommand = new MockCommand() {
|
||||
{
|
||||
requires(subsystem);
|
||||
}
|
||||
};
|
||||
|
||||
MockCommand anotherCommand = new MockCommand() {
|
||||
{
|
||||
requires(subsystem);
|
||||
}
|
||||
};
|
||||
assertCommandState(defaultCommand, 0, 0, 0, 0, 0);
|
||||
subsystem.init(defaultCommand);
|
||||
|
||||
assertCommandState(defaultCommand, 0, 0, 0, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(defaultCommand, 0, 0, 0, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(defaultCommand, 1, 1, 1, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(defaultCommand, 1, 2, 2, 0, 0);
|
||||
|
||||
anotherCommand.start();
|
||||
assertCommandState(defaultCommand, 1, 2, 2, 0, 0);
|
||||
assertCommandState(anotherCommand, 0, 0, 0, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(defaultCommand, 1, 3, 3, 0, 1);
|
||||
assertCommandState(anotherCommand, 0, 0, 0, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(defaultCommand, 1, 3, 3, 0, 1);
|
||||
assertCommandState(anotherCommand, 1, 1, 1, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(defaultCommand, 1, 3, 3, 0, 1);
|
||||
assertCommandState(anotherCommand, 1, 2, 2, 0, 0);
|
||||
anotherCommand.setHasFinished(true);
|
||||
assertCommandState(defaultCommand, 1, 3, 3, 0, 1);
|
||||
assertCommandState(anotherCommand, 1, 2, 2, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(defaultCommand, 1, 3, 3, 0, 1);
|
||||
assertCommandState(anotherCommand, 1, 3, 3, 1, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(defaultCommand, 2, 4, 4, 0, 1);
|
||||
assertCommandState(anotherCommand, 1, 3, 3, 1, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(defaultCommand, 2, 5, 5, 0, 1);
|
||||
assertCommandState(anotherCommand, 1, 3, 3, 1, 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Testing of default commands where the interrupting command is canceled
|
||||
*/
|
||||
@Test
|
||||
public void testDefaultCommandsInterruptingCommandCanceled(){
|
||||
final ASubsystem subsystem = new ASubsystem();
|
||||
|
||||
|
||||
MockCommand defaultCommand = new MockCommand() {
|
||||
{
|
||||
requires(subsystem);
|
||||
}
|
||||
};
|
||||
|
||||
MockCommand anotherCommand = new MockCommand() {
|
||||
{
|
||||
requires(subsystem);
|
||||
}
|
||||
};
|
||||
assertCommandState(defaultCommand, 0, 0, 0, 0, 0);
|
||||
subsystem.init(defaultCommand);
|
||||
subsystem.initDefaultCommand();
|
||||
assertCommandState(defaultCommand, 0, 0, 0, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(defaultCommand, 0, 0, 0, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(defaultCommand, 1, 1, 1, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(defaultCommand, 1, 2, 2, 0, 0);
|
||||
|
||||
anotherCommand.start();
|
||||
assertCommandState(defaultCommand, 1, 2, 2, 0, 0);
|
||||
assertCommandState(anotherCommand, 0, 0, 0, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(defaultCommand, 1, 3, 3, 0, 1);
|
||||
assertCommandState(anotherCommand, 0, 0, 0, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(defaultCommand, 1, 3, 3, 0, 1);
|
||||
assertCommandState(anotherCommand, 1, 1, 1, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(defaultCommand, 1, 3, 3, 0, 1);
|
||||
assertCommandState(anotherCommand, 1, 2, 2, 0, 0);
|
||||
anotherCommand.cancel();
|
||||
assertCommandState(defaultCommand, 1, 3, 3, 0, 1);
|
||||
assertCommandState(anotherCommand, 1, 2, 2, 0, 0);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(defaultCommand, 1, 3, 3, 0, 1);
|
||||
assertCommandState(anotherCommand, 1, 2, 2, 0, 1);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(defaultCommand, 2, 4, 4, 0, 1);
|
||||
assertCommandState(anotherCommand, 1, 2, 2, 0, 1);
|
||||
Scheduler.getInstance().run();
|
||||
assertCommandState(defaultCommand, 2, 5, 5, 0, 1);
|
||||
assertCommandState(anotherCommand, 1, 2, 2, 0, 1);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -131,7 +131,7 @@ public class FakeCounterSource
|
||||
{
|
||||
}
|
||||
m_task = new EncoderThread(this);
|
||||
Timer.delay(.5);
|
||||
Timer.delay(.1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -139,7 +139,7 @@ public class FakeEncoderSource
|
||||
{
|
||||
}
|
||||
m_task = new QuadEncoderThread(this);
|
||||
Timer.delay(.5);
|
||||
Timer.delay(.1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -40,7 +40,7 @@ public final class TestBench {
|
||||
* The time that it takes to have a motor go from rotating at full speed to
|
||||
* completely stopped
|
||||
*/
|
||||
public static final double MOTOR_STOP_TIME = 0.50;
|
||||
public static final double MOTOR_STOP_TIME = 0.15;
|
||||
|
||||
|
||||
//THESE MUST BE IN INCREMENTING ORDER
|
||||
|
||||
@@ -25,6 +25,10 @@ import edu.wpi.first.wpilibj.TiltPanCameraTest;
|
||||
import edu.wpi.first.wpilibj.TimerTest;
|
||||
import edu.wpi.first.wpilibj.command.CommandParallelGroupTest;
|
||||
import edu.wpi.first.wpilibj.command.CommandScheduleTest;
|
||||
import edu.wpi.first.wpilibj.command.CommandSequentialGroupTest;
|
||||
import edu.wpi.first.wpilibj.command.CommandSupersedeTest;
|
||||
import edu.wpi.first.wpilibj.command.CommandTimeoutTest;
|
||||
import edu.wpi.first.wpilibj.command.DefaultCommandTest;
|
||||
|
||||
/**
|
||||
* The WPILibJ Integeration Test Suite collects all of the tests to be run by
|
||||
@@ -41,6 +45,10 @@ import edu.wpi.first.wpilibj.command.CommandScheduleTest;
|
||||
MotorEncoderTest.class,
|
||||
CommandParallelGroupTest.class,
|
||||
CommandScheduleTest.class,
|
||||
CommandSequentialGroupTest.class,
|
||||
CommandSupersedeTest.class,
|
||||
CommandTimeoutTest.class,
|
||||
DefaultCommandTest.class,
|
||||
TimerTest.class
|
||||
})
|
||||
//NOTE: THESE ARE EACH LISTED ON SEPERATE LINES TO PREVENT GIT MERGE CONFLICTS!
|
||||
@@ -57,11 +65,13 @@ public class TestSuite {
|
||||
Logger.getAnonymousLogger().severe("Could not load default logging.properties file");
|
||||
Logger.getAnonymousLogger().severe(e.getMessage());
|
||||
}
|
||||
|
||||
System.out.println("Starting Tests");
|
||||
}
|
||||
private static final Logger WPILIBJ_ROOT_LOGGER = Logger.getLogger("edu.wpi.first.wpilibj");
|
||||
private static final Logger WPILIBJ_COMMAND_ROOT_LOGGER = Logger.getLogger("edu.wpi.first.wpilibj.command");
|
||||
|
||||
public static void main(String[] args) {
|
||||
|
||||
JUnitCore.main("edu.wpi.first.wpilibj.test.TestSuite");
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,32 @@
|
||||
# "handlers" specifies a comma separated list of log Handler
|
||||
# classes. These handlers will be installed during VM startup.
|
||||
# By default we only configure a ConsoleHandler, which will only
|
||||
# show messages at the INFO and above levels.
|
||||
handlers = java.util.logging.ConsoleHandler
|
||||
|
||||
|
||||
# Default global logging level.
|
||||
# This specifies which kinds of events are logged across
|
||||
# all loggers. For any given facility this global level
|
||||
# can be overriden by a facility specific level
|
||||
# Note that the ConsoleHandler also has a separate level
|
||||
# setting to limit messages printed to the console.
|
||||
#.level= INFO
|
||||
.level= FINEST
|
||||
|
||||
############################################################
|
||||
# Handler specific properties.
|
||||
# Describes specific configuration info for Handlers.
|
||||
############################################################
|
||||
java.util.logging.ConsoleHandler.level=FINER
|
||||
java.util.logging.ConsoleHandler.formatter=java.util.logging.SimpleFormatter
|
||||
|
||||
.level=INFO
|
||||
############################################################
|
||||
# Facility specific properties.
|
||||
# Provides extra control for each logger.
|
||||
############################################################
|
||||
edu.wpi.first.wpilibj.level=INFO
|
||||
edu.wpi.first.wpilibj.command.level=FINEST
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user