OLD | NEW |
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 Loading... |
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, 200)); |
| 548 m_hostImpl->SetViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); |
| 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 m_hostImpl->RootScrollLayer()->SetVerticalScrollbarLayer( |
| 567 vertical_scrollbar.get()); |
| 568 |
| 569 // Trying to scroll with a vertical scrollbar will succeed. |
| 570 EXPECT_TRUE(m_hostImpl->ScrollVerticallyByPage( |
| 571 gfx::Point(), WebKit::WebScrollbar::ScrollForward)); |
| 572 EXPECT_TRUE(m_hostImpl->ScrollVerticallyByPage( |
| 573 gfx::Point(), WebKit::WebScrollbar::ScrollBackward)); |
| 574 } |
| 575 |
545 TEST_F(LayerTreeHostImplTest, clearRootRenderSurfaceAndHitTestTouchHandlerRegion
) | 576 TEST_F(LayerTreeHostImplTest, clearRootRenderSurfaceAndHitTestTouchHandlerRegion
) |
546 { | 577 { |
547 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 578 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
548 m_hostImpl->SetViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 579 m_hostImpl->SetViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
549 initializeRendererAndDrawFrame(); | 580 initializeRendererAndDrawFrame(); |
550 | 581 |
551 // We should be able to hit test for touch event handlers even if the root l
ayer loses | 582 // 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. | 583 // its render surface after the most recent render. |
553 m_hostImpl->active_tree()->root_layer()->ClearRenderSurface(); | 584 m_hostImpl->active_tree()->root_layer()->ClearRenderSurface(); |
554 m_hostImpl->active_tree()->set_needs_update_draw_properties(); | 585 m_hostImpl->active_tree()->set_needs_update_draw_properties(); |
(...skipping 3789 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4344 EXPECT_EQ(gfx::Rect(0, 0, 100, 100).ToString(), renderPassQuad->rect.ToS
tring()); | 4375 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()); | 4376 EXPECT_EQ(gfx::RectF(0.f, 0.f, 1.f, 1.f).ToString(), renderPassQuad->mas
k_uv_rect.ToString()); |
4346 | 4377 |
4347 m_hostImpl->DrawLayers(&frame, base::TimeTicks::Now()); | 4378 m_hostImpl->DrawLayers(&frame, base::TimeTicks::Now()); |
4348 m_hostImpl->DidDrawAllLayers(frame); | 4379 m_hostImpl->DidDrawAllLayers(frame); |
4349 } | 4380 } |
4350 } | 4381 } |
4351 | 4382 |
4352 } // namespace | 4383 } // namespace |
4353 } // namespace cc | 4384 } // namespace cc |
OLD | NEW |