Index: modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/PortInfoTest.java =================================================================== --- modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/PortInfoTest.java (revision 0) +++ modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/PortInfoTest.java (revision 0) @@ -0,0 +1,48 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.harmony.sound.tests.javax.sound.sampled; + +import javax.sound.sampled.Port; + +import junit.framework.TestCase; + +public class PortInfoTest extends TestCase { + + public void testPortInfo() { + assertEquals("COMPACT_DISC source port", Port.Info.COMPACT_DISC.toString()); + assertEquals("LINE_OUT target port", Port.Info.LINE_OUT.toString()); + + Class cl = Port.class; + String name = "name"; + Port.Info pi1 = new Port.Info(cl, name, true); + assertEquals(name, pi1.getName()); + assertTrue(pi1.isSource()); + + Port.Info pi2 = new Port.Info(cl, name, true); + assertFalse(pi1.equals(pi2)); + assertTrue(pi1.equals(pi1)); + assertTrue(pi1.matches(pi2)); + assertTrue(pi2.matches(pi1)); + + pi2 = new Port.Info(cl, "name1", false); + assertTrue(pi1.matches(pi1)); + assertFalse(pi1.matches(pi2)); + assertFalse(pi2.matches(pi1)); + } + +} Index: modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/MixerTest.java =================================================================== --- modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/MixerTest.java (revision 0) +++ modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/MixerTest.java (revision 0) @@ -0,0 +1,50 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.harmony.sound.tests.javax.sound.sampled; + +import javax.sound.sampled.Mixer; + +import junit.framework.TestCase; + +public class MixerTest extends TestCase { + + public void testMixer() { + + Mixer.Info info = new MyMixerInfo("NAME", "VENDOR", "DESCRIPTION", + "VERSION"); + assertEquals("DESCRIPTION", info.getDescription()); + assertEquals("NAME", info.getName()); + assertEquals("VENDOR", info.getVendor()); + assertEquals("VERSION", info.getVersion()); + assertEquals("NAME, version VERSION", info.toString()); + } + + public void testEquals() { + Mixer.Info mi1 = new MyMixerInfo("1", "2", "3", "4"); + Mixer.Info mi2 = new MyMixerInfo("1", "2", "3", "4"); + assertFalse(mi1.equals(mi2)); + assertTrue(mi1.equals(mi1)); + } + + private class MyMixerInfo extends Mixer.Info { + public MyMixerInfo(String name, String vendor, String description, + String version) { + super(name, vendor, description, version); + } + } +} \ No newline at end of file Index: modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/FloatControlTest.java =================================================================== --- modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/FloatControlTest.java (revision 0) +++ modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/FloatControlTest.java (revision 0) @@ -0,0 +1,90 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.harmony.sound.tests.javax.sound.sampled; + +import javax.sound.sampled.FloatControl; + +import junit.framework.TestCase; + +public class FloatControlTest extends TestCase { + + public void testFloatControl() { + + FloatControl control = new MyControl(FloatControl.Type.MASTER_GAIN, 1f, + 10f, 3f, 4, 5f, "units", "minLabel", "midLabel", "maxLabel"); + + assertEquals(FloatControl.Type.MASTER_GAIN, control.getType()); + assertEquals(1f, control.getMinimum()); + assertEquals(10f, control.getMaximum()); + assertEquals("units", control.getUnits()); + assertEquals("minLabel", control.getMinLabel()); + assertEquals("midLabel", control.getMidLabel()); + assertEquals("maxLabel", control.getMaxLabel()); + assertEquals(3f, control.getPrecision()); + assertEquals(4, control.getUpdatePeriod()); + + assertEquals(5f, control.getValue()); + control.setValue(9f); + assertEquals(9f, control.getValue()); + control.shift(9f, 4f, 5); + assertEquals(4f, control.getValue()); + assertEquals( + "Master Gain with current value: 4.0 units (range: 1.0 - 10.0)", + control.toString()); + + try { + control.setValue(15f); + fail("No expected IllegalArgumentException"); + } catch (IllegalArgumentException expected) { + } + + control = new MyControl(FloatControl.Type.SAMPLE_RATE, 1f, 10f, 3f, 4, + 5f, "units"); + assertEquals(FloatControl.Type.SAMPLE_RATE, control.getType()); + assertEquals(1f, control.getMinimum()); + assertEquals(10f, control.getMaximum()); + assertEquals("units", control.getUnits()); + assertEquals("", control.getMinLabel()); + assertEquals("", control.getMidLabel()); + assertEquals("", control.getMaxLabel()); + assertEquals(3f, control.getPrecision()); + assertEquals(4, control.getUpdatePeriod()); + assertEquals(5f, control.getValue()); + assertEquals( + "Sample Rate with current value: 5.0 units (range: 1.0 - 10.0)", + control.toString()); + + } + + private class MyControl extends FloatControl { + public MyControl(FloatControl.Type type, float minimum, float maximum, + float precision, int updatePeriod, float initialValue, + String units, String minLabel, String midLabel, String maxLabel) { + super(type, minimum, maximum, precision, updatePeriod, + initialValue, units, minLabel, midLabel, maxLabel); + } + + public MyControl(FloatControl.Type type, float minimum, float maximum, + float precision, int updatePeriod, float initialValue, + String units) { + super(type, minimum, maximum, precision, updatePeriod, + initialValue, units); + } + } + +} \ No newline at end of file Index: modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/ReverbTypeTest.java =================================================================== --- modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/ReverbTypeTest.java (revision 0) +++ modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/ReverbTypeTest.java (revision 0) @@ -0,0 +1,53 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.harmony.sound.tests.javax.sound.sampled; + +import javax.sound.sampled.ReverbType; + +import junit.framework.TestCase; + +public class ReverbTypeTest extends TestCase { + + public void testReverbType() { + ReverbType rt1 = new MyReverbType("name", 1, 2f, 3, 4f, 5); + + assertEquals( + "name, early reflection delay 1 ns, early reflection intensity 2.0 dB, late deflection delay 3 ns, late reflection intensity 4.0 dB, decay time 5", + rt1.toString()); + assertEquals("name", rt1.getName()); + assertEquals(1, rt1.getEarlyReflectionDelay()); + assertEquals(2f, rt1.getEarlyReflectionIntensity()); + assertEquals(3, rt1.getLateReflectionDelay()); + assertEquals(4f, rt1.getLateReflectionIntensity()); + assertEquals(5, rt1.getDecayTime()); + + ReverbType rt2 = new MyReverbType("name", 1, 2f, 3, 4f, 5); + assertFalse(rt1.equals(rt2)); + assertTrue(rt1.equals(rt1)); + } + + private class MyReverbType extends ReverbType { + public MyReverbType(String name, int earlyReflectionDelay, + float earlyReflectionIntensity, int lateReflectionDelay, + float lateReflectionIntensity, int decayTime) { + + super(name, earlyReflectionDelay, earlyReflectionIntensity, + lateReflectionDelay, lateReflectionIntensity, decayTime); + } + } +} Index: modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/LineEventTest.java =================================================================== --- modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/LineEventTest.java (revision 0) +++ modules/sound/src/test/java/org/apache/harmony/sound/tests/javax/sound/sampled/LineEventTest.java (revision 0) @@ -0,0 +1,83 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.harmony.sound.tests.javax.sound.sampled; + +import javax.sound.sampled.Control; +import javax.sound.sampled.Line; +import javax.sound.sampled.LineEvent; +import javax.sound.sampled.LineListener; +import javax.sound.sampled.LineUnavailableException; + +import junit.framework.TestCase; + +public class LineEventTest extends TestCase { + + public void testLineEvent() { + + Line line = new MyLine(); + LineEvent le = new LineEvent(line, LineEvent.Type.CLOSE, 1l); + assertEquals(line, le.getSource()); + assertEquals(1, le.getFramePosition()); + assertEquals(line, le.getLine()); + assertEquals(LineEvent.Type.CLOSE, le.getType()); + assertEquals("Close event from line MyLine", le.toString()); + + } + + private class MyLine implements Line { + + public MyLine() { + } + + public void addLineListener(LineListener listener) { + } + + public void close() { + } + + public Control getControl(Control.Type control) { + return null; + } + + public Control[] getControls() { + return null; + } + + public Line.Info getLineInfo() { + return null; + } + + public boolean isControlSupported(Control.Type control) { + return false; + } + + public boolean isOpen() { + return false; + } + + public void open() throws LineUnavailableException { + } + + public void removeLineListener(LineListener listener) { + } + + public String toString() { + return "MyLine"; + } + } +} \ No newline at end of file