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

Side by Side Diff: cc/layers/scrollbar_layer_unittest.cc

Issue 1455023002: cc: Replace Pass() with std::move() in some subdirs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pass-cc
Patch Set: pass-cc2: . Created 5 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/layers/render_surface_unittest.cc ('k') | cc/layers/surface_layer.cc » ('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 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 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 "base/containers/hash_tables.h" 5 #include "base/containers/hash_tables.h"
6 #include "base/thread_task_runner_handle.h" 6 #include "base/thread_task_runner_handle.h"
7 #include "cc/animation/scrollbar_animation_controller.h" 7 #include "cc/animation/scrollbar_animation_controller.h"
8 #include "cc/layers/append_quads_data.h" 8 #include "cc/layers/append_quads_data.h"
9 #include "cc/layers/painted_scrollbar_layer.h" 9 #include "cc/layers/painted_scrollbar_layer.h"
10 #include "cc/layers/painted_scrollbar_layer_impl.h" 10 #include "cc/layers/painted_scrollbar_layer_impl.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 int track_start) { 43 int track_start) {
44 scoped_refptr<Layer> layer_tree_root = Layer::Create(settings); 44 scoped_refptr<Layer> layer_tree_root = Layer::Create(settings);
45 scoped_refptr<Layer> child1 = Layer::Create(settings); 45 scoped_refptr<Layer> child1 = Layer::Create(settings);
46 scoped_refptr<Layer> child2; 46 scoped_refptr<Layer> child2;
47 if (use_solid_color_scrollbar) { 47 if (use_solid_color_scrollbar) {
48 const bool kIsLeftSideVerticalScrollbar = false; 48 const bool kIsLeftSideVerticalScrollbar = false;
49 child2 = SolidColorScrollbarLayer::Create( 49 child2 = SolidColorScrollbarLayer::Create(
50 settings, scrollbar->Orientation(), thumb_thickness, track_start, 50 settings, scrollbar->Orientation(), thumb_thickness, track_start,
51 kIsLeftSideVerticalScrollbar, child1->id()); 51 kIsLeftSideVerticalScrollbar, child1->id());
52 } else { 52 } else {
53 child2 = 53 child2 = PaintedScrollbarLayer::Create(settings, std::move(scrollbar),
54 PaintedScrollbarLayer::Create(settings, scrollbar.Pass(), child1->id()); 54 child1->id());
55 } 55 }
56 layer_tree_root->AddChild(child1); 56 layer_tree_root->AddChild(child1);
57 layer_tree_root->InsertChild(child2, reverse_order ? 0 : 1); 57 layer_tree_root->InsertChild(child2, reverse_order ? 0 : 1);
58 host->SetRootLayer(layer_tree_root); 58 host->SetRootLayer(layer_tree_root);
59 return host->CommitAndCreateLayerImplTree(); 59 return host->CommitAndCreateLayerImplTree();
60 } 60 }
61 61
62 class FakeResourceTrackingLayerTreeHost : public FakeLayerTreeHost { 62 class FakeResourceTrackingLayerTreeHost : public FakeLayerTreeHost {
63 public: 63 public:
64 FakeResourceTrackingLayerTreeHost(FakeLayerTreeHostClient* client, 64 FakeResourceTrackingLayerTreeHost(FakeLayerTreeHostClient* client,
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 TestTaskGraphRunner task_graph_runner_; 142 TestTaskGraphRunner task_graph_runner_;
143 LayerTreeSettings layer_tree_settings_; 143 LayerTreeSettings layer_tree_settings_;
144 LayerSettings layer_settings_; 144 LayerSettings layer_settings_;
145 scoped_ptr<FakeResourceTrackingLayerTreeHost> layer_tree_host_; 145 scoped_ptr<FakeResourceTrackingLayerTreeHost> layer_tree_host_;
146 }; 146 };
147 147
148 TEST_F(ScrollbarLayerTest, ShouldScrollNonOverlayOnMainThread) { 148 TEST_F(ScrollbarLayerTest, ShouldScrollNonOverlayOnMainThread) {
149 // Create and attach a non-overlay scrollbar. 149 // Create and attach a non-overlay scrollbar.
150 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); 150 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar);
151 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( 151 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar(
152 layer_settings(), layer_tree_host_.get(), scrollbar.Pass(), false, false, 152 layer_settings(), layer_tree_host_.get(), std::move(scrollbar), false,
153 0, 0); 153 false, 0, 0);
154 PaintedScrollbarLayerImpl* scrollbar_layer_impl = 154 PaintedScrollbarLayerImpl* scrollbar_layer_impl =
155 static_cast<PaintedScrollbarLayerImpl*>( 155 static_cast<PaintedScrollbarLayerImpl*>(
156 layer_impl_tree_root->children()[1].get()); 156 layer_impl_tree_root->children()[1].get());
157 157
158 // When the scrollbar is not an overlay scrollbar, the scroll should be 158 // When the scrollbar is not an overlay scrollbar, the scroll should be
159 // responded to on the main thread as the compositor does not yet implement 159 // responded to on the main thread as the compositor does not yet implement
160 // scrollbar scrolling. 160 // scrollbar scrolling.
161 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD, 161 EXPECT_EQ(InputHandler::SCROLL_ON_MAIN_THREAD,
162 scrollbar_layer_impl->TryScroll( 162 scrollbar_layer_impl->TryScroll(
163 gfx::PointF(), InputHandler::GESTURE, SCROLL_BLOCKS_ON_NONE)); 163 gfx::PointF(), InputHandler::GESTURE, SCROLL_BLOCKS_ON_NONE));
164 164
165 // Create and attach an overlay scrollbar. 165 // Create and attach an overlay scrollbar.
166 scrollbar.reset(new FakeScrollbar(false, false, true)); 166 scrollbar.reset(new FakeScrollbar(false, false, true));
167 167
168 layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( 168 layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar(
169 layer_settings(), layer_tree_host_.get(), scrollbar.Pass(), false, false, 169 layer_settings(), layer_tree_host_.get(), std::move(scrollbar), false,
170 0, 0); 170 false, 0, 0);
171 scrollbar_layer_impl = static_cast<PaintedScrollbarLayerImpl*>( 171 scrollbar_layer_impl = static_cast<PaintedScrollbarLayerImpl*>(
172 layer_impl_tree_root->children()[1].get()); 172 layer_impl_tree_root->children()[1].get());
173 173
174 // The user shouldn't be able to drag an overlay scrollbar and the scroll 174 // The user shouldn't be able to drag an overlay scrollbar and the scroll
175 // may be handled in the compositor. 175 // may be handled in the compositor.
176 EXPECT_EQ(InputHandler::SCROLL_IGNORED, 176 EXPECT_EQ(InputHandler::SCROLL_IGNORED,
177 scrollbar_layer_impl->TryScroll( 177 scrollbar_layer_impl->TryScroll(
178 gfx::PointF(), InputHandler::GESTURE, SCROLL_BLOCKS_ON_NONE)); 178 gfx::PointF(), InputHandler::GESTURE, SCROLL_BLOCKS_ON_NONE));
179 } 179 }
180 180
181 TEST_F(ScrollbarLayerTest, ScrollOffsetSynchronization) { 181 TEST_F(ScrollbarLayerTest, ScrollOffsetSynchronization) {
182 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); 182 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar);
183 scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings()); 183 scoped_refptr<Layer> layer_tree_root = Layer::Create(layer_settings());
184 scoped_refptr<Layer> scroll_layer = Layer::Create(layer_settings()); 184 scoped_refptr<Layer> scroll_layer = Layer::Create(layer_settings());
185 scoped_refptr<Layer> content_layer = Layer::Create(layer_settings()); 185 scoped_refptr<Layer> content_layer = Layer::Create(layer_settings());
186 scoped_refptr<Layer> scrollbar_layer = PaintedScrollbarLayer::Create( 186 scoped_refptr<Layer> scrollbar_layer = PaintedScrollbarLayer::Create(
187 layer_settings(), scrollbar.Pass(), layer_tree_root->id()); 187 layer_settings(), std::move(scrollbar), layer_tree_root->id());
188 188
189 // Choose bounds to give max_scroll_offset = (30, 50). 189 // Choose bounds to give max_scroll_offset = (30, 50).
190 layer_tree_root->SetBounds(gfx::Size(70, 150)); 190 layer_tree_root->SetBounds(gfx::Size(70, 150));
191 scroll_layer->SetScrollClipLayerId(layer_tree_root->id()); 191 scroll_layer->SetScrollClipLayerId(layer_tree_root->id());
192 scroll_layer->SetScrollOffset(gfx::ScrollOffset(10, 20)); 192 scroll_layer->SetScrollOffset(gfx::ScrollOffset(10, 20));
193 scroll_layer->SetBounds(gfx::Size(100, 200)); 193 scroll_layer->SetBounds(gfx::Size(100, 200));
194 content_layer->SetBounds(gfx::Size(100, 200)); 194 content_layer->SetBounds(gfx::Size(100, 200));
195 195
196 layer_tree_host_->SetRootLayer(layer_tree_root); 196 layer_tree_host_->SetRootLayer(layer_tree_root);
197 layer_tree_root->AddChild(scroll_layer); 197 layer_tree_root->AddChild(scroll_layer);
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 scrollbar_layer_impl->ComputeThumbQuadRect().ToString()); 364 scrollbar_layer_impl->ComputeThumbQuadRect().ToString());
365 } 365 }
366 366
367 TEST_F(ScrollbarLayerTest, SolidColorDrawQuads) { 367 TEST_F(ScrollbarLayerTest, SolidColorDrawQuads) {
368 const int kThumbThickness = 3; 368 const int kThumbThickness = 3;
369 const int kTrackStart = 1; 369 const int kTrackStart = 1;
370 const int kTrackLength = 100; 370 const int kTrackLength = 100;
371 371
372 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true)); 372 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar(false, true, true));
373 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar( 373 LayerImpl* layer_impl_tree_root = LayerImplForScrollAreaAndScrollbar(
374 layer_settings(), layer_tree_host_.get(), scrollbar.Pass(), false, true, 374 layer_settings(), layer_tree_host_.get(), std::move(scrollbar), false,
375 kThumbThickness, kTrackStart); 375 true, kThumbThickness, kTrackStart);
376 ScrollbarLayerImplBase* scrollbar_layer_impl = 376 ScrollbarLayerImplBase* scrollbar_layer_impl =
377 static_cast<SolidColorScrollbarLayerImpl*>( 377 static_cast<SolidColorScrollbarLayerImpl*>(
378 layer_impl_tree_root->children()[1].get()); 378 layer_impl_tree_root->children()[1].get());
379 scrollbar_layer_impl->SetBounds(gfx::Size(kTrackLength, kThumbThickness)); 379 scrollbar_layer_impl->SetBounds(gfx::Size(kTrackLength, kThumbThickness));
380 scrollbar_layer_impl->SetCurrentPos(10.f); 380 scrollbar_layer_impl->SetCurrentPos(10.f);
381 scrollbar_layer_impl->SetClipLayerLength(200 / 3.f); 381 scrollbar_layer_impl->SetClipLayerLength(200 / 3.f);
382 scrollbar_layer_impl->SetScrollLayerLength(100 + 200 / 3.f); 382 scrollbar_layer_impl->SetScrollLayerLength(100 + 200 / 3.f);
383 383
384 // Thickness should be overridden to 3. 384 // Thickness should be overridden to 3.
385 { 385 {
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 ScrollbarLayerTestMaxTextureSize() {} 586 ScrollbarLayerTestMaxTextureSize() {}
587 587
588 void SetScrollbarBounds(const gfx::Size& bounds) { bounds_ = bounds; } 588 void SetScrollbarBounds(const gfx::Size& bounds) { bounds_ = bounds; }
589 589
590 void BeginTest() override { 590 void BeginTest() override {
591 scroll_layer_ = Layer::Create(layer_settings()); 591 scroll_layer_ = Layer::Create(layer_settings());
592 layer_tree_host()->root_layer()->AddChild(scroll_layer_); 592 layer_tree_host()->root_layer()->AddChild(scroll_layer_);
593 593
594 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar); 594 scoped_ptr<Scrollbar> scrollbar(new FakeScrollbar);
595 scrollbar_layer_ = PaintedScrollbarLayer::Create( 595 scrollbar_layer_ = PaintedScrollbarLayer::Create(
596 layer_settings(), scrollbar.Pass(), scroll_layer_->id()); 596 layer_settings(), std::move(scrollbar), scroll_layer_->id());
597 scrollbar_layer_->SetScrollLayer(scroll_layer_->id()); 597 scrollbar_layer_->SetScrollLayer(scroll_layer_->id());
598 scrollbar_layer_->SetLayerTreeHost(layer_tree_host()); 598 scrollbar_layer_->SetLayerTreeHost(layer_tree_host());
599 scrollbar_layer_->SetBounds(bounds_); 599 scrollbar_layer_->SetBounds(bounds_);
600 scrollbar_layer_->SetIsDrawable(true); 600 scrollbar_layer_->SetIsDrawable(true);
601 layer_tree_host()->root_layer()->AddChild(scrollbar_layer_); 601 layer_tree_host()->root_layer()->AddChild(scrollbar_layer_);
602 602
603 PostSetNeedsCommitToMainThread(); 603 PostSetNeedsCommitToMainThread();
604 } 604 }
605 605
606 void DidCommitAndDrawFrame() override { 606 void DidCommitAndDrawFrame() override {
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
657 scoped_refptr<Layer> scrollbar_layer; 657 scoped_refptr<Layer> scrollbar_layer;
658 if (use_solid_color_scrollbar) { 658 if (use_solid_color_scrollbar) {
659 const int kThumbThickness = 3; 659 const int kThumbThickness = 3;
660 const int kTrackStart = 0; 660 const int kTrackStart = 0;
661 const bool kIsLeftSideVerticalScrollbar = false; 661 const bool kIsLeftSideVerticalScrollbar = false;
662 scrollbar_layer = SolidColorScrollbarLayer::Create( 662 scrollbar_layer = SolidColorScrollbarLayer::Create(
663 layer_settings(), scrollbar->Orientation(), kThumbThickness, 663 layer_settings(), scrollbar->Orientation(), kThumbThickness,
664 kTrackStart, kIsLeftSideVerticalScrollbar, layer_tree_root->id()); 664 kTrackStart, kIsLeftSideVerticalScrollbar, layer_tree_root->id());
665 } else { 665 } else {
666 scrollbar_layer = PaintedScrollbarLayer::Create( 666 scrollbar_layer = PaintedScrollbarLayer::Create(
667 layer_settings(), scrollbar.Pass(), layer_tree_root->id()); 667 layer_settings(), std::move(scrollbar), layer_tree_root->id());
668 } 668 }
669 layer_tree_root->AddChild(content_layer); 669 layer_tree_root->AddChild(content_layer);
670 layer_tree_root->AddChild(scrollbar_layer); 670 layer_tree_root->AddChild(scrollbar_layer);
671 671
672 layer_tree_host_->SetRootLayer(layer_tree_root); 672 layer_tree_host_->SetRootLayer(layer_tree_root);
673 673
674 scrollbar_layer->SetIsDrawable(true); 674 scrollbar_layer->SetIsDrawable(true);
675 scrollbar_layer->SetBounds(gfx::Size(100, 100)); 675 scrollbar_layer->SetBounds(gfx::Size(100, 100));
676 layer_tree_root->SetScrollOffset(gfx::ScrollOffset(10, 20)); 676 layer_tree_root->SetScrollOffset(gfx::ScrollOffset(10, 20));
677 layer_tree_root->SetBounds(gfx::Size(100, 200)); 677 layer_tree_root->SetBounds(gfx::Size(100, 200));
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f); 999 TestScale(gfx::Rect(1240, 0, 15, 1333), 2.7754839f);
1000 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f); 1000 TestScale(gfx::Rect(1240, 0, 15, 677), 2.46677136f);
1001 1001
1002 // Horizontal Scrollbars. 1002 // Horizontal Scrollbars.
1003 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f); 1003 TestScale(gfx::Rect(0, 1240, 1333, 15), 2.7754839f);
1004 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f); 1004 TestScale(gfx::Rect(0, 1240, 677, 15), 2.46677136f);
1005 } 1005 }
1006 1006
1007 } // namespace 1007 } // namespace
1008 } // namespace cc 1008 } // namespace cc
OLDNEW
« no previous file with comments | « cc/layers/render_surface_unittest.cc ('k') | cc/layers/surface_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698