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

Side by Side Diff: cc/scrollbar_layer_unittest.cc

Issue 11550035: Implement pinch-zoom scaling for main-frame scrollbars and pinch-zoom overlay scrollbars. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to fix collision with solid colour scrollbars patch. 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_layer_impl.cc ('k') | cc/tree_synchronizer.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 "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/layer_tree_impl.h"
8 #include "cc/prioritized_resource_manager.h" 9 #include "cc/prioritized_resource_manager.h"
9 #include "cc/priority_calculator.h" 10 #include "cc/priority_calculator.h"
10 #include "cc/resource_update_queue.h" 11 #include "cc/resource_update_queue.h"
11 #include "cc/scrollbar_animation_controller.h" 12 #include "cc/scrollbar_animation_controller.h"
12 #include "cc/scrollbar_layer_impl.h" 13 #include "cc/scrollbar_layer_impl.h"
13 #include "cc/single_thread_proxy.h" 14 #include "cc/single_thread_proxy.h"
14 #include "cc/solid_color_draw_quad.h" 15 #include "cc/solid_color_draw_quad.h"
15 #include "cc/test/fake_impl_proxy.h" 16 #include "cc/test/fake_impl_proxy.h"
16 #include "cc/test/fake_layer_tree_host_client.h" 17 #include "cc/test/fake_layer_tree_host_client.h"
17 #include "cc/test/fake_layer_tree_host_impl.h" 18 #include "cc/test/fake_layer_tree_host_impl.h"
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 m_layerTreeSettings.solidColorScrollbars = false; 336 m_layerTreeSettings.solidColorScrollbars = false;
336 testResourceUpload(2); 337 testResourceUpload(2);
337 } 338 }
338 339
339 TEST_F(ScrollbarLayerTestResourceCreation, solidColorNoResourceUpload) 340 TEST_F(ScrollbarLayerTestResourceCreation, solidColorNoResourceUpload)
340 { 341 {
341 m_layerTreeSettings.solidColorScrollbars = true; 342 m_layerTreeSettings.solidColorScrollbars = true;
342 testResourceUpload(0); 343 testResourceUpload(0);
343 } 344 }
344 345
346 TEST(ScrollbarLayerTest, pinchZoomScrollbarUpdates)
347 {
348 FakeImplProxy proxy;
349 FakeLayerTreeHostImpl hostImpl(&proxy);
350
351 scoped_refptr<Layer> layerTreeRoot = Layer::Create();
352 layerTreeRoot->SetScrollable(true);
353
354 scoped_refptr<Layer> contentLayer = Layer::Create();
355 scoped_ptr<WebKit::WebScrollbar> scrollbar1(FakeWebScrollbar::Create());
356 scoped_refptr<Layer> scrollbarLayerHorizontal =
357 ScrollbarLayer::Create(scrollbar1.Pass(),
358 FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>() ,
359 FakeWebScrollbarThemeGeometry::create(true),
360 Layer::PINCH_ZOOM_ROOT_SCROLL_LAYER_ID);
361 scoped_ptr<WebKit::WebScrollbar> scrollbar2(FakeWebScrollbar::Create());
362 scoped_refptr<Layer> scrollbarLayerVertical =
363 ScrollbarLayer::Create(scrollbar2.Pass(),
364 FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>() ,
365 FakeWebScrollbarThemeGeometry::create(true),
366 Layer::PINCH_ZOOM_ROOT_SCROLL_LAYER_ID);
367
368 layerTreeRoot->AddChild(contentLayer);
369 layerTreeRoot->AddChild(scrollbarLayerHorizontal);
370 layerTreeRoot->AddChild(scrollbarLayerVertical);
371
372 layerTreeRoot->SetScrollOffset(gfx::Vector2d(10, 20));
373 layerTreeRoot->SetMaxScrollOffset(gfx::Vector2d(30, 50));
374 layerTreeRoot->SetBounds(gfx::Size(100, 200));
375 contentLayer->SetBounds(gfx::Size(100, 200));
376
377 scoped_ptr<LayerImpl> layerImplTreeRoot =
378 TreeSynchronizer::SynchronizeTrees(layerTreeRoot.get(),
379 scoped_ptr<LayerImpl>(), hostImpl.active_tree());
380 TreeSynchronizer::PushProperties(layerTreeRoot.get(),
381 layerImplTreeRoot.get());
382
383 ScrollbarLayerImpl* pinchZoomHorizontal = static_cast<ScrollbarLayerImpl*>(
384 layerImplTreeRoot->children()[1]);
385 ScrollbarLayerImpl* pinchZoomVertical = static_cast<ScrollbarLayerImpl*>(
386 layerImplTreeRoot->children()[2]);
387
388 // Need a root layer in the active tree in order for DidUpdateScroll()
389 // to work.
390 hostImpl.active_tree()->SetRootLayer(layerImplTreeRoot.Pass());
391 hostImpl.active_tree()->FindRootScrollLayer();
392
393 // Manually set the pinch-zoom layers: normally this is done by
394 // LayerTreeHost.
395 hostImpl.active_tree()->SetPinchZoomHorizontalLayerId(
396 pinchZoomHorizontal->id());
397 hostImpl.active_tree()->SetPinchZoomVerticalLayerId(
398 pinchZoomVertical->id());
399
400 hostImpl.active_tree()->DidUpdateScroll();
401
402 EXPECT_EQ(10, pinchZoomHorizontal->CurrentPos());
403 EXPECT_EQ(100, pinchZoomHorizontal->TotalSize());
404 EXPECT_EQ(30, pinchZoomHorizontal->Maximum());
405 EXPECT_EQ(20, pinchZoomVertical->CurrentPos());
406 EXPECT_EQ(200, pinchZoomVertical->TotalSize());
407 EXPECT_EQ(50, pinchZoomVertical->Maximum());
408 }
409
345 } // namespace 410 } // namespace
346 } // namespace cc 411 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scrollbar_layer_impl.cc ('k') | cc/tree_synchronizer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698