| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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 <utility> | 5 #include <utility> |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
| 10 #include "base/debug/stack_trace.h" | 10 #include "base/debug/stack_trace.h" |
| 11 #include "base/message_loop/message_loop.h" | 11 #include "base/message_loop/message_loop.h" |
| 12 #include "base/stl_util.h" | 12 #include "base/stl_util.h" |
| 13 #include "base/strings/string_number_conversions.h" | 13 #include "base/strings/string_number_conversions.h" |
| 14 #include "base/strings/string_split.h" | 14 #include "base/strings/string_split.h" |
| 15 #include "base/strings/stringprintf.h" | 15 #include "base/strings/stringprintf.h" |
| 16 #include "base/synchronization/lock.h" | 16 #include "base/synchronization/lock.h" |
| 17 #include "media/base/data_buffer.h" | 17 #include "media/base/data_buffer.h" |
| 18 #include "media/base/gmock_callback_support.h" | 18 #include "media/base/gmock_callback_support.h" |
| 19 #include "media/base/limits.h" | 19 #include "media/base/limits.h" |
| 20 #include "media/base/mock_filters.h" | 20 #include "media/base/mock_filters.h" |
| 21 #include "media/base/test_helpers.h" | 21 #include "media/base/test_helpers.h" |
| 22 #include "media/base/video_frame.h" | 22 #include "media/base/video_frame.h" |
| 23 #include "media/renderers/video_renderer_impl.h" | 23 #include "media/renderers/video_renderer_impl.h" |
| 24 #include "testing/gtest/include/gtest/gtest.h" | 24 #include "testing/gtest/include/gtest/gtest.h" |
| 25 | 25 |
| 26 using ::testing::_; | 26 using ::testing::_; |
| 27 using ::testing::AnyNumber; | 27 using ::testing::AnyNumber; |
| 28 using ::testing::Invoke; | 28 using ::testing::Invoke; |
| 29 using ::testing::Mock; |
| 29 using ::testing::NiceMock; | 30 using ::testing::NiceMock; |
| 30 using ::testing::Return; | 31 using ::testing::Return; |
| 31 using ::testing::SaveArg; | 32 using ::testing::SaveArg; |
| 32 using ::testing::StrictMock; | 33 using ::testing::StrictMock; |
| 33 | 34 |
| 34 namespace media { | 35 namespace media { |
| 35 | 36 |
| 36 ACTION_P(RunClosure, closure) { | 37 ACTION_P(RunClosure, closure) { |
| 37 closure.Run(); | 38 closure.Run(); |
| 38 } | 39 } |
| (...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 QueueFrames("0 10 20 30"); | 475 QueueFrames("0 10 20 30"); |
| 475 | 476 |
| 476 { | 477 { |
| 477 WaitableMessageLoopEvent event; | 478 WaitableMessageLoopEvent event; |
| 478 EXPECT_CALL(mock_cb_, Display(HasTimestamp(0))) | 479 EXPECT_CALL(mock_cb_, Display(HasTimestamp(0))) |
| 479 .Times(1) | 480 .Times(1) |
| 480 .WillOnce(RunClosure(event.GetClosure())); | 481 .WillOnce(RunClosure(event.GetClosure())); |
| 481 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); | 482 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)); |
| 482 StartPlayingFrom(0); | 483 StartPlayingFrom(0); |
| 483 event.RunAndWait(); | 484 event.RunAndWait(); |
| 485 Mock::VerifyAndClearExpectations(&mock_cb_); |
| 484 } | 486 } |
| 485 | 487 |
| 486 // Advance time slightly. Frames should be dropped and we should NOT signal | 488 // Advance time slightly. Frames should be dropped and we should NOT signal |
| 487 // having nothing. | 489 // having nothing. |
| 488 AdvanceTimeInMs(100); | 490 AdvanceTimeInMs(100); |
| 489 | 491 |
| 490 // Advance time more. Now we should signal having nothing. And put | 492 // Advance time more. Now we should signal having nothing. And put |
| 491 // the last frame up for display. | 493 // the last frame up for display. |
| 492 { | 494 { |
| 493 SCOPED_TRACE("Waiting for BUFFERING_HAVE_NOTHING"); | 495 SCOPED_TRACE("Waiting for BUFFERING_HAVE_NOTHING"); |
| 494 WaitableMessageLoopEvent event; | 496 WaitableMessageLoopEvent event; |
| 495 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_NOTHING)) | 497 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_NOTHING)) |
| 496 .WillOnce(RunClosure(event.GetClosure())); | 498 .WillOnce(RunClosure(event.GetClosure())); |
| 497 EXPECT_CALL(mock_cb_, Display(HasTimestamp(10))).Times(0); | 499 EXPECT_CALL(mock_cb_, Display(HasTimestamp(10))).Times(0); |
| 498 EXPECT_CALL(mock_cb_, Display(HasTimestamp(20))).Times(0); | 500 EXPECT_CALL(mock_cb_, Display(HasTimestamp(20))).Times(0); |
| 499 EXPECT_CALL(mock_cb_, Display(HasTimestamp(30))).Times(1); | 501 EXPECT_CALL(mock_cb_, Display(HasTimestamp(30))).Times(1); |
| 500 AdvanceTimeInMs(3000); // Must match kTimeToDeclareHaveNothing. | 502 AdvanceTimeInMs(3000); // Must match kTimeToDeclareHaveNothing. |
| 501 event.RunAndWait(); | 503 event.RunAndWait(); |
| 504 Mock::VerifyAndClearExpectations(&mock_cb_); |
| 502 } | 505 } |
| 503 | 506 |
| 504 // Receiving end of stream should signal having enough. | 507 // Receiving end of stream should signal having enough. |
| 505 { | 508 { |
| 506 SCOPED_TRACE("Waiting for BUFFERING_HAVE_ENOUGH"); | 509 SCOPED_TRACE("Waiting for BUFFERING_HAVE_ENOUGH"); |
| 507 WaitableMessageLoopEvent event; | 510 WaitableMessageLoopEvent event; |
| 508 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)) | 511 EXPECT_CALL(mock_cb_, BufferingStateChange(BUFFERING_HAVE_ENOUGH)) |
| 509 .WillOnce(RunClosure(event.GetClosure())); | 512 .WillOnce(RunClosure(event.GetClosure())); |
| 510 SatisfyPendingReadWithEndOfStream(); | 513 SatisfyPendingReadWithEndOfStream(); |
| 511 event.RunAndWait(); | 514 event.RunAndWait(); |
| 512 } | 515 } |
| 513 | 516 |
| 514 WaitForEnded(); | 517 WaitForEnded(); |
| 515 Destroy(); | 518 Destroy(); |
| 516 } | 519 } |
| 517 | 520 |
| 518 } // namespace media | 521 } // namespace media |
| OLD | NEW |