| 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/common/stream_parser_test_base.h" | 5 #include "media/formats/common/stream_parser_test_base.h" |
| 6 #include "media/formats/mpeg/adts_stream_parser.h" | 6 #include "media/formats/mpeg/adts_stream_parser.h" |
| 7 #include "testing/gtest/include/gtest/gtest.h" | 7 #include "testing/gtest/include/gtest/gtest.h" |
| 8 | 8 |
| 9 namespace media { | 9 namespace media { |
| 10 | 10 |
| 11 class ADTSStreamParserTest : public StreamParserTestBase, public testing::Test { | 11 class ADTSStreamParserTest : public StreamParserTestBase, public testing::Test { |
| 12 public: | 12 public: |
| 13 ADTSStreamParserTest() | 13 ADTSStreamParserTest() |
| 14 : StreamParserTestBase( | 14 : StreamParserTestBase( |
| 15 scoped_ptr<StreamParser>(new ADTSStreamParser()).Pass()) {} | 15 scoped_ptr<StreamParser>(new ADTSStreamParser()).Pass()) {} |
| 16 virtual ~ADTSStreamParserTest() {} | 16 virtual ~ADTSStreamParserTest() {} |
| 17 }; | 17 }; |
| 18 | 18 |
| 19 // Test parsing with small prime sized chunks to smoke out "power of | 19 // Test parsing with small prime sized chunks to smoke out "power of |
| 20 // 2" field size assumptions. | 20 // 2" field size assumptions. |
| 21 TEST_F(ADTSStreamParserTest, UnalignedAppend) { | 21 TEST_F(ADTSStreamParserTest, UnalignedAppend) { |
| 22 const std::string expected = | 22 const std::string expected = |
| 23 "NewSegment" | 23 "NewSegment" |
| 24 "{ 0K }" | 24 "{ 0K }" |
| 25 "{ 23K }" | 25 "{ 0K }" |
| 26 "{ 46K }" | 26 "{ 0K }" |
| 27 "{ 69K }" | 27 "{ 0K }" |
| 28 "{ 92K }" | 28 "{ 0K }" |
| 29 "{ 116K }" | 29 "{ 0K }" |
| 30 "{ 139K }" | 30 "{ 0K }" |
| 31 "{ 162K }" | 31 "{ 0K }" |
| 32 "{ 185K }" | 32 "{ 0K }" |
| 33 "EndOfSegment" | 33 "EndOfSegment" |
| 34 "NewSegment" | 34 "NewSegment" |
| 35 "{ 208K }" | 35 "{ 0K }" |
| 36 "{ 232K }" | 36 "{ 0K }" |
| 37 "{ 255K }" | 37 "{ 0K }" |
| 38 "{ 278K }" | 38 "{ 0K }" |
| 39 "{ 301K }" | 39 "{ 0K }" |
| 40 "EndOfSegment"; | 40 "EndOfSegment"; |
| 41 EXPECT_EQ(expected, ParseFile("sfx.adts", 17)); | 41 EXPECT_EQ(expected, ParseFile("sfx.adts", 17)); |
| 42 } | 42 } |
| 43 | 43 |
| 44 // Test parsing with a larger piece size to verify that multiple buffers | 44 // Test parsing with a larger piece size to verify that multiple buffers |
| 45 // are passed to |new_buffer_cb_|. | 45 // are passed to |new_buffer_cb_|. |
| 46 TEST_F(ADTSStreamParserTest, UnalignedAppend512) { | 46 TEST_F(ADTSStreamParserTest, UnalignedAppend512) { |
| 47 const std::string expected = | 47 const std::string expected = |
| 48 "NewSegment" | 48 "NewSegment" |
| 49 "{ 0K 23K 46K }" | 49 "{ 0K 23K 46K }" |
| 50 "{ 69K 92K 116K 139K 162K }" | 50 "{ 0K 23K 46K 69K 92K }" |
| 51 "{ 185K 208K 232K 255K 278K }" | 51 "{ 0K 23K 46K 69K 92K }" |
| 52 "EndOfSegment" | 52 "EndOfSegment" |
| 53 "NewSegment" | 53 "NewSegment" |
| 54 "{ 301K }" | 54 "{ 0K }" |
| 55 "EndOfSegment"; | 55 "EndOfSegment"; |
| 56 EXPECT_EQ(expected, ParseFile("sfx.adts", 512)); | 56 EXPECT_EQ(expected, ParseFile("sfx.adts", 512)); |
| 57 } | 57 } |
| 58 | 58 |
| 59 } // namespace media | 59 } // namespace media |
| OLD | NEW |