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

Unified Diff: cc/trees/layer_tree_host_unittest_scroll.cc

Issue 2393213002: cc: Update scroll offset before property tree scrolling and animation. (Closed)
Patch Set: Nit change. Created 4 years, 2 months 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
« no previous file with comments | « cc/trees/layer_tree_host_in_process.cc ('k') | third_party/WebKit/LayoutTests/TestExpectations » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_unittest_scroll.cc
diff --git a/cc/trees/layer_tree_host_unittest_scroll.cc b/cc/trees/layer_tree_host_unittest_scroll.cc
index e68e06559d8a31bd28b83590a8f331478e152f67..6c75ec1abd42eb160212f38834933c334f0c1025 100644
--- a/cc/trees/layer_tree_host_unittest_scroll.cc
+++ b/cc/trees/layer_tree_host_unittest_scroll.cc
@@ -25,6 +25,7 @@
#include "cc/test/test_task_graph_runner.h"
#include "cc/trees/layer_tree_impl.h"
#include "cc/trees/scroll_node.h"
+#include "cc/trees/transform_node.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "ui/gfx/geometry/point_conversions.h"
#include "ui/gfx/geometry/size_conversions.h"
@@ -1978,5 +1979,72 @@ class LayerTreeHostScrollTestElasticOverscroll
MULTI_THREAD_TEST_F(LayerTreeHostScrollTestElasticOverscroll);
+class LayerTreeHostScrollTestPropertyTreeUpdate
+ : public LayerTreeHostScrollTest {
+ public:
+ LayerTreeHostScrollTestPropertyTreeUpdate()
+ : initial_scroll_(10, 20), second_scroll_(0, 0) {}
+
+ void BeginTest() override {
+ layer_tree()->inner_viewport_scroll_layer()->SetScrollOffset(
+ initial_scroll_);
+ layer_tree()->inner_viewport_scroll_layer()->SetBounds(gfx::Size(100, 100));
+ PostSetNeedsCommitToMainThread();
+ }
+
+ void UpdateLayerTreeHost() override {
+ Layer* scroll_layer = layer_tree()->inner_viewport_scroll_layer();
+ if (layer_tree_host()->SourceFrameNumber() == 0) {
+ EXPECT_VECTOR_EQ(initial_scroll_, scroll_layer->scroll_offset());
+ } else {
+ EXPECT_VECTOR_EQ(
+ gfx::ScrollOffsetWithDelta(initial_scroll_, scroll_amount_),
+ scroll_layer->scroll_offset());
+ scroll_layer->SetScrollOffset(second_scroll_);
+ scroll_layer->SetOpacity(0.5f);
+ }
+ }
+
+ void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override {
+ LayerImpl* scroll_layer = impl->InnerViewportScrollLayer();
+
+ switch (impl->active_tree()->source_frame_number()) {
+ case 0:
+ EXPECT_VECTOR_EQ(initial_scroll_, ScrollTreeForLayer(scroll_layer)
+ ->GetScrollOffsetBaseForTesting(
+ scroll_layer->id()));
+ EXPECT_VECTOR_EQ(
+ initial_scroll_,
+ scroll_layer->layer_tree_impl()
+ ->property_trees()
+ ->transform_tree.Node(scroll_layer->transform_tree_index())
+ ->scroll_offset);
+ PostSetNeedsCommitToMainThread();
+ break;
+ case 1:
+ EXPECT_VECTOR_EQ(second_scroll_, ScrollTreeForLayer(scroll_layer)
+ ->GetScrollOffsetBaseForTesting(
+ scroll_layer->id()));
+ EXPECT_VECTOR_EQ(
+ second_scroll_,
+ scroll_layer->layer_tree_impl()
+ ->property_trees()
+ ->transform_tree.Node(scroll_layer->transform_tree_index())
+ ->scroll_offset);
+ EndTest();
+ break;
+ }
+ }
+
+ void AfterTest() override {}
+
+ private:
+ gfx::ScrollOffset initial_scroll_;
+ gfx::ScrollOffset second_scroll_;
+ gfx::Vector2dF scroll_amount_;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostScrollTestPropertyTreeUpdate);
+
} // namespace
} // namespace cc
« no previous file with comments | « cc/trees/layer_tree_host_in_process.cc ('k') | third_party/WebKit/LayoutTests/TestExpectations » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698