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 <vector> | 5 #include <vector> |
| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 91 // streams. | 91 // streams. |
| 92 DemuxerStream* null_pointer = NULL; | 92 DemuxerStream* null_pointer = NULL; |
| 93 EXPECT_CALL(*mocks_->demuxer(), GetStream(_)) | 93 EXPECT_CALL(*mocks_->demuxer(), GetStream(_)) |
| 94 .WillRepeatedly(Return(null_pointer)); | 94 .WillRepeatedly(Return(null_pointer)); |
| 95 | 95 |
| 96 EXPECT_CALL(*mocks_->demuxer(), GetStartTime()) | 96 EXPECT_CALL(*mocks_->demuxer(), GetStartTime()) |
| 97 .WillRepeatedly(Return(base::TimeDelta())); | 97 .WillRepeatedly(Return(base::TimeDelta())); |
| 98 } | 98 } |
| 99 | 99 |
| 100 virtual ~PipelineTest() { | 100 virtual ~PipelineTest() { |
| 101 if (!pipeline_->IsRunning()) { | |
| 102 return; | |
| 103 } | |
| 104 | |
| 105 // Shutdown sequence. | 101 // Shutdown sequence. |
| 106 // | 102 if (pipeline_->IsRunning()) { |
| 107 // TODO(scherkus): This check is required because in certain teardown | |
| 108 // cases the pipeline is still "running" but has already stopped due to | |
| 109 // errors. In an ideal world we stop running when we teardown, but that | |
| 110 // requires cleaning up shutdown path, see http://crbug.com/110228 | |
| 111 if (pipeline_->IsInitializedForTesting()) { | |
| 112 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | 103 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) |
| 113 .WillOnce(RunClosure()); | 104 .WillOnce(RunClosure()); |
| 114 | 105 |
| 115 // TODO(scherkus): Don't pause+flush on shutdown, | 106 // TODO(scherkus): Don't pause+flush on shutdown, |
| 116 // see http://crbug.com/110228 | 107 // see http://crbug.com/110228 |
| 117 if (audio_stream_) { | 108 if (audio_stream_) { |
| 118 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)) | 109 EXPECT_CALL(*mocks_->audio_renderer(), Pause(_)) |
| 119 .WillOnce(RunClosure()); | 110 .WillOnce(RunClosure()); |
| 120 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)) | 111 EXPECT_CALL(*mocks_->audio_renderer(), Flush(_)) |
| 121 .WillOnce(RunClosure()); | 112 .WillOnce(RunClosure()); |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 350 // Should always get set to zero. | 341 // Should always get set to zero. |
| 351 gfx::Size size(1, 1); | 342 gfx::Size size(1, 1); |
| 352 pipeline_->GetNaturalVideoSize(&size); | 343 pipeline_->GetNaturalVideoSize(&size); |
| 353 EXPECT_EQ(0, size.width()); | 344 EXPECT_EQ(0, size.width()); |
| 354 EXPECT_EQ(0, size.height()); | 345 EXPECT_EQ(0, size.height()); |
| 355 } | 346 } |
| 356 | 347 |
| 357 TEST_F(PipelineTest, NeverInitializes) { | 348 TEST_F(PipelineTest, NeverInitializes) { |
| 358 // Don't execute the callback passed into Initialize(). | 349 // Don't execute the callback passed into Initialize(). |
| 359 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)); | 350 EXPECT_CALL(*mocks_->demuxer(), Initialize(_, _)); |
| 360 EXPECT_CALL(*mocks_->demuxer(), Stop(_)) | |
|
scherkus (not reviewing)
2012/08/09 19:26:53
covered by pipeline_->IsRunning() check in dtor
| |
| 361 .WillOnce(RunClosure()); | |
| 362 | 351 |
| 363 // This test hangs during initialization by never calling | 352 // This test hangs during initialization by never calling |
| 364 // InitializationComplete(). StrictMock<> will ensure that the callback is | 353 // InitializationComplete(). StrictMock<> will ensure that the callback is |
| 365 // never executed. | 354 // never executed. |
| 366 pipeline_->Start( | 355 pipeline_->Start( |
| 367 mocks_->Create().Pass(), | 356 mocks_->Create().Pass(), |
| 368 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), | 357 base::Bind(&CallbackHelper::OnEnded, base::Unretained(&callbacks_)), |
| 369 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), | 358 base::Bind(&CallbackHelper::OnError, base::Unretained(&callbacks_)), |
| 370 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_))); | 359 base::Bind(&CallbackHelper::OnStart, base::Unretained(&callbacks_))); |
| 371 message_loop_.RunAllPending(); | 360 message_loop_.RunAllPending(); |
| (...skipping 891 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1263 INSTANTIATE_TEARDOWN_TEST(Stop, Playing); | 1252 INSTANTIATE_TEARDOWN_TEST(Stop, Playing); |
| 1264 | 1253 |
| 1265 INSTANTIATE_TEARDOWN_TEST(Error, Pausing); | 1254 INSTANTIATE_TEARDOWN_TEST(Error, Pausing); |
| 1266 INSTANTIATE_TEARDOWN_TEST(Error, Flushing); | 1255 INSTANTIATE_TEARDOWN_TEST(Error, Flushing); |
| 1267 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); | 1256 INSTANTIATE_TEARDOWN_TEST(Error, Seeking); |
| 1268 INSTANTIATE_TEARDOWN_TEST(Error, Prerolling); | 1257 INSTANTIATE_TEARDOWN_TEST(Error, Prerolling); |
| 1269 INSTANTIATE_TEARDOWN_TEST(Error, Starting); | 1258 INSTANTIATE_TEARDOWN_TEST(Error, Starting); |
| 1270 INSTANTIATE_TEARDOWN_TEST(Error, Playing); | 1259 INSTANTIATE_TEARDOWN_TEST(Error, Playing); |
| 1271 | 1260 |
| 1272 } // namespace media | 1261 } // namespace media |
| OLD | NEW |