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

Side by Side Diff: cc/scrollbar_layer_unittest.cc

Issue 12648005: cc: Chromify the LayerTreeHostImpl class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Compl 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
« no previous file with comments | « cc/scrollbar_animation_controller_linear_fade_unittest.cc ('k') | cc/single_thread_proxy.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/append_quads_data.h" 7 #include "cc/append_quads_data.h"
8 #include "cc/prioritized_resource_manager.h" 8 #include "cc/prioritized_resource_manager.h"
9 #include "cc/priority_calculator.h" 9 #include "cc/priority_calculator.h"
10 #include "cc/resource_update_queue.h" 10 #include "cc/resource_update_queue.h"
(...skipping 23 matching lines...) Expand all
34 scoped_ptr<LayerImpl> layerImplForScrollAreaAndScrollbar( 34 scoped_ptr<LayerImpl> layerImplForScrollAreaAndScrollbar(
35 FakeLayerTreeHostImpl* host_impl, 35 FakeLayerTreeHostImpl* host_impl,
36 scoped_ptr<WebKit::WebScrollbar> scrollbar, 36 scoped_ptr<WebKit::WebScrollbar> scrollbar,
37 bool reverse_order) 37 bool reverse_order)
38 { 38 {
39 scoped_refptr<Layer> layerTreeRoot = Layer::Create(); 39 scoped_refptr<Layer> layerTreeRoot = Layer::Create();
40 scoped_refptr<Layer> child1 = Layer::Create(); 40 scoped_refptr<Layer> child1 = Layer::Create();
41 scoped_refptr<Layer> child2 = ScrollbarLayer::Create(scrollbar.Pass(), FakeS crollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScro llbarThemeGeometry::create(true), child1->id()); 41 scoped_refptr<Layer> child2 = ScrollbarLayer::Create(scrollbar.Pass(), FakeS crollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScro llbarThemeGeometry::create(true), child1->id());
42 layerTreeRoot->AddChild(child1); 42 layerTreeRoot->AddChild(child1);
43 layerTreeRoot->InsertChild(child2, reverse_order ? 0 : 1); 43 layerTreeRoot->InsertChild(child2, reverse_order ? 0 : 1);
44 scoped_ptr<LayerImpl> layerImpl = TreeSynchronizer::synchronizeTrees(layerTr eeRoot.get(), scoped_ptr<LayerImpl>(), host_impl->activeTree()); 44 scoped_ptr<LayerImpl> layerImpl = TreeSynchronizer::synchronizeTrees(layerTr eeRoot.get(), scoped_ptr<LayerImpl>(), host_impl->active_tree());
45 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImpl.get()); 45 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImpl.get());
46 return layerImpl.Pass(); 46 return layerImpl.Pass();
47 } 47 }
48 48
49 TEST(ScrollbarLayerTest, resolveScrollLayerPointer) 49 TEST(ScrollbarLayerTest, resolveScrollLayerPointer)
50 { 50 {
51 FakeImplProxy proxy; 51 FakeImplProxy proxy;
52 FakeLayerTreeHostImpl hostImpl(&proxy); 52 FakeLayerTreeHostImpl hostImpl(&proxy);
53 53
54 { 54 {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
110 scoped_refptr<Layer> contentLayer = Layer::Create(); 110 scoped_refptr<Layer> contentLayer = Layer::Create();
111 scoped_refptr<Layer> scrollbarLayer = ScrollbarLayer::Create(scrollbar.Pass( ), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), Fak eWebScrollbarThemeGeometry::create(true), layerTreeRoot->id()); 111 scoped_refptr<Layer> scrollbarLayer = ScrollbarLayer::Create(scrollbar.Pass( ), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), Fak eWebScrollbarThemeGeometry::create(true), layerTreeRoot->id());
112 layerTreeRoot->AddChild(contentLayer); 112 layerTreeRoot->AddChild(contentLayer);
113 layerTreeRoot->AddChild(scrollbarLayer); 113 layerTreeRoot->AddChild(scrollbarLayer);
114 114
115 layerTreeRoot->SetScrollOffset(gfx::Vector2d(10, 20)); 115 layerTreeRoot->SetScrollOffset(gfx::Vector2d(10, 20));
116 layerTreeRoot->SetMaxScrollOffset(gfx::Vector2d(30, 50)); 116 layerTreeRoot->SetMaxScrollOffset(gfx::Vector2d(30, 50));
117 layerTreeRoot->SetBounds(gfx::Size(100, 200)); 117 layerTreeRoot->SetBounds(gfx::Size(100, 200));
118 contentLayer->SetBounds(gfx::Size(100, 200)); 118 contentLayer->SetBounds(gfx::Size(100, 200));
119 119
120 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.activeTree()); 120 scoped_ptr<LayerImpl> layerImplTreeRoot = TreeSynchronizer::synchronizeTrees (layerTreeRoot.get(), scoped_ptr<LayerImpl>(), hostImpl.active_tree());
121 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImplTreeRoot.get( )); 121 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImplTreeRoot.get( ));
122 122
123 ScrollbarLayerImpl* ccScrollbarLayer = static_cast<ScrollbarLayerImpl*>(laye rImplTreeRoot->children()[1]); 123 ScrollbarLayerImpl* ccScrollbarLayer = static_cast<ScrollbarLayerImpl*>(laye rImplTreeRoot->children()[1]);
124 124
125 EXPECT_EQ(10, ccScrollbarLayer->CurrentPos()); 125 EXPECT_EQ(10, ccScrollbarLayer->CurrentPos());
126 EXPECT_EQ(100, ccScrollbarLayer->TotalSize()); 126 EXPECT_EQ(100, ccScrollbarLayer->TotalSize());
127 EXPECT_EQ(30, ccScrollbarLayer->Maximum()); 127 EXPECT_EQ(30, ccScrollbarLayer->Maximum());
128 128
129 layerTreeRoot->SetScrollOffset(gfx::Vector2d(100, 200)); 129 layerTreeRoot->SetScrollOffset(gfx::Vector2d(100, 200));
130 layerTreeRoot->SetMaxScrollOffset(gfx::Vector2d(300, 500)); 130 layerTreeRoot->SetMaxScrollOffset(gfx::Vector2d(300, 500));
131 layerTreeRoot->SetBounds(gfx::Size(1000, 2000)); 131 layerTreeRoot->SetBounds(gfx::Size(1000, 2000));
132 contentLayer->SetBounds(gfx::Size(1000, 2000)); 132 contentLayer->SetBounds(gfx::Size(1000, 2000));
133 133
134 ScrollbarAnimationController* scrollbarController = layerImplTreeRoot->scrol lbar_animation_controller(); 134 ScrollbarAnimationController* scrollbarController = layerImplTreeRoot->scrol lbar_animation_controller();
135 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), hostImpl.activeTree()); 135 layerImplTreeRoot = TreeSynchronizer::synchronizeTrees(layerTreeRoot.get(), layerImplTreeRoot.Pass(), hostImpl.active_tree());
136 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImplTreeRoot.get( )); 136 TreeSynchronizer::pushProperties(layerTreeRoot.get(), layerImplTreeRoot.get( ));
137 EXPECT_EQ(scrollbarController, layerImplTreeRoot->scrollbar_animation_contro ller()); 137 EXPECT_EQ(scrollbarController, layerImplTreeRoot->scrollbar_animation_contro ller());
138 138
139 EXPECT_EQ(100, ccScrollbarLayer->CurrentPos()); 139 EXPECT_EQ(100, ccScrollbarLayer->CurrentPos());
140 EXPECT_EQ(1000, ccScrollbarLayer->TotalSize()); 140 EXPECT_EQ(1000, ccScrollbarLayer->TotalSize());
141 EXPECT_EQ(300, ccScrollbarLayer->Maximum()); 141 EXPECT_EQ(300, ccScrollbarLayer->Maximum());
142 142
143 layerImplTreeRoot->ScrollBy(gfx::Vector2d(12, 34)); 143 layerImplTreeRoot->ScrollBy(gfx::Vector2d(12, 34));
144 144
145 EXPECT_EQ(112, ccScrollbarLayer->CurrentPos()); 145 EXPECT_EQ(112, ccScrollbarLayer->CurrentPos());
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 209
210 m_scrollLayer = Layer::Create(); 210 m_scrollLayer = Layer::Create();
211 m_scrollbarLayer->SetScrollLayerId(m_scrollLayer->id()); 211 m_scrollbarLayer->SetScrollLayerId(m_scrollLayer->id());
212 m_layerTreeHost->root_layer()->AddChild(m_scrollLayer); 212 m_layerTreeHost->root_layer()->AddChild(m_scrollLayer);
213 213
214 postSetNeedsCommitToMainThread(); 214 postSetNeedsCommitToMainThread();
215 } 215 }
216 216
217 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE 217 virtual void commitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE
218 { 218 {
219 const int kMaxTextureSize = impl->rendererCapabilities().max_texture_siz e; 219 const int kMaxTextureSize = impl->GetRendererCapabilities().max_texture_ size;
220 220
221 // Check first that we're actually testing something. 221 // Check first that we're actually testing something.
222 EXPECT_GT(m_scrollbarLayer->bounds().width(), kMaxTextureSize); 222 EXPECT_GT(m_scrollbarLayer->bounds().width(), kMaxTextureSize);
223 223
224 EXPECT_EQ(m_scrollbarLayer->content_bounds().width(), kMaxTextureSize - 1); 224 EXPECT_EQ(m_scrollbarLayer->content_bounds().width(), kMaxTextureSize - 1);
225 EXPECT_EQ(m_scrollbarLayer->content_bounds().height(), kMaxTextureSize - 1); 225 EXPECT_EQ(m_scrollbarLayer->content_bounds().height(), kMaxTextureSize - 1);
226 226
227 endTest(); 227 endTest();
228 } 228 }
229 229
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
318 } 318 }
319 319
320 TEST_F(ScrollbarLayerTestResourceCreation, solidColorNoResourceUpload) 320 TEST_F(ScrollbarLayerTestResourceCreation, solidColorNoResourceUpload)
321 { 321 {
322 m_layerTreeSettings.solidColorScrollbars = true; 322 m_layerTreeSettings.solidColorScrollbars = true;
323 testResourceUpload(0); 323 testResourceUpload(0);
324 } 324 }
325 325
326 } // namespace 326 } // namespace
327 } // namespace cc 327 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scrollbar_animation_controller_linear_fade_unittest.cc ('k') | cc/single_thread_proxy.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698