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

Side by Side Diff: chromecast/media/cdm/chromecast_init_data_unittest.cc

Issue 1168153003: Chromecast PSSH boxes must use data_size parameter. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 unified diff | Download patch
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 "chromecast/media/cdm/chromecast_init_data.h" 5 #include "chromecast/media/cdm/chromecast_init_data.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 InitDataMessageType::CUSTOM_DATA, &init_data)); 55 InitDataMessageType::CUSTOM_DATA, &init_data));
56 56
57 EXPECT_EQ(InitDataMessageType::CUSTOM_DATA, init_data.type); 57 EXPECT_EQ(InitDataMessageType::CUSTOM_DATA, init_data.type);
58 EXPECT_EQ(16u, init_data.data.size()); 58 EXPECT_EQ(16u, init_data.data.size());
59 EXPECT_EQ("Test custom data", 59 EXPECT_EQ("Test custom data",
60 std::string(init_data.data.begin(), init_data.data.end())); 60 std::string(init_data.data.begin(), init_data.data.end()));
61 } 61 }
62 62
63 TEST(ChromecastInitDataTest, TestPsshCustomData) { 63 TEST(ChromecastInitDataTest, TestPsshCustomData) {
64 const uint8_t kInitDataBlob[] = { 64 const uint8_t kInitDataBlob[] = {
65 0x00, 0x00, 0x00, 0x2E, // length 65 0x00, 0x00, 0x00, 0x32, // length
66 0x70, 0x73, 0x73, 0x68, // 'pssh' 66 0x70, 0x73, 0x73, 0x68, // 'pssh'
67 0x00, 0x00, 0x00, 0x00, // version / flags 67 0x00, 0x00, 0x00, 0x00, // version / flags
68 0x2B, 0xF8, 0x66, 0x80, 0xC6, 0xE5, 0x4E, 0x24, 0xBE, 68 0x2B, 0xF8, 0x66, 0x80, 0xC6, 0xE5, 0x4E, 0x24, 0xBE,
69 0x23, 0x0F, 0x81, 0x5A, 0x60, 0x6E, 0xB2, // UUID 69 0x23, 0x0F, 0x81, 0x5A, 0x60, 0x6E, 0xB2, // UUID
70 0x00, 0x00, 0x00, 0x12, // data size
70 0x00, 0x01, // message type (CUSTOM_DATA) 71 0x00, 0x01, // message type (CUSTOM_DATA)
71 0x54, 0x65, 0x73, 0x74, 0x20, 0x63, 0x75, 0x73, 0x74, 72 0x54, 0x65, 0x73, 0x74, 0x20, 0x63, 0x75, 0x73, 0x74,
72 0x6F, 0x6D, 0x20, 0x64, 0x61, 0x74, 0x61 // 'Test custom data' 73 0x6F, 0x6D, 0x20, 0x64, 0x61, 0x74, 0x61 // 'Test custom data'
73 }; 74 };
74 75
75 ChromecastInitData init_data; 76 ChromecastInitData init_data;
76 EXPECT_TRUE(FindChromecastInitData( 77 EXPECT_TRUE(FindChromecastInitData(
77 std::vector<uint8_t>(kInitDataBlob, 78 std::vector<uint8_t>(kInitDataBlob,
78 kInitDataBlob + sizeof(kInitDataBlob)), 79 kInitDataBlob + sizeof(kInitDataBlob)),
79 InitDataMessageType::CUSTOM_DATA, &init_data)); 80 InitDataMessageType::CUSTOM_DATA, &init_data));
80 81
81 EXPECT_EQ(InitDataMessageType::CUSTOM_DATA, init_data.type); 82 EXPECT_EQ(InitDataMessageType::CUSTOM_DATA, init_data.type);
82 EXPECT_EQ(16u, init_data.data.size()); 83 EXPECT_EQ(16u, init_data.data.size());
83 EXPECT_EQ("Test custom data", 84 EXPECT_EQ("Test custom data",
84 std::string(init_data.data.begin(), init_data.data.end())); 85 std::string(init_data.data.begin(), init_data.data.end()));
85 } 86 }
86 87
88 TEST(ChromecastInitDataTest, TestPsshCustomData_NoSize) {
89 const uint8_t kInitDataBlob[] = {
90 0x00, 0x00, 0x00, 0x2E, // length
91 0x70, 0x73, 0x73, 0x68, // 'pssh'
92 0x00, 0x00, 0x00, 0x00, // version / flags
93 0x2B, 0xF8, 0x66, 0x80, 0xC6, 0xE5, 0x4E, 0x24, 0xBE,
94 0x23, 0x0F, 0x81, 0x5A, 0x60, 0x6E, 0xB2, // UUID
95 // [missing size should be present here].
96 0x00, 0x01, // message type (CUSTOM_DATA)
97 0x54, 0x65, 0x73, 0x74, 0x20, 0x63, 0x75, 0x73, 0x74,
98 0x6F, 0x6D, 0x20, 0x64, 0x61, 0x74, 0x61 // 'Test custom data'
99 };
100
101 ChromecastInitData init_data;
102 EXPECT_FALSE(FindChromecastInitData(
103 std::vector<uint8_t>(kInitDataBlob,
104 kInitDataBlob + sizeof(kInitDataBlob)),
105 InitDataMessageType::CUSTOM_DATA, &init_data));
106 }
107
87 TEST(ChromecastInitDataTest, TestPsshSecureStop) { 108 TEST(ChromecastInitDataTest, TestPsshSecureStop) {
88 const uint8_t kInitDataBlob[] = { 109 const uint8_t kInitDataBlob[] = {
89 0x00, 0x00, 0x00, 0x1E, // length 110 0x00, 0x00, 0x00, 0x22, // length
90 0x70, 0x73, 0x73, 0x68, // 'pssh' 111 0x70, 0x73, 0x73, 0x68, // 'pssh'
91 0x00, 0x00, 0x00, 0x00, // version / flags 112 0x00, 0x00, 0x00, 0x00, // version / flags
92 0x2B, 0xF8, 0x66, 0x80, 0xC6, 0xE5, 0x4E, 0x24, 113 0x2B, 0xF8, 0x66, 0x80, 0xC6, 0xE5, 0x4E, 0x24,
93 0xBE, 0x23, 0x0F, 0x81, 0x5A, 0x60, 0x6E, 0xB2, // UUID 114 0xBE, 0x23, 0x0F, 0x81, 0x5A, 0x60, 0x6E, 0xB2, // UUID
115 0x00, 0x00, 0x00, 0x02, // data size
94 0x00, 0x02, // message type (ENABLE_SECURE_STOP) 116 0x00, 0x02, // message type (ENABLE_SECURE_STOP)
95 }; 117 };
96 118
97 ChromecastInitData init_data; 119 ChromecastInitData init_data;
98 EXPECT_TRUE(FindChromecastInitData( 120 EXPECT_TRUE(FindChromecastInitData(
99 std::vector<uint8_t>(kInitDataBlob, 121 std::vector<uint8_t>(kInitDataBlob,
100 kInitDataBlob + sizeof(kInitDataBlob)), 122 kInitDataBlob + sizeof(kInitDataBlob)),
101 InitDataMessageType::ENABLE_SECURE_STOP, &init_data)); 123 InitDataMessageType::ENABLE_SECURE_STOP, &init_data));
102 124
103 EXPECT_EQ(InitDataMessageType::ENABLE_SECURE_STOP, init_data.type); 125 EXPECT_EQ(InitDataMessageType::ENABLE_SECURE_STOP, init_data.type);
104 EXPECT_EQ(0u, init_data.data.size()); 126 EXPECT_EQ(0u, init_data.data.size());
105 } 127 }
106 128
129 TEST(ChromecastInitDataTest, TestPsshSecureStop_NoSize) {
130 const uint8_t kInitDataBlob[] = {
131 0x00, 0x00, 0x00, 0x1E, // length
132 0x70, 0x73, 0x73, 0x68, // 'pssh'
133 0x00, 0x00, 0x00, 0x00, // version / flags
134 0x2B, 0xF8, 0x66, 0x80, 0xC6, 0xE5, 0x4E, 0x24,
135 0xBE, 0x23, 0x0F, 0x81, 0x5A, 0x60, 0x6E, 0xB2, // UUID
136 // [missing size should be present here].
137 0x00, 0x02, // message type (ENABLE_SECURE_STOP)
138 };
139
140 ChromecastInitData init_data;
141 EXPECT_FALSE(FindChromecastInitData(
142 std::vector<uint8_t>(kInitDataBlob,
143 kInitDataBlob + sizeof(kInitDataBlob)),
144 InitDataMessageType::ENABLE_SECURE_STOP, &init_data));
145 }
146
107 } // namespace media 147 } // namespace media
108 } // namespace chromecast 148 } // namespace chromecast
OLDNEW
« chromecast/media/cdm/chromecast_init_data.cc ('K') | « chromecast/media/cdm/chromecast_init_data.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698