use of org.eclipse.smarthome.binding.dmx.internal.action.FadeAction in project smarthome by eclipse.
the class FadeActionTest method checkWithoutFadingWithoutHold.
@Test
public void checkWithoutFadingWithoutHold() {
FadeAction fadeAction = new FadeAction(0, testValue, 0);
DmxChannel testChannel = new DmxChannel(0, 1, 0);
testChannel.setValue(0);
long startTime = System.currentTimeMillis();
assertThat(fadeAction.getState(), is(ActionState.WAITING));
assertThat(fadeAction.getNewValue(testChannel, startTime), is(256 * testValue));
assertThat(fadeAction.getState(), is(ActionState.COMPLETED));
fadeAction.reset();
assertThat(fadeAction.getState(), is(ActionState.WAITING));
}
use of org.eclipse.smarthome.binding.dmx.internal.action.FadeAction in project smarthome by eclipse.
the class FadeActionTest method checkWithFadingWithHold.
@Test
public void checkWithFadingWithHold() {
FadeAction fadeAction = new FadeAction(testFadeTime, testValue, testHoldTime);
DmxChannel testChannel = new DmxChannel(0, 1, 0);
testChannel.setValue(0);
long startTime = System.currentTimeMillis();
assertThat(fadeAction.getState(), is(ActionState.WAITING));
assertThat(fadeAction.getNewValue(testChannel, startTime), is(0));
assertThat(fadeAction.getState(), is(ActionState.RUNNING));
assertThat(fadeAction.getNewValue(testChannel, startTime + testFadeTime / 2), is(256 * testValue / 2));
assertThat(fadeAction.getNewValue(testChannel, startTime + testFadeTime), is(256 * testValue));
assertThat(fadeAction.getState(), is(ActionState.RUNNING));
assertThat(fadeAction.getNewValue(testChannel, startTime + testFadeTime + testHoldTime / 2), is(256 * testValue));
assertThat(fadeAction.getState(), is(ActionState.RUNNING));
assertThat(fadeAction.getNewValue(testChannel, startTime + testFadeTime + testHoldTime), is(256 * testValue));
assertThat(fadeAction.getState(), is(ActionState.COMPLETED));
fadeAction.reset();
assertThat(fadeAction.getState(), is(ActionState.WAITING));
}
use of org.eclipse.smarthome.binding.dmx.internal.action.FadeAction in project smarthome by eclipse.
the class DmxChannelTest method checkMultipleInfiniteFadeAction.
@Test
public void checkMultipleInfiniteFadeAction() {
dmxChannel.addChannelAction(new FadeAction(1000, 243, 0));
dmxChannel.addChannelAction(new FadeAction(1000, 127, 0));
dmxChannel.getNewValue(currentTime);
assertThat(dmxChannel.hasRunningActions(), is(true));
Mockito.verify(dimmerThingHandler).updateChannelValue(valueChannelUID, 0);
// check first action completes
dmxChannel.getNewValue(currentTime);
currentTime += 1000;
dmxChannel.getNewValue(currentTime);
assertThat(dmxChannel.hasRunningActions(), is(true));
Mockito.verify(dimmerThingHandler).updateChannelValue(valueChannelUID, 243);
// check second action completes
dmxChannel.getNewValue(currentTime);
currentTime += 1000;
dmxChannel.getNewValue(currentTime);
assertThat(dmxChannel.hasRunningActions(), is(true));
Mockito.verify(dimmerThingHandler).updateChannelValue(valueChannelUID, 127);
// check first action completes again
currentTime += 1000;
dmxChannel.getNewValue(currentTime);
assertThat(dmxChannel.hasRunningActions(), is(true));
Mockito.verify(dimmerThingHandler).updateChannelValue(valueChannelUID, 243);
}
use of org.eclipse.smarthome.binding.dmx.internal.action.FadeAction in project smarthome by eclipse.
the class DmxChannelTest method setAndClearAction.
@Test
public void setAndClearAction() {
// has action
dmxChannel.setChannelAction(new FadeAction(0, 100, -1));
assertThat(dmxChannel.hasRunningActions(), is(true));
// clear action
dmxChannel.clearAction();
assertThat(dmxChannel.hasRunningActions(), is(false));
}
Aggregations