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 <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 } | 44 } |
45 | 45 |
46 MATCHER_P(UnexpectedContentEncAlgo, algo, "") { | 46 MATCHER_P(UnexpectedContentEncAlgo, algo, "") { |
47 return CONTAINS_STRING( | 47 return CONTAINS_STRING( |
48 arg, "Unexpected ContentEncAlgo " + base::IntToString(algo) + "."); | 48 arg, "Unexpected ContentEncAlgo " + base::IntToString(algo) + "."); |
49 } | 49 } |
50 | 50 |
51 class WebMContentEncodingsClientTest : public testing::Test { | 51 class WebMContentEncodingsClientTest : public testing::Test { |
52 public: | 52 public: |
53 WebMContentEncodingsClientTest() | 53 WebMContentEncodingsClientTest() |
54 : media_log_(new StrictMock<MockMediaLog>()), | 54 : client_(&media_log_), parser_(kWebMIdContentEncodings, &client_) {} |
55 client_(media_log_), | |
56 parser_(kWebMIdContentEncodings, &client_) {} | |
57 | 55 |
58 void ParseAndExpectToFail(const uint8_t* buf, int size) { | 56 void ParseAndExpectToFail(const uint8_t* buf, int size) { |
59 int result = parser_.Parse(buf, size); | 57 int result = parser_.Parse(buf, size); |
60 EXPECT_EQ(-1, result); | 58 EXPECT_EQ(-1, result); |
61 } | 59 } |
62 | 60 |
63 protected: | 61 protected: |
64 scoped_refptr<StrictMock<MockMediaLog>> media_log_; | 62 StrictMock<MockMediaLog> media_log_; |
65 WebMContentEncodingsClient client_; | 63 WebMContentEncodingsClient client_; |
66 WebMListParser parser_; | 64 WebMListParser parser_; |
67 }; | 65 }; |
68 | 66 |
69 TEST_F(WebMContentEncodingsClientTest, EmptyContentEncodings) { | 67 TEST_F(WebMContentEncodingsClientTest, EmptyContentEncodings) { |
70 const uint8_t kContentEncodings[] = { | 68 const uint8_t kContentEncodings[] = { |
71 0x6D, 0x80, 0x80, // ContentEncodings (size = 0) | 69 0x6D, 0x80, 0x80, // ContentEncodings (size = 0) |
72 }; | 70 }; |
73 int size = sizeof(kContentEncodings); | 71 int size = sizeof(kContentEncodings); |
74 EXPECT_MEDIA_LOG(MissingContentEncoding()); | 72 EXPECT_MEDIA_LOG(MissingContentEncoding()); |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 0x47, 0xE1, 0x81, 0xEE, // ContentEncAlgo (size = 1), invalid | 273 0x47, 0xE1, 0x81, 0xEE, // ContentEncAlgo (size = 1), invalid |
276 0x47, 0xE2, 0x88, // ContentEncKeyID (size = 8) | 274 0x47, 0xE2, 0x88, // ContentEncKeyID (size = 8) |
277 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, | 275 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
278 }; | 276 }; |
279 int size = sizeof(kContentEncodings); | 277 int size = sizeof(kContentEncodings); |
280 EXPECT_MEDIA_LOG(UnexpectedContentEncAlgo(0xEE)); | 278 EXPECT_MEDIA_LOG(UnexpectedContentEncAlgo(0xEE)); |
281 ParseAndExpectToFail(kContentEncodings, size); | 279 ParseAndExpectToFail(kContentEncodings, size); |
282 } | 280 } |
283 | 281 |
284 } // namespace media | 282 } // namespace media |
OLD | NEW |