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/layer_tree_host_impl.h" | 5 #include "cc/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 461 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
472 | 472 |
473 // This point would fall into the non-fast scrollable region except that we'
ve moved the layer down by 25 pixels. | 473 // This point would fall into the non-fast scrollable region except that we'
ve moved the layer down by 25 pixels. |
474 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(40, 10), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollStarted); | 474 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(40, 10), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollStarted); |
475 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 1)); | 475 m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 1)); |
476 m_hostImpl->scrollEnd(); | 476 m_hostImpl->scrollEnd(); |
477 | 477 |
478 // This point is still inside the non-fast region. | 478 // This point is still inside the non-fast region. |
479 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollOnMainThread); | 479 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollOnMainThread); |
480 } | 480 } |
481 | 481 |
| 482 TEST_P(LayerTreeHostImplTest, scrollByReturnsCorrectValue) |
| 483 { |
| 484 setupScrollAndContentsLayers(gfx::Size(200, 200)); |
| 485 m_hostImpl->setViewportSize(gfx::Size(100, 100), gfx::Size(100, 100)); |
| 486 |
| 487 initializeRendererAndDrawFrame(); |
| 488 |
| 489 EXPECT_EQ(InputHandlerClient::ScrollStarted, |
| 490 m_hostImpl->scrollBegin(gfx::Point(0, 0), InputHandlerClient::Gesture)); |
| 491 |
| 492 // Trying to scroll to the left/top will not succeed. |
| 493 EXPECT_FALSE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, 0))); |
| 494 EXPECT_FALSE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, -10))); |
| 495 EXPECT_FALSE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, -10))); |
| 496 |
| 497 // Scrolling to the right/bottom will succeed. |
| 498 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(10, 0))); |
| 499 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, 10))); |
| 500 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(10, 10))); |
| 501 |
| 502 // Scrolling to left/top will now succeed. |
| 503 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, 0))); |
| 504 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(0, -10))); |
| 505 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(-10, -10))); |
| 506 |
| 507 // Trying to scroll more than the available space will also succeed. |
| 508 EXPECT_TRUE(m_hostImpl->scrollBy(gfx::Point(), gfx::Vector2d(5000, 5000))); |
| 509 } |
| 510 |
482 TEST_P(LayerTreeHostImplTest, maxScrollOffsetChangedByDeviceScaleFactor) | 511 TEST_P(LayerTreeHostImplTest, maxScrollOffsetChangedByDeviceScaleFactor) |
483 { | 512 { |
484 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 513 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
485 | 514 |
486 float deviceScaleFactor = 2; | 515 float deviceScaleFactor = 2; |
487 gfx::Size layoutViewport(25, 25); | 516 gfx::Size layoutViewport(25, 25); |
488 gfx::Size deviceViewport(gfx::ToFlooredSize(gfx::ScaleSize(layoutViewport, d
eviceScaleFactor))); | 517 gfx::Size deviceViewport(gfx::ToFlooredSize(gfx::ScaleSize(layoutViewport, d
eviceScaleFactor))); |
489 m_hostImpl->setViewportSize(layoutViewport, deviceViewport); | 518 m_hostImpl->setViewportSize(layoutViewport, deviceViewport); |
490 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); | 519 m_hostImpl->setDeviceScaleFactor(deviceScaleFactor); |
491 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), gfx::Vector2d(25, 25))
; | 520 EXPECT_EQ(m_hostImpl->rootLayer()->maxScrollOffset(), gfx::Vector2d(25, 25))
; |
(...skipping 3947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4439 testCaseIndex++; | 4468 testCaseIndex++; |
4440 } | 4469 } |
4441 } | 4470 } |
4442 | 4471 |
4443 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4472 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
4444 LayerTreeHostImplTest, | 4473 LayerTreeHostImplTest, |
4445 ::testing::Values(false, true)); | 4474 ::testing::Values(false, true)); |
4446 | 4475 |
4447 } // namespace | 4476 } // namespace |
4448 } // namespace cc | 4477 } // namespace cc |
OLD | NEW |