Skip to content
Permalink
Browse files

listener test

  • Loading branch information...
bobjacobsen committed Sep 23, 2018
1 parent 0bea019 commit d2a4441ff3ff49f3a8cd3178f40ce6f9c8b0f87b
Showing with 24 additions and 0 deletions.
  1. +24 −0 java/test/jmri/jmrit/simpleclock/SimpleTimebaseTest.java
@@ -1,5 +1,6 @@
package jmri.jmrit.simpleclock;

import java.beans.*;
import java.time.Instant;
import java.util.Date;
import junit.framework.Test;
@@ -109,6 +110,29 @@ public void testSetGetRate() {

}

double seenNewMinutes;
double seenOldMinutes;

public void testSetSendsUpdate() {
SimpleTimebase p = new SimpleTimebase();
p.setRun(false); // prevent clock ticking during test

seenNewMinutes = -1;
seenOldMinutes = -1;
p.addMinuteChangeListener(new PropertyChangeListener() {
public void propertyChange(PropertyChangeEvent e) {
seenOldMinutes = (Double) e.getOldValue();
seenNewMinutes = (Double) e.getNewValue();
}
});

Date date = p.getTime();
Date tenMinLater = new Date(10*60*1000L+date.getTime());

p.setTime(tenMinLater);
Assert.assertEquals(seenOldMinutes + 10.0, seenNewMinutes, 0.01);
}

/* public void testShortDelay() { */
/* SimpleTimebase p = new SimpleTimebase(); */
/* Date now = new Date(); */

0 comments on commit d2a4441

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