Skip to content

Commit

Permalink
StatusPollTimer can now properly set the update interval
Browse files Browse the repository at this point in the history
  • Loading branch information
breiler committed Feb 6, 2024
1 parent 9edf8ca commit accc7e9
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void receivedStatus() {
*/
public void setUpdateInterval(int updateInterval) {
this.updateInterval = Math.max(updateInterval, 10);
if (timer.isRunning()) {
if (timer != null && timer.isRunning()) {
stop();
start();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ public void applySettingsToController(Settings settings, IController controller)
.append(Localization.getString("firmware.feature.linesToArc")).append(NEW_LINE)
.append(Localization.getString("firmware.feature.statusUpdates")).append(NEW_LINE)
.append(Localization.getString("firmware.feature.statusUpdateRate"));

logger.log(Level.SEVERE, "Could not load firmware settings", ex);
throw new Exception(message.toString(), ex);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package com.willwinder.universalgcodesender;

import static org.junit.Assert.assertEquals;
import org.junit.Before;
import org.junit.Test;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;

public class StatusPollTimerTest {
private StatusPollTimer statusPollTimer;

@Mock
private IController controller;

@Before
public void setUp() {
MockitoAnnotations.initMocks(this);
statusPollTimer = new StatusPollTimer(controller);
}

@Test
public void setUpdateIntervalShouldSetTheIntervalWhenTimerIsNotRunning() {
statusPollTimer.setUpdateInterval(100);
assertEquals(100, statusPollTimer.getUpdateInterval());
}
}

0 comments on commit accc7e9

Please sign in to comment.