mirror of
https://github.com/wpilibsuite/allwpilib
synced 2026-06-21 01:01:43 +00:00
Applies Google Styleguide to Java parts of the library (#23)
This was partially applied to simulation but simulation is a bit of a mess and has a lot of duplicated code.
This commit is contained in:
committed by
Peter Johnson
parent
64ab6e51fe
commit
a834fff7b2
@@ -7,15 +7,6 @@
|
||||
|
||||
package edu.wpi.first.wpilibj;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.BeforeClass;
|
||||
@@ -24,18 +15,30 @@ import org.junit.runner.RunWith;
|
||||
import org.junit.runners.Parameterized;
|
||||
import org.junit.runners.Parameterized.Parameters;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import edu.wpi.first.wpilibj.can.CANMessageNotFoundException;
|
||||
import edu.wpi.first.wpilibj.fixtures.MotorEncoderFixture;
|
||||
import edu.wpi.first.wpilibj.test.AbstractComsSetup;
|
||||
import edu.wpi.first.wpilibj.test.TestBench;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
||||
/**
|
||||
* Test that covers the {@link PowerDistributionPanel}.
|
||||
*/
|
||||
@RunWith(Parameterized.class)
|
||||
public class PDPTest extends AbstractComsSetup {
|
||||
private static final Logger logger = Logger.getLogger(PCMTest.class.getName());
|
||||
|
||||
private static PowerDistributionPanel pdp;
|
||||
private static MotorEncoderFixture<?> me;
|
||||
private final double expectedStoppedCurrentDraw;
|
||||
private final double m_expectedStoppedCurrentDraw;
|
||||
|
||||
@BeforeClass
|
||||
public static void setUpBeforeClass() throws Exception {
|
||||
@@ -51,20 +54,22 @@ public class PDPTest extends AbstractComsSetup {
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("JavadocMethod")
|
||||
public PDPTest(MotorEncoderFixture<?> mef, Double expectedCurrentDraw) {
|
||||
logger.fine("Constructor with: " + mef.getType());
|
||||
if (me != null && !me.equals(mef))
|
||||
if (me != null && !me.equals(mef)) {
|
||||
me.teardown();
|
||||
}
|
||||
me = mef;
|
||||
me.setup();
|
||||
|
||||
this.expectedStoppedCurrentDraw = expectedCurrentDraw;
|
||||
m_expectedStoppedCurrentDraw = expectedCurrentDraw;
|
||||
}
|
||||
|
||||
@Parameters(name = "{index}: {0}, Expected Stopped Current Draw: {1}")
|
||||
public static Collection<Object[]> generateData() {
|
||||
// logger.fine("Loading the MotorList");
|
||||
return Arrays.asList(new Object[][] {
|
||||
return Arrays.asList(new Object[][]{
|
||||
{TestBench.getInstance().getTalonPair(), new Double(0.0)}});
|
||||
}
|
||||
|
||||
@@ -74,24 +79,23 @@ public class PDPTest extends AbstractComsSetup {
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Test if the current changes when the motor is driven using a talon
|
||||
* Test if the current changes when the motor is driven using a talon.
|
||||
*/
|
||||
@Test
|
||||
public void CheckStoppedCurrentForSpeedController() throws CANMessageNotFoundException {
|
||||
public void checkStoppedCurrentForSpeedController() throws CANMessageNotFoundException {
|
||||
Timer.delay(0.25);
|
||||
|
||||
/* The Current should be 0 */
|
||||
assertEquals("The low current was not within the expected range.", expectedStoppedCurrentDraw,
|
||||
assertEquals("The low current was not within the expected range.", m_expectedStoppedCurrentDraw,
|
||||
pdp.getCurrent(me.getPDPChannel()), 0.001);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test if the current changes when the motor is driven using a talon
|
||||
* Test if the current changes when the motor is driven using a talon.
|
||||
*/
|
||||
@Test
|
||||
public void CheckRunningCurrentForSpeedController() throws CANMessageNotFoundException {
|
||||
public void checkRunningCurrentForSpeedController() throws CANMessageNotFoundException {
|
||||
|
||||
/* Set the motor to full forward */
|
||||
me.getMotor().set(1.0);
|
||||
@@ -99,7 +103,7 @@ public class PDPTest extends AbstractComsSetup {
|
||||
|
||||
/* The current should now be greater than the low current */
|
||||
assertThat("The driven current is not greater than the resting current.",
|
||||
pdp.getCurrent(me.getPDPChannel()), is(greaterThan(expectedStoppedCurrentDraw)));
|
||||
pdp.getCurrent(me.getPDPChannel()), is(greaterThan(m_expectedStoppedCurrentDraw)));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user