-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathjlpTest.java
102 lines (89 loc) · 3.72 KB
/
jlpTest.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
/*
* 11/19/2004 : 1.0 moved to LGPL.
* 01/01/2004 : Initial version by E.B [email protected]
*-----------------------------------------------------------------------
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as published
* by the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*----------------------------------------------------------------------
*/
package javazoom.jl.player;
import java.io.InputStream;
import java.util.Properties;
import javazoom.jl.player.my.MyJavaSoundAudioDevice;
import javazoom.jl.player.my.MyJavaSoundAudioDeviceFactory;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import vavix.util.DelayedWorker;
import static org.junit.jupiter.api.Assertions.assertTrue;
/**
* Simple player unit test.
* It takes around 3-6% of CPU and 10MB RAM under Win2K/PIII/1GHz/JDK1.5.0
* It takes around 10-12% of CPU and 10MB RAM under Win2K/PIII/1GHz/JDK1.4.1
* It takes around 08-10% of CPU and 10MB RAM under Win2K/PIII/1GHz/JDK1.3.1
*
* @since 0.4
*/
class jlpTest {
static final float volume = (float) Double.parseDouble(System.getProperty("vavi.test.volume", "0.2"));
private Properties props = null;
private String filename = null;
long time;
@BeforeEach
void setUp() throws Exception {
props = new Properties();
InputStream pin = getClass().getClassLoader().getResourceAsStream("test.mp3.properties");
props.load(pin);
String basefile = props.getProperty("basefile");
String name = props.getProperty("filename");
filename = basefile + name;
System.err.println(filename);
time = System.getProperty("vavi.test", "").equals("ide") ? 100000 : 3000;
}
@Test
@DisplayName("original audio device")
void testPlay() throws Exception {
String[] args = new String[1];
args[0] = filename;
jlp player = jlp.createInstance(args);
player.setAudioDevice(FactoryRegistry.systemRegistry().createAudioDevice(JavaSoundAudioDeviceFactory.class));
DelayedWorker.later(3000, player::stop);
player.play();
assertTrue(true, "Play");
}
@Test
@DisplayName("my audio device w/ volume")
void testPlay2() throws Exception {
String[] args = new String[1];
args[0] = filename;
jlp player = jlp.createInstance(args);
// my audio device might have first priority
((MyJavaSoundAudioDevice) player.setAudioDevice()).setVolume(volume);
DelayedWorker.later(3000, player::stop);
player.play();
assertTrue(true, "Play");
}
@Test
@DisplayName("specified my audio device w/ volume")
void testPlay3() throws Exception {
String[] args = new String[1];
args[0] = filename;
jlp player = jlp.createInstance(args);
player.setAudioDevice(FactoryRegistry.systemRegistry().createAudioDevice(MyJavaSoundAudioDeviceFactory.class));
((MyJavaSoundAudioDevice) player.setAudioDevice()).setVolume(volume);
DelayedWorker.later(3000, player::stop);
player.play();
assertTrue(true, "Play");
}
}