| 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 628 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 639 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); | 639 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); |
| 640 | 640 |
| 641 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { | 641 if (!m_hostImpl->settings().pageScalePinchZoomEnabled) { |
| 642 // Pushed to (0,0) via clamping against contents layer size. | 642 // Pushed to (0,0) via clamping against contents layer size. |
| 643 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -5
0)); | 643 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-50, -5
0)); |
| 644 } else { | 644 } else { |
| 645 EXPECT_TRUE(scrollInfo->scrolls.empty()); | 645 EXPECT_TRUE(scrollInfo->scrolls.empty()); |
| 646 } | 646 } |
| 647 } | 647 } |
| 648 | 648 |
| 649 // Two-finger panning | 649 // Two-finger panning should not happen based on pinch events only |
| 650 { | 650 { |
| 651 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 651 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
| 652 scrollLayer->setImplTransform(identityScaleTransform); | 652 scrollLayer->setImplTransform(identityScaleTransform); |
| 653 scrollLayer->setScrollDelta(gfx::Vector2d()); | 653 scrollLayer->setScrollDelta(gfx::Vector2d()); |
| 654 scrollLayer->setScrollOffset(gfx::Vector2d(20, 20)); | 654 scrollLayer->setScrollOffset(gfx::Vector2d(20, 20)); |
| 655 | 655 |
| 656 float pageScaleDelta = 1; | 656 float pageScaleDelta = 1; |
| 657 m_hostImpl->pinchGestureBegin(); | 657 m_hostImpl->pinchGestureBegin(); |
| 658 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(10, 10)); | 658 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(10, 10)); |
| 659 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(20, 20)); | 659 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(20, 20)); |
| 660 m_hostImpl->pinchGestureEnd(); | 660 m_hostImpl->pinchGestureEnd(); |
| 661 | 661 |
| 662 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); | 662 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 663 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 663 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
| 664 EXPECT_TRUE(scrollInfo->scrolls.empty()); |
| 665 } |
| 666 |
| 667 // Two-finger panning should work with interleaved scroll events |
| 668 { |
| 669 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
| 670 scrollLayer->setImplTransform(identityScaleTransform); |
| 671 scrollLayer->setScrollDelta(gfx::Vector2d()); |
| 672 scrollLayer->setScrollOffset(gfx::Vector2d(20, 20)); |
| 673 |
| 674 float pageScaleDelta = 1; |
| 675 m_hostImpl->scrollBegin(gfx::Point(10, 10), InputHandlerClient::Wheel); |
| 676 m_hostImpl->pinchGestureBegin(); |
| 677 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(10, 10)); |
| 678 m_hostImpl->scrollBy(gfx::Point(10, 10), gfx::Vector2d(-10, -10)); |
| 679 m_hostImpl->pinchGestureUpdate(pageScaleDelta, gfx::Point(20, 20)); |
| 680 m_hostImpl->pinchGestureEnd(); |
| 681 m_hostImpl->scrollEnd(); |
| 682 |
| 683 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt
as(); |
| 684 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
| 664 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-10, -10)); | 685 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(-10, -10)); |
| 665 } | 686 } |
| 666 } | 687 } |
| 667 | 688 |
| 668 TEST_P(LayerTreeHostImplTest, pageScaleAnimation) | 689 TEST_P(LayerTreeHostImplTest, pageScaleAnimation) |
| 669 { | 690 { |
| 670 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 691 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
| 671 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 692 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
| 672 initializeRendererAndDrawFrame(); | 693 initializeRendererAndDrawFrame(); |
| 673 | 694 |
| (...skipping 3774 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4448 testCaseIndex++; | 4469 testCaseIndex++; |
| 4449 } | 4470 } |
| 4450 } | 4471 } |
| 4451 | 4472 |
| 4452 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4473 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
| 4453 LayerTreeHostImplTest, | 4474 LayerTreeHostImplTest, |
| 4454 ::testing::Values(false, true)); | 4475 ::testing::Values(false, true)); |
| 4455 | 4476 |
| 4456 } // namespace | 4477 } // namespace |
| 4457 } // namespace cc | 4478 } // namespace cc |
| OLD | NEW |