Skip to content

Commit

Permalink
Ogg Flac packet level test (failing...)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gagravarr committed Aug 23, 2015
1 parent c8eacbe commit e3a9002
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions core/src/test/java/org/gagravarr/flac/TestFlacFileRead.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import junit.framework.TestCase;

import org.gagravarr.ogg.OggFile;
import org.gagravarr.ogg.OggPacket;
import org.gagravarr.ogg.OggPacketReader;

/**
* Tests for reading things using FlacFile, both for
Expand All @@ -40,6 +42,29 @@ protected void tearDown() throws IOException {
}
}

/**
* Test that the first audio frame used all the data
* from it's ogg packet, and it's all still available
* unchanged for if you wanted to write it back out again
*/
public void testOggFirstAudioFrame() throws IOException {
// Find the first audio packet
OggFile ogg = new OggFile(getTestOggFile());
OggPacketReader r = ogg.getPacketReader();
// Will have Info then tags
OggPacket p = r.getNextPacket();
FlacInfo info = (new FlacFirstOggPacket(p)).getInfo();
p = r.getNextPacket();
// Next are other metadata
while ((p = r.getNextPacket()) != null) {
if (p.getData()[0] == -1) break;
}
// Decode audio as Flac
FlacAudioFrame audio = new FlacAudioFrame(p.getData(), info);
// Check same
assertEquals(p.getData().length, audio.getData().length);
}

public void testReadOgg() throws IOException {
OggFile ogg = new OggFile(getTestOggFile());
flac = new FlacOggFile(ogg);
Expand Down

0 comments on commit e3a9002

Please sign in to comment.