Chromium Code Reviews| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 #include <stdint.h> | 6 #include <stdint.h> |
| 7 | 7 |
| 8 #include "base/bind.h" | |
| 9 #include "base/callback.h" | |
| 8 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
| 9 #include "base/run_loop.h" | 11 #include "base/run_loop.h" |
| 10 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
| 11 #include "cc/playback/raster_source.h" | 13 #include "cc/playback/raster_source.h" |
| 12 #include "cc/playback/recording_source.h" | 14 #include "cc/playback/recording_source.h" |
| 13 #include "cc/raster/raster_buffer.h" | 15 #include "cc/raster/raster_buffer.h" |
| 14 #include "cc/raster/synchronous_task_graph_runner.h" | 16 #include "cc/raster/synchronous_task_graph_runner.h" |
| 15 #include "cc/resources/resource_pool.h" | 17 #include "cc/resources/resource_pool.h" |
| 16 #include "cc/test/begin_frame_args_test.h" | 18 #include "cc/test/begin_frame_args_test.h" |
| 17 #include "cc/test/fake_compositor_frame_sink.h" | 19 #include "cc/test/fake_compositor_frame_sink.h" |
| (...skipping 1457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1475 public: | 1477 public: |
| 1476 MockLayerTreeHostImpl(const LayerTreeSettings& settings, | 1478 MockLayerTreeHostImpl(const LayerTreeSettings& settings, |
| 1477 TaskRunnerProvider* task_runner_provider, | 1479 TaskRunnerProvider* task_runner_provider, |
| 1478 TaskGraphRunner* task_graph_runner) | 1480 TaskGraphRunner* task_graph_runner) |
| 1479 : FakeLayerTreeHostImpl(settings, | 1481 : FakeLayerTreeHostImpl(settings, |
| 1480 task_runner_provider, | 1482 task_runner_provider, |
| 1481 task_graph_runner) {} | 1483 task_graph_runner) {} |
| 1482 | 1484 |
| 1483 MOCK_METHOD0(NotifyAllTileTasksCompleted, void()); | 1485 MOCK_METHOD0(NotifyAllTileTasksCompleted, void()); |
| 1484 MOCK_METHOD0(NotifyReadyToDraw, void()); | 1486 MOCK_METHOD0(NotifyReadyToDraw, void()); |
| 1487 MOCK_METHOD0(NotifyReadyToActivate, void()); | |
| 1485 }; | 1488 }; |
| 1486 | 1489 |
| 1487 std::unique_ptr<FakeLayerTreeHostImpl> CreateHostImpl( | 1490 std::unique_ptr<FakeLayerTreeHostImpl> CreateHostImpl( |
| 1488 const LayerTreeSettings& settings, | 1491 const LayerTreeSettings& settings, |
| 1489 TaskRunnerProvider* task_runner_provider, | 1492 TaskRunnerProvider* task_runner_provider, |
| 1490 TaskGraphRunner* task_graph_runner) override { | 1493 TaskGraphRunner* task_graph_runner) override { |
| 1491 return base::MakeUnique<MockLayerTreeHostImpl>( | 1494 return base::MakeUnique<testing::NiceMock<MockLayerTreeHostImpl>>( |
| 1492 settings, task_runner_provider, task_graph_runner); | 1495 settings, task_runner_provider, task_graph_runner); |
| 1493 } | 1496 } |
| 1494 | 1497 |
| 1495 // By default use software compositing (no context provider). | 1498 // By default use software compositing (no context provider). |
| 1496 std::unique_ptr<CompositorFrameSink> CreateCompositorFrameSink() override { | 1499 std::unique_ptr<CompositorFrameSink> CreateCompositorFrameSink() override { |
| 1497 return FakeCompositorFrameSink::CreateSoftware(); | 1500 return FakeCompositorFrameSink::CreateSoftware(); |
| 1498 } | 1501 } |
| 1499 | 1502 |
| 1500 MockLayerTreeHostImpl& MockHostImpl() { | 1503 MockLayerTreeHostImpl& MockHostImpl() { |
| 1501 return *static_cast<MockLayerTreeHostImpl*>(host_impl()); | 1504 return *static_cast<MockLayerTreeHostImpl*>(host_impl()); |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1877 TEST_F(PartialRasterTileManagerTest, PartialRasterSuccessfullyEnabled) { | 1880 TEST_F(PartialRasterTileManagerTest, PartialRasterSuccessfullyEnabled) { |
| 1878 RunPartialRasterCheck(TakeHostImpl(), true /* partial_raster_enabled */); | 1881 RunPartialRasterCheck(TakeHostImpl(), true /* partial_raster_enabled */); |
| 1879 } | 1882 } |
| 1880 | 1883 |
| 1881 // Ensures that the tile manager does not attempt to reuse tiles when partial | 1884 // Ensures that the tile manager does not attempt to reuse tiles when partial |
| 1882 // raster is disabled. | 1885 // raster is disabled. |
| 1883 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { | 1886 TEST_F(TileManagerTest, PartialRasterSuccessfullyDisabled) { |
| 1884 RunPartialRasterCheck(TakeHostImpl(), false /* partial_raster_enabled */); | 1887 RunPartialRasterCheck(TakeHostImpl(), false /* partial_raster_enabled */); |
| 1885 } | 1888 } |
| 1886 | 1889 |
| 1890 // FakeRasterBufferProviderImpl that allows us to mock SetReadyToDrawCallback. | |
| 1891 class MockReadyToDrawRasterBufferProviderImpl | |
| 1892 : public FakeRasterBufferProviderImpl { | |
| 1893 public: | |
| 1894 MOCK_CONST_METHOD3( | |
| 1895 SetReadyToDrawCallback, | |
| 1896 uint64_t(const ResourceProvider::ResourceIdArray& resource_ids, | |
| 1897 const base::Callback<void(uint64_t)>& callback, | |
| 1898 uint64_t pending_callback_id)); | |
| 1899 }; | |
| 1900 | |
| 1901 TEST_F(TileManagerTest, SmoothActivationWaitsOnCallback) { | |
| 1902 MockReadyToDrawRasterBufferProviderImpl raster_buffer_provider; | |
| 1903 host_impl()->tile_manager()->SetRasterBufferProviderForTesting( | |
| 1904 &raster_buffer_provider); | |
| 1905 host_impl()->SetTreePriority(SMOOTHNESS_TAKES_PRIORITY); | |
| 1906 | |
| 1907 base::Callback<void(uint64_t)> callback; | |
| 1908 { | |
| 1909 base::RunLoop run_loop; | |
| 1910 EXPECT_CALL(raster_buffer_provider, | |
| 1911 SetReadyToDrawCallback(testing::_, testing::_, 0)) | |
| 1912 .WillOnce(testing::Invoke([&run_loop, &callback]( | |
| 1913 const ResourceProvider::ResourceIdArray& resource_ids, | |
| 1914 const base::Callback<void(uint64_t)>& callback_in, | |
| 1915 uint64_t pending_callback_id) { | |
| 1916 callback = callback_in; | |
| 1917 run_loop.Quit(); | |
| 1918 return 1; | |
| 1919 })); | |
| 1920 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); | |
| 1921 run_loop.Run(); | |
| 1922 } | |
| 1923 | |
| 1924 EXPECT_FALSE(host_impl()->tile_manager()->IsReadyToActivate()); | |
| 1925 | |
| 1926 { | |
| 1927 base::RunLoop run_loop; | |
| 1928 EXPECT_CALL(MockHostImpl(), NotifyReadyToActivate()) | |
| 1929 .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); | |
| 1930 callback.Run(1); | |
| 1931 run_loop.Run(); | |
| 1932 } | |
| 1933 | |
| 1934 EXPECT_TRUE(host_impl()->tile_manager()->IsReadyToActivate()); | |
| 1935 | |
| 1936 TakeHostImpl(); | |
| 1937 } | |
| 1938 | |
| 1939 TEST_F(TileManagerTest, SmoothActivationDoesNotWaitOnZeroCallback) { | |
| 1940 MockReadyToDrawRasterBufferProviderImpl raster_buffer_provider; | |
| 1941 host_impl()->tile_manager()->SetRasterBufferProviderForTesting( | |
| 1942 &raster_buffer_provider); | |
| 1943 host_impl()->SetTreePriority(SMOOTHNESS_TAKES_PRIORITY); | |
| 1944 | |
| 1945 base::RunLoop run_loop; | |
| 1946 EXPECT_CALL(raster_buffer_provider, | |
| 1947 SetReadyToDrawCallback(testing::_, testing::_, 0)) | |
| 1948 .WillOnce(testing::Return(0)); | |
| 1949 EXPECT_CALL(MockHostImpl(), NotifyReadyToActivate()) | |
| 1950 .WillOnce(testing::Invoke([&run_loop]() { run_loop.Quit(); })); | |
| 1951 | |
| 1952 host_impl()->tile_manager()->PrepareTiles(host_impl()->global_tile_state()); | |
| 1953 run_loop.Run(); | |
| 1954 | |
| 1955 EXPECT_TRUE(host_impl()->tile_manager()->IsReadyToActivate()); | |
| 1956 | |
| 1957 TakeHostImpl(); | |
| 1958 } | |
|
vmpstr
2016/12/07 21:00:25
Can you add a test for non-smoothness mode as well
| |
| 1959 | |
| 1887 } // namespace | 1960 } // namespace |
| 1888 } // namespace cc | 1961 } // namespace cc |
| OLD | NEW |