AbstractSampleEncryptionBoxTestpublic abstract class AbstractSampleEncryptionBoxTest extends Object Created by IntelliJ IDEA.
User: sannies
Date: 11/19/11
Time: 4:06 PM
To change this template use File | Settings | File Templates. |
Fields Summary |
---|
protected AbstractSampleEncryptionBox | senc |
Methods Summary |
---|
public void | setUp()
| public void | testRoundTripFlagsOne()
senc.setOverrideTrackEncryptionBoxParameters(true);
senc.setAlgorithmId(0x333333);
senc.setIvSize(8);
senc.setKid(UUIDConverter.convert(UUID.randomUUID()));
List<AbstractSampleEncryptionBox.Entry> entries = new LinkedList<AbstractSampleEncryptionBox.Entry>();
AbstractSampleEncryptionBox.Entry entry = senc.createEntry();
entry.iv = new byte[]{1, 2, 3, 4, 5, 6, 7, 8};
entries.add(entry);
senc.setEntries(entries);
long sizeBeforeWrite = senc.getSize();
ByteArrayOutputStream baos = new ByteArrayOutputStream();
senc.getBox(Channels.newChannel(baos));
Assert.assertEquals(baos.size(), senc.getSize());
Assert.assertEquals(sizeBeforeWrite, senc.getSize());
IsoFile iso = new IsoFile(new ByteBufferByteChannel(ByteBuffer.wrap(baos.toByteArray())));
Assert.assertTrue(iso.getBoxes().get(0) instanceof AbstractSampleEncryptionBox);
AbstractSampleEncryptionBox senc2 = (AbstractSampleEncryptionBox) iso.getBoxes().get(0);
Assert.assertEquals(1, senc2.getFlags());
Assert.assertTrue(senc.equals(senc2));
Assert.assertTrue(senc2.equals(senc));
| public void | testRoundTripFlagsThree()
senc.setSubSampleEncryption(true);
senc.setOverrideTrackEncryptionBoxParameters(true);
senc.setAlgorithmId(0x333333);
senc.setIvSize(8);
senc.setKid(UUIDConverter.convert(UUID.randomUUID()));
List<AbstractSampleEncryptionBox.Entry> entries = new LinkedList<AbstractSampleEncryptionBox.Entry>();
AbstractSampleEncryptionBox.Entry entry = senc.createEntry();
entry.iv = new byte[]{1, 2, 3, 4, 5, 6, 7, 8};
entry.pairs = new LinkedList<AbstractSampleEncryptionBox.Entry.Pair>();
entry.pairs.add(entry.createPair(5, 15));
entry.pairs.add(entry.createPair(5, 16));
entry.pairs.add(entry.createPair(5, 17));
entry.pairs.add(entry.createPair(5, 18));
entry.pairs.add(entry.createPair(5, 19));
entries.add(entry);
entries.add(entry);
entries.add(entry);
entries.add(entry);
senc.setEntries(entries);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
senc.getBox(Channels.newChannel(baos));
Assert.assertEquals(baos.size(), senc.getSize());
IsoFile iso = new IsoFile(new ByteBufferByteChannel(ByteBuffer.wrap(baos.toByteArray())));
Assert.assertTrue(iso.getBoxes().get(0) instanceof AbstractSampleEncryptionBox);
AbstractSampleEncryptionBox senc2 = (AbstractSampleEncryptionBox) iso.getBoxes().get(0);
Assert.assertEquals(3, senc2.getFlags());
Assert.assertTrue(senc.equals(senc2));
Assert.assertTrue(senc2.equals(senc));
| public void | testRoundTripFlagsTwo()
senc.setSubSampleEncryption(true);
List<AbstractSampleEncryptionBox.Entry> entries = new LinkedList<AbstractSampleEncryptionBox.Entry>();
AbstractSampleEncryptionBox.Entry entry = senc.createEntry();
entry.iv = new byte[]{1, 2, 3, 4, 5, 6, 7, 8};
entry.pairs = new LinkedList<AbstractSampleEncryptionBox.Entry.Pair>();
entry.pairs.add(entry.createPair(5, 15));
entry.pairs.add(entry.createPair(5, 16));
entry.pairs.add(entry.createPair(5, 17));
entry.pairs.add(entry.createPair(5, 18));
entry.pairs.add(entry.createPair(5, 19));
entries.add(entry);
senc.setEntries(entries);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
senc.getBox(Channels.newChannel(baos));
Assert.assertEquals(baos.size(), senc.getSize());
IsoFile iso = new IsoFile(new ByteBufferByteChannel(ByteBuffer.wrap(baos.toByteArray())));
Assert.assertTrue(iso.getBoxes().get(0) instanceof AbstractSampleEncryptionBox);
AbstractSampleEncryptionBox senc2 = (AbstractSampleEncryptionBox) iso.getBoxes().get(0);
Assert.assertEquals(2, senc2.getFlags());
Assert.assertTrue(senc.equals(senc2));
Assert.assertTrue(senc2.equals(senc));
| public void | testRoundTripFlagsZero()
List<AbstractSampleEncryptionBox.Entry> entries = new LinkedList<AbstractSampleEncryptionBox.Entry>();
AbstractSampleEncryptionBox.Entry entry = senc.createEntry();
entry.iv = new byte[]{1, 2, 3, 4, 5, 6, 7, 8};
entries.add(entry);
senc.setEntries(entries);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
long sizeBeforeWrite = senc.getSize();
senc.getBox(Channels.newChannel(baos));
Assert.assertEquals(baos.size(), senc.getSize());
Assert.assertEquals(baos.size(), sizeBeforeWrite);
IsoFile iso = new IsoFile(new ByteBufferByteChannel(ByteBuffer.wrap(baos.toByteArray())));
Assert.assertTrue(iso.getBoxes().get(0) instanceof AbstractSampleEncryptionBox);
AbstractSampleEncryptionBox senc2 = (AbstractSampleEncryptionBox) iso.getBoxes().get(0);
Assert.assertEquals(0, senc2.getFlags());
Assert.assertTrue(senc.equals(senc2));
Assert.assertTrue(senc2.equals(senc));
| public void | testRoundTripSmallIV()
List<AbstractSampleEncryptionBox.Entry> entries = new LinkedList<AbstractSampleEncryptionBox.Entry>();
senc.setOverrideTrackEncryptionBoxParameters(true);
senc.setAlgorithmId(1);
senc.setIvSize(8);
senc.setKid(UUIDConverter.convert(UUID.randomUUID()));
AbstractSampleEncryptionBox.Entry entry = senc.createEntry();
entry.iv = new byte[]{1, 2, 3, 5, 6, 7, 8};
entries.add(entry);
entry = senc.createEntry();
entry.iv = new byte[]{1, 2, 3, 5, 6, 7, 9};
entries.add(entry);
entry = senc.createEntry();
entry.iv = new byte[]{1, 2, 3, 5, 6, 7, 10};
entries.add(entry);
senc.setEntries(entries);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
long sizeBeforeWrite = senc.getSize();
senc.getBox(Channels.newChannel(baos));
Assert.assertEquals(baos.size(), senc.getSize());
Assert.assertEquals(baos.size(), sizeBeforeWrite);
IsoFile iso = new IsoFile(new ByteBufferByteChannel(ByteBuffer.wrap(baos.toByteArray())));
Assert.assertTrue(iso.getBoxes().get(0) instanceof AbstractSampleEncryptionBox);
AbstractSampleEncryptionBox senc2 = (AbstractSampleEncryptionBox) iso.getBoxes().get(0);
Assert.assertEquals(senc.getFlags(), senc2.getFlags());
Assert.assertTrue(senc.equals(senc2));
Assert.assertTrue(senc2.equals(senc));
|
|