Skip to content
Permalink
Browse files

tests for speed slider

  • Loading branch information...
pabender committed Sep 25, 2018
1 parent 97fe3d4 commit 985c360433fb988f64810cd22c6efb527f16c148
@@ -204,6 +204,102 @@ public void testToggleAlt2() {
JUnitUtil.disposeFrame(Bundle.getMessage("ThrottleListFrameTile"), true, true);
}

// Tests for Control (Speed and Direction) panel.

@Test
public void testStopButton() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
ThrottleWindow frame = new ThrottleWindow();
ThrottleFrame panel = new ThrottleFrame(frame);
frame.setExtendedState( frame.getExtendedState()|java.awt.Frame.MAXIMIZED_BOTH );
panel.toFront();

ThrottleOperator to = new ThrottleOperator(Bundle.getMessage("ThrottleTitle"));

to.setAddressValue(new DccLocoAddress(42,false));

to.pushStopButton();
// should verify the throttle is set to stop.
Assert.assertEquals("Speed set to Stop",0,to.getSpeedSliderValue());


to.pushReleaseButton();
to.requestClose();
// the throttle list frame gets created above, but needs to be shown to be disposed
InstanceManager.getDefault(ThrottleFrameManager.class).showThrottlesList();
JUnitUtil.disposeFrame(Bundle.getMessage("ThrottleListFrameTile"), true, true);
}

@Test
public void testEStopButton() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
ThrottleWindow frame = new ThrottleWindow();
ThrottleFrame panel = new ThrottleFrame(frame);
frame.setExtendedState( frame.getExtendedState()|java.awt.Frame.MAXIMIZED_BOTH );
panel.toFront();

ThrottleOperator to = new ThrottleOperator(Bundle.getMessage("ThrottleTitle"));

to.setAddressValue(new DccLocoAddress(42,false));

to.pushEStopButton();
// should verify the throttle is set to stop.
Assert.assertEquals("Speed set to Stop",0,to.getSpeedSliderValue());

to.pushReleaseButton();
to.requestClose();
// the throttle list frame gets created above, but needs to be shown to be disposed
InstanceManager.getDefault(ThrottleFrameManager.class).showThrottlesList();
JUnitUtil.disposeFrame(Bundle.getMessage("ThrottleListFrameTile"), true, true);
}

@Test
public void testSliderMaximumSpeed() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
ThrottleWindow frame = new ThrottleWindow();
ThrottleFrame panel = new ThrottleFrame(frame);
frame.setExtendedState( frame.getExtendedState()|java.awt.Frame.MAXIMIZED_BOTH );
panel.toFront();

ThrottleOperator to = new ThrottleOperator(Bundle.getMessage("ThrottleTitle"));

to.setAddressValue(new DccLocoAddress(42,false));

to.speedSliderMaximum();

Assert.assertEquals("Speed set to Maximum",126,to.getSpeedSliderValue());

to.pushReleaseButton();
to.requestClose();
// the throttle list frame gets created above, but needs to be shown to be disposed
InstanceManager.getDefault(ThrottleFrameManager.class).showThrottlesList();
JUnitUtil.disposeFrame(Bundle.getMessage("ThrottleListFrameTile"), true, true);
}

@Test
public void testSliderMinimumSpeed() {
Assume.assumeFalse(GraphicsEnvironment.isHeadless());
ThrottleWindow frame = new ThrottleWindow();
ThrottleFrame panel = new ThrottleFrame(frame);
frame.setExtendedState( frame.getExtendedState()|java.awt.Frame.MAXIMIZED_BOTH );
panel.toFront();

ThrottleOperator to = new ThrottleOperator(Bundle.getMessage("ThrottleTitle"));

to.setAddressValue(new DccLocoAddress(42,false));

to.setSpeedSlider(28);
to.slideSpeedSlider(1); // jemmy can't slide the slider to zero for some
// reason.
Assert.assertEquals("Speed set to Minimum",1,to.getSpeedSliderValue());

to.pushReleaseButton();
to.requestClose();
// the throttle list frame gets created above, but needs to be shown to be disposed
InstanceManager.getDefault(ThrottleFrameManager.class).showThrottlesList();
JUnitUtil.disposeFrame(Bundle.getMessage("ThrottleListFrameTile"), true, true);
}

@Before
public void setUp() {
JUnitUtil.setUp();
@@ -18,6 +18,7 @@
import org.netbeans.jemmy.operators.JTextFieldOperator;
import org.netbeans.jemmy.operators.JToggleButtonOperator;
import org.netbeans.jemmy.operators.JRadioButtonOperator;
import org.netbeans.jemmy.operators.JSliderOperator;
import org.netbeans.jemmy.util.NameComponentChooser;

/*
@@ -200,4 +201,41 @@ public void toggleFunctionMomentary(int function){

}

// Control (Speed and Direction) panel operations
public JInternalFrameOperator getControlPanelOperator(){
return new JInternalFrameOperator(this,
Bundle.getMessage("ThrottleMenuViewControlPanel"));
}

public void pushStopButton(){
new JButtonOperator(getControlPanelOperator(),
Bundle.getMessage("ButtonStop")).push();
}

public void pushEStopButton(){
new JButtonOperator(getControlPanelOperator(),
Bundle.getMessage("ButtonStop")).push();
}

public int getSpeedSliderValue(){
return new JSliderOperator(getControlPanelOperator()).getValue();
}

public void setSpeedSlider(int i){
new JSliderOperator(getControlPanelOperator()).setValue(i);
}

public void slideSpeedSlider(int i){
new JSliderOperator(getControlPanelOperator()).scrollToValue(i);
}

public void speedSliderMaximum(){
new JSliderOperator(getControlPanelOperator()).scrollToMaximum();
}

public void speedSliderMinimum(){
new JSliderOperator(getControlPanelOperator()).scrollToMinimum();
}


}

0 comments on commit 985c360

Please sign in to comment.
You can’t perform that action at this time.