Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/stl_util.h" | 9 #include "base/stl_util.h" |
| 10 #include "base/threading/simple_thread.h" | 10 #include "base/threading/simple_thread.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 150 EXPECT_CALL(*mocks_->audio_decoder(), SetPlaybackRate(0.0f)); | 150 EXPECT_CALL(*mocks_->audio_decoder(), SetPlaybackRate(0.0f)); |
| 151 EXPECT_CALL(*mocks_->audio_decoder(), Seek(base::TimeDelta(), _)) | 151 EXPECT_CALL(*mocks_->audio_decoder(), Seek(base::TimeDelta(), _)) |
| 152 .WillOnce(Invoke(&RunFilterStatusCB)); | 152 .WillOnce(Invoke(&RunFilterStatusCB)); |
| 153 EXPECT_CALL(*mocks_->audio_decoder(), Stop(_)) | 153 EXPECT_CALL(*mocks_->audio_decoder(), Stop(_)) |
| 154 .WillOnce(Invoke(&RunStopFilterCallback)); | 154 .WillOnce(Invoke(&RunStopFilterCallback)); |
| 155 } | 155 } |
| 156 | 156 |
| 157 // Sets up expectations to allow the video renderer to initialize. | 157 // Sets up expectations to allow the video renderer to initialize. |
| 158 void InitializeVideoRenderer() { | 158 void InitializeVideoRenderer() { |
| 159 EXPECT_CALL(*mocks_->video_renderer(), | 159 EXPECT_CALL(*mocks_->video_renderer(), |
| 160 Initialize(mocks_->video_decoder(), _, _)) | 160 Initialize(mocks_->video_decoder(), _, _, _)) |
| 161 .WillOnce(Invoke(&RunFilterCallback3)); | 161 .WillOnce(Invoke(&RunFilterCallback4)); |
| 162 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(0.0f)); | 162 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(0.0f)); |
| 163 EXPECT_CALL(*mocks_->video_renderer(), | 163 EXPECT_CALL(*mocks_->video_renderer(), |
| 164 Seek(mocks_->demuxer()->GetStartTime(), _)) | 164 Seek(mocks_->demuxer()->GetStartTime(), _)) |
| 165 .WillOnce(Invoke(&RunFilterStatusCB)); | 165 .WillOnce(Invoke(&RunFilterStatusCB)); |
| 166 EXPECT_CALL(*mocks_->video_renderer(), Stop(_)) | 166 EXPECT_CALL(*mocks_->video_renderer(), Stop(_)) |
| 167 .WillOnce(Invoke(&RunStopFilterCallback)); | 167 .WillOnce(Invoke(&RunStopFilterCallback)); |
| 168 } | 168 } |
| 169 | 169 |
| 170 // Sets up expectations to allow the audio renderer to initialize. | 170 // Sets up expectations to allow the audio renderer to initialize. |
| 171 void InitializeAudioRenderer(bool disable_after_init_callback = false) { | 171 void InitializeAudioRenderer(bool disable_after_init_callback = false) { |
| 172 if (disable_after_init_callback) { | 172 if (disable_after_init_callback) { |
| 173 EXPECT_CALL(*mocks_->audio_renderer(), | 173 EXPECT_CALL(*mocks_->audio_renderer(), |
| 174 Initialize(mocks_->audio_decoder(), _, _)) | 174 Initialize(mocks_->audio_decoder(), _, _, _)) |
| 175 .WillOnce(DoAll(Invoke(&RunFilterCallback3), | 175 .WillOnce(DoAll(Invoke(&RunFilterCallback4), |
| 176 DisableAudioRenderer(mocks_->audio_renderer()))); | 176 DisableAudioRenderer(mocks_->audio_renderer()))); |
| 177 } else { | 177 } else { |
| 178 EXPECT_CALL(*mocks_->audio_renderer(), | 178 EXPECT_CALL(*mocks_->audio_renderer(), |
| 179 Initialize(mocks_->audio_decoder(), _, _)) | 179 Initialize(mocks_->audio_decoder(), _, _, _)) |
| 180 .WillOnce(Invoke(&RunFilterCallback3)); | 180 .WillOnce(Invoke(&RunFilterCallback4)); |
| 181 } | 181 } |
| 182 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(0.0f)); | 182 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(0.0f)); |
| 183 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(1.0f)); | 183 EXPECT_CALL(*mocks_->audio_renderer(), SetVolume(1.0f)); |
| 184 EXPECT_CALL(*mocks_->audio_renderer(), Seek(base::TimeDelta(), _)) | 184 EXPECT_CALL(*mocks_->audio_renderer(), Seek(base::TimeDelta(), _)) |
| 185 .WillOnce(Invoke(&RunFilterStatusCB)); | 185 .WillOnce(Invoke(&RunFilterStatusCB)); |
| 186 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)) | 186 EXPECT_CALL(*mocks_->audio_renderer(), Stop(_)) |
| 187 .WillOnce(Invoke(&RunStopFilterCallback)); | 187 .WillOnce(Invoke(&RunStopFilterCallback)); |
| 188 } | 188 } |
| 189 | 189 |
| 190 // Sets up expectations on the callback and initializes the pipeline. Called | 190 // Sets up expectations on the callback and initializes the pipeline. Called |
| (...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 686 InitializeAudioRenderer(); | 686 InitializeAudioRenderer(); |
| 687 InitializeVideoDecoder(video_stream()); | 687 InitializeVideoDecoder(video_stream()); |
| 688 InitializeVideoRenderer(); | 688 InitializeVideoRenderer(); |
| 689 InitializePipeline(PIPELINE_OK); | 689 InitializePipeline(PIPELINE_OK); |
| 690 | 690 |
| 691 // For convenience to simulate filters calling the methods. | 691 // For convenience to simulate filters calling the methods. |
| 692 FilterHost* host = pipeline_; | 692 FilterHost* host = pipeline_; |
| 693 | 693 |
| 694 // Replace the clock so we can simulate wallclock time advancing w/o using | 694 // Replace the clock so we can simulate wallclock time advancing w/o using |
| 695 // Sleep(). | 695 // Sleep(). |
| 696 pipeline_->SetClockForTesting(new Clock(&StaticClockFunction)); | 696 pipeline_->SetClockForTesting(new Clock(&StaticClockFunction)); |
|
acolwell GONE FROM CHROMIUM
2012/01/24 18:13:59
I think if you move this before InitializeDemuxer(
vrk (LEFT CHROMIUM)
2012/01/25 00:09:32
Doing this actually made the test fail... because
| |
| 697 static_cast<DemuxerHost*>(pipeline_)->SetDuration(duration); | |
| 697 | 698 |
| 698 EXPECT_EQ(0, host->GetTime().ToInternalValue()); | 699 EXPECT_EQ(0, host->GetTime().ToInternalValue()); |
| 699 | 700 |
| 700 float playback_rate = 1.0f; | 701 float playback_rate = 1.0f; |
| 701 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(playback_rate)); | 702 EXPECT_CALL(*mocks_->demuxer(), SetPlaybackRate(playback_rate)); |
| 702 EXPECT_CALL(*mocks_->video_decoder(), SetPlaybackRate(playback_rate)); | 703 EXPECT_CALL(*mocks_->video_decoder(), SetPlaybackRate(playback_rate)); |
| 703 EXPECT_CALL(*mocks_->audio_decoder(), SetPlaybackRate(playback_rate)); | 704 EXPECT_CALL(*mocks_->audio_decoder(), SetPlaybackRate(playback_rate)); |
| 704 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(playback_rate)); | 705 EXPECT_CALL(*mocks_->video_renderer(), SetPlaybackRate(playback_rate)); |
| 705 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(playback_rate)); | 706 EXPECT_CALL(*mocks_->audio_renderer(), SetPlaybackRate(playback_rate)); |
| 706 pipeline_->SetPlaybackRate(playback_rate); | 707 pipeline_->SetPlaybackRate(playback_rate); |
| (...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 911 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0)); | 912 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(0)); |
| 912 } | 913 } |
| 913 | 914 |
| 914 // Test that different-thread, some-delay callback (the expected common case) | 915 // Test that different-thread, some-delay callback (the expected common case) |
| 915 // works correctly. | 916 // works correctly. |
| 916 TEST(PipelineStatusNotificationTest, DelayedCallback) { | 917 TEST(PipelineStatusNotificationTest, DelayedCallback) { |
| 917 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20)); | 918 TestPipelineStatusNotification(base::TimeDelta::FromMilliseconds(20)); |
| 918 } | 919 } |
| 919 | 920 |
| 920 } // namespace media | 921 } // namespace media |
| OLD | NEW |