|
| 1 | +package net.bramp.ffmpeg.info; |
| 2 | + |
| 3 | +import static org.hamcrest.Matchers.is; |
| 4 | +import static org.hamcrest.MatcherAssert.assertThat; |
| 5 | + |
| 6 | +import org.junit.Test; |
| 7 | + |
| 8 | +import net.bramp.ffmpeg.shared.CodecType; |
| 9 | + |
| 10 | +public class CodecTest { |
| 11 | + @Test |
| 12 | + public void testCodecConstructor() { |
| 13 | + Codec c1 = new Codec("012v", "Uncompressed 4:2:2 10-bit", "D.VI.S"); |
| 14 | + assertThat(c1.getName(), is("012v")); |
| 15 | + assertThat(c1.getLongName(), is("Uncompressed 4:2:2 10-bit")); |
| 16 | + assertThat(c1.getCanDecode(), is(true)); |
| 17 | + assertThat(c1.getCanEncode(), is(false)); |
| 18 | + assertThat(c1.getType(), is(CodecType.VIDEO)); |
| 19 | + assertThat(c1.isIntraFrameOnly(), is(true)); |
| 20 | + assertThat(c1.supportsLossyCompression(), is(false)); |
| 21 | + assertThat(c1.losslessCompression, is(true)); |
| 22 | + |
| 23 | + Codec c2 = new Codec("4xm", "4X Movie", "D.V.L."); |
| 24 | + assertThat(c2.getName(), is("4xm")); |
| 25 | + assertThat(c2.getLongName(), is("4X Movie")); |
| 26 | + assertThat(c2.getCanDecode(), is(true)); |
| 27 | + assertThat(c2.getCanEncode(), is(false)); |
| 28 | + assertThat(c2.getType(), is(CodecType.VIDEO)); |
| 29 | + assertThat(c2.isIntraFrameOnly(), is(false)); |
| 30 | + assertThat(c2.supportsLossyCompression(), is(true)); |
| 31 | + assertThat(c2.supportsLosslessCompression(), is(false)); |
| 32 | + |
| 33 | + Codec c3 = new Codec("alias_pix", "Alias/Wavefront PIX image", "DEVI.S"); |
| 34 | + assertThat(c3.getName(), is("alias_pix")); |
| 35 | + assertThat(c3.getLongName(), is("Alias/Wavefront PIX image")); |
| 36 | + assertThat(c3.getCanDecode(), is(true)); |
| 37 | + assertThat(c3.getCanEncode(), is(true)); |
| 38 | + assertThat(c3.getType(), is(CodecType.VIDEO)); |
| 39 | + assertThat(c3.isIntraFrameOnly(), is(true)); |
| 40 | + assertThat(c3.supportsLossyCompression(), is(false)); |
| 41 | + assertThat(c3.supportsLosslessCompression(), is(true)); |
| 42 | + |
| 43 | + Codec c4 = new Codec("binkaudio_rdft", "Bink Audio (RDFT)", "D.AIL."); |
| 44 | + assertThat(c4.getType(), is(CodecType.AUDIO)); |
| 45 | + |
| 46 | + Codec c6 = new Codec("mov_text", "MOV text", "DES..."); |
| 47 | + assertThat(c6.getType(), is(CodecType.SUBTITLE)); |
| 48 | + |
| 49 | + Codec c7 = new Codec("bin_data", "binary data", "..D..."); |
| 50 | + assertThat(c7.getType(), is(CodecType.DATA)); |
| 51 | + } |
| 52 | + |
| 53 | + @Test(expected = IllegalArgumentException.class) |
| 54 | + public void testBadDecodeValue() { |
| 55 | + new Codec("test", "test", "X.V..."); |
| 56 | + } |
| 57 | + |
| 58 | + @Test(expected = IllegalArgumentException.class) |
| 59 | + public void testBadEncodeValue() { |
| 60 | + new Codec("test", "test", ".XV..."); |
| 61 | + } |
| 62 | + |
| 63 | + @Test(expected = IllegalArgumentException.class) |
| 64 | + public void testBadCodecValue() { |
| 65 | + new Codec("test", "test", "..X..."); |
| 66 | + } |
| 67 | + |
| 68 | + @Test(expected = IllegalArgumentException.class) |
| 69 | + public void testBadIntraFrameOnlyValue() { |
| 70 | + new Codec("test", "test", "..VX.."); |
| 71 | + } |
| 72 | + |
| 73 | + @Test(expected = IllegalArgumentException.class) |
| 74 | + public void testBadLossyValue() { |
| 75 | + new Codec("test", "test", "..V.X."); |
| 76 | + } |
| 77 | + |
| 78 | + @Test(expected = IllegalArgumentException.class) |
| 79 | + public void testBadLosslessValue() { |
| 80 | + new Codec("test", "test", "..V..X"); |
| 81 | + } |
| 82 | +} |
0 commit comments