Index: media/base/pipeline_unittest.cc |
diff --git a/media/base/pipeline_unittest.cc b/media/base/pipeline_unittest.cc |
index a12f91cc35616199a138f41f06bfa12523237be5..32040f8002db7ab1f0776adaecb663359984582f 100644 |
--- a/media/base/pipeline_unittest.cc |
+++ b/media/base/pipeline_unittest.cc |
@@ -5,8 +5,10 @@ |
#include <vector> |
#include "base/bind.h" |
+#include "base/clock.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 "media/base/clock.h" |
#include "media/base/gmock_callback_support.h" |
@@ -278,6 +280,7 @@ class PipelineTest : public ::testing::Test { |
// Fixture members. |
StrictMock<CallbackHelper> callbacks_; |
+ base::SimpleTestClock test_clock_; |
MessageLoop message_loop_; |
scoped_refptr<Pipeline> pipeline_; |
scoped_ptr<media::MockFilterCollection> mocks_; |
@@ -581,12 +584,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); |
@@ -598,7 +595,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); |
@@ -619,8 +616,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. |
@@ -629,8 +625,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. |