Changeset 15755 in josm for trunk/test/unit/org


Ignore:
Timestamp:
2020-01-23T22:57:46+01:00 (4 years ago)
Author:
simon04
Message:

Introduce Stopwatch class to measure elapsed time

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/io/audio/AudioPlayerTest.java

    r12327 r15755  
    1414import org.openstreetmap.josm.JOSMFixture;
    1515import org.openstreetmap.josm.TestUtils;
    16 import org.openstreetmap.josm.tools.Utils;
     16import org.openstreetmap.josm.tools.Stopwatch;
    1717
    1818/**
     
    4646            System.out.println("Playing " + w.toPath());
    4747            URL url = w.toURI().toURL();
    48             long start = System.currentTimeMillis();
     48            final Stopwatch stopwatch = Stopwatch.createStarted();
    4949            AudioPlayer.play(url);
    5050            assertTrue(AudioPlayer.playing());
     
    5454            assertTrue(AudioPlayer.paused());
    5555            AudioPlayer.play(url, AudioPlayer.position());
    56             while (AudioPlayer.playing() && (System.currentTimeMillis() - start) < MAX_DURATION) {
     56            while (AudioPlayer.playing() && stopwatch.elapsed() < MAX_DURATION) {
    5757                Thread.sleep(500);
    5858            }
    59             long duration = System.currentTimeMillis() - start;
    60             System.out.println("Play finished after " + Utils.getDurationString(duration));
    61             assertTrue(duration < MAX_DURATION);
     59            System.out.println("Play finished after " + stopwatch);
     60            assertTrue(stopwatch.elapsed() < MAX_DURATION);
    6261            AudioPlayer.reset();
    6362            Thread.sleep(1000); // precaution, see #13809
Note: See TracChangeset for help on using the changeset viewer.