[wpilib] Fix SendableChooser test (#5835)

Using unique NT keys for each test seems to resolve the failure on Linux. Changed Java as well, for completeness.
This commit is contained in:
Ryan Blue
2023-10-26 23:47:04 -04:00
committed by GitHub
parent 3ba501f947
commit 366b715942
2 changed files with 17 additions and 10 deletions

View File

@@ -28,13 +28,16 @@ class SendableChooserTest {
@ParameterizedTest
void returnsSelected(int toSelect) {
try (var chooser = new SendableChooser<Integer>();
var publisher = m_inst.getStringTopic("/SmartDashboard/chooser/selected").publish()) {
var publisher =
m_inst
.getStringTopic("/SmartDashboard/returnsSelectedChooser" + toSelect + "/selected")
.publish()) {
for (int i = 1; i <= 3; i++) {
chooser.addOption(String.valueOf(i), i);
}
chooser.setDefaultOption(String.valueOf(0), 0);
SmartDashboard.putData("chooser", chooser);
SmartDashboard.putData("returnsSelectedChooser" + toSelect, chooser);
SmartDashboard.updateValues();
publisher.set(String.valueOf(toSelect));
SmartDashboard.updateValues();
@@ -74,9 +77,9 @@ class SendableChooserTest {
AtomicInteger currentVal = new AtomicInteger();
chooser.onChange(val -> currentVal.set(val));
SmartDashboard.putData("chooser", chooser);
SmartDashboard.putData("changeListenerChooser", chooser);
SmartDashboard.updateValues();
SmartDashboard.putString("chooser/selected", "3");
SmartDashboard.putString("changeListenerChooser/selected", "3");
SmartDashboard.updateValues();
assertEquals(3, currentVal.get());
}