OLD | NEW |
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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/scrollbar_layer.h" | 7 #include "cc/scrollbar_layer.h" |
8 | 8 |
9 #include "cc/scrollbar_animation_controller.h" | 9 #include "cc/scrollbar_animation_controller.h" |
10 #include "cc/scrollbar_layer_impl.h" | 10 #include "cc/scrollbar_layer_impl.h" |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
90 | 90 |
91 WebKit::WebScrollbarThemePainter painter; | 91 WebKit::WebScrollbarThemePainter painter; |
92 | 92 |
93 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create()); | 93 scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create()); |
94 scoped_refptr<Layer> layerTreeRoot = Layer::create(); | 94 scoped_refptr<Layer> layerTreeRoot = Layer::create(); |
95 scoped_refptr<Layer> contentLayer = Layer::create(); | 95 scoped_refptr<Layer> contentLayer = Layer::create(); |
96 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()
); |
97 layerTreeRoot->addChild(contentLayer); | 97 layerTreeRoot->addChild(contentLayer); |
98 layerTreeRoot->addChild(scrollbarLayer); | 98 layerTreeRoot->addChild(scrollbarLayer); |
99 | 99 |
100 layerTreeRoot->setScrollPosition(IntPoint(10, 20)); | 100 layerTreeRoot->setScrollOffset(gfx::Vector2d(10, 20)); |
101 layerTreeRoot->setMaxScrollPosition(IntSize(30, 50)); | 101 layerTreeRoot->setMaxScrollOffset(gfx::Vector2d(30, 50)); |
102 contentLayer->setBounds(IntSize(100, 200)); | 102 contentLayer->setBounds(gfx::Size(100, 200)); |
103 | 103 |
104 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees
(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), 0); | 104 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees
(layerTreeRoot.get(), scoped_ptr<LayerImpl>(), 0); |
105 | 105 |
106 ScrollbarLayerImpl* ccScrollbarLayer = static_cast<ScrollbarLayerImpl*>(laye
rImplTreeRoot->children()[1]); | 106 ScrollbarLayerImpl* ccScrollbarLayer = static_cast<ScrollbarLayerImpl*>(laye
rImplTreeRoot->children()[1]); |
107 | 107 |
108 EXPECT_EQ(10, ccScrollbarLayer->currentPos()); | 108 EXPECT_EQ(10, ccScrollbarLayer->currentPos()); |
109 EXPECT_EQ(100, ccScrollbarLayer->totalSize()); | 109 EXPECT_EQ(100, ccScrollbarLayer->totalSize()); |
110 EXPECT_EQ(30, ccScrollbarLayer->maximum()); | 110 EXPECT_EQ(30, ccScrollbarLayer->maximum()); |
111 | 111 |
112 layerTreeRoot->setScrollPosition(IntPoint(100, 200)); | 112 layerTreeRoot->setScrollOffset(gfx::Vector2d(100, 200)); |
113 layerTreeRoot->setMaxScrollPosition(IntSize(300, 500)); | 113 layerTreeRoot->setMaxScrollOffset(gfx::Vector2d(300, 500)); |
114 contentLayer->setBounds(IntSize(1000, 2000)); | 114 contentLayer->setBounds(gfx::Size(1000, 2000)); |
115 | 115 |
116 ScrollbarAnimationController* scrollbarController = layerImplTreeRoot->scrol
lbarAnimationController(); | 116 ScrollbarAnimationController* scrollbarController = layerImplTreeRoot->scrol
lbarAnimationController(); |
117 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(),
layerImplTreeRoot.Pass(), 0); | 117 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(),
layerImplTreeRoot.Pass(), 0); |
118 EXPECT_EQ(scrollbarController, layerImplTreeRoot->scrollbarAnimationControll
er()); | 118 EXPECT_EQ(scrollbarController, layerImplTreeRoot->scrollbarAnimationControll
er()); |
119 | 119 |
120 EXPECT_EQ(100, ccScrollbarLayer->currentPos()); | 120 EXPECT_EQ(100, ccScrollbarLayer->currentPos()); |
121 EXPECT_EQ(1000, ccScrollbarLayer->totalSize()); | 121 EXPECT_EQ(1000, ccScrollbarLayer->totalSize()); |
122 EXPECT_EQ(300, ccScrollbarLayer->maximum()); | 122 EXPECT_EQ(300, ccScrollbarLayer->maximum()); |
123 | 123 |
124 layerImplTreeRoot->scrollBy(FloatSize(12, 34)); | 124 layerImplTreeRoot->scrollBy(gfx::Vector2d(12, 34)); |
125 | 125 |
126 EXPECT_EQ(112, ccScrollbarLayer->currentPos()); | 126 EXPECT_EQ(112, ccScrollbarLayer->currentPos()); |
127 EXPECT_EQ(1000, ccScrollbarLayer->totalSize()); | 127 EXPECT_EQ(1000, ccScrollbarLayer->totalSize()); |
128 EXPECT_EQ(300, ccScrollbarLayer->maximum()); | 128 EXPECT_EQ(300, ccScrollbarLayer->maximum()); |
129 } | 129 } |
130 | 130 |
131 } | 131 } |
OLD | NEW |