author | prr |
Fri, 25 May 2018 12:12:24 -0700 | |
changeset 50347 | b2f046ae8eb6 |
parent 47216 | 71c04702a3d5 |
permissions | -rw-r--r-- |
1846
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
1 |
/* |
31448
1066345d2a8a
8076468: Add @modules to tests in jdk_desktop test group
yan
parents:
23010
diff
changeset
|
2 |
* Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. |
1846
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
4 |
* |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
21596 | 7 |
* published by the Free Software Foundation. |
1846
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
8 |
* |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
13 |
* accompanied this code). |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
14 |
* |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
18 |
* |
5506 | 19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
20 |
* or visit www.oracle.com if you need additional information or have any |
|
21 |
* questions. |
|
1846
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
22 |
*/ |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
23 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
24 |
/* @test |
31448
1066345d2a8a
8076468: Add @modules to tests in jdk_desktop test group
yan
parents:
23010
diff
changeset
|
25 |
@summary Test SimpleInstrument setPatch(Patch) method |
1066345d2a8a
8076468: Add @modules to tests in jdk_desktop test group
yan
parents:
23010
diff
changeset
|
26 |
@modules java.desktop/com.sun.media.sound |
1066345d2a8a
8076468: Add @modules to tests in jdk_desktop test group
yan
parents:
23010
diff
changeset
|
27 |
*/ |
1846
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
28 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
29 |
import javax.sound.midi.Patch; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
30 |
import javax.sound.sampled.*; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
31 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
32 |
import com.sun.media.sound.*; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
33 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
34 |
public class SetPatch { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
35 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
36 |
private static void assertEquals(Object a, Object b) throws Exception |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
37 |
{ |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
38 |
if(!a.equals(b)) |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
39 |
throw new RuntimeException("assertEquals fails!"); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
40 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
41 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
42 |
public static void main(String[] args) throws Exception { |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
43 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
44 |
SimpleInstrument instrument = new SimpleInstrument(); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
45 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
46 |
ModelPerformer[] performers = new ModelPerformer[2]; |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
47 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
48 |
performers[0] = new ModelPerformer(); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
49 |
performers[0].setExclusiveClass(1); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
50 |
performers[0].setKeyFrom(36); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
51 |
performers[0].setKeyTo(48); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
52 |
performers[0].setVelFrom(16); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
53 |
performers[0].setVelTo(80); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
54 |
performers[0].setSelfNonExclusive(true); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
55 |
performers[0].setDefaultConnectionsEnabled(false); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
56 |
performers[0].getConnectionBlocks().add(new ModelConnectionBlock()); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
57 |
performers[0].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
58 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
59 |
performers[1] = new ModelPerformer(); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
60 |
performers[1].setExclusiveClass(0); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
61 |
performers[1].setKeyFrom(12); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
62 |
performers[1].setKeyTo(24); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
63 |
performers[1].setVelFrom(20); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
64 |
performers[1].setVelTo(90); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
65 |
performers[1].setSelfNonExclusive(false); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
66 |
performers[0].setDefaultConnectionsEnabled(true); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
67 |
performers[1].getConnectionBlocks().add(new ModelConnectionBlock()); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
68 |
performers[1].getOscillators().add(new ModelByteBufferWavetable(new ModelByteBuffer(new byte[] {1,2,3}))); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
69 |
|
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
70 |
Patch patch = new Patch(0,36); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
71 |
instrument.setPatch(patch); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
72 |
assertEquals(instrument.getPatch().getProgram(), patch.getProgram()); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
73 |
assertEquals(instrument.getPatch().getBank(), patch.getBank()); |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
74 |
} |
4a53d636e2f4
6702956: OpenJDK: replace encumbered code (software synthesizer)
amenkov
parents:
diff
changeset
|
75 |
} |