* FYI: sound test update
@ 2007-07-07 19:20 Mario Torre
0 siblings, 0 replies; only message in thread
From: Mario Torre @ 2007-07-07 19:20 UTC (permalink / raw)
To: mauve-patches; +Cc: Mark Wielaard
[-- Attachment #1: Type: text/plain, Size: 1047 bytes --]
This add tests for AU files. Note that under the JDK (1.6) the streaming
of AU files fails for me, not sure why (not because the test is wrong!).
+1 for us :)
2007-07-07 Mario Torre <neugens@limasoftware.net>
* gnu/testlet/javax/sound/sampled/AudioProperties.java:
(test): added test for AU audio files.
(testAU): new test.
(getAudioStream): new support method to load sound file and return
audio
streams accordingly.
(testWav): refactored.
(processAUStream): new helper method, part of the AU test.
* gnu/testlet/javax/sound/sampled/data/k3b_success1.au:
* README: added k3b_success1.au to the "NOTES" section.
--
Lima Software - http://www.limasoftware.net/
GNU Classpath Developer - http://www.classpath.org/
Fedora Ambassador - http://fedoraproject.org/wiki/MarioTorre
Jabber: neugens@jabber.org
pgp key: http://subkeys.pgp.net/ PGP Key ID: 80F240CF
Fingerprint: BA39 9666 94EC 8B73 27FA FC7C 4086 63E3 80F2 40CF
Please, support open standards:
http://opendocumentfellowship.org/petition/
http://www.nosoftwarepatents.com/
[-- Attachment #2: 2007-07-07-gsoc-mauve-3.patch --]
[-- Type: text/x-patch, Size: 5337 bytes --]
### Eclipse Workspace Patch 1.0
#P mauve
Index: README
===================================================================
RCS file: /cvs/mauve/mauve/README,v
retrieving revision 1.28
diff -u -r1.28 README
--- README 6 Jul 2007 10:47:26 -0000 1.28
+++ README 7 Jul 2007 19:17:14 -0000
@@ -297,3 +297,5 @@
* gnu/testlet/javax/sound/sampled/data/k3b_success1.wav, GPL,
k3b-1.0.1-1.fc7.2 (fedora 7)
+ * gnu/testlet/javax/sound/sampled/data/k3b_success1.au, GPL,
+ converted from k3b_success1.wav.
Index: gnu/testlet/javax/sound/sampled/AudioProperties.java
===================================================================
RCS file: /cvs/mauve/mauve/gnu/testlet/javax/sound/sampled/AudioProperties.java,v
retrieving revision 1.1
diff -u -r1.1 AudioProperties.java
--- gnu/testlet/javax/sound/sampled/AudioProperties.java 5 Jul 2007 23:04:28 -0000 1.1
+++ gnu/testlet/javax/sound/sampled/AudioProperties.java 7 Jul 2007 19:17:14 -0000
@@ -27,7 +27,6 @@
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
-import java.io.InputStream;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioInputStream;
@@ -46,6 +45,7 @@
private static final String BASE_PATH =
"gnu#testlet#javax#sound#sampled#data#";
private static final String WAV = BASE_PATH + "k3b_success1.wav";
+ private static final String AU = BASE_PATH + "k3b_success1.au";
protected TestHarness harness = null;
@@ -53,6 +53,7 @@
{
this.harness = harness;
this.testWav();
+ this.testAU();
}
private void processWaveStream(AudioInputStream stream)
@@ -69,38 +70,67 @@
this.harness.check(format.getFrameRate() == 8000.0);
this.harness.check(format.getSampleSizeInBits() == 8);
}
+
+ private void processAUStream(AudioInputStream stream)
+ {
+ AudioFormat format = stream.getFormat();
- /**
- * Read a wav file and check if the expected properties match
- * the actual result.
- */
- private void testWav()
+ // NOTE: we don't check for encoding, because our backend is unable
+ // to get the correct encoding as defined by AudioFormat.Encoding
+ // this is not a problem, because the encodings specified do not
+ // make sense in most cases.
+ this.harness.check(format.getFrameSize() == 2);
+ this.harness.check(format.getChannels() == 1);
+ this.harness.check(format.getSampleRate() == 8000.0);
+ this.harness.check(format.getFrameRate() == 8000.0);
+ this.harness.check(format.getSampleSizeInBits() == 16);
+ }
+
+ private AudioInputStream getAudioStream(String filepath, boolean stream)
+ throws IOException, UnsupportedAudioFileException
{
- this.harness.checkPoint("testWav()");
-
- File wav = null;
+ File file = null;
try
{
- wav = this.harness.getResourceFile(WAV);
+ file = this.harness.getResourceFile(filepath);
}
catch (ResourceNotFoundException e1)
{
- this.harness.fail("ResourceNotFoundException: check the correct " +
- "input file location");
- return;
+ throw new IOException("ResourceNotFoundException: check the correct " +
+ "input file location");
+ }
+
+ AudioInputStream audioInputStream = null;
+ if (stream)
+ {
+ audioInputStream =
+ AudioSystem.getAudioInputStream(new FileInputStream(file));
+ }
+ else
+ {
+ audioInputStream = AudioSystem.getAudioInputStream(file);
}
+ return audioInputStream;
+ }
+
+ /**
+ * Read a wav file and check if the expected properties match
+ * the actual result.
+ */
+ private void testWav()
+ {
+ this.harness.checkPoint("testWav()");
+
try
{
this.harness.checkPoint("testWav() - FILE");
- AudioInputStream audioInputStream =
- AudioSystem.getAudioInputStream(wav);
+ AudioInputStream audioInputStream = getAudioStream(WAV, false);
processWaveStream(audioInputStream);
this.harness.checkPoint("testWav() - STREAM");
- AudioInputStream audioInputStream2 =
- AudioSystem.getAudioInputStream(new FileInputStream(wav));
+ AudioInputStream audioInputStream2 = getAudioStream(WAV, true);
processWaveStream(audioInputStream2);
}
@@ -111,7 +141,34 @@
}
catch (IOException e)
{
- this.harness.fail("IOException: check the correct input file location");
+ this.harness.fail(e.getMessage());
+ }
+ }
+
+ private void testAU()
+ {
+ this.harness.checkPoint("testAU()");
+
+ try
+ {
+ this.harness.checkPoint("testAU() - FILE");
+ AudioInputStream audioInputStream = getAudioStream(AU, false);
+
+ processAUStream(audioInputStream);
+
+ this.harness.checkPoint("testAU() - STREAM");
+ AudioInputStream audioInputStream2 = getAudioStream(AU, true);
+
+ processAUStream(audioInputStream2);
+ }
+ catch (UnsupportedAudioFileException e)
+ {
+ this.harness.fail("AU files should be supported by any" +
+ " implementation");
+ }
+ catch (IOException e)
+ {
+ this.harness.fail(e.getMessage());
}
}
}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2007-07-07 19:20 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-07 19:20 FYI: sound test update Mario Torre
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).