| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/cdm/cenc_utils.h" | 5 #include "media/cdm/cenc_utils.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 | 9 |
| 10 namespace media { | 10 namespace media { |
| (...skipping 504 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 515 | 515 |
| 516 std::vector<uint8_t> box2 = MakePSSHBox(0); | 516 std::vector<uint8_t> box2 = MakePSSHBox(0); |
| 517 std::vector<uint8_t> data2(data2_bytes, data2_bytes + arraysize(data2_bytes)); | 517 std::vector<uint8_t> data2(data2_bytes, data2_bytes + arraysize(data2_bytes)); |
| 518 AppendData(box2, data2); | 518 AppendData(box2, data2); |
| 519 | 519 |
| 520 box1.insert(box1.end(), box2.begin(), box2.end()); | 520 box1.insert(box1.end(), box2.begin(), box2.end()); |
| 521 EXPECT_TRUE(GetPsshData(box1, CommonSystemSystemId(), &pssh_data)); | 521 EXPECT_TRUE(GetPsshData(box1, CommonSystemSystemId(), &pssh_data)); |
| 522 EXPECT_EQ(data1, pssh_data); | 522 EXPECT_EQ(data1, pssh_data); |
| 523 EXPECT_NE(data2, pssh_data); | 523 EXPECT_NE(data2, pssh_data); |
| 524 } | 524 } |
| 525 |
| 526 TEST_F(CencUtilsTest, NonPsshData) { |
| 527 // Create a non-'pssh' box. |
| 528 const uint8_t data[] = { |
| 529 0x00, 0x00, 0x00, 0x08, // size = 8 |
| 530 'p', 's', 's', 'g' |
| 531 }; |
| 532 std::vector<uint8_t> non_pssh_box(data, data + arraysize(data)); |
| 533 EXPECT_FALSE(ValidatePsshInput(non_pssh_box)); |
| 534 |
| 535 // Make a valid 'pssh' box. |
| 536 std::vector<uint8_t> pssh_box = MakePSSHBox(1, Key1()); |
| 537 EXPECT_TRUE(ValidatePsshInput(pssh_box)); |
| 538 |
| 539 // Concatentate the boxes together (|pssh_box| first). |
| 540 std::vector<uint8_t> boxes; |
| 541 boxes.insert(boxes.end(), pssh_box.begin(), pssh_box.end()); |
| 542 boxes.insert(boxes.end(), non_pssh_box.begin(), non_pssh_box.end()); |
| 543 EXPECT_FALSE(ValidatePsshInput(boxes)); |
| 544 |
| 545 // Repeat with |non_pssh_box| first. |
| 546 boxes.clear(); |
| 547 boxes.insert(boxes.end(), non_pssh_box.begin(), non_pssh_box.end()); |
| 548 boxes.insert(boxes.end(), pssh_box.begin(), pssh_box.end()); |
| 549 EXPECT_FALSE(ValidatePsshInput(boxes)); |
| 550 } |
| 551 |
| 525 } // namespace media | 552 } // namespace media |
| OLD | NEW |