Skip to content

Commit

Permalink
WIP test for proper ignore of property change event while moving slider.
Browse files Browse the repository at this point in the history
  • Loading branch information
pabender committed Oct 31, 2018
1 parent 521bc46 commit bb489d0
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
Expand Up @@ -36,4 +36,10 @@ public String getLastInfo(){
return lastInfo; return lastInfo;
} }


public void reset(){
lastPacket = null;
lastAlert = null;
lastInfo = null;
}

} }
28 changes: 28 additions & 0 deletions java/test/jmri/jmrit/withrottle/MultiThrottleControllerTest.java
Expand Up @@ -196,6 +196,34 @@ public void testQuitWithAddress(){
Assert.assertEquals("Velocity set",0.0f,t.getSpeedSetting(),0.0005f); Assert.assertEquals("Velocity set",0.0f,t.getSpeedSetting(),0.0005f);
} }


@Test
public void testVelocityChangeSequence() {
jmri.DccThrottle t = new jmri.jmrix.debugthrottle.DebugThrottle(new jmri.DccLocoAddress(1,false),null){
@Override
public void setSpeedSetting(float s){
// override so we can send property changes in sequence.
}
};
controller.notifyThrottleFound(t);
cis.reset();
// withrottle may actually sends more than one speed change when
// moving the slider.
Assert.assertTrue("Continue after velicity",controller.sort("V7"));
Assert.assertTrue("Continue after velicity",controller.sort("V15"));
Assert.assertTrue("Continue after velicity",controller.sort("V25"));
controller.propertyChange(new PropertyChangeEvent(this,"SpeedSetting",0.0,7.0/126.0));
Assert.assertNull("outgoing message after property change", cis.getLastPacket() );
Assert.assertTrue("Continue after velicity",controller.sort("V32"));
Assert.assertTrue("Continue after velicity",controller.sort("V45"));
Assert.assertTrue("Continue after velicity",controller.sort("V63"));
controller.propertyChange(new PropertyChangeEvent(this,"SpeedSetting",7.0/126.0,15.0/126.0));
Assert.assertNull("outgoing message after property change", cis.getLastPacket() );
controller.propertyChange(new PropertyChangeEvent(this,"SpeedSetting",15.0/126.0,25.0/126.0));
Assert.assertNull("outgoing message after property change", cis.getLastPacket() );
controller.propertyChange(new PropertyChangeEvent(this,"SpeedSetting",0.0,63.0/126.0));
Assert.assertEquals("outgoing message after property change", "MAAtest<;>V63",cis.getLastPacket() );
}

@Before @Before
public void setUp() throws Exception { public void setUp() throws Exception {
JUnitUtil.setUp(); JUnitUtil.setUp();
Expand Down

0 comments on commit bb489d0

Please sign in to comment.