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

Side by Side Diff: media/cdm/cenc_utils_unittest.cc

Issue 1189073004: Properly verify that input data is just 'pssh' boxes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Android compile issues Created 5 years, 5 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 unified diff | Download patch
« no previous file with comments | « media/cdm/cenc_utils.cc ('k') | media/formats/mp4/box_reader.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « media/cdm/cenc_utils.cc ('k') | media/formats/mp4/box_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698