| Index: media/cdm/cenc_utils_unittest.cc
|
| diff --git a/media/cdm/cenc_utils_unittest.cc b/media/cdm/cenc_utils_unittest.cc
|
| index af6066a03f78b4af9f9bd6db02cf07944ee23779..01ca5a1a5dc1bcb05ef510c014c725dc0e06aef8 100644
|
| --- a/media/cdm/cenc_utils_unittest.cc
|
| +++ b/media/cdm/cenc_utils_unittest.cc
|
| @@ -180,28 +180,29 @@ class CencUtilsTest : public testing::Test {
|
| TEST_F(CencUtilsTest, EmptyPSSH) {
|
| KeyIdList key_ids;
|
| EXPECT_TRUE(ValidatePsshInput(std::vector<uint8_t>()));
|
| - EXPECT_FALSE(GetKeyIdsForCommonSystemId(std::vector<uint8_t>(), &key_ids));
|
| + EXPECT_FALSE(
|
| + GetKeyIds(std::vector<uint8_t>(), CommonSystemSystemId(), &key_ids));
|
| }
|
|
|
| TEST_F(CencUtilsTest, PSSHVersion0) {
|
| std::vector<uint8_t> box = MakePSSHBox(0);
|
| KeyIdList key_ids;
|
| EXPECT_TRUE(ValidatePsshInput(box));
|
| - EXPECT_FALSE(GetKeyIdsForCommonSystemId(box, &key_ids));
|
| + EXPECT_FALSE(GetKeyIds(box, CommonSystemSystemId(), &key_ids));
|
| }
|
|
|
| TEST_F(CencUtilsTest, PSSHVersion1WithNoKeys) {
|
| std::vector<uint8_t> box = MakePSSHBox(1);
|
| KeyIdList key_ids;
|
| EXPECT_TRUE(ValidatePsshInput(box));
|
| - EXPECT_FALSE(GetKeyIdsForCommonSystemId(box, &key_ids));
|
| + EXPECT_FALSE(GetKeyIds(box, CommonSystemSystemId(), &key_ids));
|
| }
|
|
|
| TEST_F(CencUtilsTest, PSSHVersion1WithOneKey) {
|
| std::vector<uint8_t> box = MakePSSHBox(1, Key1());
|
| KeyIdList key_ids;
|
| EXPECT_TRUE(ValidatePsshInput(box));
|
| - EXPECT_TRUE(GetKeyIdsForCommonSystemId(box, &key_ids));
|
| + EXPECT_TRUE(GetKeyIds(box, CommonSystemSystemId(), &key_ids));
|
| EXPECT_EQ(1u, key_ids.size());
|
| EXPECT_EQ(key_ids[0], Key1());
|
| }
|
| @@ -210,7 +211,7 @@ TEST_F(CencUtilsTest, PSSHVersion1WithTwoKeys) {
|
| std::vector<uint8_t> box = MakePSSHBox(1, Key1(), Key2());
|
| KeyIdList key_ids;
|
| EXPECT_TRUE(ValidatePsshInput(box));
|
| - EXPECT_TRUE(GetKeyIdsForCommonSystemId(box, &key_ids));
|
| + EXPECT_TRUE(GetKeyIds(box, CommonSystemSystemId(), &key_ids));
|
| EXPECT_EQ(2u, key_ids.size());
|
| EXPECT_EQ(key_ids[0], Key1());
|
| EXPECT_EQ(key_ids[1], Key2());
|
| @@ -222,12 +223,11 @@ TEST_F(CencUtilsTest, PSSHVersion0Plus1) {
|
|
|
| // Concatentate box1 onto end of box0.
|
| box0.insert(box0.end(), box1.begin(), box1.end());
|
| + EXPECT_TRUE(ValidatePsshInput(box0));
|
|
|
| + // No key IDs returned as only the first 'pssh' box is processed.
|
| KeyIdList key_ids;
|
| - EXPECT_TRUE(ValidatePsshInput(box0));
|
| - EXPECT_TRUE(GetKeyIdsForCommonSystemId(box0, &key_ids));
|
| - EXPECT_EQ(1u, key_ids.size());
|
| - EXPECT_EQ(key_ids[0], Key1());
|
| + EXPECT_FALSE(GetKeyIds(box0, CommonSystemSystemId(), &key_ids));
|
| }
|
|
|
| TEST_F(CencUtilsTest, PSSHVersion1Plus0) {
|
| @@ -236,10 +236,10 @@ TEST_F(CencUtilsTest, PSSHVersion1Plus0) {
|
|
|
| // Concatentate box0 onto end of box1.
|
| box1.insert(box1.end(), box0.begin(), box0.end());
|
| + EXPECT_TRUE(ValidatePsshInput(box1));
|
|
|
| KeyIdList key_ids;
|
| - EXPECT_TRUE(ValidatePsshInput(box1));
|
| - EXPECT_TRUE(GetKeyIdsForCommonSystemId(box1, &key_ids));
|
| + EXPECT_TRUE(GetKeyIds(box1, CommonSystemSystemId(), &key_ids));
|
| EXPECT_EQ(1u, key_ids.size());
|
| EXPECT_EQ(key_ids[0], Key1());
|
| }
|
| @@ -252,18 +252,13 @@ TEST_F(CencUtilsTest, MultiplePSSHVersion1) {
|
| // Concatentate box1 and box2 onto end of box.
|
| box.insert(box.end(), box1.begin(), box1.end());
|
| box.insert(box.end(), box2.begin(), box2.end());
|
| + EXPECT_TRUE(ValidatePsshInput(box));
|
|
|
| KeyIdList key_ids;
|
| - EXPECT_TRUE(ValidatePsshInput(box));
|
| - // TODO(jrummell): GetKeyIdsForCommonSystemId() returns the key IDs out of
|
| - // all matching boxes. It should only return the key IDs from the first
|
| - // matching box.
|
| - EXPECT_TRUE(GetKeyIdsForCommonSystemId(box, &key_ids));
|
| - EXPECT_EQ(4u, key_ids.size());
|
| + EXPECT_TRUE(GetKeyIds(box, CommonSystemSystemId(), &key_ids));
|
| + EXPECT_EQ(2u, key_ids.size());
|
| EXPECT_EQ(key_ids[0], Key1());
|
| EXPECT_EQ(key_ids[1], Key2());
|
| - EXPECT_EQ(key_ids[2], Key3());
|
| - EXPECT_EQ(key_ids[3], Key4());
|
| }
|
|
|
| TEST_F(CencUtilsTest, PsshBoxSmallerThanSize) {
|
| @@ -275,7 +270,7 @@ TEST_F(CencUtilsTest, PsshBoxSmallerThanSize) {
|
| // Truncate the box to be less than the specified box size.
|
| std::vector<uint8_t> truncated(&box[0], &box[0] + i);
|
| EXPECT_FALSE(ValidatePsshInput(truncated)) << "Failed for length " << i;
|
| - EXPECT_FALSE(GetKeyIdsForCommonSystemId(truncated, &key_ids));
|
| + EXPECT_FALSE(GetKeyIds(truncated, CommonSystemSystemId(), &key_ids));
|
| }
|
| }
|
|
|
| @@ -293,18 +288,53 @@ TEST_F(CencUtilsTest, PsshBoxLargerThanSize) {
|
| // Modify size of box passed to be less than current size.
|
| std::vector<uint8_t> truncated(&box[0], &box[0] + i);
|
| EXPECT_FALSE(ValidatePsshInput(truncated)) << "Failed for length " << i;
|
| - EXPECT_FALSE(GetKeyIdsForCommonSystemId(truncated, &key_ids));
|
| + EXPECT_FALSE(GetKeyIds(truncated, CommonSystemSystemId(), &key_ids));
|
| }
|
| }
|
|
|
| TEST_F(CencUtilsTest, UnrecognizedSystemID) {
|
| + const uint8_t data[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
| + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f};
|
| + std::vector<uint8_t> different_system_id(data, data + arraysize(data));
|
| + KeyIdList key_ids;
|
| +
|
| std::vector<uint8_t> box = MakePSSHBox(1, Key1(), Key2());
|
| + EXPECT_TRUE(GetKeyIds(box, CommonSystemSystemId(), &key_ids));
|
| + EXPECT_FALSE(GetKeyIds(box, different_system_id, &key_ids));
|
|
|
| - // Modify the System ID.
|
| + // Modify the System ID and try again.
|
| ++box[20];
|
| + EXPECT_FALSE(GetKeyIds(box, CommonSystemSystemId(), &key_ids));
|
| + EXPECT_FALSE(GetKeyIds(box, different_system_id, &key_ids));
|
| +}
|
|
|
| +TEST_F(CencUtilsTest, DifferentSystemID) {
|
| + const uint8_t data[] = {
|
| + 0x00, 0x00, 0x00, 0x44, // size
|
| + 'p', 's', 's', 'h',
|
| + 0x01, // version
|
| + 0x00, 0x00, 0x00, // flags
|
| + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, // SystemID
|
| + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f,
|
| + 0x00, 0x00, 0x00, 0x02, // key count
|
| + 0x7E, 0x57, 0x1D, 0x03, 0x7E, 0x57, 0x1D, 0x03, // key1
|
| + 0x7E, 0x57, 0x1D, 0x03, 0x7E, 0x57, 0x1D, 0x03,
|
| + 0x7E, 0x57, 0x1D, 0x04, 0x7E, 0x57, 0x1D, 0x04, // key2
|
| + 0x7E, 0x57, 0x1D, 0x04, 0x7E, 0x57, 0x1D, 0x04,
|
| + 0x00, 0x00, 0x00, 0x00 // datasize
|
| + };
|
| + const uint8_t id_data[] = {
|
| + 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07,
|
| + 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e, 0x0f
|
| + };
|
| KeyIdList key_ids;
|
| - EXPECT_FALSE(GetKeyIdsForCommonSystemId(box, &key_ids));
|
| +
|
| + EXPECT_FALSE(GetKeyIds(std::vector<uint8_t>(data, data + arraysize(data)),
|
| + CommonSystemSystemId(), &key_ids));
|
| + EXPECT_TRUE(GetKeyIds(
|
| + std::vector<uint8_t>(data, data + arraysize(data)),
|
| + std::vector<uint8_t>(id_data, id_data + arraysize(id_data)), &key_ids));
|
| + EXPECT_EQ(2u, key_ids.size());
|
| }
|
|
|
| TEST_F(CencUtilsTest, InvalidFlags) {
|
| @@ -314,7 +344,7 @@ TEST_F(CencUtilsTest, InvalidFlags) {
|
| box[10] = 3;
|
|
|
| KeyIdList key_ids;
|
| - EXPECT_FALSE(GetKeyIdsForCommonSystemId(box, &key_ids));
|
| + EXPECT_FALSE(GetKeyIds(box, CommonSystemSystemId(), &key_ids));
|
| }
|
|
|
| TEST_F(CencUtilsTest, LongSize) {
|
| @@ -337,8 +367,8 @@ TEST_F(CencUtilsTest, LongSize) {
|
| KeyIdList key_ids;
|
| EXPECT_TRUE(
|
| ValidatePsshInput(std::vector<uint8_t>(data, data + arraysize(data))));
|
| - EXPECT_TRUE(GetKeyIdsForCommonSystemId(
|
| - std::vector<uint8_t>(data, data + arraysize(data)), &key_ids));
|
| + EXPECT_TRUE(GetKeyIds(std::vector<uint8_t>(data, data + arraysize(data)),
|
| + CommonSystemSystemId(), &key_ids));
|
| EXPECT_EQ(2u, key_ids.size());
|
| }
|
|
|
| @@ -361,8 +391,8 @@ TEST_F(CencUtilsTest, SizeIsZero) {
|
| KeyIdList key_ids;
|
| EXPECT_TRUE(
|
| ValidatePsshInput(std::vector<uint8_t>(data, data + arraysize(data))));
|
| - EXPECT_TRUE(GetKeyIdsForCommonSystemId(
|
| - std::vector<uint8_t>(data, data + arraysize(data)), &key_ids));
|
| + EXPECT_TRUE(GetKeyIds(std::vector<uint8_t>(data, data + arraysize(data)),
|
| + CommonSystemSystemId(), &key_ids));
|
| EXPECT_EQ(2u, key_ids.size());
|
| }
|
|
|
| @@ -388,8 +418,8 @@ TEST_F(CencUtilsTest, HugeSize) {
|
| // is not enough bytes in |data|.
|
| EXPECT_FALSE(
|
| ValidatePsshInput(std::vector<uint8_t>(data, data + arraysize(data))));
|
| - EXPECT_FALSE(GetKeyIdsForCommonSystemId(
|
| - std::vector<uint8_t>(data, data + arraysize(data)), &key_ids));
|
| + EXPECT_FALSE(GetKeyIds(std::vector<uint8_t>(data, data + arraysize(data)),
|
| + CommonSystemSystemId(), &key_ids));
|
| }
|
|
|
| TEST_F(CencUtilsTest, GetPsshData_Version0) {
|
| @@ -457,10 +487,9 @@ TEST_F(CencUtilsTest, GetPsshData_Version2ThenVersion1) {
|
| boxes.insert(boxes.end(), box_v1.begin(), box_v1.end());
|
| EXPECT_TRUE(GetPsshData(boxes, CommonSystemSystemId(), &pssh_data));
|
|
|
| - // GetKeyIdsForCommonSystemId() should return the single key from the v1
|
| - // 'pssh' box.
|
| + // GetKeyIds() should return the single key from the v1 'pssh' box.
|
| KeyIdList key_ids;
|
| - EXPECT_TRUE(GetKeyIdsForCommonSystemId(boxes, &key_ids));
|
| + EXPECT_TRUE(GetKeyIds(boxes, CommonSystemSystemId(), &key_ids));
|
| EXPECT_EQ(1u, key_ids.size());
|
| EXPECT_EQ(key_ids[0], Key1());
|
| }
|
| @@ -477,10 +506,9 @@ TEST_F(CencUtilsTest, GetPsshData_Version1ThenVersion2) {
|
| boxes.insert(boxes.end(), box_v2.begin(), box_v2.end());
|
| EXPECT_TRUE(GetPsshData(boxes, CommonSystemSystemId(), &pssh_data));
|
|
|
| - // GetKeyIdsForCommonSystemId() should return the single key from the v1
|
| - // 'pssh' box.
|
| + // GetKeyIds() should return the single key from the v1 'pssh' box.
|
| KeyIdList key_ids;
|
| - EXPECT_TRUE(GetKeyIdsForCommonSystemId(boxes, &key_ids));
|
| + EXPECT_TRUE(GetKeyIds(boxes, CommonSystemSystemId(), &key_ids));
|
| EXPECT_EQ(1u, key_ids.size());
|
| EXPECT_EQ(key_ids[0], Key3());
|
| }
|
|
|