source: josm/trunk/test/unit/org/openstreetmap/josm/tools/AudioPlayerTest.java@ 11220

Last change on this file since 11220 was 11220, checked in by bastiK, 7 years ago

fixed #13809 - Jenkins build hangs (disable AudioPlayerTest)

  • Property svn:eol-style set to native
File size: 2.3 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package org.openstreetmap.josm.tools;
3
4import static org.junit.Assert.assertFalse;
5import static org.junit.Assert.assertTrue;
6
7import java.io.File;
8import java.net.MalformedURLException;
9import java.net.URL;
10
11import org.junit.BeforeClass;
12import org.junit.Ignore;
13import org.junit.Test;
14import org.openstreetmap.josm.JOSMFixture;
15import org.openstreetmap.josm.TestUtils;
16
17/**
18 * Unit tests of {@link AudioPlayer} class.
19 */
20@Ignore("unresolved sporadic deadlock - see #13809")
21public class AudioPlayerTest {
22
23 // We play wav files of about 4 seconds + pause, so define timeout at 16 seconds
24 private static final long MAX_DURATION = 16000;
25
26 /**
27 * Setup test.
28 */
29 @BeforeClass
30 public static void setUp() {
31 JOSMFixture.createUnitTestFixture().init();
32 }
33
34 /**
35 * Test method for {@code AudioPlayer#play(URL)}
36 * @throws Exception audio fault exception, e.g. can't open stream, unhandleable audio format
37 * @throws MalformedURLException wrong URL
38 */
39 @Test(timeout = 4*MAX_DURATION)
40 public void testPlay() throws MalformedURLException, Exception {
41 File wav1 = new File(TestUtils.getRegressionDataFile(6851, "20111003_121226.wav"));
42 File wav2 = new File(TestUtils.getRegressionDataFile(6851, "20111003_121557.wav"));
43
44 for (File w : new File[] {wav1, wav2}) {
45 System.out.println("Playing " + w.toPath());
46 URL url = w.toURI().toURL();
47 long start = System.currentTimeMillis();
48 AudioPlayer.play(url);
49 assertTrue(AudioPlayer.playing());
50 assertFalse(AudioPlayer.paused());
51 AudioPlayer.pause();
52 assertFalse(AudioPlayer.playing());
53 assertTrue(AudioPlayer.paused());
54 AudioPlayer.play(url, AudioPlayer.position());
55 while (AudioPlayer.playing() && (System.currentTimeMillis() - start) < MAX_DURATION) {
56 Thread.sleep(500);
57 }
58 long duration = System.currentTimeMillis() - start;
59 System.out.println("Play finished after " + Utils.getDurationString(duration));
60 assertTrue(duration < MAX_DURATION);
61 AudioPlayer.reset();
62 Thread.sleep(1000); // precaution, see #13809
63 }
64 }
65}
Note: See TracBrowser for help on using the repository browser.