Squashed 'third_party/allwpilib/' changes from 66b57f032..e473a00f9
e473a00f9 [wpiutil] Base64: Add unsigned span/vector variants (#3702)
52f2d580e [wpiutil] raw_uv_ostream: Add reset() (#3701)
d7b1e3576 [wpiutil] WebSocket: move std::function (#3700)
93799fbe9 [examples] Fix description of TrapezoidProfileSubsystem (#3699)
b84644740 [wpimath] Document pose estimator states, inputs, and outputs (#3698)
2dc35c139 [wpimath] Fix classpaths for JNI class loads (#3697)
2cb171f6f [docs] Set Doxygen extract_all to true and fix Doxygen failures (#3695)
a939cd9c8 [wpimath] Print uncontrollable/unobservable models in LQR and KF (#3694)
d5270d113 [wpimath] Clean up C++ StateSpaceUtil tests (#3692)
b20903960 [wpimath] Remove redundant discretization tests from StateSpaceUtilTest (#3689)
c0cb545b4 [wpilibc] Add deprecated Doxygen attribute to SpeedController (#3691)
35c9f66a7 [wpilib] Rename PneumaticsHub to PneumaticHub (#3686)
796d03d10 [wpiutil] Remove unused LLVM header (#3688)
8723caf78 [wpilibj] Make Java TrapezoidProfile.Constraints an immutable class (#3687)
187f50a34 [wpimath] Catch incorrect parameters to state-space models earlier (#3680)
8d04606c4 Replace instances of frc-characterization with SysId (NFC) (#3681)
b82d4f6e5 [hal, cscore, ntcore] Use WPI common handle type base
87e34967e [wpiutil] Add synchronization primitives
e32499c54 [wpiutil] Add ParallelTcpConnector (#3655)
aa0b49228 [wpilib] Remove redundant "quick turn" docs for curvature drive (NFC) (#3674)
57301a7f9 [hal] REVPH: Start closed-loop compressor control on init (#3673)
d1842ea8f [wpilib] Improve interrupt docs (NFC) (#3679)
558151061 [wpiutil] Add DsClient (#3654)
181723e57 Replace `.to<double>()` and `.template to<double>()` with `.value()` (#3667)
6bc1db44b [commands] Add pointer overload of AddRequirements (artf6003) (#3669)
737b57ed5 [wpimath] Update to drake v0.35.0 (#3665)
4d287d1ae [build] Upgrade WPIJREArtifact to JRE 2022-11.0.12u5 (#3666)
f26eb5ada [hal] Fix another typo (get -> gets) (NFC) (#3663)
94ed275ba [hal] Fix misspelling (numer -> number) (NFC) (#3662)
ac2f44da3 [wpiutil] uv: use move for std::function (#3653)
75fa1fbfb [wpiutil] json::serializer: Optimize construction (#3647)
5e689faea [wpiutil] Import MessagePack implementation (mpack) (#3650)
649a50b40 [wpiutil] Add LEB128 byte-by-byte reader (#3652)
e94397a97 [wpiutil] Move json_serializer.h to public headers (#3646)
4ec58724d [wpiutil] uv::Tcp: Clarify SetNoDelay documentation (#3649)
8cb294aa4 [wpiutil] WebSocket: Make Shutdown() public (#3651)
2b3a9a52b [wpiutil] json: Fix map iterator key() for std::string_view (#3645)
138cbb94b [wpiutil] uv::Async: Add direct call for no-parameter specialization (#3648)
e56d6dea8 [ci] Update testbench pool image to ubuntu-latest (#3643)
43f30e44e [build] Enable comments in doxygen source files (#3644)
9e6db17ef [build] Enable doxygen preprocessor expansion of WPI_DEPRECATED (#3642)
0e631ad2f Add WPILib version to issue template (#3641)
6229d8d2f [build] Docs: set case_sense_names to false (#3392)
4647d09b5 [docs] Fix Doxygen warnings, add CI docs lint job (#3639)
4ad3a5402 [hal] Fix PWM allocation channel (#3637)
05e5feac4 [docs] Fix brownout docs (NFC) (#3638)
67df469c5 [examples] Remove old command-based templates and examples (#3263)
689e9ccfb [hal, wpilib] Add brownout voltage configuration (#3632)
9cd4bc407 [docs] Add useLocal to avoid using installer artifacts (#3634)
61996c2bb [cscore] Fix Java direct callback notifications (#3631)
6d3dd99eb [build] Update to newest native-utils (#3633)
f0b484892 [wpiutil] Fix StringMap iterator equality check (#3629)
8352cbb7a Update development build instructions for 2022 (#3616)
6da08b71d [examples] Fix Intermediate Vision Java Example description (#3628)
5d99059bf [wpiutil] Remove optional.h (#3627)
fa41b106a [glass, wpiutil] Add missing format args (#3626)
4e3fd7d42 [build] Enable Zc:__cplusplus for Windows (#3625)
791d8354d [build] Suppress deprecation/removal warnings for old commands (#3618)
10f19e6fc [hal, wpilib] Add REV PneumaticsHub (#3600)
4c61a1305 [ntcore] Revert to per-element copy for toNative() (#3621)
7b3f62244 [wpiutil] SendableRegistry: Print exception stacktrace (#3620)
d347928e4 [hal] Use better error for when console out is enabled while attempting to use onboard serial port (#3622)
cc31079a1 [hal] Use setcap instead of setuid for setting thread priorities (#3613)
4676648b7 [wpimath] Upgrade to Drake v0.34.0 (#3607)
c7594c911 [build] Allow building wpilibc in cmake without cscore and opencv (#3605)
173cb7359 [wpilib] Add TimesliceRobot (#3502)
af295879f [hal] Set error status for I2C port out of range (#3603)
95dd20a15 [build] Enable spotbugs (#3601)
b65fce86b [wpilib] Remove Timer lock in wpilibj and update docs (#3602)
3b8d3bbcb Remove unused and add missing deprecated.h includes (#3599)
f9e976467 [examples] Rename DriveTrain classes to Drivetrain (#3594)
118a27be2 [wpilib] Add Timer tests (#3595)
59c89428e [wpilib] Deprecate Timer::HasPeriodPassed() (#3598)
202ca5e78 Force C++17 in .clang-format (#3597)
d6f185d8e Rename tests for consistency (#3592)
54ca474db [ci] Enable asan and tsan in CI for tests that pass (#3591)
1ca383b23 Add Debouncer (#3590)
179fde3a7 [build] Update to 2022 native utils and gradle 7 (#3588)
50198ffcf [examples] Add Mechanism2d visualization to Elevator Sim (#3587)
a446c2559 [examples] Synchronize C++ and Java Mechanism2d examples (#3589)
a7fb83103 [ci] clang-tidy: Generate compilation commands DB with Gradle (#3585)
4f5e0c9f8 [examples] Update ArmSimulation example to use Mechanism2d (#3572)
8164b91dc [CI] Print CMake test output on failure (#3583)
4d5fca27e [wpilib] Impove Mechanism2D documentation (NFC) (#3584)
fe59e4b9f Make C++ test names more consistent (#3586)
5c8868549 [wpilibc] Fix C++ MechanisimRoot2D to use same NT entries as Java/Glass (#3582)
9359431ba [wpimath] Clean up Eigen usage
72716f51c [wpimath] Upgrade to Eigen 3.4
382deef75 [wpimath] Explicitly export wpimath symbols
161e21173 [ntcore] Match standard handle layout, only allow 16 instances (#3577)
263a24811 [wpimath] Use jinja for codegen (#3574)
725251d29 [wpilib] Increase tolerances of DifferentialDriveSimTest (#3581)
4dff87301 [wpimath] Make LinearFilter::Factorial() constexpr (#3579)
60ede67ab [hal, wpilib] Switch PCM to be a single object that is allowed to be duplicated (#3475)
906bfc846 [build] Add CMake build support for sanitizers (#3576)
0d4f08ad9 [hal] Simplify string copy of joystick name (#3575)
a52bf87b7 [wpiutil] Add Java function package (#3570)
40c7645d6 [wpiutil] UidVector: Return old object from erase() (#3571)
5b886a23f [wpiutil] jni_util: Add size, operator[] to JArrayRef (#3569)
65797caa7 [sim] Fix halsim_ds_socket stringop overflow warning from GCC 10 (#3568)
66abb3988 [hal] Update runtime enum to allow selecting roborio 2 (#3565)
95a12e0ee [hal] UidSetter: Don't revert euid if its already current value (#3566)
27951442b [wpimath] Use external Eigen headers only (#3564)
c42e053ae [docs] Update to doxygen 1.9.2 (#3562)
e7048c8c8 [docs] Disable doxygen linking for common words that are also classes (#3563)
d8e0b6c97 [wpilibj] Fix java async interrupts (#3559)
5e6c34c61 Update to 2022 roborio image (#3537)
828f073eb [wpiutil] Fix uv::Buffer memory leaks caught by asan (#3555)
2dd5701ac [cscore] Fix mutex use-after-free in cscore test (#3557)
531439198 [ntcore] Fix NetworkTables memory leaks caught by asan (#3556)
3d9a4d585 [wpilibc] Fix AnalogTriggerOutput memory leak reported by asan (#3554)
54eda5928 [wpiutil] Ignore ubsan vptr upcast warning in SendableHelper moves (#3553)
5a4f75c9f [wpilib] Replace Speed controller comments with motor controller (NFC) (#3551)
7810f665f [wpiutil] Fix bug in uleb128 (#3540)
697e2dd33 [wpilib] Fix errant jaguar reference in comments (NFC) (#3550)
936c64ff5 [docs] Enable -linksource for javadocs (#3549)
1ea654954 [build] Upgrade CMake build to googletest 1.11.0 (#3548)
32d9949e4 [wpimath] Move controller tests to wpimath (#3541)
01ba56a8a [hal] Replace strncpy with memcpy (#3539)
e109c4251 [build] Rename makeSim flag to forceGazebo to better describe what it does (#3535)
e4c709164 [docs] Use a doxygen theme and add logo (#3533)
960b6e589 [wpimath] Fix Javadoc warning (#3532)
82eef8d5e [hal] Remove over current fault HAL functions from REV PDH (#3526)
aa3848b2c [wpimath] Move RobotDriveBase::ApplyDeadband() to MathUtil (#3529)
3b5d0d141 [wpimath] Add LinearFilter::BackwardFiniteDifference() (#3528)
c8fc715fe [wpimath] Upgrade drake files to v0.33.0 (#3531)
e5fe3a8e1 [build] Treat javadoc warnings as errors in CI and fix warnings (#3530)
e0c6cd3dc [wpimath] Add an operator for composing two Transform2ds (#3527)
2edd510ab [sim] Add sim wrappers for sensors that use SimDevice (#3517)
2b3e2ebc1 [hal] Fix HAL Notifier thread priority setting (#3522)
ab4cb5932 [gitignore] Update gitignore to ignore bazel / clion files (#3524)
57c8615af [build] Generate spotless patch on failure (#3523)
b90317321 Replace std::cout and std::cerr with fmt::print() (#3519)
10cc8b89c [hal] [wpilib] Add initial support for the REV PDH (#3503)
5d9ae3cdb [hal] Set HAL Notifier thread as RT by default (#3482)
192d251ee [wpilibcIntegrationTests] Properly disable DMA integration tests (#3514)
031962608 [wpilib] Add PS4Controller, remove Hand from GenericHID/XboxController (#3345)
25f6f478a [wpilib] Rename DriverStation::IsOperatorControl() to IsTeleop() (#3505)
e80f09f84 [wpilibj] Add unit tests (#3501)
c159f91f0 [wpilib] Only read DS control word once in IterativeRobotBase (#3504)
eb790a74d Add rio development docs documenting myRobot deploy tasks (#3508)
e47451f5a [wpimath] Replace auto with Eigen types (#3511)
252b8c83b Remove Java formatting from build task in CI (#3507)
09666ff29 Shorten Gazebo CI build (#3506)
baf2e501d Update myRobot to use 2021 java (#3509)
5ac60f0a2 [wpilib] Remove IterativeRobotBase mode init prints (#3500)
fb2ee8ec3 [wpilib] Add TimedRobot functions for running code on mode exit (#3499)
94e0db796 [wpilibc] Add more unit tests (#3494)
b25324695 [wpilibj] Add units to parameter names (NFC) (#3497)
1ac73a247 [hal] Rename PowerDistributionPanel to PowerDistribution (#3466)
2014115bc [examples] frisbeebot: Fix typo and reflow comments (NFC) (#3498)
4a944dc39 [examples] Consistently use 0 for controller port (#3496)
3838cc4ec Use unicode characters in docs equations (#3487)
85748f2e6 [examples] Add C++ TankDrive example (#3493)
d7b8aa56d [wpilibj] Rename DriverStation In[Mode] functions to follow style guide (#3488)
16e096cf8 [build] Fix CMake Windows CI (#3490)
50af74c38 [wpimath] Clean up NumericalIntegration and add Discretization tests (#3489)
bfc209b12 Automate fmt update (#3486)
e7f9331e4 [build] Update to Doxygen 1.9.1 (#3008)
ab8e8aa2a [wpimath] Update drake with upstream (#3484)
1ef826d1d [wpimath] Fix IOException path in WPIMath JNI (#3485)
52bddaa97 [wpimath] Disable iostream support for units and enable fmtlib (#3481)
e4dc3908b [wpiutil] Upgrade to fmtlib 8.0.1 (#3483)
1daadb812 [wpimath] Implement Dormand-Prince integration method (#3476)
9c2723391 [cscore] Add [[nodiscard]] to GrabFrame functions (#3479)
7a8796414 [wpilib] Add Notifier integration tests (#3480)
f8f13c536 [wpilibcExamples] Prefix decimal numbers with 0 (#3478)
1adb69c0f [ntcore] Use "NetworkTables" instead of "Network Tables" in NT specs (#3477)
5f5830b96 Upload wpiformat diff if one exists (#3474)
9fb4f35bb [wpimath] Add tests for DARE overload with Q, R, and N matrices (#3472)
c002e6f92 Run wpiformat (#3473)
c154e5262 [wpilib] Make solenoids exclusive use, PCM act like old sendable compressor (#3464)
6ddef1cca [hal] JNI setDIO: use a boolean and not a short (#3469)
9d68d9582 Remove extra newlines after open curly braces (NFC) (#3471)
a4233e1a1 [wpimath] Add script for updating Drake (#3470)
39373c6d2 Update README.md for new GCC version requirement (#3467)
d29acc90a [wpigui] Add option to reset UI on exit (#3463)
a371235b0 [ntcore] Fix dangling pointer in logger (#3465)
53b4891a5 [wpilibcintegrationtests] Fix deprecated Preferences usage (#3461)
646ded912 [wpimath] Remove incorrect discretization in pose estimators (#3460)
ea0b8f48e Fix some deprecation warnings due to fmtlib upgrade (#3459)
2067d7e30 [wpilibjexamples] Add wpimathjni, wpiutiljni to library path (#3455)
866571ab4 [wpiutil] Upgrade to fmtlib 8.0.0 (#3457)
4e1fa0308 [build] Skip PDB copy on windows build servers (#3458)
b45572167 [build] Change CI back to 18.04 docker images (#3456)
57a160f1b [wpilibc] Fix LiveWindow deprecation warning in RobotBase skeleton template (#3454)
29ae8640d [HLT] Implement duty cycle cross connect tests (#3453)
ee6377e54 [HLT] Add relay and analog cross connects (#3452)
b0f1ae7ea [build] CMake: Build the HAL even if WITH_CSCORE=OFF (#3449)
7aae2b72d Replace std::to_string() with fmt::format() (#3451)
73fcbbd74 [HLT] Add relay digital cross connect tests (#3450)
e7bedde83 [HLT] Add PWM tests that use DMA as the back end (#3447)
7253edb1e [wpilibc] Timer: Fix deprecated warning (#3446)
efa28125c [wpilibc] Add message to RobotBase on how to read stacktrace (#3444)
9832fcfe1 [hal] Fix DIO direction getter (#3445)
49c71f9f2 [wpilibj] Clarify robot quit message (#3364)
791770cf6 [wpimath] Move controller from wpilibj to wpimath (#3439)
9ce9188ff [wpimath] Add ReportWarning to MathShared (#3441)
362066a9b [wpilib] Deprecate getInstance() in favor of static functions (#3440)
26ff9371d Initial commit of cross connect integration test project (#3434)
4a36f86c8 [hal] Add support for DMA to Java (#3158)
85144e47f [commands] Unbreak build (#3438)
b417d961e Split Sendable into NT and non-NT portions (#3432)
ef4ea84cb [commands] Change grouping decorator impl to flatten nested group structures (#3335)
b422665a3 [examples] Invert right side of drive subsystems (#3437)
186dadf14 [hal] Error if attempting to set DIO output on an input port (#3436)
04e64db94 Remove redundant C++ lambda parentheses (NFC) (#3433)
f60994ad2 [wpiutil] Rename Java package to edu.wpi.first.util (#3431)
cfa1ca96f [wpilibc] Make ShuffleboardValue non-copyable (#3430)
4d9ff7643 Fix documentation warnings generated by JavaDoc (NFC) (#3428)
9e1b7e046 [build] Fix clang-tidy and clang-format (#3429)
a77c6ff3a [build] Upgrade clang-format and clang-tidy (NFC) (#3422)
099fde97d [wpilib] Improve PDP comments (NFC) (#3427)
f8fc2463e [wpilibc, wpiutil] Clean up includes (NFC) (#3426)
e246b7884 [wpimath] Clean up member initialization in feedforward classes (#3425)
c1e128bd5 Disable frivolous PMD warnings and enable PMD in ntcore (#3419)
8284075ee Run "Lint and Format" CI job on push as well as pull request (#3412)
f7db09a12 [wpimath] Move C++ filters into filter folder to match Java (#3417)
f9c3d54bd [wpimath] Reset error covariance in pose estimator ResetPosition() (#3418)
0773f4033 [hal] Ensure HAL status variables are initialized to zero (#3421)
d068fb321 [build] Upgrade CI to use 20.04 docker images (#3420)
8d054c940 [wpiutil] Remove STLExtras.h
80f1d7921 [wpiutil] Split function_ref to a separate header
64f541325 Use wpi::span instead of wpi::ArrayRef across all libraries (#3414)
2abbbd9e7 [build] clang-tidy: Remove bugprone-exception-escape (#3415)
a5c471af7 [wpimath] Add LQR template specialization for 2x2 system
edd2f0232 [wpimath] Add DARE solver for Q, R, and N with LQR ctor overloads
b2c3b2dd8 Use std::string_view and fmtlib across all libraries (#3402)
4f1cecb8e [wpiutil] Remove Path.h (#3413)
b336eac34 [build] Publish halsim_ws_core to Maven
2a09f6fa4 [build] Also build sim modules as static libraries
0e702eb79 [hal] Add a unified PCM object (#3331)
dea841103 [wpimath] Add fmtlib formatter overloads for Eigen::Matrix and units (#3409)
82856cf81 [wpiutil] Improve wpi::circular_buffer iterators (#3410)
8aecda03e [wpilib] Fix a documentation typo (#3408)
5c817082a [wpilib] Remove InterruptableSensorBase and replace with interrupt classes (#2410)
15c521a7f [wpimath] Fix drivetrain system identification (#3406)
989de4a1b [build] Force all linker warnings to be fatal for rio builds (#3407)
d9eeb45b0 [wpilibc] Add units to Ultrasonic class API (#3403)
fe570e000 [wpiutil] Replace llvm filesystem with C++17 filesystem (#3401)
01dc0249d [wpimath] Move SlewRateLimiter from wpilib to wpimath (#3399)
93523d572 [wpilibc] Clean up integration tests (#3400)
4f7a4464d [wpiutil] Rewrite StringExtras for std::string_view (#3394)
e09293a15 [wpilibc] Transition C++ classes to units::second_t (#3396)
827b17a52 [build] Create run tasks for Glass and OutlineViewer (#3397)
a61037996 [wpiutil] Avoid MSVC warning on span include (#3393)
4e2c3051b [wpilibc] Use std::string_view instead of Twine (#3380)
50915cb7e [wpilibc] MotorSafety::GetDescription(): Return std::string (#3390)
f4e2d26d5 [wpilibc] Move NullDeleter from frc/Base.h to wpi/NullDeleter.h (#3387)
cb0051ae6 [wpilibc] SimDeviceSim: use fmtlib (#3389)
a238cec12 [wpiutil] Deprecate wpi::math constants in favor of wpi::numbers (#3383)
393bf23c0 [ntcore, cscore, wpiutil] Standardize template impl files on .inc extension (NFC) (#3124)
e7d9ba135 [sim] Disable flaky web server integration tests (#3388)
0a0003c11 [wpilibjExamples] Fix name of Java swerve drive pose estimator example (#3382)
7e1b27554 [wpilibc] Use default copies and moves when possible (#3381)
fb2a56e2d [wpilibc] Remove START_ROBOT_CLASS macro (#3384)
84218bfb4 [wpilibc] Remove frc namespace shim (#3385)
dd7824340 [wpilibc] Remove C++ compiler version static asserts (#3386)
484cf9c0e [wpimath] Suppress the -Wmaybe-uninitialized warning in Eigen (#3378)
a04d1b4f9 [wpilibc] DriverStation: Remove ReportError and ReportWarning
831c10bdf [wpilibc] Errors: Use fmtlib
87603e400 [wpiutil] Import fmtlib (#3375)
442621672 [wpiutil] Add ArrayRef/std::span/wpi::span implicit conversions
bc15b953b [wpiutil] Add std::span implementation
6d20b1204 [wpiutil] StringRef, Twine, raw_ostream: Add std::string_view support (#3373)
2385c2a43 [wpilibc] Remove Utility.h (#3376)
87384ea68 [wpilib] Fix PIDController continuous range error calculations (#3170)
04dae799a [wpimath] Add SimpleMotorFeedforward::Calculate(velocity, nextVelocity) overload (#3183)
0768c3903 [wpilib] DifferentialDrive: Remove right side inversion (#3340)
8dd8d4d2d [wpimath] Fix redundant nested math package introduced by #3316 (#3368)
49b06beed [examples] Add Field2d to RamseteController example (#3371)
4c562a445 [wpimath] Fix typo in comment of update_eigen.py (#3369)
fdbbf1188 [wpimath] Add script for updating Eigen
f1e64b349 [wpimath] Move Eigen unsupported folder into eigeninclude
224f3a05c [sim] Fix build error when building with GCC 11.1 (#3361)
ff56d6861 [wpilibj] Fix SpeedController deprecated warnings (#3360)
1873fbefb [examples] Fix Swerve and Mecanum examples (#3359)
80b479e50 [examples] Fix SwerveBot example to use unique encoder ports (#3358)
1f7c9adee [wpilibjExamples] Fix pose estimator examples (#3356)
9ebc3b058 [outlineviewer] Change default size to 600x400 (#3353)
e21b443a4 [build] Gradle: Make C++ examples runnable (#3348)
da590120c [wpilibj] Add MotorController.setVoltage default (#3347)
561d53885 [build] Update opencv to 4.5.2, imgui/implot to latest (#3344)
44ad67ca8 [wpilibj] Preferences: Add missing Deprecated annotation (#3343)
3fe8fc75a [wpilibc] Revert "Return reference from GetInstance" (#3342)
3cc2da332 Merge branch '2022'
a3cd90dd7 [wpimath] Fix classpath used by generate_numbers.py (#3339)
d6cfdd3ba [wpilib] Preferences: Deprecate Put* in favor of Set* (#3337)
ba08baabb [wpimath] Update Drake DARE solver to v0.29.0 (#3336)
497b712f6 [wpilib] Make IterativeRobotBase::m_period private with getter
f00dfed7a [wpilib] Remove IterativeRobot base class
3c0846168 [hal] Use last error reporting instead of PARAMETER_OUT_OF_RANGE (#3328)
5ef2b4fdc [wpilibj] Fix @deprecated warning for SerialPort constructor (#3329)
23d2326d1 [hal] Report previous allocation location for indexed resource duplicates (#3322)
e338f9f19 [build] Fix wpilibc runCpp task (#3327)
c8ff626fe [wpimath] Move Java classes to edu.wpi.first.math (#3316)
4e424d51f [wpilibj] DifferentialDrivetrainSim: Rename constants to match the style guide (#3312)
6b50323b0 [cscore] Use Lock2DSize if possible for Windows USB cameras (#3326)
65c148536 [wpilibc] Fix "control reaches end of non-void function" warning (#3324)
f99f62bee [wpiutil] uv Handle: Use malloc/free instead of new/delete (#3325)
365f5449c [wpimath] Fix MecanumDriveKinematics (#3266)
ff52f207c [glass, wpilib] Rewrite Mechanism2d (#3281)
ee0eed143 [wpimath] Add DCMotor factory function for Romi motors (#3319)
512738072 [hal] Add HAL_GetLastError to enable better error messages from HAL calls (#3320)
ced654880 [glass, outlineviewer] Update Mac icons to macOS 11 style (#3313)
936d3b9f8 [templates] Add Java template for educational robot (#3309)
6e31230ad [examples] Fix odometry update in SwerveControllerCommand example (#3310)
05ebe9318 Merge branch 'main' into 2022
aaf24e255 [wpilib] Fix initial heading behavior in HolonomicDriveController (#3290)
8d961dfd2 [wpilibc] Remove ErrorBase (#3306)
659b37ef9 [wpiutil] StackTrace: Include offset on Linux (#3305)
0abf6c904 [wpilib] Move motor controllers to motorcontrol package (#3302)
4630191fa [wpiutil] circular_buffer: Use value initialization instead of passing zero (#3303)
b7b178f49 [wpilib] Remove Potentiometer interface
687066af3 [wpilib] Remove GyroBase
6b168ab0c [wpilib] Remove PIDController, PIDOutput, PIDSource
948625de9 [wpimath] Document conversion from filter cutoff frequency to time constant (#3299)
3848eb8b1 [wpilibc] Fix flywhel -> flywheel typo in FlywheelSim (#3298)
3abe0b9d4 [cscore] Move java package to edu.wpi.first.cscore (#3294)
d7fabe81f [wpilib] Remove RobotDrive (#3295)
1dc81669c [wpilib] Remove GearTooth (#3293)
01d0e1260 [wpilib] Revert move of RomiGyro into main wpilibc/j (#3296)
397e569aa [ntcore] Remove "using wpi" from nt namespace
79267f9e6 [ntcore] Remove NetworkTable -> nt::NetworkTable shim
48ebe5736 [ntcore] Remove deprecated Java interfaces and classes
c2064c78b [ntcore] Remove deprecated ITable interfaces
36608a283 [ntcore] Remove deprecated C++ APIs
a1c87e1e1 [glass] LogView: Add "copy to clipboard" button (#3274)
fa7240a50 [wpimath] Fix typo in quintic spline basis matrix
ffb4d38e2 [wpimath] Add derivation for spline basis matrices
f57c188f2 [wpilib] Add AnalogEncoder(int) ctor (#3273)
8471c4fb2 [wpilib] FieldObject2d: Add setTrajectory() method (#3277)
c97acd18e [glass] Field2d enhancements (#3234)
ffb590bfc [wpilib] Fix Compressor sendable properties (#3269)
6137f98eb [hal] Rename SimValueCallback2 to SimValueCallback (#3212)
a6f653969 [hal] Move registerSimPeriodic functions to HAL package (#3211)
10c038d9b [glass] Plot: Fix window creation after removal (#3264)
2d2eaa3ef [wpigui] Ensure window will be initially visible (#3256)
4d28b1f0c [wpimath] Use JNI for trajectory serialization (#3257)
3de800a60 [wpimath] TrajectoryUtil.h: Comment formatting (NFC) (#3262)
eff592377 [glass] Plot: Don't overwrite series ID (#3260)
a79faace1 [wpilibc] Return reference from GetInstance (#3247)
9550777b9 [wpilib] PWMSpeedController: Use PWM by composition (#3248)
c8521a3c3 [glass] Plot: Set reasonable default window size (#3261)
d71eb2cf3 [glass] Plot: Show full source name as tooltip and in popup (#3255)
160fb740f [hal] Use std::lround() instead of adding 0.5 and truncating (#3012)
48e9f3951 [wpilibj] Remove wpilibj package CameraServer (#3213)
8afa596fd [wpilib] Remove deprecated Sendable functions and SendableBase (#3210)
d3e45c297 [wpimath] Make C++ geometry classes immutable (#3249)
2c98939c1 [glass] StringChooser: Don't call SameLine() at end
a18a7409f [glass] NTStringChooser: Clear value of deleted entries
2f19cf452 [glass] NetworkTablesHelper: listen to delete events
da96707dc Merge branch 'main' into 2022
c3a8bdc24 [build] Fix clang-tidy action (#3246)
21624ef27 Add ImGui OutlineViewer (#3220)
1032c9b91 [wpiutil] Unbreak wpi::Format on Windows (#3242)
2e07902d7 [glass] NTField2D: Fix name lookup (#3233)
6e23e1840 [wpilibc] Remove WPILib.h (#3235)
3e22e4506 [wpilib] Make KoP drivetrain simulation weight 60 lbs (#3228)
79d1bd6c8 [glass] NetworkTablesSetting: Allow disable of server option (#3227)
fe341a16f [examples] Use more logical elevator setpoints in GearsBot (#3198)
62abf46b3 [glass] NetworkTablesSettings: Don't block GUI (#3226)
a95a5e0d9 [glass] Move NetworkTablesSettings to libglassnt (#3224)
d6f6ceaba [build] Run Spotless formatter (NFC) (#3221)
0922f8af5 [commands] CommandScheduler.requiring(): Note return can be null (NFC) (#2934)
6812302ff [examples] Make DriveDistanceOffboard example work in sim (#3199)
f3f86b8e7 [wpimath] Add pose estimator overload for vision + std dev measurement (#3200)
1a2680b9e [wpilibj] Change CommandBase.withName() to return CommandBase (#3209)
435bbb6a8 [command] RamseteCommand: Output 0 if interrupted (#3216)
3cf44e0a5 [hal] Add function for changing HAL Notifier thread priority (#3218)
40b367513 [wpimath] Units.java: Add kg-lb conversions (#3203)
9f563d584 [glass] NT: Fix return value in StringToDoubleArray (#3208)
af4adf537 [glass] Auto-size plots to fit window (#3193)
2560146da [sim] GUI: Add option to show prefix in Other Devices (#3186)
eae3a6397 gitignore: Ignore .cache directory (#3196)
959611420 [wpilib] Require non-zero positive value for PIDController.period (#3175)
9522f2e8c [wpimath] Add methods to concatenate trajectories (#3139)
e42a0b6cf [wpimath] Rotation2d comment formatting (NFC) (#3162)
d1c7032de [wpimath] Fix order of setting gyro offset in pose estimators (#3176)
d241bc81a [sim] Add DoubleSolenoidSim and SolenoidSim classes (#3177)
cb7f39afa [wpilibc] Add RobotController::GetBatteryVoltage() to C++ (#3179)
99b5ad9eb [wpilibj] Fix warnings that are not unused variables or deprecation (#3161)
c14b23775 [build] Fixup doxygen generated include dirs to match what users would need (#3154)
d447c7dc3 [sim] Add SimDeviceSim ctor overloads (#3134)
247420c9c [build] Remove jcenter repo (#3157)
04b112e00 [build] Include debug info in plugin published artifacts (#3149)
be0ce9900 [examples] Use PWMSparkMax instead of PWMVictorSPX (#3156)
69e8d0b65 [wpilib] Move RomiGyro into main wpilibc/j (#3143)
94e685e1b [wpimath] Add custom residual support to EKF (#3148)
5899f3dd2 [sim] GUI: Make keyboard settings loading more robust (#3167)
f82aa1d56 [wpilib] Fix HolonomicDriveController atReference() behavior (#3163)
fe5c2cf4b [wpimath] Remove ControllerUtil.java (#3169)
43d40c6e9 [wpiutil] Suppress unchecked cast in CombinedRuntimeLoader (#3155)
3d44d8f79 [wpimath] Fix argument order in UKF docs (NFC) (#3147)
ba6fe8ff2 [cscore] Add USB camera change event (#3123)
533725888 [build] Tweak OpenCV cmake search paths to work better on Linux (#3144)
29bf9d6ef [cscore] Add polled support to listener
483beb636 [ntcore] Move CallbackManager to wpiutil
fdaec7759 [examples] Instantiate m_ramseteController in example (#3142)
8494a5761 Rename default branch to main (#3140)
45590eea2 [wpigui] Hardcode window scale to 1 on macOS (#3135)
834a64920 [build] Publish libglass and libglassnt to Maven (#3127)
2c2ccb361 [wpimath] Fix Rotation2d equality operator (#3128)
fb5c8c39a [wpigui] clang-tidy: readability-braces-around-statements
f7d39193a [wpigui] Fix copyright in pfd and wpigui_metal.mm
aec796b21 [ntcore] Fix conditional jump on uninitialized value (#3125)
fb13bb239 [sim] GUI: Add right click popup for keyboard joystick settings (#3119)
c517ec677 [build] Update thirdparty-imgui to 1.79-2 (#3118)
e8cbf2a71 [wpimath] Fix typo in SwerveDrivePoseEstimator doc (NFC) (#3112)
e9c86df46 [wpimath] Add tests for swerve module optimization (#3100)
6ba8c289c [examples] Remove negative of ArcadeDrive(fwd, ..) in the C++ Getting Started Example (#3102)
3f1672e89 [hal] Add SimDevice createInt() and createLong() (#3110)
15be5cbf1 [examples] Fix segfault in GearsBot C++ example (#3111)
4cf0e5e6d Add quick links to API documentation in README (#3082)
6b1898f12 Fix RT priority docs (NFC) (#3098)
b3426e9c0 [wpimath] Fix missing whitespace in pose estimator doc (#3097)
38c1a1f3e [examples] Fix feildRelative -> fieldRelative typo in XControllerCommand examples (#3104)
4488e25f1 [glass] Shorten SmartDashboard window names (#3096)
cfdb3058e [wpilibj] Update SimDeviceSimTest (#3095)
64adff5fe [examples] Fix typo in ArcadeDrive constructor parameter name (#3092)
6efc58e3d [build] Fix issues with build on windows, deprecations, and native utils (#3090)
f393989a5 [wpimath, wpiutil] Add wpi::array for compile time size checking (#3087)
d6ed20c1e [build] Set macOS deployment target to 10.14 (#3088)
7c524014c [hal] Add [[nodiscard]] to HAL_WaitForNotifierAlarm() (#3085)
406d055f0 [wpilib] Fixup wouldHitLowerLimit in elevator and arm simulation classes. (#3076)
04a90b5dd [examples] Don't continually set setpoint in PotentiometerPID Examples (#3084)
8c5bfa013 [sim] GUI: Add max value setting for keyboard joysticks (#3083)
bc80c5535 [hal] Add SimValue reset() function (#3064)
9c3b51ca0 [wpilib] Document simulation APIs (#3079)
26584ff14 [wpimath] Add model description to LinearSystemId Javadocs (#3080)
42c3d5286 [examples] Sync Java and C++ trajectories in sim example (#3081)
64e72f710 [wpilibc] Add missing function RoboRioSim::ResetData (#3073)
e95503798 [wpimath] Add optimize() to SwerveModuleState (#3065)
fb99910c2 [hal] Add SimInt and SimLong wrappers for int/long SimValue (#3066)
e620bd4d3 [doc] Add machine-readable websocket specification (#3059)
a44e761d9 [glass] Add support for plot Y axis labels
ea1974d57 [wpigui] Update imgui and implot to latest
85a0bd43c [wpimath] Add RKF45 integration (#3047)
278e0f126 [glass] Use .controllable to set widgets' read-only state (#3035)
d8652cfd4 [wpimath] Make Java DCMotor API consistent with C++ and fix motor calcs (#3046)
377b7065a [build] Add toggleOffOn to Java spotless (#3053)
1e9c79c58 [sim] Use plant output to retrieve simulated position (#3043)
78147aa34 [sim] GUI: Fix Keyboard Joystick (#3052)
cd4a2265b [ntcore] Fix NetworkTableEntry::GetRaw() (#3051)
767ac1de1 [build] Use deploy key for doc publish (#3048)
d762215d1 [build] Add publish documentation script (#3040)
1fd09593c [examples] Add missing TestInit method to GettingStarted Example (#3039)
e45a0f6ce [examples] Add RomiGyro to the Romi Reference example (#3037)
94f852572 Update imaging link and fix typo (#3038)
d73cf64e5 [examples] Update RomiReference to match motor directions (#3036)
f945462ba Bump copyright year to 2021 (#3033)
b05946175 [wpimath] Catch Drake JNI exceptions and rethrow them (#3032)
62f0f8190 [wpimath] Deduplicate angle modulus functions (#2998)
bf8c0da4b [glass] Add "About" popup with version number (#3031)
dfdd6b389 [build] Increase Gradle heap size in Gazebo build (#3028)
f5e0fc3e9 Finish clang-tidy cleanups (#3003)
d741101fe [sim] Revert accidental commit of WSProvider_PDP.h (#3027)
e1620799c [examples] Add C++ RomiReference example (#2969)
749c7adb1 [command] Fix use-after-free in CommandScheduler (#3024)
921a73391 [sim] Add WS providers for AddressableLED, PCM, and Solenoid (#3026)
26d0004fe [build] Split Actions into different yml files (#3025)
948af6d5b [wpilib] PWMSpeedController.get(): Apply Inversion (#3016)
670a187a3 [wpilibc] SuppliedValueWidget.h: Forward declare ShuffleboardContainer (#3021)
be9f72502 [ntcore] NetworkTableValue: Use std::forward instead of std::move (#3022)
daf3f4cb1 [cscore] cscore_raw_cv.h: Fix error in PutFrame() (#3019)
5acda4cc7 [wpimath] ElevatorFeedforward.h: Add time.h include
8452af606 [wpimath] units/radiation.h: Add mass.h include
630d44952 [hal] ErrorsInternal.h: Add stdint.h include
7372cf7d9 [cscore] Windows NetworkUtil.cpp: Add missing include
b7e46c558 Include .h from .inc/.inl files (NFC) (#3017)
bf8f8710e [examples] Update Romi template and example (#2996)
6ffe5b775 [glass] Ensure NetworkTableTree parent context menu has an id (#3015)
be0805b85 [build] Update to WPILibVersioningPlugin 4.1.0 (#3014)
65b2359b2 [build] Add spotless for other files (#3007)
8651aa73e [examples] Enable NT Flush in Field2d examples (#3013)
78b542737 [build] Add Gazebo build to Actions CI (#3004)
fccf86532 [sim] DriverStationGui: Fix two bugs (#3010)
185741760 [sim] WSProvider_Joystick: Fix off-by-1 in incoming buttons (#3011)
ee7114a58 [glass] Add drive class widgets (#2975)
00fa91d0d [glass] Use ImGui style for gyro widget colors (#3009)
b7a25bfc3 ThirdPartyNotices: Add portable file dialogs license (#3005)
a2e46b9a1 [glass] modernize-use-nullptr (NFC) (#3006)
a751fa22d [build] Apply spotless for java formatting (#1768)
e563a0b7d [wpimath] Make LinearSystemLoop move-constructible and move-assignable (#2967)
49085ca94 [glass] Add context menus to remove and add NetworkTables values (#2979)
560a850a2 [glass] Add NetworkTables Log window (#2997)
66782e231 [sim] Create Left/Right drivetrain current accessors (#3001)
b60eb1544 clang-tidy: bugprone-virtual-near-miss
cbe59fa3b clang-tidy: google-explicit-constructor
c97c6dc06 clang-tidy: google-readability-casting (NFC)
32fa97d68 clang-tidy: modernize-use-nullptr (NFC)
aee460326 clang-tidy: modernize-pass-by-value
29c7da5f1 clang-tidy: modernize-make-unique
6131f4e32 clang-tidy: modernize-concat-nested-namespaces (NFC)
67e03e625 clang-tidy: modernize-use-equals-default
b124f9101 clang-tidy: modernize-use-default-member-init
d11a3a638 clang-tidy: modernize-use-override (NFC)
4cc0706b0 clang-tidy: modernize-use-using (NFC)
885f5a978 [wpilibc] Speed up ScopedTracerTest (#2999)
60b596457 [wpilibj] Fix typos (NFC) (#3000)
6e1919414 [build] Bring naming checkstyle rules up to date with Google Style guide (#1781)
8c8ec5e63 [wpilibj] Suppress unchecked cast warnings (#2995)
b8413ddd5 [wpiutil] Add noexcept to timestamp static functions (#2994)
5d976b6e1 [glass] Load NetworkTableView settings on first draw (#2993)
2b4317452 Replace NOLINT(runtime/explicit) comments with NOLINT (NFC) (#2992)
1c3011ba4 [glass] Fix handling of "/" NetworkTables key (#2991)
574a42f3b [hal] Fix UnsafeManipulateDIO status check (#2987)
9005cd59e [wpilib] Clamp input voltage in sim classes (#2955)
dd494d4ab [glass] NetworkTablesModel::Update(): Avoid use-after-move (#2988)
7cca469a1 [wpimath] NormalizeAngle: Make inline, remove unnamed namespace (#2986)
2aed432b4 Add braces to C++ single-line loops and conditionals (NFC) (#2973)
0291a3ff5 [wpiutil] StringRef: Add noexcept to several constructors (#2984)
5d7315280 [wpimath] Update UnitsTest.cpp copyright (#2985)
254931b9a [wpimath] Remove LinearSystem from LinearSystemLoop (#2968)
aa89744c9 Update OtherVersions.md to include wpimath info (#2983)
1cda3f5ad [glass] Fix styleguide (#2976)
8f1f64ffb Remove year from file copyright message (NFC) (#2972)
2bc0a7795 [examples] Fix wpiformat warning about utility include (#2971)
4204da6ad [glass] Add application icon
7ac39b10f [wpigui] Add icon support
6b567e006 [wpimath] Add support for varying vision standard deviations in pose estimators (#2956)
df299d6ed [wpimath] Add UnscentedKalmanFilter::Correct() overload (#2966)
4e34f0523 [examples] Use ADXRS450_GyroSim class in simulation example (#2964)
9962f6fd7 [wpilib] Give Field2d a default Sendable name (#2953)
f9d492f4b [sim] GUI: Show "Other Devices" window by default (#2961)
a8bb2ef1c [sim] Fix ADXRS450_GyroSim and DutyCycleEncoderSim (#2963)
240c629cd [sim] Try to guess "Map Gamepad" setting (#2960)
952567dd3 [wpilibc] Add missing move constructors and assignment operators (#2959)
10b396b4c [sim] Various WebSockets fixes and enhancements (#2952)
699bbe21a [examples] Fix comments in Gearsbot to match implementation (NFC) (#2957)
27b67deca [glass] Add more widgets (#2947)
581b7ec55 [wpilib] Add option to flush NetworkTables every iterative loop
acfbb1a44 [ntcore] DispatcherBase::Flush: Use wpi::Now()
d85a6d8fe [ntcore] Reduce limit on flush and update rate to 5 ms
20fbb5c63 [sim] Fix stringop truncation warning from GCC 10 (#2945)
1051a06a7 [glass] Show NT timestamps in seconds (#2944)
98dfc2620 [glass] Fix plots (#2943)
1ba0a2ced [sim] GUI: Add keyboard virtual joystick support (#2940)
4afb13f98 [examples] Replace M_PI with wpi::math::pi (#2938)
b27d33675 [examples] Enhance Romi templates (#2931)
00b9ae77f [sim] Change default WS port number to 3300 (#2932)
65219f309 [examples] Update Field2d position in periodic() (#2928)
f78d1d434 [sim] Process WS Encoder reset internally (#2927)
941edca59 [hal] Add Java SimDeviceDataJNI.getSimDeviceName (#2924)
a699435ed [wpilibj] Fix FlywheelSim argument order in constructor (#2922)
66d641718 [examples] Add tasks to run Java examples (#2920)
558e37c41 [examples] Add simple differential drive simulation example (#2918)
4f40d991e [glass] Switch name of Glass back to glass (#2919)
549af9900 [build] Update native-utils to 2021.0.6 (#2914)
b33693009 [glass] Change basename of glass to Glass (#2915)
c9a0edfb8 [glass] Package macOS application bundle
2c5668af4 [wpigui] Add platform-specific preferences save
751dea32a [wpilibc] Try to work around ABI break introduced in #2901 (#2917)
cd8f4bfb1 [build] Package up msvc runtime into maven artifact (#2913)
a6cfcc686 [wpilibc] Move SendableChooser Doxygen comments to header (NFC) (#2911)
b8c4f603d [wpimath] Upgrade to Eigen 3.3.9 (#2910)
0075e4b39 [wpilibj] Fix NPE in Field2d (#2909)
125af556c [simulation] Fix halsim_gui ntcore and wpiutil deps (#2908)
963ad5c25 [wpilib] Add noise to Differential Drive simulator (#2903)
387f56cb7 [examples] Add Romi reference Java example and templates (#2905)
b3deda38c [examples] Zero motors on disabledInit() in sim physics examples (#2906)
2a5ca7745 [glass] Add glass: an application for display of robot data
727940d84 [wpilib] Move Field2d to SmartDashboard
8cd42478e [wpilib] SendableBuilder: Make GetTable() visible
c11d34b26 [command] Use addCommands in command group templates (#2900)
339d7445b [sim] Add HAL hooks for simulationPeriodic (#2881)
d16f05f2c [wpilib] Fix SmartDashboard update order (#2896)
5427b32a4 [wpiutil] unique_function: Restrict implicit conversion (#2899)
f73701239 [ntcore] Add missing SetDefault initializer_list functions (#2898)
f5a6fc070 [sim] Add initialized flag for all solenoids on a PCM (#2897)
bdf5ba91a [wpilibj] Fix typo in ElevatorSim (#2895)
bc8f33877 [wpilib] Add pose estimators (#2867)
3413bfc06 [wpilib] PIDController: Recompute the error in AtSetpoint() (#2822)
2056f0ce0 [wpilib] Fix bugs in Hatchbot examples (#2893)
5eb8cfd69 [wpilibc] Fix MatchDataSender (#2892)
e6a425448 [build] Delete test folders after tests execute (#2891)
d478ad00d [imgui] Allow usage of imgui_stdlib (#2889)
53eda861d [build] Add unit-testing infrastructure to examples (#2863)
cc1d86ba6 [sim] Add title to simulator GUI window (#2888)
f0528f00e [build] CMake: Use project-specific binary and source dirs (#2886)
5cd2ad124 [wpilibc] Add Color::operator!= (#2887)
6c00e7a90 [build] CI CMake: build with GUI enabled (#2884)
53170bbb5 Update roboRIO toolchain installation instructions (#2883)
467258e05 [sim] GUI: Add option to not zero disconnected joysticks (#2876)
129be23c9 Clarify JDK installation instructions in readme (#2882)
8e9290e86 [build] Add separate CMake setting for wpimath (#2885)
7cf5bebf8 [wpilibj] Cache NT writes from DriverStation (#2780)
f7f9087fb [command] Fix timing issue in RamseteCommand (#2871)
256e7904f [wpilibj] SimDeviceSim: Fix sim value changed callback (#2880)
c8ea1b6c3 [wpilib] Add function to adjust LQR controller gain for pure time delay (#2878)
2816b06c0 [sim] HAL_GetControlWord: Fully zero output (#2873)
4c695ea08 Add toolchain installation instructions to README (#2875)
a14d51806 [wpimath] DCMotor: fix doc typo (NFC) (#2868)
017097791 [build] CMake: build sim extensions as shared libs (#2866)
f61726b5a [build] Fix cmake-config files (#2865)
fc27fdac5 [wpilibc] Cache NT values from driver station (#2768)
47c59859e [sim] Make SimDevice callbacks synchronous (#2861)
6e76ab9c0 [build] Turn on WITH_GUI for Windows cmake CI
5f78b7670 [build] Set GLFW_INSTALL to OFF
5e0808c84 [wpigui] Fix Windows cmake build
508f05a47 [imgui] Fix typo in Windows CMake target sources
Change-Id: I1737b45965f31803a96676bedc7dc40e337aa321
git-subtree-dir: third_party/allwpilib
git-subtree-split: e473a00f9785f9949e5ced30901baeaf426d2fc9
Signed-off-by: Austin Schuh <austin.linux@gmail.com>
diff --git a/wpilibjIntegrationTests/build.gradle b/wpilibjIntegrationTests/build.gradle
index 090d309..3224345 100644
--- a/wpilibjIntegrationTests/build.gradle
+++ b/wpilibjIntegrationTests/build.gradle
@@ -11,7 +11,7 @@
apply from: "${rootDir}/shared/opencv.gradle"
-mainClassName = 'edu.wpi.first.wpilibj.test.AntJunitLanucher'
+mainClassName = 'edu.wpi.first.wpilibj.test.AntJunitLauncher'
apply plugin: 'com.github.johnrengelman.shadow'
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AbstractInterruptTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AbstractInterruptTest.java
index de54234..219a611 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AbstractInterruptTest.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AbstractInterruptTest.java
@@ -1,311 +1,254 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2019 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicInteger;
-import java.util.concurrent.atomic.AtomicLong;
-
-import org.junit.After;
-import org.junit.Test;
-
-import edu.wpi.first.wpilibj.test.AbstractComsSetup;
-
import static org.hamcrest.Matchers.both;
import static org.hamcrest.Matchers.greaterThan;
import static org.hamcrest.Matchers.lessThan;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
+import edu.wpi.first.wpilibj.test.AbstractComsSetup;
+import java.util.concurrent.atomic.AtomicBoolean;
+import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicLong;
+import org.junit.After;
+import org.junit.Test;
+
/**
* This class should not be run as a test explicitly. Instead it should be extended by tests that
- * use the InterruptableSensorBase.
+ * use DigitalSource.
*/
public abstract class AbstractInterruptTest extends AbstractComsSetup {
- private InterruptableSensorBase m_interruptable = null;
+ private DigitalSource m_source = null;
- private InterruptableSensorBase getInterruptable() {
- if (m_interruptable == null) {
- m_interruptable = giveInterruptableSensorBase();
+ private DigitalSource getSource() {
+ if (m_source == null) {
+ m_source = giveSource();
}
- return m_interruptable;
+ return m_source;
}
-
@After
public void interruptTeardown() {
- if (m_interruptable != null) {
- freeInterruptableSensorBase();
- m_interruptable = null;
+ if (m_source != null) {
+ freeSource();
+ m_source = null;
}
}
- /**
- * Give the interruptable sensor base that interrupts can be attached to.
- */
- abstract InterruptableSensorBase giveInterruptableSensorBase();
+ /** Give the sensor source that interrupts can be attached to. */
+ abstract DigitalSource giveSource();
- /**
- * Cleans up the interruptable sensor base. This is only called if {@link
- * #giveInterruptableSensorBase()} is called.
- */
- abstract void freeInterruptableSensorBase();
+ /** Cleans up the sensor source. This is only called if {@link #giveSource()} is called. */
+ abstract void freeSource();
- /**
- * Perform whatever action is required to set the interrupt high.
- */
+ /** Perform whatever action is required to set the interrupt high. */
abstract void setInterruptHigh();
- /**
- * Perform whatever action is required to set the interrupt low.
- */
+ /** Perform whatever action is required to set the interrupt low. */
abstract void setInterruptLow();
-
- private class InterruptCounter {
- private final AtomicInteger m_count = new AtomicInteger();
-
- void increment() {
- m_count.addAndGet(1);
- }
-
- int getCount() {
- return m_count.get();
- }
- }
-
- private class TestInterruptHandlerFunction extends InterruptHandlerFunction<InterruptCounter> {
- protected final AtomicBoolean m_exceptionThrown = new AtomicBoolean(false);
- /**
- * Stores the time that the interrupt fires.
- */
- final AtomicLong m_interruptFireTime = new AtomicLong();
- /**
- * Stores if the interrupt has completed at least once.
- */
- final AtomicBoolean m_interruptComplete = new AtomicBoolean(false);
- protected Exception m_ex;
- final InterruptCounter m_counter;
-
- TestInterruptHandlerFunction(InterruptCounter counter) {
- m_counter = counter;
- }
-
- @Override
- public void interruptFired(int interruptAssertedMask, InterruptCounter param) {
- m_interruptFireTime.set(RobotController.getFPGATime());
- m_counter.increment();
- try {
- // This won't cause the test to fail
- assertSame(m_counter, param);
- } catch (Exception ex) {
- // So we must throw the exception within the test
- m_exceptionThrown.set(true);
- m_ex = ex;
- }
- m_interruptComplete.set(true);
- }
-
- @Override
- public InterruptCounter overridableParameter() {
- return m_counter;
- }
- }
-
@Test(timeout = 1000)
public void testSingleInterruptsTriggering() throws Exception {
// Given
- final InterruptCounter counter = new InterruptCounter();
- TestInterruptHandlerFunction function = new TestInterruptHandlerFunction(counter);
+ // final InterruptCounter counter = new InterruptCounter();
+ // TestInterruptHandlerFunction function = new
+ // TestInterruptHandlerFunction(counter);
- // When
- getInterruptable().requestInterrupts(function);
- getInterruptable().enableInterrupts();
+ AtomicBoolean hasFired = new AtomicBoolean(false);
+ AtomicInteger counter = new AtomicInteger(0);
+ AtomicLong interruptFireTime = new AtomicLong();
- setInterruptLow();
- Timer.delay(0.01);
- // Note: Utility.getFPGATime() is used because double values can turn over
- // after the robot has been running for a long time
- final long interruptTriggerTime = RobotController.getFPGATime();
- setInterruptHigh();
+ try (AsynchronousInterrupt interrupt =
+ new AsynchronousInterrupt(
+ getSource(),
+ (a, b) -> {
+ interruptFireTime.set(RobotController.getFPGATime());
+ hasFired.set(true);
+ counter.incrementAndGet();
+ })) {
+ interrupt.enable();
+ setInterruptLow();
+ Timer.delay(0.01);
+ final long interruptTriggerTime = RobotController.getFPGATime();
+ setInterruptHigh();
+ while (!hasFired.get()) {
+ Timer.delay(0.005);
+ }
- // Delay until the interrupt is complete
- while (!function.m_interruptComplete.get()) {
- Timer.delay(0.005);
+ assertEquals("The interrupt did not fire the expected number of times", 1, counter.get());
+
+ final long range = 10000; // in microseconds
+ assertThat(
+ "The interrupt did not fire within the expected time period (values in milliseconds)",
+ interruptFireTime.get(),
+ both(greaterThan(interruptTriggerTime - range))
+ .and(lessThan(interruptTriggerTime + range)));
+ assertThat(
+ "The readRisingTimestamp() did not return the correct value (values in seconds)",
+ interrupt.getRisingTimestamp(),
+ both(greaterThan((interruptTriggerTime - range) / 1e6))
+ .and(lessThan((interruptTriggerTime + range) / 1e6)));
}
-
-
- // Then
- assertEquals("The interrupt did not fire the expected number of times", 1, counter.getCount());
- // If the test within the interrupt failed
- if (function.m_exceptionThrown.get()) {
- throw function.m_ex;
- }
- final long range = 10000; // in microseconds
- assertThat(
- "The interrupt did not fire within the expected time period (values in milliseconds)",
- function.m_interruptFireTime.get(),
- both(greaterThan(interruptTriggerTime - range)).and(lessThan(interruptTriggerTime
- + range)));
- assertThat(
- "The readRisingTimestamp() did not return the correct value (values in seconds)",
- getInterruptable().readRisingTimestamp(),
- both(greaterThan((interruptTriggerTime - range) / 1e6)).and(
- lessThan((interruptTriggerTime + range) / 1e6)));
}
@Test(timeout = 2000)
public void testMultipleInterruptsTriggering() {
- // Given
- final InterruptCounter counter = new InterruptCounter();
- TestInterruptHandlerFunction function = new TestInterruptHandlerFunction(counter);
+ AtomicBoolean hasFired = new AtomicBoolean(false);
+ AtomicInteger counter = new AtomicInteger(0);
- // When
- getInterruptable().requestInterrupts(function);
- getInterruptable().enableInterrupts();
+ try (AsynchronousInterrupt interrupt =
+ new AsynchronousInterrupt(
+ getSource(),
+ (a, b) -> {
+ hasFired.set(true);
+ counter.incrementAndGet();
+ })) {
+ interrupt.enable();
- final int fireCount = 50;
- for (int i = 0; i < fireCount; i++) {
- setInterruptLow();
- setInterruptHigh();
- // Wait for the interrupt to complete before moving on
- while (!function.m_interruptComplete.getAndSet(false)) {
- Timer.delay(0.005);
+ final int fireCount = 50;
+ for (int i = 0; i < fireCount; i++) {
+ setInterruptLow();
+ setInterruptHigh();
+ // Wait for the interrupt to complete before moving on
+ while (!hasFired.getAndSet(false)) {
+ Timer.delay(0.005);
+ }
}
+ // Then
+ assertEquals(
+ "The interrupt did not fire the expected number of times", fireCount, counter.get());
}
- // Then
- assertEquals("The interrupt did not fire the expected number of times", fireCount,
- counter.getCount());
}
- /**
- * The timeout length for this test in seconds.
- */
+ /** The timeout length for this test in seconds. */
private static final int synchronousTimeout = 5;
@Test(timeout = (long) (synchronousTimeout * 1e3))
public void testSynchronousInterruptsTriggering() {
- // Given
- getInterruptable().requestInterrupts();
+ try (SynchronousInterrupt interrupt = new SynchronousInterrupt(getSource())) {
+ final double synchronousDelay = synchronousTimeout / 2.0;
+ final Runnable runnable =
+ () -> {
+ Timer.delay(synchronousDelay);
+ setInterruptLow();
+ setInterruptHigh();
+ };
- final double synchronousDelay = synchronousTimeout / 2.0;
- final Runnable runnable = () -> {
- Timer.delay(synchronousDelay);
- setInterruptLow();
- setInterruptHigh();
- };
+ // When
- // When
+ // Note: the long time value is used because doubles can flip if the robot
+ // is left running for long enough
+ final long startTimeStamp = RobotController.getFPGATime();
+ new Thread(runnable).start();
+ // Delay for twice as long as the timeout so the test should fail first
+ interrupt.waitForInterrupt(synchronousTimeout * 2);
+ final long stopTimeStamp = RobotController.getFPGATime();
- // Note: the long time value is used because doubles can flip if the robot
- // is left running for long enough
- final long startTimeStamp = RobotController.getFPGATime();
- new Thread(runnable).start();
- // Delay for twice as long as the timeout so the test should fail first
- getInterruptable().waitForInterrupt(synchronousTimeout * 2);
- final long stopTimeStamp = RobotController.getFPGATime();
-
- // Then
- // The test will not have timed out and:
- final double interruptRunTime = (stopTimeStamp - startTimeStamp) * 1e-6;
- assertEquals("The interrupt did not run for the expected amount of time (units in seconds)",
- synchronousDelay, interruptRunTime, 0.1);
+ // Then
+ // The test will not have timed out and:
+ final double interruptRunTime = (stopTimeStamp - startTimeStamp) * 1e-6;
+ assertEquals(
+ "The interrupt did not run for the expected amount of time (units in seconds)",
+ synchronousDelay,
+ interruptRunTime,
+ 0.1);
+ }
}
@Test(timeout = (long) (synchronousTimeout * 1e3))
public void testSynchronousInterruptsWaitResultTimeout() {
- // Given
- getInterruptable().requestInterrupts();
+ try (SynchronousInterrupt interrupt = new SynchronousInterrupt(getSource())) {
+ SynchronousInterrupt.WaitResult result = interrupt.waitForInterrupt(synchronousTimeout / 2);
- //Don't fire interrupt. Expect it to timeout.
- InterruptableSensorBase.WaitResult result = getInterruptable()
- .waitForInterrupt(synchronousTimeout / 2);
-
- assertEquals("The interrupt did not time out correctly.", result, InterruptableSensorBase
- .WaitResult.kTimeout);
+ assertEquals(
+ "The interrupt did not time out correctly.",
+ result,
+ SynchronousInterrupt.WaitResult.kTimeout);
+ }
}
@Test(timeout = (long) (synchronousTimeout * 1e3))
public void testSynchronousInterruptsWaitResultRisingEdge() {
- // Given
- getInterruptable().requestInterrupts();
+ try (SynchronousInterrupt interrupt = new SynchronousInterrupt(getSource())) {
+ final double synchronousDelay = synchronousTimeout / 2.0;
+ final Runnable runnable =
+ () -> {
+ Timer.delay(synchronousDelay);
+ setInterruptLow();
+ setInterruptHigh();
+ };
- final double synchronousDelay = synchronousTimeout / 2.0;
- final Runnable runnable = () -> {
- Timer.delay(synchronousDelay);
- setInterruptLow();
- setInterruptHigh();
- };
+ new Thread(runnable).start();
+ // Delay for twice as long as the timeout so the test should fail first
+ SynchronousInterrupt.WaitResult result = interrupt.waitForInterrupt(synchronousTimeout * 2);
- new Thread(runnable).start();
- // Delay for twice as long as the timeout so the test should fail first
- InterruptableSensorBase.WaitResult result = getInterruptable()
- .waitForInterrupt(synchronousTimeout * 2);
-
- assertEquals("The interrupt did not fire on the rising edge.", result,
- InterruptableSensorBase.WaitResult.kRisingEdge);
+ assertEquals(
+ "The interrupt did not fire on the rising edge.",
+ result,
+ SynchronousInterrupt.WaitResult.kRisingEdge);
+ }
}
@Test(timeout = (long) (synchronousTimeout * 1e3))
public void testSynchronousInterruptsWaitResultFallingEdge() {
- // Given
- getInterruptable().requestInterrupts();
- getInterruptable().setUpSourceEdge(false, true);
+ try (SynchronousInterrupt interrupt = new SynchronousInterrupt(getSource())) {
+ // Given
+ interrupt.setInterruptEdges(false, true);
- final double synchronousDelay = synchronousTimeout / 2.0;
- final Runnable runnable = () -> {
- Timer.delay(synchronousDelay);
- setInterruptHigh();
- setInterruptLow();
- };
+ final double synchronousDelay = synchronousTimeout / 2.0;
+ final Runnable runnable =
+ () -> {
+ Timer.delay(synchronousDelay);
+ setInterruptHigh();
+ setInterruptLow();
+ };
- new Thread(runnable).start();
- // Delay for twice as long as the timeout so the test should fail first
- InterruptableSensorBase.WaitResult result = getInterruptable()
- .waitForInterrupt(synchronousTimeout * 2);
+ new Thread(runnable).start();
+ // Delay for twice as long as the timeout so the test should fail first
+ SynchronousInterrupt.WaitResult result = interrupt.waitForInterrupt(synchronousTimeout * 2);
- assertEquals("The interrupt did not fire on the falling edge.", result,
- InterruptableSensorBase.WaitResult.kFallingEdge);
+ assertEquals(
+ "The interrupt did not fire on the falling edge.",
+ result,
+ SynchronousInterrupt.WaitResult.kFallingEdge);
+ }
}
-
@Test(timeout = 4000)
public void testDisableStopsInterruptFiring() {
- final InterruptCounter counter = new InterruptCounter();
- TestInterruptHandlerFunction function = new TestInterruptHandlerFunction(counter);
-
- // When
- getInterruptable().requestInterrupts(function);
- getInterruptable().enableInterrupts();
-
- final int fireCount = 50;
- for (int i = 0; i < fireCount; i++) {
- setInterruptLow();
- setInterruptHigh();
- // Wait for the interrupt to complete before moving on
- while (!function.m_interruptComplete.getAndSet(false)) {
+ AtomicBoolean interruptComplete = new AtomicBoolean(false);
+ AtomicInteger counter = new AtomicInteger(0);
+ try (AsynchronousInterrupt interrupt =
+ new AsynchronousInterrupt(
+ getSource(),
+ (a, b) -> {
+ interruptComplete.set(true);
+ counter.incrementAndGet();
+ })) {
+ interrupt.enable();
+ final int fireCount = 50;
+ for (int i = 0; i < fireCount; i++) {
+ setInterruptLow();
+ setInterruptHigh();
+ // Wait for the interrupt to complete before moving on
+ while (!interruptComplete.getAndSet(false)) {
+ Timer.delay(0.005);
+ }
+ }
+ interrupt.disable();
+ for (int i = 0; i < fireCount; i++) {
+ setInterruptLow();
+ setInterruptHigh();
+ // Just wait because the interrupt should not fire
Timer.delay(0.005);
}
- }
- getInterruptable().disableInterrupts();
- // TestBench.out().println("Finished disabling the robot");
- for (int i = 0; i < fireCount; i++) {
- setInterruptLow();
- setInterruptHigh();
- // Just wait because the interrupt should not fire
- Timer.delay(0.005);
+ assertEquals(
+ "The interrupt did not fire the expected number of times", fireCount, counter.get());
}
-
- // Then
- assertEquals("The interrupt did not fire the expected number of times", fireCount,
- counter.getCount());
}
-
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AnalogCrossConnectTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AnalogCrossConnectTest.java
index 14b7034..34c57fb 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AnalogCrossConnectTest.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AnalogCrossConnectTest.java
@@ -1,30 +1,23 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2019 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj;
-import java.util.logging.Logger;
-
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import edu.wpi.first.wpilibj.AnalogTriggerOutput.AnalogTriggerType;
-import edu.wpi.first.wpilibj.fixtures.AnalogCrossConnectFixture;
-import edu.wpi.first.wpilibj.test.TestBench;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-/**
- * Test that covers the {@link AnalogCrossConnectFixture}.
- */
+import edu.wpi.first.wpilibj.AnalogTriggerOutput.AnalogTriggerType;
+import edu.wpi.first.wpilibj.fixtures.AnalogCrossConnectFixture;
+import edu.wpi.first.wpilibj.test.TestBench;
+import java.util.logging.Logger;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/** Test that covers the {@link AnalogCrossConnectFixture}. */
public class AnalogCrossConnectTest extends AbstractInterruptTest {
private static final Logger logger = Logger.getLogger(AnalogCrossConnectTest.class.getName());
@@ -37,7 +30,6 @@
return logger;
}
-
@BeforeClass
public static void setUpBeforeClass() {
analogIO = TestBench.getAnalogCrossConnectFixture();
@@ -54,7 +46,6 @@
analogIO.setup();
}
-
@Test
public void testAnalogOuput() {
for (int i = 0; i < 50; i++) {
@@ -148,34 +139,31 @@
* (non-Javadoc)
*
* @see
- * edu.wpi.first.wpilibj.AbstractInterruptTest#giveInterruptableSensorBase()
+ * edu.wpi.first.wpilibj.AbstractInterruptTest#giveSource()
*/
@Override
- InterruptableSensorBase giveInterruptableSensorBase() {
+ DigitalSource giveSource() {
m_interruptTrigger = new AnalogTrigger(analogIO.getInput());
m_interruptTrigger.setLimitsVoltage(2.0, 3.0);
- m_interruptTriggerOutput = new AnalogTriggerOutput(m_interruptTrigger,
- AnalogTriggerType.kState);
+ m_interruptTriggerOutput =
+ new AnalogTriggerOutput(m_interruptTrigger, AnalogTriggerType.kState);
return m_interruptTriggerOutput;
}
-
/*
* (non-Javadoc)
*
* @see
- * edu.wpi.first.wpilibj.AbstractInterruptTest#freeInterruptableSensorBase()
+ * edu.wpi.first.wpilibj.AbstractInterruptTest#freeSource()
*/
@Override
- void freeInterruptableSensorBase() {
- m_interruptTriggerOutput.cancelInterrupts();
+ void freeSource() {
m_interruptTriggerOutput.close();
m_interruptTriggerOutput = null;
m_interruptTrigger.close();
m_interruptTrigger = null;
}
-
/*
* (non-Javadoc)
*
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometerTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometerTest.java
index 29ac6e4..1bac2ca 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometerTest.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/AnalogPotentiometerTest.java
@@ -1,28 +1,21 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2019 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj;
-import java.util.logging.Logger;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
import edu.wpi.first.wpilibj.fixtures.AnalogCrossConnectFixture;
import edu.wpi.first.wpilibj.mockhardware.FakePotentiometerSource;
import edu.wpi.first.wpilibj.test.AbstractComsSetup;
import edu.wpi.first.wpilibj.test.TestBench;
+import java.util.logging.Logger;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests the {@link AnalogPotentiometer}.
- */
+/** Tests the {@link AnalogPotentiometer}. */
public class AnalogPotentiometerTest extends AbstractComsSetup {
private static final Logger logger = Logger.getLogger(AnalogPotentiometerTest.class.getName());
private AnalogCrossConnectFixture m_analogIO;
@@ -36,7 +29,6 @@
m_analogIO = TestBench.getAnalogCrossConnectFixture();
m_potSource = new FakePotentiometerSource(m_analogIO.getOutput(), 360);
m_pot = new AnalogPotentiometer(m_analogIO.getInput(), 360.0, 0);
-
}
@After
@@ -65,6 +57,4 @@
assertEquals(i, m_pot.get(), DOUBLE_COMPARISON_DELTA);
}
}
-
-
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/BuiltInAccelerometerTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/BuiltInAccelerometerTest.java
index dbfddfa..8b1188d 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/BuiltInAccelerometerTest.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/BuiltInAccelerometerTest.java
@@ -1,27 +1,22 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2014-2018 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj;
+import static org.junit.Assert.assertEquals;
+
+import edu.wpi.first.wpilibj.interfaces.Accelerometer;
+import edu.wpi.first.wpilibj.test.AbstractComsSetup;
import java.util.Arrays;
import java.util.Collection;
import java.util.logging.Logger;
-
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
-import edu.wpi.first.wpilibj.interfaces.Accelerometer;
-import edu.wpi.first.wpilibj.test.AbstractComsSetup;
-
-import static org.junit.Assert.assertEquals;
-
@RunWith(Parameterized.class)
public class BuiltInAccelerometerTest extends AbstractComsSetup {
private static final Logger logger = Logger.getLogger(BuiltInAccelerometerTest.class.getName());
@@ -41,13 +36,13 @@
Timer.delay(1.0);
}
- /**
- * Test with all valid ranges to make sure unpacking is always done correctly.
- */
+ /** Test with all valid ranges to make sure unpacking is always done correctly. */
@Parameters
public static Collection<Accelerometer.Range[]> generateData() {
- return Arrays.asList(new Accelerometer.Range[][]{{Accelerometer.Range.k2G},
- {Accelerometer.Range.k4G}, {Accelerometer.Range.k8G}});
+ return Arrays.asList(
+ new Accelerometer.Range[][] {
+ {Accelerometer.Range.k2G}, {Accelerometer.Range.k4G}, {Accelerometer.Range.k8G}
+ });
}
@Override
@@ -65,5 +60,4 @@
assertEquals(1.0, m_accelerometer.getY(), kAccelerationTolerance);
assertEquals(0.0, m_accelerometer.getZ(), kAccelerationTolerance);
}
-
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/ConstantsPortsTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/ConstantsPortsTest.java
index aae1661..63ea22a 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/ConstantsPortsTest.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/ConstantsPortsTest.java
@@ -1,23 +1,16 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2018 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj;
-import java.util.logging.Logger;
-
-import org.junit.Test;
-
-import edu.wpi.first.wpilibj.test.AbstractComsSetup;
-
import static org.junit.Assert.assertEquals;
-/**
- * Tests for checking our constant and port values.
- */
+import edu.wpi.first.wpilibj.test.AbstractComsSetup;
+import java.util.logging.Logger;
+import org.junit.Test;
+
+/** Tests for checking our constant and port values. */
public class ConstantsPortsTest extends AbstractComsSetup {
private static final Logger logger = Logger.getLogger(ConstantsPortsTest.class.getName());
@@ -26,75 +19,33 @@
return logger;
}
- /**
- * kDigitalChannels.
- */
+ /** kDigitalChannels. */
@Test
public void testDigitalChannels() {
assertEquals(31, SensorUtil.kDigitalChannels);
}
- /**
- * kAnalogInputChannels.
- */
+ /** kAnalogInputChannels. */
@Test
public void testAnalogInputChannels() {
assertEquals(8, SensorUtil.kAnalogInputChannels);
}
- /**
- * kAnalogOutputChannels.
- */
+ /** kAnalogOutputChannels. */
@Test
public void testAnalogOutputChannels() {
assertEquals(2, SensorUtil.kAnalogOutputChannels);
}
- /**
- * kSolenoidChannels.
- */
- @Test
- public void testSolenoidChannels() {
- assertEquals(8, SensorUtil.kSolenoidChannels);
- }
-
- /**
- * kPwmChannels.
- */
+ /** kPwmChannels. */
@Test
public void testPwmChannels() {
assertEquals(20, SensorUtil.kPwmChannels);
}
- /**
- * kRelayChannels.
- */
+ /** kRelayChannels. */
@Test
public void testRelayChannels() {
assertEquals(4, SensorUtil.kRelayChannels);
}
-
- /**
- * kPDPChannels.
- */
- @Test
- public void testPDPChannels() {
- assertEquals(16, SensorUtil.kPDPChannels);
- }
-
- /**
- * kPDPModules.
- */
- @Test
- public void testPDPModules() {
- assertEquals(63, SensorUtil.kPDPModules);
- }
-
- /**
- * kPCMModules.
- */
- @Test
- public void testPCMModules() {
- assertEquals(63, SensorUtil.kPCMModules);
- }
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/CounterTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/CounterTest.java
index f6e3326..793c7e9 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/CounterTest.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/CounterTest.java
@@ -1,15 +1,17 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2019 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import edu.wpi.first.wpilibj.fixtures.FakeCounterFixture;
+import edu.wpi.first.wpilibj.test.AbstractComsSetup;
+import edu.wpi.first.wpilibj.test.TestBench;
import java.util.Collection;
import java.util.logging.Logger;
-
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -18,16 +20,7 @@
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
-import edu.wpi.first.wpilibj.fixtures.FakeCounterFixture;
-import edu.wpi.first.wpilibj.test.AbstractComsSetup;
-import edu.wpi.first.wpilibj.test.TestBench;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Tests to see if the Counter is working properly.
- */
+/** Tests to see if the Counter is working properly. */
@RunWith(Parameterized.class)
public class CounterTest extends AbstractComsSetup {
private static FakeCounterFixture counter = null;
@@ -44,7 +37,7 @@
/**
* Constructs a Counter Test with the given inputs.
*
- * @param input The input Port
+ * @param input The input Port
* @param output The output Port
*/
public CounterTest(Integer input, Integer output) {
@@ -73,13 +66,11 @@
// port}.
// These data are hard-coded into the class, but they could be
// generated or loaded in any way you like.
- return TestBench.getInstance().getDIOCrossConnectCollection();
+ return TestBench.getDIOCrossConnectCollection();
}
-
@BeforeClass
- public static void setUpBeforeClass() {
- }
+ public static void setUpBeforeClass() {}
@AfterClass
public static void tearDownAfterClass() {
@@ -92,9 +83,7 @@
counter.setup();
}
- /**
- * Tests the default state of the counter immediately after reset.
- */
+ /** Tests the default state of the counter immediately after reset. */
@Test
public void testDefault() {
assertEquals("Counter did not reset to 0", 0, counter.getCounter().get());
@@ -108,8 +97,15 @@
final int count = counter.getCounter().get();
- assertTrue("Fake Counter, Input: " + m_input + ", Output: " + m_output + ", did not return "
- + goal + " instead got: " + count, count == goal);
+ assertTrue(
+ "Fake Counter, Input: "
+ + m_input
+ + ", Output: "
+ + m_output
+ + ", did not return "
+ + goal
+ + " instead got: "
+ + count,
+ count == goal);
}
-
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DIOCrossConnectTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DIOCrossConnectTest.java
index 14eed0c..97405ce 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DIOCrossConnectTest.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DIOCrossConnectTest.java
@@ -1,15 +1,16 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2019 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import edu.wpi.first.wpilibj.fixtures.DIOCrossConnectFixture;
+import edu.wpi.first.wpilibj.test.TestBench;
import java.util.Collection;
import java.util.logging.Logger;
-
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Test;
@@ -17,15 +18,7 @@
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
-import edu.wpi.first.wpilibj.fixtures.DIOCrossConnectFixture;
-import edu.wpi.first.wpilibj.test.TestBench;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Tests to see if the Digital ports are working properly.
- */
+/** Tests to see if the Digital ports are working properly. */
@RunWith(Parameterized.class)
public class DIOCrossConnectTest extends AbstractInterruptTest {
private static final Logger logger = Logger.getLogger(DIOCrossConnectTest.class.getName());
@@ -39,11 +32,11 @@
/**
* Default constructor for the DIOCrossConnectTest This test is parameterized in order to allow it
- * to be tested using a variety of different input/output pairs without duplicate code.<br> This
- * class takes Integer port values instead of DigitalClasses because it would force them to be
- * instantiated at the same time which could (untested) cause port binding errors.
+ * to be tested using a variety of different input/output pairs without duplicate code.<br>
+ * This class takes Integer port values instead of DigitalClasses because it would force them to
+ * be instantiated at the same time which could (untested) cause port binding errors.
*
- * @param input The port for the input wire
+ * @param input The port for the input wire
* @param output The port for the output wire
*/
public DIOCrossConnectTest(Integer input, Integer output) {
@@ -53,7 +46,6 @@
dio = new DIOCrossConnectFixture(input, output);
}
-
/**
* Test data generator. This method is called the the JUnit parameterized test runner and returns
* a Collection of Arrays. For each Array in the Collection, each array element corresponds to a
@@ -66,7 +58,7 @@
// port}.
// These data are hard-coded into the class, but they could be
// generated or loaded in any way you like.
- return TestBench.getInstance().getDIOCrossConnectCollection();
+ return TestBench.getDIOCrossConnectCollection();
}
@AfterClass
@@ -80,9 +72,7 @@
dio.reset();
}
- /**
- * Tests to see if the DIO can create and recognize a high value.
- */
+ /** Tests to see if the DIO can create and recognize a high value. */
@Test
public void testSetHigh() {
dio.getOutput().set(true);
@@ -91,9 +81,7 @@
assertTrue("DIO Not High after .05s delay", dio.getInput().get());
}
- /**
- * Tests to see if the DIO can create and recognize a low value.
- */
+ /** Tests to see if the DIO can create and recognize a low value. */
@Test
public void testSetLow() {
dio.getOutput().set(false);
@@ -102,23 +90,22 @@
assertFalse("DIO Not Low after .05s delay", dio.getInput().get());
}
- /**
- * Tests to see if the DIO PWM functionality works.
- */
+ /** Tests to see if the DIO PWM functionality works. */
@Test
public void testDIOpulseWidthModulation() {
dio.getOutput().set(false);
assertFalse("DIO Not Low after no delay", dio.getInput().get());
- //Set frequency to 2.0 Hz
+ // Set frequency to 2.0 Hz
dio.getOutput().setPWMRate(2.0);
- //Enable PWM, but leave it off.
+ // Enable PWM, but leave it off.
dio.getOutput().enablePWM(0.0);
Timer.delay(0.5);
dio.getOutput().updateDutyCycle(0.5);
- dio.getInput().requestInterrupts();
- dio.getInput().setUpSourceEdge(false, true);
- //TODO: Add return value from WaitForInterrupt
- dio.getInput().waitForInterrupt(3.0, true);
+ try (var interruptHandler = new SynchronousInterrupt(dio.getInput())) {
+ interruptHandler.setInterruptEdges(false, true);
+ // TODO: Add return value from WaitForInterrupt
+ interruptHandler.waitForInterrupt(3.0, true);
+ }
Timer.delay(0.5);
final boolean firstCycle = dio.getInput().get();
Timer.delay(0.5);
@@ -154,10 +141,10 @@
* (non-Javadoc)
*
* @see
- * edu.wpi.first.wpilibj.AbstractInterruptTest#giveInterruptableSensorBase()
+ * edu.wpi.first.wpilibj.AbstractInterruptTest#giveSource()
*/
@Override
- InterruptableSensorBase giveInterruptableSensorBase() {
+ DigitalSource giveSource() {
return dio.getInput();
}
@@ -165,10 +152,10 @@
* (non-Javadoc)
*
* @see
- * edu.wpi.first.wpilibj.AbstractInterruptTest#freeInterruptableSensorBase()
+ * edu.wpi.first.wpilibj.AbstractInterruptTest#freeSource()
*/
@Override
- void freeInterruptableSensorBase() {
+ void freeSource() {
// Handled in the fixture
}
@@ -190,7 +177,5 @@
@Override
void setInterruptLow() {
dio.getOutput().set(false);
-
}
-
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DMATest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DMATest.java
new file mode 100644
index 0000000..1da5c6f
--- /dev/null
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DMATest.java
@@ -0,0 +1,161 @@
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
+
+package edu.wpi.first.wpilibj;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertTrue;
+
+import edu.wpi.first.math.util.Units;
+import edu.wpi.first.wpilibj.fixtures.AnalogCrossConnectFixture;
+import edu.wpi.first.wpilibj.motorcontrol.Jaguar;
+import edu.wpi.first.wpilibj.motorcontrol.PWMMotorController;
+import edu.wpi.first.wpilibj.test.AbstractComsSetup;
+import edu.wpi.first.wpilibj.test.TestBench;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.logging.Logger;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Ignore;
+import org.junit.Test;
+
+@Ignore
+public class DMATest extends AbstractComsSetup {
+ private static final Logger logger = Logger.getLogger(DMATest.class.getName());
+
+ @Override
+ protected Logger getClassLogger() {
+ return logger;
+ }
+
+ private AnalogCrossConnectFixture m_analogIO;
+ private DigitalOutput m_manualTrigger;
+ private PWMMotorController m_pwm;
+ private DMA m_dma;
+ private DMASample m_dmaSample;
+
+ @Before
+ public void setUp() {
+ m_analogIO = TestBench.getAnalogCrossConnectFixture();
+ m_manualTrigger = new DigitalOutput(7);
+ m_pwm = new Jaguar(14);
+ m_dma = new DMA();
+ m_dmaSample = new DMASample();
+
+ m_dma.addAnalogInput(m_analogIO.getInput());
+ m_dma.setExternalTrigger(m_manualTrigger, false, true);
+ m_manualTrigger.set(true);
+ }
+
+ @After
+ public void tearDown() {
+ m_dma.close();
+ m_manualTrigger.close();
+ m_analogIO.teardown();
+ m_pwm.close();
+ }
+
+ @Test
+ public void testPausingWorks() {
+ m_dma.start(1024);
+ m_dma.setPause(true);
+ m_manualTrigger.set(false);
+
+ var timedOut = m_dmaSample.update(m_dma, Units.millisecondsToSeconds(5));
+
+ assertEquals(DMASample.DMAReadStatus.kTimeout, timedOut);
+ }
+
+ @Test
+ public void testRemovingTriggersWorks() {
+ m_dma.clearExternalTriggers();
+ m_dma.start(1024);
+ m_manualTrigger.set(false);
+
+ var timedOut = m_dmaSample.update(m_dma, Units.millisecondsToSeconds(5));
+
+ assertEquals(DMASample.DMAReadStatus.kTimeout, timedOut);
+ }
+
+ @Test
+ public void testManualTriggerOnlyHappensOnce() {
+ m_dma.start(1024);
+ m_manualTrigger.set(false);
+ var timedOut = m_dmaSample.update(m_dma, Units.millisecondsToSeconds(5));
+ m_manualTrigger.set(true);
+
+ assertEquals(DMASample.DMAReadStatus.kOk, timedOut);
+ assertEquals(0, m_dmaSample.getRemaining());
+ timedOut = m_dmaSample.update(m_dma, Units.millisecondsToSeconds(5));
+ assertEquals(DMASample.DMAReadStatus.kTimeout, timedOut);
+ }
+
+ @Test
+ public void testAnalogIndividualTriggers() {
+ m_dma.start(1024);
+ for (double i = 0; i < 5; i += 0.5) {
+ m_analogIO.getOutput().setVoltage(i);
+ // Need to sleep to ensure value sets
+ Timer.delay(AnalogCrossConnectTest.kDelayTime);
+ m_manualTrigger.set(false);
+ var timedOut = m_dmaSample.update(m_dma, Units.millisecondsToSeconds(1));
+ m_manualTrigger.set(true);
+
+ assertEquals(DMASample.DMAReadStatus.kOk, timedOut);
+ assertEquals(0, m_dmaSample.getRemaining());
+ assertEquals(
+ m_analogIO.getInput().getVoltage(),
+ m_dmaSample.getAnalogInputVoltage(m_analogIO.getInput()),
+ 0.01);
+ }
+ }
+
+ @Test
+ public void testAnalogMultipleTriggers() {
+ m_dma.start(1024);
+ List<Double> values = new ArrayList<>();
+ for (double i = 0; i < 5; i += 0.5) {
+ m_analogIO.getOutput().setVoltage(i);
+ values.add(i);
+ // Need to sleep to ensure value sets
+ Timer.delay(AnalogCrossConnectTest.kDelayTime);
+ m_manualTrigger.set(false);
+ Timer.delay(AnalogCrossConnectTest.kDelayTime);
+ m_manualTrigger.set(true);
+ }
+
+ for (int i = 0; i < values.size(); i++) {
+ var timedOut = m_dmaSample.update(m_dma, Units.millisecondsToSeconds(1));
+ assertEquals(DMASample.DMAReadStatus.kOk, timedOut);
+ assertEquals(values.size() - i - 1, m_dmaSample.getRemaining());
+ assertEquals(values.get(i), m_dmaSample.getAnalogInputVoltage(m_analogIO.getInput()), 0.01);
+ }
+ }
+
+ @Test
+ public void testTimedTriggers() {
+ m_dma.setTimedTrigger(Units.millisecondsToSeconds(10));
+ m_dma.start(1024);
+ Timer.delay(Units.millisecondsToSeconds(100));
+ m_dma.setPause(true);
+
+ var timedOut = m_dmaSample.update(m_dma, Units.millisecondsToSeconds(1));
+ assertEquals(DMASample.DMAReadStatus.kOk, timedOut);
+ assertTrue("Received more then 5 samples in 100 ms", m_dmaSample.getRemaining() > 5);
+ }
+
+ @Test
+ public void testPwmTimedTriggers() {
+ m_dma.clearExternalTriggers();
+ m_dma.setPwmEdgeTrigger(m_pwm, true, false);
+ m_dma.start(1024);
+ Timer.delay(Units.millisecondsToSeconds(100));
+ m_dma.setPause(true);
+
+ var timedOut = m_dmaSample.update(m_dma, Units.millisecondsToSeconds(1));
+ assertEquals(DMASample.DMAReadStatus.kOk, timedOut);
+ assertTrue("Received more then 5 samples in 100 ms", m_dmaSample.getRemaining() > 5);
+ }
+}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DigitalGlitchFilterTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DigitalGlitchFilterTest.java
index 821f5cc..932195e 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DigitalGlitchFilterTest.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DigitalGlitchFilterTest.java
@@ -1,26 +1,18 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2018 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj;
-import java.util.logging.Logger;
-
-import org.junit.Test;
-
-import edu.wpi.first.wpilibj.test.AbstractComsSetup;
-
import static org.junit.Assert.assertEquals;
-/**
- * Test for the DigitalGlitchFilter class.
- */
+import edu.wpi.first.wpilibj.test.AbstractComsSetup;
+import java.util.logging.Logger;
+import org.junit.Test;
+
+/** Test for the DigitalGlitchFilter class. */
public class DigitalGlitchFilterTest extends AbstractComsSetup {
- private static final Logger logger = Logger.getLogger(
- DigitalGlitchFilterTest.class.getName());
+ private static final Logger logger = Logger.getLogger(DigitalGlitchFilterTest.class.getName());
@Override
protected Logger getClassLogger() {
@@ -29,9 +21,9 @@
/**
* This is a test to make sure that filters can be created and are consistent. This assumes that
- * the FPGA implementation to actually implement the filter has been tested. It does validate
- * that we are successfully able to set and get the active filters for ports and makes sure that
- * the FPGA filter is changed correctly, and does the same for the period.
+ * the FPGA implementation to actually implement the filter has been tested. It does validate that
+ * we are successfully able to set and get the active filters for ports and makes sure that the
+ * FPGA filter is changed correctly, and does the same for the period.
*/
@Test
public void testDigitalGlitchFilterBasic() {
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DriverStationTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DriverStationTest.java
index 301a7ee..b2e727d 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DriverStationTest.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/DriverStationTest.java
@@ -1,20 +1,14 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2018 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj;
-import java.util.logging.Logger;
-
-import org.junit.Test;
-
-import edu.wpi.first.wpilibj.test.AbstractComsSetup;
-
import static org.junit.Assert.assertEquals;
+import edu.wpi.first.wpilibj.test.AbstractComsSetup;
+import java.util.logging.Logger;
+import org.junit.Test;
public class DriverStationTest extends AbstractComsSetup {
private static final Logger logger = Logger.getLogger(TimerTest.class.getName());
@@ -32,13 +26,15 @@
// Wait for data 50 times
for (int i = 0; i < 50; i++) {
- DriverStation.getInstance().waitForData();
+ DriverStation.waitForData();
}
long endTime = RobotController.getFPGATime();
long difference = endTime - startTime;
- assertEquals("DriverStation waitForData did not wait long enough", TIMER_RUNTIME, difference,
+ assertEquals(
+ "DriverStation waitForData did not wait long enough",
+ TIMER_RUNTIME,
+ difference,
TIMER_TOLERANCE * TIMER_RUNTIME);
}
-
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/EncoderTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/EncoderTest.java
index 3a639ab..f1bfca5 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/EncoderTest.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/EncoderTest.java
@@ -1,15 +1,16 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2019 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj;
+import static org.junit.Assert.assertTrue;
+
+import edu.wpi.first.wpilibj.fixtures.FakeEncoderFixture;
+import edu.wpi.first.wpilibj.test.AbstractComsSetup;
+import edu.wpi.first.wpilibj.test.TestBench;
import java.util.Collection;
import java.util.logging.Logger;
-
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -18,16 +19,7 @@
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
-import edu.wpi.first.wpilibj.fixtures.FakeEncoderFixture;
-import edu.wpi.first.wpilibj.test.AbstractComsSetup;
-import edu.wpi.first.wpilibj.test.TestBench;
-
-import static org.junit.Assert.assertTrue;
-
-
-/**
- * Test to see if the FPGA properly recognizes a mock Encoder input.
- */
+/** Test to see if the FPGA properly recognizes a mock Encoder input. */
@RunWith(Parameterized.class)
public class EncoderTest extends AbstractComsSetup {
private static final Logger logger = Logger.getLogger(EncoderTest.class.getName());
@@ -45,23 +37,23 @@
}
/**
- * Test data generator. This method is called the the JUnit parametrized test runner and returns
- * a Collection of Arrays. For each Array in the Collection, each array element corresponds to a
+ * Test data generator. This method is called the the JUnit parametrized test runner and returns a
+ * Collection of Arrays. For each Array in the Collection, each array element corresponds to a
* parameter in the constructor.
*/
@Parameters
public static Collection<Integer[]> generateData() {
- return TestBench.getInstance().getEncoderDIOCrossConnectCollection();
+ return TestBench.getEncoderDIOCrossConnectCollection();
}
/**
* Constructs a parametrized Encoder Test.
*
- * @param inputA The port number for inputA
+ * @param inputA The port number for inputA
* @param outputA The port number for outputA
- * @param inputB The port number for inputB
+ * @param inputB The port number for inputB
* @param outputB The port number for outputB
- * @param flip whether or not these set of values require the encoder to be reversed (0 or 1)
+ * @param flip whether or not these set of values require the encoder to be reversed (0 or 1)
*/
public EncoderTest(int inputA, int outputA, int inputB, int outputB, int flip) {
m_inputA = inputA;
@@ -84,9 +76,7 @@
encoder = null;
}
- /**
- * Sets up the test and verifies that the test was reset to the default state.
- */
+ /** Sets up the test and verifies that the test was reset to the default state. */
@Before
public void setUp() {
encoder.setup();
@@ -98,18 +88,14 @@
encoder.reset();
}
- /**
- * Tests to see if Encoders initialize to zero.
- */
+ /** Tests to see if Encoders initialize to zero. */
@Test
public void testDefaultState() {
int value = encoder.getEncoder().get();
assertTrue(errorMessage(0, value), value == 0);
}
- /**
- * Tests to see if Encoders can count up successfully.
- */
+ /** Tests to see if Encoders can count up successfully. */
@Test
public void testCountUp() {
int goal = 100;
@@ -118,12 +104,9 @@
encoder.getFakeEncoderSource().execute();
int value = encoder.getEncoder().get();
assertTrue(errorMessage(goal, value), value == goal);
-
}
- /**
- * Tests to see if Encoders can count down successfully.
- */
+ /** Tests to see if Encoders can count down successfully. */
@Test
public void testCountDown() {
int goal = -100;
@@ -132,18 +115,27 @@
encoder.getFakeEncoderSource().execute();
int value = encoder.getEncoder().get();
assertTrue(errorMessage(goal, value), value == goal);
-
}
/**
* Creates a simple message with the error that was encountered for the Encoders.
*
- * @param goal The goal that was trying to be reached
+ * @param goal The goal that was trying to be reached
* @param trueValue The actual value that was reached by the test
* @return A fully constructed message with data about where and why the the test failed.
*/
private String errorMessage(int goal, int trueValue) {
- return "Encoder ({In,Out}): {" + m_inputA + ", " + m_outputA + "},{" + m_inputB + ", "
- + m_outputB + "} Returned: " + trueValue + ", Wanted: " + goal;
+ return "Encoder ({In,Out}): {"
+ + m_inputA
+ + ", "
+ + m_outputA
+ + "},{"
+ + m_inputB
+ + ", "
+ + m_outputB
+ + "} Returned: "
+ + trueValue
+ + ", Wanted: "
+ + goal;
}
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/GyroTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/GyroTest.java
index 1fc828c..0182a00 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/GyroTest.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/GyroTest.java
@@ -1,27 +1,20 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2019 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj;
-import java.util.logging.Logger;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
import edu.wpi.first.wpilibj.fixtures.TiltPanCameraFixture;
import edu.wpi.first.wpilibj.test.AbstractComsSetup;
import edu.wpi.first.wpilibj.test.TestBench;
+import java.util.logging.Logger;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-
-/**
- * Tests that the {@link TiltPanCameraFixture}.
- */
+/** Tests that the {@link TiltPanCameraFixture}. */
public class GyroTest extends AbstractComsSetup {
private static final Logger logger = Logger.getLogger(GyroTest.class.getName());
@@ -37,7 +30,7 @@
@Before
public void setUp() {
logger.fine("Setup: TiltPan camera");
- m_tpcam = TestBench.getInstance().getTiltPanCam();
+ m_tpcam = TestBench.getTiltPanCam();
m_tpcam.setup();
}
@@ -92,7 +85,6 @@
assertEquals(errorMessage(diff, TEST_ANGLE), TEST_ANGLE, angle, 10);
}
-
protected void testDeviationOverTime(AnalogGyro gyro) {
// Make sure that the test isn't influenced by any previous motions.
Timer.delay(0.5);
@@ -125,5 +117,4 @@
private String errorMessage(double difference, double target) {
return "Gyro angle skewed " + difference + " deg away from target " + target;
}
-
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MockDS.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MockDS.java
index 0998ee9..dfd5b6c 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MockDS.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MockDS.java
@@ -1,9 +1,6 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2017-2018 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj;
@@ -25,50 +22,52 @@
data[5] = 0x00; // red 1 station
}
- @SuppressWarnings("JavadocMethod")
+ @SuppressWarnings("MissingJavadocMethod")
public void start() {
- m_thread = new Thread(() -> {
- DatagramSocket socket;
- try {
- socket = new DatagramSocket();
- } catch (SocketException e1) {
- // TODO Auto-generated catch block
- e1.printStackTrace();
- return;
- }
- InetSocketAddress addr = new InetSocketAddress("127.0.0.1", 1110);
- byte[] sendData = new byte[6];
- DatagramPacket packet = new DatagramPacket(sendData, 0, 6, addr);
- short sendCount = 0;
- int initCount = 0;
- while (!Thread.currentThread().isInterrupted()) {
- try {
- Thread.sleep(20);
- generateEnabledDsPacket(sendData, sendCount++);
- // ~50 disabled packets are required to make the robot actually enable
- // 1 is definitely not enough.
- if (initCount < 50) {
- initCount++;
- sendData[3] = 0;
- }
- packet.setData(sendData);
- socket.send(packet);
- } catch (InterruptedException ex) {
- Thread.currentThread().interrupt();
- } catch (IOException ex) {
- // TODO Auto-generated catch block
- ex.printStackTrace();
- }
- }
- socket.close();
- });
+ m_thread =
+ new Thread(
+ () -> {
+ DatagramSocket socket;
+ try {
+ socket = new DatagramSocket();
+ } catch (SocketException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ return;
+ }
+ InetSocketAddress addr = new InetSocketAddress("127.0.0.1", 1110);
+ byte[] sendData = new byte[6];
+ DatagramPacket packet = new DatagramPacket(sendData, 0, 6, addr);
+ short sendCount = 0;
+ int initCount = 0;
+ while (!Thread.currentThread().isInterrupted()) {
+ try {
+ Thread.sleep(20);
+ generateEnabledDsPacket(sendData, sendCount++);
+ // ~50 disabled packets are required to make the robot actually enable
+ // 1 is definitely not enough.
+ if (initCount < 50) {
+ initCount++;
+ sendData[3] = 0;
+ }
+ packet.setData(sendData);
+ socket.send(packet);
+ } catch (InterruptedException ex) {
+ Thread.currentThread().interrupt();
+ } catch (IOException ex) {
+ // TODO Auto-generated catch block
+ ex.printStackTrace();
+ }
+ }
+ socket.close();
+ });
// Because of the test setup in Java, this thread will not be stopped
// So it must be a daemon thread
m_thread.setDaemon(true);
m_thread.start();
}
- @SuppressWarnings("JavadocMethod")
+ @SuppressWarnings("MissingJavadocMethod")
public void stop() {
if (m_thread == null) {
return;
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MockSpeedController.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MockSpeedController.java
deleted file mode 100644
index d183723..0000000
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MockSpeedController.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2017-2018 FIRST. 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;
-
-public class MockSpeedController implements SpeedController {
- private double m_speed;
- private boolean m_isInverted;
-
- @Override
- public void set(double speed) {
- m_speed = m_isInverted ? -speed : speed;
- }
-
- @Override
- public double get() {
- return m_speed;
- }
-
- @Override
- public void setInverted(boolean isInverted) {
- m_isInverted = isInverted;
- }
-
- @Override
- public boolean getInverted() {
- return m_isInverted;
- }
-
- @Override
- public void disable() {
- m_speed = 0;
- }
-
- @Override
- public void stopMotor() {
- disable();
- }
-
- @Override
- public void pidWrite(double output) {
- set(output);
- }
-}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorEncoderTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorEncoderTest.java
index e6e48a6..72c2c55 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorEncoderTest.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorEncoderTest.java
@@ -1,16 +1,22 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2020 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import edu.wpi.first.math.MathUtil;
+import edu.wpi.first.math.controller.PIDController;
+import edu.wpi.first.math.filter.LinearFilter;
+import edu.wpi.first.wpilibj.fixtures.MotorEncoderFixture;
+import edu.wpi.first.wpilibj.test.AbstractComsSetup;
+import edu.wpi.first.wpilibj.test.TestBench;
import java.util.Arrays;
import java.util.Collection;
import java.util.logging.Logger;
-
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -19,17 +25,6 @@
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
-import edu.wpi.first.wpilibj.controller.PIDController;
-import edu.wpi.first.wpilibj.fixtures.MotorEncoderFixture;
-import edu.wpi.first.wpilibj.test.AbstractComsSetup;
-import edu.wpi.first.wpilibj.test.TestBench;
-import edu.wpi.first.wpiutil.math.MathUtil;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-
@RunWith(Parameterized.class)
public class MotorEncoderTest extends AbstractComsSetup {
private static final Logger logger = Logger.getLogger(MotorEncoderTest.class.getName());
@@ -61,8 +56,10 @@
@Parameters(name = "{index}: {0}")
public static Collection<MotorEncoderFixture<?>[]> generateData() {
// logger.fine("Loading the MotorList");
- return Arrays.asList(new MotorEncoderFixture<?>[][]{{TestBench.getInstance().getTalonPair()},
- {TestBench.getInstance().getVictorPair()}, {TestBench.getInstance().getJaguarPair()}});
+ return Arrays.asList(
+ new MotorEncoderFixture<?>[][] {
+ {TestBench.getTalonPair()}, {TestBench.getVictorPair()}, {TestBench.getJaguarPair()}
+ });
}
@Before
@@ -72,7 +69,6 @@
me.getType() + " Did not start with an initial speed of 0 instead got: " + initialSpeed,
Math.abs(initialSpeed) < 0.001);
me.setup();
-
}
@After
@@ -112,9 +108,13 @@
me.getMotor().set(0.2);
Timer.delay(MOTOR_RUNTIME);
int currentValue = me.getEncoder().get();
- assertTrue(me.getType() + " Encoder not incremented: start: " + startValue + "; current: "
- + currentValue, startValue < currentValue);
-
+ assertTrue(
+ me.getType()
+ + " Encoder not incremented: start: "
+ + startValue
+ + "; current: "
+ + currentValue,
+ startValue < currentValue);
}
/**
@@ -128,13 +128,16 @@
me.getMotor().set(-0.2);
Timer.delay(MOTOR_RUNTIME);
int currentValue = me.getEncoder().get();
- assertTrue(me.getType() + " Encoder not decremented: start: " + startValue + "; current: "
- + currentValue, startValue > currentValue);
+ assertTrue(
+ me.getType()
+ + " Encoder not decremented: start: "
+ + startValue
+ + "; current: "
+ + currentValue,
+ startValue > currentValue);
}
- /**
- * This method test if the counters count when the motors rotate.
- */
+ /** This method test if the counters count when the motors rotate. */
@Test
public void testCounter() {
final int counter1Start = me.getCounters()[0].get();
@@ -144,10 +147,20 @@
Timer.delay(MOTOR_RUNTIME);
int counter1End = me.getCounters()[0].get();
int counter2End = me.getCounters()[1].get();
- assertTrue(me.getType() + " Counter not incremented: start: " + counter1Start + "; current: "
- + counter1End, counter1Start < counter1End);
- assertTrue(me.getType() + " Counter not incremented: start: " + counter1Start + "; current: "
- + counter2End, counter2Start < counter2End);
+ assertTrue(
+ me.getType()
+ + " Counter not incremented: start: "
+ + counter1Start
+ + "; current: "
+ + counter1End,
+ counter1Start < counter1End);
+ assertTrue(
+ me.getType()
+ + " Counter not incremented: start: "
+ + counter1Start
+ + "; current: "
+ + counter2End,
+ counter2Start < counter2End);
me.reset();
encodersResetCheck(me);
}
@@ -159,7 +172,8 @@
@Test
public void testSetHighForwardSpeed() {
me.getMotor().set(15);
- assertTrue(me.getType() + " Motor speed was not close to 1.0, was: " + me.getMotor().get(),
+ assertTrue(
+ me.getType() + " Motor speed was not close to 1.0, was: " + me.getMotor().get(),
me.isMotorSpeedWithinRange(1.0, 0.001));
}
@@ -170,11 +184,11 @@
@Test
public void testSetHighReverseSpeed() {
me.getMotor().set(-15);
- assertTrue(me.getType() + " Motor speed was not close to 1.0, was: " + me.getMotor().get(),
+ assertTrue(
+ me.getType() + " Motor speed was not close to 1.0, was: " + me.getMotor().get(),
me.isMotorSpeedWithinRange(-1.0, 0.001));
}
-
@Test
public void testPositionPIDController() {
try (PIDController pidController = new PIDController(0.001, 0.0005, 0)) {
@@ -182,17 +196,20 @@
pidController.setIntegratorRange(-0.2, 0.2);
pidController.setSetpoint(1000);
- try (Notifier pidRunner = new Notifier(() -> {
- var speed = pidController.calculate(me.getEncoder().getDistance());
- me.getMotor().set(MathUtil.clamp(speed, -0.2, 0.2));
- })) {
+ try (Notifier pidRunner =
+ new Notifier(
+ () -> {
+ var speed = pidController.calculate(me.getEncoder().getDistance());
+ me.getMotor().set(MathUtil.clamp(speed, -0.2, 0.2));
+ })) {
pidRunner.startPeriodic(pidController.getPeriod());
Timer.delay(10.0);
pidRunner.stop();
assertTrue(
"PID loop did not reach reference within 10 seconds. The current error was"
- + pidController.getPositionError(), pidController.atSetpoint());
+ + pidController.getPositionError(),
+ pidController.atSetpoint());
}
}
}
@@ -204,16 +221,20 @@
pidController.setTolerance(200);
pidController.setSetpoint(600);
- try (Notifier pidRunner = new Notifier(() -> {
- var speed = filter.calculate(me.getEncoder().getRate());
- me.getMotor().set(MathUtil.clamp(speed, -0.3, 0.3));
- })) {
+ try (Notifier pidRunner =
+ new Notifier(
+ () -> {
+ var speed = filter.calculate(me.getEncoder().getRate());
+ me.getMotor().set(MathUtil.clamp(speed, -0.3, 0.3));
+ })) {
pidRunner.startPeriodic(pidController.getPeriod());
Timer.delay(10.0);
pidRunner.stop();
- assertTrue("PID loop did not reach reference within 10 seconds. The error was: "
- + pidController.getPositionError(), pidController.atSetpoint());
+ assertTrue(
+ "PID loop did not reach reference within 10 seconds. The error was: "
+ + pidController.getPositionError(),
+ pidController.atSetpoint());
}
}
}
@@ -224,18 +245,18 @@
* @param me The MotorEncoderFixture under test
*/
private void encodersResetCheck(MotorEncoderFixture<?> me) {
- assertEquals(me.getType() + " Encoder value was incorrect after reset.", me.getEncoder().get(),
- 0);
- assertEquals(me.getType() + " Motor value was incorrect after reset.", me.getMotor().get(), 0,
- 0);
- assertEquals(me.getType() + " Counter1 value was incorrect after reset.",
- me.getCounters()[0].get(), 0);
- assertEquals(me.getType() + " Counter2 value was incorrect after reset.",
- me.getCounters()[1].get(), 0);
+ assertEquals(
+ me.getType() + " Encoder value was incorrect after reset.", me.getEncoder().get(), 0);
+ assertEquals(
+ me.getType() + " Motor value was incorrect after reset.", me.getMotor().get(), 0, 0);
+ assertEquals(
+ me.getType() + " Counter1 value was incorrect after reset.", me.getCounters()[0].get(), 0);
+ assertEquals(
+ me.getType() + " Counter2 value was incorrect after reset.", me.getCounters()[1].get(), 0);
Timer.delay(0.5); // so this doesn't fail with the 0.5 second default
// timeout on the encoders
- assertTrue(me.getType() + " Encoder.getStopped() returned false after the motor was reset.",
+ assertTrue(
+ me.getType() + " Encoder.getStopped() returned false after the motor was reset.",
me.getEncoder().getStopped());
}
-
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorInvertingTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorInvertingTest.java
index 5857681..769fa7f 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorInvertingTest.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/MotorInvertingTest.java
@@ -1,16 +1,18 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2016-2018 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import edu.wpi.first.wpilibj.fixtures.MotorEncoderFixture;
+import edu.wpi.first.wpilibj.test.AbstractComsSetup;
+import edu.wpi.first.wpilibj.test.TestBench;
import java.util.Arrays;
import java.util.Collection;
import java.util.logging.Logger;
-
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.Test;
@@ -18,23 +20,13 @@
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
-import edu.wpi.first.wpilibj.fixtures.MotorEncoderFixture;
-import edu.wpi.first.wpilibj.test.AbstractComsSetup;
-import edu.wpi.first.wpilibj.test.TestBench;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Tests Inversion of motors using the SpeedController setInverted.
- */
+/** Tests Inversion of motors using the MotorController setInverted. */
@RunWith(Parameterized.class)
public class MotorInvertingTest extends AbstractComsSetup {
static MotorEncoderFixture<?> fixture = null;
private static final double motorspeed = 0.2;
private static final double delaytime = 0.3;
-
/**
* Constructs the test.
*
@@ -52,8 +44,10 @@
@Parameters(name = "{index}: {0}")
public static Collection<MotorEncoderFixture<?>[]> generateData() {
// logger.fine("Loading the MotorList");
- return Arrays.asList(new MotorEncoderFixture<?>[][]{{TestBench.getInstance().getTalonPair()},
- {TestBench.getInstance().getVictorPair()}, {TestBench.getInstance().getJaguarPair()}});
+ return Arrays.asList(
+ new MotorEncoderFixture<?>[][] {
+ {TestBench.getTalonPair()}, {TestBench.getVictorPair()}, {TestBench.getJaguarPair()}
+ });
}
private static final Logger logger = Logger.getLogger(MotorInvertingTest.class.getName());
@@ -85,8 +79,9 @@
fixture.getMotor().setInverted(true);
fixture.getMotor().set(motorspeed);
Timer.delay(delaytime);
- assertFalse("Inverting with Positive value does not change direction", fixture.getEncoder()
- .getDirection() == initDirection);
+ assertFalse(
+ "Inverting with Positive value does not change direction",
+ fixture.getEncoder().getDirection() == initDirection);
fixture.getMotor().set(0);
}
@@ -99,8 +94,9 @@
fixture.getMotor().setInverted(true);
fixture.getMotor().set(-motorspeed);
Timer.delay(delaytime);
- assertFalse("Inverting with Negative value does not change direction", fixture.getEncoder()
- .getDirection() == initDirection);
+ assertFalse(
+ "Inverting with Negative value does not change direction",
+ fixture.getEncoder().getDirection() == initDirection);
fixture.getMotor().set(0);
}
@@ -113,8 +109,9 @@
fixture.getMotor().setInverted(true);
fixture.getMotor().set(-motorspeed);
Timer.delay(delaytime);
- assertTrue("Inverting with Switching value does change direction", fixture.getEncoder()
- .getDirection() == initDirection);
+ assertTrue(
+ "Inverting with Switching value does change direction",
+ fixture.getEncoder().getDirection() == initDirection);
fixture.getMotor().set(0);
}
@@ -127,8 +124,9 @@
fixture.getMotor().setInverted(true);
fixture.getMotor().set(motorspeed);
Timer.delay(delaytime);
- assertTrue("Inverting with Switching value does change direction", fixture.getEncoder()
- .getDirection() == initDirection);
+ assertTrue(
+ "Inverting with Switching value does change direction",
+ fixture.getEncoder().getDirection() == initDirection);
fixture.getMotor().set(0);
}
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/NotifierTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/NotifierTest.java
new file mode 100644
index 0000000..2f2ca74
--- /dev/null
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/NotifierTest.java
@@ -0,0 +1,56 @@
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
+
+package edu.wpi.first.wpilibj;
+
+import static org.junit.Assert.assertEquals;
+
+import edu.wpi.first.wpilibj.test.AbstractComsSetup;
+import java.util.logging.Logger;
+import org.junit.Test;
+
+/** Tests to see if the Notifier is working properly. */
+public class NotifierTest extends AbstractComsSetup {
+ private static final Logger logger = Logger.getLogger(NotifierTest.class.getName());
+ private static int counter = 0;
+
+ @Override
+ protected Logger getClassLogger() {
+ return logger;
+ }
+
+ @Test
+ public void testStartPeriodicAndStop() {
+ counter = 0;
+ Notifier notifier = new Notifier(() -> ++counter);
+ notifier.startPeriodic(1.0);
+
+ Timer.delay(10.5);
+
+ notifier.stop();
+ assertEquals("Received " + counter + " notifications in 10.5 seconds\n", 10, counter);
+ System.out.println("Received " + counter + " notifications in 10.5 seconds");
+
+ Timer.delay(3.0);
+
+ assertEquals("Received " + (counter - 10) + " notifications in 3 seconds\n", 10, counter);
+ System.out.println("Received " + (counter - 10) + " notifications in 3 seconds");
+
+ notifier.close();
+ }
+
+ @Test
+ public void testStartSingle() {
+ counter = 0;
+ Notifier notifier = new Notifier(() -> ++counter);
+ notifier.startSingle(1.0);
+
+ Timer.delay(10.5);
+
+ assertEquals("Received " + counter + " notifications in 10.5 seconds\n", 1, counter);
+ System.out.println("Received " + counter + " notifications in 10.5 seconds");
+
+ notifier.close();
+ }
+}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PCMTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PCMTest.java
index 2c1eac1..9c44983 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PCMTest.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PCMTest.java
@@ -1,29 +1,21 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2014-2019 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj;
-import java.util.logging.Logger;
-
-import org.junit.AfterClass;
-import org.junit.Before;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-import edu.wpi.first.wpilibj.test.AbstractComsSetup;
-
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
-/**
- * Test that covers the {@link Compressor}.
- */
+import edu.wpi.first.wpilibj.test.AbstractComsSetup;
+import java.util.logging.Logger;
+import org.junit.AfterClass;
+import org.junit.Before;
+import org.junit.BeforeClass;
+import org.junit.Test;
+/** Test that covers the {@link Compressor}. */
public class PCMTest extends AbstractComsSetup {
private static final Logger logger = Logger.getLogger(PCMTest.class.getName());
/*
@@ -42,7 +34,7 @@
protected static final double kCompressorOnVoltage = 5.00;
protected static final double kCompressorOffVoltage = 1.68;
- private static Compressor compressor;
+ private static PneumaticsControlModule pcm;
private static DigitalOutput fakePressureSwitch;
private static AnalogInput fakeCompressor;
@@ -52,7 +44,7 @@
@BeforeClass
public static void setUpBeforeClass() {
- compressor = new Compressor();
+ pcm = new PneumaticsControlModule();
fakePressureSwitch = new DigitalOutput(11);
fakeCompressor = new AnalogInput(1);
@@ -72,41 +64,43 @@
@Before
public void reset() {
- compressor.stop();
+ pcm.setClosedLoopControl(false);
fakePressureSwitch.set(false);
}
- /**
- * Test if the compressor turns on and off when the pressure switch is toggled.
- */
+ /** Test if the compressor turns on and off when the pressure switch is toggled. */
@Test
public void testPressureSwitch() throws Exception {
final double range = 0.5;
reset();
- compressor.setClosedLoopControl(true);
+ pcm.setClosedLoopControl(true);
// Turn on the compressor
fakePressureSwitch.set(true);
Timer.delay(kCompressorDelayTime);
- assertEquals("Compressor did not turn on when the pressure switch turned on.",
- kCompressorOnVoltage, fakeCompressor.getVoltage(), range);
+ assertEquals(
+ "Compressor did not turn on when the pressure switch turned on.",
+ kCompressorOnVoltage,
+ fakeCompressor.getVoltage(),
+ range);
// Turn off the compressor
fakePressureSwitch.set(false);
Timer.delay(kCompressorDelayTime);
- assertEquals("Compressor did not turn off when the pressure switch turned off.",
- kCompressorOffVoltage, fakeCompressor.getVoltage(), range);
+ assertEquals(
+ "Compressor did not turn off when the pressure switch turned off.",
+ kCompressorOffVoltage,
+ fakeCompressor.getVoltage(),
+ range);
}
- /**
- * Test if the correct solenoids turn on and off when they should.
- */
+ /** Test if the correct solenoids turn on and off when they should. */
@Test
public void testSolenoid() throws Exception {
reset();
- Solenoid solenoid1 = new Solenoid(0);
- Solenoid solenoid2 = new Solenoid(1);
+ Solenoid solenoid1 = new Solenoid(PneumaticsModuleType.CTREPCM, 0);
+ Solenoid solenoid2 = new Solenoid(PneumaticsModuleType.CTREPCM, 1);
solenoid1.set(false);
solenoid2.set(false);
@@ -153,7 +147,7 @@
*/
@Test
public void doubleSolenoid() {
- DoubleSolenoid solenoid = new DoubleSolenoid(0, 1);
+ DoubleSolenoid solenoid = new DoubleSolenoid(PneumaticsModuleType.CTREPCM, 0, 1);
solenoid.set(DoubleSolenoid.Value.kOff);
Timer.delay(kSolenoidDelayTime);
@@ -165,28 +159,26 @@
Timer.delay(kSolenoidDelayTime);
assertFalse("Solenoid #1 did not turn on", fakeSolenoid1.get());
assertTrue("Solenoid #2 did not turn off", fakeSolenoid2.get());
- assertTrue("DoubleSolenoid did not report Forward", solenoid.get() == DoubleSolenoid.Value
- .kForward);
+ assertTrue(
+ "DoubleSolenoid did not report Forward", solenoid.get() == DoubleSolenoid.Value.kForward);
solenoid.set(DoubleSolenoid.Value.kReverse);
Timer.delay(kSolenoidDelayTime);
assertTrue("Solenoid #1 did not turn off", fakeSolenoid1.get());
assertFalse("Solenoid #2 did not turn on", fakeSolenoid2.get());
- assertTrue("DoubleSolenoid did not report Reverse", solenoid.get() == DoubleSolenoid.Value
- .kReverse);
+ assertTrue(
+ "DoubleSolenoid did not report Reverse", solenoid.get() == DoubleSolenoid.Value.kReverse);
solenoid.close();
}
- /**
- * Test if the correct solenoids turn on and off when they should.
- */
+ /** Test if the correct solenoids turn on and off when they should. */
@Test
public void testOneShot() throws Exception {
reset();
- Solenoid solenoid1 = new Solenoid(0);
- Solenoid solenoid2 = new Solenoid(1);
+ Solenoid solenoid1 = new Solenoid(PneumaticsModuleType.CTREPCM, 0);
+ Solenoid solenoid2 = new Solenoid(PneumaticsModuleType.CTREPCM, 1);
solenoid1.set(false);
solenoid2.set(false);
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PDPTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PDPTest.java
index b781060..548c2e0 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PDPTest.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PDPTest.java
@@ -1,16 +1,21 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2016-2019 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
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 edu.wpi.first.hal.can.CANMessageNotFoundException;
+import edu.wpi.first.wpilibj.fixtures.MotorEncoderFixture;
+import edu.wpi.first.wpilibj.test.AbstractComsSetup;
+import edu.wpi.first.wpilibj.test.TestBench;
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;
@@ -19,30 +24,18 @@
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
-import edu.wpi.first.hal.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}.
- */
+/** Test that covers the {@link PowerDistribution}. */
@RunWith(Parameterized.class)
public class PDPTest extends AbstractComsSetup {
private static final Logger logger = Logger.getLogger(PDPTest.class.getName());
- private static PowerDistributionPanel pdp;
+ private static PowerDistribution pdp;
private static MotorEncoderFixture<?> me;
private final double m_expectedStoppedCurrentDraw;
@BeforeClass
public static void setUpBeforeClass() {
- pdp = new PowerDistributionPanel();
+ pdp = new PowerDistribution();
}
@AfterClass
@@ -52,8 +45,7 @@
me = null;
}
-
- @SuppressWarnings("JavadocMethod")
+ @SuppressWarnings("MissingJavadocMethod")
public PDPTest(MotorEncoderFixture<?> mef, Double expectedCurrentDraw) {
logger.fine("Constructor with: " + mef.getType());
if (me != null && !me.equals(mef)) {
@@ -68,8 +60,7 @@
@Parameters(name = "{index}: {0}, Expected Stopped Current Draw: {1}")
public static Collection<Object[]> generateData() {
// logger.fine("Loading the MotorList");
- return Arrays.asList(new Object[][]{
- {TestBench.getInstance().getTalonPair(), 0.0}});
+ return Arrays.asList(new Object[][] {{TestBench.getTalonPair(), 0.0}});
}
@After
@@ -77,31 +68,31 @@
me.reset();
}
-
- /**
- * 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 checkStoppedCurrentForMotorController() throws CANMessageNotFoundException {
Timer.delay(0.25);
/* The Current should be 0 */
- assertEquals("The low current was not within the expected range.", m_expectedStoppedCurrentDraw,
- pdp.getCurrent(me.getPDPChannel()), 0.001);
+ 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 checkRunningCurrentForMotorController() throws CANMessageNotFoundException {
/* Set the motor to full forward */
me.getMotor().set(1.0);
Timer.delay(2);
/* 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(m_expectedStoppedCurrentDraw)));
+ assertThat(
+ "The driven current is not greater than the resting current.",
+ pdp.getCurrent(me.getPDPChannel()),
+ is(greaterThan(m_expectedStoppedCurrentDraw)));
}
@Override
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PIDTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PIDTest.java
index 601fff5..c8afb4b 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PIDTest.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PIDTest.java
@@ -1,17 +1,24 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2019 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import edu.wpi.first.math.controller.PIDController;
+import edu.wpi.first.networktables.NetworkTable;
+import edu.wpi.first.networktables.NetworkTableInstance;
+import edu.wpi.first.wpilibj.fixtures.MotorEncoderFixture;
+import edu.wpi.first.wpilibj.smartdashboard.SendableBuilderImpl;
+import edu.wpi.first.wpilibj.test.AbstractComsSetup;
+import edu.wpi.first.wpilibj.test.TestBench;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.logging.Logger;
-
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
@@ -21,23 +28,7 @@
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
-import edu.wpi.first.networktables.NetworkTable;
-import edu.wpi.first.networktables.NetworkTableInstance;
-import edu.wpi.first.wpilibj.controller.PIDController;
-import edu.wpi.first.wpilibj.fixtures.MotorEncoderFixture;
-import edu.wpi.first.wpilibj.smartdashboard.SendableBuilderImpl;
-import edu.wpi.first.wpilibj.test.AbstractComsSetup;
-import edu.wpi.first.wpilibj.test.TestBench;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-
-/**
- * Test that covers the {@link PIDController}.
- */
-
+/** Test that covers the {@link PIDController}. */
@RunWith(Parameterized.class)
public class PIDTest extends AbstractComsSetup {
private static final Logger logger = Logger.getLogger(PIDTest.class.getName());
@@ -58,8 +49,7 @@
return logger;
}
-
- @SuppressWarnings({"ParameterName", "JavadocMethod"})
+ @SuppressWarnings({"ParameterName", "MissingJavadocMethod"})
public PIDTest(Double p, Double i, Double d, MotorEncoderFixture<?> mef) {
logger.fine("Constructor with: " + mef.getType());
if (PIDTest.me != null && !PIDTest.me.equals(mef)) {
@@ -71,7 +61,6 @@
this.k_d = d;
}
-
@Parameters
public static Collection<Object[]> generateData() {
// logger.fine("Loading the MotorList");
@@ -80,16 +69,19 @@
double ki = 0.0005;
double kd = 0.0;
for (int i = 0; i < 1; i++) {
- data.addAll(Arrays.asList(new Object[][]{{kp, ki, kd, TestBench.getInstance().getTalonPair()},
- {kp, ki, kd, TestBench.getInstance().getVictorPair()},
- {kp, ki, kd, TestBench.getInstance().getJaguarPair()}}));
+ data.addAll(
+ Arrays.asList(
+ new Object[][] {
+ {kp, ki, kd, TestBench.getTalonPair()},
+ {kp, ki, kd, TestBench.getVictorPair()},
+ {kp, ki, kd, TestBench.getJaguarPair()}
+ }));
}
return data;
}
@BeforeClass
- public static void setUpBeforeClass() {
- }
+ public static void setUpBeforeClass() {}
@AfterClass
public static void tearDownAfterClass() {
@@ -130,9 +122,12 @@
setupIntegratorRange();
double reference = 2500.0;
m_controller.setSetpoint(reference);
- assertEquals("PID.getPositionError() did not start at " + reference,
- reference, m_controller.getPositionError(), 0);
- m_builder.updateTable();
+ assertEquals(
+ "PID.getPositionError() did not start at " + reference,
+ reference,
+ m_controller.getPositionError(),
+ 0);
+ m_builder.update();
assertEquals(k_p, m_table.getEntry("Kp").getDouble(9999999), 0);
assertEquals(k_i, m_table.getEntry("Ki").getDouble(9999999), 0);
assertEquals(k_d, m_table.getEntry("Kd").getDouble(9999999), 0);
@@ -156,28 +151,38 @@
double reference = 1000.0;
assertEquals(pidData() + "did not start at 0", 0, me.getMotor().get(), 0);
m_controller.setSetpoint(reference);
- assertEquals(pidData() + "did not have an error of " + reference, reference,
- m_controller.getPositionError(), 0);
- Notifier pidRunner = new Notifier(
- () -> me.getMotor().set(m_controller.calculate(me.getEncoder().getDistance())));
+ assertEquals(
+ pidData() + "did not have an error of " + reference,
+ reference,
+ m_controller.getPositionError(),
+ 0);
+ Notifier pidRunner =
+ new Notifier(
+ () -> me.getMotor().set(m_controller.calculate(me.getEncoder().getDistance())));
pidRunner.startPeriodic(m_controller.getPeriod());
Timer.delay(5);
pidRunner.stop();
- assertTrue(pidData() + "Was not on Target. Controller Error: "
- + m_controller.getPositionError(), m_controller.atSetpoint());
+ assertTrue(
+ pidData() + "Was not on Target. Controller Error: " + m_controller.getPositionError(),
+ m_controller.atSetpoint());
pidRunner.close();
}
private String pidData() {
- return me.getType() + " PID {P:" + m_controller.getP() + " I:" + m_controller.getI() + " D:"
- + m_controller.getD() + "} ";
+ return me.getType()
+ + " PID {P:"
+ + m_controller.getP()
+ + " I:"
+ + m_controller.getI()
+ + " D:"
+ + m_controller.getD()
+ + "} ";
}
-
@Test(expected = RuntimeException.class)
public void testOnTargetNoToleranceSet() {
setupIntegratorRange();
- m_controller.atSetpoint();
+ assertFalse(m_controller.atSetpoint());
}
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PriorityTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PriorityTest.java
new file mode 100644
index 0000000..7c3455d
--- /dev/null
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/PriorityTest.java
@@ -0,0 +1,44 @@
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
+
+package edu.wpi.first.wpilibj;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import edu.wpi.first.wpilibj.test.AbstractComsSetup;
+import java.util.logging.Logger;
+import org.junit.Test;
+
+/** Tests to see if the thread and process priority functions work. */
+public class PriorityTest extends AbstractComsSetup {
+ private static final Logger logger = Logger.getLogger(PriorityTest.class.getName());
+
+ @Override
+ protected Logger getClassLogger() {
+ return logger;
+ }
+
+ @Test
+ public void testSetCurrentThreadPriority() {
+ // Non-RT thread has priority of zero
+ assertEquals(0, Threads.getCurrentThreadPriority());
+ assertFalse(Threads.getCurrentThreadIsRealTime());
+
+ // Set thread priority to 15
+ assertTrue(Threads.setCurrentThreadPriority(true, 15));
+
+ // Verify thread was given priority 15
+ assertEquals(15, Threads.getCurrentThreadPriority());
+ assertTrue(Threads.getCurrentThreadIsRealTime());
+
+ // Set thread back to non-RT
+ assertTrue(Threads.setCurrentThreadPriority(false, 0));
+
+ // Verify thread is now non-RT
+ assertEquals(0, Threads.getCurrentThreadPriority());
+ assertFalse(Threads.getCurrentThreadIsRealTime());
+ }
+}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/RelayCrossConnectTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/RelayCrossConnectTest.java
index 29fad5f..cc520c3 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/RelayCrossConnectTest.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/RelayCrossConnectTest.java
@@ -1,17 +1,12 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2019 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj;
-import java.util.logging.Logger;
-
-import org.junit.After;
-import org.junit.Before;
-import org.junit.Test;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
import edu.wpi.first.networktables.NetworkTable;
import edu.wpi.first.networktables.NetworkTableInstance;
@@ -22,14 +17,12 @@
import edu.wpi.first.wpilibj.smartdashboard.SendableBuilderImpl;
import edu.wpi.first.wpilibj.test.AbstractComsSetup;
import edu.wpi.first.wpilibj.test.TestBench;
+import java.util.logging.Logger;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertTrue;
-
-/**
- * Tests the {@link RelayCrossConnectFixture}.
- */
+/** Tests the {@link RelayCrossConnectFixture}. */
public class RelayCrossConnectTest extends AbstractComsSetup {
private static final Logger logger = Logger.getLogger(RelayCrossConnectTest.class.getName());
private static final NetworkTable table =
@@ -37,7 +30,6 @@
private RelayCrossConnectFixture m_relayFixture;
private SendableBuilderImpl m_builder;
-
@Before
public void setUp() {
m_relayFixture = TestBench.getRelayCrossConnectFixture();
@@ -57,11 +49,11 @@
public void testBothHigh() {
m_relayFixture.getRelay().setDirection(Direction.kBoth);
m_relayFixture.getRelay().set(Value.kOn);
- m_builder.updateTable();
- assertTrue("Input one was not high when relay set both high", m_relayFixture.getInputOne()
- .get());
- assertTrue("Input two was not high when relay set both high", m_relayFixture.getInputTwo()
- .get());
+ m_builder.update();
+ assertTrue(
+ "Input one was not high when relay set both high", m_relayFixture.getInputOne().get());
+ assertTrue(
+ "Input two was not high when relay set both high", m_relayFixture.getInputTwo().get());
assertEquals(Value.kOn, m_relayFixture.getRelay().get());
assertEquals("On", table.getEntry("Value").getString(""));
}
@@ -70,12 +62,11 @@
public void testFirstHigh() {
m_relayFixture.getRelay().setDirection(Direction.kBoth);
m_relayFixture.getRelay().set(Value.kForward);
- m_builder.updateTable();
- assertFalse("Input one was not low when relay set Value.kForward", m_relayFixture.getInputOne()
- .get());
- assertTrue("Input two was not high when relay set Value.kForward", m_relayFixture
- .getInputTwo()
- .get());
+ m_builder.update();
+ assertFalse(
+ "Input one was not low when relay set Value.kForward", m_relayFixture.getInputOne().get());
+ assertTrue(
+ "Input two was not high when relay set Value.kForward", m_relayFixture.getInputTwo().get());
assertEquals(Value.kForward, m_relayFixture.getRelay().get());
assertEquals("Forward", table.getEntry("Value").getString(""));
}
@@ -84,12 +75,11 @@
public void testSecondHigh() {
m_relayFixture.getRelay().setDirection(Direction.kBoth);
m_relayFixture.getRelay().set(Value.kReverse);
- m_builder.updateTable();
- assertTrue("Input one was not high when relay set Value.kReverse", m_relayFixture.getInputOne()
- .get());
- assertFalse("Input two was not low when relay set Value.kReverse", m_relayFixture
- .getInputTwo()
- .get());
+ m_builder.update();
+ assertTrue(
+ "Input one was not high when relay set Value.kReverse", m_relayFixture.getInputOne().get());
+ assertFalse(
+ "Input two was not low when relay set Value.kReverse", m_relayFixture.getInputTwo().get());
assertEquals(Value.kReverse, m_relayFixture.getRelay().get());
assertEquals("Reverse", table.getEntry("Value").getString(""));
}
@@ -98,10 +88,12 @@
public void testForwardDirection() {
m_relayFixture.getRelay().setDirection(Direction.kForward);
m_relayFixture.getRelay().set(Value.kOn);
- m_builder.updateTable();
- assertFalse("Input one was not low when relay set Value.kOn in kForward Direction",
+ m_builder.update();
+ assertFalse(
+ "Input one was not low when relay set Value.kOn in kForward Direction",
m_relayFixture.getInputOne().get());
- assertTrue("Input two was not high when relay set Value.kOn in kForward Direction",
+ assertTrue(
+ "Input two was not high when relay set Value.kOn in kForward Direction",
m_relayFixture.getInputTwo().get());
assertEquals(Value.kOn, m_relayFixture.getRelay().get());
assertEquals("On", table.getEntry("Value").getString(""));
@@ -111,10 +103,12 @@
public void testReverseDirection() {
m_relayFixture.getRelay().setDirection(Direction.kReverse);
m_relayFixture.getRelay().set(Value.kOn);
- m_builder.updateTable();
- assertTrue("Input one was not high when relay set Value.kOn in kReverse Direction",
+ m_builder.update();
+ assertTrue(
+ "Input one was not high when relay set Value.kOn in kReverse Direction",
m_relayFixture.getInputOne().get());
- assertFalse("Input two was not low when relay set Value.kOn in kReverse Direction",
+ assertFalse(
+ "Input two was not low when relay set Value.kOn in kReverse Direction",
m_relayFixture.getInputTwo().get());
assertEquals(Value.kOn, m_relayFixture.getRelay().get());
assertEquals("On", table.getEntry("Value").getString(""));
@@ -134,7 +128,7 @@
@Test
public void testInitialSettings() {
- m_builder.updateTable();
+ m_builder.update();
assertEquals(Value.kOff, m_relayFixture.getRelay().get());
// Initially both outputs should be off
assertFalse(m_relayFixture.getInputOne().get());
@@ -146,5 +140,4 @@
protected Logger getClassLogger() {
return logger;
}
-
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/SampleTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/SampleTest.java
index efcea23..bb0fcc9 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/SampleTest.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/SampleTest.java
@@ -1,24 +1,19 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2018 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj;
-import java.util.logging.Logger;
+import static org.junit.Assert.assertTrue;
+import edu.wpi.first.wpilibj.fixtures.SampleFixture;
+import edu.wpi.first.wpilibj.test.AbstractComsSetup;
+import java.util.logging.Logger;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
-import edu.wpi.first.wpilibj.fixtures.SampleFixture;
-import edu.wpi.first.wpilibj.test.AbstractComsSetup;
-
-import static org.junit.Assert.assertTrue;
-
/**
* Sample test for a sample PID controller. This demonstrates the general pattern of how to create a
* test and use testing fixtures and categories. All tests must extend from {@link
@@ -62,5 +57,4 @@
Timer.delay(0.5);
assertTrue(true);
}
-
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/TimerTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/TimerTest.java
index 2acd5bb..8d0fc95 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/TimerTest.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/TimerTest.java
@@ -1,20 +1,14 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2018 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj;
-import java.util.logging.Logger;
-
-import org.junit.Test;
-
-import edu.wpi.first.wpilibj.test.AbstractComsSetup;
-
import static org.junit.Assert.assertEquals;
+import edu.wpi.first.wpilibj.test.AbstractComsSetup;
+import java.util.logging.Logger;
+import org.junit.Test;
public class TimerTest extends AbstractComsSetup {
private static final Logger logger = Logger.getLogger(TimerTest.class.getName());
@@ -38,8 +32,10 @@
// Then
long offset = difference - TIMER_RUNTIME;
- assertEquals("Timer.delay ran " + offset + " microseconds too long", TIMER_RUNTIME, difference,
+ assertEquals(
+ "Timer.delay ran " + offset + " microseconds too long",
+ TIMER_RUNTIME,
+ difference,
TIMER_TOLERANCE);
}
-
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/WpiLibJTestSuite.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/WpiLibJTestSuite.java
index 9ab6850..e7d968f 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/WpiLibJTestSuite.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/WpiLibJTestSuite.java
@@ -1,28 +1,38 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2019 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj;
+import edu.wpi.first.wpilibj.test.AbstractTestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
-import edu.wpi.first.wpilibj.test.AbstractTestSuite;
-
/**
* Holds all of the tests in the root wpilibj directory. Please list alphabetically so that it is
* easy to determine if a test is missing from the list.
*/
@RunWith(Suite.class)
-@SuiteClasses({AnalogCrossConnectTest.class, AnalogPotentiometerTest.class,
- BuiltInAccelerometerTest.class, ConstantsPortsTest.class, CounterTest.class,
- DigitalGlitchFilterTest.class, DIOCrossConnectTest.class,
- DriverStationTest.class, EncoderTest.class, GyroTest.class, MotorEncoderTest.class,
- MotorInvertingTest.class, PCMTest.class, PDPTest.class, PIDTest.class,
- RelayCrossConnectTest.class, SampleTest.class, TimerTest.class})
-public class WpiLibJTestSuite extends AbstractTestSuite {
-}
+@SuiteClasses({
+ AnalogCrossConnectTest.class,
+ AnalogPotentiometerTest.class,
+ BuiltInAccelerometerTest.class,
+ ConstantsPortsTest.class,
+ CounterTest.class,
+ DigitalGlitchFilterTest.class,
+ DIOCrossConnectTest.class,
+ DMATest.class,
+ DriverStationTest.class,
+ EncoderTest.class,
+ GyroTest.class,
+ MotorEncoderTest.class,
+ MotorInvertingTest.class,
+ PCMTest.class,
+ PDPTest.class,
+ PIDTest.class,
+ RelayCrossConnectTest.class,
+ SampleTest.class,
+ TimerTest.class
+})
+public class WpiLibJTestSuite extends AbstractTestSuite {}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/can/CANStatusTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/can/CANStatusTest.java
index 6aa6c8e..d5c11e3 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/can/CANStatusTest.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/can/CANStatusTest.java
@@ -1,22 +1,18 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2017-2018 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj.can;
-import org.junit.Test;
-
import edu.wpi.first.hal.can.CANJNI;
import edu.wpi.first.hal.can.CANStatus;
+import org.junit.Test;
public class CANStatusTest {
@Test
public void canStatusGetDoesntThrow() {
CANStatus status = new CANStatus();
- CANJNI.GetCANStatus(status);
+ CANJNI.getCANStatus(status);
// Nothing we can assert, so just make sure it didn't throw.
}
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/AnalogCrossConnectFixture.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/AnalogCrossConnectFixture.java
index ece1dc9..1dd63da 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/AnalogCrossConnectFixture.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/AnalogCrossConnectFixture.java
@@ -1,18 +1,13 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2018 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj.fixtures;
import edu.wpi.first.wpilibj.AnalogInput;
import edu.wpi.first.wpilibj.AnalogOutput;
-/**
- * A fixture that connects an {@link AnalogInput} and an {@link AnalogOutput}.
- */
+/** A fixture that connects an {@link AnalogInput} and an {@link AnalogOutput}. */
public abstract class AnalogCrossConnectFixture implements ITestFixture {
private boolean m_initialized = false;
@@ -23,7 +18,6 @@
protected abstract AnalogOutput giveAnalogOutput();
-
private void initialize() {
synchronized (this) {
if (!m_initialized) {
@@ -40,10 +34,9 @@
* @see edu.wpi.first.wpilibj.fixtures.ITestFixture#setup()
*/
@Override
- public boolean setup() {
+ public void setup() {
initialize();
m_output.setVoltage(0);
- return true;
}
/*
@@ -52,9 +45,8 @@
* @see edu.wpi.first.wpilibj.fixtures.ITestFixture#reset()
*/
@Override
- public boolean reset() {
+ public void reset() {
initialize();
- return true;
}
/*
@@ -63,15 +55,12 @@
* @see edu.wpi.first.wpilibj.fixtures.ITestFixture#teardown()
*/
@Override
- public boolean teardown() {
+ public void teardown() {
m_input.close();
m_output.close();
- return true;
}
- /**
- * Analog Output.
- */
+ /** Analog Output. */
public final AnalogOutput getOutput() {
initialize();
return m_output;
@@ -81,6 +70,4 @@
initialize();
return m_input;
}
-
-
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/DIOCrossConnectFixture.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/DIOCrossConnectFixture.java
index fa17baa..78880d8 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/DIOCrossConnectFixture.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/DIOCrossConnectFixture.java
@@ -1,21 +1,15 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2020 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj.fixtures;
+import edu.wpi.first.wpilibj.DigitalInput;
+import edu.wpi.first.wpilibj.DigitalOutput;
import java.util.logging.Level;
import java.util.logging.Logger;
-import edu.wpi.first.wpilibj.DigitalInput;
-import edu.wpi.first.wpilibj.DigitalOutput;
-
-/**
- * Connects a digital input to a digital output.
- */
+/** Connects a digital input to a digital output. */
public class DIOCrossConnectFixture implements ITestFixture {
private static final Logger logger = Logger.getLogger(DIOCrossConnectFixture.class.getName());
@@ -26,7 +20,7 @@
/**
* Constructs using two pre-allocated digital objects.
*
- * @param input The input
+ * @param input The input
* @param output The output.
*/
public DIOCrossConnectFixture(DigitalInput input, DigitalOutput output) {
@@ -40,7 +34,7 @@
/**
* Constructs a {@link DIOCrossConnectFixture} using the ports of the digital objects.
*
- * @param input The port of the {@link DigitalInput}
+ * @param input The port of the {@link DigitalInput}
* @param output The port of the {@link DigitalOutput}
*/
public DIOCrossConnectFixture(Integer input, Integer output) {
@@ -61,30 +55,20 @@
}
@Override
- public boolean setup() {
- return true;
- }
+ public void setup() {}
@Override
- public boolean reset() {
- try {
- m_input.cancelInterrupts();
- } catch (IllegalStateException ex) {
- // This will happen if the interrupt has not been allocated for this test.
- }
+ public void reset() {
m_output.set(false);
- return true;
}
@Override
- public boolean teardown() {
+ public void teardown() {
logger.log(Level.FINE, "Beginning teardown");
if (m_allocated) {
m_input.close();
m_output.close();
m_allocated = false;
}
- return true;
}
-
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/FakeCounterFixture.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/FakeCounterFixture.java
index 8dbb4d3..38fbbfc 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/FakeCounterFixture.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/FakeCounterFixture.java
@@ -1,21 +1,15 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2020 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj.fixtures;
+import edu.wpi.first.wpilibj.Counter;
+import edu.wpi.first.wpilibj.mockhardware.FakeCounterSource;
import java.util.logging.Level;
import java.util.logging.Logger;
-import edu.wpi.first.wpilibj.Counter;
-import edu.wpi.first.wpilibj.mockhardware.FakeCounterSource;
-
-/**
- * A fixture that can test the {@link Counter} using a {@link DIOCrossConnectFixture}.
- */
+/** A fixture that can test the {@link Counter} using a {@link DIOCrossConnectFixture}. */
public class FakeCounterFixture implements ITestFixture {
private static final Logger logger = Logger.getLogger(FakeEncoderFixture.class.getName());
@@ -36,11 +30,10 @@
m_counter = new Counter(dio.getInput());
}
-
/**
* Constructs a FakeCounterFixture using two port numbers.
*
- * @param input the input port
+ * @param input the input port
* @param output the output port
*/
public FakeCounterFixture(int input, int output) {
@@ -68,17 +61,13 @@
return m_counter;
}
-
/*
* (non-Javadoc)
*
* @see edu.wpi.first.wpilibj.fixtures.ITestFixture#setup()
*/
@Override
- public boolean setup() {
- return true;
-
- }
+ public void setup() {}
/*
* (non-Javadoc)
@@ -86,9 +75,8 @@
* @see edu.wpi.first.wpilibj.fixtures.ITestFixture#reset()
*/
@Override
- public boolean reset() {
+ public void reset() {
m_counter.reset();
- return true;
}
/*
@@ -97,7 +85,7 @@
* @see edu.wpi.first.wpilibj.fixtures.ITestFixture#teardown()
*/
@Override
- public boolean teardown() {
+ public void teardown() {
logger.log(Level.FINE, "Beginning teardown");
m_counter.close();
m_source.close();
@@ -105,8 +93,5 @@
m_dio.teardown();
m_allocated = false;
}
- return true;
}
-
-
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/FakeEncoderFixture.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/FakeEncoderFixture.java
index ef9da0e..480185e 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/FakeEncoderFixture.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/FakeEncoderFixture.java
@@ -1,16 +1,12 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2020 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj.fixtures;
-import java.util.logging.Logger;
-
import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.mockhardware.FakeEncoderSource;
+import java.util.logging.Logger;
/**
* An encoder that uses two {@link DIOCrossConnectFixture DIOCrossConnectFixtures} to test the
@@ -28,9 +24,7 @@
private final Encoder m_encoder;
private int[] m_encoderPort = new int[2];
- /**
- * Constructs a FakeEncoderFixture from two DIOCrossConnectFixture.
- */
+ /** Constructs a FakeEncoderFixture from two DIOCrossConnectFixture. */
public FakeEncoderFixture(DIOCrossConnectFixture dio1, DIOCrossConnectFixture dio2) {
assert dio1 != null;
assert dio2 != null;
@@ -41,9 +35,7 @@
m_encoder = new Encoder(dio1.getInput(), dio2.getInput());
}
- /**
- * Construcst a FakeEncoderFixture from a set of Digital I/O ports.
- */
+ /** Construcst a FakeEncoderFixture from a set of Digital I/O ports. */
public FakeEncoderFixture(int inputA, int outputA, int inputB, int outputB) {
assert outputA != outputB;
assert outputA != inputA;
@@ -76,9 +68,7 @@
* @see edu.wpi.first.wpilibj.fixtures.ITestFixture#setup()
*/
@Override
- public boolean setup() {
- return true;
- }
+ public void setup() {}
/*
* (non-Javadoc)
@@ -86,11 +76,10 @@
* @see edu.wpi.first.wpilibj.fixtures.ITestFixture#reset()
*/
@Override
- public boolean reset() {
+ public void reset() {
m_dio1.reset();
m_dio2.reset();
m_encoder.reset();
- return true;
}
/*
@@ -99,7 +88,7 @@
* @see edu.wpi.first.wpilibj.fixtures.ITestFixture#teardown()
*/
@Override
- public boolean teardown() {
+ public void teardown() {
logger.fine("Beginning teardown");
m_source.close();
logger.finer("Source freed " + m_sourcePort[0] + ", " + m_sourcePort[1]);
@@ -109,8 +98,5 @@
m_dio1.teardown();
m_dio2.teardown();
}
- return true;
}
-
-
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/ITestFixture.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/ITestFixture.java
index 3465915..527606e 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/ITestFixture.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/ITestFixture.java
@@ -1,9 +1,6 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2020 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj.fixtures;
@@ -21,10 +18,8 @@
/**
* Performs any required setup for this fixture, ensuring that all fixture elements are ready for
* testing.
- *
- * @return True if the fixture is ready for testing
*/
- boolean setup();
+ void setup();
/**
* Resets the fixture back to test start state. This should be called by the test class in the
@@ -32,16 +27,12 @@
* ITestFixture#setup()} as that is called once, before the class is constructed, so it may need
* to start sensors. This method should not have to start anything, just reset sensors and ensure
* that motors are stopped.
- *
- * @return True if the fixture is ready for testing
*/
- boolean reset();
+ void reset();
/**
* Performs any required teardown after use of the fixture, ensuring that future tests will not
* run into conflicts.
- *
- * @return True if the teardown succeeded
*/
- boolean teardown();
+ void teardown();
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/MotorEncoderFixture.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/MotorEncoderFixture.java
index fab3306..220db18 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/MotorEncoderFixture.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/MotorEncoderFixture.java
@@ -1,31 +1,28 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2018 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj.fixtures;
-import java.lang.reflect.ParameterizedType;
-import java.util.logging.Logger;
-
import edu.wpi.first.wpilibj.Counter;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.Encoder;
import edu.wpi.first.wpilibj.PWM;
-import edu.wpi.first.wpilibj.SpeedController;
import edu.wpi.first.wpilibj.Timer;
+import edu.wpi.first.wpilibj.motorcontrol.MotorController;
import edu.wpi.first.wpilibj.test.TestBench;
+import java.lang.reflect.ParameterizedType;
+import java.util.logging.Logger;
/**
* Represents a physically connected Motor and Encoder to allow for unit tests on these different
- * pairs<br> Designed to allow the user to easily setup and tear down the fixture to allow for
- * reuse. This class should be explicitly instantiated in the TestBed class to allow any test to
- * access this fixture. This allows tests to be mailable so that you can easily reconfigure the
- * physical testbed without breaking the tests.
+ * pairs<br>
+ * Designed to allow the user to easily setup and tear down the fixture to allow for reuse. This
+ * class should be explicitly instantiated in the TestBed class to allow any test to access this
+ * fixture. This allows tests to be mailable so that you can easily reconfigure the physical testbed
+ * without breaking the tests.
*/
-public abstract class MotorEncoderFixture<T extends SpeedController> implements ITestFixture {
+public abstract class MotorEncoderFixture<T extends MotorController> implements ITestFixture {
private static final Logger logger = Logger.getLogger(MotorEncoderFixture.class.getName());
private boolean m_initialized = false;
private boolean m_tornDown = false;
@@ -35,22 +32,19 @@
protected DigitalInput m_alphaSource; // Stored so it can be freed at tear down
protected DigitalInput m_betaSource;
- /**
- * Default constructor for a MotorEncoderFixture.
- */
- public MotorEncoderFixture() {
- }
+ /** Default constructor for a MotorEncoderFixture. */
+ public MotorEncoderFixture() {}
public abstract int getPDPChannel();
/**
* Where the implementer of this class should pass the speed controller Constructor should only be
- * called from outside this class if the Speed controller is not also an implementation of PWM
+ * called from outside this class if the Motor controller is not also an implementation of PWM
* interface.
*
- * @return SpeedController
+ * @return MotorController
*/
- protected abstract T giveSpeedController();
+ protected abstract T giveMotorController();
/**
* Where the implementer of this class should pass one of the digital inputs.
@@ -78,20 +72,18 @@
m_alphaSource = giveDigitalInputA();
m_betaSource = giveDigitalInputB();
-
m_encoder = new Encoder(m_alphaSource, m_betaSource);
m_counters[0] = new Counter(m_alphaSource);
m_counters[1] = new Counter(m_betaSource);
logger.fine("Creating the speed controller!");
- m_motor = giveSpeedController();
+ m_motor = giveMotorController();
}
}
}
@Override
- public boolean setup() {
+ public void setup() {
initialize();
- return true;
}
/**
@@ -133,7 +125,7 @@
* Checks to see if the speed of the motor is within some range of a given value. This is used
* instead of equals() because doubles can have inaccuracies.
*
- * @param value The value to compare against
+ * @param value The value to compare against
* @param accuracy The accuracy range to check against to see if the
* @return true if the range of values between motors speed accuracy contains the 'value'.
*/
@@ -143,7 +135,7 @@
}
@Override
- public boolean reset() {
+ public void reset() {
initialize();
m_motor.setInverted(false);
m_motor.set(0);
@@ -152,18 +144,8 @@
for (Counter c : m_counters) {
c.reset();
}
-
- boolean wasReset = true;
- wasReset = wasReset && m_motor.get() == 0;
- wasReset = wasReset && m_encoder.get() == 0;
- for (Counter c : m_counters) {
- wasReset = wasReset && c.get() == 0;
- }
-
- return wasReset;
}
-
/**
* Safely tears down the MotorEncoder Fixture in a way that makes sure that even if an object
* fails to initialize the rest of the fixture can still be torn down and the resources
@@ -171,62 +153,37 @@
*/
@Override
@SuppressWarnings("Regexp")
- public boolean teardown() {
- String type;
- if (m_motor != null) {
- type = getType();
- } else {
- type = "null";
- }
+ public void teardown() {
if (!m_tornDown) {
- boolean wasNull = false;
- if (m_motor instanceof PWM && m_motor != null) {
- ((PWM) m_motor).close();
+ if (m_motor != null) {
+ if (m_motor instanceof PWM) {
+ ((PWM) m_motor).close();
+ }
m_motor = null;
- } else if (m_motor == null) {
- wasNull = true;
}
if (m_encoder != null) {
m_encoder.close();
m_encoder = null;
- } else {
- wasNull = true;
}
if (m_counters[0] != null) {
m_counters[0].close();
m_counters[0] = null;
- } else {
- wasNull = true;
}
if (m_counters[1] != null) {
m_counters[1].close();
m_counters[1] = null;
- } else {
- wasNull = true;
}
if (m_alphaSource != null) {
m_alphaSource.close();
m_alphaSource = null;
- } else {
- wasNull = true;
}
if (m_betaSource != null) {
m_betaSource.close();
m_betaSource = null;
- } else {
- wasNull = true;
}
m_tornDown = true;
-
- if (wasNull) {
- throw new NullPointerException("MotorEncoderFixture had null params at teardown");
- }
- } else {
- throw new RuntimeException(type + " Motor Encoder torn down multiple times");
}
-
- return true;
}
@Override
@@ -235,11 +192,10 @@
// Get the generic type as a class
@SuppressWarnings("unchecked")
Class<T> class1 =
- (Class<T>) ((ParameterizedType) getClass().getGenericSuperclass())
- .getActualTypeArguments()[0];
+ (Class<T>)
+ ((ParameterizedType) getClass().getGenericSuperclass()).getActualTypeArguments()[0];
string.append(class1.getSimpleName());
string.append(">");
return string.toString();
}
-
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/RelayCrossConnectFixture.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/RelayCrossConnectFixture.java
index 382b4bb..3076caf 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/RelayCrossConnectFixture.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/RelayCrossConnectFixture.java
@@ -1,18 +1,13 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2018 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj.fixtures;
import edu.wpi.first.wpilibj.DigitalInput;
import edu.wpi.first.wpilibj.Relay;
-/**
- * A connection between a {@link Relay} and two {@link DigitalInput DigitalInputs}.
- */
+/** A connection between a {@link Relay} and two {@link DigitalInput DigitalInputs}. */
public abstract class RelayCrossConnectFixture implements ITestFixture {
private DigitalInput m_inputOne;
private DigitalInput m_inputTwo;
@@ -21,7 +16,6 @@
private boolean m_initialized = false;
private boolean m_freed = false;
-
protected abstract Relay giveRelay();
protected abstract DigitalInput giveInputOne();
@@ -60,9 +54,8 @@
* @see edu.wpi.first.wpilibj.fixtures.ITestFixture#setup()
*/
@Override
- public boolean setup() {
+ public void setup() {
initialize();
- return true;
}
/*
@@ -71,9 +64,8 @@
* @see edu.wpi.first.wpilibj.fixtures.ITestFixture#reset()
*/
@Override
- public boolean reset() {
+ public void reset() {
initialize();
- return true;
}
/*
@@ -82,16 +74,17 @@
* @see edu.wpi.first.wpilibj.fixtures.ITestFixture#teardown()
*/
@Override
- public boolean teardown() {
+ public void teardown() {
if (!m_freed) {
m_relay.close();
m_inputOne.close();
m_inputTwo.close();
m_freed = true;
} else {
- throw new RuntimeException("You attempted to free the "
- + RelayCrossConnectFixture.class.getSimpleName() + " multiple times");
+ throw new RuntimeException(
+ "You attempted to free the "
+ + RelayCrossConnectFixture.class.getSimpleName()
+ + " multiple times");
}
- return true;
}
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/SampleFixture.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/SampleFixture.java
index 994c6ee..38ea638 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/SampleFixture.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/SampleFixture.java
@@ -1,48 +1,41 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2018 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj.fixtures;
-
/**
* This is an example of how to use the {@link ITestFixture} interface to create test fixtures for a
* test.
*/
public class SampleFixture implements ITestFixture {
@Override
- public boolean setup() {
+ public void setup() {
/*
* If this fixture actually accessed the hardware, here is where it would
* set up the starting state of the test bench. For example, reseting
* encoders, ensuring motors are stopped, reseting any serial communication
* if necessary, etc.
*/
- return true;
}
@Override
- public boolean reset() {
+ public void reset() {
/*
* This is where the fixture would reset any sensors or motors used by the
* fixture to test default state. This method should not worry about whether
* or not the sensors have been allocated correctly, that is the job of the
* setup function.
*/
- return false;
}
@Override
- public boolean teardown() {
+ public void teardown() {
/*
* This is where the fixture would deallocate and reset back to normal
* conditions any necessary hardware. This includes ensuring motors are
* stopped, stoppable sensors are actually stopped, ensuring serial
* communications are ready for the next test, etc.
*/
- return true;
}
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/TiltPanCameraFixture.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/TiltPanCameraFixture.java
index afeaf38..f41687d 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/TiltPanCameraFixture.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/fixtures/TiltPanCameraFixture.java
@@ -1,17 +1,13 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2018 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj.fixtures;
-import java.util.logging.Logger;
-
import edu.wpi.first.wpilibj.AnalogGyro;
import edu.wpi.first.wpilibj.Servo;
import edu.wpi.first.wpilibj.Timer;
+import java.util.logging.Logger;
/**
* A class to represent the a physical Camera with two servos (tilt and pan) designed to test to see
@@ -27,7 +23,6 @@
private Servo m_pan;
private boolean m_initialized = false;
-
protected abstract AnalogGyro giveGyro();
protected abstract AnalogGyro giveGyroParam(int center, double offset);
@@ -36,15 +31,11 @@
protected abstract Servo givePan();
- /**
- * Constructs the TiltPanCamera.
- */
- public TiltPanCameraFixture() {
- }
+ /** Constructs the TiltPanCamera. */
+ public TiltPanCameraFixture() {}
@Override
- public boolean setup() {
- boolean wasSetup = false;
+ public void setup() {
if (!m_initialized) {
m_initialized = true;
m_tilt = giveTilt();
@@ -56,17 +47,14 @@
logger.fine("Initializing the gyro");
m_gyro = giveGyro();
m_gyro.reset();
- wasSetup = true;
}
- return wasSetup;
}
@Override
- public boolean reset() {
+ public void reset() {
if (m_gyro != null) {
m_gyro.reset();
}
- return true;
}
public Servo getTilt() {
@@ -97,20 +85,18 @@
}
@Override
- public boolean teardown() {
+ public void teardown() {
m_tilt.close();
m_tilt = null;
m_pan.close();
m_pan = null;
- if (m_gyro != null) { //in case not freed during gyro tests
+ if (m_gyro != null) { // in case not freed during gyro tests
m_gyro.close();
m_gyro = null;
}
- if (m_gyroParam != null) { //in case gyro tests failed before getting to this point
+ if (m_gyroParam != null) { // in case gyro tests failed before getting to this point
m_gyroParam.close();
m_gyroParam = null;
}
- return true;
}
-
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/mockhardware/FakeCounterSource.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/mockhardware/FakeCounterSource.java
index d67fbdb..ac1094c 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/mockhardware/FakeCounterSource.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/mockhardware/FakeCounterSource.java
@@ -1,18 +1,13 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2014-2019 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj.mockhardware;
import edu.wpi.first.wpilibj.DigitalOutput;
import edu.wpi.first.wpilibj.Timer;
-/**
- * Simulates an encoder for testing purposes.
- */
+/** Simulates an encoder for testing purposes. */
public class FakeCounterSource implements AutoCloseable {
private Thread m_task;
private int m_count;
@@ -20,10 +15,8 @@
private DigitalOutput m_output;
private boolean m_allocated;
- /**
- * Thread object that allows emulation of an encoder.
- */
- private class EncoderThread extends Thread {
+ /** Thread object that allows emulation of an encoder. */
+ private static class EncoderThread extends Thread {
FakeCounterSource m_encoder;
EncoderThread(FakeCounterSource encode) {
@@ -68,9 +61,7 @@
initEncoder();
}
- /**
- * Destroy Object with minimum memory leak.
- */
+ /** Destroy Object with minimum memory leak. */
@Override
public void close() {
m_task = null;
@@ -81,25 +72,19 @@
}
}
- /**
- * Common initailization code.
- */
+ /** Common initailization code. */
private void initEncoder() {
m_milliSec = 1;
m_task = new EncoderThread(this);
m_output.set(false);
}
- /**
- * Starts the thread execution task.
- */
+ /** Starts the thread execution task. */
public void start() {
m_task.start();
}
- /**
- * Waits for the thread to complete.
- */
+ /** Waits for the thread to complete. */
public void complete() {
try {
m_task.join();
@@ -110,9 +95,7 @@
Timer.delay(0.01);
}
- /**
- * Starts and completes a task set - does not return until thred has finished its operations.
- */
+ /** Starts and completes a task set - does not return until thred has finished its operations. */
public void execute() {
start();
complete();
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/mockhardware/FakeEncoderSource.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/mockhardware/FakeEncoderSource.java
index efc69a5..5b91b0c 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/mockhardware/FakeEncoderSource.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/mockhardware/FakeEncoderSource.java
@@ -1,18 +1,13 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2014-2019 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj.mockhardware;
import edu.wpi.first.wpilibj.DigitalOutput;
import edu.wpi.first.wpilibj.Timer;
-/**
- * Emulates a quadrature encoder.
- */
+/** Emulates a quadrature encoder. */
public class FakeEncoderSource implements AutoCloseable {
private Thread m_task;
private int m_count;
@@ -22,10 +17,8 @@
private final DigitalOutput m_outputB;
private final boolean m_allocatedOutputs;
- /**
- * Thread object that allows emulation of a quadrature encoder.
- */
- private class QuadEncoderThread extends Thread {
+ /** Thread object that allows emulation of a quadrature encoder. */
+ private static class QuadEncoderThread extends Thread {
FakeEncoderSource m_encoder;
QuadEncoderThread(FakeEncoderSource encode) {
@@ -91,9 +84,7 @@
initQuadEncoder();
}
- /**
- * Frees the resource.
- */
+ /** Frees the resource. */
@Override
public void close() {
m_task = null;
@@ -103,9 +94,7 @@
}
}
- /**
- * Common initialization code.
- */
+ /** Common initialization code. */
private void initQuadEncoder() {
m_milliSec = 1;
m_forward = true;
@@ -114,16 +103,12 @@
m_outputB.set(false);
}
- /**
- * Starts the thread.
- */
+ /** Starts the thread. */
public void start() {
m_task.start();
}
- /**
- * Waits for thread to end.
- */
+ /** Waits for thread to end. */
public void complete() {
try {
m_task.join();
@@ -134,9 +119,7 @@
Timer.delay(0.01);
}
- /**
- * Runs and waits for thread to end before returning.
- */
+ /** Runs and waits for thread to end before returning. */
public void execute() {
start();
complete();
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/mockhardware/FakePotentiometerSource.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/mockhardware/FakePotentiometerSource.java
index 63af674..59cc5c7 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/mockhardware/FakePotentiometerSource.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/mockhardware/FakePotentiometerSource.java
@@ -1,17 +1,12 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2018 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj.mockhardware;
import edu.wpi.first.wpilibj.AnalogOutput;
-/**
- * A fake source to provide output to a {@link edu.wpi.first.wpilibj.interfaces.Potentiometer}.
- */
+/** A fake source to provide output to a {@link edu.wpi.first.wpilibj.interfaces.Potentiometer}. */
public class FakePotentiometerSource implements AutoCloseable {
private AnalogOutput m_output;
private boolean m_initOutput;
@@ -22,7 +17,7 @@
/**
* Constructs the fake source.
*
- * @param output The analog port to output the signal on
+ * @param output The analog port to output the signal on
* @param defaultPotMaxAngle The default maximum angle the pot supports.
*/
public FakePotentiometerSource(AnalogOutput output, double defaultPotMaxAngle) {
@@ -80,9 +75,7 @@
return voltage * (m_potMaxAngle / m_potMaxVoltage);
}
- /**
- * Frees the resouce.
- */
+ /** Frees the resouce. */
@Override
public void close() {
if (m_initOutput) {
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/motorcontrol/MockMotorController.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/motorcontrol/MockMotorController.java
new file mode 100644
index 0000000..e7a6b8e
--- /dev/null
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/motorcontrol/MockMotorController.java
@@ -0,0 +1,40 @@
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
+
+package edu.wpi.first.wpilibj.motorcontrol;
+
+public class MockMotorController implements MotorController {
+ private double m_speed;
+ private boolean m_isInverted;
+
+ @Override
+ public void set(double speed) {
+ m_speed = m_isInverted ? -speed : speed;
+ }
+
+ @Override
+ public double get() {
+ return m_speed;
+ }
+
+ @Override
+ public void setInverted(boolean isInverted) {
+ m_isInverted = isInverted;
+ }
+
+ @Override
+ public boolean getInverted() {
+ return m_isInverted;
+ }
+
+ @Override
+ public void disable() {
+ m_speed = 0;
+ }
+
+ @Override
+ public void stopMotor() {
+ disable();
+ }
+}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractComsSetup.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractComsSetup.java
index 7c49eef..734115c 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractComsSetup.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractComsSetup.java
@@ -1,26 +1,21 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2019 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj.test;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-import org.junit.BeforeClass;
-import org.junit.Rule;
-import org.junit.rules.TestWatcher;
-import org.junit.runner.Description;
-import org.junit.runners.model.MultipleFailureException;
-
import edu.wpi.first.hal.HAL;
import edu.wpi.first.wpilibj.DriverStation;
import edu.wpi.first.wpilibj.MockDS;
import edu.wpi.first.wpilibj.Timer;
import edu.wpi.first.wpilibj.livewindow.LiveWindow;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import org.junit.BeforeClass;
+import org.junit.Rule;
+import org.junit.rules.TestWatcher;
+import org.junit.runner.Description;
+import org.junit.runners.model.MultipleFailureException;
/**
* This class serves as a superclass for all tests that involve the hardware on the roboRIO. It uses
@@ -29,19 +24,16 @@
* to run.
*/
public abstract class AbstractComsSetup {
- /**
- * Stores whether network coms have been initialized.
- */
+ /** Stores whether network coms have been initialized. */
private static boolean initialized = false;
// We have no way to stop the MockDS, so its thread is daemon.
- private static MockDS ds;
+ private static MockDS ds;
/**
- * This sets up the network communications library to enable the driver
- * station. After starting network coms, it will loop until the driver station
- * returns that the robot is enabled, to ensure that tests will be able to run
- * on the hardware.
+ * This sets up the network communications library to enable the driver station. After starting
+ * network coms, it will loop until the driver station returns that the robot is enabled, to
+ * ensure that tests will be able to run on the hardware.
*/
static {
if (!initialized) {
@@ -49,7 +41,7 @@
// Set some implementations so that the static methods work properly
HAL.initialize(500, 0);
HAL.observeUserProgramStarting();
- DriverStation.getInstance().getAlliance();
+ DriverStation.getAlliance();
ds = new MockDS();
ds.start();
@@ -64,7 +56,7 @@
// Wait until the robot is enabled before starting the tests
int enableCounter = 0;
- while (!DriverStation.getInstance().isEnabled()) {
+ while (!DriverStation.isEnabled()) {
if (enableCounter > 50) {
// Robot did not enable properly after 5 seconds.
// Force exit
@@ -86,12 +78,9 @@
}
}
-
protected abstract Logger getClassLogger();
- /**
- * This causes a stack trace to be printed as the test is running as well as at the end.
- */
+ /** This causes a stack trace to be printed as the test is running as well as at the end. */
@Rule
public final TestWatcher getTestWatcher() {
return getOverridenTestWatcher();
@@ -124,19 +113,32 @@
int exceptionCount = 1; // Running exception count
int failureCount = ((MultipleFailureException) throwable).getFailures().size();
for (Throwable singleThrown : ((MultipleFailureException) throwable).getFailures()) {
- getClassLogger().logp(
- Level.SEVERE,
- description.getClassName(),
- description.getMethodName(),
- (exceptionCount++) + "/" + failureCount + " " + description.getDisplayName() + " "
- + "failed " + singleThrown.getMessage() + "\n" + status, singleThrown);
+ getClassLogger()
+ .logp(
+ Level.SEVERE,
+ description.getClassName(),
+ description.getMethodName(),
+ (exceptionCount++)
+ + "/"
+ + failureCount
+ + " "
+ + description.getDisplayName()
+ + " "
+ + "failed "
+ + singleThrown.getMessage()
+ + "\n"
+ + status,
+ singleThrown);
}
} else {
- getClassLogger().logp(Level.SEVERE, description.getClassName(),
- description.getMethodName(),
- description.getDisplayName() + " failed " + throwable.getMessage() + "\n" + status,
- throwable);
+ getClassLogger()
+ .logp(
+ Level.SEVERE,
+ description.getClassName(),
+ description.getMethodName(),
+ description.getDisplayName() + " failed " + throwable.getMessage() + "\n" + status,
+ throwable);
}
super.failed(throwable, description);
}
@@ -152,7 +154,6 @@
failed(exception, description, "");
}
-
/*
* (non-Javadoc)
*
@@ -163,7 +164,7 @@
TestBench.out().println();
// Wait until the robot is enabled before starting the next tests
int enableCounter = 0;
- while (!DriverStation.getInstance().isEnabled()) {
+ while (!DriverStation.isEnabled()) {
try {
Thread.sleep(100);
} catch (InterruptedException ex) {
@@ -172,8 +173,8 @@
// Prints the message on one line overwriting itself each time
TestBench.out().print("\rWaiting for enable: " + enableCounter++);
}
- getClassLogger().logp(Level.INFO, description.getClassName(), description.getMethodName(),
- "Starting");
+ getClassLogger()
+ .logp(Level.INFO, description.getClassName(), description.getMethodName(), "Starting");
super.starting(description);
}
@@ -182,13 +183,12 @@
simpleLog(Level.INFO, "TEST PASSED!");
super.succeeded(description);
}
-
}
/**
* Logs a simple message without the logger formatting associated with it.
*
- * @param level The level to log the message at
+ * @param level The level to log the message at
* @param message The message to log
*/
protected void simpleLog(Level level, String message) {
@@ -201,9 +201,8 @@
* Provided as a replacement to lambda functions to allow for repeatable checks to see if a
* correct state is reached.
*/
- public abstract class BooleanCheck {
- public BooleanCheck() {
- }
+ public abstract static class BooleanCheck {
+ public BooleanCheck() {}
/**
* Runs the enclosed code and evaluates it to determine what state it should return.
@@ -216,22 +215,23 @@
/**
* Delays until either the correct state is reached or we reach the timeout.
*
- * @param level The level to log the message at.
- * @param timeout How long the delay should run before it should timeout and allow the test
- * to continue
- * @param message The message to accompany the delay. The message will display 'message' took
- * 'timeout' seconds if it passed.
+ * @param level The level to log the message at.
+ * @param timeout How long the delay should run before it should timeout and allow the test to
+ * continue
+ * @param message The message to accompany the delay. The message will display 'message' took
+ * 'timeout' seconds if it passed.
* @param correctState A method to determine if the test has reached a state where it is valid to
- * continue
+ * continue
* @return a double representing how long the delay took to run in seconds.
*/
- public double delayTillInCorrectStateWithMessage(Level level, double timeout, String message,
- BooleanCheck correctState) {
+ public double delayTillInCorrectStateWithMessage(
+ Level level, double timeout, String message, BooleanCheck correctState) {
int timeoutIndex;
// As long as we are not in the correct state and the timeout has not been
// reached then continue to run this loop
- for (timeoutIndex = 0; timeoutIndex < (timeout * 100) && !correctState.getAsBoolean();
- timeoutIndex++) {
+ for (timeoutIndex = 0;
+ timeoutIndex < (timeout * 100) && !correctState.getAsBoolean();
+ timeoutIndex++) {
Timer.delay(0.01);
}
if (correctState.getAsBoolean()) {
@@ -241,5 +241,4 @@
}
return timeoutIndex * 0.01;
}
-
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractTestSuite.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractTestSuite.java
index 54aae9e..ff0542c 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractTestSuite.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractTestSuite.java
@@ -1,9 +1,6 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2020 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj.test;
@@ -14,7 +11,6 @@
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.regex.Pattern;
-
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.Request;
@@ -40,8 +36,8 @@
SuiteClasses annotation = getClass().getAnnotation(SuiteClasses.class);
List<Class<?>> classes = new ArrayList<>();
if (annotation == null) {
- throw new RuntimeException(String.format("class '%s' must have a SuiteClasses annotation",
- getClass().getName()));
+ throw new RuntimeException(
+ String.format("class '%s' must have a SuiteClasses annotation", getClass().getName()));
}
for (Class<?> c : annotation.value()) {
classes.add(c);
@@ -63,7 +59,7 @@
* Stores a method name and method class pair. Used when searching for methods matching a given
* regex text.
*/
- protected class ClassMethodPair {
+ protected static class ClassMethodPair {
public final Class<?> m_methodClass;
public final String m_methodName;
@@ -84,7 +80,8 @@
for (Method m : c.getMethods()) {
// If this is a test method that is not trying to be ignored and it
// matches the regex
- if (m.getAnnotation(Test.class) != null && m.getAnnotation(Ignore.class) == null
+ if (m.getAnnotation(Test.class) != null
+ && m.getAnnotation(Ignore.class) == null
&& Pattern.matches(regex, m.getName())) {
ClassMethodPair pair = new ClassMethodPair(c, m);
classMethodPairs.add(pair);
@@ -94,7 +91,6 @@
return classMethodPairs;
}
-
/**
* Gets all of the test classes listed in this suite. Does not include any of the test suites. All
* of these classes contain tests.
@@ -112,16 +108,20 @@
// Add the tests from this suite that match the regex to the list of
// tests to run
runningList = suite.getAllContainedBaseTests(runningList);
- } catch (NoSuchMethodException | InvocationTargetException | InstantiationException
+ } catch (NoSuchMethodException
+ | InvocationTargetException
+ | InstantiationException
| IllegalAccessException ex) {
// This shouldn't happen unless the constructor is changed in some
// way.
- logger.log(Level.SEVERE, "Test suites can not take parameters in their constructors.",
- ex);
+ logger.log(
+ Level.SEVERE, "Test suites can not take parameters in their constructors.", ex);
}
} else if (c.getAnnotation(SuiteClasses.class) != null) {
- logger.log(Level.SEVERE,
- String.format("class '%s' must extend %s to be searchable using regex.",
+ logger.log(
+ Level.SEVERE,
+ String.format(
+ "class '%s' must extend %s to be searchable using regex.",
c.getName(), AbstractTestSuite.class.getName()));
} else { // This is a class containing tests
// so add it to the list
@@ -142,12 +142,11 @@
return getAllContainedBaseTests(runningBaseTests);
}
-
/**
* Retrieves all of the classes listed in the <code>@SuiteClasses</code> annotation that match the
* given regex text.
*
- * @param regex the text pattern to retrieve.
+ * @param regex the text pattern to retrieve.
* @param runningList the running list of classes to prevent recursion
* @return The list of classes matching the regex pattern
*/
@@ -181,12 +180,11 @@
* @param regex the regex text to search for
* @return the list of suite and/or test classes matching the regex.
*/
- private List<Class<?>> getSuiteOrTestMatchingRegex(final String regex, List<Class<?>>
- runningList) {
+ private List<Class<?>> getSuiteOrTestMatchingRegex(
+ final String regex, List<Class<?>> runningList) {
// Get any test suites matching the regex using the superclass methods
runningList = getAllClassMatching(regex, runningList);
-
// Then search any test suites not retrieved already for test classes
// matching the regex.
List<Class<?>> unCollectedSuites = getAllClasses();
@@ -208,12 +206,14 @@
runningList = suite.getSuiteOrTestMatchingRegex(regex, runningList);
}
- } catch (NoSuchMethodException | InvocationTargetException | InstantiationException
+ } catch (NoSuchMethodException
+ | InvocationTargetException
+ | InstantiationException
| IllegalAccessException ex) {
// This shouldn't happen unless the constructor is changed in some
// way.
- logger.log(Level.SEVERE, "Test suites can not take parameters in their constructors.",
- ex);
+ logger.log(
+ Level.SEVERE, "Test suites can not take parameters in their constructors.", ex);
}
}
}
@@ -233,7 +233,6 @@
return getSuiteOrTestMatchingRegex(regex, matchingClasses);
}
-
/**
* Retrieves all of the classes listed in the <code>@SuiteClasses</code> annotation.
*
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractTestSuiteTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractTestSuiteTest.java
index d788b81..c41ff8a 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractTestSuiteTest.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AbstractTestSuiteTest.java
@@ -1,14 +1,16 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2019 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj.test;
-import java.util.List;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.hamcrest.Matchers.hasItems;
+import static org.hamcrest.Matchers.not;
+import static org.junit.Assert.assertEquals;
+import edu.wpi.first.wpilibj.test.AbstractTestSuite.ClassMethodPair;
+import java.util.List;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
@@ -16,13 +18,6 @@
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
-import edu.wpi.first.wpilibj.test.AbstractTestSuite.ClassMethodPair;
-
-import static org.hamcrest.MatcherAssert.assertThat;
-import static org.hamcrest.Matchers.hasItems;
-import static org.hamcrest.Matchers.not;
-import static org.junit.Assert.assertEquals;
-
/**
* Yes, this is the test system testing itself. Functionally, this is making sure that all tests get
* run correctly when you use parametrized arguments.
@@ -31,10 +26,16 @@
public class AbstractTestSuiteTest {
@Ignore("Prevents ANT from trying to run these as tests")
@RunWith(Suite.class)
- @SuiteClasses({FirstSampleTest.class, SecondSampleTest.class, ThirdSampleTest.class,
- FourthSampleTest.class, UnusualTest.class, ExampleSubSuite.class, EmptySuite.class})
- class TestForAbstractTestSuite extends AbstractTestSuite {
- }
+ @SuiteClasses({
+ FirstSampleTest.class,
+ SecondSampleTest.class,
+ ThirdSampleTest.class,
+ FourthSampleTest.class,
+ UnusualTest.class,
+ ExampleSubSuite.class,
+ EmptySuite.class
+ })
+ static class TestForAbstractTestSuite extends AbstractTestSuite {}
TestForAbstractTestSuite m_testSuite;
@@ -82,10 +83,11 @@
List<Class<?>> collectedTests = m_testSuite.getSuiteOrTestMatchingRegex(".*Test.*");
// then
assertEquals(7, collectedTests.size());
- assertThat(collectedTests, hasItems(FirstSubSuiteTest.class,
- SecondSubSuiteTest.class, UnusualTest.class));
- assertThat(collectedTests,
- not(hasItems(new Class<?>[]{ExampleSubSuite.class, EmptySuite.class})));
+ assertThat(
+ collectedTests,
+ hasItems(FirstSubSuiteTest.class, SecondSubSuiteTest.class, UnusualTest.class));
+ assertThat(
+ collectedTests, not(hasItems(new Class<?>[] {ExampleSubSuite.class, EmptySuite.class})));
}
@Test
@@ -96,31 +98,23 @@
assertEquals(1, pairs.size());
assertEquals(FirstSubSuiteTest.class, pairs.get(0).m_methodClass);
assertEquals(FirstSubSuiteTest.METHODNAME, pairs.get(0).m_methodName);
-
}
-
}
@SuppressWarnings("OneTopLevelClass")
-class FirstSampleTest {
-}
+class FirstSampleTest {}
@SuppressWarnings("OneTopLevelClass")
-class SecondSampleTest {
-}
+class SecondSampleTest {}
@SuppressWarnings("OneTopLevelClass")
-class ThirdSampleTest {
-}
+class ThirdSampleTest {}
@SuppressWarnings("OneTopLevelClass")
-class FourthSampleTest {
-}
+class FourthSampleTest {}
@SuppressWarnings("OneTopLevelClass")
-class UnusualTest {
-} // This is a member of both suites
-
+class UnusualTest {} // This is a member of both suites
@Ignore("Prevents ANT from trying to run these as tests")
@SuppressWarnings("OneTopLevelClass")
@@ -129,26 +123,20 @@
@Test
@SuppressWarnings("MethodName")
- public void aTestMethod() {
- }
+ public void aTestMethod() {}
}
@SuppressWarnings("OneTopLevelClass")
-class SecondSubSuiteTest {
-}
-
+class SecondSubSuiteTest {}
@RunWith(Suite.class)
@SuiteClasses({FirstSubSuiteTest.class, SecondSubSuiteTest.class, UnusualTest.class})
@Ignore("Prevents ANT from trying to run these as tests")
@SuppressWarnings("OneTopLevelClass")
-class ExampleSubSuite extends AbstractTestSuite {
-}
-
+class ExampleSubSuite extends AbstractTestSuite {}
@Ignore("Prevents ANT from trying to run these as tests")
@RunWith(Suite.class)
@SuiteClasses({})
@SuppressWarnings("OneTopLevelClass")
-class EmptySuite extends AbstractTestSuite {
-}
+class EmptySuite extends AbstractTestSuite {}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AntJunitLanucher.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AntJunitLauncher.java
similarity index 80%
rename from wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AntJunitLanucher.java
rename to wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AntJunitLauncher.java
index 0350ea4..4dfa6e1 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AntJunitLanucher.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/AntJunitLauncher.java
@@ -1,14 +1,10 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2018 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj.test;
import java.io.File;
-
import org.apache.tools.ant.BuildLogger;
import org.apache.tools.ant.DefaultLogger;
import org.apache.tools.ant.Project;
@@ -20,7 +16,7 @@
* Provides an entry point for tests to run with ANT. This allows ant to output JUnit XML test
* results for Jenkins.
*/
-public class AntJunitLanucher {
+public class AntJunitLauncher {
/**
* Main entry point for jenkins.
*
@@ -79,13 +75,13 @@
ex.printStackTrace();
}
} else {
- TestBench.out().println(
- "Run will not output XML for Jenkins because " + "tests are not being run with ANT");
+ TestBench.out()
+ .println(
+ "Run will not output XML for Jenkins because " + "tests are not being run with ANT");
// This should never return as it makes its own call to
// System.exit();
TestSuite.main(args);
}
System.exit(0);
}
-
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/QuickTest.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/QuickTest.java
index 87b05d0..3dd2ea1 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/QuickTest.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/QuickTest.java
@@ -1,14 +1,10 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2018 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj.test;
import java.util.logging.Logger;
-
import org.junit.Test;
/**
@@ -30,8 +26,6 @@
return logger;
}
-
@Test
- public void test() {
- }
+ public void test() {}
}
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/RepeatRule.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/RepeatRule.java
index deb0da8..07f41f2 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/RepeatRule.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/RepeatRule.java
@@ -1,16 +1,12 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2018 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj.test;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
-
import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
@@ -20,21 +16,18 @@
* is important if you have a test that fails only "sometimes" and needs to be rerun to find the
* issue.
*
- * <p>This code was originally found here:
- * <a href="http://www.codeaffine.com/2013/04/10/running-junit-tests-repeatedly-without-loops/">
- * Running JUnit Tests Repeatedly Without Loops</a>
+ * <p>This code was originally found here: <a
+ * href="http://www.codeaffine.com/2013/04/10/running-junit-tests-repeatedly-without-loops/">Running
+ * JUnit Tests Repeatedly Without Loops</a>
*/
public class RepeatRule implements TestRule {
@Retention(RetentionPolicy.RUNTIME)
@Target({java.lang.annotation.ElementType.METHOD})
public @interface Repeat {
- /**
- * The number of times to repeat the test.
- */
+ /** The number of times to repeat the test. */
int times();
}
-
private static class RepeatStatement extends Statement {
private final int m_times;
private final Statement m_statement;
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestBench.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestBench.java
index afd152f..8e63dc9 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestBench.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestBench.java
@@ -1,38 +1,30 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2019 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj.test;
+import edu.wpi.first.wpilibj.AnalogGyro;
+import edu.wpi.first.wpilibj.AnalogInput;
+import edu.wpi.first.wpilibj.AnalogOutput;
+import edu.wpi.first.wpilibj.DigitalInput;
+import edu.wpi.first.wpilibj.Relay;
+import edu.wpi.first.wpilibj.Servo;
+import edu.wpi.first.wpilibj.fixtures.AnalogCrossConnectFixture;
+import edu.wpi.first.wpilibj.fixtures.DIOCrossConnectFixture;
+import edu.wpi.first.wpilibj.fixtures.MotorEncoderFixture;
+import edu.wpi.first.wpilibj.fixtures.RelayCrossConnectFixture;
+import edu.wpi.first.wpilibj.fixtures.TiltPanCameraFixture;
+import edu.wpi.first.wpilibj.motorcontrol.Jaguar;
+import edu.wpi.first.wpilibj.motorcontrol.Talon;
+import edu.wpi.first.wpilibj.motorcontrol.Victor;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
-import edu.wpi.first.wpilibj.AnalogGyro;
-import edu.wpi.first.wpilibj.AnalogInput;
-import edu.wpi.first.wpilibj.AnalogOutput;
-import edu.wpi.first.wpilibj.DigitalInput;
-import edu.wpi.first.wpilibj.Jaguar;
-import edu.wpi.first.wpilibj.Relay;
-import edu.wpi.first.wpilibj.Servo;
-import edu.wpi.first.wpilibj.Talon;
-import edu.wpi.first.wpilibj.Victor;
-import edu.wpi.first.wpilibj.fixtures.AnalogCrossConnectFixture;
-import edu.wpi.first.wpilibj.fixtures.DIOCrossConnectFixture;
-import edu.wpi.first.wpilibj.fixtures.MotorEncoderFixture;
-import edu.wpi.first.wpilibj.fixtures.RelayCrossConnectFixture;
-import edu.wpi.first.wpilibj.fixtures.TiltPanCameraFixture;
-
-/**
- * This class provides access to all of the elements on the test bench, for use in fixtures. This
- * class is a singleton, you should use {@link #getInstance()} to obtain a reference to the {@code
- * TestBench}.
- */
+/** This class provides access to all of the elements on the test bench, for use in fixtures. */
public final class TestBench {
/**
* The time that it takes to have a motor go from rotating at full speed to completely stopped.
@@ -49,8 +41,7 @@
public static final int kTiltServoChannel = 9;
public static final int kPanServoChannel = 8;
-
- /* PowerDistributionPanel channels */
+ /* PowerDistribution channels */
public static final int kJaguarPDPChannel = 6;
public static final int kVictorPDPChannel = 8;
public static final int kTalonPDPChannel = 10;
@@ -61,17 +52,14 @@
public static final int DIOCrossConnectA2 = 7;
public static final int DIOCrossConnectA1 = 6;
- /**
- * The Singleton instance of the Test Bench.
- */
+ /** The Singleton instance of the Test Bench. */
private static TestBench instance = null;
/**
* The single constructor for the TestBench. This method is private in order to prevent multiple
* TestBench objects from being allocated.
*/
- protected TestBench() {
- }
+ protected TestBench() {}
/**
* Constructs a new set of objects representing a connected set of Talon controlled Motors and an
@@ -79,10 +67,10 @@
*
* @return a freshly allocated Talon, Encoder pair
*/
- public MotorEncoderFixture<Talon> getTalonPair() {
+ public static MotorEncoderFixture<Talon> getTalonPair() {
return new MotorEncoderFixture<Talon>() {
@Override
- protected Talon giveSpeedController() {
+ protected Talon giveMotorController() {
return new Talon(kTalonChannel);
}
@@ -109,10 +97,10 @@
*
* @return a freshly allocated Victor, Encoder pair
*/
- public MotorEncoderFixture<Victor> getVictorPair() {
+ public static MotorEncoderFixture<Victor> getVictorPair() {
return new MotorEncoderFixture<Victor>() {
@Override
- protected Victor giveSpeedController() {
+ protected Victor giveMotorController() {
return new Victor(kVictorChannel);
}
@@ -139,10 +127,10 @@
*
* @return a freshly allocated Jaguar, Encoder pair
*/
- public MotorEncoderFixture<Jaguar> getJaguarPair() {
+ public static MotorEncoderFixture<Jaguar> getJaguarPair() {
return new MotorEncoderFixture<Jaguar>() {
@Override
- protected Jaguar giveSpeedController() {
+ protected Jaguar giveMotorController() {
return new Jaguar(kJaguarChannel);
}
@@ -168,8 +156,7 @@
*
* @return a freshly allocated Servo's and a freshly allocated Gyroscope
*/
- public TiltPanCameraFixture getTiltPanCam() {
-
+ public static TiltPanCameraFixture getTiltPanCam() {
return new TiltPanCameraFixture() {
@Override
protected AnalogGyro giveGyro() {
@@ -197,31 +184,33 @@
};
}
- public DIOCrossConnectFixture getDIOCrossConnectFixture(int inputPort, int outputPort) {
+ public static DIOCrossConnectFixture getDIOCrossConnectFixture(int inputPort, int outputPort) {
return new DIOCrossConnectFixture(inputPort, outputPort);
}
- /**
- * Gets two lists of possible DIO pairs for the two pairs.
- */
- private List<List<Integer[]>> getDIOCrossConnect() {
+ /** Gets two lists of possible DIO pairs for the two pairs. */
+ private static List<List<Integer[]>> getDIOCrossConnect() {
List<List<Integer[]>> pairs = new ArrayList<List<Integer[]>>();
List<Integer[]> setA =
- Arrays.asList(new Integer[][]{
- {DIOCrossConnectA1, DIOCrossConnectA2},
- {DIOCrossConnectA2, DIOCrossConnectA1}});
+ Arrays.asList(
+ new Integer[][] {
+ {DIOCrossConnectA1, DIOCrossConnectA2},
+ {DIOCrossConnectA2, DIOCrossConnectA1}
+ });
pairs.add(setA);
List<Integer[]> setB =
- Arrays.asList(new Integer[][]{
- {DIOCrossConnectB1, DIOCrossConnectB2},
- {DIOCrossConnectB2, DIOCrossConnectB1}});
+ Arrays.asList(
+ new Integer[][] {
+ {DIOCrossConnectB1, DIOCrossConnectB2},
+ {DIOCrossConnectB2, DIOCrossConnectB1}
+ });
pairs.add(setB);
// NOTE: IF MORE DIOCROSSCONNECT PAIRS ARE ADDED ADD THEM HERE
return pairs;
}
- @SuppressWarnings("JavadocMethod")
+ @SuppressWarnings("MissingJavadocMethod")
public static AnalogCrossConnectFixture getAnalogCrossConnectFixture() {
return new AnalogCrossConnectFixture() {
@Override
@@ -236,7 +225,7 @@
};
}
- @SuppressWarnings("JavadocMethod")
+ @SuppressWarnings("MissingJavadocMethod")
public static RelayCrossConnectFixture getRelayCrossConnectFixture() {
return new RelayCrossConnectFixture() {
@Override
@@ -262,7 +251,7 @@
*
* @return pairs of DIOCrossConnectFixtures
*/
- public Collection<Integer[]> getDIOCrossConnectCollection() {
+ public static Collection<Integer[]> getDIOCrossConnectCollection() {
Collection<Integer[]> pairs = new ArrayList<Integer[]>();
for (Collection<Integer[]> collection : getDIOCrossConnect()) {
pairs.addAll(collection);
@@ -276,8 +265,8 @@
* @param flip whether this encoder needs to be flipped
* @return A list of different inputs to use for the tests
*/
- private Collection<Integer[]> getPairArray(List<Integer[]> listA, List<Integer[]> listB,
- boolean flip) {
+ private static Collection<Integer[]> getPairArray(
+ List<Integer[]> listA, List<Integer[]> listB, boolean flip) {
Collection<Integer[]> encoderPortPairs = new ArrayList<Integer[]>();
for (Integer[] portPairsA : listA) {
Integer[] inputs = new Integer[5];
@@ -310,13 +299,13 @@
*
* @return A collection of different input pairs to use for the encoder
*/
- public Collection<Integer[]> getEncoderDIOCrossConnectCollection() {
+ public static Collection<Integer[]> getEncoderDIOCrossConnectCollection() {
Collection<Integer[]> encoderPortPairs = new ArrayList<Integer[]>();
assert getDIOCrossConnect().size() == 2;
- encoderPortPairs.addAll(getPairArray(getDIOCrossConnect().get(0), getDIOCrossConnect().get(1),
- false));
- encoderPortPairs.addAll(getPairArray(getDIOCrossConnect().get(1), getDIOCrossConnect().get(0),
- false));
+ encoderPortPairs.addAll(
+ getPairArray(getDIOCrossConnect().get(0), getDIOCrossConnect().get(1), false));
+ encoderPortPairs.addAll(
+ getPairArray(getDIOCrossConnect().get(1), getDIOCrossConnect().get(0), false));
assert encoderPortPairs.size() == 8;
return encoderPortPairs;
}
@@ -326,7 +315,9 @@
* new instance of it. Otherwise it returns the existing instance.
*
* @return The Singleton instance of the TestBench
+ * @deprecated Use the static methods instead
*/
+ @Deprecated
public static TestBench getInstance() {
if (instance == null) {
instance = new TestBench();
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestSuite.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestSuite.java
index 31b3b0d..880a97c 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestSuite.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/TestSuite.java
@@ -1,12 +1,10 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2008-2019 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
package edu.wpi.first.wpilibj.test;
+import edu.wpi.first.wpilibj.WpiLibJTestSuite;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@@ -16,7 +14,8 @@
import java.util.logging.LogManager;
import java.util.logging.Logger;
import java.util.regex.Pattern;
-
+import junit.framework.JUnit4TestAdapter;
+import junit.runner.Version;
import org.junit.runner.JUnitCore;
import org.junit.runner.Result;
import org.junit.runner.RunWith;
@@ -24,11 +23,6 @@
import org.junit.runners.Suite;
import org.junit.runners.Suite.SuiteClasses;
-import junit.framework.JUnit4TestAdapter;
-import junit.runner.Version;
-
-import edu.wpi.first.wpilibj.WpiLibJTestSuite;
-
/**
* The WPILibJ Integeration Test Suite collects all of the tests to be run by junit. In order for a
* test to be run, it must be added the list of suite classes below. The tests will be run in the
@@ -48,14 +42,18 @@
Logger.getAnonymousLogger().severe("Could not load default logging.properties file");
Logger.getAnonymousLogger().severe(ex.getMessage());
}
+ try {
+ inputStream.close();
+ } catch (IOException e) {
+ throw new RuntimeException(e.getMessage());
+ }
TestBench.out().println("Starting Tests");
}
private static final Logger WPILIBJ_ROOT_LOGGER = Logger.getLogger("edu.wpi.first.wpilibj");
- private static final Logger WPILIBJ_COMMAND_ROOT_LOGGER = Logger
- .getLogger("edu.wpi.first.wpilibj.command");
-
+ private static final Logger WPILIBJ_COMMAND_ROOT_LOGGER =
+ Logger.getLogger("edu.wpi.first.wpilibj.command");
private static final Class<?> QUICK_TEST = QuickTest.class;
private static final String QUICK_TEST_FLAG = "--quick";
@@ -66,9 +64,7 @@
private static TestSuite instance = null;
- /**
- * Get the singleton instance of the test suite.
- */
+ /** Get the singleton instance of the test suite. */
public static TestSuite getInstance() {
if (instance == null) {
instance = new TestSuite();
@@ -76,32 +72,41 @@
return instance;
}
- /**
- * This has to be public so that the JUnit4.
- */
- public TestSuite() {
- }
+ /** This has to be public so that the JUnit4. */
+ public TestSuite() {}
- /**
- * Displays a help message for the user when they use the --help flag at runtime.
- */
+ /** Displays a help message for the user when they use the --help flag at runtime. */
protected static void displayHelp() {
StringBuilder helpMessage = new StringBuilder("Test Parameters help: \n");
- helpMessage.append("\t" + QUICK_TEST_FLAG
- + " will cause the quick test to be run. Ignores other flags except for "
- + METHOD_REPEAT_FILTER + "\n");
- helpMessage.append("\t" + CLASS_NAME_FILTER
- + " will use the supplied regex text to search for suite/test class names "
- + "matching the regex and run them.\n");
- helpMessage.append("\t" + METHOD_NAME_FILTER
- + " will use the supplied regex text to search for test methods (excluding methods "
- + "with the @Ignore annotation) and run only those methods. Can be paired with "
- + METHOD_REPEAT_FILTER + " to " + "repeat the selected tests multiple times.\n");
- helpMessage.append("\t" + METHOD_REPEAT_FILTER + " will repeat the tests selected with either "
- + QUICK_TEST_FLAG + " or " + CLASS_NAME_FILTER
- + " and run them the given number of times.\n");
- helpMessage
- .append("[NOTE] All regex uses the syntax defined by java.util.regex.Pattern. This "
+ helpMessage.append(
+ "\t"
+ + QUICK_TEST_FLAG
+ + " will cause the quick test to be run. Ignores other flags except for "
+ + METHOD_REPEAT_FILTER
+ + "\n");
+ helpMessage.append(
+ "\t"
+ + CLASS_NAME_FILTER
+ + " will use the supplied regex text to search for suite/test class names "
+ + "matching the regex and run them.\n");
+ helpMessage.append(
+ "\t"
+ + METHOD_NAME_FILTER
+ + " will use the supplied regex text to search for test methods (excluding methods "
+ + "with the @Ignore annotation) and run only those methods. Can be paired with "
+ + METHOD_REPEAT_FILTER
+ + " to "
+ + "repeat the selected tests multiple times.\n");
+ helpMessage.append(
+ "\t"
+ + METHOD_REPEAT_FILTER
+ + " will repeat the tests selected with either "
+ + QUICK_TEST_FLAG
+ + " or "
+ + CLASS_NAME_FILTER
+ + " and run them the given number of times.\n");
+ helpMessage.append(
+ "[NOTE] All regex uses the syntax defined by java.util.regex.Pattern. This "
+ "documentation can be found at "
+ "http://docs.oracle.com/javase/7/docs/api/java/util/regex/Pattern.html\n");
helpMessage.append("\n");
@@ -121,12 +126,12 @@
invalidMessage.append(a + " ");
}
invalidMessage.append("\n");
- invalidMessage
- .append("For details on proper usage of the runtime flags please run again with the "
- + HELP_FLAG + " flag.\n\n");
+ invalidMessage.append(
+ "For details on proper usage of the runtime flags please run again with the "
+ + HELP_FLAG
+ + " flag.\n\n");
TestBench.out().println(invalidMessage);
-
}
/**
@@ -147,7 +152,6 @@
TestBench.out().println(loadedTestsMessage);
}
-
/**
* Parses the arguments passed at runtime and runs the appropriate tests based upon these
* arguments.
@@ -173,14 +177,14 @@
for (String s : args) {
if (Pattern.matches(METHOD_NAME_FILTER + ".*", s)) {
methodFilter = true;
- methodRegex = new String(s).replace(METHOD_NAME_FILTER, "");
+ methodRegex = s.replace(METHOD_NAME_FILTER, "");
}
if (Pattern.matches(METHOD_REPEAT_FILTER + ".*", s)) {
try {
- repeatCount = Integer.parseInt(new String(s).replace(METHOD_REPEAT_FILTER, ""));
+ repeatCount = Integer.parseInt(s.replace(METHOD_REPEAT_FILTER, ""));
} catch (NumberFormatException ex) {
- displayInvalidUsage("The argument passed to the repeat rule was not a valid integer.",
- args);
+ displayInvalidUsage(
+ "The argument passed to the repeat rule was not a valid integer.", args);
}
}
if (Pattern.matches(CLASS_NAME_FILTER + ".*", s)) {
@@ -189,7 +193,6 @@
}
}
-
ArrayList<String> argsParsed = new ArrayList<String>(Arrays.asList(args));
if (argsParsed.contains(HELP_FLAG)) {
// If the user inputs the help flag then return the help message and exit
@@ -203,8 +206,8 @@
}
/**
- * Stores the data from multiple {@link Result}s in one class that can be
- * returned to display the results.
+ * Stores the data from multiple {@link Result}s in one class that can be returned to display
+ * the results.
*/
class MultipleResult extends Result {
private static final long serialVersionUID = 1L;
@@ -255,8 +258,8 @@
if (methodFilter) {
List<ClassMethodPair> pairs = (new TestSuite()).getMethodMatching(methodRegex);
if (pairs.size() == 0) {
- displayInvalidUsage("None of the arguments passed to the method name filter matched.",
- args);
+ displayInvalidUsage(
+ "None of the arguments passed to the method name filter matched.", args);
return null;
}
// Print out the list of tests before we run them
@@ -271,7 +274,6 @@
TestBench.out().println("\t" + p.m_methodName);
}
-
// The test results will be saved here
MultipleResult results = new MultipleResult();
// Runs tests multiple times if the repeat rule is used
@@ -323,9 +325,17 @@
TestBench.out().println();
TestBench.out().println("FAILURES!!!");
// Print the test statistics
- TestBench.out().println(
- "Tests run: " + result.getRunCount() + ", Failures: " + result.getFailureCount()
- + ", Ignored: " + result.getIgnoreCount() + ", In " + result.getRunTime() + "ms");
+ TestBench.out()
+ .println(
+ "Tests run: "
+ + result.getRunCount()
+ + ", Failures: "
+ + result.getFailureCount()
+ + ", Ignored: "
+ + result.getIgnoreCount()
+ + ", In "
+ + result.getRunTime()
+ + "ms");
// Prints out a list of test that failed
TestBench.out().println("Failure List (short):");
@@ -340,9 +350,15 @@
}
} else {
TestBench.out().println("SUCCESS!");
- TestBench.out().println(
- "Tests run: " + result.getRunCount() + ", Ignored: " + result.getIgnoreCount() + ", In "
- + result.getRunTime() + "ms");
+ TestBench.out()
+ .println(
+ "Tests run: "
+ + result.getRunCount()
+ + ", Ignored: "
+ + result.getIgnoreCount()
+ + ", In "
+ + result.getRunTime()
+ + "ms");
}
TestBench.out().println();
}
@@ -356,7 +372,6 @@
return new JUnit4TestAdapter(TestSuite.class);
}
-
/**
* The method called at runtime.
*
diff --git a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/package-info.java b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/package-info.java
index 481cb08..8ce4285 100644
--- a/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/package-info.java
+++ b/wpilibjIntegrationTests/src/main/java/edu/wpi/first/wpilibj/test/package-info.java
@@ -1,18 +1,14 @@
-/*----------------------------------------------------------------------------*/
-/* Copyright (c) 2016-2018 FIRST. 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. */
-/*----------------------------------------------------------------------------*/
+// Copyright (c) FIRST and other WPILib contributors.
+// Open Source Software; you can modify and/or share it under the terms of
+// the WPILib BSD license file in the root directory of this project.
/**
* This is the starting point for the integration testing framework. This package should contain
* classes that are not explicitly for testing the library but instead provide the framework that
- * the tests can extend from. Every test should extend from
- * {@link edu.wpi.first.wpilibj.test.AbstractComsSetup}
- * to ensure that Network Communications is properly instantiated before the test is run. The
- * {@link edu.wpi.first.wpilibj.test.TestBench} should contain the port numbers for all of the
- * hardware and these values should not be explicitly defined anywhere else in the testing
- * framework.
+ * the tests can extend from. Every test should extend from {@link
+ * edu.wpi.first.wpilibj.test.AbstractComsSetup} to ensure that Network Communications is properly
+ * instantiated before the test is run. The {@link edu.wpi.first.wpilibj.test.TestBench} should
+ * contain the port numbers for all of the hardware and these values should not be explicitly
+ * defined anywhere else in the testing framework.
*/
package edu.wpi.first.wpilibj.test;