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());
}