Controller.java revision 8729:0242fce0f717
1233294Sstas/* 2178825Sdfr * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. 3178825Sdfr * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4178825Sdfr * 5178825Sdfr * This code is free software; you can redistribute it and/or modify it 6178825Sdfr * under the terms of the GNU General Public License version 2 only, as 7178825Sdfr * published by the Free Software Foundation. 8178825Sdfr * 9178825Sdfr * This code is distributed in the hope that it will be useful, but WITHOUT 10178825Sdfr * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11178825Sdfr * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12178825Sdfr * version 2 for more details (a copy is included in the LICENSE file that 13178825Sdfr * accompanied this code). 14178825Sdfr * 15178825Sdfr * You should have received a copy of the GNU General Public License version 16178825Sdfr * 2 along with this work; if not, write to the Free Software Foundation, 17178825Sdfr * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18178825Sdfr * 19178825Sdfr * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20178825Sdfr * or visit www.oracle.com if you need additional information or have any 21178825Sdfr * questions. 22178825Sdfr */ 23178825Sdfr 24178825Sdfr/* @test 25178825Sdfr @summary Test SoftChannel controller method */ 26178825Sdfr 27178825Sdfrimport javax.sound.midi.*; 28178825Sdfrimport javax.sound.sampled.*; 29178825Sdfr 30178825Sdfrimport com.sun.media.sound.*; 31178825Sdfr 32233294Sstaspublic class Controller { 33178825Sdfr 34178825Sdfr private static void assertEquals(Object a, Object b) throws Exception 35178825Sdfr { 36178825Sdfr if(!a.equals(b)) 37178825Sdfr throw new RuntimeException("assertEquals fails!"); 38178825Sdfr } 39178825Sdfr 40178825Sdfr private static void assertTrue(boolean value) throws Exception 41178825Sdfr { 42178825Sdfr if(!value) 43178825Sdfr throw new RuntimeException("assertTrue fails!"); 44178825Sdfr } 45178825Sdfr 46178825Sdfr public static void main(String[] args) throws Exception { 47178825Sdfr SoftTestUtils soft = new SoftTestUtils(); 48178825Sdfr MidiChannel channel = soft.synth.getChannels()[0]; 49178825Sdfr 50178825Sdfr for (int i = 0; i < 128; i++) { 51178825Sdfr if(i == 0 || i == 32) continue; 52178825Sdfr channel.controlChange(i, 10); 53178825Sdfr assertEquals(channel.getController(i), 10); 54178825Sdfr channel.controlChange(i, 100); 55178825Sdfr assertEquals(channel.getController(i), 100); 56178825Sdfr } 57178825Sdfr 58178825Sdfr soft.close(); 59178825Sdfr } 60178825Sdfr} 61178825Sdfr