Chromium Code Reviews| 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..af019016307dcf5bfe0b6039d4327db9ddaec0d9 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)); |
|
sandersd (OOO until July 31)
2015/06/22 20:17:20
Add a test using a different key system ID?
jrummell
2015/06/22 21:01:18
There is one (line 295), but added a second variat
sandersd (OOO until July 31)
2015/06/22 22:23:29
I would also like to see a test were a |key_system
jrummell
2015/06/24 00:18:47
Added.
|
| } |
| 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,7 +288,7 @@ 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)); |
| } |
| } |
| @@ -304,7 +299,7 @@ TEST_F(CencUtilsTest, UnrecognizedSystemID) { |
| ++box[20]; |
| KeyIdList key_ids; |
| - EXPECT_FALSE(GetKeyIdsForCommonSystemId(box, &key_ids)); |
| + EXPECT_FALSE(GetKeyIds(box, CommonSystemSystemId(), &key_ids)); |
| } |
| TEST_F(CencUtilsTest, InvalidFlags) { |
| @@ -314,7 +309,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 +332,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 +356,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 +383,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 +452,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 +471,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()); |
| } |