Updating XTBs based on .GRDs from branch master
[chromium-blink-merge.git] / media / formats / mp2t / es_parser_adts_unittest.cc
blob966553803f60249a85df4abcf84ac5eaf8143650
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.
5 #include <vector>
7 #include "base/bind.h"
8 #include "base/logging.h"
9 #include "base/time/time.h"
10 #include "media/base/buffers.h"
11 #include "media/base/stream_parser_buffer.h"
12 #include "media/formats/mp2t/es_parser_adts.h"
13 #include "media/formats/mp2t/es_parser_test_base.h"
14 #include "testing/gtest/include/gtest/gtest.h"
16 namespace media {
17 class AudioDecoderConfig;
19 namespace mp2t {
21 class EsParserAdtsTest : public EsParserTestBase,
22 public testing::Test {
23 public:
24 EsParserAdtsTest();
26 protected:
27 bool Process(const std::vector<Packet>& pes_packets, bool force_timing);
29 private:
30 DISALLOW_COPY_AND_ASSIGN(EsParserAdtsTest);
33 EsParserAdtsTest::EsParserAdtsTest() {
36 bool EsParserAdtsTest::Process(
37 const std::vector<Packet>& pes_packets,
38 bool force_timing) {
39 EsParserAdts es_parser(
40 base::Bind(&EsParserAdtsTest::NewAudioConfig, base::Unretained(this)),
41 base::Bind(&EsParserAdtsTest::EmitBuffer, base::Unretained(this)),
42 false);
43 return ProcessPesPackets(&es_parser, pes_packets, force_timing);
46 TEST_F(EsParserAdtsTest, NoInitialPts) {
47 LoadStream("bear.adts");
48 std::vector<Packet> pes_packets = GenerateFixedSizePesPacket(512);
49 // Process should succeed even without timing info, we should just skip the
50 // audio frames without timing info, but still should be able to parse and
51 // play the stream after that.
52 EXPECT_TRUE(Process(pes_packets, false));
53 EXPECT_EQ(1u, config_count_);
54 EXPECT_EQ(0u, buffer_count_);
57 TEST_F(EsParserAdtsTest, SinglePts) {
58 LoadStream("bear.adts");
60 std::vector<Packet> pes_packets = GenerateFixedSizePesPacket(512);
61 pes_packets.front().pts = base::TimeDelta::FromSeconds(10);
63 EXPECT_TRUE(Process(pes_packets, false));
64 EXPECT_EQ(1u, config_count_);
65 EXPECT_EQ(45u, buffer_count_);
68 } // namespace mp2t
69 } // namespace media