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

Unified Diff: cc/trees/tree_synchronizer_unittest.cc

Issue 2393213002: cc: Update scroll offset before property tree scrolling and animation. (Closed)
Patch Set: Update scroll offset before updating property tree scrolling and animation. 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
Index: cc/trees/tree_synchronizer_unittest.cc
diff --git a/cc/trees/tree_synchronizer_unittest.cc b/cc/trees/tree_synchronizer_unittest.cc
index f656634636a169d33a73916a3c430a072cc037ee..af086d62aab4973d29b425b5d11ba5129cdbd0f9 100644
--- a/cc/trees/tree_synchronizer_unittest.cc
+++ b/cc/trees/tree_synchronizer_unittest.cc
@@ -26,6 +26,7 @@
#include "cc/trees/layer_tree_host_common.h"
#include "cc/trees/single_thread_proxy.h"
#include "cc/trees/task_runner_provider.h"
+#include "cc/trees/transform_node.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace cc {
@@ -620,6 +621,66 @@ TEST_F(TreeSynchronizerTest, SynchronizeScrollTreeScrollOffsetMap) {
EXPECT_TRUE(is_equal(scroll_offset_map, scroll_tree.scroll_offset_map()));
}
+TEST_F(TreeSynchronizerTest,
+ SynchronizeScrollTreeScrollOffsetMapFromMainToActive) {
+ host_->InitializeSingleThreaded(&single_thread_client_,
+ base::ThreadTaskRunnerHandle::Get());
+ FakeLayerTreeHostImpl* host_impl = host_->host_impl();
+
+ scoped_refptr<Layer> layer_tree_root = Layer::Create();
+ scoped_refptr<Layer> scroll_clip_layer = Layer::Create();
+ scoped_refptr<Layer> scroll_layer = Layer::Create();
+
+ layer_tree_root->AddChild(scroll_clip_layer);
+ scroll_clip_layer->AddChild(scroll_layer);
+
+ scroll_layer->SetScrollClipLayerId(scroll_clip_layer->id());
+ scroll_layer->SetScrollOffset(gfx::ScrollOffset(10, 20));
+
+ host_->SetRootLayer(layer_tree_root);
+ host_->BuildPropertyTreesForTesting();
+ host_->FinishCommitOnImplThread(host_impl);
+
+ ExpectTreesAreIdentical(layer_tree_root.get(),
+ host_impl->active_tree()->root_layer_for_testing(),
+ host_impl->active_tree());
+
+ // After the initial commit, scroll_offset_map in scroll_tree is expected to
+ // have one entry for scroll_layer and one entry for transient_scroll_layer,
+ // the pending base and active base must be the same at this stage.
+ ScrollTree::ScrollOffsetMap scroll_offset_map;
+ scroll_offset_map[scroll_layer->id()] = new SyncedScrollOffset;
+ scroll_offset_map[scroll_layer->id()]->PushFromMainThread(
+ scroll_layer->scroll_offset());
+ scroll_offset_map[scroll_layer->id()]->PushPendingToActive();
+ EXPECT_TRUE(
+ is_equal(scroll_offset_map, host_impl->active_tree()
+ ->property_trees()
+ ->scroll_tree.scroll_offset_map()));
+
+ // When running Layout tests in single thread mode, it is possible that the
+ // scroll tree's scroll offset map got cleared between commits, as a new test
+ // is started after finishing the previous one.
+ host_->property_trees()->scroll_tree.scroll_offset_map().clear();
+ scroll_layer->SetScrollOffset(gfx::ScrollOffset(0, 0));
+
+ host_->BuildPropertyTreesForTesting();
+ host_->FinishCommitOnImplThread(host_impl);
+
+ scroll_offset_map[scroll_layer->id()]->PushFromMainThread(
+ gfx::ScrollOffset(0, 0));
+ scroll_offset_map[scroll_layer->id()]->PushPendingToActive();
+ EXPECT_TRUE(
+ is_equal(scroll_offset_map, host_impl->active_tree()
+ ->property_trees()
+ ->scroll_tree.scroll_offset_map()));
+ EXPECT_EQ(host_impl->active_tree()
+ ->property_trees()
+ ->transform_tree.Node(scroll_layer->transform_tree_index())
+ ->scroll_offset,
+ gfx::ScrollOffset(0, 0));
+}
+
TEST_F(TreeSynchronizerTest, RefreshPropertyTreesCachedData) {
host_->InitializeSingleThreaded(&single_thread_client_,
base::ThreadTaskRunnerHandle::Get());

Powered by Google App Engine
This is Rietveld 408576698