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

Side by Side Diff: media/cast/test/end2end_unittest.cc

Issue 2371783002: Remove stl_util's deletion functions from media/. (Closed)
Patch Set: just the count Created 4 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 // This test generate synthetic data. For audio it's a sinusoid waveform with 5 // This test generate synthetic data. For audio it's a sinusoid waveform with
6 // frequency kSoundFrequency and different amplitudes. For video it's a pattern 6 // frequency kSoundFrequency and different amplitudes. For video it's a pattern
7 // that is shifting by one pixel per frame, each pixels neighbors right and down 7 // that is shifting by one pixel per frame, each pixels neighbors right and down
8 // is this pixels value +1, since the pixel value is 8 bit it will wrap 8 // is this pixels value +1, since the pixel value is 8 bit it will wrap
9 // frequently within the image. Visually this will create diagonally color bands 9 // frequently within the image. Visually this will create diagonally color bands
10 // that moves across the screen 10 // that moves across the screen
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 } 249 }
250 250
251 void AddExpectedResult(const AudioBus& audio_bus, 251 void AddExpectedResult(const AudioBus& audio_bus,
252 const base::TimeTicks& playout_time) { 252 const base::TimeTicks& playout_time) {
253 std::unique_ptr<ExpectedAudioFrame> expected_audio_frame( 253 std::unique_ptr<ExpectedAudioFrame> expected_audio_frame(
254 new ExpectedAudioFrame()); 254 new ExpectedAudioFrame());
255 expected_audio_frame->audio_bus = 255 expected_audio_frame->audio_bus =
256 AudioBus::Create(audio_bus.channels(), audio_bus.frames()); 256 AudioBus::Create(audio_bus.channels(), audio_bus.frames());
257 audio_bus.CopyTo(expected_audio_frame->audio_bus.get()); 257 audio_bus.CopyTo(expected_audio_frame->audio_bus.get());
258 expected_audio_frame->playout_time = playout_time; 258 expected_audio_frame->playout_time = playout_time;
259 expected_frames_.push_back(expected_audio_frame.release()); 259 expected_frames_.push_back(std::move(expected_audio_frame));
260 } 260 }
261 261
262 void IgnoreAudioFrame(std::unique_ptr<AudioBus> audio_bus, 262 void IgnoreAudioFrame(std::unique_ptr<AudioBus> audio_bus,
263 const base::TimeTicks& playout_time, 263 const base::TimeTicks& playout_time,
264 bool is_continuous) { 264 bool is_continuous) {
265 ++num_called_; 265 ++num_called_;
266 } 266 }
267 267
268 void CheckAudioFrame(std::unique_ptr<AudioBus> audio_bus, 268 void CheckAudioFrame(std::unique_ptr<AudioBus> audio_bus,
269 const base::TimeTicks& playout_time, 269 const base::TimeTicks& playout_time,
270 bool is_continuous) { 270 bool is_continuous) {
271 ++num_called_; 271 ++num_called_;
272 272
273 ASSERT_TRUE(audio_bus); 273 ASSERT_TRUE(audio_bus);
274 ASSERT_FALSE(expected_frames_.empty()); 274 ASSERT_FALSE(expected_frames_.empty());
275 const std::unique_ptr<ExpectedAudioFrame> expected_audio_frame( 275 const std::unique_ptr<ExpectedAudioFrame> expected_audio_frame =
276 expected_frames_.front()); 276 std::move(expected_frames_.front());
277 expected_frames_.pop_front(); 277 expected_frames_.pop_front();
278 278
279 EXPECT_EQ(audio_bus->channels(), kAudioChannels); 279 EXPECT_EQ(audio_bus->channels(), kAudioChannels);
280 EXPECT_EQ(audio_bus->frames(), expected_audio_frame->audio_bus->frames()); 280 EXPECT_EQ(audio_bus->frames(), expected_audio_frame->audio_bus->frames());
281 for (int ch = 0; ch < audio_bus->channels(); ++ch) { 281 for (int ch = 0; ch < audio_bus->channels(); ++ch) {
282 EXPECT_NEAR(CountZeroCrossings( 282 EXPECT_NEAR(CountZeroCrossings(
283 expected_audio_frame->audio_bus->channel(ch), 283 expected_audio_frame->audio_bus->channel(ch),
284 expected_audio_frame->audio_bus->frames()), 284 expected_audio_frame->audio_bus->frames()),
285 CountZeroCrossings(audio_bus->channel(ch), 285 CountZeroCrossings(audio_bus->channel(ch),
286 audio_bus->frames()), 286 audio_bus->frames()),
287 1); 287 1);
288 } 288 }
289 289
290 EXPECT_NEAR( 290 EXPECT_NEAR(
291 (playout_time - expected_audio_frame->playout_time).InMillisecondsF(), 291 (playout_time - expected_audio_frame->playout_time).InMillisecondsF(),
292 0.0, 292 0.0,
293 kMaxAllowedPlayoutErrorMs); 293 kMaxAllowedPlayoutErrorMs);
294 VLOG_IF(1, !last_playout_time_.is_null()) 294 VLOG_IF(1, !last_playout_time_.is_null())
295 << "Audio frame playout time delta (compared to last frame) is " 295 << "Audio frame playout time delta (compared to last frame) is "
296 << (playout_time - last_playout_time_).InMicroseconds() << " usec."; 296 << (playout_time - last_playout_time_).InMicroseconds() << " usec.";
297 last_playout_time_ = playout_time; 297 last_playout_time_ = playout_time;
298 298
299 EXPECT_TRUE(is_continuous); 299 EXPECT_TRUE(is_continuous);
300 } 300 }
301 301
302 int number_times_called() const { return num_called_; } 302 int number_times_called() const { return num_called_; }
303 303
304 protected: 304 protected:
305 virtual ~TestReceiverAudioCallback() { 305 virtual ~TestReceiverAudioCallback() {
306 base::STLDeleteElements(&expected_frames_);
307 } 306 }
308 307
309 private: 308 private:
310 friend class base::RefCountedThreadSafe<TestReceiverAudioCallback>; 309 friend class base::RefCountedThreadSafe<TestReceiverAudioCallback>;
311 310
312 int num_called_; 311 int num_called_;
313 int expected_sampling_frequency_; 312 int expected_sampling_frequency_;
314 std::list<ExpectedAudioFrame*> expected_frames_; 313 std::list<std::unique_ptr<ExpectedAudioFrame>> expected_frames_;
315 base::TimeTicks last_playout_time_; 314 base::TimeTicks last_playout_time_;
316 }; 315 };
317 316
318 // Class that verifies the video frames coming out of the receiver. 317 // Class that verifies the video frames coming out of the receiver.
319 class TestReceiverVideoCallback 318 class TestReceiverVideoCallback
320 : public base::RefCountedThreadSafe<TestReceiverVideoCallback> { 319 : public base::RefCountedThreadSafe<TestReceiverVideoCallback> {
321 public: 320 public:
322 struct ExpectedVideoFrame { 321 struct ExpectedVideoFrame {
323 int frame_number; 322 int frame_number;
324 gfx::Size size; 323 gfx::Size size;
(...skipping 945 matching lines...) Expand 10 before | Expand all | Expand 10 after
1270 EXPECT_EQ(0u, jump); 1269 EXPECT_EQ(0u, jump);
1271 jump = i; 1270 jump = i;
1272 } 1271 }
1273 } 1272 }
1274 EXPECT_GT(jump, 49u); 1273 EXPECT_GT(jump, 49u);
1275 EXPECT_LT(jump, 120u); 1274 EXPECT_LT(jump, 120u);
1276 } 1275 }
1277 1276
1278 } // namespace cast 1277 } // namespace cast
1279 } // namespace media 1278 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698