Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(687)

Side by Side Diff: media/formats/webm/webm_stream_parser_unittest.cc

Issue 1874413003: Convert media/formats to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/webm/webm_stream_parser.h"
6
7 #include <memory>
8
5 #include "base/bind.h" 9 #include "base/bind.h"
6 #include "media/base/decoder_buffer.h" 10 #include "media/base/decoder_buffer.h"
7 #include "media/base/media_tracks.h" 11 #include "media/base/media_tracks.h"
8 #include "media/base/mock_media_log.h" 12 #include "media/base/mock_media_log.h"
9 #include "media/base/stream_parser.h" 13 #include "media/base/stream_parser.h"
10 #include "media/base/test_data_util.h" 14 #include "media/base/test_data_util.h"
11 #include "media/base/text_track_config.h" 15 #include "media/base/text_track_config.h"
12 #include "media/formats/webm/webm_stream_parser.h"
13 #include "testing/gtest/include/gtest/gtest.h" 16 #include "testing/gtest/include/gtest/gtest.h"
14 17
15 using testing::SaveArg; 18 using testing::SaveArg;
16 using testing::_; 19 using testing::_;
17 20
18 namespace media { 21 namespace media {
19 22
20 class WebMStreamParserTest : public testing::Test { 23 class WebMStreamParserTest : public testing::Test {
21 public: 24 public:
22 WebMStreamParserTest() 25 WebMStreamParserTest()
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 params.detected_audio_track_count); 64 params.detected_audio_track_count);
62 EXPECT_EQ(expected_params.detected_video_track_count, 65 EXPECT_EQ(expected_params.detected_video_track_count,
63 params.detected_video_track_count); 66 params.detected_video_track_count);
64 EXPECT_EQ(expected_params.detected_text_track_count, 67 EXPECT_EQ(expected_params.detected_text_track_count,
65 params.detected_text_track_count); 68 params.detected_text_track_count);
66 InitCB(params); 69 InitCB(params);
67 } 70 }
68 71
69 MOCK_METHOD1(InitCB, void(const StreamParser::InitParameters& params)); 72 MOCK_METHOD1(InitCB, void(const StreamParser::InitParameters& params));
70 73
71 bool NewConfigCB(scoped_ptr<MediaTracks> tracks, 74 bool NewConfigCB(std::unique_ptr<MediaTracks> tracks,
72 const StreamParser::TextTrackConfigMap& text_track_map) { 75 const StreamParser::TextTrackConfigMap& text_track_map) {
73 DCHECK(tracks.get()); 76 DCHECK(tracks.get());
74 media_tracks_ = std::move(tracks); 77 media_tracks_ = std::move(tracks);
75 return true; 78 return true;
76 } 79 }
77 80
78 MOCK_METHOD3(NewBuffersCB, 81 MOCK_METHOD3(NewBuffersCB,
79 bool(const StreamParser::BufferQueue&, 82 bool(const StreamParser::BufferQueue&,
80 const StreamParser::BufferQueue&, 83 const StreamParser::BufferQueue&,
81 const StreamParser::TextBufferQueueMap&)); 84 const StreamParser::TextBufferQueueMap&));
82 MOCK_METHOD2(OnEncryptedMediaInitData, 85 MOCK_METHOD2(OnEncryptedMediaInitData,
83 void(EmeInitDataType init_data_type, 86 void(EmeInitDataType init_data_type,
84 const std::vector<uint8_t>& init_data)); 87 const std::vector<uint8_t>& init_data));
85 MOCK_METHOD0(NewMediaSegmentCB, void()); 88 MOCK_METHOD0(NewMediaSegmentCB, void());
86 MOCK_METHOD0(EndMediaSegmentCB, void()); 89 MOCK_METHOD0(EndMediaSegmentCB, void());
87 90
88 scoped_refptr<testing::StrictMock<MockMediaLog>> media_log_; 91 scoped_refptr<testing::StrictMock<MockMediaLog>> media_log_;
89 scoped_ptr<WebMStreamParser> parser_; 92 std::unique_ptr<WebMStreamParser> parser_;
90 scoped_ptr<MediaTracks> media_tracks_; 93 std::unique_ptr<MediaTracks> media_tracks_;
91 }; 94 };
92 95
93 TEST_F(WebMStreamParserTest, VerifyMediaTrackMetadata) { 96 TEST_F(WebMStreamParserTest, VerifyMediaTrackMetadata) {
94 EXPECT_MEDIA_LOG(testing::HasSubstr("Estimating WebM block duration")) 97 EXPECT_MEDIA_LOG(testing::HasSubstr("Estimating WebM block duration"))
95 .Times(testing::AnyNumber()); 98 .Times(testing::AnyNumber());
96 StreamParser::InitParameters params(kInfiniteDuration()); 99 StreamParser::InitParameters params(kInfiniteDuration());
97 params.detected_audio_track_count = 1; 100 params.detected_audio_track_count = 1;
98 params.detected_video_track_count = 1; 101 params.detected_video_track_count = 1;
99 params.detected_text_track_count = 0; 102 params.detected_text_track_count = 0;
100 ParseWebMFile("bear.webm", params); 103 ParseWebMFile("bear.webm", params);
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 params.detected_audio_track_count = 1; 149 params.detected_audio_track_count = 1;
147 params.detected_video_track_count = 1; 150 params.detected_video_track_count = 1;
148 params.detected_text_track_count = 1; 151 params.detected_text_track_count = 1;
149 ParseWebMFile("bear-vp8-webvtt.webm", params); 152 ParseWebMFile("bear-vp8-webvtt.webm", params);
150 EXPECT_EQ(media_tracks_->tracks().size(), 2u); 153 EXPECT_EQ(media_tracks_->tracks().size(), 2u);
151 EXPECT_EQ(media_tracks_->tracks()[0]->type(), MediaTrack::Video); 154 EXPECT_EQ(media_tracks_->tracks()[0]->type(), MediaTrack::Video);
152 EXPECT_EQ(media_tracks_->tracks()[1]->type(), MediaTrack::Audio); 155 EXPECT_EQ(media_tracks_->tracks()[1]->type(), MediaTrack::Audio);
153 } 156 }
154 157
155 } // namespace media 158 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698