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/cluster_builder.h" | 5 #include "media/webm/cluster_builder.h" |
6 #include "media/webm/webm_constants.h" | 6 #include "media/webm/webm_constants.h" |
7 #include "media/webm/webm_parser.h" | 7 #include "media/webm/webm_parser.h" |
8 #include "testing/gmock/include/gmock/gmock.h" | 8 #include "testing/gmock/include/gmock/gmock.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
360 int id; | 360 int id; |
361 int64 element_size; | 361 int64 element_size; |
362 int buffer_size = 2 + i; | 362 int buffer_size = 2 + i; |
363 EXPECT_EQ(buffer_size, WebMParseElementHeader(kBuffers[i], buffer_size, | 363 EXPECT_EQ(buffer_size, WebMParseElementHeader(kBuffers[i], buffer_size, |
364 &id, &element_size)); | 364 &id, &element_size)); |
365 EXPECT_EQ(id, 0xA3); | 365 EXPECT_EQ(id, 0xA3); |
366 EXPECT_EQ(element_size, kWebMUnknownSize); | 366 EXPECT_EQ(element_size, kWebMUnknownSize); |
367 } | 367 } |
368 } | 368 } |
369 | 369 |
| 370 TEST_F(WebMParserTest, ZeroPaddedStrings) { |
| 371 const uint8 kBuffer[] = { |
| 372 0x1A, 0x45, 0xDF, 0xA3, 0x91, // EBMLHEADER (size = 17) |
| 373 0x42, 0x82, 0x80, // DocType (size = 0) |
| 374 0x42, 0x82, 0x81, 0x00, // DocType (size = 1) "" |
| 375 0x42, 0x82, 0x81, 'a', // DocType (size = 1) "a" |
| 376 0x42, 0x82, 0x83, 'a', 0x00, 0x00 // DocType (size = 3) "a" |
| 377 }; |
| 378 int size = sizeof(kBuffer); |
| 379 |
| 380 InSequence s; |
| 381 EXPECT_CALL(client_, OnListStart(kWebMIdEBMLHeader)) |
| 382 .WillOnce(Return(&client_)); |
| 383 EXPECT_CALL(client_, OnString(kWebMIdDocType, "")).WillOnce(Return(true)); |
| 384 EXPECT_CALL(client_, OnString(kWebMIdDocType, "")).WillOnce(Return(true)); |
| 385 EXPECT_CALL(client_, OnString(kWebMIdDocType, "a")).WillOnce(Return(true)); |
| 386 EXPECT_CALL(client_, OnString(kWebMIdDocType, "a")).WillOnce(Return(true)); |
| 387 EXPECT_CALL(client_, OnListEnd(kWebMIdEBMLHeader)).WillOnce(Return(true)); |
| 388 |
| 389 WebMListParser parser(kWebMIdEBMLHeader, &client_); |
| 390 int result = parser.Parse(kBuffer, size); |
| 391 EXPECT_EQ(size, result); |
| 392 EXPECT_TRUE(parser.IsParsingComplete()); |
| 393 } |
| 394 |
370 } // namespace media | 395 } // namespace media |
OLD | NEW |