| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "base/test/simple_test_tick_clock.h" | 9 #include "base/test/simple_test_tick_clock.h" |
| 10 #include "cc/layers/video_frame_provider.h" | 10 #include "cc/layers/video_frame_provider.h" |
| (...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 base::TimeTicks, | 64 base::TimeTicks, |
| 65 bool)); | 65 bool)); |
| 66 MOCK_METHOD0(OnFrameDropped, void()); | 66 MOCK_METHOD0(OnFrameDropped, void()); |
| 67 | 67 |
| 68 void StartVideoRendererSink() { | 68 void StartVideoRendererSink() { |
| 69 EXPECT_CALL(*this, StartRendering()); | 69 EXPECT_CALL(*this, StartRendering()); |
| 70 const bool had_current_frame = !!compositor_->GetCurrentFrame(); | 70 const bool had_current_frame = !!compositor_->GetCurrentFrame(); |
| 71 compositor()->Start(this); | 71 compositor()->Start(this); |
| 72 // If we previously had a frame, we should still have one now. | 72 // If we previously had a frame, we should still have one now. |
| 73 EXPECT_EQ(had_current_frame, !!compositor_->GetCurrentFrame()); | 73 EXPECT_EQ(had_current_frame, !!compositor_->GetCurrentFrame()); |
| 74 message_loop.RunUntilIdle(); | 74 base::RunLoop().RunUntilIdle(); |
| 75 } | 75 } |
| 76 | 76 |
| 77 void StopVideoRendererSink(bool have_client) { | 77 void StopVideoRendererSink(bool have_client) { |
| 78 if (have_client) | 78 if (have_client) |
| 79 EXPECT_CALL(*this, StopRendering()); | 79 EXPECT_CALL(*this, StopRendering()); |
| 80 const bool had_current_frame = !!compositor_->GetCurrentFrame(); | 80 const bool had_current_frame = !!compositor_->GetCurrentFrame(); |
| 81 compositor()->Stop(); | 81 compositor()->Stop(); |
| 82 // If we previously had a frame, we should still have one now. | 82 // If we previously had a frame, we should still have one now. |
| 83 EXPECT_EQ(had_current_frame, !!compositor_->GetCurrentFrame()); | 83 EXPECT_EQ(had_current_frame, !!compositor_->GetCurrentFrame()); |
| 84 message_loop.RunUntilIdle(); | 84 base::RunLoop().RunUntilIdle(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void RenderFrame() { | 87 void RenderFrame() { |
| 88 compositor()->GetCurrentFrame(); | 88 compositor()->GetCurrentFrame(); |
| 89 compositor()->PutCurrentFrame(); | 89 compositor()->PutCurrentFrame(); |
| 90 } | 90 } |
| 91 | 91 |
| 92 base::MessageLoop message_loop; | 92 base::MessageLoop message_loop; |
| 93 base::SimpleTestTickClock* tick_clock_; // Owned by |compositor_| | 93 base::SimpleTestTickClock* tick_clock_; // Owned by |compositor_| |
| 94 std::unique_ptr<VideoFrameCompositor> compositor_; | 94 std::unique_ptr<VideoFrameCompositor> compositor_; |
| (...skipping 164 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 259 | 259 |
| 260 // Advancing the tick clock should allow a new frame to be requested. | 260 // Advancing the tick clock should allow a new frame to be requested. |
| 261 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); | 261 tick_clock_->Advance(base::TimeDelta::FromMilliseconds(10)); |
| 262 ASSERT_EQ(opaque_frame_2, compositor()->GetCurrentFrameAndUpdateIfStale()); | 262 ASSERT_EQ(opaque_frame_2, compositor()->GetCurrentFrameAndUpdateIfStale()); |
| 263 | 263 |
| 264 // Background rendering should tick another render callback. | 264 // Background rendering should tick another render callback. |
| 265 StopVideoRendererSink(false); | 265 StopVideoRendererSink(false); |
| 266 } | 266 } |
| 267 | 267 |
| 268 } // namespace media | 268 } // namespace media |
| OLD | NEW |