Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(209)

Unified Diff: media/cdm/cenc_utils_unittest.cc

Issue 1163713007: Use 'pssh' data to determine key_id properly (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: use message event Created 5 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « media/cdm/cenc_utils.cc ('k') | media/test/data/bear-1280x720-a_frag-cenc.mp4 » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/cdm/cenc_utils_unittest.cc
diff --git a/media/cdm/cenc_utils_unittest.cc b/media/cdm/cenc_utils_unittest.cc
index 3bc55ccda7ca37b1f8b16b7a718cf0c4f0190dda..a43d5eaea5703b101918729cb3f64102522ee227 100644
--- a/media/cdm/cenc_utils_unittest.cc
+++ b/media/cdm/cenc_utils_unittest.cc
@@ -180,24 +180,21 @@ class CencUtilsTest : public testing::Test {
TEST_F(CencUtilsTest, EmptyPSSH) {
KeyIdList key_ids;
EXPECT_TRUE(ValidatePsshInput(std::vector<uint8_t>()));
- EXPECT_TRUE(GetKeyIdsForCommonSystemId(std::vector<uint8_t>(), &key_ids));
- EXPECT_EQ(0u, key_ids.size());
+ EXPECT_FALSE(GetKeyIdsForCommonSystemId(std::vector<uint8_t>(), &key_ids));
}
TEST_F(CencUtilsTest, PSSHVersion0) {
std::vector<uint8_t> box = MakePSSHBox(0);
KeyIdList key_ids;
EXPECT_TRUE(ValidatePsshInput(box));
- EXPECT_TRUE(GetKeyIdsForCommonSystemId(box, &key_ids));
- EXPECT_EQ(0u, key_ids.size());
+ EXPECT_FALSE(GetKeyIdsForCommonSystemId(box, &key_ids));
}
TEST_F(CencUtilsTest, PSSHVersion1WithNoKeys) {
std::vector<uint8_t> box = MakePSSHBox(1);
KeyIdList key_ids;
EXPECT_TRUE(ValidatePsshInput(box));
- EXPECT_TRUE(GetKeyIdsForCommonSystemId(box, &key_ids));
- EXPECT_EQ(0u, key_ids.size());
+ EXPECT_FALSE(GetKeyIdsForCommonSystemId(box, &key_ids));
}
TEST_F(CencUtilsTest, PSSHVersion1WithOneKey) {
@@ -258,6 +255,9 @@ TEST_F(CencUtilsTest, MultiplePSSHVersion1) {
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_EQ(key_ids[0], Key1());
@@ -266,15 +266,22 @@ TEST_F(CencUtilsTest, MultiplePSSHVersion1) {
EXPECT_EQ(key_ids[3], Key4());
}
-TEST_F(CencUtilsTest, InvalidPSSH) {
+TEST_F(CencUtilsTest, TruncatedAtEndPSSH) {
ddorwin 2015/06/17 22:42:05 is there a test where size is greater than the box
ddorwin 2015/06/17 22:42:05 PsshBoxLessThanSize might be better. Oh, I misunde
ddorwin 2015/06/17 22:42:06 // Tries every size less than the actual size. I'
jrummell 2015/06/17 23:54:10 Done.
jrummell 2015/06/17 23:54:10 Done.
jrummell 2015/06/17 23:54:10 Added.
std::vector<uint8_t> box = MakePSSHBox(1, Key1(), Key2());
KeyIdList key_ids;
for (size_t i = 1; i < box.size(); ++i) {
- // Modify size of data passed to be less than real size.
+ // Modify size of box passed to be less than real 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));
- // Modify starting point.
+ }
+}
+
+TEST_F(CencUtilsTest, TruncatedAtStartPSSH) {
ddorwin 2015/06/17 22:42:05 ditto
jrummell 2015/06/17 23:54:10 Done.
+ std::vector<uint8_t> box = MakePSSHBox(1, Key1(), Key2());
+ KeyIdList key_ids;
+ for (size_t i = 1; i < box.size(); ++i) {
+ // Modify starting point of box.
std::vector<uint8_t> changed_offset(&box[i], &box[i] + box.size() - i);
EXPECT_FALSE(ValidatePsshInput(changed_offset)) << "Failed for offset "
<< i;
@@ -282,15 +289,14 @@ TEST_F(CencUtilsTest, InvalidPSSH) {
}
}
-TEST_F(CencUtilsTest, InvalidSystemID) {
+TEST_F(CencUtilsTest, UnrecognizedSystemID) {
std::vector<uint8_t> box = MakePSSHBox(1, Key1(), Key2());
// Modify the System ID.
++box[20];
KeyIdList key_ids;
- EXPECT_TRUE(GetKeyIdsForCommonSystemId(box, &key_ids));
- EXPECT_EQ(0u, key_ids.size());
+ EXPECT_FALSE(GetKeyIdsForCommonSystemId(box, &key_ids));
}
TEST_F(CencUtilsTest, InvalidFlags) {
@@ -328,7 +334,7 @@ TEST_F(CencUtilsTest, LongSize) {
EXPECT_EQ(2u, key_ids.size());
}
-TEST_F(CencUtilsTest, NoSize) {
+TEST_F(CencUtilsTest, SizeIsZero) {
const uint8_t data[] = {
0x00, 0x00, 0x00, 0x00, // size = 0
0x70, 0x73, 0x73, 0x68, // 'pssh'
@@ -370,6 +376,8 @@ TEST_F(CencUtilsTest, HugeSize) {
};
KeyIdList key_ids;
+ // These tests fail as the box size is huge (0xffffffffffffffff) and there
ddorwin 2015/06/17 22:42:06 nit: s/tests/calls/ "tests" could be ambiguous.
jrummell 2015/06/17 23:54:10 Done.
+ // is not enough bytes in |data|.
EXPECT_FALSE(
ValidatePsshInput(std::vector<uint8_t>(data, data + arraysize(data))));
EXPECT_FALSE(GetKeyIdsForCommonSystemId(
« no previous file with comments | « media/cdm/cenc_utils.cc ('k') | media/test/data/bear-1280x720-a_frag-cenc.mp4 » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698