RecorderController { public void start() { listenerHandle = startStopControlEntry.addListener(this::updateControl, updateFlags); markerGenerator.start(); } RecorderController(NetworkTableInstance ntInstance,
                            String startStopKey,
                            String fileNameFormatKey,
                            Recorder recorder); static RecorderController createWithDefaultEntries(NetworkTableInstance ntInstance); void start(); void stop(); static final String DEFAULT_RECORDING_ROOT_TABLE; static final String DEFAULT_START_STOP_KEY; static final String DEFAULT_FILE_NAME_FORMAT_KEY; }
@Test public void testSetOnStartup() { final String format = "already-set-when-connected-${time}"; ntInstance.getEntry(RecorderController.DEFAULT_START_STOP_KEY).setBoolean(true); ntInstance.getEntry(RecorderController.DEFAULT_FILE_NAME_FORMAT_KEY).setString(format); controller.start(); ntInstance.waitForEntryListenerQueue(-1); assertAll( () -> assertTrue(recorder.isRunning(), "Recorder should be running"), () -> assertEquals(format, recorder.getFileNameFormat(), "File name format should have been set") ); }
@Test public void testStartWhenEntryUpdates() { controller.start(); ntInstance.getEntry(RecorderController.DEFAULT_START_STOP_KEY).setBoolean(true); ntInstance.waitForEntryListenerQueue(-1); assertTrue(recorder.isRunning(), "Recorder should have been started"); }
@Test public void testStopsRecorder() { controller.start(); ntInstance.getEntry(RecorderController.DEFAULT_START_STOP_KEY).setBoolean(true); ntInstance.waitForEntryListenerQueue(-1); assertTrue(recorder.isRunning()); ntInstance.getEntry(RecorderController.DEFAULT_START_STOP_KEY).setBoolean(false); ntInstance.waitForEntryListenerQueue(-1); assertFalse(recorder.isRunning(), "Recorder should have been stopped"); }
@Test public void testDoNothingIfInPlayBack() { controller.start(); DashboardMode.setCurrentMode(DashboardMode.PLAYBACK); ntInstance.getEntry(RecorderController.DEFAULT_START_STOP_KEY).setBoolean(true); ntInstance.waitForEntryListenerQueue(-1); assertFalse(recorder.isRunning(), "Recorder should not have been started"); }