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

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

Issue 12927003: cc: Chromify FakeWebScrollbarThemeGeometry (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 9 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 unified diff | Download patch | Annotate | Revision Log
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 "cc/layers/scrollbar_layer.h" 5 #include "cc/layers/scrollbar_layer.h"
6 6
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/scrollbar_layer_impl.h" 9 #include "cc/layers/scrollbar_layer_impl.h"
10 #include "cc/quads/solid_color_draw_quad.h" 10 #include "cc/quads/solid_color_draw_quad.h"
(...skipping 21 matching lines...) Expand all
32 namespace cc { 32 namespace cc {
33 namespace { 33 namespace {
34 34
35 scoped_ptr<LayerImpl> layerImplForScrollAreaAndScrollbar( 35 scoped_ptr<LayerImpl> layerImplForScrollAreaAndScrollbar(
36 FakeLayerTreeHostImpl* host_impl, 36 FakeLayerTreeHostImpl* host_impl,
37 scoped_ptr<WebKit::WebScrollbar> scrollbar, 37 scoped_ptr<WebKit::WebScrollbar> scrollbar,
38 bool reverse_order) 38 bool reverse_order)
39 { 39 {
40 scoped_refptr<Layer> layerTreeRoot = Layer::Create(); 40 scoped_refptr<Layer> layerTreeRoot = Layer::Create();
41 scoped_refptr<Layer> child1 = Layer::Create(); 41 scoped_refptr<Layer> child1 = Layer::Create();
42 scoped_refptr<Layer> child2 = ScrollbarLayer::Create(scrollbar.Pass(), FakeS crollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScro llbarThemeGeometry::create(true), child1->id()); 42 scoped_refptr<Layer> child2 = ScrollbarLayer::Create(scrollbar.Pass(), FakeS crollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScro llbarThemeGeometry::Create(true), child1->id());
43 layerTreeRoot->AddChild(child1); 43 layerTreeRoot->AddChild(child1);
44 layerTreeRoot->InsertChild(child2, reverse_order ? 0 : 1); 44 layerTreeRoot->InsertChild(child2, reverse_order ? 0 : 1);
45 scoped_ptr<LayerImpl> layerImpl = TreeSynchronizer::SynchronizeTrees(layerTr eeRoot.get(), scoped_ptr<LayerImpl>(), host_impl->active_tree()); 45 scoped_ptr<LayerImpl> layerImpl = TreeSynchronizer::SynchronizeTrees(layerTr eeRoot.get(), scoped_ptr<LayerImpl>(), host_impl->active_tree());
46 TreeSynchronizer::PushProperties(layerTreeRoot.get(), layerImpl.get()); 46 TreeSynchronizer::PushProperties(layerTreeRoot.get(), layerImpl.get());
47 return layerImpl.Pass(); 47 return layerImpl.Pass();
48 } 48 }
49 49
50 TEST(ScrollbarLayerTest, resolveScrollLayerPointer) 50 TEST(ScrollbarLayerTest, resolveScrollLayerPointer)
51 { 51 {
52 FakeImplProxy proxy; 52 FakeImplProxy proxy;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 102 }
103 103
104 TEST(ScrollbarLayerTest, scrollOffsetSynchronization) 104 TEST(ScrollbarLayerTest, scrollOffsetSynchronization)
105 { 105 {
106 FakeImplProxy proxy; 106 FakeImplProxy proxy;
107 FakeLayerTreeHostImpl hostImpl(&proxy); 107 FakeLayerTreeHostImpl hostImpl(&proxy);
108 108
109 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create()); 109 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create());
110 scoped_refptr<Layer> layerTreeRoot = Layer::Create(); 110 scoped_refptr<Layer> layerTreeRoot = Layer::Create();
111 scoped_refptr<Layer> contentLayer = Layer::Create(); 111 scoped_refptr<Layer> contentLayer = Layer::Create();
112 scoped_refptr<Layer> scrollbarLayer = ScrollbarLayer::Create(scrollbar.Pass( ), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), Fak eWebScrollbarThemeGeometry::create(true), layerTreeRoot->id()); 112 scoped_refptr<Layer> scrollbarLayer = ScrollbarLayer::Create(scrollbar.Pass( ), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), Fak eWebScrollbarThemeGeometry::Create(true), layerTreeRoot->id());
113 layerTreeRoot->AddChild(contentLayer); 113 layerTreeRoot->AddChild(contentLayer);
114 layerTreeRoot->AddChild(scrollbarLayer); 114 layerTreeRoot->AddChild(scrollbarLayer);
115 115
116 layerTreeRoot->SetScrollOffset(gfx::Vector2d(10, 20)); 116 layerTreeRoot->SetScrollOffset(gfx::Vector2d(10, 20));
117 layerTreeRoot->SetMaxScrollOffset(gfx::Vector2d(30, 50)); 117 layerTreeRoot->SetMaxScrollOffset(gfx::Vector2d(30, 50));
118 layerTreeRoot->SetBounds(gfx::Size(100, 200)); 118 layerTreeRoot->SetBounds(gfx::Size(100, 200));
119 contentLayer->SetBounds(gfx::Size(100, 200)); 119 contentLayer->SetBounds(gfx::Size(100, 200));
120 120
121 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::SynchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.active_tree()); 121 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::SynchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.active_tree());
122 TreeSynchronizer::PushProperties(layerTreeRoot.get(), layerImplTreeRoot.get( )); 122 TreeSynchronizer::PushProperties(layerTreeRoot.get(), layerImplTreeRoot.get( ));
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 215
216 void setScrollbarBounds(gfx::Size bounds) { 216 void setScrollbarBounds(gfx::Size bounds) {
217 bounds_ = bounds; 217 bounds_ = bounds;
218 } 218 }
219 219
220 virtual void BeginTest() OVERRIDE 220 virtual void BeginTest() OVERRIDE
221 { 221 {
222 layer_tree_host()->InitializeRendererIfNeeded(); 222 layer_tree_host()->InitializeRendererIfNeeded();
223 223
224 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create()); 224 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create());
225 m_scrollbarLayer = ScrollbarLayer::Create(scrollbar.Pass(), FakeScrollba rThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScrollbarTh emeGeometry::create(true), 1); 225 m_scrollbarLayer = ScrollbarLayer::Create(scrollbar.Pass(), FakeScrollba rThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScrollbarTh emeGeometry::Create(true), 1);
226 m_scrollbarLayer->SetLayerTreeHost(layer_tree_host()); 226 m_scrollbarLayer->SetLayerTreeHost(layer_tree_host());
227 m_scrollbarLayer->SetBounds(bounds_); 227 m_scrollbarLayer->SetBounds(bounds_);
228 layer_tree_host()->root_layer()->AddChild(m_scrollbarLayer); 228 layer_tree_host()->root_layer()->AddChild(m_scrollbarLayer);
229 229
230 m_scrollLayer = Layer::Create(); 230 m_scrollLayer = Layer::Create();
231 m_scrollbarLayer->SetScrollLayerId(m_scrollLayer->id()); 231 m_scrollbarLayer->SetScrollLayerId(m_scrollLayer->id());
232 layer_tree_host()->root_layer()->AddChild(m_scrollLayer); 232 layer_tree_host()->root_layer()->AddChild(m_scrollLayer);
233 233
234 PostSetNeedsCommitToMainThread(); 234 PostSetNeedsCommitToMainThread();
235 } 235 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 { 282 {
283 } 283 }
284 284
285 void testResourceUpload(int expectedResources) 285 void testResourceUpload(int expectedResources)
286 { 286 {
287 m_layerTreeHost.reset(new MockLayerTreeHost(&m_fakeClient, m_layerTreeSe ttings)); 287 m_layerTreeHost.reset(new MockLayerTreeHost(&m_fakeClient, m_layerTreeSe ttings));
288 288
289 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create()); 289 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::Create());
290 scoped_refptr<Layer> layerTreeRoot = Layer::Create(); 290 scoped_refptr<Layer> layerTreeRoot = Layer::Create();
291 scoped_refptr<Layer> contentLayer = Layer::Create(); 291 scoped_refptr<Layer> contentLayer = Layer::Create();
292 scoped_refptr<Layer> scrollbarLayer = ScrollbarLayer::Create(scrollbar.P ass(), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScrollbarThemeGeometry::create(true), layerTreeRoot->id()); 292 scoped_refptr<Layer> scrollbarLayer = ScrollbarLayer::Create(scrollbar.P ass(), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScrollbarThemeGeometry::Create(true), layerTreeRoot->id());
293 layerTreeRoot->AddChild(contentLayer); 293 layerTreeRoot->AddChild(contentLayer);
294 layerTreeRoot->AddChild(scrollbarLayer); 294 layerTreeRoot->AddChild(scrollbarLayer);
295 295
296 m_layerTreeHost->InitializeRendererIfNeeded(); 296 m_layerTreeHost->InitializeRendererIfNeeded();
297 m_layerTreeHost->contents_texture_manager()->SetMaxMemoryLimitBytes(1024 * 1024); 297 m_layerTreeHost->contents_texture_manager()->SetMaxMemoryLimitBytes(1024 * 1024);
298 m_layerTreeHost->SetRootLayer(layerTreeRoot); 298 m_layerTreeHost->SetRootLayer(layerTreeRoot);
299 299
300 scrollbarLayer->SetIsDrawable(true); 300 scrollbarLayer->SetIsDrawable(true);
301 scrollbarLayer->SetBounds(gfx::Size(100, 100)); 301 scrollbarLayer->SetBounds(gfx::Size(100, 100));
302 layerTreeRoot->SetScrollOffset(gfx::Vector2d(10, 20)); 302 layerTreeRoot->SetScrollOffset(gfx::Vector2d(10, 20));
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 FakeLayerTreeHostImpl hostImpl(&proxy); 348 FakeLayerTreeHostImpl hostImpl(&proxy);
349 349
350 scoped_refptr<Layer> layerTreeRoot = Layer::Create(); 350 scoped_refptr<Layer> layerTreeRoot = Layer::Create();
351 layerTreeRoot->SetScrollable(true); 351 layerTreeRoot->SetScrollable(true);
352 352
353 scoped_refptr<Layer> contentLayer = Layer::Create(); 353 scoped_refptr<Layer> contentLayer = Layer::Create();
354 scoped_ptr<WebKit::WebScrollbar> scrollbar1(FakeWebScrollbar::Create()); 354 scoped_ptr<WebKit::WebScrollbar> scrollbar1(FakeWebScrollbar::Create());
355 scoped_refptr<Layer> scrollbarLayerHorizontal = 355 scoped_refptr<Layer> scrollbarLayerHorizontal =
356 ScrollbarLayer::Create(scrollbar1.Pass(), 356 ScrollbarLayer::Create(scrollbar1.Pass(),
357 FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>() , 357 FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>() ,
358 FakeWebScrollbarThemeGeometry::create(true), 358 FakeWebScrollbarThemeGeometry::Create(true),
359 Layer::PINCH_ZOOM_ROOT_SCROLL_LAYER_ID); 359 Layer::PINCH_ZOOM_ROOT_SCROLL_LAYER_ID);
360 scoped_ptr<WebKit::WebScrollbar> scrollbar2(FakeWebScrollbar::Create()); 360 scoped_ptr<WebKit::WebScrollbar> scrollbar2(FakeWebScrollbar::Create());
361 scoped_refptr<Layer> scrollbarLayerVertical = 361 scoped_refptr<Layer> scrollbarLayerVertical =
362 ScrollbarLayer::Create(scrollbar2.Pass(), 362 ScrollbarLayer::Create(scrollbar2.Pass(),
363 FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>() , 363 FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>() ,
364 FakeWebScrollbarThemeGeometry::create(true), 364 FakeWebScrollbarThemeGeometry::Create(true),
365 Layer::PINCH_ZOOM_ROOT_SCROLL_LAYER_ID); 365 Layer::PINCH_ZOOM_ROOT_SCROLL_LAYER_ID);
366 366
367 layerTreeRoot->AddChild(contentLayer); 367 layerTreeRoot->AddChild(contentLayer);
368 layerTreeRoot->AddChild(scrollbarLayerHorizontal); 368 layerTreeRoot->AddChild(scrollbarLayerHorizontal);
369 layerTreeRoot->AddChild(scrollbarLayerVertical); 369 layerTreeRoot->AddChild(scrollbarLayerVertical);
370 370
371 layerTreeRoot->SetScrollOffset(gfx::Vector2d(10, 20)); 371 layerTreeRoot->SetScrollOffset(gfx::Vector2d(10, 20));
372 layerTreeRoot->SetMaxScrollOffset(gfx::Vector2d(30, 50)); 372 layerTreeRoot->SetMaxScrollOffset(gfx::Vector2d(30, 50));
373 layerTreeRoot->SetBounds(gfx::Size(100, 200)); 373 layerTreeRoot->SetBounds(gfx::Size(100, 200));
374 contentLayer->SetBounds(gfx::Size(100, 200)); 374 contentLayer->SetBounds(gfx::Size(100, 200));
(...skipping 26 matching lines...) Expand all
401 EXPECT_EQ(10, pinchZoomHorizontal->CurrentPos()); 401 EXPECT_EQ(10, pinchZoomHorizontal->CurrentPos());
402 EXPECT_EQ(100, pinchZoomHorizontal->TotalSize()); 402 EXPECT_EQ(100, pinchZoomHorizontal->TotalSize());
403 EXPECT_EQ(30, pinchZoomHorizontal->Maximum()); 403 EXPECT_EQ(30, pinchZoomHorizontal->Maximum());
404 EXPECT_EQ(20, pinchZoomVertical->CurrentPos()); 404 EXPECT_EQ(20, pinchZoomVertical->CurrentPos());
405 EXPECT_EQ(200, pinchZoomVertical->TotalSize()); 405 EXPECT_EQ(200, pinchZoomVertical->TotalSize());
406 EXPECT_EQ(50, pinchZoomVertical->Maximum()); 406 EXPECT_EQ(50, pinchZoomVertical->Maximum());
407 } 407 }
408 408
409 } // namespace 409 } // namespace
410 } // namespace cc 410 } // namespace cc
OLDNEW
« no previous file with comments | « cc/animation/scrollbar_animation_controller_linear_fade_unittest.cc ('k') | cc/test/fake_scrollbar_layer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698