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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 12582009: Implement windows mousewheel scroll by page functionality (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: fix scroll distance calculation to more closely match windows behavior 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 2011 The Chromium Authors. All rights reserved. 1 // Copyright 2011 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/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <cmath> 7 #include <cmath>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 535
536 // Scrolling diagonally against an edge will succeed. 536 // Scrolling diagonally against an edge will succeed.
537 EXPECT_TRUE(m_hostImpl->ScrollBy(gfx::Point(), gfx::Vector2d(10, -10))); 537 EXPECT_TRUE(m_hostImpl->ScrollBy(gfx::Point(), gfx::Vector2d(10, -10)));
538 EXPECT_TRUE(m_hostImpl->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 0))); 538 EXPECT_TRUE(m_hostImpl->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 0)));
539 EXPECT_TRUE(m_hostImpl->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 10))); 539 EXPECT_TRUE(m_hostImpl->ScrollBy(gfx::Point(), gfx::Vector2d(-10, 10)));
540 540
541 // Trying to scroll more than the available space will also succeed. 541 // Trying to scroll more than the available space will also succeed.
542 EXPECT_TRUE(m_hostImpl->ScrollBy(gfx::Point(), gfx::Vector2d(5000, 5000))); 542 EXPECT_TRUE(m_hostImpl->ScrollBy(gfx::Point(), gfx::Vector2d(5000, 5000)));
543 } 543 }
544 544
545 TEST_F(LayerTreeHostImplTest, scrollVerticallyByPageReturnsCorrectValue)
546 {
547 setupScrollAndContentsLayers(gfx::Size(200, 2000));
548 m_hostImpl->SetViewportSize(gfx::Size(100, 1000), gfx::Size(100, 1000));
549
550 initializeRendererAndDrawFrame();
551
552 EXPECT_EQ(InputHandlerClient::ScrollStarted,
553 m_hostImpl->ScrollBegin(gfx::Point(0, 0), InputHandlerClient::Wheel));
554
555 // Trying to scroll without a vertical scrollbar will fail.
556 EXPECT_FALSE(m_hostImpl->ScrollVerticallyByPage(
557 gfx::Point(), WebKit::WebScrollbar::ScrollForward));
558 EXPECT_FALSE(m_hostImpl->ScrollVerticallyByPage(
559 gfx::Point(), WebKit::WebScrollbar::ScrollBackward));
560
561 scoped_ptr<cc::ScrollbarLayerImpl> vertical_scrollbar(
562 cc::ScrollbarLayerImpl::Create(
563 m_hostImpl->active_tree(),
564 20,
565 scoped_ptr<ScrollbarGeometryFixedThumb>()));
566 vertical_scrollbar->SetBounds(gfx::Size(15, 1000));
567 m_hostImpl->RootScrollLayer()->SetVerticalScrollbarLayer(
568 vertical_scrollbar.get());
569
570 // Trying to scroll with a vertical scrollbar will succeed.
571 EXPECT_TRUE(m_hostImpl->ScrollVerticallyByPage(
572 gfx::Point(), WebKit::WebScrollbar::ScrollForward));
573 EXPECT_FLOAT_EQ(875.f, m_hostImpl->RootScrollLayer()->scroll_delta().y());
574 EXPECT_TRUE(m_hostImpl->ScrollVerticallyByPage(
575 gfx::Point(), WebKit::WebScrollbar::ScrollBackward));
576 }
577
545 TEST_F(LayerTreeHostImplTest, clearRootRenderSurfaceAndHitTestTouchHandlerRegion ) 578 TEST_F(LayerTreeHostImplTest, clearRootRenderSurfaceAndHitTestTouchHandlerRegion )
546 { 579 {
547 setupScrollAndContentsLayers(gfx::Size(100, 100)); 580 setupScrollAndContentsLayers(gfx::Size(100, 100));
548 m_hostImpl->SetViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); 581 m_hostImpl->SetViewportSize(gfx::Size(50, 50), gfx::Size(50, 50));
549 initializeRendererAndDrawFrame(); 582 initializeRendererAndDrawFrame();
550 583
551 // We should be able to hit test for touch event handlers even if the root l ayer loses 584 // We should be able to hit test for touch event handlers even if the root l ayer loses
552 // its render surface after the most recent render. 585 // its render surface after the most recent render.
553 m_hostImpl->active_tree()->root_layer()->ClearRenderSurface(); 586 m_hostImpl->active_tree()->root_layer()->ClearRenderSurface();
554 m_hostImpl->active_tree()->set_needs_update_draw_properties(); 587 m_hostImpl->active_tree()->set_needs_update_draw_properties();
(...skipping 3789 matching lines...) Expand 10 before | Expand all | Expand 10 after
4344 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), renderPassQuad->rect.ToS tring()); 4377 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), renderPassQuad->rect.ToS tring());
4345 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), renderPassQuad->mas k_uv_rect.ToString()); 4378 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), renderPassQuad->mas k_uv_rect.ToString());
4346 4379
4347 m_hostImpl->DrawLayers(&frame, base::TimeTicks::Now()); 4380 m_hostImpl->DrawLayers(&frame, base::TimeTicks::Now());
4348 m_hostImpl->DidDrawAllLayers(frame); 4381 m_hostImpl->DidDrawAllLayers(frame);
4349 } 4382 }
4350 } 4383 }
4351 4384
4352 } // namespace 4385 } // namespace
4353 } // namespace cc 4386 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698