Chromium Code Reviews| Index: cc/tiles/tile_manager_unittest.cc |
| diff --git a/cc/tiles/tile_manager_unittest.cc b/cc/tiles/tile_manager_unittest.cc |
| index 04aaabc6c4d6b50e1337c7b39de1a2283eb0cb3f..5a44b4f4614c580ce26cbcba285d72db85488df2 100644 |
| --- a/cc/tiles/tile_manager_unittest.cc |
| +++ b/cc/tiles/tile_manager_unittest.cc |
| @@ -5,6 +5,8 @@ |
| #include <stddef.h> |
| #include <stdint.h> |
| +#include "base/bind.h" |
| +#include "base/callback.h" |
| #include "base/memory/ptr_util.h" |
| #include "base/run_loop.h" |
| #include "base/threading/thread_task_runner_handle.h" |
| @@ -1482,13 +1484,14 @@ class TileManagerTest : public TestLayerTreeHostBase { |
| MOCK_METHOD0(NotifyAllTileTasksCompleted, void()); |
| MOCK_METHOD0(NotifyReadyToDraw, void()); |
| + MOCK_METHOD0(NotifyReadyToActivate, void()); |
| }; |
| std::unique_ptr<FakeLayerTreeHostImpl> CreateHostImpl( |
| const LayerTreeSettings& settings, |
| TaskRunnerProvider* task_runner_provider, |
| TaskGraphRunner* task_graph_runner) override { |
| - return base::MakeUnique<MockLayerTreeHostImpl>( |
| + return base::MakeUnique<testing::NiceMock<MockLayerTreeHostImpl>>( |
| settings, task_runner_provider, task_graph_runner); |
| } |
| @@ -1884,5 +1887,75 @@ TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { |
| RunPartialRasterCheck(TakeHostImpl(), false /* partial_raster_enabled */); |
| } |
| +// FakeRasterBufferProviderImpl that allows us to mock SetReadyToDrawCallback. |
| +class MockReadyToDrawRasterBufferProviderImpl |
| + : public FakeRasterBufferProviderImpl { |
| + public: |
| + MOCK_CONST_METHOD3( |
| + SetReadyToDrawCallback, |
| + uint64_t(const ResourceProvider::ResourceIdArray& resource_ids, |
| + const base::Callback<void(uint64_t)>& callback, |
| + uint64_t pending_callback_id)); |
| +}; |
| + |
| +TEST_F(TileManagerTest, SmoothActivationWaitsOnCallback) { |
| + MockReadyToDrawRasterBufferProviderImpl raster_buffer_provider; |
| + host_impl()->tile_manager()->SetRasterBufferProviderForTesting( |
| + &raster_buffer_provider); |
| + host_impl()->SetTreePriority(SMOOTHNESS_TAKES_PRIORITY); |
| + |
| + base::Callback<void(uint64_t)> callback; |
| + { |
| + base::RunLoop run_loop; |
| + EXPECT_CALL(raster_buffer_provider, |
| + SetReadyToDrawCallback(testing::_, testing::_, 0)) |
| + .WillOnce(testing::Invoke([&run_loop, &callback]( |
| + const ResourceProvider::ResourceIdArray& resource_ids, |
| + const base::Callback<void(uint64_t)>& callback_in, |
| + uint64_t pending_callback_id) { |
| + callback = callback_in; |
| + run_loop.Quit(); |
| + return 1; |
| + })); |
| + host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); |
| + run_loop.Run(); |
| + } |
| + |
| + EXPECT_FALSE(host_impl()->tile_manager()->IsReadyToActivate()); |
| + |
| + { |
| + base::RunLoop run_loop; |
| + EXPECT_CALL(MockHostImpl(), NotifyReadyToActivate()) |
| + .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); |
| + callback.Run(1); |
| + run_loop.Run(); |
| + } |
| + |
| + EXPECT_TRUE(host_impl()->tile_manager()->IsReadyToActivate()); |
| + |
| + TakeHostImpl(); |
| +} |
| + |
| +TEST_F(TileManagerTest, SmoothActivationDoesNotWaitOnZeroCallback) { |
| + MockReadyToDrawRasterBufferProviderImpl raster_buffer_provider; |
| + host_impl()->tile_manager()->SetRasterBufferProviderForTesting( |
| + &raster_buffer_provider); |
| + host_impl()->SetTreePriority(SMOOTHNESS_TAKES_PRIORITY); |
| + |
| + base::RunLoop run_loop; |
| + EXPECT_CALL(raster_buffer_provider, |
| + SetReadyToDrawCallback(testing::_, testing::_, 0)) |
| + .WillOnce(testing::Return(0)); |
| + EXPECT_CALL(MockHostImpl(), NotifyReadyToActivate()) |
| + .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); |
| + |
| + host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); |
| + run_loop.Run(); |
| + |
| + EXPECT_TRUE(host_impl()->tile_manager()->IsReadyToActivate()); |
| + |
| + TakeHostImpl(); |
| +} |
|
vmpstr
2016/12/07 21:00:25
Can you add a test for non-smoothness mode as well
|
| + |
| } // namespace |
| } // namespace cc |