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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « cc/trees/transform_node.cc ('k') | ui/compositor/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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 "cc/trees/tree_synchronizer.h" 5 #include "cc/trees/tree_synchronizer.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 ASSERT_TRUE(clip_children->find(layer) != clip_children->end()); 123 ASSERT_TRUE(clip_children->find(layer) != clip_children->end());
124 } 124 }
125 } 125 }
126 } 126 }
127 127
128 class TreeSynchronizerTest : public testing::Test { 128 class TreeSynchronizerTest : public testing::Test {
129 protected: 129 protected:
130 TreeSynchronizerTest() 130 TreeSynchronizerTest()
131 : host_(FakeLayerTreeHost::Create(&client_, &task_graph_runner_)) {} 131 : host_(FakeLayerTreeHost::Create(&client_, &task_graph_runner_)) {}
132 132
133 bool is_equal(ScrollTree::ScrollOffsetMap map, 133 bool is_equal(const ScrollTree::ScrollOffsetMap& map,
134 ScrollTree::ScrollOffsetMap other) { 134 const ScrollTree::ScrollOffsetMap& other) {
135 if (map.size() != other.size()) 135 if (map.size() != other.size())
136 return false; 136 return false;
137 for (auto& map_entry : map) { 137 for (const auto& map_entry : map) {
138 if (other.find(map_entry.first) == other.end()) 138 auto other_found = other.find(map_entry.first);
139 if (other_found == other.end())
139 return false; 140 return false;
140 SyncedScrollOffset& from_map = *map_entry.second.get(); 141 SyncedScrollOffset& from_map = *map_entry.second.synced_offset.get();
141 SyncedScrollOffset& from_other = *other[map_entry.first].get(); 142 SyncedScrollOffset& from_other = *other_found->second.synced_offset.get();
142 if (from_map.PendingBase() != from_other.PendingBase() || 143 if (from_map.PendingBase() != from_other.PendingBase() ||
143 from_map.ActiveBase() != from_other.ActiveBase() || 144 from_map.ActiveBase() != from_other.ActiveBase() ||
144 from_map.Delta() != from_other.Delta() || 145 from_map.Delta() != from_other.Delta() ||
145 from_map.PendingDelta().get() != from_other.PendingDelta().get()) 146 from_map.PendingDelta().get() != from_other.PendingDelta().get())
146 return false; 147 return false;
147 } 148 }
148 return true; 149 return true;
149 } 150 }
150 151
151 FakeLayerTreeHostClient client_; 152 FakeLayerTreeHostClient client_;
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after
559 host_impl->ActivateSyncTree(); 560 host_impl->ActivateSyncTree();
560 561
561 ExpectTreesAreIdentical(layer_tree_root.get(), 562 ExpectTreesAreIdentical(layer_tree_root.get(),
562 host_impl->active_tree()->root_layer_for_testing(), 563 host_impl->active_tree()->root_layer_for_testing(),
563 host_impl->active_tree()); 564 host_impl->active_tree());
564 565
565 // After the initial commit, scroll_offset_map in scroll_tree is expected to 566 // After the initial commit, scroll_offset_map in scroll_tree is expected to
566 // have one entry for scroll_layer and one entry for transient_scroll_layer, 567 // have one entry for scroll_layer and one entry for transient_scroll_layer,
567 // the pending base and active base must be the same at this stage. 568 // the pending base and active base must be the same at this stage.
568 ScrollTree::ScrollOffsetMap scroll_offset_map; 569 ScrollTree::ScrollOffsetMap scroll_offset_map;
569 scroll_offset_map[scroll_layer->id()] = new SyncedScrollOffset; 570 auto& scroll_offset = scroll_offset_map[scroll_layer->id()].synced_offset;
570 scroll_offset_map[transient_scroll_layer->id()] = new SyncedScrollOffset; 571 auto& transient_offset =
571 scroll_offset_map[scroll_layer->id()]->PushFromMainThread( 572 scroll_offset_map[transient_scroll_layer->id()].synced_offset;
572 scroll_layer->scroll_offset()); 573
573 scroll_offset_map[scroll_layer->id()]->PushPendingToActive(); 574 scroll_offset = new SyncedScrollOffset;
574 scroll_offset_map[transient_scroll_layer->id()]->PushFromMainThread( 575 transient_offset = new SyncedScrollOffset;
575 transient_scroll_layer->scroll_offset()); 576 scroll_offset->PushFromMainThread(scroll_layer->scroll_offset());
576 scroll_offset_map[transient_scroll_layer->id()]->PushPendingToActive(); 577 scroll_offset->PushPendingToActive();
577 EXPECT_TRUE( 578 transient_offset->PushFromMainThread(transient_scroll_layer->scroll_offset());
578 is_equal(scroll_offset_map, host_impl->active_tree() 579 transient_offset->PushPendingToActive();
579 ->property_trees() 580 EXPECT_TRUE(is_equal(scroll_offset_map,
580 ->scroll_tree.scroll_offset_map())); 581 host_impl->active_tree()
582 ->property_trees()
583 ->scroll_tree.scroll_offset_map_for_test()));
581 584
582 // Set ScrollOffset active delta: gfx::ScrollOffset(10, 10) 585 // Set ScrollOffset active delta: gfx::ScrollOffset(10, 10)
583 LayerImpl* scroll_layer_impl = 586 LayerImpl* scroll_layer_impl =
584 host_impl->active_tree()->LayerById(scroll_layer->id()); 587 host_impl->active_tree()->LayerById(scroll_layer->id());
585 ScrollTree& scroll_tree = 588 ScrollTree& scroll_tree =
586 host_impl->active_tree()->property_trees()->scroll_tree; 589 host_impl->active_tree()->property_trees()->scroll_tree;
587 scroll_tree.SetScrollOffset(scroll_layer_impl->id(), 590 scroll_tree.SetScrollOffset(scroll_layer_impl->id(),
588 gfx::ScrollOffset(20, 30)); 591 gfx::ScrollOffset(20, 30));
589 592
590 // Pull ScrollOffset delta for main thread, and change offset on main thread 593 // Pull ScrollOffset delta for main thread, and change offset on main thread
(...skipping 13 matching lines...) Expand all
604 transient_scroll_layer->SetScrollClipLayerId(Layer::INVALID_ID); 607 transient_scroll_layer->SetScrollClipLayerId(Layer::INVALID_ID);
605 host_->BuildPropertyTreesForTesting(); 608 host_->BuildPropertyTreesForTesting();
606 609
607 host_impl->CreatePendingTree(); 610 host_impl->CreatePendingTree();
608 host_->CommitAndCreatePendingTree(); 611 host_->CommitAndCreatePendingTree();
609 host_impl->ActivateSyncTree(); 612 host_impl->ActivateSyncTree();
610 613
611 EXPECT_EQ(scroll_layer->id(), 614 EXPECT_EQ(scroll_layer->id(),
612 host_impl->active_tree()->CurrentlyScrollingLayer()->id()); 615 host_impl->active_tree()->CurrentlyScrollingLayer()->id());
613 scroll_offset_map.erase(transient_scroll_layer->id()); 616 scroll_offset_map.erase(transient_scroll_layer->id());
614 scroll_offset_map[scroll_layer->id()]->SetCurrent(gfx::ScrollOffset(20, 30)); 617 scroll_offset = scroll_offset_map[scroll_layer->id()].synced_offset;
615 scroll_offset_map[scroll_layer->id()]->PullDeltaForMainThread(); 618 scroll_offset->SetCurrent(gfx::ScrollOffset(20, 30));
616 scroll_offset_map[scroll_layer->id()]->SetCurrent(gfx::ScrollOffset(40, 50)); 619 scroll_offset->PullDeltaForMainThread();
617 scroll_offset_map[scroll_layer->id()]->PushFromMainThread( 620 scroll_offset->SetCurrent(gfx::ScrollOffset(40, 50));
618 gfx::ScrollOffset(100, 100)); 621 scroll_offset->PushFromMainThread(gfx::ScrollOffset(100, 100));
619 scroll_offset_map[scroll_layer->id()]->PushPendingToActive(); 622 scroll_offset->PushPendingToActive();
620 EXPECT_TRUE(is_equal(scroll_offset_map, scroll_tree.scroll_offset_map())); 623 EXPECT_TRUE(
624 is_equal(scroll_offset_map, scroll_tree.scroll_offset_map_for_test()));
621 } 625 }
622 626
623 TEST_F(TreeSynchronizerTest, RefreshPropertyTreesCachedData) { 627 TEST_F(TreeSynchronizerTest, RefreshPropertyTreesCachedData) {
624 host_->InitializeSingleThreaded(&single_thread_client_, 628 host_->InitializeSingleThreaded(&single_thread_client_,
625 base::ThreadTaskRunnerHandle::Get()); 629 base::ThreadTaskRunnerHandle::Get());
626 LayerTreeSettings settings; 630 LayerTreeSettings settings;
627 FakeLayerTreeHostImplClient client; 631 FakeLayerTreeHostImplClient client;
628 FakeImplTaskRunnerProvider task_runner_provider; 632 FakeImplTaskRunnerProvider task_runner_provider;
629 FakeRenderingStatsInstrumentation stats_instrumentation; 633 FakeRenderingStatsInstrumentation stats_instrumentation;
630 TestSharedBitmapManager shared_bitmap_manager; 634 TestSharedBitmapManager shared_bitmap_manager;
(...skipping 30 matching lines...) Expand all
661 host_->CommitAndCreatePendingTree(); 665 host_->CommitAndCreatePendingTree();
662 host_impl->ActivateSyncTree(); 666 host_impl->ActivateSyncTree();
663 EXPECT_EQ( 667 EXPECT_EQ(
664 CombinedAnimationScale(0.f, 0.f), 668 CombinedAnimationScale(0.f, 0.f),
665 host_impl->active_tree()->property_trees()->GetAnimationScales( 669 host_impl->active_tree()->property_trees()->GetAnimationScales(
666 transform_layer->transform_tree_index(), host_impl->active_tree())); 670 transform_layer->transform_tree_index(), host_impl->active_tree()));
667 } 671 }
668 672
669 } // namespace 673 } // namespace
670 } // namespace cc 674 } // namespace cc
OLDNEW
« 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