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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "cc/layer_tree_host_impl.h" | 7 #include "cc/layer_tree_host_impl.h" |
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 625 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
636 | 636 |
637 TEST_P(LayerTreeHostImplTest, pageScaleAnimation) | 637 TEST_P(LayerTreeHostImplTest, pageScaleAnimation) |
638 { | 638 { |
639 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 639 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
640 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 640 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
641 initializeRendererAndDrawFrame(); | 641 initializeRendererAndDrawFrame(); |
642 | 642 |
643 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | 643 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
644 DCHECK(scrollLayer); | 644 DCHECK(scrollLayer); |
645 | 645 |
646 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5; | 646 const float minPageScale = 0.5; |
647 const float maxPageScale = 4; | 647 const float maxPageScale = 4; |
648 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS
econds(1); | 648 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS
econds(1); |
649 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 649 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
650 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2; | 650 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2; |
651 const base::TimeTicks endTime = startTime + duration; | 651 const base::TimeTicks endTime = startTime + duration; |
652 const WebTransformationMatrix identityScaleTransform; | 652 const WebTransformationMatrix identityScaleTransform; |
653 | 653 |
654 // Non-anchor zoom-in | 654 // Non-anchor zoom-in |
655 { | 655 { |
656 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 656 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 | 757 |
758 TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPage
Scale) | 758 TEST_P(LayerTreeHostImplTest, inhibitScrollAndPageScaleUpdatesWhileAnimatingPage
Scale) |
759 { | 759 { |
760 setupScrollAndContentsLayers(gfx::Size(100, 100)); | 760 setupScrollAndContentsLayers(gfx::Size(100, 100)); |
761 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); | 761 m_hostImpl->setViewportSize(gfx::Size(50, 50), gfx::Size(50, 50)); |
762 initializeRendererAndDrawFrame(); | 762 initializeRendererAndDrawFrame(); |
763 | 763 |
764 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); | 764 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); |
765 DCHECK(scrollLayer); | 765 DCHECK(scrollLayer); |
766 | 766 |
767 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5; | 767 const float minPageScale = 0.5; |
768 const float maxPageScale = 4; | 768 const float maxPageScale = 4; |
769 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS
econds(1); | 769 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS
econds(1); |
770 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); | 770 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); |
771 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2; | 771 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2; |
772 const base::TimeTicks endTime = startTime + duration; | 772 const base::TimeTicks endTime = startTime + duration; |
773 // Start a page scale animation. | 773 |
774 const float pageScaleDelta = 2; | 774 const float pageScaleDelta = 2; |
| 775 gfx::Vector2d target(25, 25); |
| 776 gfx::Vector2d scaledTarget = target; |
| 777 if (!Settings::pageScalePinchZoomEnabled()) |
| 778 scaledTarget = gfx::Vector2d(12, 12); |
| 779 |
775 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); | 780 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); |
776 m_hostImpl->startPageScaleAnimation(gfx::Vector2d(50, 50), false, pageScaleD
elta, startTime, duration); | 781 m_hostImpl->startPageScaleAnimation(target, false, pageScaleDelta, startTime
, duration); |
777 | 782 |
778 // We should immediately get the final zoom and scroll values for the | 783 // We should immediately get the final zoom and scroll values for the |
779 // animation. | 784 // animation. |
780 m_hostImpl->animate(halfwayThroughAnimation, base::Time()); | 785 m_hostImpl->animate(halfwayThroughAnimation, base::Time()); |
781 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; | 786 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas()
; |
782 | 787 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
783 if (!Settings::pageScalePinchZoomEnabled()) { | 788 expectContains(*scrollInfo, scrollLayer->id(), scaledTarget); |
784 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | |
785 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(25, 25)); | |
786 } else { | |
787 EXPECT_EQ(scrollInfo->pageScaleDelta, 1); | |
788 EXPECT_TRUE(scrollInfo->scrolls.empty()); | |
789 } | |
790 | 789 |
791 // Scrolling during the animation is ignored. | 790 // Scrolling during the animation is ignored. |
792 const gfx::Vector2d scrollDelta(0, 10); | 791 const gfx::Vector2d scrollDelta(0, 10); |
793 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(25, 25), InputHandlerClient::Wh
eel), InputHandlerClient::ScrollStarted); | 792 EXPECT_EQ(m_hostImpl->scrollBegin(gfx::Point(target.x(), target.y()), InputH
andlerClient::Wheel), InputHandlerClient::ScrollStarted); |
794 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); | 793 m_hostImpl->scrollBy(gfx::Point(), scrollDelta); |
795 m_hostImpl->scrollEnd(); | 794 m_hostImpl->scrollEnd(); |
796 | 795 |
797 // The final page scale and scroll deltas should match what we got | 796 // The final page scale and scroll deltas should match what we got |
798 // earlier. | 797 // earlier. |
799 m_hostImpl->animate(endTime, base::Time()); | 798 m_hostImpl->animate(endTime, base::Time()); |
800 scrollInfo = m_hostImpl->processScrollDeltas(); | 799 scrollInfo = m_hostImpl->processScrollDeltas(); |
801 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); | 800 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); |
802 expectContains(*scrollInfo, scrollLayer->id(), gfx::Vector2d(25, 25)); | 801 expectContains(*scrollInfo, scrollLayer->id(), scaledTarget); |
803 } | 802 } |
804 | 803 |
805 class DidDrawCheckLayer : public TiledLayerImpl { | 804 class DidDrawCheckLayer : public TiledLayerImpl { |
806 public: | 805 public: |
807 static scoped_ptr<LayerImpl> create(int id) { return scoped_ptr<LayerImpl>(n
ew DidDrawCheckLayer(id)); } | 806 static scoped_ptr<LayerImpl> create(int id) { return scoped_ptr<LayerImpl>(n
ew DidDrawCheckLayer(id)); } |
808 | 807 |
809 virtual void didDraw(ResourceProvider*) OVERRIDE | 808 virtual void didDraw(ResourceProvider*) OVERRIDE |
810 { | 809 { |
811 m_didDrawCalled = true; | 810 m_didDrawCalled = true; |
812 } | 811 } |
(...skipping 3595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4408 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); | 4407 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat
a); |
4409 testCaseIndex++; | 4408 testCaseIndex++; |
4410 } | 4409 } |
4411 } | 4410 } |
4412 | 4411 |
4413 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, | 4412 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, |
4414 LayerTreeHostImplTest, | 4413 LayerTreeHostImplTest, |
4415 ::testing::Values(false, true)); | 4414 ::testing::Values(false, true)); |
4416 | 4415 |
4417 } // anonymous namespace | 4416 } // anonymous namespace |
OLD | NEW |