OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/formats/webm/webm_content_encodings_client.h" | 5 #include "media/formats/webm/webm_content_encodings_client.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/bind.h" | 9 #include "base/bind.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
46 arg, "Unexpected ContentEncAlgo " + base::IntToString(algo) + "."); | 46 arg, "Unexpected ContentEncAlgo " + base::IntToString(algo) + "."); |
47 } | 47 } |
48 | 48 |
49 class WebMContentEncodingsClientTest : public testing::Test { | 49 class WebMContentEncodingsClientTest : public testing::Test { |
50 public: | 50 public: |
51 WebMContentEncodingsClientTest() | 51 WebMContentEncodingsClientTest() |
52 : media_log_(new StrictMock<MockMediaLog>()), | 52 : media_log_(new StrictMock<MockMediaLog>()), |
53 client_(media_log_), | 53 client_(media_log_), |
54 parser_(kWebMIdContentEncodings, &client_) {} | 54 parser_(kWebMIdContentEncodings, &client_) {} |
55 | 55 |
56 void ParseAndExpectToFail(const uint8* buf, int size) { | 56 void ParseAndExpectToFail(const uint8_t* buf, int size) { |
57 int result = parser_.Parse(buf, size); | 57 int result = parser_.Parse(buf, size); |
58 EXPECT_EQ(-1, result); | 58 EXPECT_EQ(-1, result); |
59 } | 59 } |
60 | 60 |
61 protected: | 61 protected: |
62 scoped_refptr<StrictMock<MockMediaLog>> media_log_; | 62 scoped_refptr<StrictMock<MockMediaLog>> media_log_; |
63 WebMContentEncodingsClient client_; | 63 WebMContentEncodingsClient client_; |
64 WebMListParser parser_; | 64 WebMListParser parser_; |
65 }; | 65 }; |
66 | 66 |
67 TEST_F(WebMContentEncodingsClientTest, EmptyContentEncodings) { | 67 TEST_F(WebMContentEncodingsClientTest, EmptyContentEncodings) { |
68 const uint8 kContentEncodings[] = { | 68 const uint8_t kContentEncodings[] = { |
69 0x6D, 0x80, 0x80, // ContentEncodings (size = 0) | 69 0x6D, 0x80, 0x80, // ContentEncodings (size = 0) |
70 }; | 70 }; |
71 int size = sizeof(kContentEncodings); | 71 int size = sizeof(kContentEncodings); |
72 EXPECT_MEDIA_LOG(MissingContentEncoding()); | 72 EXPECT_MEDIA_LOG(MissingContentEncoding()); |
73 ParseAndExpectToFail(kContentEncodings, size); | 73 ParseAndExpectToFail(kContentEncodings, size); |
74 } | 74 } |
75 | 75 |
76 TEST_F(WebMContentEncodingsClientTest, EmptyContentEncoding) { | 76 TEST_F(WebMContentEncodingsClientTest, EmptyContentEncoding) { |
77 const uint8 kContentEncodings[] = { | 77 const uint8_t kContentEncodings[] = { |
78 0x6D, 0x80, 0x83, // ContentEncodings (size = 3) | 78 0x6D, 0x80, 0x83, // ContentEncodings (size = 3) |
79 0x63, 0x40, 0x80, // ContentEncoding (size = 0) | 79 0x63, 0x40, 0x80, // ContentEncoding (size = 0) |
80 }; | 80 }; |
81 int size = sizeof(kContentEncodings); | 81 int size = sizeof(kContentEncodings); |
82 ParseAndExpectToFail(kContentEncodings, size); | 82 ParseAndExpectToFail(kContentEncodings, size); |
83 } | 83 } |
84 | 84 |
85 TEST_F(WebMContentEncodingsClientTest, SingleContentEncoding) { | 85 TEST_F(WebMContentEncodingsClientTest, SingleContentEncoding) { |
86 const uint8 kContentEncodings[] = { | 86 const uint8_t kContentEncodings[] = { |
87 0x6D, 0x80, 0xA1, // ContentEncodings (size = 33) | 87 0x6D, 0x80, 0xA1, // ContentEncodings (size = 33) |
88 0x62, 0x40, 0x9e, // ContentEncoding (size = 30) | 88 0x62, 0x40, 0x9e, // ContentEncoding (size = 30) |
89 0x50, 0x31, 0x81, 0x00, // ContentEncodingOrder (size = 1) | 89 0x50, 0x31, 0x81, 0x00, // ContentEncodingOrder (size = 1) |
90 0x50, 0x32, 0x81, 0x01, // ContentEncodingScope (size = 1) | 90 0x50, 0x32, 0x81, 0x01, // ContentEncodingScope (size = 1) |
91 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) | 91 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) |
92 0x50, 0x35, 0x8F, // ContentEncryption (size = 15) | 92 0x50, 0x35, 0x8F, // ContentEncryption (size = 15) |
93 0x47, 0xE1, 0x81, 0x05, // ContentEncAlgo (size = 1) | 93 0x47, 0xE1, 0x81, 0x05, // ContentEncAlgo (size = 1) |
94 0x47, 0xE2, 0x88, // ContentEncKeyID (size = 8) | 94 0x47, 0xE2, 0x88, // ContentEncKeyID (size = 8) |
95 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, | 95 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
96 }; | 96 }; |
97 int size = sizeof(kContentEncodings); | 97 int size = sizeof(kContentEncodings); |
98 | 98 |
99 int result = parser_.Parse(kContentEncodings, size); | 99 int result = parser_.Parse(kContentEncodings, size); |
100 ASSERT_EQ(size, result); | 100 ASSERT_EQ(size, result); |
101 const ContentEncodings& content_encodings = client_.content_encodings(); | 101 const ContentEncodings& content_encodings = client_.content_encodings(); |
102 | 102 |
103 ASSERT_EQ(1u, content_encodings.size()); | 103 ASSERT_EQ(1u, content_encodings.size()); |
104 ASSERT_TRUE(content_encodings[0]); | 104 ASSERT_TRUE(content_encodings[0]); |
105 EXPECT_EQ(0, content_encodings[0]->order()); | 105 EXPECT_EQ(0, content_encodings[0]->order()); |
106 EXPECT_EQ(ContentEncoding::kScopeAllFrameContents, | 106 EXPECT_EQ(ContentEncoding::kScopeAllFrameContents, |
107 content_encodings[0]->scope()); | 107 content_encodings[0]->scope()); |
108 EXPECT_EQ(ContentEncoding::kTypeEncryption, content_encodings[0]->type()); | 108 EXPECT_EQ(ContentEncoding::kTypeEncryption, content_encodings[0]->type()); |
109 EXPECT_EQ(ContentEncoding::kEncAlgoAes, | 109 EXPECT_EQ(ContentEncoding::kEncAlgoAes, |
110 content_encodings[0]->encryption_algo()); | 110 content_encodings[0]->encryption_algo()); |
111 EXPECT_EQ(8u, content_encodings[0]->encryption_key_id().size()); | 111 EXPECT_EQ(8u, content_encodings[0]->encryption_key_id().size()); |
112 } | 112 } |
113 | 113 |
114 TEST_F(WebMContentEncodingsClientTest, MultipleContentEncoding) { | 114 TEST_F(WebMContentEncodingsClientTest, MultipleContentEncoding) { |
115 const uint8 kContentEncodings[] = { | 115 const uint8_t kContentEncodings[] = { |
116 0x6D, 0x80, 0xC2, // ContentEncodings (size = 66) | 116 0x6D, 0x80, 0xC2, // ContentEncodings (size = 66) |
117 0x62, 0x40, 0x9e, // ContentEncoding (size = 30) | 117 0x62, 0x40, 0x9e, // ContentEncoding (size = 30) |
118 0x50, 0x31, 0x81, 0x00, // ContentEncodingOrder (size = 1) | 118 0x50, 0x31, 0x81, 0x00, // ContentEncodingOrder (size = 1) |
119 0x50, 0x32, 0x81, 0x03, // ContentEncodingScope (size = 1) | 119 0x50, 0x32, 0x81, 0x03, // ContentEncodingScope (size = 1) |
120 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) | 120 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) |
121 0x50, 0x35, 0x8F, // ContentEncryption (size = 15) | 121 0x50, 0x35, 0x8F, // ContentEncryption (size = 15) |
122 0x47, 0xE1, 0x81, 0x05, // ContentEncAlgo (size = 1) | 122 0x47, 0xE1, 0x81, 0x05, // ContentEncAlgo (size = 1) |
123 0x47, 0xE2, 0x88, // ContentEncKeyID (size = 8) | 123 0x47, 0xE2, 0x88, // ContentEncKeyID (size = 8) |
124 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, | 124 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
125 0x62, 0x40, 0x9e, // ContentEncoding (size = 30) | 125 0x62, 0x40, 0x9e, // ContentEncoding (size = 30) |
126 0x50, 0x31, 0x81, 0x01, // ContentEncodingOrder (size = 1) | 126 0x50, 0x31, 0x81, 0x01, // ContentEncodingOrder (size = 1) |
127 0x50, 0x32, 0x81, 0x03, // ContentEncodingScope (size = 1) | 127 0x50, 0x32, 0x81, 0x03, // ContentEncodingScope (size = 1) |
128 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) | 128 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) |
129 0x50, 0x35, 0x8F, // ContentEncryption (size = 15) | 129 0x50, 0x35, 0x8F, // ContentEncryption (size = 15) |
130 0x47, 0xE1, 0x81, 0x01, // ContentEncAlgo (size = 1) | 130 0x47, 0xE1, 0x81, 0x01, // ContentEncAlgo (size = 1) |
131 0x47, 0xE2, 0x88, // ContentEncKeyID (size = 8) | 131 0x47, 0xE2, 0x88, // ContentEncKeyID (size = 8) |
132 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, | 132 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, 0xBB, |
133 }; | 133 }; |
134 int size = sizeof(kContentEncodings); | 134 int size = sizeof(kContentEncodings); |
135 | 135 |
136 int result = parser_.Parse(kContentEncodings, size); | 136 int result = parser_.Parse(kContentEncodings, size); |
137 ASSERT_EQ(size, result); | 137 ASSERT_EQ(size, result); |
138 const ContentEncodings& content_encodings = client_.content_encodings(); | 138 const ContentEncodings& content_encodings = client_.content_encodings(); |
139 ASSERT_EQ(2u, content_encodings.size()); | 139 ASSERT_EQ(2u, content_encodings.size()); |
140 | 140 |
141 for (int i = 0; i < 2; ++i) { | 141 for (int i = 0; i < 2; ++i) { |
142 ASSERT_TRUE(content_encodings[i]); | 142 ASSERT_TRUE(content_encodings[i]); |
143 EXPECT_EQ(i, content_encodings[i]->order()); | 143 EXPECT_EQ(i, content_encodings[i]->order()); |
144 EXPECT_EQ(ContentEncoding::kScopeAllFrameContents | | 144 EXPECT_EQ(ContentEncoding::kScopeAllFrameContents | |
145 ContentEncoding::kScopeTrackPrivateData, | 145 ContentEncoding::kScopeTrackPrivateData, |
146 content_encodings[i]->scope()); | 146 content_encodings[i]->scope()); |
147 EXPECT_EQ(ContentEncoding::kTypeEncryption, content_encodings[i]->type()); | 147 EXPECT_EQ(ContentEncoding::kTypeEncryption, content_encodings[i]->type()); |
148 EXPECT_EQ(!i ? ContentEncoding::kEncAlgoAes : ContentEncoding::kEncAlgoDes, | 148 EXPECT_EQ(!i ? ContentEncoding::kEncAlgoAes : ContentEncoding::kEncAlgoDes, |
149 content_encodings[i]->encryption_algo()); | 149 content_encodings[i]->encryption_algo()); |
150 EXPECT_EQ(8u, content_encodings[i]->encryption_key_id().size()); | 150 EXPECT_EQ(8u, content_encodings[i]->encryption_key_id().size()); |
151 } | 151 } |
152 } | 152 } |
153 | 153 |
154 TEST_F(WebMContentEncodingsClientTest, DefaultValues) { | 154 TEST_F(WebMContentEncodingsClientTest, DefaultValues) { |
155 const uint8 kContentEncodings[] = { | 155 const uint8_t kContentEncodings[] = { |
156 0x6D, 0x80, 0x8A, // ContentEncodings (size = 10) | 156 0x6D, 0x80, 0x8A, // ContentEncodings (size = 10) |
157 0x62, 0x40, 0x87, // ContentEncoding (size = 7) | 157 0x62, 0x40, 0x87, // ContentEncoding (size = 7) |
158 // ContentEncodingOrder missing | 158 // ContentEncodingOrder missing |
159 // ContentEncodingScope missing | 159 // ContentEncodingScope missing |
160 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) | 160 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) |
161 0x50, 0x35, 0x80, // ContentEncryption (size = 0) | 161 0x50, 0x35, 0x80, // ContentEncryption (size = 0) |
162 // ContentEncAlgo missing | 162 // ContentEncAlgo missing |
163 }; | 163 }; |
164 int size = sizeof(kContentEncodings); | 164 int size = sizeof(kContentEncodings); |
165 | 165 |
166 int result = parser_.Parse(kContentEncodings, size); | 166 int result = parser_.Parse(kContentEncodings, size); |
167 ASSERT_EQ(size, result); | 167 ASSERT_EQ(size, result); |
168 const ContentEncodings& content_encodings = client_.content_encodings(); | 168 const ContentEncodings& content_encodings = client_.content_encodings(); |
169 | 169 |
170 ASSERT_EQ(1u, content_encodings.size()); | 170 ASSERT_EQ(1u, content_encodings.size()); |
171 ASSERT_TRUE(content_encodings[0]); | 171 ASSERT_TRUE(content_encodings[0]); |
172 EXPECT_EQ(0, content_encodings[0]->order()); | 172 EXPECT_EQ(0, content_encodings[0]->order()); |
173 EXPECT_EQ(ContentEncoding::kScopeAllFrameContents, | 173 EXPECT_EQ(ContentEncoding::kScopeAllFrameContents, |
174 content_encodings[0]->scope()); | 174 content_encodings[0]->scope()); |
175 EXPECT_EQ(ContentEncoding::kTypeEncryption, content_encodings[0]->type()); | 175 EXPECT_EQ(ContentEncoding::kTypeEncryption, content_encodings[0]->type()); |
176 EXPECT_EQ(ContentEncoding::kEncAlgoNotEncrypted, | 176 EXPECT_EQ(ContentEncoding::kEncAlgoNotEncrypted, |
177 content_encodings[0]->encryption_algo()); | 177 content_encodings[0]->encryption_algo()); |
178 EXPECT_TRUE(content_encodings[0]->encryption_key_id().empty()); | 178 EXPECT_TRUE(content_encodings[0]->encryption_key_id().empty()); |
179 } | 179 } |
180 | 180 |
181 TEST_F(WebMContentEncodingsClientTest, ContentEncodingsClientReuse) { | 181 TEST_F(WebMContentEncodingsClientTest, ContentEncodingsClientReuse) { |
182 const uint8 kContentEncodings[] = { | 182 const uint8_t kContentEncodings[] = { |
183 0x6D, 0x80, 0xA1, // ContentEncodings (size = 33) | 183 0x6D, 0x80, 0xA1, // ContentEncodings (size = 33) |
184 0x62, 0x40, 0x9e, // ContentEncoding (size = 30) | 184 0x62, 0x40, 0x9e, // ContentEncoding (size = 30) |
185 0x50, 0x31, 0x81, 0x00, // ContentEncodingOrder (size = 1) | 185 0x50, 0x31, 0x81, 0x00, // ContentEncodingOrder (size = 1) |
186 0x50, 0x32, 0x81, 0x01, // ContentEncodingScope (size = 1) | 186 0x50, 0x32, 0x81, 0x01, // ContentEncodingScope (size = 1) |
187 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) | 187 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) |
188 0x50, 0x35, 0x8F, // ContentEncryption (size = 15) | 188 0x50, 0x35, 0x8F, // ContentEncryption (size = 15) |
189 0x47, 0xE1, 0x81, 0x05, // ContentEncAlgo (size = 1) | 189 0x47, 0xE1, 0x81, 0x05, // ContentEncAlgo (size = 1) |
190 0x47, 0xE2, 0x88, // ContentEncKeyID (size = 8) | 190 0x47, 0xE2, 0x88, // ContentEncKeyID (size = 8) |
191 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, | 191 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
192 }; | 192 }; |
193 int size = sizeof(kContentEncodings); | 193 int size = sizeof(kContentEncodings); |
194 | 194 |
195 // Parse for the first time. | 195 // Parse for the first time. |
196 int result = parser_.Parse(kContentEncodings, size); | 196 int result = parser_.Parse(kContentEncodings, size); |
197 ASSERT_EQ(size, result); | 197 ASSERT_EQ(size, result); |
198 | 198 |
199 // Parse again. | 199 // Parse again. |
200 parser_.Reset(); | 200 parser_.Reset(); |
201 result = parser_.Parse(kContentEncodings, size); | 201 result = parser_.Parse(kContentEncodings, size); |
202 ASSERT_EQ(size, result); | 202 ASSERT_EQ(size, result); |
203 const ContentEncodings& content_encodings = client_.content_encodings(); | 203 const ContentEncodings& content_encodings = client_.content_encodings(); |
204 | 204 |
205 ASSERT_EQ(1u, content_encodings.size()); | 205 ASSERT_EQ(1u, content_encodings.size()); |
206 ASSERT_TRUE(content_encodings[0]); | 206 ASSERT_TRUE(content_encodings[0]); |
207 EXPECT_EQ(0, content_encodings[0]->order()); | 207 EXPECT_EQ(0, content_encodings[0]->order()); |
208 EXPECT_EQ(ContentEncoding::kScopeAllFrameContents, | 208 EXPECT_EQ(ContentEncoding::kScopeAllFrameContents, |
209 content_encodings[0]->scope()); | 209 content_encodings[0]->scope()); |
210 EXPECT_EQ(ContentEncoding::kTypeEncryption, content_encodings[0]->type()); | 210 EXPECT_EQ(ContentEncoding::kTypeEncryption, content_encodings[0]->type()); |
211 EXPECT_EQ(ContentEncoding::kEncAlgoAes, | 211 EXPECT_EQ(ContentEncoding::kEncAlgoAes, |
212 content_encodings[0]->encryption_algo()); | 212 content_encodings[0]->encryption_algo()); |
213 EXPECT_EQ(8u, content_encodings[0]->encryption_key_id().size()); | 213 EXPECT_EQ(8u, content_encodings[0]->encryption_key_id().size()); |
214 } | 214 } |
215 | 215 |
216 TEST_F(WebMContentEncodingsClientTest, InvalidContentEncodingOrder) { | 216 TEST_F(WebMContentEncodingsClientTest, InvalidContentEncodingOrder) { |
217 const uint8 kContentEncodings[] = { | 217 const uint8_t kContentEncodings[] = { |
218 0x6D, 0x80, 0x8E, // ContentEncodings (size = 14) | 218 0x6D, 0x80, 0x8E, // ContentEncodings (size = 14) |
219 0x62, 0x40, 0x8B, // ContentEncoding (size = 11) | 219 0x62, 0x40, 0x8B, // ContentEncoding (size = 11) |
220 0x50, 0x31, 0x81, 0xEE, // ContentEncodingOrder (size = 1), invalid | 220 0x50, 0x31, 0x81, 0xEE, // ContentEncodingOrder (size = 1), invalid |
221 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) | 221 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) |
222 0x50, 0x35, 0x80, // ContentEncryption (size = 0) | 222 0x50, 0x35, 0x80, // ContentEncryption (size = 0) |
223 }; | 223 }; |
224 int size = sizeof(kContentEncodings); | 224 int size = sizeof(kContentEncodings); |
225 EXPECT_MEDIA_LOG(UnexpectedContentEncodingOrder()); | 225 EXPECT_MEDIA_LOG(UnexpectedContentEncodingOrder()); |
226 ParseAndExpectToFail(kContentEncodings, size); | 226 ParseAndExpectToFail(kContentEncodings, size); |
227 } | 227 } |
228 | 228 |
229 TEST_F(WebMContentEncodingsClientTest, InvalidContentEncodingScope) { | 229 TEST_F(WebMContentEncodingsClientTest, InvalidContentEncodingScope) { |
230 const uint8 kContentEncodings[] = { | 230 const uint8_t kContentEncodings[] = { |
231 0x6D, 0x80, 0x8E, // ContentEncodings (size = 14) | 231 0x6D, 0x80, 0x8E, // ContentEncodings (size = 14) |
232 0x62, 0x40, 0x8B, // ContentEncoding (size = 11) | 232 0x62, 0x40, 0x8B, // ContentEncoding (size = 11) |
233 0x50, 0x32, 0x81, 0xEE, // ContentEncodingScope (size = 1), invalid | 233 0x50, 0x32, 0x81, 0xEE, // ContentEncodingScope (size = 1), invalid |
234 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) | 234 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) |
235 0x50, 0x35, 0x80, // ContentEncryption (size = 0) | 235 0x50, 0x35, 0x80, // ContentEncryption (size = 0) |
236 }; | 236 }; |
237 int size = sizeof(kContentEncodings); | 237 int size = sizeof(kContentEncodings); |
238 EXPECT_MEDIA_LOG(UnexpectedContentEncodingScope()); | 238 EXPECT_MEDIA_LOG(UnexpectedContentEncodingScope()); |
239 ParseAndExpectToFail(kContentEncodings, size); | 239 ParseAndExpectToFail(kContentEncodings, size); |
240 } | 240 } |
241 | 241 |
242 TEST_F(WebMContentEncodingsClientTest, InvalidContentEncodingType) { | 242 TEST_F(WebMContentEncodingsClientTest, InvalidContentEncodingType) { |
243 const uint8 kContentEncodings[] = { | 243 const uint8_t kContentEncodings[] = { |
244 0x6D, 0x80, 0x8E, // ContentEncodings (size = 14) | 244 0x6D, 0x80, 0x8E, // ContentEncodings (size = 14) |
245 0x62, 0x40, 0x8B, // ContentEncoding (size = 11) | 245 0x62, 0x40, 0x8B, // ContentEncoding (size = 11) |
246 0x50, 0x33, 0x81, 0x00, // ContentEncodingType (size = 1), invalid | 246 0x50, 0x33, 0x81, 0x00, // ContentEncodingType (size = 1), invalid |
247 0x50, 0x35, 0x80, // ContentEncryption (size = 0) | 247 0x50, 0x35, 0x80, // ContentEncryption (size = 0) |
248 }; | 248 }; |
249 int size = sizeof(kContentEncodings); | 249 int size = sizeof(kContentEncodings); |
250 EXPECT_MEDIA_LOG(ContentCompressionNotSupported()); | 250 EXPECT_MEDIA_LOG(ContentCompressionNotSupported()); |
251 ParseAndExpectToFail(kContentEncodings, size); | 251 ParseAndExpectToFail(kContentEncodings, size); |
252 } | 252 } |
253 | 253 |
254 // ContentEncodingType is encryption but no ContentEncryption present. | 254 // ContentEncodingType is encryption but no ContentEncryption present. |
255 TEST_F(WebMContentEncodingsClientTest, MissingContentEncryption) { | 255 TEST_F(WebMContentEncodingsClientTest, MissingContentEncryption) { |
256 const uint8 kContentEncodings[] = { | 256 const uint8_t kContentEncodings[] = { |
257 0x6D, 0x80, 0x87, // ContentEncodings (size = 7) | 257 0x6D, 0x80, 0x87, // ContentEncodings (size = 7) |
258 0x62, 0x40, 0x84, // ContentEncoding (size = 4) | 258 0x62, 0x40, 0x84, // ContentEncoding (size = 4) |
259 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) | 259 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) |
260 // ContentEncryption missing | 260 // ContentEncryption missing |
261 }; | 261 }; |
262 int size = sizeof(kContentEncodings); | 262 int size = sizeof(kContentEncodings); |
263 EXPECT_MEDIA_LOG(MissingContentEncryption()); | 263 EXPECT_MEDIA_LOG(MissingContentEncryption()); |
264 ParseAndExpectToFail(kContentEncodings, size); | 264 ParseAndExpectToFail(kContentEncodings, size); |
265 } | 265 } |
266 | 266 |
267 TEST_F(WebMContentEncodingsClientTest, InvalidContentEncAlgo) { | 267 TEST_F(WebMContentEncodingsClientTest, InvalidContentEncAlgo) { |
268 const uint8 kContentEncodings[] = { | 268 const uint8_t kContentEncodings[] = { |
269 0x6D, 0x80, 0x99, // ContentEncodings (size = 25) | 269 0x6D, 0x80, 0x99, // ContentEncodings (size = 25) |
270 0x62, 0x40, 0x96, // ContentEncoding (size = 22) | 270 0x62, 0x40, 0x96, // ContentEncoding (size = 22) |
271 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) | 271 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) |
272 0x50, 0x35, 0x8F, // ContentEncryption (size = 15) | 272 0x50, 0x35, 0x8F, // ContentEncryption (size = 15) |
273 0x47, 0xE1, 0x81, 0xEE, // ContentEncAlgo (size = 1), invalid | 273 0x47, 0xE1, 0x81, 0xEE, // ContentEncAlgo (size = 1), invalid |
274 0x47, 0xE2, 0x88, // ContentEncKeyID (size = 8) | 274 0x47, 0xE2, 0x88, // ContentEncKeyID (size = 8) |
275 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, | 275 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
276 }; | 276 }; |
277 int size = sizeof(kContentEncodings); | 277 int size = sizeof(kContentEncodings); |
278 EXPECT_MEDIA_LOG(UnexpectedContentEncAlgo(0xEE)); | 278 EXPECT_MEDIA_LOG(UnexpectedContentEncAlgo(0xEE)); |
279 ParseAndExpectToFail(kContentEncodings, size); | 279 ParseAndExpectToFail(kContentEncodings, size); |
280 } | 280 } |
281 | 281 |
282 } // namespace media | 282 } // namespace media |
OLD | NEW |