/* * Copyright (c) 2003, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code 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 General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
/** * Execute the test on all available Sequencers. * * @return true if the test passed for all Sequencers, false otherwise
*/ privatestaticboolean testAll() throws Exception { boolean result = true;
MidiDevice.Info[] devices = MidiSystem.getMidiDeviceInfo(); for (int i = 0; i < devices.length; i++) {
MidiDevice device = MidiSystem.getMidiDevice(devices[i]); if (device instanceof Sequencer) {
result &= testSequencer((Sequencer) device);
}
} return result;
}
/** * Execute the test on the passed Sequencer. * * @return true if the test is passed this Sequencer, false otherwise
*/ privatestaticboolean testSequencer(Sequencer seq) throws Exception{ boolean result = true;
out("testing: " + seq);
try { if (seq.getLoopStartPoint() != 0) {
out("start point", isSequenceLoaded, "isn't 0!");
result = false;
}
} catch (IllegalArgumentException iae) { if (!isSequenceLoaded) {
out("Caught permissable IllegalArgumentException:");
} else {
out("Threw unacceptable IllegalArgumentException! FAILED");
result = false;
}
out(iae.toString());
}
if (seq.getLoopEndPoint() != -1) {
out("end point", isSequenceLoaded, "isn't -1!");
result = false;
}
try {
seq.setLoopStartPoint(25); if (seq.getLoopStartPoint() != 25) {
out("setLoopStartPoint()", isSequenceLoaded, "doesn't set the start point correctly!");
result = false;
}
} catch (IllegalArgumentException iae) { if (!isSequenceLoaded) {
out("Caught permissable IllegalArgumentException:");
} else {
out("Threw unacceptable IllegalArgumentException! FAILED");
result = false;
}
out(iae.toString());
}
try {
seq.setLoopEndPoint(26); if (seq.getLoopEndPoint() != 26) {
out("setLoopEndPoint()", isSequenceLoaded, "doesn't set the end point correctly!");
result = false;
}
} catch (IllegalArgumentException iae) { if (!isSequenceLoaded) {
out("Caught permissable IllegalArgumentException:");
} else {
out("Threw unacceptable IllegalArgumentException! FAILED");
result = false;
}
out(iae.toString());
}
try {
seq.setLoopStartPoint(0); if (seq.getLoopStartPoint() != 0) {
out("setLoopStartPoint()", isSequenceLoaded, "doesn't set the start point correctly!");
result = false;
}
} catch (IllegalArgumentException iae) { if (!isSequenceLoaded) {
out("Caught permissable IllegalArgumentException:");
} else {
out("Threw unacceptable IllegalArgumentException! FAILED");
result = false;
}
out(iae.toString());
}
if (isSequenceLoaded) {
seq.setLoopEndPoint(sequence.getTickLength()); if (seq.getLoopEndPoint() != sequence.getTickLength()) {
out("setLoopEndPoint()", isSequenceLoaded, "doesn't set the end point correctly!");
result = false;
}
} else { // fails
seq.setLoopEndPoint(-1); if (seq.getLoopEndPoint() != -1) {
out("setLoopEndPoint()", isSequenceLoaded, "doesn't set the end point correctly!");
result = false;
}
}
if (seq.getLoopCount() != 0) {
out("loop count", isSequenceLoaded, "isn't 0!");
result = false;
}
seq.setLoopCount(1001); if (seq.getLoopCount() != 1001) {
out("setLoopCount()", isSequenceLoaded, "doesn't set the loop count correctly!");
result = false;
}
seq.setLoopCount(Sequencer.LOOP_CONTINUOUSLY); if (seq.getLoopCount() != Sequencer.LOOP_CONTINUOUSLY) {
out("setLoopCount(Sequencer.LOOP_CONTINUOUSLY)", isSequenceLoaded, "doesn't set the loop count correctly!");
result = false;
}
try {
seq.setLoopCount(-55);
out("setLoopCount()", isSequenceLoaded, "doesn't throw IllegalArgumentException on illegal value!");
result = false;
} catch (IllegalArgumentException e) { // EXCEPTION IS EXPECTED
out("Caught permissable IAE");
}
seq.setLoopCount(0); if (seq.getLoopCount() != 0) {
out("setLoopCount()", isSequenceLoaded, "doesn't set the loop count correctly!");
result = false;
}
return result;
}
privatestaticboolean testPlay(Sequencer seq) { boolean result = true; long stopTime;
publicvoid meta(MetaMessage m) {
System.out.print(" Got MetaMessage: "); if (m.getType() == 47) {
stopTime = System.currentTimeMillis();
System.out.println(" End Of Track -- OK");
} else {
System.out.println(" unknown. Ignored.");
}
}
publiclong getStopTime() { return stopTime;
}
}
}
Messung V0.5
¤ Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.0.12Bemerkung:
(vorverarbeitet)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.