diff --git a/wpilibj/RunTestsProject/BSD_License_for_WPILib_code.txt b/wpilibj/RunTestsProject/BSD_License_for_WPILib_code.txt deleted file mode 100644 index 4172601c73..0000000000 --- a/wpilibj/RunTestsProject/BSD_License_for_WPILib_code.txt +++ /dev/null @@ -1,24 +0,0 @@ -* Copyright (c) 2009 FIRST -* All rights reserved. -* -* Redistribution and use in source and binary forms, with or without -* modification, are permitted provided that the following conditions are met: -* * Redistributions of source code must retain the above copyright -* notice, this list of conditions and the following disclaimer. -* * Redistributions in binary form must reproduce the above copyright -* notice, this list of conditions and the following disclaimer in the -* documentation and/or other materials provided with the distribution. -* * Neither the name of the FIRST nor the -* names of its contributors may be used to endorse or promote products -* derived from this software without specific prior written permission. -* -* THIS SOFTWARE IS PROVIDED BY FIRST AND CONTRIBUTORS``AS IS'' AND ANY -* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -* WARRANTIES OF MERCHANTABILITY NONINFRINGEMENT AND FITNESS FOR A PARTICULAR -* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL FIRST OR CONTRIBUTORS BE LIABLE FOR -* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND -* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/wpilibj/RunTestsProject/build.xml b/wpilibj/RunTestsProject/build.xml deleted file mode 100644 index e997b910cf..0000000000 --- a/wpilibj/RunTestsProject/build.xml +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - ENABLING IN 30 SECONDS - Starting headless driver station in 30 seconds... - - - - - - - - - - - - diff --git a/wpilibj/RunTestsProject/nbproject/private/private.xml b/wpilibj/RunTestsProject/nbproject/private/private.xml deleted file mode 100644 index dc5712b815..0000000000 --- a/wpilibj/RunTestsProject/nbproject/private/private.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - file:/D:/Projects/WPILibJ-trunk/RunTestsProject/src/edu/wpi/first/wpilibj/unittests/ButtonTest.java - - diff --git a/wpilibj/RunTestsProject/nbproject/project.xml b/wpilibj/RunTestsProject/nbproject/project.xml deleted file mode 100644 index 08ac030471..0000000000 --- a/wpilibj/RunTestsProject/nbproject/project.xml +++ /dev/null @@ -1,92 +0,0 @@ - - - org.netbeans.modules.ant.freeform - - - RunTestsProject - - ${user.home}/.sunspotfrc.properties - build.properties - ${sunspot.home}/default.properties - - - - - java - src - - - - - jar-app - - - clean - - - deploy - run - - - clean - jar-app - - - deploy - debug-run - - - javadoc - - - - folder - build - jar-app - - - - - - src - - - build.xml - - - - - - - - - - - - deploy - - - - jar-deploy - - - - - - - - - src - ${sunspot.home}\lib\squawk.jar - D:\Projects\WPILibJ-trunk\WPILibJ\dist\lib\wpilibj.jar;D:\Projects\NetworkTables2.0\trunk\java\dist\lib\networktables-crio.jar;${sunspot.home}\lib\sunit-server.jar - build - 1.4 - - - - diff --git a/wpilibj/RunTestsProject/pom.xml b/wpilibj/RunTestsProject/pom.xml deleted file mode 100644 index 6196468915..0000000000 --- a/wpilibj/RunTestsProject/pom.xml +++ /dev/null @@ -1,64 +0,0 @@ - - - 4.0.0 - edu.wpi.first.wpilib.wpilibj - RunTestsProject - jar - 0.1.0-SNAPSHOT - - - - edu.wpi.first.wpilib - WPILibJ - 0.1.0-SNAPSHOT - - - org.reflections - reflections - 0.9.9-RC1 - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - 1.7 - 1.7 - - edu/wpi/first/wpilibj/unittests/PreferencesTest.java - - - - - org.apache.maven.plugins - maven-shade-plugin - - - package - - shade - - - true - true - jar-with-dependencies - - - - edu.wpi.first.wpilibj.RobotBase - edu.wpi.first.wpilibj.unittests.RunTests - - - - - - - - - - - diff --git a/wpilibj/RunTestsProject/resources/META-INF/MANIFEST.MF b/wpilibj/RunTestsProject/resources/META-INF/MANIFEST.MF deleted file mode 100644 index b92aa6d00b..0000000000 --- a/wpilibj/RunTestsProject/resources/META-INF/MANIFEST.MF +++ /dev/null @@ -1,6 +0,0 @@ -MIDlet-Name: RunTestsProject -MIDlet-Version: 1.0.0 -MIDlet-Vendor: FIRST -MIDlet-1: RunTests, , edu.wpi.first.wpilibj.unittests.RunTests -MicroEdition-Profile: IMP-1.0 -MicroEdition-Configuration: CLDC-1.1 diff --git a/wpilibj/RunTestsProject/src/main/java/Assemblies/DIOCrossConnect.java b/wpilibj/RunTestsProject/src/main/java/Assemblies/DIOCrossConnect.java deleted file mode 100644 index 84c2d0f6ed..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/Assemblies/DIOCrossConnect.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package Assemblies; - -import edu.wpi.first.wpilibj.DigitalInput; -import edu.wpi.first.wpilibj.DigitalOutput; - -/** - * - * @author brad - */ -public class DIOCrossConnect { - - /** - * Cross connected Digital I/O lines. - * The A1, B1, C1, and D1 are digital module 1 and - * A2, B2, C2, and D2 are digital module 2 - */ - public static final int DIOCrossConnectA1 = 8; - public static final int DIOCrossConnectA2 = 11; - public static final int DIOCrossConnectB1 = 9; - public static final int DIOCrossConnectB2 = 10; - public static final int DIOCrossConnectC1 = 10; - public static final int DIOCrossConnectC2 = 9; - public static final int DIOCrossConnectD1 = 11; - public static final int DIOCrossConnectD2 = 8; - - public static DigitalOutput getOutputA() { - return new DigitalOutput(DIOCrossConnectA1); - } - - public static DigitalInput getInputA() { - return new DigitalInput(2, DIOCrossConnectA2); - } - - public static DigitalOutput getOutputB() { - return new DigitalOutput(DIOCrossConnectB1); - } - - public static DigitalInput getInputB() { - return new DigitalInput(2, DIOCrossConnectB2); - } - - public static DigitalOutput getOutputC() { - return new DigitalOutput(DIOCrossConnectC1); - } - - public static DigitalInput getInputC() { - return new DigitalInput(2, DIOCrossConnectC2); - } - - public static DigitalOutput getOutputD() { - return new DigitalOutput(DIOCrossConnectD1); - } - - public static DigitalInput getInputD() { - return new DigitalInput(2, DIOCrossConnectD2); - } -} diff --git a/wpilibj/RunTestsProject/src/main/java/Assemblies/FakeCounterSource.java b/wpilibj/RunTestsProject/src/main/java/Assemblies/FakeCounterSource.java deleted file mode 100644 index e5f3300316..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/Assemblies/FakeCounterSource.java +++ /dev/null @@ -1,147 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2008. 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 Assemblies; - -import edu.wpi.first.wpilibj.DigitalOutput; -import edu.wpi.first.wpilibj.Timer; - -/** - * @file FakeCounterSource.java - * Simulates an encoder for testing purposes - * @author Ryan O'Meara - */ -public class FakeCounterSource -{ - - private Thread m_task; - private int m_count; - private int m_mSec; - private DigitalOutput m_output; - - /** - * Thread object that allows emulation of an encoder - */ - private class EncoderThread extends Thread - { - - FakeCounterSource m_encoder; - - EncoderThread(FakeCounterSource encode) - { - m_encoder = encode; - } - - public void run() - { - m_encoder.m_output.set(false); - try - { - for (int i = 0; i < m_encoder.m_count; i++) - { - Thread.sleep(m_encoder.m_mSec); - m_encoder.m_output.set(true); - Thread.sleep(m_encoder.m_mSec); - m_encoder.m_output.set(false); - } - } catch (InterruptedException e) - { - } - } - } - - /** - * Create a fake encoder on a given port - * @param port The port the encoder is supposed to be on - */ - public FakeCounterSource(int port) - { - m_output = new DigitalOutput(port); - initEncoder(); - } - - /** - * Create a new fake encoder on the indicated slot and port - * @param slot Slot to create on - * @param port THe port that the encoder is supposably on - */ - public FakeCounterSource(int slot, int port) - { - m_output = new DigitalOutput(slot, port); - initEncoder(); - } - - /** - * Destroy Object with minimum memory leak - */ - public void free() - { - m_task = null; - m_output.free(); - } - - /** - * Common initailization code - */ - private void initEncoder() - { - m_mSec = 1; - m_task = new EncoderThread(this); - m_output.set(false); - } - - /** - * Starts the thread execution task - */ - public void start() - { - m_task.start(); - } - - /** - * Waits for the thread to complete - */ - public void complete() - { - try - { - m_task.join(); - } catch (InterruptedException e) - { - } - m_task = new EncoderThread(this); - Timer.delay(.5); - } - - /** - * Starts and completes a task set - does not return until thred has finished - * its operations - */ - public void execute() - { - start(); - complete(); - } - - /** - * Sets the count to run encoder - * @param count The count to emulate to the controller - */ - public void setCount(int count) - { - m_count = count; - } - - /** - * Specify the rate to send pulses - * @param mSec The rate to send out pulses at - */ - public void setRate(int mSec) - { - m_mSec = mSec; - } -} diff --git a/wpilibj/RunTestsProject/src/main/java/Assemblies/FakeEncoderSource.java b/wpilibj/RunTestsProject/src/main/java/Assemblies/FakeEncoderSource.java deleted file mode 100644 index b000ae57fb..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/Assemblies/FakeEncoderSource.java +++ /dev/null @@ -1,190 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2008. 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 Assemblies; - -import edu.wpi.first.wpilibj.DigitalOutput; -import edu.wpi.first.wpilibj.Timer; - -/** - * @file FakeEncoderSource.java - * Emulates a quadrature encoder - * @author Ryan O'Meara - */ -public class FakeEncoderSource -{ - - private Thread m_task; - private int m_count; - private int m_mSec; - private boolean m_forward; - private DigitalOutput m_outputA, m_outputB; - private boolean allocatedOutputs; - - /** - * Thread object that allows emulation of a quadrature encoder - */ - private class QuadEncoderThread extends Thread - { - - FakeEncoderSource m_encoder; - - QuadEncoderThread(FakeEncoderSource encode) - { - m_encoder = encode; - } - - public void run() - { - - DigitalOutput lead, lag; - - m_encoder.m_outputA.set(false); - m_encoder.m_outputB.set(false); - - if (m_encoder.isForward()) - { - lead = m_encoder.m_outputA; - lag = m_encoder.m_outputB; - } else - { - lead = m_encoder.m_outputB; - lag = m_encoder.m_outputA; - } - - try - { - for (int i = 0; i < m_encoder.m_count; i++) - { - lead.set(true); - Thread.sleep(m_encoder.m_mSec); - lag.set(true); - Thread.sleep(m_encoder.m_mSec); - lead.set(false); - Thread.sleep(m_encoder.m_mSec); - lag.set(false); - Thread.sleep(m_encoder.m_mSec); - } - } catch (InterruptedException e) - { - } - } - } - - public FakeEncoderSource(int slotA, int portA, int slotB, int portB) - { - m_outputA = new DigitalOutput(slotA, portA); - m_outputB = new DigitalOutput(slotB, portB); - allocatedOutputs = true; - initQuadEncoder(); - } - - public FakeEncoderSource(int portA, int portB) - { - m_outputA = new DigitalOutput(portA); - m_outputB = new DigitalOutput(portB); - allocatedOutputs = true; - initQuadEncoder(); - } - - public FakeEncoderSource(DigitalOutput iA, DigitalOutput iB) - { - m_outputA = iA; - m_outputB = iB; - allocatedOutputs = false; - initQuadEncoder(); - } - - public void free() - { - m_task = null; - if (allocatedOutputs) { - m_outputA.free(); - m_outputB.free(); - } - } - - /** - * Common initialization code - */ - private void initQuadEncoder() - { - m_mSec = 1; - m_forward = true; - m_task = new QuadEncoderThread(this); - m_outputA.set(false); - m_outputB.set(false); - } - - /** - * Starts the thread - */ - public void start() - { - m_task.start(); - } - - /** - * Waits for thread to end - */ - public void complete() - { - try - { - m_task.join(); - } catch (InterruptedException e) - { - } - m_task = new QuadEncoderThread(this); - Timer.delay(.5); - } - - /** - * Runs and waits for thread to end before returning - */ - public void execute() - { - start(); - complete(); - } - - /** - * Rate of pulses to send - * @param mSec Pulse Rate - */ - public void setRate(int mSec) - { - m_mSec = mSec; - } - - /** - * Set the number of pulses to simulate - * @param count Pulse count - */ - public void setCount(int count) - { - m_count = count; - } - - /** - * Set which direction the encoder simulates motion in - * @param isForward Whether to simulate forward motion - */ - public void setForward(boolean isForward) - { - m_forward = isForward; - } - - /** - * Accesses whether the encoder is simulating forward motion - * @return Whether the simulated motion is in the forward direction - */ - public boolean isForward() - { - return m_forward; - } -} diff --git a/wpilibj/RunTestsProject/src/main/java/Assemblies/MagneticRotaryAssembly.java b/wpilibj/RunTestsProject/src/main/java/Assemblies/MagneticRotaryAssembly.java deleted file mode 100644 index 78fa14ffd5..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/Assemblies/MagneticRotaryAssembly.java +++ /dev/null @@ -1,42 +0,0 @@ -package Assemblies; - -import edu.wpi.first.wpilibj.AnalogChannel; -import edu.wpi.first.wpilibj.Counter; -import edu.wpi.first.wpilibj.DigitalOutput; -import edu.wpi.first.wpilibj.Encoder; -import edu.wpi.first.wpilibj.Jaguar; - -/** - * - * @author brad - */ -public class MagneticRotaryAssembly { - - public static Jaguar getJaguar() { - return new Jaguar(1, 6); - } - - public static DigitalOutput getLimitSWFwd() { - return new DigitalOutput(2, 13); - } - - public static DigitalOutput getLimitSWRev() { - return new DigitalOutput(2, 14); - } - - public static Counter getGTS() { - return new Counter(1, 5); - } - - public static Encoder getEncoder() { - return new Encoder(1, 6, 1, 7); - } - - public static Counter getHallEffect() { - return new Counter(1, 1); - } - - public AnalogChannel getMagneticEncoder() { - return new AnalogChannel(2, 6); - } -} diff --git a/wpilibj/RunTestsProject/src/main/java/Assemblies/PotentiometerAssembly.java b/wpilibj/RunTestsProject/src/main/java/Assemblies/PotentiometerAssembly.java deleted file mode 100644 index 362273d8b6..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/Assemblies/PotentiometerAssembly.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package Assemblies; - -import edu.wpi.first.wpilibj.AnalogChannel; -import edu.wpi.first.wpilibj.Counter; -import edu.wpi.first.wpilibj.DigitalOutput; -import edu.wpi.first.wpilibj.Jaguar; -import edu.wpi.first.wpilibj.Victor; - -/** - * - * @author Fred - */ -public class PotentiometerAssembly { - - public static Jaguar getJaguar(){ - return new Jaguar(1,5); - } - - public static DigitalOutput getLimSWFwd(){ - return new DigitalOutput(1, 13); - } - - public static DigitalOutput getLimSWRev(){ - return new DigitalOutput(1, 14); - } - - public static Victor getVictor(){ - return new Victor(1, 2); - } - - public static AnalogChannel getPotentiometer(){ - return new AnalogChannel(1, 3); - } - - public static Counter getHallEffect(){ - return new Counter(1, 4); - } - - public static Counter getGearTooth(){ - return new Counter(2, 7); - } -} diff --git a/wpilibj/RunTestsProject/src/main/java/Assemblies/RCAssembly.java b/wpilibj/RunTestsProject/src/main/java/Assemblies/RCAssembly.java deleted file mode 100644 index 9ce269b21a..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/Assemblies/RCAssembly.java +++ /dev/null @@ -1,28 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package Assemblies; - -import edu.wpi.first.testing.SlowServo; -import edu.wpi.first.wpilibj.Gyro; -import edu.wpi.first.wpilibj.Servo; - -/** - * - * @author mwills - */ -public class RCAssembly { - - public static Servo getServo(){ - return new SlowServo(1, 1); - } - - public static Gyro getGyro(){ - return new Gyro(1, 1); - } - - /*public static SPIAccelerometer getAccelerometer(){ - return new SPIAccelerometer(2, 1, 2, 3, 4, 5, 6); - }*/ -} diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/testing/Connections.java b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/testing/Connections.java deleted file mode 100644 index ab700987b5..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/testing/Connections.java +++ /dev/null @@ -1,35 +0,0 @@ - -package edu.wpi.first.testing; - -/** - * - * @author brad - */ -public interface Connections { - - /** - * Grey Jaguar, Victor and associated motor and sensors - */ - public static final int GreyJagPWM = 5; - public static final int GreyJagBrakeCoast = 12; - public static final int GreyJagLimitFWD = 13; - public static final int GreyJagLimitRev = 14; - public static final int VictorPWM = 2; - public static final int VictorBrakeCoast = 2; - public static final int GreyJagGearTooth = 7; // DSC module 2 - public static final int ContinuousTurnPot = 3; - - /** - * - */ - public static final int DIOCrossConnectA1 = 8; - public static final int DIOCrossConnectA2 = 11; - public static final int DIOCrossConnectB1 = 9; - public static final int DIOCrossConnectB2 = 10; - public static final int DIOCrossConnectC1 = 10; - public static final int DIOCrossConnectC2 = 9; - public static final int DIOCrossConnectD1 = 11; - public static final int DIOCrossConnectD2 = 8; - - -} diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/testing/Failure.java b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/testing/Failure.java deleted file mode 100644 index 30089d2012..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/testing/Failure.java +++ /dev/null @@ -1,44 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2008-2011. 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.testing; - -/** - * - * @author dtjones - */ -public class Failure { - TestFailure failure; - Failure(TestFailure failure) { - this.failure = failure; - } - - /** - * Get a string represention of the failed test. - * @return A string representation of the failed test. - */ - public String toString() { - return getTest() + " " + getTestClass() + " : " + failure.getMessage(); - } - - /** - * Get the name of the test that failed. - * @return The name of the test that failed. - */ - public String getTest() { - return failure.getTest(); - } - - /** - * Get the name of the test class that failed. - * @return The name of the test class that failed. - */ - public String getTestClass() { - return failure.getTestClass(); - } - -} diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/testing/SlowServo.java b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/testing/SlowServo.java deleted file mode 100644 index 89182c9866..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/testing/SlowServo.java +++ /dev/null @@ -1,66 +0,0 @@ -package edu.wpi.first.testing; - -import edu.wpi.first.wpilibj.Servo; -import edu.wpi.first.wpilibj.Timer; - -/** - * Servo which moves very slowly. - * - * In order to support testing a gyroscope using a hobby servo, we must slow - * down the turn rate of the hobby servo. Otherwise, the hobby servo would - * rotate at a speed much higher than that that the gyroscope can measure. - * - * @author pmalmsten - */ -public class SlowServo extends Servo { - - public SlowServo(int port) { - super(port); - } - - public SlowServo(int module, int port) { - super(module, port); - } - - /** - * Change the servo position moving at a slow rate of speed and block - * until it gets there. - * - * Servo values range from 0.0 to 1.0 corresponding to the range of full left to full right. - * - * @param value Position from 0.0 to 1.0. - */ - public void setPosition(double position) { - double posToGo = position - getPosition(); - - for(int i = 0; i < Math.floor(Math.abs(posToGo) / 0.05); i++) { - // Apply step - super.setPosition(getPosition() + ((posToGo > 0)? 0.05:-0.05)); - - System.out.println(" At: " + getPosition() + " Going to: " + posToGo); - - // Wait - Timer.delay(0.5); - } - - // Apply remainder - super.setPosition(position); - - System.out.println(" At: " + getPosition() + " Going to: " + posToGo); - - // Wait - Timer.delay(0.5); - } - - /** - * Set the servo position directly and does not block. Should not be used - * during testing (but may be useful for preparing a test). - * - * Servo values range from 0.0 to 1.0 corresponding to the range of full left to full right. - * - * @param value Position from 0.0 to 1.0. - */ - public void fastSet(double position) { - super.set(position); - } -} diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/testing/TestClass.java b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/testing/TestClass.java deleted file mode 100644 index ec93e0132b..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/testing/TestClass.java +++ /dev/null @@ -1,353 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2008-2011. 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.testing; - -import java.util.Enumeration; -import java.util.Hashtable; -import java.util.Set; -import java.util.Vector; - -import org.reflections.Reflections; - -/** - * This class should be extended by test classes. Make sure to call the - * constructor for each subclass once so that the class is added to the master - * hashtable - * @author dtjones - */ -public abstract class TestClass { - static Hashtable testClassesByName = new Hashtable(); - static Hashtable testClassesByTag = new Hashtable(); - Hashtable tests = new Hashtable(); - static Vector failedTests = new Vector(); - - - static { - Reflections reflections = new Reflections("edu.wpi.first.wpilibj.unittests"); - - Set> tests = reflections.getSubTypesOf(TestClass.class); - for (Class test : tests) { - try { - test.newInstance(); - } catch (InstantiationException | IllegalAccessException e) { - // TODO Auto-generated catch block - e.printStackTrace(); - } - } - } - - /** - * Create a new instance of the test class and add it to the master table - * of test classes - */ - public TestClass () { - testClassesByName.put(getName(), this); - - String[] tags = getTags(); - for(int i = 0; i < tags.length; i++) { - if(testClassesByTag.containsKey(tags[i])) { - // The tag exists; add ourself to it - ((Vector) testClassesByTag.get(tags[i])).addElement(this); - } else { - // The tag does not already exist; create it - Vector testClassVector = new Vector(); - testClassesByTag.put(tags[i], testClassVector); - - // Add ourself to it - testClassVector.addElement(this); - } - } - } - - /** - * This class should be extended within subclasses of each TestClass to - * add a test. In the constructor for the TestClass you could put : - * new Test() { - * public String getName() { return "Sample"; } - * public void run() { - * //your test here - * assertFail("I don't work"); - * } - * }; - */ - public abstract class Test { - private String testName; - /** - * Create a new Test and add it to the master classes table of tests - * @param name The name for this test, This should be unique for this TestClass. - */ - public Test(String name) { - this.testName = name; - tests.put(getName(), this); - } - /** - * Get the name of this test, should be unique within this test class. - * @return the name of the test - */ - public String getName () { return this.testName;}; - /** - * The code to test. Failure is triggered using one of the assert methods - */ - public abstract void run (); - /** - * Setup code to run before this test is run - */ - public void setup() {} - /** - * Teardown code to run after the test is run - */ - public void teardown() {} - - /** - * Return a string representing this Test. - * @return The name of the Test. - */ - public String toString() { - return getName(); - } - - /** - * Runs this test case. - */ - final void test() { - try { - setup(); - run(); - onPass(); - } catch (TestFailure e) { - onFailure(e); - } finally { - teardown(); - } - } - - /** - * Default failure hook called when a test fails. May be - * overridden. - * - * @param e The TestFailure to report. - */ - protected void onFailure(TestFailure e) { -// System.out.println(" " + getName() + " failed : " + e.getMessage()); - System.out.println("!!! TEST FAILED: " + getName() + " with: " + e.getMessage()); - System.out.print(" "); - e.print(System.out); - System.out.println(); - e.setTestName( - TestClass.this.getName(), - this.getName()); - failedTests.addElement(new Failure(e)); - } - - /** - * Default pass hook called when a test passes. May be overridden. - */ - public void onPass() { - System.out.println(" " + getName() + " passed"); - } - } - - /** - * A test which does not emit a test failure sentinel to the console - * when it fails, such that an automated test harness like Hudson does - * not mark the build as unstable. - */ - public abstract class TestUnderDevelopment extends Test { - public TestUnderDevelopment(String name) { - super(name); - } - - protected void onFailure(TestFailure e) { - System.out.println("### " + getName() + " failed : " + e.getMessage()); - System.out.print(" "); - e.print(System.out); - System.out.println(); - e.setTestName( - TestClass.this.getName(), - this.getName()); - failedTests.addElement(new Failure(e)); - } - } - - /** - * Get the name of this TestClass. This should be unique within the testClassesByName - * @return The name of this test class - */ - public abstract String getName(); - - /** - * Returns an array of tag names for which this class is associated. - * - * @return An array of tag names that this class is associated with. - */ - public String[] getTags() { - return new String[] {}; - } - - /** - * Setup code to run before the tests within this class are run - */ - public void setup() {} - /** - * Teardown code to run after the tests within this class are run - */ - public void teardown() {} - - /** - * Get a list of all the failed tests. - * @return A list of all of the failed tests. - */ - public static Failure[] getFailures() { - Failure[] failures = new Failure[failedTests.size()]; - failedTests.copyInto(failures); - return failures; - } - - /** - * Get a string representing this TestClass. - * @return The name of this test class. - */ - public String toString() { - return getName(); - } - - final void test() { - System.out.println("Running: " + getName()); - setup(); - Enumeration elements = tests.elements(); - while(elements.hasMoreElements()) - ((Test)elements.nextElement()).test(); - teardown(); - } - - final void test(String test) { - System.out.println("Running: " + getName()); - setup(); - ((Test)tests.get(test)).test(); - teardown(); - } - - /** - * Run the tests within the class name given - * @param clas The name of the TestClass to run - */ - public static void run(String clas) { - TestClass testCase = (TestClass)testClassesByName.get(clas); - testCase.test(); - System.out.println("Completed: " + testCase.getName()); - System.out.println(); - } - - /** - * Run the given test within the given class - * @param clas The name of the class to run. - * @param test The name of the test to run. - */ - public static void run(String clas, String test) { - TestClass testCase = (TestClass)testClassesByName.get(clas); - testCase.test(test); - System.out.println("Completed: " + testCase.getName()); - System.out.println(); - } - - /** - * Run all of the tests in all of the classes. - */ - public static void runAll () { - Enumeration elements = testClassesByName.elements(); - while(elements.hasMoreElements()) - ((TestClass)elements.nextElement()).test(); - System.out.println("Tests complete"); - } - - /** - * Runs all tests within test classes whose getTags() result contains the - * given string. - * - * @param tagName The tag name for which all associated tests should run. - */ - public static void runAllWithTag(String tagName) { - Vector tests = (Vector) testClassesByTag.get(tagName); - - if(tests != null) { - Enumeration elements = tests.elements(); - while(elements.hasMoreElements()) - ((TestClass)elements.nextElement()).test(); - System.out.println("Tests complete"); - } - } - - /** - * Fail the test. - * @param msg A message descibing the failure. - */ - protected void assertFail (String msg) { - throw new TestFailure(msg); - } - - /** - * Fail the test if the given items are not the same - * @param expected The expected value. - * @param actual The actual value. - */ - protected void assertEquals (Object expected, Object actual) { - if ((null == expected) ^ (null == actual)) - throw new TestFailure("Expected " + expected + " got " + actual); - if (!expected.equals(actual)) - throw new TestFailure("Expected " + expected + " got " + actual); - } - - /** - * Fail the test if the given items are not the same - * @param expected The expected value. - * @param actual The actual value. - */ - protected void assertEquals (long expected, long actual) { - if (expected != actual) - throw new TestFailure("Expected " + expected + " got " + actual); - } - - /** - * Fail the test if the given items are not the same - * @param expected The expected value. - * @param actual The actual value. - */ - protected void assertEquals (double expected, double actual) { - if (expected != actual) - throw new TestFailure("Expected " + expected + " got " + actual); - } - - /** - * Fail the test if the given items are not the same - * @param expected The expected value. - * @param actual The actual value. - * @param tolerance The amount by which the values must match - */ - protected void assertEquals (double expected, double actual, double tolerance) { - if (Math.abs(expected - actual) > tolerance) - throw new TestFailure("Expected " + expected + " got " + actual); - } - - /** - * Fail the test if the given value is false. - * @param value Boolean value that must be true for success - */ - protected void assertTrue (boolean value) { - if ( ! value ) - throw new TestFailure("Assertion was false"); - } - - /** - * Fail the test if the given value is true. - * @param value Boolean value that must be false for success - */ - protected void assertFalse (boolean value) { - if ( value ) - throw new TestFailure("Assertion was true"); - } -} diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/testing/TestFailure.java b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/testing/TestFailure.java deleted file mode 100644 index 17bfb58922..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/testing/TestFailure.java +++ /dev/null @@ -1,60 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2008-2011. 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.testing; - -import java.io.PrintStream; - - -/** - * This Exception is thrown when a test fails. - * @author dtjones - */ -class TestFailure extends RuntimeException { - private String testClass = null; - private String test = null; - /** - * An execution point representing the line where the assertion that failed - * was called. - */ - protected final StackTraceElement failedTest; - /** - * Create a new TestFailure exception to fail the currently runningt test. - * @param msg The message to pass with the exception explaining what failed - * in the test - */ - protected TestFailure (String msg) { - super(msg); - failedTest = Thread.currentThread().getStackTrace()[3]; - // failedTest = VM.reifyCurrentStack(-1)[3]; - } - - void setTestName(String testClass, String test) { - this.testClass = testClass; - this.test = test; - } - - /** - * Get the name of the test class - * @return the name of the test class - */ - public String getTestClass() { - return testClass; - } - - /** - * Get the name of the test - * @return the name of the test - */ - public String getTest() { - return test; - } - - public void print(PrintStream out) { - out.print(failedTest.toString()); - } -} diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/testing/Utils.java b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/testing/Utils.java deleted file mode 100644 index 338d086a26..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/testing/Utils.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package edu.wpi.first.testing; - -/** - * - * @author alex - */ -public class Utils { - public static int[] combine(int[] a, int[] b) { - int[] out = new int[a.length+b.length]; - System.arraycopy(a, 0, out, 0, a.length); - System.arraycopy(b, 0, out, a.length, b.length); - return out; - } -} diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/testing/package.html b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/testing/package.html deleted file mode 100644 index 428101a88d..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/testing/package.html +++ /dev/null @@ -1,10 +0,0 @@ - - - - WPI Test Utilities - - - - Test utility classes used by WPILibJ testing. See WPILibJ/tests for examples. - - diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/ButtonTest.java b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/ButtonTest.java deleted file mode 100644 index 4090024e3a..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/ButtonTest.java +++ /dev/null @@ -1,142 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package edu.wpi.first.wpilibj.unittests; - -import edu.wpi.first.testing.TestClass; -import edu.wpi.first.wpilibj.buttons.InternalButton; -import edu.wpi.first.wpilibj.command.Scheduler; - -/** - * - * @author Mitchell - */ -public class ButtonTest extends TestClass{ - - public String getName() { - return "Button Test"; - } - - public String[] getTags() { - return new String[] { RunTests.Tags.Lifecycle.INPRODUCTION, - RunTests.Tags.Type.COMMANDBASED }; - } - - private InternalButton button1; - private InternalButton button2; - public void setup() { - button1 = new InternalButton(); - button2 = new InternalButton(); - } - - public void teardown() { - } - - - { - new Test("Simple Button Test") { - - public void run() { - TestCommand command1 = new TestCommand(); - TestCommand command2 = new TestCommand(); - TestCommand command3 = new TestCommand(); - TestCommand command4 = new TestCommand(); - - button1.whenPressed(command1); - button1.whenReleased(command2); - button1.whileHeld(command3); - button2.whileHeld(command4); - - assertCommandState(command1, 0, 0, 0, 0, 0); - assertCommandState(command2, 0, 0, 0, 0, 0); - assertCommandState(command3, 0, 0, 0, 0, 0); - assertCommandState(command4, 0, 0, 0, 0, 0); - button1.setPressed(true); - assertCommandState(command1, 0, 0, 0, 0, 0); - assertCommandState(command2, 0, 0, 0, 0, 0); - assertCommandState(command3, 0, 0, 0, 0, 0); - assertCommandState(command4, 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); - assertCommandState(command4, 0, 0, 0, 0, 0); - Scheduler.getInstance().run(); - assertCommandState(command1, 1, 1, 1, 0, 0); - assertCommandState(command2, 0, 0, 0, 0, 0); - assertCommandState(command3, 1, 1, 1, 0, 0); - assertCommandState(command4, 0, 0, 0, 0, 0); - Scheduler.getInstance().run(); - assertCommandState(command1, 1, 2, 2, 0, 0); - assertCommandState(command2, 0, 0, 0, 0, 0); - assertCommandState(command3, 1, 2, 2, 0, 0); - assertCommandState(command4, 0, 0, 0, 0, 0); - button2.setPressed(true); - Scheduler.getInstance().run(); - assertCommandState(command1, 1, 3, 3, 0, 0); - assertCommandState(command2, 0, 0, 0, 0, 0); - assertCommandState(command3, 1, 3, 3, 0, 0); - assertCommandState(command4, 0, 0, 0, 0, 0); - Scheduler.getInstance().run(); - assertCommandState(command1, 1, 4, 4, 0, 0); - assertCommandState(command2, 0, 0, 0, 0, 0); - assertCommandState(command3, 1, 4, 4, 0, 0); - assertCommandState(command4, 1, 1, 1, 0, 0); - button1.setPressed(false); - Scheduler.getInstance().run(); - assertCommandState(command1, 1, 5, 5, 0, 0); - assertCommandState(command2, 0, 0, 0, 0, 0); - assertCommandState(command3, 1, 4, 4, 0, 1); - assertCommandState(command4, 1, 2, 2, 0, 0); - Scheduler.getInstance().run(); - assertCommandState(command1, 1, 6, 6, 0, 0); - assertCommandState(command2, 1, 1, 1, 0, 0); - assertCommandState(command3, 1, 4, 4, 0, 1); - assertCommandState(command4, 1, 3, 3, 0, 0); - button2.setPressed(false); - Scheduler.getInstance().run(); - assertCommandState(command1, 1, 7, 7, 0, 0); - assertCommandState(command2, 1, 2, 2, 0, 0); - assertCommandState(command3, 1, 4, 4, 0, 1); - assertCommandState(command4, 1, 3, 3, 0, 1); - command1.cancel(); - Scheduler.getInstance().run(); - assertCommandState(command1, 1, 7, 7, 0, 1); - assertCommandState(command2, 1, 3, 3, 0, 0); - assertCommandState(command3, 1, 4, 4, 0, 1); - assertCommandState(command4, 1, 3, 3, 0, 1); - command2.setHasFinished(true); - Scheduler.getInstance().run(); - assertCommandState(command1, 1, 7, 7, 0, 1); - assertCommandState(command2, 1, 4, 4, 1, 0); - assertCommandState(command3, 1, 4, 4, 0, 1); - assertCommandState(command4, 1, 3, 3, 0, 1); - Scheduler.getInstance().run(); - assertCommandState(command1, 1, 7, 7, 0, 1); - assertCommandState(command2, 1, 4, 4, 1, 0); - assertCommandState(command3, 1, 4, 4, 0, 1); - assertCommandState(command4, 1, 3, 3, 0, 1); - - - } - }; - } - - - private int testCount = 1; - public void assertCommandState(TestCommand command, int initialize, int execute, int isFinished, int end, int interrupted) { - //System.out.println("Test Command Initialize "+(testCount++)); - assertEquals(initialize, command.getInitializeCount()); - //System.out.println("Test Command Execute"); - assertEquals(execute, command.getExecuteCount()); - //System.out.println("Test Command IsFinished"); - assertEquals(isFinished, command.getIsFinishedCount()); - //System.out.println("Test Command End"); - assertEquals(end, command.getEndCount()); - //System.out.println("Test Command Interrupted"); - assertEquals(interrupted, command.getInterruptedCount()); - } - - -} diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/CommandParallelGroupTest.java b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/CommandParallelGroupTest.java deleted file mode 100644 index 72caa18195..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/CommandParallelGroupTest.java +++ /dev/null @@ -1,140 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package edu.wpi.first.wpilibj.unittests; - -import edu.wpi.first.testing.TestClass; -import edu.wpi.first.wpilibj.command.Command; -import edu.wpi.first.wpilibj.command.CommandGroup; -import edu.wpi.first.wpilibj.command.Scheduler; -import edu.wpi.first.wpilibj.command.Subsystem; - -/** - * - * @author Mitchell - */ -public class CommandParallelGroupTest extends TestClass{ - - public String getName() { - return "Command Parallel Group Test"; - } - - public String[] getTags() { - return new String[] { RunTests.Tags.Lifecycle.INPRODUCTION, - RunTests.Tags.Type.COMMANDBASED }; - } - - public void setup() { - } - - public void teardown() { - } - - private class ASubsystem extends Subsystem { - protected void initDefaultCommand(){ - } - } - - { - new Test("Simple Parallel Command Group With 2 commands one command terminates first") { - - public void run() { - TestCommand command1 = new TestCommand(); - TestCommand command2 = new TestCommand(); - - CommandGroup commandGroup = new CommandGroup(); - commandGroup.addParallel(command1); - commandGroup.addParallel(command2); - - - assertCommandState(command1, 0, 0, 0, 0, 0); - assertCommandState(command2, 0, 0, 0, 0, 0); - commandGroup.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, 1, 1, 1, 0, 0); - Scheduler.getInstance().run(); - assertCommandState(command1, 1, 2, 2, 0, 0); - assertCommandState(command2, 1, 2, 2, 0, 0); - command1.setHasFinished(true); - Scheduler.getInstance().run(); - assertCommandState(command1, 1, 3, 3, 1, 0); - assertCommandState(command2, 1, 3, 3, 0, 0); - Scheduler.getInstance().run(); - assertCommandState(command1, 1, 3, 3, 1, 0); - assertCommandState(command2, 1, 4, 4, 0, 0); - command2.setHasFinished(true); - Scheduler.getInstance().run(); - assertCommandState(command1, 1, 3, 3, 1, 0); - assertCommandState(command2, 1, 5, 5, 1, 0); - - } - }; - } - - { - new Test("Simple Parallel Command Group With 2 commands. The group is canceled") { - - public void run() { - TestCommand command1 = new TestCommand(); - TestCommand command2 = new TestCommand(); - - CommandGroup commandGroup = new CommandGroup(); - commandGroup.addParallel(command1); - commandGroup.addParallel(command2); - - - assertCommandState(command1, 0, 0, 0, 0, 0); - assertCommandState(command2, 0, 0, 0, 0, 0); - commandGroup.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, 1, 1, 1, 0, 0); - Scheduler.getInstance().run(); - assertCommandState(command1, 1, 2, 2, 0, 0); - assertCommandState(command2, 1, 2, 2, 0, 0); - commandGroup.cancel(); - assertCommandState(command1, 1, 2, 2, 0, 0); - assertCommandState(command2, 1, 2, 2, 0, 0); - Scheduler.getInstance().run(); - assertCommandState(command1, 1, 2, 2, 0, 1); - assertCommandState(command2, 1, 2, 2, 0, 1); - - } - }; - } - - private int testCount = 1; - public void assertCommandState(TestCommand command, int initialize, int execute, int isFinished, int end, int interrupted) { - //System.out.println("Test Command Initialize "+(testCount++)); - assertEquals(initialize, command.getInitializeCount()); - //System.out.println("Test Command Execute"); - assertEquals(execute, command.getExecuteCount()); - //System.out.println("Test Command IsFinished"); - assertEquals(isFinished, command.getIsFinishedCount()); - //System.out.println("Test Command End"); - assertEquals(end, command.getEndCount()); - //System.out.println("Test Command Interrupted"); - assertEquals(interrupted, command.getInterruptedCount()); - } - - public void sleep(long time){ - try { - Thread.sleep(time); - } catch (InterruptedException ex) { - assertFail("Sleep Interrupted!?!?!?!?"); - } - } - -} diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/CommandScheduleTest.java b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/CommandScheduleTest.java deleted file mode 100644 index ef006bec5e..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/CommandScheduleTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package edu.wpi.first.wpilibj.unittests; - -import edu.wpi.first.testing.TestClass; -import edu.wpi.first.wpilibj.command.Scheduler; - -/** - * - * @author mwills - */ -public class CommandScheduleTest extends TestClass{ - public String getName() { - return "Command Schedule Test"; - } - - public String[] getTags() { - return new String[] { RunTests.Tags.Lifecycle.INPRODUCTION, - RunTests.Tags.Type.COMMANDBASED }; - } - - public void setup() { - } - - public void teardown() { - } - - { - new Test("Simple scheduling of a command and making sure the command is run and successfully terminates") { - public void run() { - TestCommand command = new TestCommand(); - 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); - command.setHasFinished(true); - assertCommandState(command, 1, 2, 2, 0, 0); - Scheduler.getInstance().run(); - assertCommandState(command, 1, 3, 3, 1, 0); - Scheduler.getInstance().run(); - assertCommandState(command, 1, 3, 3, 1, 0); - } - - }; - } - { - new Test("Simple scheduling of a command and making sure the command is run and cancels correctly") { - public void run() { - TestCommand command = new TestCommand(); - 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); - command.cancel(); - assertCommandState(command, 1, 3, 3, 0, 0); - Scheduler.getInstance().run(); - assertCommandState(command, 1, 3, 3, 0, 1); - Scheduler.getInstance().run(); - assertCommandState(command, 1, 3, 3, 0, 1); - } - - }; - } - - - public void assertCommandState(TestCommand command, int initialize, int execute, int isFinished, int end, int interrupted){ - assertEquals(initialize, command.getInitializeCount()); - assertEquals(execute, command.getExecuteCount()); - assertEquals(isFinished, command.getIsFinishedCount()); - assertEquals(end, command.getEndCount()); - assertEquals(interrupted, command.getInterruptedCount()); - } - -} diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/CommandSequentialGroupTest.java b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/CommandSequentialGroupTest.java deleted file mode 100644 index 1b34a0a710..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/CommandSequentialGroupTest.java +++ /dev/null @@ -1,223 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package edu.wpi.first.wpilibj.unittests; - -import edu.wpi.first.testing.TestClass; -import edu.wpi.first.wpilibj.command.Command; -import edu.wpi.first.wpilibj.command.CommandGroup; -import edu.wpi.first.wpilibj.command.Scheduler; -import edu.wpi.first.wpilibj.command.Subsystem; - -/** - * - * @author Mitchell - */ -public class CommandSequentialGroupTest extends TestClass{ - - public String getName() { - return "Command Sequential Group Test"; - } - - public String[] getTags() { - return new String[] { RunTests.Tags.Lifecycle.INPRODUCTION, - RunTests.Tags.Type.COMMANDBASED }; - } - - public void setup() { - } - - public void teardown() { - } - - private class ASubsystem extends Subsystem { - protected void initDefaultCommand(){ - } - } - - { - new Test("Simple Command Group With 3 commands that all depend on a subsystem") { - - public void run() { - final ASubsystem subsystem = new ASubsystem(); - - - TestCommand command1 = new TestCommand() { - { - requires(subsystem); - } - }; - - TestCommand command2 = new TestCommand() { - { - requires(subsystem); - } - }; - - TestCommand command3 = new TestCommand() { - { - requires(subsystem); - } - }; - - CommandGroup commandGroup = new CommandGroup(); - commandGroup.addSequential(command1); - commandGroup.addSequential(command2); - commandGroup.addSequential(command3); - - - assertCommandState(command1, 0, 0, 0, 0, 0); - assertCommandState(command2, 0, 0, 0, 0, 0); - assertCommandState(command3, 0, 0, 0, 0, 0); - 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); - command1.setHasFinished(true); - assertCommandState(command1, 1, 1, 1, 0, 0); - assertCommandState(command2, 0, 0, 0, 0, 0); - assertCommandState(command3, 0, 0, 0, 0, 0); - - Scheduler.getInstance().run(); - assertCommandState(command1, 1, 2, 2, 1, 0); - assertCommandState(command2, 1, 1, 1, 0, 0); - assertCommandState(command3, 0, 0, 0, 0, 0); - command2.setHasFinished(true); - assertCommandState(command1, 1, 2, 2, 1, 0); - assertCommandState(command2, 1, 1, 1, 0, 0); - assertCommandState(command3, 0, 0, 0, 0, 0); - - Scheduler.getInstance().run(); - assertCommandState(command1, 1, 2, 2, 1, 0); - assertCommandState(command2, 1, 2, 2, 1, 0); - assertCommandState(command3, 1, 1, 1, 0, 0); - command3.setHasFinished(true); - assertCommandState(command1, 1, 2, 2, 1, 0); - assertCommandState(command2, 1, 2, 2, 1, 0); - assertCommandState(command3, 1, 1, 1, 0, 0); - Scheduler.getInstance().run(); - assertCommandState(command1, 1, 2, 2, 1, 0); - assertCommandState(command2, 1, 2, 2, 1, 0); - assertCommandState(command3, 1, 2, 2, 1, 0); - Scheduler.getInstance().run(); - assertCommandState(command1, 1, 2, 2, 1, 0); - assertCommandState(command2, 1, 2, 2, 1, 0); - assertCommandState(command3, 1, 2, 2, 1, 0); - - } - }; - } - { - new Test("Simple Command Group With 3 commands that all depend on a subsystem. Some commands have a timeout") { - - public void run() { - final ASubsystem subsystem = new ASubsystem(); - - - TestCommand command1 = new TestCommand() { - { - requires(subsystem); - } - }; - - TestCommand command2 = new TestCommand() { - { - requires(subsystem); - } - }; - - TestCommand command3 = new TestCommand() { - { - requires(subsystem); - } - }; - - 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); - 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); - - } - }; - } - - private int testCount = 1; - public void assertCommandState(TestCommand command, int initialize, int execute, int isFinished, int end, int interrupted) { - //System.out.println("Test Command Initialize "+(testCount++)); - assertEquals(initialize, command.getInitializeCount()); - //System.out.println("Test Command Execute"); - assertEquals(execute, command.getExecuteCount()); - //System.out.println("Test Command IsFinished"); - assertEquals(isFinished, command.getIsFinishedCount()); - //System.out.println("Test Command End"); - assertEquals(end, command.getEndCount()); - //System.out.println("Test Command Interrupted"); - assertEquals(interrupted, command.getInterruptedCount()); - } - - public void sleep(long time){ - try { - Thread.sleep(time); - } catch (InterruptedException ex) { - assertFail("Sleep Interrupted!?!?!?!?"); - } - } -} diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/CommandSupercedeTest.java b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/CommandSupercedeTest.java deleted file mode 100644 index a77195eb0e..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/CommandSupercedeTest.java +++ /dev/null @@ -1,155 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package edu.wpi.first.wpilibj.unittests; - -import edu.wpi.first.testing.TestClass; -import edu.wpi.first.wpilibj.command.Scheduler; -import edu.wpi.first.wpilibj.command.Subsystem; - -/** - * - * @author Mitchell - */ -public class CommandSupercedeTest extends TestClass{ - - public String getName() { - return "Command Supercede Test"; - } - - public String[] getTags() { - return new String[] { RunTests.Tags.Lifecycle.INPRODUCTION, - RunTests.Tags.Type.COMMANDBASED }; - } - - public void setup() { - } - - public void teardown() { - } - - private class ASubsystem extends Subsystem { - protected void initDefaultCommand(){ - } - } - - { - new Test("Testing one command superceeding another because of dependancies") { - - public void run() { - final ASubsystem subsystem = new ASubsystem(); - - - TestCommand command1 = new TestCommand() { - { - requires(subsystem); - } - }; - - TestCommand command2 = new TestCommand() { - { - 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); - - } - }; - } - { - new Test("Testing one command failing superceeding another because of dependancies because the first command cannot be interrupted") { - - public void run() { - final ASubsystem subsystem = new ASubsystem(); - - - TestCommand command1 = new TestCommand() { - { - requires(subsystem); - setInterruptible(false); - } - }; - - TestCommand command2 = new TestCommand() { - { - 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); - - } - }; - } - - private int testCount = 1; - public void assertCommandState(TestCommand command, int initialize, int execute, int isFinished, int end, int interrupted) { - //System.out.println("Test Command Initialize "+(testCount++)); - assertEquals(initialize, command.getInitializeCount()); - //System.out.println("Test Command Execute"); - assertEquals(execute, command.getExecuteCount()); - //System.out.println("Test Command IsFinished"); - assertEquals(isFinished, command.getIsFinishedCount()); - //System.out.println("Test Command End"); - assertEquals(end, command.getEndCount()); - //System.out.println("Test Command Interrupted"); - assertEquals(interrupted, command.getInterruptedCount()); - } -} diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/CommandTimeoutTest.java b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/CommandTimeoutTest.java deleted file mode 100644 index 290893b5bb..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/CommandTimeoutTest.java +++ /dev/null @@ -1,98 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package edu.wpi.first.wpilibj.unittests; - -import edu.wpi.first.testing.TestClass; -import edu.wpi.first.testing.TestClass.Test; -import edu.wpi.first.wpilibj.command.Command; -import edu.wpi.first.wpilibj.command.CommandGroup; -import edu.wpi.first.wpilibj.command.Scheduler; -import edu.wpi.first.wpilibj.command.Subsystem; - -/** - * - * @author Mitchell - */ -public class CommandTimeoutTest extends TestClass{ - - public String getName() { - return "Command Timeout Test"; - } - - public String[] getTags() { - return new String[] { RunTests.Tags.Lifecycle.INPRODUCTION, - RunTests.Tags.Type.COMMANDBASED }; - } - - - public void setup() { - } - - public void teardown() { - } - - private class ASubsystem extends Subsystem { - protected void initDefaultCommand(){ - } - } - - { - new Test("Command 2 second Timeout Test") { - - public void run() { - final ASubsystem subsystem = new ASubsystem(); - - - TestCommand command = new TestCommand() { - { - requires(subsystem); - setTimeout(2); - } - 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); - } - }; - } - - private int testCount = 1; - public void assertCommandState(TestCommand command, int initialize, int execute, int isFinished, int end, int interrupted) { - //System.out.println("Test Command Initialize "+(testCount++)); - assertEquals(initialize, command.getInitializeCount()); - //System.out.println("Test Command Execute"); - assertEquals(execute, command.getExecuteCount()); - //System.out.println("Test Command IsFinished"); - assertEquals(isFinished, command.getIsFinishedCount()); - //System.out.println("Test Command End"); - assertEquals(end, command.getEndCount()); - //System.out.println("Test Command Interrupted"); - assertEquals(interrupted, command.getInterruptedCount()); - } - - public void sleep(long time){ - try { - Thread.sleep(time); - } catch (InterruptedException ex) { - assertFail("Sleep Interrupted!?!?!?!?"); - } - } -} diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/DIOToDIOTest.java b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/DIOToDIOTest.java deleted file mode 100644 index 78359e3b3c..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/DIOToDIOTest.java +++ /dev/null @@ -1,54 +0,0 @@ -package edu.wpi.first.wpilibj.unittests; - -import Assemblies.DIOCrossConnect; -import edu.wpi.first.testing.TestClass; -import edu.wpi.first.wpilibj.DigitalInput; -import edu.wpi.first.wpilibj.DigitalOutput; - -/** - * Tests the crossed DIO lines between the two digital sidecars on the - * version 2.1 test stand by Chris Jennings. - * - * @author Paul - */ -public class DIOToDIOTest extends TestClass { - private DigitalOutput m_AOut; - private DigitalInput m_AIn; - - public String getName() { - return "DIOToDIOTest"; - } - - public String[] getTags() { - return new String[] {RunTests.Tags.Lifecycle.INPRODUCTION, - RunTests.Tags.Type.DIGITAL}; - } - - public void setup() { - m_AOut = DIOCrossConnect.getOutputA(); - m_AIn = DIOCrossConnect.getInputA(); - } - - { - new Test("SignalALowDetected") { - - public void run() { - m_AOut.set(false); - assertFalse(m_AIn.get()); - } - }; - - new Test("SignalAHighDetected") { - - public void run() { - m_AOut.set(true); - assertTrue(m_AIn.get()); - } - }; - } - - public void teardown() { - m_AIn.free(); - m_AOut.free(); - } -} diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/DefaultCommandsTest.java b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/DefaultCommandsTest.java deleted file mode 100644 index e631d53979..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/DefaultCommandsTest.java +++ /dev/null @@ -1,168 +0,0 @@ -package edu.wpi.first.wpilibj.unittests; - -import edu.wpi.first.testing.TestClass; -import edu.wpi.first.testing.TestClass.Test; -import edu.wpi.first.wpilibj.command.Command; -import edu.wpi.first.wpilibj.command.Scheduler; -import edu.wpi.first.wpilibj.command.Subsystem; - -/** - * - * @author mwills - */ -public class DefaultCommandsTest extends TestClass { - - public String getName() { - return "Default Commands Test"; - } - - public String[] getTags() { - return new String[] { RunTests.Tags.Lifecycle.INPRODUCTION, - RunTests.Tags.Type.COMMANDBASED }; - } - - public void setup() { - } - - public void teardown() { - } - - private class ASubsystem extends Subsystem { - Command command; - protected void initDefaultCommand(){ - setDefaultCommand(command); - } - public void init(Command command) { - this.command = command; - } - } - - { - new Test("Testing of default commands where the interrupting command is ends itself") { - - public void run() { - final ASubsystem subsystem = new ASubsystem(); - - - TestCommand defaultCommand = new TestCommand() { - { - requires(subsystem); - } - }; - - TestCommand anotherCommand = new TestCommand() { - { - 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); - - } - }; - } - - { - new Test("Testing of default commands where the interrupting command is canceled") { - - public void run() { - final ASubsystem subsystem = new ASubsystem(); - - - TestCommand defaultCommand = new TestCommand() { - { - requires(subsystem); - } - }; - - TestCommand anotherCommand = new TestCommand() { - { - 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); - - } - }; - } - - public void assertCommandState(TestCommand command, int initialize, int execute, int isFinished, int end, int interrupted) { - //System.out.println("Test Command Initialize"); - assertEquals(initialize, command.getInitializeCount()); - //System.out.println("Test Command Execute"); - assertEquals(execute, command.getExecuteCount()); - //System.out.println("Test Command IsFinished"); - assertEquals(isFinished, command.getIsFinishedCount()); - //System.out.println("Test Command End"); - assertEquals(end, command.getEndCount()); - //System.out.println("Test Command Interrupted"); - assertEquals(interrupted, command.getInterruptedCount()); - } -} diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/EncoderTest.java b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/EncoderTest.java deleted file mode 100644 index 59e35ffdba..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/EncoderTest.java +++ /dev/null @@ -1,122 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package edu.wpi.first.wpilibj.unittests; - -import Assemblies.MagneticRotaryAssembly; -import edu.wpi.first.testing.TestClass; -import edu.wpi.first.wpilibj.Counter; -import edu.wpi.first.wpilibj.DigitalOutput; -import edu.wpi.first.wpilibj.Encoder; -import edu.wpi.first.wpilibj.Jaguar; -import edu.wpi.first.wpilibj.Timer; - -/** - * - * @author brad - */ -public class EncoderTest extends TestClass { - - private Encoder encoder; - private Jaguar jag; - private DigitalOutput fwdLimit; - private DigitalOutput revLimit; - private Counter gts; - - public String getName() { - return "Encoder test"; - } - - public String[] getTags() { - return new String[] { RunTests.Tags.Lifecycle.INPRODUCTION, - RunTests.Tags.Type.DIGITAL, - RunTests.Tags.Type.PWM, - }; - } - - public void setup() { - encoder = MagneticRotaryAssembly.getEncoder(); - jag = MagneticRotaryAssembly.getJaguar(); - fwdLimit = MagneticRotaryAssembly.getLimitSWFwd(); - revLimit = MagneticRotaryAssembly.getLimitSWRev(); - gts = MagneticRotaryAssembly.getGTS(); - fwdLimit.set(false); - revLimit.set(false); - } - - public void teardown() { - encoder.free(); - jag.free(); - fwdLimit.free(); - revLimit.free(); - gts.free(); - } - - { - new Test("Compare Encoder with Geartooth sensor") { - - /** - * Drive forward for a fixed time - */ - private int driveForward(double time) { - encoder.reset(); - encoder.start(); - jag.set(1); - Timer.delay(time); - jag.set(0); - return encoder.get(); - } - - public void run() { - gts.reset(); - gts.start(); - driveForward(2); - Timer.delay(2); - System.out.println("Gear tooth sensor: " + gts.get()); - System.out.println("Encoder: " + encoder.get()); - } - - }; - } - - { - new Test("Drive forward then backward") { - - /** - * Drive forward for a fixed time - */ - private int driveForward(double time) { - encoder.reset(); - encoder.start(); - jag.set(1); - Timer.delay(time); - jag.set(0); - return encoder.get(); - } - - /** - * Drive forward then let the motor stop, then drive forward again. Compare the results. - * Then drive backwards, and see that the results have gone back near zero. - * - * This is pretty cheesy, and needs to be replaced with a test that compares the gear tooth - * sensor with the encoder. - */ - public void run() { - - int pass1 = driveForward(1); - assertEquals(1064, pass1, 50); - - Timer.delay(2); // wait for motor to stop - - int pass2 = driveForward(1); - assertEquals(0, pass1-pass2, (int)(pass1*0.05)); - - jag.set(-1); - Timer.delay(1); - jag.set(0); - assertEquals(0, encoder.get(), (int)(pass1*0.10)); - } - }; - } -} diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/FakeEncoderTest.java b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/FakeEncoderTest.java deleted file mode 100644 index 1c2c07c49e..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/FakeEncoderTest.java +++ /dev/null @@ -1,67 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2008. 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.unittests; - -import Assemblies.FakeCounterSource; -import edu.wpi.first.testing.Connections; -import edu.wpi.first.testing.TestClass; -import edu.wpi.first.wpilibj.Counter; - -/** - * @file FakeEncoderTest.java - * Test the fake encoder classes to verify they are valid for future test use - * @author Ryan O'Meara - */ -public class FakeEncoderTest extends TestClass implements Connections -{ - private Counter counter; - private FakeCounterSource fakeEncoder; - - public String getName() - { - return "FakeEncoder Test"; - } - - public String[] getTags() { - return new String[] { RunTests.Tags.Lifecycle.INPRODUCTION, - RunTests.Tags.Type.DIGITAL }; - } - - public void setup() - { - counter = new Counter(DIOCrossConnectD1); - fakeEncoder = new FakeCounterSource(2, DIOCrossConnectD2); - } - - public void teardown() - { - counter.free(); - fakeEncoder.free(); - } - - - { - new Test("Counting accuracy") - { - - public void run() - { - final int MAXCOUNT = 500; - counter.reset(); - counter.start(); - - fakeEncoder.setCount(MAXCOUNT); - fakeEncoder.setRate(1); - fakeEncoder.execute(); - assertEquals(counter.get(), MAXCOUNT); - counter.stop(); - - } - }; - } -} diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/FakeQuadEncoderTest.java b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/FakeQuadEncoderTest.java deleted file mode 100644 index 8599f1ce66..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/FakeQuadEncoderTest.java +++ /dev/null @@ -1,94 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2008. 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.unittests; - -import Assemblies.FakeEncoderSource; -import edu.wpi.first.testing.Connections; -import edu.wpi.first.testing.TestClass; -import edu.wpi.first.wpilibj.Counter; - -/** - * @file FakeEncoderTest.java - * Test the fake encoder classes to verify they are valid for future test use - * @author Ryan O'Meara - */ -public class FakeQuadEncoderTest extends TestClass implements Connections -{ - - private final int MAXCOUNT = 500; - private Counter counter; - private Counter counter2; - private FakeEncoderSource fakeQEncoder; - - public String getName() - { - return "FakeQuadEncoder Test"; - } - - public String[] getTags() { - return new String[] { RunTests.Tags.Lifecycle.INPRODUCTION, - RunTests.Tags.Type.DIGITAL }; - } - - public void setup() - { - counter = new Counter(DIOCrossConnectA1); - counter2 = new Counter(DIOCrossConnectB1); - fakeQEncoder = new FakeEncoderSource(2, DIOCrossConnectA2, 2, DIOCrossConnectB2); - } - - public void teardown() - { - counter.free(); - counter2.free(); - fakeQEncoder.free(); - } - - - { - new Test("Forward counting") - { - - public void run() - { - counter.reset(); - counter2.reset(); - - fakeQEncoder.setCount(MAXCOUNT); - fakeQEncoder.setRate(1); - counter.start(); - counter2.start(); - fakeQEncoder.execute(); - assertEquals(counter.get(), MAXCOUNT); - assertEquals(counter2.get(), MAXCOUNT); - } - }; - - new Test("Reverse counting") - { - - public void run() - { - counter.reset(); - counter2.reset(); - fakeQEncoder.setForward(false); - fakeQEncoder.setCount(MAXCOUNT); - fakeQEncoder.setRate(1); - counter.start(); - counter2.start(); - fakeQEncoder.execute(); - - assertEquals(counter.get(), MAXCOUNT); - assertEquals(counter2.get(), MAXCOUNT); - - counter.stop(); - counter2.stop(); - } - }; - } -} diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/GyroTest.java b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/GyroTest.java deleted file mode 100644 index 33e9294e72..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/GyroTest.java +++ /dev/null @@ -1,113 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package edu.wpi.first.wpilibj.unittests; - -import Assemblies.RCAssembly; -import edu.wpi.first.testing.TestClass; -import edu.wpi.first.wpilibj.Gyro; -import edu.wpi.first.wpilibj.Servo; -import edu.wpi.first.wpilibj.Timer; - -/** - * - * @author mwills - */ -public class GyroTest extends TestClass{ - private Gyro gyro; - private Servo servo; - public String getName() { - return "Gyro Test"; - } - - public String[] getTags() { - return new String[] { RunTests.Tags.Lifecycle.INDEVEL, - RunTests.Tags.Type.ANALOG }; - } - - public void setup() { - gyro = RCAssembly.getGyro(); - servo = RCAssembly.getServo(); - } - - public void teardown() { - gyro.free(); - servo.free(); - } - - { - new TestUnderDevelopment("Gyro connected to servo panning one way") { - public void run() { - servo.set(0); - Timer.delay(3); - gyro.reset(); - servo.set(1); - Timer.delay(3); - assertEquals(138, gyro.getAngle(), 1); - } - - }; - } - - { - new TestUnderDevelopment("Gyro connected to servo panning back and forth once") { - public void run() { - servo.set(0); - Timer.delay(3); - gyro.reset(); - servo.set(1); - Timer.delay(3); - servo.set(0); - Timer.delay(3); - - assertEquals(0, gyro.getAngle(), .3); - } - - }; - } - - { - new TestUnderDevelopment("Gyro connected to servo panning back and forth 5 times") { - public void run() { - servo.set(0); - Timer.delay(3); - gyro.reset(); - for(int i = 0; i<5; ++i){ - servo.set(1); - Timer.delay(3); - servo.set(0); - Timer.delay(3); - } - - assertEquals(0, gyro.getAngle(), 1); - } - - }; - } - - { - new TestUnderDevelopment("Gyro connected to servo panning back and forth to many positions") { - public void run() { - servo.set(0); - Timer.delay(3); - gyro.reset(); - - servo.set(0.5); - Timer.delay(1); - servo.set(0.75); - Timer.delay(1); - servo.set(0.25); - Timer.delay(1); - servo.set(1); - Timer.delay(1); - servo.set(0); - Timer.delay(3); - - assertEquals(0, gyro.getAngle(), 1.2); - } - - }; - } - -} diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/JaguarTest.java b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/JaguarTest.java deleted file mode 100644 index 30b86d9c7c..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/JaguarTest.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package edu.wpi.first.wpilibj.unittests; - -import edu.wpi.first.testing.Connections; -import edu.wpi.first.testing.TestClass; -import edu.wpi.first.wpilibj.Counter; -import edu.wpi.first.wpilibj.DigitalInput; -import edu.wpi.first.wpilibj.Timer; -import edu.wpi.first.wpilibj.Victor; - -/** - * - * @author brad - */ -public class JaguarTest extends TestClass implements Connections { - - Victor victor; - Counter gts; - - public String getName() { - return "JaguarTest"; - } - - public String[] getTags() { - return new String[] { RunTests.Tags.Lifecycle.INPRODUCTION, - RunTests.Tags.Type.DIGITAL, - RunTests.Tags.Type.PWM - }; - } - - public void setup() { - victor = new Victor(2); - gts = new Counter(2, GreyJagGearTooth); // need to encode this slot number - } - - public void teardown() { - victor.free(); - gts.free(); - } - - { - new Test("Drive forward") { - - public void run() { - gts.reset(); - gts.start(); - victor.set(1); - Timer.delay(1); - victor.set(0); - System.out.println("Counter output: " + gts.get()); - - assertEquals(0.0, 0.1, 0.1); - } - }; - - new Test("Drive backward") { - - public void run() { - victor.set(-1); - Timer.delay(1); - victor.set(0); - - assertEquals(0.0, 0.1, 0.1); - } - }; - } -} diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/PIDEncoderTest.java b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/PIDEncoderTest.java deleted file mode 100644 index dbfb2482fd..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/PIDEncoderTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package edu.wpi.first.wpilibj.unittests; - -import Assemblies.MagneticRotaryAssembly; -import edu.wpi.first.testing.TestClass; -import edu.wpi.first.wpilibj.DigitalOutput; -import edu.wpi.first.wpilibj.Encoder; -import edu.wpi.first.wpilibj.Jaguar; -import edu.wpi.first.wpilibj.PIDController; -import edu.wpi.first.wpilibj.Timer; - -/** - * - * @author Fred - */ -public class PIDEncoderTest extends TestClass { - - private Encoder encoder; - private Jaguar jag; - private PIDController PID; - private DigitalOutput fwdLimit; - private DigitalOutput revLimit; - - public String getName() { - return "PID Encoder Test"; - } - - public String[] getTags() { - return new String[] { RunTests.Tags.Lifecycle.INPRODUCTION, - RunTests.Tags.Type.DIGITAL, RunTests.Tags.Type.PWM }; - } - - public void setup() { - encoder = MagneticRotaryAssembly.getEncoder(); - jag = MagneticRotaryAssembly.getJaguar(); - encoder.setPIDSourceParameter(Encoder.PIDSourceParameter.kDistance); - PID = new PIDController(.01, 0, 0, encoder, jag); - fwdLimit = MagneticRotaryAssembly.getLimitSWFwd(); - revLimit = MagneticRotaryAssembly.getLimitSWRev(); - fwdLimit.set(false); - revLimit.set(false); - } - - public void teardown() { - encoder.free(); - jag.free(); - PID.disable(); - fwdLimit.free(); - revLimit.free(); - } - - { - new Test("Set PID Setpoint to 1000 and confirm running forward") { - private void runPID() { - PID.setSetpoint(1000); - Timer.delay(3); - } - - public void run() { - encoder.reset(); - encoder.start(); - PID.reset(); - PID.enable(); - runPID(); - // while (true) { - // System.out.println("Setpoint: " + PID.getSetpoint() - // + " Value: " + PID.get() + " Encoder: " - // + encoder.getDistance() + " Jaguar: " + jag.get()); - // } - assertEquals(1000, encoder.getDistance(), 15); - } - }; - new Test("Set PID Setpoint to 0 and confirm running backwards") { - private void reversePID() { - PID.setSetpoint(0); - Timer.delay(3); - } - - public void run() { - reversePID(); - assertEquals(0, encoder.getDistance(), 15); - } - }; - } -} diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/PreferencesTest.java b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/PreferencesTest.java deleted file mode 100644 index 91c9473fcd..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/PreferencesTest.java +++ /dev/null @@ -1,104 +0,0 @@ -/* - * To change this template, choose Tools | Templates - * and open the template in the editor. - */ -package edu.wpi.first.wpilibj.unittests; - -import edu.wpi.first.testing.TestClass; -import edu.wpi.first.wpilibj.Preferences; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStream; - -/** - * - * @author Fred - */ -public class PreferencesTest extends TestClass { - - private Preferences pref; - private long check; - - public String getName() { - return "Preferences test"; - } - - public String[] getTags() { - return new String[] { RunTests.Tags.Lifecycle.INPRODUCTION, - RunTests.Tags.Type.PREFERENCES }; - } - - public void setup() { - try { - File file = new File("file:///wpilib-preferences.ini"); - file.mkdirs(); - if (file.exists()) { - file.delete(); - } - file.createNewFile(); - OutputStream output = new FileOutputStream(file); - output.write("checkedValueInt = 2\ncheckedValueDouble = .2\ncheckedValueFloat = 3.14\ncheckedValueLong = 172\ncheckedValueString =\"hello \nHow are you ?\"\ncheckedValueBoolean = false" - .getBytes()); - - } catch (IOException e) { - e.printStackTrace(); - } - - pref = Preferences.getInstance(); - check = System.currentTimeMillis(); - } - - public void teardown() { - } - - { - new Test("Check preferences file operations") { - - public void remove() { - pref.remove("checkedValueLong"); - pref.remove("checkedValueDouble"); - pref.remove("checkedValueString"); - pref.remove("checkedValueInt"); - pref.remove("checkedValueFloat"); - pref.remove("checkedValueBoolean"); - } - - public void addCheckedValue() { - pref.putLong("checkedValueLong", check); - pref.putDouble("checkedValueDouble", 1); - pref.putString("checkedValueString", "checked"); - pref.putInt("checkedValueInt", 1); - pref.putFloat("checkedValueFloat", 1); - pref.putBoolean("checkedValueBoolean", true); - } - - public void run() { - assertEquals(pref.getLong("checkedValueLong", 0), 172); - assertEquals(pref.getDouble("checkedValueDouble", 0), .2); - assertEquals(pref.getString("checkedValueString", ""), - "hello \nHow are you ?"); - assertEquals(pref.getInt("checkedValueInt", 0), 2); - assertEquals(pref.getFloat("checkedValueFloat", 0), 3.14, .001); - assertFalse(pref.getBoolean("checkedValueBoolean", true)); - remove(); - assertEquals(pref.getLong("checkedValueLong", 0), 0); - assertEquals(pref.getDouble("checkedValueDouble", 0), 0); - assertEquals(pref.getString("checkedValueString", ""), ""); - assertEquals(pref.getInt("checkedValueInt", 0), 0); - assertEquals(pref.getFloat("checkedValueFloat", 0), 0); - assertFalse(pref.getBoolean("checkedValueBoolean", false)); - addCheckedValue(); - pref.save(); - assertEquals(check, pref.getLong("checkedValueLong", 0)); - assertEquals(pref.getDouble("checkedValueDouble", 0), 1); - assertEquals(pref.getString("checkedValueString", ""), - "checked"); - assertEquals(pref.getInt("checkedValueInt", 0), 1); - assertEquals(pref.getFloat("checkedValueFloat", 0), 1); - assertTrue(pref.getBoolean("checkedValueBoolean", false)); - } - }; - } -} diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/RunTests.java b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/RunTests.java deleted file mode 100644 index 2ae7fcaf63..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/RunTests.java +++ /dev/null @@ -1,76 +0,0 @@ -/*----------------------------------------------------------------------------*/ -/* Copyright (c) FIRST 2008. 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.unittests; - -import edu.wpi.first.testing.TestClass; -import edu.wpi.first.wpilibj.SimpleRobot; - - -/** - * The VM is configured to automatically run this class, and to call the - * functions corresponding to each mode, as described in the SimpleRobot - * documentation. If you change the name of this class or the package after - * creating this project, you must also update the manifest file in the resource - * directory. - */ -public class RunTests extends SimpleRobot { - public class Tags { - // Test life-cycle - public class Lifecycle { - public static final String INDEVEL = "in-dev"; - public static final String INTEST = "in-test"; - public static final String INPRODUCTION = "in-production"; - public static final String DEPRECATED = "deprecated"; - } - - // Type of test - public class Type { - public static final String DIGITAL = "digital"; - public static final String ANALOG = "analog"; - public static final String COMMANDBASED = "command-based-robot"; - public static final String PWM = "pwm"; - public static final String PREFERENCES = "preferences"; - public static final String NETWORKTABLES = "networktables"; - } - } - - public void robotInit() { - System.out.println("!!! WAITING FOR ENABLE"); - } - /** - * This function is called once each time the robot enters autonomous mode. - */ - public void autonomous() { - - } - - /** - * This function is called once each time the robot enters operator control. - */ - public void operatorControl() { - System.out.println("!!! TESTS BEGINNING"); - - runTests(); - - System.out.println("!!! TESTS COMPLETE"); - } - - private void runTests() { - // Uncomment line below to run tests that are not yet trustworthy - // Do not check this in! - //TestClass.runAllWithTag(Tags.Lifecycle.INDEVEL); - // Uncomment line below to run tests related to networktables - // Do not check this in! - //TestClass.runAllWithTag(Tags.Type.NETWORKTABLES); - TestClass.runAllWithTag(Tags.Lifecycle.INTEST); - TestClass.runAllWithTag(Tags.Lifecycle.INPRODUCTION); - - System.out.println("##### The following tests (if any) are deprecated #####"); - //TestClass.runAllWithTag(Tags.Lifecycle.DEPRECATED); - } -} diff --git a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/TestCommand.java b/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/TestCommand.java deleted file mode 100644 index 41d4b12d9d..0000000000 --- a/wpilibj/RunTestsProject/src/main/java/edu/wpi/first/wpilibj/unittests/TestCommand.java +++ /dev/null @@ -1,113 +0,0 @@ -package edu.wpi.first.wpilibj.unittests; - -import edu.wpi.first.wpilibj.command.Command; - -/** - * A class to simulate a simple command - * The command keeps track of how many times each method was called - * - * @author mwills - */ -public class TestCommand extends Command{ - private int initializeCount = 0; - private int executeCount = 0; - private int isFinishedCount = 0; - private boolean hasFinished = false; - private int endCount = 0; - private int interruptedCount = 0; - - protected void initialize() { - ++initializeCount; - } - - protected void execute() { - ++executeCount; - } - - protected boolean isFinished() { - ++isFinishedCount; - return isHasFinished(); - } - - protected void end() { - ++endCount; - } - - protected void interrupted() { - ++interruptedCount; - } - - - - - - - - /** - * @return how many times the initialize method has been called - */ - public int getInitializeCount() { - return initializeCount; - } - /** - * @return if the initialize method has been called at least once - */ - public boolean hasInitialized(){ - return getInitializeCount()>0; - } - - /** - * @return how many time the execute method has been called - */ - public int getExecuteCount() { - return executeCount; - } - - /** - * @return how many times the isFinished method has been called - */ - public int getIsFinishedCount() { - return isFinishedCount; - } - - /** - * @return what value the isFinished method will return - */ - public boolean isHasFinished() { - return hasFinished; - } - - /** - * @param set what value the isFinished method will return - */ - public void setHasFinished(boolean hasFinished) { - this.hasFinished = hasFinished; - } - - /** - * @return how many times the end method has been called - */ - public int getEndCount() { - return endCount; - } - /** - * @return if the end method has been called at least once - */ - public boolean hasEnd(){ - return getEndCount()>0; - } - - /** - * @return how many times the interrupted method has been called - */ - public int getInterruptedCount() { - return interruptedCount; - } - /** - * @return if the interrupted method has been called at least once - */ - public boolean hasInterrupted(){ - return getInterruptedCount()>0; - } - -} diff --git a/wpilibj/build.properties b/wpilibj/build.properties deleted file mode 100644 index 3c97bea040..0000000000 --- a/wpilibj/build.properties +++ /dev/null @@ -1,2 +0,0 @@ -preverify.exclude.library.jars=true -alternate.wpilibj.archive= \ No newline at end of file diff --git a/wpilibj/build.xml b/wpilibj/build.xml deleted file mode 100644 index 2d2da161a2..0000000000 --- a/wpilibj/build.xml +++ /dev/null @@ -1,82 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Building NetworkTables 2.0 - Build Number: ${BUILD_NUMBER} - Build Time: ${BUILD_ID} - SVN Revision: ${SVN_REVISION} - Build Type: ${BUILD_TYPE} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/wpilibj/nbproject/project.bak.xml b/wpilibj/nbproject/project.bak.xml deleted file mode 100644 index e4c6adef60..0000000000 --- a/wpilibj/nbproject/project.bak.xml +++ /dev/null @@ -1,90 +0,0 @@ - - - org.netbeans.modules.ant.freeform - - - WPILibJ - - ${user.home}/.sunspotfrc.properties - build.properties - ${sunspot.home}/default.properties - - - - - java - src - - - - java - tests - - - - - dist - - - clean - - - deploy-tests - run - - - clean - dist - - - deploy - debug-run - - - - folder - build - dist - - - - - - src - - - - tests - - - build.xml - - - - - - - - - - - - - - - - src - tests - ${sunspot.home}\lib\squawk.jar - ${sunspot.home}\lib\networktables-crio.jar;${sunspot.home}\lib\sunit-server.jar - build - 1.3 - - - - diff --git a/wpilibj/nbproject/project.xml b/wpilibj/nbproject/project.xml deleted file mode 100644 index f9536c495c..0000000000 --- a/wpilibj/nbproject/project.xml +++ /dev/null @@ -1,99 +0,0 @@ - - org.netbeans.modules.ant.freeform - - - WPILibJ - - - WPILibJ - - ${user.home}/.sunspotfrc.properties - build.properties - ${sunspot.home}/default.properties - - - - - java - tests - UTF-8 - - - - java - src/main/java - UTF-8 - - - - . - UTF-8 - - - - - dist - - - clean - - - deploy-tests - run - - - clean - dist - - - deploy - debug-run - - - - folder - build - dist - - - - - - tests - - - - src/main/java - - - build.xml - - - - - - - - - - - - - - - - tests - src/main/java - ${sunspot.home}/lib/squawk.jar - ${sunspot.home}/lib/networktables-crio.jar - build - 1.3 - - - - diff --git a/wpilibj/wpilibJavaIntegrationTests/README.md b/wpilibj/wpilibJavaIntegrationTests/README.md index e4199f9eb6..0df86c7f5e 100644 --- a/wpilibj/wpilibJavaIntegrationTests/README.md +++ b/wpilibj/wpilibJavaIntegrationTests/README.md @@ -1,7 +1,7 @@ -TO LOAD & RUN INTEGRATION TESTS +TO LOAD & RUN INTEGRATION TESTS -1) Run 'mvn clean package' from this directory -2) Run 'scp target/wpilibJavaIntegrationTests-0.1.0-SNAPSHOT.jar admin@10.1.90.2:/home/admin' and enter the password on the RoboRio -3) ssh into the RoboRio using 'ssh admin@10.1.90.2' -4) Run the integration tests on the roborio using './runintegrationjavaprogram' -5) Enable the robot using a driver station (this will be automatic eventually) +1. Run `mvn clean package` from this directory +2. Run `scp target/wpilibJavaIntegrationTests-0.1.0-SNAPSHOT.jar admin@10.1.90.2:/home/admin` and enter the password on the RoboRio +3. ssh into the RoboRio using `ssh admin@10.1.90.2` +4. Run the integration tests on the roborio using `./runintegrationjavaprogram` +5. Enable the robot using a driver station (this will be automatic eventually)