Test playing an audio file with an odd size

This commit is contained in:
Marco Castelluccio 2015-01-27 16:49:00 +01:00
Родитель c2f9bbad29
Коммит cd61c32778
5 изменённых файлов: 31 добавлений и 7 удалений

Просмотреть файл

@ -70,6 +70,7 @@ Media.extToFormat = new Map([
["jpeg", "JPEG"],
["png", "PNG"],
["wav", "wav"],
["ogg", "ogg"],
]);
Media.contentTypeToFormat = new Map([
@ -933,7 +934,7 @@ Native["com/sun/mmedia/MediaDownload.nBuffering.(I[BII)I"] = function(handle, bu
// Check the parameters.
if (buffer === null || size === 0) {
return bufferSize / 2;
return bufferSize >>> 1;
}
player.writeBuffer(buffer.subarray(offset, offset + size));

Просмотреть файл

@ -19,6 +19,7 @@ PACKAGE_FILES = \
javax/microedition/media/hello.wav \
javax/microedition/media/audio.3gp \
javax/microedition/media/audio.amr \
javax/microedition/media/hello.ogg \
$(NULL)
all: tests.jar

Просмотреть файл

@ -70,9 +70,9 @@ var gfxTests = [
];
var expectedUnitTestResults = [
{ name: "pass", number: 71533 },
{ name: "pass", number: 71546 },
{ name: "fail", number: 0 },
{ name: "known fail", number: 215 },
{ name: "known fail", number: 214 },
{ name: "unknown pass", number: 0 }
];

Просмотреть файл

@ -31,7 +31,7 @@ public class TestAudioPlayer implements Testlet, PlayerListener {
try {
InputStream is = getClass().getResourceAsStream("/javax/microedition/media/hello.wav");
Player player = Manager.createPlayer(is, "audio/x-wav");
testPlay(player);
testPlay(player, "audio/x-wav");
} catch (Exception e) {
e.printStackTrace();
th.fail("Unexpected exception: " + e);
@ -50,7 +50,29 @@ public class TestAudioPlayer implements Testlet, PlayerListener {
os.close();
Player player = Manager.createPlayer(url);
testPlay(player);
testPlay(player, "audio/x-wav");
file.delete();
file.close();
} catch (Exception e) {
th.fail("Unexpected exception: " + e);
e.printStackTrace();
}
// Test player with file URL with a odd size
try {
String url = "file:////hello.ogg";
FileConnection file = (FileConnection)Connector.open(url, Connector.READ_WRITE);
if (!file.exists()) {
file.create();
}
OutputStream os = file.openDataOutputStream();
InputStream is = getClass().getResourceAsStream("/javax/microedition/media/hello.ogg");
os.write(TestUtils.read(is));
os.close();
Player player = Manager.createPlayer(url);
testPlay(player, "audio/ogg");
file.delete();
file.close();
@ -60,7 +82,7 @@ public class TestAudioPlayer implements Testlet, PlayerListener {
}
}
private void testPlay(Player player) throws Exception {
private void testPlay(Player player, String expectedContentType) throws Exception {
player.addPlayerListener(this);
// Check duration
@ -72,7 +94,7 @@ public class TestAudioPlayer implements Testlet, PlayerListener {
player.start();
// Check content type.
th.check(player.getContentType(), "audio/x-wav");
th.check(player.getContentType(), expectedContentType);
// Play the audio for a short time.
while (player.getMediaTime() <= 0) {

Двоичные данные
tests/javax/microedition/media/hello.ogg Normal file

Двоичный файл не отображается.