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

Side by Side Diff: media/muxers/webm_muxer_unittest.cc

Issue 2253943004: Re-write many calls to WrapUnique() with MakeUnique() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « media/muxers/webm_muxer.cc ('k') | media/renderers/default_renderer_factory.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/muxers/webm_muxer.h" 5 #include "media/muxers/webm_muxer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 media::CHANNEL_LAYOUT_MONO, sample_rate, bits_per_sample, 151 media::CHANNEL_LAYOUT_MONO, sample_rate, bits_per_sample,
152 frames_per_buffer); 152 frames_per_buffer);
153 153
154 const std::string encoded_data("abcdefghijklmnopqrstuvwxyz"); 154 const std::string encoded_data("abcdefghijklmnopqrstuvwxyz");
155 155
156 EXPECT_CALL(*this, WriteCallback(_)) 156 EXPECT_CALL(*this, WriteCallback(_))
157 .Times(AtLeast(1)) 157 .Times(AtLeast(1))
158 .WillRepeatedly( 158 .WillRepeatedly(
159 WithArgs<0>(Invoke(this, &WebmMuxerTest::SaveEncodedDataLen))); 159 WithArgs<0>(Invoke(this, &WebmMuxerTest::SaveEncodedDataLen)));
160 webm_muxer_.OnEncodedAudio(audio_params, 160 webm_muxer_.OnEncodedAudio(audio_params,
161 base::WrapUnique(new std::string(encoded_data)), 161 base::MakeUnique<std::string>(encoded_data),
162 base::TimeTicks::Now()); 162 base::TimeTicks::Now());
163 163
164 // First time around WriteCallback() is pinged a number of times to write the 164 // First time around WriteCallback() is pinged a number of times to write the
165 // Matroska header, but at the end it dumps |encoded_data|. 165 // Matroska header, but at the end it dumps |encoded_data|.
166 EXPECT_EQ(last_encoded_length_, encoded_data.size()); 166 EXPECT_EQ(last_encoded_length_, encoded_data.size());
167 EXPECT_EQ(GetWebmMuxerPosition(), accumulated_position_); 167 EXPECT_EQ(GetWebmMuxerPosition(), accumulated_position_);
168 EXPECT_GE(GetWebmMuxerPosition(), static_cast<int64_t>(last_encoded_length_)); 168 EXPECT_GE(GetWebmMuxerPosition(), static_cast<int64_t>(last_encoded_length_));
169 EXPECT_EQ(GetWebmSegmentMode(), mkvmuxer::Segment::kLive); 169 EXPECT_EQ(GetWebmSegmentMode(), mkvmuxer::Segment::kLive);
170 170
171 const int64_t begin_of_second_block = accumulated_position_; 171 const int64_t begin_of_second_block = accumulated_position_;
172 EXPECT_CALL(*this, WriteCallback(_)) 172 EXPECT_CALL(*this, WriteCallback(_))
173 .Times(AtLeast(1)) 173 .Times(AtLeast(1))
174 .WillRepeatedly( 174 .WillRepeatedly(
175 WithArgs<0>(Invoke(this, &WebmMuxerTest::SaveEncodedDataLen))); 175 WithArgs<0>(Invoke(this, &WebmMuxerTest::SaveEncodedDataLen)));
176 webm_muxer_.OnEncodedAudio(audio_params, 176 webm_muxer_.OnEncodedAudio(audio_params,
177 base::WrapUnique(new std::string(encoded_data)), 177 base::MakeUnique<std::string>(encoded_data),
178 base::TimeTicks::Now()); 178 base::TimeTicks::Now());
179 179
180 // The second time around the callbacks should include a SimpleBlock header, 180 // The second time around the callbacks should include a SimpleBlock header,
181 // namely the track index, a timestamp and a flags byte, for a total of 6B. 181 // namely the track index, a timestamp and a flags byte, for a total of 6B.
182 EXPECT_EQ(last_encoded_length_, encoded_data.size()); 182 EXPECT_EQ(last_encoded_length_, encoded_data.size());
183 EXPECT_EQ(GetWebmMuxerPosition(), accumulated_position_); 183 EXPECT_EQ(GetWebmMuxerPosition(), accumulated_position_);
184 const uint32_t kSimpleBlockSize = 6u; 184 const uint32_t kSimpleBlockSize = 6u;
185 EXPECT_EQ(static_cast<int64_t>(begin_of_second_block + kSimpleBlockSize + 185 EXPECT_EQ(static_cast<int64_t>(begin_of_second_block + kSimpleBlockSize +
186 encoded_data.size()), 186 encoded_data.size()),
187 accumulated_position_); 187 accumulated_position_);
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
244 {kCodecVP9, 0, 1}, 244 {kCodecVP9, 0, 1},
245 {kCodecVP9, 1, 1}, 245 {kCodecVP9, 1, 1},
246 {kCodecH264, 1, 0}, 246 {kCodecH264, 1, 0},
247 {kCodecH264, 0, 1}, 247 {kCodecH264, 0, 1},
248 {kCodecH264, 1, 1}, 248 {kCodecH264, 1, 1},
249 }; 249 };
250 250
251 INSTANTIATE_TEST_CASE_P(, WebmMuxerTest, ValuesIn(kTestCases)); 251 INSTANTIATE_TEST_CASE_P(, WebmMuxerTest, ValuesIn(kTestCases));
252 252
253 } // namespace media 253 } // namespace media
OLDNEW
« no previous file with comments | « media/muxers/webm_muxer.cc ('k') | media/renderers/default_renderer_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698