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/base/test_data_util.h" | 5 #include "media/base/test_data_util.h" |
6 #include "media/formats/common/stream_parser_test_base.h" | 6 #include "media/formats/common/stream_parser_test_base.h" |
7 #include "media/formats/mpeg/mp3_stream_parser.h" | 7 #include "media/formats/mpeg/mp3_stream_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 22 matching lines...) Expand all Loading... |
33 "NewSegment" | 33 "NewSegment" |
34 "{ 0K }" | 34 "{ 0K }" |
35 "{ 0K }" | 35 "{ 0K }" |
36 "{ 0K }" | 36 "{ 0K }" |
37 "EndOfSegment" | 37 "EndOfSegment" |
38 "NewSegment" | 38 "NewSegment" |
39 "{ 0K }" | 39 "{ 0K }" |
40 "{ 0K }" | 40 "{ 0K }" |
41 "EndOfSegment"; | 41 "EndOfSegment"; |
42 EXPECT_EQ(expected, ParseFile("sfx.mp3", 17)); | 42 EXPECT_EQ(expected, ParseFile("sfx.mp3", 17)); |
| 43 EXPECT_GT(last_audio_config().codec_delay(), 0); |
43 } | 44 } |
44 | 45 |
45 // Test parsing with a larger piece size to verify that multiple buffers | 46 // Test parsing with a larger piece size to verify that multiple buffers |
46 // are passed to |new_buffer_cb_|. | 47 // are passed to |new_buffer_cb_|. |
47 TEST_F(MP3StreamParserTest, UnalignedAppend512) { | 48 TEST_F(MP3StreamParserTest, UnalignedAppend512) { |
48 const std::string expected = | 49 const std::string expected = |
49 "NewSegment" | 50 "NewSegment" |
50 "{ 0K 26K 52K 78K }" | 51 "{ 0K 26K 52K 78K }" |
51 "EndOfSegment" | 52 "EndOfSegment" |
52 "NewSegment" | 53 "NewSegment" |
53 "{ 0K 26K 52K }" | 54 "{ 0K 26K 52K }" |
54 "{ 0K 26K 52K 78K }" | 55 "{ 0K 26K 52K 78K }" |
55 "{ 0K }" | 56 "{ 0K }" |
56 "EndOfSegment"; | 57 "EndOfSegment"; |
57 EXPECT_EQ(expected, ParseFile("sfx.mp3", 512)); | 58 EXPECT_EQ(expected, ParseFile("sfx.mp3", 512)); |
| 59 EXPECT_GT(last_audio_config().codec_delay(), 0); |
58 } | 60 } |
59 | 61 |
60 TEST_F(MP3StreamParserTest, MetadataParsing) { | 62 TEST_F(MP3StreamParserTest, MetadataParsing) { |
61 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile("sfx.mp3"); | 63 scoped_refptr<DecoderBuffer> buffer = ReadTestDataFile("sfx.mp3"); |
62 const uint8_t* buffer_ptr = buffer->data(); | 64 const uint8_t* buffer_ptr = buffer->data(); |
63 | 65 |
64 // The first 32 bytes of sfx.mp3 are an ID3 tag, so no segments should be | 66 // The first 32 bytes of sfx.mp3 are an ID3 tag, so no segments should be |
65 // extracted after appending those bytes. | 67 // extracted after appending those bytes. |
66 const int kId3TagSize = 32; | 68 const int kId3TagSize = 32; |
67 EXPECT_EQ("", ParseData(buffer_ptr, kId3TagSize)); | 69 EXPECT_EQ("", ParseData(buffer_ptr, kId3TagSize)); |
(...skipping 16 matching lines...) Expand all Loading... |
84 buffer_ptr += kXingRemainingSize; | 86 buffer_ptr += kXingRemainingSize; |
85 | 87 |
86 // Append the first real frame and ensure we get a segment. | 88 // Append the first real frame and ensure we get a segment. |
87 const int kFirstRealFrameSize = 182; | 89 const int kFirstRealFrameSize = 182; |
88 EXPECT_EQ("NewSegment{ 0K }EndOfSegment", | 90 EXPECT_EQ("NewSegment{ 0K }EndOfSegment", |
89 ParseData(buffer_ptr, kFirstRealFrameSize)); | 91 ParseData(buffer_ptr, kFirstRealFrameSize)); |
90 EXPECT_TRUE(last_audio_config().IsValidConfig()); | 92 EXPECT_TRUE(last_audio_config().IsValidConfig()); |
91 } | 93 } |
92 | 94 |
93 } // namespace media | 95 } // namespace media |
OLD | NEW |