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