diff options
author | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-21 21:50:34 +0000 |
---|---|---|
committer | akalin@chromium.org <akalin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-02-21 21:50:34 +0000 |
commit | 0cb3d72e44bbca50104f8a79acdff5c6344278b8 (patch) | |
tree | a79b35e3eb8c1c705268ae173fc9caa00bf47e8b /media/base/pipeline_unittest.cc | |
parent | 4d805b5db89c08532633e9fcacdc4df0828fe1fe (diff) | |
download | chromium_src-0cb3d72e44bbca50104f8a79acdff5c6344278b8.zip chromium_src-0cb3d72e44bbca50104f8a79acdff5c6344278b8.tar.gz chromium_src-0cb3d72e44bbca50104f8a79acdff5c6344278b8.tar.bz2 |
Add a Clock and TickClock interface for mocking out time
Add DefaultClock and DefaultTickClock implementations.
Add SimpleTestClock and SimpleTestTickClock implementations for test.
Port some classes in sync/ and media/ to use SimpleTest{,Tick}Clock.
BUG=166469
Review URL: https://codereview.chromium.org/11607003
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@183865 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'media/base/pipeline_unittest.cc')
-rw-r--r-- | media/base/pipeline_unittest.cc | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/media/base/pipeline_unittest.cc b/media/base/pipeline_unittest.cc index 320c83a..d2d14b2 100644 --- a/media/base/pipeline_unittest.cc +++ b/media/base/pipeline_unittest.cc @@ -7,7 +7,9 @@ #include "base/bind.h" #include "base/message_loop.h" #include "base/stl_util.h" +#include "base/test/simple_test_clock.h" #include "base/threading/simple_thread.h" +#include "base/time/clock.h" #include "media/base/clock.h" #include "media/base/gmock_callback_support.h" #include "media/base/media_log.h" @@ -298,6 +300,7 @@ class PipelineTest : public ::testing::Test { // Fixture members. StrictMock<CallbackHelper> callbacks_; + base::SimpleTestClock test_clock_; MessageLoop message_loop_; scoped_refptr<Pipeline> pipeline_; @@ -608,12 +611,6 @@ TEST_F(PipelineTest, EndedCallback) { message_loop_.RunUntilIdle(); } -// Static function & time variable used to simulate changes in wallclock time. -static int64 g_static_clock_time; -static base::Time StaticClockFunction() { - return base::Time::FromInternalValue(g_static_clock_time); -} - TEST_F(PipelineTest, AudioStreamShorterThanVideo) { base::TimeDelta duration = base::TimeDelta::FromSeconds(10); @@ -625,7 +622,7 @@ TEST_F(PipelineTest, AudioStreamShorterThanVideo) { // Replace the clock so we can simulate wallclock time advancing w/o using // Sleep(). - pipeline_->SetClockForTesting(new Clock(&StaticClockFunction)); + pipeline_->SetClockForTesting(new Clock(&test_clock_)); InitializeDemuxer(&streams, duration); InitializeAudioRenderer(audio_stream(), false); @@ -646,8 +643,7 @@ TEST_F(PipelineTest, AudioStreamShorterThanVideo) { // Verify that the clock doesn't advance since it hasn't been started by // a time update from the audio stream. int64 start_time = pipeline_->GetMediaTime().ToInternalValue(); - g_static_clock_time += - base::TimeDelta::FromMilliseconds(100).ToInternalValue(); + test_clock_.Advance(base::TimeDelta::FromMilliseconds(100)); EXPECT_EQ(pipeline_->GetMediaTime().ToInternalValue(), start_time); // Signal end of audio stream. @@ -656,8 +652,7 @@ TEST_F(PipelineTest, AudioStreamShorterThanVideo) { // Verify that the clock advances. start_time = pipeline_->GetMediaTime().ToInternalValue(); - g_static_clock_time += - base::TimeDelta::FromMilliseconds(100).ToInternalValue(); + test_clock_.Advance(base::TimeDelta::FromMilliseconds(100)); EXPECT_GT(pipeline_->GetMediaTime().ToInternalValue(), start_time); // Signal end of video stream and make sure OnEnded() callback occurs. |