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

Side by Side Diff: media/base/audio_renderer_mixer_unittest.cc

Issue 16823003: Replace erroneous use of base::Time with base::TimeTicks throughout media code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: s/PresubmitPromptWarning/PresubmitPromptOrNotify/ Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « media/base/audio_renderer_mixer.cc ('k') | media/base/clock.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 // MSVC++ requires this to be set before any other includes to get M_PI. 5 // MSVC++ requires this to be set before any other includes to get M_PI.
6 #define _USE_MATH_DEFINES 6 #define _USE_MATH_DEFINES
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after
414 const base::TimeDelta kTestTimeout = 10 * kPauseTime; 414 const base::TimeDelta kTestTimeout = 10 * kPauseTime;
415 mixer_->set_pause_delay_for_testing(kPauseTime); 415 mixer_->set_pause_delay_for_testing(kPauseTime);
416 416
417 base::WaitableEvent pause_event(true, false); 417 base::WaitableEvent pause_event(true, false);
418 EXPECT_CALL(*sink_.get(), Pause()).Times(2) 418 EXPECT_CALL(*sink_.get(), Pause()).Times(2)
419 .WillRepeatedly(SignalEvent(&pause_event)); 419 .WillRepeatedly(SignalEvent(&pause_event));
420 InitializeInputs(1); 420 InitializeInputs(1);
421 421
422 // Ensure never playing the input results in a sink pause. 422 // Ensure never playing the input results in a sink pause.
423 const base::TimeDelta kSleepTime = base::TimeDelta::FromMilliseconds(100); 423 const base::TimeDelta kSleepTime = base::TimeDelta::FromMilliseconds(100);
424 base::Time start_time = base::Time::Now(); 424 base::TimeTicks start_time = base::TimeTicks::Now();
425 while (!pause_event.IsSignaled()) { 425 while (!pause_event.IsSignaled()) {
426 mixer_callback_->Render(audio_bus_.get(), 0); 426 mixer_callback_->Render(audio_bus_.get(), 0);
427 base::PlatformThread::Sleep(kSleepTime); 427 base::PlatformThread::Sleep(kSleepTime);
428 ASSERT_TRUE(base::Time::Now() - start_time < kTestTimeout); 428 ASSERT_TRUE(base::TimeTicks::Now() - start_time < kTestTimeout);
429 } 429 }
430 pause_event.Reset(); 430 pause_event.Reset();
431 431
432 // Playing the input for the first time should cause a sink play. 432 // Playing the input for the first time should cause a sink play.
433 mixer_inputs_[0]->Start(); 433 mixer_inputs_[0]->Start();
434 EXPECT_CALL(*sink_.get(), Play()); 434 EXPECT_CALL(*sink_.get(), Play());
435 mixer_inputs_[0]->Play(); 435 mixer_inputs_[0]->Play();
436 mixer_inputs_[0]->Pause(); 436 mixer_inputs_[0]->Pause();
437 437
438 // Ensure once the input is paused the sink eventually pauses. 438 // Ensure once the input is paused the sink eventually pauses.
439 start_time = base::Time::Now(); 439 start_time = base::TimeTicks::Now();
440 while (!pause_event.IsSignaled()) { 440 while (!pause_event.IsSignaled()) {
441 mixer_callback_->Render(audio_bus_.get(), 0); 441 mixer_callback_->Render(audio_bus_.get(), 0);
442 base::PlatformThread::Sleep(kSleepTime); 442 base::PlatformThread::Sleep(kSleepTime);
443 ASSERT_TRUE(base::Time::Now() - start_time < kTestTimeout); 443 ASSERT_TRUE(base::TimeTicks::Now() - start_time < kTestTimeout);
444 } 444 }
445 445
446 mixer_inputs_[0]->Stop(); 446 mixer_inputs_[0]->Stop();
447 } 447 }
448 448
449 INSTANTIATE_TEST_CASE_P( 449 INSTANTIATE_TEST_CASE_P(
450 AudioRendererMixerTest, AudioRendererMixerTest, testing::Values( 450 AudioRendererMixerTest, AudioRendererMixerTest, testing::Values(
451 // No resampling. 451 // No resampling.
452 std::tr1::make_tuple(44100, 44100, 0.00000048), 452 std::tr1::make_tuple(44100, 44100, 0.00000048),
453 453
454 // Upsampling. 454 // Upsampling.
455 std::tr1::make_tuple(44100, 48000, 0.033), 455 std::tr1::make_tuple(44100, 48000, 0.033),
456 456
457 // Downsampling. 457 // Downsampling.
458 std::tr1::make_tuple(48000, 41000, 0.042))); 458 std::tr1::make_tuple(48000, 41000, 0.042)));
459 459
460 // Test cases for behavior which is independent of parameters. Values() doesn't 460 // Test cases for behavior which is independent of parameters. Values() doesn't
461 // support single item lists and we don't want these test cases to run for every 461 // support single item lists and we don't want these test cases to run for every
462 // parameter set. 462 // parameter set.
463 INSTANTIATE_TEST_CASE_P( 463 INSTANTIATE_TEST_CASE_P(
464 AudioRendererMixerBehavioralTest, AudioRendererMixerBehavioralTest, 464 AudioRendererMixerBehavioralTest, AudioRendererMixerBehavioralTest,
465 testing::ValuesIn(std::vector<AudioRendererMixerTestData>( 465 testing::ValuesIn(std::vector<AudioRendererMixerTestData>(
466 1, std::tr1::make_tuple(44100, 44100, 0)))); 466 1, std::tr1::make_tuple(44100, 44100, 0))));
467 467
468 } // namespace media 468 } // namespace media
OLDNEW
« no previous file with comments | « media/base/audio_renderer_mixer.cc ('k') | media/base/clock.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698