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

Side by Side Diff: cc/layer_tree_host_impl_unittest.cc

Issue 11191068: Remove WTF::currentTime() / WTF::monotonicallyIncreasingTime() uses from cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 1 month 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
« no previous file with comments | « cc/layer_tree_host_impl.cc ('k') | cc/layer_tree_host_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "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/command_line.h" 9 #include "base/command_line.h"
10 #include "base/hash_tables.h" 10 #include "base/hash_tables.h"
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 m_hostImpl->initializeRenderer(createContext()); 75 m_hostImpl->initializeRenderer(createContext());
76 m_hostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10)); 76 m_hostImpl->setViewportSize(IntSize(10, 10), IntSize(10, 10));
77 } 77 }
78 78
79 virtual void TearDown() 79 virtual void TearDown()
80 { 80 {
81 } 81 }
82 82
83 virtual void didLoseContextOnImplThread() OVERRIDE { } 83 virtual void didLoseContextOnImplThread() OVERRIDE { }
84 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { } 84 virtual void onSwapBuffersCompleteOnImplThread() OVERRIDE { }
85 virtual void onVSyncParametersChanged(double, double) OVERRIDE { } 85 virtual void onVSyncParametersChanged(base::TimeTicks, base::TimeDelta) OVER RIDE { }
86 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState ChangedCalled = true; } 86 virtual void onCanDrawStateChanged(bool canDraw) OVERRIDE { m_onCanDrawState ChangedCalled = true; }
87 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr ue; } 87 virtual void setNeedsRedrawOnImplThread() OVERRIDE { m_didRequestRedraw = tr ue; }
88 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr ue; } 88 virtual void setNeedsCommitOnImplThread() OVERRIDE { m_didRequestCommit = tr ue; }
89 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio nEventsVector>, double wallClockTime) OVERRIDE { } 89 virtual void postAnimationEventsToMainThreadOnImplThread(scoped_ptr<Animatio nEventsVector>, base::Time wallClockTime) OVERRIDE { }
90 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int priorityCutoff) OVERRIDE { return m_reduceMemoryResult; } 90 virtual bool reduceContentsTextureMemoryOnImplThread(size_t limitBytes, int priorityCutoff) OVERRIDE { return m_reduceMemoryResult; }
91 virtual void sendManagedMemoryStats() OVERRIDE { } 91 virtual void sendManagedMemoryStats() OVERRIDE { }
92 92
93 void setReduceMemoryResult(bool reduceMemoryResult) { m_reduceMemoryResult = reduceMemoryResult; } 93 void setReduceMemoryResult(bool reduceMemoryResult) { m_reduceMemoryResult = reduceMemoryResult; }
94 94
95 scoped_ptr<LayerTreeHostImpl> createLayerTreeHost(bool partialSwap, scoped_p tr<GraphicsContext> graphicsContext, scoped_ptr<LayerImpl> root) 95 scoped_ptr<LayerTreeHostImpl> createLayerTreeHost(bool partialSwap, scoped_p tr<GraphicsContext> graphicsContext, scoped_ptr<LayerImpl> root)
96 { 96 {
97 Settings::setPartialSwapEnabled(partialSwap); 97 Settings::setPartialSwapEnabled(partialSwap);
98 98
99 LayerTreeSettings settings; 99 LayerTreeSettings settings;
(...skipping 528 matching lines...) Expand 10 before | Expand all | Expand 10 after
628 { 628 {
629 setupScrollAndContentsLayers(IntSize(100, 100)); 629 setupScrollAndContentsLayers(IntSize(100, 100));
630 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); 630 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
631 initializeRendererAndDrawFrame(); 631 initializeRendererAndDrawFrame();
632 632
633 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); 633 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
634 DCHECK(scrollLayer); 634 DCHECK(scrollLayer);
635 635
636 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5; 636 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5;
637 const float maxPageScale = 4; 637 const float maxPageScale = 4;
638 const double startTime = 1; 638 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS econds(1);
639 const double duration = 0.1; 639 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
640 const double halfwayThroughAnimation = startTime + duration / 2; 640 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2;
641 const double endTime = startTime + duration; 641 const base::TimeTicks endTime = startTime + duration;
642 const WebTransformationMatrix identityScaleTransform; 642 const WebTransformationMatrix identityScaleTransform;
643 643
644 // Non-anchor zoom-in 644 // Non-anchor zoom-in
645 { 645 {
646 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 646 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
647 scrollLayer->setImplTransform(identityScaleTransform); 647 scrollLayer->setImplTransform(identityScaleTransform);
648 scrollLayer->setScrollPosition(IntPoint(50, 50)); 648 scrollLayer->setScrollPosition(IntPoint(50, 50));
649 649
650 m_hostImpl->startPageScaleAnimation(IntSize(0, 0), false, 2, startTime, duration); 650 m_hostImpl->startPageScaleAnimation(IntSize(0, 0), false, 2, startTime, duration);
651 m_hostImpl->animate(halfwayThroughAnimation, halfwayThroughAnimation); 651 m_hostImpl->animate(halfwayThroughAnimation, base::Time());
652 EXPECT_TRUE(m_didRequestRedraw); 652 EXPECT_TRUE(m_didRequestRedraw);
653 m_hostImpl->animate(endTime, endTime); 653 m_hostImpl->animate(endTime, base::Time());
654 EXPECT_TRUE(m_didRequestCommit); 654 EXPECT_TRUE(m_didRequestCommit);
655 655
656 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as(); 656 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as();
657 EXPECT_EQ(scrollInfo->pageScaleDelta, 2); 657 EXPECT_EQ(scrollInfo->pageScaleDelta, 2);
658 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); 658 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50));
659 } 659 }
660 660
661 // Anchor zoom-out 661 // Anchor zoom-out
662 { 662 {
663 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 663 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
664 scrollLayer->setImplTransform(identityScaleTransform); 664 scrollLayer->setImplTransform(identityScaleTransform);
665 scrollLayer->setScrollPosition(IntPoint(50, 50)); 665 scrollLayer->setScrollPosition(IntPoint(50, 50));
666 666
667 m_hostImpl->startPageScaleAnimation(IntSize(25, 25), true, minPageScale, startTime, duration); 667 m_hostImpl->startPageScaleAnimation(IntSize(25, 25), true, minPageScale, startTime, duration);
668 m_hostImpl->animate(endTime, endTime); 668 m_hostImpl->animate(endTime, base::Time());
669 EXPECT_TRUE(m_didRequestRedraw); 669 EXPECT_TRUE(m_didRequestRedraw);
670 EXPECT_TRUE(m_didRequestCommit); 670 EXPECT_TRUE(m_didRequestCommit);
671 671
672 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as(); 672 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDelt as();
673 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale); 673 EXPECT_EQ(scrollInfo->pageScaleDelta, minPageScale);
674 // Pushed to (0,0) via clamping against contents layer size. 674 // Pushed to (0,0) via clamping against contents layer size.
675 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50)); 675 expectContains(*scrollInfo, scrollLayer->id(), IntSize(-50, -50));
676 } 676 }
677 } 677 }
678 678
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
749 { 749 {
750 setupScrollAndContentsLayers(IntSize(100, 100)); 750 setupScrollAndContentsLayers(IntSize(100, 100));
751 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50)); 751 m_hostImpl->setViewportSize(IntSize(50, 50), IntSize(50, 50));
752 initializeRendererAndDrawFrame(); 752 initializeRendererAndDrawFrame();
753 753
754 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer(); 754 LayerImpl* scrollLayer = m_hostImpl->rootScrollLayer();
755 DCHECK(scrollLayer); 755 DCHECK(scrollLayer);
756 756
757 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5; 757 const float minPageScale = Settings::pageScalePinchZoomEnabled() ? 1 : 0.5;
758 const float maxPageScale = 4; 758 const float maxPageScale = 4;
759 const double startTime = 1; 759 const base::TimeTicks startTime = base::TimeTicks() + base::TimeDelta::FromS econds(1);
760 const double duration = 0.1; 760 const base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
761 const double halfwayThroughAnimation = startTime + duration / 2; 761 const base::TimeTicks halfwayThroughAnimation = startTime + duration / 2;
762 const double endTime = startTime + duration; 762 const base::TimeTicks endTime = startTime + duration;
763
764 // Start a page scale animation. 763 // Start a page scale animation.
765 const float pageScaleDelta = 2; 764 const float pageScaleDelta = 2;
766 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale); 765 m_hostImpl->setPageScaleFactorAndLimits(1, minPageScale, maxPageScale);
767 m_hostImpl->startPageScaleAnimation(IntSize(50, 50), false, pageScaleDelta, startTime, duration); 766 m_hostImpl->startPageScaleAnimation(IntSize(50, 50), false, pageScaleDelta, startTime, duration);
768 767
769 // We should immediately get the final zoom and scroll values for the 768 // We should immediately get the final zoom and scroll values for the
770 // animation. 769 // animation.
771 m_hostImpl->animate(halfwayThroughAnimation, halfwayThroughAnimation); 770 m_hostImpl->animate(halfwayThroughAnimation, base::Time());
772 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ; 771 scoped_ptr<ScrollAndScaleSet> scrollInfo = m_hostImpl->processScrollDeltas() ;
773 772
774 if (!Settings::pageScalePinchZoomEnabled()) { 773 if (!Settings::pageScalePinchZoomEnabled()) {
775 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); 774 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
776 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); 775 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25));
777 } else { 776 } else {
778 EXPECT_EQ(scrollInfo->pageScaleDelta, 1); 777 EXPECT_EQ(scrollInfo->pageScaleDelta, 1);
779 EXPECT_TRUE(scrollInfo->scrolls.isEmpty()); 778 EXPECT_TRUE(scrollInfo->scrolls.isEmpty());
780 } 779 }
781 780
782 // Scrolling during the animation is ignored. 781 // Scrolling during the animation is ignored.
783 const IntSize scrollDelta(0, 10); 782 const IntSize scrollDelta(0, 10);
784 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted); 783 EXPECT_EQ(m_hostImpl->scrollBegin(IntPoint(25, 25), InputHandlerClient::Whee l), InputHandlerClient::ScrollStarted);
785 m_hostImpl->scrollBy(IntPoint(), scrollDelta); 784 m_hostImpl->scrollBy(IntPoint(), scrollDelta);
786 m_hostImpl->scrollEnd(); 785 m_hostImpl->scrollEnd();
787 786
788 // The final page scale and scroll deltas should match what we got 787 // The final page scale and scroll deltas should match what we got
789 // earlier. 788 // earlier.
790 m_hostImpl->animate(endTime, endTime); 789 m_hostImpl->animate(endTime, base::Time());
791 scrollInfo = m_hostImpl->processScrollDeltas(); 790 scrollInfo = m_hostImpl->processScrollDeltas();
792 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta); 791 EXPECT_EQ(scrollInfo->pageScaleDelta, pageScaleDelta);
793 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25)); 792 expectContains(*scrollInfo, scrollLayer->id(), IntSize(25, 25));
794 } 793 }
795 794
796 class DidDrawCheckLayer : public TiledLayerImpl { 795 class DidDrawCheckLayer : public TiledLayerImpl {
797 public: 796 public:
798 static scoped_ptr<LayerImpl> create(int id) { return scoped_ptr<LayerImpl>(n ew DidDrawCheckLayer(id)); } 797 static scoped_ptr<LayerImpl> create(int id) { return scoped_ptr<LayerImpl>(n ew DidDrawCheckLayer(id)); }
799 798
800 virtual void didDraw(ResourceProvider*) OVERRIDE 799 virtual void didDraw(ResourceProvider*) OVERRIDE
(...skipping 3575 matching lines...) Expand 10 before | Expand all | Expand 10 after
4376 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat a); 4375 verifyRenderPassTestData(removeRenderPassesCases[testCaseIndex], testDat a);
4377 testCaseIndex++; 4376 testCaseIndex++;
4378 } 4377 }
4379 } 4378 }
4380 4379
4381 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests, 4380 INSTANTIATE_TEST_CASE_P(LayerTreeHostImplTests,
4382 LayerTreeHostImplTest, 4381 LayerTreeHostImplTest,
4383 ::testing::Values(false, true)); 4382 ::testing::Values(false, true));
4384 4383
4385 } // namespace 4384 } // namespace
OLDNEW
« no previous file with comments | « cc/layer_tree_host_impl.cc ('k') | cc/layer_tree_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698