Search in sources :

Example 1 with ContinuousJogWorker

use of com.willwinder.universalgcodesender.utils.ContinuousJogWorker in project Universal-G-Code-Sender by winder.

the class AnalogJogActionTest method actionPerformedShouldGenerateJogCommandsWhenStateIsIdle.

@Test
public void actionPerformedShouldGenerateJogCommandsWhenStateIsIdle() {
    ContinuousJogWorker worker = mock(ContinuousJogWorker.class);
    AnalogJogAction action = new AnalogJogAction(worker, Axis.Y);
    // Simulate the controller in running state
    action.UGSEvent(new ControllerStateEvent(ControllerState.IDLE, ControllerState.IDLE));
    action.actionPerformed(null);
    assertTrue(action.isEnabled());
    verify(worker, times(1)).setDirection(eq(Axis.Y), anyFloat());
}
Also used : ControllerStateEvent(com.willwinder.universalgcodesender.model.events.ControllerStateEvent) ContinuousJogWorker(com.willwinder.universalgcodesender.utils.ContinuousJogWorker) Test(org.junit.Test)

Example 2 with ContinuousJogWorker

use of com.willwinder.universalgcodesender.utils.ContinuousJogWorker in project Universal-G-Code-Sender by winder.

the class AnalogJogActionTest method actionPerformedShouldNotGenerateJogCommandsWhenStateIsDoor.

@Test
public void actionPerformedShouldNotGenerateJogCommandsWhenStateIsDoor() {
    ContinuousJogWorker worker = mock(ContinuousJogWorker.class);
    AnalogJogAction action = new AnalogJogAction(worker, Axis.Y);
    // Simulate the controller in running state
    action.UGSEvent(new ControllerStateEvent(ControllerState.DOOR, ControllerState.IDLE));
    action.actionPerformed(null);
    assertFalse(action.isEnabled());
    verifyNoInteractions(worker);
}
Also used : ControllerStateEvent(com.willwinder.universalgcodesender.model.events.ControllerStateEvent) ContinuousJogWorker(com.willwinder.universalgcodesender.utils.ContinuousJogWorker) Test(org.junit.Test)

Example 3 with ContinuousJogWorker

use of com.willwinder.universalgcodesender.utils.ContinuousJogWorker in project Universal-G-Code-Sender by winder.

the class AnalogJogActionTest method actionPerformedShouldGenerateJogCommandsWhenStateIsJog.

@Test
public void actionPerformedShouldGenerateJogCommandsWhenStateIsJog() {
    ContinuousJogWorker worker = mock(ContinuousJogWorker.class);
    AnalogJogAction action = new AnalogJogAction(worker, Axis.Y);
    // Simulate the controller in running state
    action.UGSEvent(new ControllerStateEvent(ControllerState.JOG, ControllerState.IDLE));
    action.actionPerformed(null);
    assertTrue(action.isEnabled());
    verify(worker, times(1)).setDirection(eq(Axis.Y), anyFloat());
}
Also used : ControllerStateEvent(com.willwinder.universalgcodesender.model.events.ControllerStateEvent) ContinuousJogWorker(com.willwinder.universalgcodesender.utils.ContinuousJogWorker) Test(org.junit.Test)

Example 4 with ContinuousJogWorker

use of com.willwinder.universalgcodesender.utils.ContinuousJogWorker in project Universal-G-Code-Sender by winder.

the class AnalogJogActionTest method setValueShouldSetThePercentageToUse.

@Test
public void setValueShouldSetThePercentageToUse() {
    ContinuousJogWorker worker = mock(ContinuousJogWorker.class);
    AnalogJogAction action = new AnalogJogAction(worker, Axis.Y);
    // Simulate the controller in running state
    action.setValue(0.6f);
    action.UGSEvent(new ControllerStateEvent(ControllerState.JOG, ControllerState.IDLE));
    action.actionPerformed(null);
    assertTrue(action.isEnabled());
    verify(worker, times(1)).setDirection(eq(Axis.Y), eq(0.6f));
}
Also used : ControllerStateEvent(com.willwinder.universalgcodesender.model.events.ControllerStateEvent) ContinuousJogWorker(com.willwinder.universalgcodesender.utils.ContinuousJogWorker) Test(org.junit.Test)

Example 5 with ContinuousJogWorker

use of com.willwinder.universalgcodesender.utils.ContinuousJogWorker in project Universal-G-Code-Sender by winder.

the class AnalogJogActionTest method actionPerformedShouldNotGenerateJogCommandsWhenStateIsRunning.

@Test
public void actionPerformedShouldNotGenerateJogCommandsWhenStateIsRunning() {
    ContinuousJogWorker worker = mock(ContinuousJogWorker.class);
    AnalogJogAction action = new AnalogJogAction(worker, Axis.Y);
    // Simulate the controller in running state
    action.UGSEvent(new ControllerStateEvent(ControllerState.RUN, ControllerState.IDLE));
    action.actionPerformed(null);
    assertFalse(action.isEnabled());
    verifyNoInteractions(worker);
}
Also used : ControllerStateEvent(com.willwinder.universalgcodesender.model.events.ControllerStateEvent) ContinuousJogWorker(com.willwinder.universalgcodesender.utils.ContinuousJogWorker) Test(org.junit.Test)

Aggregations

ControllerStateEvent (com.willwinder.universalgcodesender.model.events.ControllerStateEvent)5 ContinuousJogWorker (com.willwinder.universalgcodesender.utils.ContinuousJogWorker)5 Test (org.junit.Test)5