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

Unified Diff: cc/trees/tree_synchronizer_unittest.cc

Issue 2194833002: Overscroll and Elasticity for views::ScrollView Base URL: https://chromium.googlesource.com/chromium/src.git@20160728-MacViews-RouteThroughInputHandler
Patch Set: Restore functionality and fix bugs \o/ Created 4 years, 1 month 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/transform_node.cc ('k') | ui/compositor/BUILD.gn » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..cf56de38d10b324b93dc1119c73d17cfad3691f9 100644
--- a/cc/trees/tree_synchronizer_unittest.cc
+++ b/cc/trees/tree_synchronizer_unittest.cc
@@ -130,15 +130,16 @@ class TreeSynchronizerTest : public testing::Test {
TreeSynchronizerTest()
: host_(FakeLayerTreeHost::Create(&client_, &task_graph_runner_)) {}
- bool is_equal(ScrollTree::ScrollOffsetMap map,
- ScrollTree::ScrollOffsetMap other) {
+ bool is_equal(const ScrollTree::ScrollOffsetMap& map,
+ const ScrollTree::ScrollOffsetMap& other) {
if (map.size() != other.size())
return false;
- for (auto& map_entry : map) {
- if (other.find(map_entry.first) == other.end())
+ for (const auto& map_entry : map) {
+ auto other_found = other.find(map_entry.first);
+ if (other_found == other.end())
return false;
- SyncedScrollOffset& from_map = *map_entry.second.get();
- SyncedScrollOffset& from_other = *other[map_entry.first].get();
+ SyncedScrollOffset& from_map = *map_entry.second.synced_offset.get();
+ SyncedScrollOffset& from_other = *other_found->second.synced_offset.get();
if (from_map.PendingBase() != from_other.PendingBase() ||
from_map.ActiveBase() != from_other.ActiveBase() ||
from_map.Delta() != from_other.Delta() ||
@@ -566,18 +567,20 @@ TEST_F(TreeSynchronizerTest, SynchronizeScrollTreeScrollOffsetMap) {
// 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[transient_scroll_layer->id()] = new SyncedScrollOffset;
- scroll_offset_map[scroll_layer->id()]->PushFromMainThread(
- scroll_layer->scroll_offset());
- scroll_offset_map[scroll_layer->id()]->PushPendingToActive();
- scroll_offset_map[transient_scroll_layer->id()]->PushFromMainThread(
- transient_scroll_layer->scroll_offset());
- scroll_offset_map[transient_scroll_layer->id()]->PushPendingToActive();
- EXPECT_TRUE(
- is_equal(scroll_offset_map, host_impl->active_tree()
- ->property_trees()
- ->scroll_tree.scroll_offset_map()));
+ auto& scroll_offset = scroll_offset_map[scroll_layer->id()].synced_offset;
+ auto& transient_offset =
+ scroll_offset_map[transient_scroll_layer->id()].synced_offset;
+
+ scroll_offset = new SyncedScrollOffset;
+ transient_offset = new SyncedScrollOffset;
+ scroll_offset->PushFromMainThread(scroll_layer->scroll_offset());
+ scroll_offset->PushPendingToActive();
+ transient_offset->PushFromMainThread(transient_scroll_layer->scroll_offset());
+ transient_offset->PushPendingToActive();
+ EXPECT_TRUE(is_equal(scroll_offset_map,
+ host_impl->active_tree()
+ ->property_trees()
+ ->scroll_tree.scroll_offset_map_for_test()));
// Set ScrollOffset active delta: gfx::ScrollOffset(10, 10)
LayerImpl* scroll_layer_impl =
@@ -611,13 +614,14 @@ TEST_F(TreeSynchronizerTest, SynchronizeScrollTreeScrollOffsetMap) {
EXPECT_EQ(scroll_layer->id(),
host_impl->active_tree()->CurrentlyScrollingLayer()->id());
scroll_offset_map.erase(transient_scroll_layer->id());
- scroll_offset_map[scroll_layer->id()]->SetCurrent(gfx::ScrollOffset(20, 30));
- scroll_offset_map[scroll_layer->id()]->PullDeltaForMainThread();
- scroll_offset_map[scroll_layer->id()]->SetCurrent(gfx::ScrollOffset(40, 50));
- scroll_offset_map[scroll_layer->id()]->PushFromMainThread(
- gfx::ScrollOffset(100, 100));
- scroll_offset_map[scroll_layer->id()]->PushPendingToActive();
- EXPECT_TRUE(is_equal(scroll_offset_map, scroll_tree.scroll_offset_map()));
+ scroll_offset = scroll_offset_map[scroll_layer->id()].synced_offset;
+ scroll_offset->SetCurrent(gfx::ScrollOffset(20, 30));
+ scroll_offset->PullDeltaForMainThread();
+ scroll_offset->SetCurrent(gfx::ScrollOffset(40, 50));
+ scroll_offset->PushFromMainThread(gfx::ScrollOffset(100, 100));
+ scroll_offset->PushPendingToActive();
+ EXPECT_TRUE(
+ is_equal(scroll_offset_map, scroll_tree.scroll_offset_map_for_test()));
}
TEST_F(TreeSynchronizerTest, RefreshPropertyTreesCachedData) {
« no previous file with comments | « cc/trees/transform_node.cc ('k') | ui/compositor/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698