Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2371)

Unified Diff: cc/tiles/tile_manager_unittest.cc

Issue 2555743004: Delay activation/draw on GPU tile work completion (Closed)
Patch Set: cleanup Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« cc/tiles/tile_manager.cc ('K') | « cc/tiles/tile_manager.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« cc/tiles/tile_manager.cc ('K') | « cc/tiles/tile_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698