OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/webm/webm_constants.h" | 5 #include "media/webm/webm_constants.h" |
6 #include "media/webm/webm_content_encodings_client.h" | 6 #include "media/webm/webm_content_encodings_client.h" |
7 #include "media/webm/webm_parser.h" | 7 #include "media/webm/webm_parser.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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 const ContentEncodings& content_encodings = client_.content_encodings(); | 60 const ContentEncodings& content_encodings = client_.content_encodings(); |
61 | 61 |
62 ASSERT_EQ(1u, content_encodings.size()); | 62 ASSERT_EQ(1u, content_encodings.size()); |
63 ASSERT_TRUE(content_encodings[0]); | 63 ASSERT_TRUE(content_encodings[0]); |
64 EXPECT_EQ(0, content_encodings[0]->order()); | 64 EXPECT_EQ(0, content_encodings[0]->order()); |
65 EXPECT_EQ(ContentEncoding::kScopeAllFrameContents, | 65 EXPECT_EQ(ContentEncoding::kScopeAllFrameContents, |
66 content_encodings[0]->scope()); | 66 content_encodings[0]->scope()); |
67 EXPECT_EQ(ContentEncoding::kTypeEncryption, content_encodings[0]->type()); | 67 EXPECT_EQ(ContentEncoding::kTypeEncryption, content_encodings[0]->type()); |
68 EXPECT_EQ(ContentEncoding::kEncAlgoAes, | 68 EXPECT_EQ(ContentEncoding::kEncAlgoAes, |
69 content_encodings[0]->encryption_algo()); | 69 content_encodings[0]->encryption_algo()); |
70 EXPECT_TRUE(content_encodings[0]->encryption_key_id()); | 70 EXPECT_EQ(8u, content_encodings[0]->encryption_key_id().size()); |
71 EXPECT_EQ(8, content_encodings[0]->encryption_key_id_size()); | |
72 } | 71 } |
73 | 72 |
74 TEST_F(WebMContentEncodingsClientTest, MultipleContentEncoding) { | 73 TEST_F(WebMContentEncodingsClientTest, MultipleContentEncoding) { |
75 const uint8 kContentEncodings[] = { | 74 const uint8 kContentEncodings[] = { |
76 0x6D, 0x80, 0xC2, // ContentEncodings (size = 66) | 75 0x6D, 0x80, 0xC2, // ContentEncodings (size = 66) |
77 0x62, 0x40, 0x9e, // ContentEncoding (size = 30) | 76 0x62, 0x40, 0x9e, // ContentEncoding (size = 30) |
78 0x50, 0x31, 0x81, 0x00, // ContentEncodingOrder (size = 1) | 77 0x50, 0x31, 0x81, 0x00, // ContentEncodingOrder (size = 1) |
79 0x50, 0x32, 0x81, 0x03, // ContentEncodingScope (size = 1) | 78 0x50, 0x32, 0x81, 0x03, // ContentEncodingScope (size = 1) |
80 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) | 79 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) |
81 0x50, 0x35, 0x8F, // ContentEncryption (size = 15) | 80 0x50, 0x35, 0x8F, // ContentEncryption (size = 15) |
(...skipping 18 matching lines...) Expand all Loading... |
100 | 99 |
101 for (int i = 0; i < 2; ++i) { | 100 for (int i = 0; i < 2; ++i) { |
102 ASSERT_TRUE(content_encodings[i]); | 101 ASSERT_TRUE(content_encodings[i]); |
103 EXPECT_EQ(i, content_encodings[i]->order()); | 102 EXPECT_EQ(i, content_encodings[i]->order()); |
104 EXPECT_EQ(ContentEncoding::kScopeAllFrameContents | | 103 EXPECT_EQ(ContentEncoding::kScopeAllFrameContents | |
105 ContentEncoding::kScopeTrackPrivateData, | 104 ContentEncoding::kScopeTrackPrivateData, |
106 content_encodings[i]->scope()); | 105 content_encodings[i]->scope()); |
107 EXPECT_EQ(ContentEncoding::kTypeEncryption, content_encodings[i]->type()); | 106 EXPECT_EQ(ContentEncoding::kTypeEncryption, content_encodings[i]->type()); |
108 EXPECT_EQ(!i ? ContentEncoding::kEncAlgoAes : ContentEncoding::kEncAlgoDes, | 107 EXPECT_EQ(!i ? ContentEncoding::kEncAlgoAes : ContentEncoding::kEncAlgoDes, |
109 content_encodings[i]->encryption_algo()); | 108 content_encodings[i]->encryption_algo()); |
110 EXPECT_TRUE(content_encodings[i]->encryption_key_id()); | 109 EXPECT_EQ(8u, content_encodings[i]->encryption_key_id().size()); |
111 EXPECT_EQ(8, content_encodings[i]->encryption_key_id_size()); | |
112 } | 110 } |
113 } | 111 } |
114 | 112 |
115 TEST_F(WebMContentEncodingsClientTest, DefaultValues) { | 113 TEST_F(WebMContentEncodingsClientTest, DefaultValues) { |
116 const uint8 kContentEncodings[] = { | 114 const uint8 kContentEncodings[] = { |
117 0x6D, 0x80, 0x8A, // ContentEncodings (size = 10) | 115 0x6D, 0x80, 0x8A, // ContentEncodings (size = 10) |
118 0x62, 0x40, 0x87, // ContentEncoding (size = 7) | 116 0x62, 0x40, 0x87, // ContentEncoding (size = 7) |
119 // ContentEncodingOrder missing | 117 // ContentEncodingOrder missing |
120 // ContentEncodingScope missing | 118 // ContentEncodingScope missing |
121 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) | 119 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) |
122 0x50, 0x35, 0x80, // ContentEncryption (size = 0) | 120 0x50, 0x35, 0x80, // ContentEncryption (size = 0) |
123 // ContentEncAlgo missing | 121 // ContentEncAlgo missing |
124 }; | 122 }; |
125 int size = sizeof(kContentEncodings); | 123 int size = sizeof(kContentEncodings); |
126 | 124 |
127 int result = parser_.Parse(kContentEncodings, size); | 125 int result = parser_.Parse(kContentEncodings, size); |
128 ASSERT_EQ(size, result); | 126 ASSERT_EQ(size, result); |
129 const ContentEncodings& content_encodings = client_.content_encodings(); | 127 const ContentEncodings& content_encodings = client_.content_encodings(); |
130 | 128 |
131 ASSERT_EQ(1u, content_encodings.size()); | 129 ASSERT_EQ(1u, content_encodings.size()); |
132 ASSERT_TRUE(content_encodings[0]); | 130 ASSERT_TRUE(content_encodings[0]); |
133 EXPECT_EQ(0, content_encodings[0]->order()); | 131 EXPECT_EQ(0, content_encodings[0]->order()); |
134 EXPECT_EQ(ContentEncoding::kScopeAllFrameContents, | 132 EXPECT_EQ(ContentEncoding::kScopeAllFrameContents, |
135 content_encodings[0]->scope()); | 133 content_encodings[0]->scope()); |
136 EXPECT_EQ(ContentEncoding::kTypeEncryption, content_encodings[0]->type()); | 134 EXPECT_EQ(ContentEncoding::kTypeEncryption, content_encodings[0]->type()); |
137 EXPECT_EQ(ContentEncoding::kEncAlgoNotEncrypted, | 135 EXPECT_EQ(ContentEncoding::kEncAlgoNotEncrypted, |
138 content_encodings[0]->encryption_algo()); | 136 content_encodings[0]->encryption_algo()); |
139 EXPECT_FALSE(content_encodings[0]->encryption_key_id()); | 137 EXPECT_TRUE(content_encodings[0]->encryption_key_id().empty()); |
140 EXPECT_EQ(0, content_encodings[0]->encryption_key_id_size()); | |
141 } | 138 } |
142 | 139 |
143 TEST_F(WebMContentEncodingsClientTest, ContentEncodingsClientReuse) { | 140 TEST_F(WebMContentEncodingsClientTest, ContentEncodingsClientReuse) { |
144 const uint8 kContentEncodings[] = { | 141 const uint8 kContentEncodings[] = { |
145 0x6D, 0x80, 0xA1, // ContentEncodings (size = 33) | 142 0x6D, 0x80, 0xA1, // ContentEncodings (size = 33) |
146 0x62, 0x40, 0x9e, // ContentEncoding (size = 30) | 143 0x62, 0x40, 0x9e, // ContentEncoding (size = 30) |
147 0x50, 0x31, 0x81, 0x00, // ContentEncodingOrder (size = 1) | 144 0x50, 0x31, 0x81, 0x00, // ContentEncodingOrder (size = 1) |
148 0x50, 0x32, 0x81, 0x01, // ContentEncodingScope (size = 1) | 145 0x50, 0x32, 0x81, 0x01, // ContentEncodingScope (size = 1) |
149 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) | 146 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) |
150 0x50, 0x35, 0x8F, // ContentEncryption (size = 15) | 147 0x50, 0x35, 0x8F, // ContentEncryption (size = 15) |
(...skipping 14 matching lines...) Expand all Loading... |
165 const ContentEncodings& content_encodings = client_.content_encodings(); | 162 const ContentEncodings& content_encodings = client_.content_encodings(); |
166 | 163 |
167 ASSERT_EQ(1u, content_encodings.size()); | 164 ASSERT_EQ(1u, content_encodings.size()); |
168 ASSERT_TRUE(content_encodings[0]); | 165 ASSERT_TRUE(content_encodings[0]); |
169 EXPECT_EQ(0, content_encodings[0]->order()); | 166 EXPECT_EQ(0, content_encodings[0]->order()); |
170 EXPECT_EQ(ContentEncoding::kScopeAllFrameContents, | 167 EXPECT_EQ(ContentEncoding::kScopeAllFrameContents, |
171 content_encodings[0]->scope()); | 168 content_encodings[0]->scope()); |
172 EXPECT_EQ(ContentEncoding::kTypeEncryption, content_encodings[0]->type()); | 169 EXPECT_EQ(ContentEncoding::kTypeEncryption, content_encodings[0]->type()); |
173 EXPECT_EQ(ContentEncoding::kEncAlgoAes, | 170 EXPECT_EQ(ContentEncoding::kEncAlgoAes, |
174 content_encodings[0]->encryption_algo()); | 171 content_encodings[0]->encryption_algo()); |
175 EXPECT_TRUE(content_encodings[0]->encryption_key_id()); | 172 EXPECT_EQ(8u, content_encodings[0]->encryption_key_id().size()); |
176 EXPECT_EQ(8, content_encodings[0]->encryption_key_id_size()); | |
177 } | 173 } |
178 | 174 |
179 TEST_F(WebMContentEncodingsClientTest, InvalidContentEncodingOrder) { | 175 TEST_F(WebMContentEncodingsClientTest, InvalidContentEncodingOrder) { |
180 const uint8 kContentEncodings[] = { | 176 const uint8 kContentEncodings[] = { |
181 0x6D, 0x80, 0x8E, // ContentEncodings (size = 14) | 177 0x6D, 0x80, 0x8E, // ContentEncodings (size = 14) |
182 0x62, 0x40, 0x8B, // ContentEncoding (size = 11) | 178 0x62, 0x40, 0x8B, // ContentEncoding (size = 11) |
183 0x50, 0x31, 0x81, 0xEE, // ContentEncodingOrder (size = 1), invalid | 179 0x50, 0x31, 0x81, 0xEE, // ContentEncodingOrder (size = 1), invalid |
184 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) | 180 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) |
185 0x50, 0x35, 0x80, // ContentEncryption (size = 0) | 181 0x50, 0x35, 0x80, // ContentEncryption (size = 0) |
186 }; | 182 }; |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) | 226 0x50, 0x33, 0x81, 0x01, // ContentEncodingType (size = 1) |
231 0x50, 0x35, 0x8F, // ContentEncryption (size = 15) | 227 0x50, 0x35, 0x8F, // ContentEncryption (size = 15) |
232 0x47, 0xE1, 0x81, 0xEE, // ContentEncAlgo (size = 1), invalid | 228 0x47, 0xE1, 0x81, 0xEE, // ContentEncAlgo (size = 1), invalid |
233 0x47, 0xE2, 0x88, // ContentEncKeyID (size = 8) | 229 0x47, 0xE2, 0x88, // ContentEncKeyID (size = 8) |
234 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, | 230 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, |
235 }; | 231 }; |
236 int size = sizeof(kContentEncodings); | 232 int size = sizeof(kContentEncodings); |
237 ParseAndExpectToFail(kContentEncodings, size); | 233 ParseAndExpectToFail(kContentEncodings, size); |
238 } | 234 } |
239 | 235 |
240 } // media | 236 } // namespace media |
OLD | NEW |