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

Side by Side Diff: cc/scrollbar_layer_unittest.cc

Issue 11472021: cc: Pass LayerTreeHostImpl to LayerImpl constructor (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years 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
« no previous file with comments | « cc/scrollbar_layer_impl.cc ('k') | cc/solid_color_layer.h » ('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 "cc/scrollbar_layer.h" 5 #include "cc/scrollbar_layer.h"
6 6
7 #include "cc/scrollbar_animation_controller.h" 7 #include "cc/scrollbar_animation_controller.h"
8 #include "cc/scrollbar_layer_impl.h" 8 #include "cc/scrollbar_layer_impl.h"
9 #include "cc/single_thread_proxy.h" 9 #include "cc/single_thread_proxy.h"
10 #include "cc/test/fake_impl_proxy.h"
11 #include "cc/test/fake_layer_tree_host_impl.h"
10 #include "cc/test/fake_web_scrollbar_theme_geometry.h" 12 #include "cc/test/fake_web_scrollbar_theme_geometry.h"
11 #include "cc/test/layer_tree_test_common.h" 13 #include "cc/test/layer_tree_test_common.h"
12 #include "cc/tree_synchronizer.h" 14 #include "cc/tree_synchronizer.h"
13 #include "testing/gtest/include/gtest/gtest.h" 15 #include "testing/gtest/include/gtest/gtest.h"
14 #include <public/WebScrollbar.h> 16 #include <public/WebScrollbar.h>
15 #include <public/WebScrollbarThemeGeometry.h> 17 #include <public/WebScrollbarThemeGeometry.h>
16 #include <public/WebScrollbarThemePainter.h> 18 #include <public/WebScrollbarThemePainter.h>
17 19
18 namespace cc { 20 namespace cc {
19 namespace { 21 namespace {
(...skipping 16 matching lines...) Expand all
36 virtual ScrollbarControlSize controlSize() const OVERRIDE { return WebScroll bar::RegularScrollbar; } 38 virtual ScrollbarControlSize controlSize() const OVERRIDE { return WebScroll bar::RegularScrollbar; }
37 virtual ScrollbarPart pressedPart() const OVERRIDE { return WebScrollbar::No Part; } 39 virtual ScrollbarPart pressedPart() const OVERRIDE { return WebScrollbar::No Part; }
38 virtual ScrollbarPart hoveredPart() const OVERRIDE { return WebScrollbar::No Part; } 40 virtual ScrollbarPart hoveredPart() const OVERRIDE { return WebScrollbar::No Part; }
39 virtual ScrollbarOverlayStyle scrollbarOverlayStyle() const OVERRIDE { retur n WebScrollbar::ScrollbarOverlayStyleDefault; } 41 virtual ScrollbarOverlayStyle scrollbarOverlayStyle() const OVERRIDE { retur n WebScrollbar::ScrollbarOverlayStyleDefault; }
40 virtual bool isCustomScrollbar() const OVERRIDE { return false; } 42 virtual bool isCustomScrollbar() const OVERRIDE { return false; }
41 virtual Orientation orientation() const OVERRIDE { return WebScrollbar::Hori zontal; } 43 virtual Orientation orientation() const OVERRIDE { return WebScrollbar::Hori zontal; }
42 }; 44 };
43 45
44 TEST(ScrollbarLayerTest, resolveScrollLayerPointer) 46 TEST(ScrollbarLayerTest, resolveScrollLayerPointer)
45 { 47 {
48 FakeImplProxy proxy;
49 FakeLayerTreeHostImpl hostImpl(&proxy);
46 WebKit::WebScrollbarThemePainter painter; 50 WebKit::WebScrollbarThemePainter painter;
47 51
48 { 52 {
49 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create()); 53 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create());
50 scoped_refptr<Layer> layerTreeRoot = Layer::create(); 54 scoped_refptr<Layer> layerTreeRoot = Layer::create();
51 scoped_refptr<Layer> child1 = Layer::create(); 55 scoped_refptr<Layer> child1 = Layer::create();
52 scoped_refptr<Layer> child2 = ScrollbarLayer::create(scrollbar.Pass(), p ainter, WebKit::FakeWebScrollbarThemeGeometry::create(), child1->id()); 56 scoped_refptr<Layer> child2 = ScrollbarLayer::create(scrollbar.Pass(), p ainter, WebKit::FakeWebScrollbarThemeGeometry::create(), child1->id());
53 layerTreeRoot->addChild(child1); 57 layerTreeRoot->addChild(child1);
54 layerTreeRoot->addChild(child2); 58 layerTreeRoot->addChild(child2);
55 59
56 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeT rees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), 0); 60 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeT rees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), &hostImpl);
57 61
58 LayerImpl* ccChild1 = layerImplTreeRoot->children()[0]; 62 LayerImpl* ccChild1 = layerImplTreeRoot->children()[0];
59 ScrollbarLayerImpl* ccChild2 = static_cast<ScrollbarLayerImpl*>(layerImp lTreeRoot->children()[1]); 63 ScrollbarLayerImpl* ccChild2 = static_cast<ScrollbarLayerImpl*>(layerImp lTreeRoot->children()[1]);
60 64
61 EXPECT_TRUE(ccChild1->scrollbarAnimationController()); 65 EXPECT_TRUE(ccChild1->scrollbarAnimationController());
62 EXPECT_EQ(ccChild1->horizontalScrollbarLayer(), ccChild2); 66 EXPECT_EQ(ccChild1->horizontalScrollbarLayer(), ccChild2);
63 } 67 }
64 68
65 { // another traverse order 69 { // another traverse order
66 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create()); 70 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create());
67 scoped_refptr<Layer> layerTreeRoot = Layer::create(); 71 scoped_refptr<Layer> layerTreeRoot = Layer::create();
68 scoped_refptr<Layer> child2 = Layer::create(); 72 scoped_refptr<Layer> child2 = Layer::create();
69 scoped_refptr<Layer> child1 = ScrollbarLayer::create(scrollbar.Pass(), p ainter, WebKit::FakeWebScrollbarThemeGeometry::create(), child2->id()); 73 scoped_refptr<Layer> child1 = ScrollbarLayer::create(scrollbar.Pass(), p ainter, WebKit::FakeWebScrollbarThemeGeometry::create(), child2->id());
70 layerTreeRoot->addChild(child1); 74 layerTreeRoot->addChild(child1);
71 layerTreeRoot->addChild(child2); 75 layerTreeRoot->addChild(child2);
72 76
73 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeT rees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), 0); 77 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeT rees(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), &hostImpl);
74 78
75 ScrollbarLayerImpl* ccChild1 = static_cast<ScrollbarLayerImpl*>(layerImp lTreeRoot->children()[0]); 79 ScrollbarLayerImpl* ccChild1 = static_cast<ScrollbarLayerImpl*>(layerImp lTreeRoot->children()[0]);
76 LayerImpl* ccChild2 = layerImplTreeRoot->children()[1]; 80 LayerImpl* ccChild2 = layerImplTreeRoot->children()[1];
77 81
78 EXPECT_TRUE(ccChild2->scrollbarAnimationController()); 82 EXPECT_TRUE(ccChild2->scrollbarAnimationController());
79 EXPECT_EQ(ccChild2->horizontalScrollbarLayer(), ccChild1); 83 EXPECT_EQ(ccChild2->horizontalScrollbarLayer(), ccChild1);
80 } 84 }
81 } 85 }
82 86
83 TEST(ScrollbarLayerTest, scrollOffsetSynchronization) 87 TEST(ScrollbarLayerTest, scrollOffsetSynchronization)
84 { 88 {
89 FakeImplProxy proxy;
90 FakeLayerTreeHostImpl hostImpl(&proxy);
85 WebKit::WebScrollbarThemePainter painter; 91 WebKit::WebScrollbarThemePainter painter;
86 92
87 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create()); 93 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create());
88 scoped_refptr<Layer> layerTreeRoot = Layer::create(); 94 scoped_refptr<Layer> layerTreeRoot = Layer::create();
89 scoped_refptr<Layer> contentLayer = Layer::create(); 95 scoped_refptr<Layer> contentLayer = Layer::create();
90 scoped_refptr<Layer> scrollbarLayer = ScrollbarLayer::create(scrollbar.Pass( ), painter, WebKit::FakeWebScrollbarThemeGeometry::create(), layerTreeRoot->id() ); 96 scoped_refptr<Layer> scrollbarLayer = ScrollbarLayer::create(scrollbar.Pass( ), painter, WebKit::FakeWebScrollbarThemeGeometry::create(), layerTreeRoot->id() );
91 layerTreeRoot->addChild(contentLayer); 97 layerTreeRoot->addChild(contentLayer);
92 layerTreeRoot->addChild(scrollbarLayer); 98 layerTreeRoot->addChild(scrollbarLayer);
93 99
94 layerTreeRoot->setScrollOffset(gfx::Vector2d(10, 20)); 100 layerTreeRoot->setScrollOffset(gfx::Vector2d(10, 20));
95 layerTreeRoot->setMaxScrollOffset(gfx::Vector2d(30, 50)); 101 layerTreeRoot->setMaxScrollOffset(gfx::Vector2d(30, 50));
96 contentLayer->setBounds(gfx::Size(100, 200)); 102 contentLayer->setBounds(gfx::Size(100, 200));
97 103
98 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), 0); 104 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), &hostImpl);
99 105
100 ScrollbarLayerImpl* ccScrollbarLayer = static_cast<ScrollbarLayerImpl*>(laye rImplTreeRoot->children()[1]); 106 ScrollbarLayerImpl* ccScrollbarLayer = static_cast<ScrollbarLayerImpl*>(laye rImplTreeRoot->children()[1]);
101 107
102 EXPECT_EQ(10, ccScrollbarLayer->currentPos()); 108 EXPECT_EQ(10, ccScrollbarLayer->currentPos());
103 EXPECT_EQ(100, ccScrollbarLayer->totalSize()); 109 EXPECT_EQ(100, ccScrollbarLayer->totalSize());
104 EXPECT_EQ(30, ccScrollbarLayer->maximum()); 110 EXPECT_EQ(30, ccScrollbarLayer->maximum());
105 111
106 layerTreeRoot->setScrollOffset(gfx::Vector2d(100, 200)); 112 layerTreeRoot->setScrollOffset(gfx::Vector2d(100, 200));
107 layerTreeRoot->setMaxScrollOffset(gfx::Vector2d(300, 500)); 113 layerTreeRoot->setMaxScrollOffset(gfx::Vector2d(300, 500));
108 contentLayer->setBounds(gfx::Size(1000, 2000)); 114 contentLayer->setBounds(gfx::Size(1000, 2000));
109 115
110 ScrollbarAnimationController* scrollbarController = layerImplTreeRoot->scrol lbarAnimationController(); 116 ScrollbarAnimationController* scrollbarController = layerImplTreeRoot->scrol lbarAnimationController();
111 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), 0); 117 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), &hostImpl);
112 EXPECT_EQ(scrollbarController, layerImplTreeRoot->scrollbarAnimationControll er()); 118 EXPECT_EQ(scrollbarController, layerImplTreeRoot->scrollbarAnimationControll er());
113 119
114 EXPECT_EQ(100, ccScrollbarLayer->currentPos()); 120 EXPECT_EQ(100, ccScrollbarLayer->currentPos());
115 EXPECT_EQ(1000, ccScrollbarLayer->totalSize()); 121 EXPECT_EQ(1000, ccScrollbarLayer->totalSize());
116 EXPECT_EQ(300, ccScrollbarLayer->maximum()); 122 EXPECT_EQ(300, ccScrollbarLayer->maximum());
117 123
118 layerImplTreeRoot->scrollBy(gfx::Vector2d(12, 34)); 124 layerImplTreeRoot->scrollBy(gfx::Vector2d(12, 34));
119 125
120 EXPECT_EQ(112, ccScrollbarLayer->currentPos()); 126 EXPECT_EQ(112, ccScrollbarLayer->currentPos());
121 EXPECT_EQ(1000, ccScrollbarLayer->totalSize()); 127 EXPECT_EQ(1000, ccScrollbarLayer->totalSize());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 TEST_F(ScrollbarLayerTestMaxTextureSize, runTest) { 179 TEST_F(ScrollbarLayerTestMaxTextureSize, runTest) {
174 WebKit::FakeWebGraphicsContext3D context; 180 WebKit::FakeWebGraphicsContext3D context;
175 int max_size = 0; 181 int max_size = 0;
176 context.getIntegerv(GL_MAX_TEXTURE_SIZE, &max_size); 182 context.getIntegerv(GL_MAX_TEXTURE_SIZE, &max_size);
177 setScrollbarBounds(gfx::Size(max_size + 100, max_size + 100)); 183 setScrollbarBounds(gfx::Size(max_size + 100, max_size + 100));
178 runTest(true); 184 runTest(true);
179 } 185 }
180 186
181 } // namespace 187 } // namespace
182 } // namespace cc 188 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scrollbar_layer_impl.cc ('k') | cc/solid_color_layer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698