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

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 1297363004: cc: Move animate steps from proxies to LayerTreeHostImpl. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: moveanimatecodetolthi: . Created 5 years, 4 months 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
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 "cc/trees/layer_tree_host_impl.h" 5 #include "cc/trees/layer_tree_host_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
165 virtual bool CreateHostImpl(const LayerTreeSettings& settings, 165 virtual bool CreateHostImpl(const LayerTreeSettings& settings,
166 scoped_ptr<OutputSurface> output_surface) { 166 scoped_ptr<OutputSurface> output_surface) {
167 host_impl_ = LayerTreeHostImpl::Create( 167 host_impl_ = LayerTreeHostImpl::Create(
168 settings, this, &proxy_, &stats_instrumentation_, 168 settings, this, &proxy_, &stats_instrumentation_,
169 &shared_bitmap_manager_, &gpu_memory_buffer_manager_, 169 &shared_bitmap_manager_, &gpu_memory_buffer_manager_,
170 &task_graph_runner_, 0); 170 &task_graph_runner_, 0);
171 bool init = host_impl_->InitializeRenderer(output_surface.Pass()); 171 bool init = host_impl_->InitializeRenderer(output_surface.Pass());
172 host_impl_->SetViewportSize(gfx::Size(10, 10)); 172 host_impl_->SetViewportSize(gfx::Size(10, 10));
173 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f); 173 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 1.f, 1.f);
174 // Set the BeginFrameArgs so that methods which use it are able to. 174 // Set the BeginFrameArgs so that methods which use it are able to.
175 host_impl_->WillBeginImplFrame( 175 host_impl_->WillBeginImplFrame(CreateBeginFrameArgsForTesting(
176 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE)); 176 BEGINFRAME_FROM_HERE,
177 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1)));
178 host_impl_->DidFinishImplFrame();
177 return init; 179 return init;
178 } 180 }
179 181
180 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) { 182 void SetupRootLayerImpl(scoped_ptr<LayerImpl> root) {
181 root->SetPosition(gfx::PointF()); 183 root->SetPosition(gfx::PointF());
182 root->SetBounds(gfx::Size(10, 10)); 184 root->SetBounds(gfx::Size(10, 10));
183 root->SetDrawsContent(true); 185 root->SetDrawsContent(true);
184 root->draw_properties().visible_layer_rect = gfx::Rect(0, 0, 10, 10); 186 root->draw_properties().visible_layer_rect = gfx::Rect(0, 0, 10, 10);
185 root->SetHasRenderSurface(true); 187 root->SetHasRenderSurface(true);
186 host_impl_->active_tree()->SetRootLayer(root.Pass()); 188 host_impl_->active_tree()->SetRootLayer(root.Pass());
(...skipping 1453 matching lines...) Expand 10 before | Expand all | Expand 10 after
1640 DCHECK(scroll_layer); 1642 DCHECK(scroll_layer);
1641 1643
1642 float min_page_scale = 0.5f; 1644 float min_page_scale = 0.5f;
1643 float max_page_scale = 4.f; 1645 float max_page_scale = 4.f;
1644 base::TimeTicks start_time = base::TimeTicks() + 1646 base::TimeTicks start_time = base::TimeTicks() +
1645 base::TimeDelta::FromSeconds(1); 1647 base::TimeDelta::FromSeconds(1);
1646 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); 1648 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
1647 base::TimeTicks halfway_through_animation = start_time + duration / 2; 1649 base::TimeTicks halfway_through_animation = start_time + duration / 2;
1648 base::TimeTicks end_time = start_time + duration; 1650 base::TimeTicks end_time = start_time + duration;
1649 1651
1652 BeginFrameArgs begin_frame_args =
1653 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
1654
1650 // Non-anchor zoom-in 1655 // Non-anchor zoom-in
1651 { 1656 {
1652 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 1657 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
1653 max_page_scale); 1658 max_page_scale);
1654 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); 1659 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50));
1655 1660
1656 did_request_redraw_ = false; 1661 did_request_redraw_ = false;
1657 did_request_animate_ = false; 1662 did_request_animate_ = false;
1658 host_impl_->active_tree()->SetPendingPageScaleAnimation( 1663 host_impl_->active_tree()->SetPendingPageScaleAnimation(
1659 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( 1664 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation(
1660 gfx::Vector2d(), 1665 gfx::Vector2d(),
1661 false, 1666 false,
1662 2.f, 1667 2.f,
1663 duration))); 1668 duration)));
1664 host_impl_->ActivateSyncTree(); 1669 host_impl_->ActivateSyncTree();
1665 EXPECT_FALSE(did_request_redraw_); 1670 EXPECT_FALSE(did_request_redraw_);
1666 EXPECT_TRUE(did_request_animate_); 1671 EXPECT_TRUE(did_request_animate_);
1667 1672
1668 did_request_redraw_ = false; 1673 did_request_redraw_ = false;
1669 did_request_animate_ = false; 1674 did_request_animate_ = false;
1670 host_impl_->Animate(start_time); 1675 begin_frame_args.frame_time = start_time;
1676 host_impl_->WillBeginImplFrame(begin_frame_args);
1677 host_impl_->Animate();
1671 EXPECT_TRUE(did_request_redraw_); 1678 EXPECT_TRUE(did_request_redraw_);
1672 EXPECT_TRUE(did_request_animate_); 1679 EXPECT_TRUE(did_request_animate_);
1680 host_impl_->DidFinishImplFrame();
1673 1681
1674 did_request_redraw_ = false; 1682 did_request_redraw_ = false;
1675 did_request_animate_ = false; 1683 did_request_animate_ = false;
1676 host_impl_->Animate(halfway_through_animation); 1684 begin_frame_args.frame_time = halfway_through_animation;
1685 host_impl_->WillBeginImplFrame(begin_frame_args);
1686 host_impl_->Animate();
1677 EXPECT_TRUE(did_request_redraw_); 1687 EXPECT_TRUE(did_request_redraw_);
1678 EXPECT_TRUE(did_request_animate_); 1688 EXPECT_TRUE(did_request_animate_);
1689 host_impl_->DidFinishImplFrame();
1679 1690
1680 did_request_redraw_ = false; 1691 did_request_redraw_ = false;
1681 did_request_animate_ = false; 1692 did_request_animate_ = false;
1682 did_request_commit_ = false; 1693 did_request_commit_ = false;
1683 host_impl_->Animate(end_time); 1694 begin_frame_args.frame_time = end_time;
1695 host_impl_->WillBeginImplFrame(begin_frame_args);
1696 host_impl_->Animate();
1684 EXPECT_TRUE(did_request_commit_); 1697 EXPECT_TRUE(did_request_commit_);
1685 EXPECT_FALSE(did_request_animate_); 1698 EXPECT_FALSE(did_request_animate_);
1699 host_impl_->DidFinishImplFrame();
1686 1700
1687 scoped_ptr<ScrollAndScaleSet> scroll_info = 1701 scoped_ptr<ScrollAndScaleSet> scroll_info =
1688 host_impl_->ProcessScrollDeltas(); 1702 host_impl_->ProcessScrollDeltas();
1689 EXPECT_EQ(scroll_info->page_scale_delta, 2); 1703 EXPECT_EQ(scroll_info->page_scale_delta, 2);
1690 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), 1704 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(),
1691 gfx::Vector2d(-50, -50))); 1705 gfx::Vector2d(-50, -50)));
1692 } 1706 }
1693 1707
1708 start_time += base::TimeDelta::FromSeconds(10);
1709 halfway_through_animation += base::TimeDelta::FromSeconds(10);
1710 end_time += base::TimeDelta::FromSeconds(10);
1711
1694 // Anchor zoom-out 1712 // Anchor zoom-out
1695 { 1713 {
1696 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 1714 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
1697 max_page_scale); 1715 max_page_scale);
1698 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); 1716 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50));
1699 1717
1700 did_request_redraw_ = false; 1718 did_request_redraw_ = false;
1701 did_request_animate_ = false; 1719 did_request_animate_ = false;
1702 host_impl_->active_tree()->SetPendingPageScaleAnimation( 1720 host_impl_->active_tree()->SetPendingPageScaleAnimation(
1703 scoped_ptr<PendingPageScaleAnimation> (new PendingPageScaleAnimation( 1721 scoped_ptr<PendingPageScaleAnimation> (new PendingPageScaleAnimation(
1704 gfx::Vector2d(25, 25), 1722 gfx::Vector2d(25, 25),
1705 true, 1723 true,
1706 min_page_scale, 1724 min_page_scale,
1707 duration))); 1725 duration)));
1708 host_impl_->ActivateSyncTree(); 1726 host_impl_->ActivateSyncTree();
1709 EXPECT_FALSE(did_request_redraw_); 1727 EXPECT_FALSE(did_request_redraw_);
1710 EXPECT_TRUE(did_request_animate_); 1728 EXPECT_TRUE(did_request_animate_);
1711 1729
1712 did_request_redraw_ = false; 1730 did_request_redraw_ = false;
1713 did_request_animate_ = false; 1731 did_request_animate_ = false;
1714 host_impl_->Animate(start_time); 1732 begin_frame_args.frame_time = start_time;
1733 host_impl_->WillBeginImplFrame(begin_frame_args);
1734 host_impl_->Animate();
1715 EXPECT_TRUE(did_request_redraw_); 1735 EXPECT_TRUE(did_request_redraw_);
1716 EXPECT_TRUE(did_request_animate_); 1736 EXPECT_TRUE(did_request_animate_);
1737 host_impl_->DidFinishImplFrame();
1717 1738
1718 did_request_redraw_ = false; 1739 did_request_redraw_ = false;
1719 did_request_commit_ = false; 1740 did_request_commit_ = false;
1720 did_request_animate_ = false; 1741 did_request_animate_ = false;
1721 host_impl_->Animate(end_time); 1742 begin_frame_args.frame_time = end_time;
1743 host_impl_->WillBeginImplFrame(begin_frame_args);
1744 host_impl_->Animate();
1722 EXPECT_TRUE(did_request_redraw_); 1745 EXPECT_TRUE(did_request_redraw_);
1723 EXPECT_FALSE(did_request_animate_); 1746 EXPECT_FALSE(did_request_animate_);
1724 EXPECT_TRUE(did_request_commit_); 1747 EXPECT_TRUE(did_request_commit_);
1748 host_impl_->DidFinishImplFrame();
1725 1749
1726 scoped_ptr<ScrollAndScaleSet> scroll_info = 1750 scoped_ptr<ScrollAndScaleSet> scroll_info =
1727 host_impl_->ProcessScrollDeltas(); 1751 host_impl_->ProcessScrollDeltas();
1728 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale); 1752 EXPECT_EQ(scroll_info->page_scale_delta, min_page_scale);
1729 // Pushed to (0,0) via clamping against contents layer size. 1753 // Pushed to (0,0) via clamping against contents layer size.
1730 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), 1754 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(),
1731 gfx::Vector2d(-50, -50))); 1755 gfx::Vector2d(-50, -50)));
1732 } 1756 }
1733 } 1757 }
1734 1758
1735 TEST_F(LayerTreeHostImplTest, PageScaleAnimationNoOp) { 1759 TEST_F(LayerTreeHostImplTest, PageScaleAnimationNoOp) {
1736 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 1760 SetupScrollAndContentsLayers(gfx::Size(100, 100));
1737 host_impl_->SetViewportSize(gfx::Size(50, 50)); 1761 host_impl_->SetViewportSize(gfx::Size(50, 50));
1738 DrawFrame(); 1762 DrawFrame();
1739 1763
1740 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); 1764 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer();
1741 DCHECK(scroll_layer); 1765 DCHECK(scroll_layer);
1742 1766
1743 float min_page_scale = 0.5f; 1767 float min_page_scale = 0.5f;
1744 float max_page_scale = 4.f; 1768 float max_page_scale = 4.f;
1745 base::TimeTicks start_time = base::TimeTicks() + 1769 base::TimeTicks start_time = base::TimeTicks() +
1746 base::TimeDelta::FromSeconds(1); 1770 base::TimeDelta::FromSeconds(1);
1747 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); 1771 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
1748 base::TimeTicks halfway_through_animation = start_time + duration / 2; 1772 base::TimeTicks halfway_through_animation = start_time + duration / 2;
1749 base::TimeTicks end_time = start_time + duration; 1773 base::TimeTicks end_time = start_time + duration;
1750 1774
1775 BeginFrameArgs begin_frame_args =
1776 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
1777
1751 // Anchor zoom with unchanged page scale should not change scroll or scale. 1778 // Anchor zoom with unchanged page scale should not change scroll or scale.
1752 { 1779 {
1753 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale, 1780 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, min_page_scale,
1754 max_page_scale); 1781 max_page_scale);
1755 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); 1782 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50));
1756 1783
1757 host_impl_->active_tree()->SetPendingPageScaleAnimation( 1784 host_impl_->active_tree()->SetPendingPageScaleAnimation(
1758 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( 1785 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation(
1759 gfx::Vector2d(), 1786 gfx::Vector2d(),
1760 true, 1787 true,
1761 1.f, 1788 1.f,
1762 duration))); 1789 duration)));
1763 host_impl_->ActivateSyncTree(); 1790 host_impl_->ActivateSyncTree();
1764 host_impl_->Animate(start_time); 1791 begin_frame_args.frame_time = start_time;
1765 host_impl_->Animate(halfway_through_animation); 1792 host_impl_->WillBeginImplFrame(begin_frame_args);
1793 host_impl_->Animate();
1794 host_impl_->DidFinishImplFrame();
1795
1796 begin_frame_args.frame_time = halfway_through_animation;
1797 host_impl_->WillBeginImplFrame(begin_frame_args);
1798 host_impl_->Animate();
1766 EXPECT_TRUE(did_request_redraw_); 1799 EXPECT_TRUE(did_request_redraw_);
1767 host_impl_->Animate(end_time); 1800 host_impl_->DidFinishImplFrame();
1801
1802 begin_frame_args.frame_time = end_time;
1803 host_impl_->WillBeginImplFrame(begin_frame_args);
1804 host_impl_->Animate();
1768 EXPECT_TRUE(did_request_commit_); 1805 EXPECT_TRUE(did_request_commit_);
1806 host_impl_->DidFinishImplFrame();
1769 1807
1770 scoped_ptr<ScrollAndScaleSet> scroll_info = 1808 scoped_ptr<ScrollAndScaleSet> scroll_info =
1771 host_impl_->ProcessScrollDeltas(); 1809 host_impl_->ProcessScrollDeltas();
1772 EXPECT_EQ(scroll_info->page_scale_delta, 1); 1810 EXPECT_EQ(scroll_info->page_scale_delta, 1);
1773 ExpectNone(*scroll_info, scroll_layer->id()); 1811 ExpectNone(*scroll_info, scroll_layer->id());
1774 } 1812 }
1775 } 1813 }
1776 1814
1777 TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) { 1815 TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) {
1778 host_impl_->CreatePendingTree(); 1816 host_impl_->CreatePendingTree();
(...skipping 14 matching lines...) Expand all
1793 host_impl_->ActivateSyncTree(); 1831 host_impl_->ActivateSyncTree();
1794 1832
1795 base::TimeTicks start_time = base::TimeTicks() + 1833 base::TimeTicks start_time = base::TimeTicks() +
1796 base::TimeDelta::FromSeconds(1); 1834 base::TimeDelta::FromSeconds(1);
1797 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); 1835 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
1798 base::TimeTicks third_through_animation = start_time + duration / 3; 1836 base::TimeTicks third_through_animation = start_time + duration / 3;
1799 base::TimeTicks halfway_through_animation = start_time + duration / 2; 1837 base::TimeTicks halfway_through_animation = start_time + duration / 2;
1800 base::TimeTicks end_time = start_time + duration; 1838 base::TimeTicks end_time = start_time + duration;
1801 float target_scale = 2.f; 1839 float target_scale = 2.f;
1802 1840
1841 BeginFrameArgs begin_frame_args =
1842 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
1843
1803 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); 1844 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50));
1804 1845
1805 // Make sure TakePageScaleAnimation works properly. 1846 // Make sure TakePageScaleAnimation works properly.
1806 1847
1807 host_impl_->sync_tree()->SetPendingPageScaleAnimation( 1848 host_impl_->sync_tree()->SetPendingPageScaleAnimation(
1808 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( 1849 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation(
1809 gfx::Vector2d(), 1850 gfx::Vector2d(),
1810 false, 1851 false,
1811 target_scale, 1852 target_scale,
1812 duration))); 1853 duration)));
1813 scoped_ptr<PendingPageScaleAnimation> psa = 1854 scoped_ptr<PendingPageScaleAnimation> psa =
1814 host_impl_->sync_tree()->TakePendingPageScaleAnimation(); 1855 host_impl_->sync_tree()->TakePendingPageScaleAnimation();
1815 EXPECT_EQ(target_scale, psa->scale); 1856 EXPECT_EQ(target_scale, psa->scale);
1816 EXPECT_EQ(duration, psa->duration); 1857 EXPECT_EQ(duration, psa->duration);
1817 EXPECT_EQ(nullptr, host_impl_->sync_tree()->TakePendingPageScaleAnimation()); 1858 EXPECT_EQ(nullptr, host_impl_->sync_tree()->TakePendingPageScaleAnimation());
1818 1859
1819 // Recreate the PSA. Nothing should happen here since the tree containing the 1860 // Recreate the PSA. Nothing should happen here since the tree containing the
1820 // PSA hasn't been activated yet. 1861 // PSA hasn't been activated yet.
1821 did_request_redraw_ = false; 1862 did_request_redraw_ = false;
1822 did_request_animate_ = false; 1863 did_request_animate_ = false;
1823 host_impl_->sync_tree()->SetPendingPageScaleAnimation( 1864 host_impl_->sync_tree()->SetPendingPageScaleAnimation(
1824 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( 1865 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation(
1825 gfx::Vector2d(), 1866 gfx::Vector2d(),
1826 false, 1867 false,
1827 target_scale, 1868 target_scale,
1828 duration))); 1869 duration)));
1829 host_impl_->Animate(halfway_through_animation); 1870 begin_frame_args.frame_time = halfway_through_animation;
1871 host_impl_->WillBeginImplFrame(begin_frame_args);
1872 host_impl_->Animate();
1830 EXPECT_FALSE(did_request_animate_); 1873 EXPECT_FALSE(did_request_animate_);
1831 EXPECT_FALSE(did_request_redraw_); 1874 EXPECT_FALSE(did_request_redraw_);
1875 host_impl_->DidFinishImplFrame();
1832 1876
1833 // Activate the sync tree. This should cause the animation to become enabled. 1877 // Activate the sync tree. This should cause the animation to become enabled.
1834 // It should also clear the pointer on the sync tree. 1878 // It should also clear the pointer on the sync tree.
1835 host_impl_->ActivateSyncTree(); 1879 host_impl_->ActivateSyncTree();
1836 EXPECT_EQ(nullptr, 1880 EXPECT_EQ(nullptr,
1837 host_impl_->sync_tree()->TakePendingPageScaleAnimation().get()); 1881 host_impl_->sync_tree()->TakePendingPageScaleAnimation().get());
1838 EXPECT_FALSE(did_request_redraw_); 1882 EXPECT_FALSE(did_request_redraw_);
1839 EXPECT_TRUE(did_request_animate_); 1883 EXPECT_TRUE(did_request_animate_);
1840 1884
1885 start_time += base::TimeDelta::FromSeconds(10);
1886 third_through_animation += base::TimeDelta::FromSeconds(10);
1887 halfway_through_animation += base::TimeDelta::FromSeconds(10);
1888 end_time += base::TimeDelta::FromSeconds(10);
1889
1841 // From here on, make sure the animation runs as normal. 1890 // From here on, make sure the animation runs as normal.
1842 did_request_redraw_ = false; 1891 did_request_redraw_ = false;
1843 did_request_animate_ = false; 1892 did_request_animate_ = false;
1844 host_impl_->Animate(start_time); 1893 begin_frame_args.frame_time = start_time;
1894 host_impl_->WillBeginImplFrame(begin_frame_args);
1895 host_impl_->Animate();
1845 EXPECT_TRUE(did_request_redraw_); 1896 EXPECT_TRUE(did_request_redraw_);
1846 EXPECT_TRUE(did_request_animate_); 1897 EXPECT_TRUE(did_request_animate_);
1898 host_impl_->DidFinishImplFrame();
1847 1899
1848 did_request_redraw_ = false; 1900 did_request_redraw_ = false;
1849 did_request_animate_ = false; 1901 did_request_animate_ = false;
1850 host_impl_->Animate(third_through_animation); 1902 begin_frame_args.frame_time = third_through_animation;
1903 host_impl_->WillBeginImplFrame(begin_frame_args);
1904 host_impl_->Animate();
1851 EXPECT_TRUE(did_request_redraw_); 1905 EXPECT_TRUE(did_request_redraw_);
1852 EXPECT_TRUE(did_request_animate_); 1906 EXPECT_TRUE(did_request_animate_);
1907 host_impl_->DidFinishImplFrame();
1853 1908
1854 // Another activation shouldn't have any effect on the animation. 1909 // Another activation shouldn't have any effect on the animation.
1855 host_impl_->ActivateSyncTree(); 1910 host_impl_->ActivateSyncTree();
1856 1911
1857 did_request_redraw_ = false; 1912 did_request_redraw_ = false;
1858 did_request_animate_ = false; 1913 did_request_animate_ = false;
1859 host_impl_->Animate(halfway_through_animation); 1914 begin_frame_args.frame_time = halfway_through_animation;
1915 host_impl_->WillBeginImplFrame(begin_frame_args);
1916 host_impl_->Animate();
1860 EXPECT_TRUE(did_request_redraw_); 1917 EXPECT_TRUE(did_request_redraw_);
1861 EXPECT_TRUE(did_request_animate_); 1918 EXPECT_TRUE(did_request_animate_);
1919 host_impl_->DidFinishImplFrame();
1862 1920
1863 did_request_redraw_ = false; 1921 did_request_redraw_ = false;
1864 did_request_animate_ = false; 1922 did_request_animate_ = false;
1865 did_request_commit_ = false; 1923 did_request_commit_ = false;
1866 host_impl_->Animate(end_time); 1924 begin_frame_args.frame_time = end_time;
1925 host_impl_->WillBeginImplFrame(begin_frame_args);
1926 host_impl_->Animate();
1867 EXPECT_TRUE(did_request_commit_); 1927 EXPECT_TRUE(did_request_commit_);
1868 EXPECT_FALSE(did_request_animate_); 1928 EXPECT_FALSE(did_request_animate_);
1929 host_impl_->DidFinishImplFrame();
1869 1930
1870 scoped_ptr<ScrollAndScaleSet> scroll_info = 1931 scoped_ptr<ScrollAndScaleSet> scroll_info =
1871 host_impl_->ProcessScrollDeltas(); 1932 host_impl_->ProcessScrollDeltas();
1872 EXPECT_EQ(scroll_info->page_scale_delta, target_scale); 1933 EXPECT_EQ(scroll_info->page_scale_delta, target_scale);
1873 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(), 1934 EXPECT_TRUE(ScrollInfoContains(*scroll_info, scroll_layer->id(),
1874 gfx::Vector2d(-50, -50))); 1935 gfx::Vector2d(-50, -50)));
1875 } 1936 }
1876 1937
1877 TEST_F(LayerTreeHostImplTest, PageScaleAnimationCompletedNotification) { 1938 TEST_F(LayerTreeHostImplTest, PageScaleAnimationCompletedNotification) {
1878 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 1939 SetupScrollAndContentsLayers(gfx::Size(100, 100));
1879 host_impl_->SetViewportSize(gfx::Size(50, 50)); 1940 host_impl_->SetViewportSize(gfx::Size(50, 50));
1880 DrawFrame(); 1941 DrawFrame();
1881 1942
1882 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer(); 1943 LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer();
1883 DCHECK(scroll_layer); 1944 DCHECK(scroll_layer);
1884 1945
1885 base::TimeTicks start_time = 1946 base::TimeTicks start_time =
1886 base::TimeTicks() + base::TimeDelta::FromSeconds(1); 1947 base::TimeTicks() + base::TimeDelta::FromSeconds(1);
1887 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100); 1948 base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
1888 base::TimeTicks halfway_through_animation = start_time + duration / 2; 1949 base::TimeTicks halfway_through_animation = start_time + duration / 2;
1889 base::TimeTicks end_time = start_time + duration; 1950 base::TimeTicks end_time = start_time + duration;
1890 1951
1952 BeginFrameArgs begin_frame_args =
1953 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
1954
1891 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f); 1955 host_impl_->active_tree()->PushPageScaleFromMainThread(1.f, 0.5f, 4.f);
1892 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50)); 1956 scroll_layer->PushScrollOffsetFromMainThread(gfx::ScrollOffset(50, 50));
1893 1957
1894 did_complete_page_scale_animation_ = false; 1958 did_complete_page_scale_animation_ = false;
1895 host_impl_->active_tree()->SetPendingPageScaleAnimation( 1959 host_impl_->active_tree()->SetPendingPageScaleAnimation(
1896 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation( 1960 scoped_ptr<PendingPageScaleAnimation>(new PendingPageScaleAnimation(
1897 gfx::Vector2d(), false, 2.f, duration))); 1961 gfx::Vector2d(), false, 2.f, duration)));
1898 host_impl_->ActivateSyncTree(); 1962 host_impl_->ActivateSyncTree();
1899 host_impl_->Animate(start_time); 1963 begin_frame_args.frame_time = start_time;
1964 host_impl_->WillBeginImplFrame(begin_frame_args);
1965 host_impl_->Animate();
1900 EXPECT_FALSE(did_complete_page_scale_animation_); 1966 EXPECT_FALSE(did_complete_page_scale_animation_);
1967 host_impl_->DidFinishImplFrame();
1901 1968
1902 host_impl_->Animate(halfway_through_animation); 1969 begin_frame_args.frame_time = halfway_through_animation;
1970 host_impl_->WillBeginImplFrame(begin_frame_args);
1971 host_impl_->Animate();
1903 EXPECT_FALSE(did_complete_page_scale_animation_); 1972 EXPECT_FALSE(did_complete_page_scale_animation_);
1973 host_impl_->DidFinishImplFrame();
1904 1974
1905 host_impl_->Animate(end_time); 1975 begin_frame_args.frame_time = end_time;
1976 host_impl_->WillBeginImplFrame(begin_frame_args);
1977 host_impl_->Animate();
1906 EXPECT_TRUE(did_complete_page_scale_animation_); 1978 EXPECT_TRUE(did_complete_page_scale_animation_);
1979 host_impl_->DidFinishImplFrame();
1907 } 1980 }
1908 1981
1909 class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl { 1982 class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl {
1910 public: 1983 public:
1911 LayerTreeHostImplOverridePhysicalTime( 1984 LayerTreeHostImplOverridePhysicalTime(
1912 const LayerTreeSettings& settings, 1985 const LayerTreeSettings& settings,
1913 LayerTreeHostImplClient* client, 1986 LayerTreeHostImplClient* client,
1914 Proxy* proxy, 1987 Proxy* proxy,
1915 SharedBitmapManager* manager, 1988 SharedBitmapManager* manager,
1916 TaskGraphRunner* task_graph_runner, 1989 TaskGraphRunner* task_graph_runner,
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
2010 2083
2011 fake_now += requested_animation_delay_; 2084 fake_now += requested_animation_delay_;
2012 requested_animation_delay_ = base::TimeDelta(); 2085 requested_animation_delay_ = base::TimeDelta();
2013 animation_task_.Run(); 2086 animation_task_.Run();
2014 animation_task_ = base::Closure(); 2087 animation_task_ = base::Closure();
2015 EXPECT_TRUE(did_request_animate_); 2088 EXPECT_TRUE(did_request_animate_);
2016 did_request_animate_ = false; 2089 did_request_animate_ = false;
2017 EXPECT_FALSE(did_request_redraw_); 2090 EXPECT_FALSE(did_request_redraw_);
2018 2091
2019 // After the scrollbar animation begins, we should start getting redraws. 2092 // After the scrollbar animation begins, we should start getting redraws.
2020 host_impl_->Animate(fake_now); 2093 BeginFrameArgs begin_frame_args =
2094 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, fake_now);
2095 host_impl_->WillBeginImplFrame(begin_frame_args);
2096 host_impl_->Animate();
2021 EXPECT_TRUE(did_request_animate_); 2097 EXPECT_TRUE(did_request_animate_);
2022 did_request_animate_ = false; 2098 did_request_animate_ = false;
2023 EXPECT_TRUE(did_request_redraw_); 2099 EXPECT_TRUE(did_request_redraw_);
2024 did_request_redraw_ = false; 2100 did_request_redraw_ = false;
2025 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_); 2101 EXPECT_EQ(base::TimeDelta(), requested_animation_delay_);
2026 EXPECT_TRUE(animation_task_.Equals(base::Closure())); 2102 EXPECT_TRUE(animation_task_.Equals(base::Closure()));
2103 host_impl_->DidFinishImplFrame();
2027 2104
2028 // Setting the scroll offset outside a scroll should also cause the 2105 // Setting the scroll offset outside a scroll should also cause the
2029 // scrollbar to appear and to schedule a scrollbar animation. 2106 // scrollbar to appear and to schedule a scrollbar animation.
2030 host_impl_->InnerViewportScrollLayer()->PushScrollOffsetFromMainThread( 2107 host_impl_->InnerViewportScrollLayer()->PushScrollOffsetFromMainThread(
2031 gfx::ScrollOffset(5, 5)); 2108 gfx::ScrollOffset(5, 5));
2032 EXPECT_FALSE(did_request_animate_); 2109 EXPECT_FALSE(did_request_animate_);
2033 EXPECT_FALSE(did_request_redraw_); 2110 EXPECT_FALSE(did_request_redraw_);
2034 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20), 2111 EXPECT_EQ(base::TimeDelta::FromMilliseconds(20),
2035 requested_animation_delay_); 2112 requested_animation_delay_);
2036 EXPECT_FALSE(animation_task_.Equals(base::Closure())); 2113 EXPECT_FALSE(animation_task_.Equals(base::Closure()));
(...skipping 4968 matching lines...) Expand 10 before | Expand all | Expand 10 after
7005 7082
7006 protected: 7083 protected:
7007 static const int top_controls_height_; 7084 static const int top_controls_height_;
7008 }; 7085 };
7009 7086
7010 const int LayerTreeHostImplWithTopControlsTest::top_controls_height_ = 50; 7087 const int LayerTreeHostImplWithTopControlsTest::top_controls_height_ = 50;
7011 7088
7012 TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) { 7089 TEST_F(LayerTreeHostImplWithTopControlsTest, NoIdleAnimations) {
7013 SetupScrollAndContentsLayers(gfx::Size(100, 100)) 7090 SetupScrollAndContentsLayers(gfx::Size(100, 100))
7014 ->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 10)); 7091 ->PushScrollOffsetFromMainThread(gfx::ScrollOffset(0, 10));
7015 host_impl_->Animate(base::TimeTicks()); 7092 BeginFrameArgs begin_frame_args =
7093 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
7094 host_impl_->WillBeginImplFrame(begin_frame_args);
7095 host_impl_->Animate();
7016 EXPECT_FALSE(did_request_redraw_); 7096 EXPECT_FALSE(did_request_redraw_);
7097 host_impl_->DidFinishImplFrame();
7017 } 7098 }
7018 7099
7019 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsHeightIsCommitted) { 7100 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsHeightIsCommitted) {
7020 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 7101 SetupScrollAndContentsLayers(gfx::Size(100, 100));
7021 EXPECT_FALSE(did_request_redraw_); 7102 EXPECT_FALSE(did_request_redraw_);
7022 host_impl_->CreatePendingTree(); 7103 host_impl_->CreatePendingTree();
7023 host_impl_->sync_tree()->set_top_controls_height(100); 7104 host_impl_->sync_tree()->set_top_controls_height(100);
7024 host_impl_->ActivateSyncTree(); 7105 host_impl_->ActivateSyncTree();
7025 EXPECT_EQ(100, host_impl_->top_controls_manager()->TopControlsHeight()); 7106 EXPECT_EQ(100, host_impl_->top_controls_manager()->TopControlsHeight());
7026 } 7107 }
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after
7175 7256
7176 // End the scroll while the controls are still offset from their limit. 7257 // End the scroll while the controls are still offset from their limit.
7177 host_impl_->ScrollEnd(); 7258 host_impl_->ScrollEnd();
7178 ASSERT_TRUE(host_impl_->top_controls_manager()->animation()); 7259 ASSERT_TRUE(host_impl_->top_controls_manager()->animation());
7179 EXPECT_TRUE(did_request_animate_); 7260 EXPECT_TRUE(did_request_animate_);
7180 EXPECT_TRUE(did_request_redraw_); 7261 EXPECT_TRUE(did_request_redraw_);
7181 EXPECT_FALSE(did_request_commit_); 7262 EXPECT_FALSE(did_request_commit_);
7182 7263
7183 // The top controls should properly animate until finished, despite the scroll 7264 // The top controls should properly animate until finished, despite the scroll
7184 // offset being at the origin. 7265 // offset being at the origin.
7185 base::TimeTicks animation_time = base::TimeTicks::Now(); 7266 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting(
7267 BEGINFRAME_FROM_HERE, base::TimeTicks::Now());
7186 while (did_request_animate_) { 7268 while (did_request_animate_) {
7187 did_request_redraw_ = false; 7269 did_request_redraw_ = false;
7188 did_request_animate_ = false; 7270 did_request_animate_ = false;
7189 did_request_commit_ = false; 7271 did_request_commit_ = false;
7190 7272
7191 float old_offset = 7273 float old_offset =
7192 host_impl_->top_controls_manager()->ControlsTopOffset(); 7274 host_impl_->top_controls_manager()->ControlsTopOffset();
7193 7275
7194 animation_time += base::TimeDelta::FromMilliseconds(5); 7276 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5);
7195 host_impl_->Animate(animation_time); 7277 host_impl_->WillBeginImplFrame(begin_frame_args);
7278 host_impl_->Animate();
7196 EXPECT_EQ(gfx::Vector2dF().ToString(), 7279 EXPECT_EQ(gfx::Vector2dF().ToString(),
7197 scroll_layer->CurrentScrollOffset().ToString()); 7280 scroll_layer->CurrentScrollOffset().ToString());
7198 7281
7199 float new_offset = 7282 float new_offset =
7200 host_impl_->top_controls_manager()->ControlsTopOffset(); 7283 host_impl_->top_controls_manager()->ControlsTopOffset();
7201 7284
7202 // No commit is needed as the controls are animating the content offset, 7285 // No commit is needed as the controls are animating the content offset,
7203 // not the scroll offset. 7286 // not the scroll offset.
7204 EXPECT_FALSE(did_request_commit_); 7287 EXPECT_FALSE(did_request_commit_);
7205 7288
7206 if (new_offset != old_offset) 7289 if (new_offset != old_offset)
7207 EXPECT_TRUE(did_request_redraw_); 7290 EXPECT_TRUE(did_request_redraw_);
7208 7291
7209 if (new_offset != 0) { 7292 if (new_offset != 0) {
7210 EXPECT_TRUE(host_impl_->top_controls_manager()->animation()); 7293 EXPECT_TRUE(host_impl_->top_controls_manager()->animation());
7211 EXPECT_TRUE(did_request_animate_); 7294 EXPECT_TRUE(did_request_animate_);
7212 } 7295 }
7296 host_impl_->DidFinishImplFrame();
7213 } 7297 }
7214 EXPECT_FALSE(host_impl_->top_controls_manager()->animation()); 7298 EXPECT_FALSE(host_impl_->top_controls_manager()->animation());
7215 } 7299 }
7216 7300
7217 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) { 7301 TEST_F(LayerTreeHostImplWithTopControlsTest, TopControlsAnimationAfterScroll) {
7218 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); 7302 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200));
7219 host_impl_->SetViewportSize(gfx::Size(100, 100)); 7303 host_impl_->SetViewportSize(gfx::Size(100, 100));
7220 host_impl_->top_controls_manager()->UpdateTopControlsState( 7304 host_impl_->top_controls_manager()->UpdateTopControlsState(
7221 BOTH, SHOWN, false); 7305 BOTH, SHOWN, false);
7222 float initial_scroll_offset = 50; 7306 float initial_scroll_offset = 50;
(...skipping 22 matching lines...) Expand all
7245 did_request_commit_ = false; 7329 did_request_commit_ = false;
7246 7330
7247 // End the scroll while the controls are still offset from the limit. 7331 // End the scroll while the controls are still offset from the limit.
7248 host_impl_->ScrollEnd(); 7332 host_impl_->ScrollEnd();
7249 ASSERT_TRUE(host_impl_->top_controls_manager()->animation()); 7333 ASSERT_TRUE(host_impl_->top_controls_manager()->animation());
7250 EXPECT_TRUE(did_request_animate_); 7334 EXPECT_TRUE(did_request_animate_);
7251 EXPECT_TRUE(did_request_redraw_); 7335 EXPECT_TRUE(did_request_redraw_);
7252 EXPECT_FALSE(did_request_commit_); 7336 EXPECT_FALSE(did_request_commit_);
7253 7337
7254 // Animate the top controls to the limit. 7338 // Animate the top controls to the limit.
7255 base::TimeTicks animation_time = base::TimeTicks::Now(); 7339 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting(
7340 BEGINFRAME_FROM_HERE, base::TimeTicks::Now());
7256 while (did_request_animate_) { 7341 while (did_request_animate_) {
7257 did_request_redraw_ = false; 7342 did_request_redraw_ = false;
7258 did_request_animate_ = false; 7343 did_request_animate_ = false;
7259 did_request_commit_ = false; 7344 did_request_commit_ = false;
7260 7345
7261 float old_offset = 7346 float old_offset =
7262 host_impl_->top_controls_manager()->ControlsTopOffset(); 7347 host_impl_->top_controls_manager()->ControlsTopOffset();
7263 7348
7264 animation_time += base::TimeDelta::FromMilliseconds(5); 7349 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5);
7265 host_impl_->Animate(animation_time); 7350 host_impl_->WillBeginImplFrame(begin_frame_args);
7351 host_impl_->Animate();
7266 7352
7267 float new_offset = 7353 float new_offset =
7268 host_impl_->top_controls_manager()->ControlsTopOffset(); 7354 host_impl_->top_controls_manager()->ControlsTopOffset();
7269 7355
7270 if (new_offset != old_offset) { 7356 if (new_offset != old_offset) {
7271 EXPECT_TRUE(did_request_redraw_); 7357 EXPECT_TRUE(did_request_redraw_);
7272 EXPECT_TRUE(did_request_commit_); 7358 EXPECT_TRUE(did_request_commit_);
7273 } 7359 }
7360 host_impl_->DidFinishImplFrame();
7274 } 7361 }
7275 EXPECT_FALSE(host_impl_->top_controls_manager()->animation()); 7362 EXPECT_FALSE(host_impl_->top_controls_manager()->animation());
7276 EXPECT_EQ(-top_controls_height_, 7363 EXPECT_EQ(-top_controls_height_,
7277 host_impl_->top_controls_manager()->ControlsTopOffset()); 7364 host_impl_->top_controls_manager()->ControlsTopOffset());
7278 } 7365 }
7279 7366
7280 TEST_F(LayerTreeHostImplWithTopControlsTest, 7367 TEST_F(LayerTreeHostImplWithTopControlsTest,
7281 TopControlsAnimationAfterMainThreadFlingStopped) { 7368 TopControlsAnimationAfterMainThreadFlingStopped) {
7282 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200)); 7369 LayerImpl* scroll_layer = SetupScrollAndContentsLayers(gfx::Size(100, 200));
7283 host_impl_->SetViewportSize(gfx::Size(100, 100)); 7370 host_impl_->SetViewportSize(gfx::Size(100, 100));
(...skipping 25 matching lines...) Expand all
7309 did_request_commit_ = false; 7396 did_request_commit_ = false;
7310 7397
7311 // End the fling while the controls are still offset from the limit. 7398 // End the fling while the controls are still offset from the limit.
7312 host_impl_->MainThreadHasStoppedFlinging(); 7399 host_impl_->MainThreadHasStoppedFlinging();
7313 ASSERT_TRUE(host_impl_->top_controls_manager()->animation()); 7400 ASSERT_TRUE(host_impl_->top_controls_manager()->animation());
7314 EXPECT_TRUE(did_request_animate_); 7401 EXPECT_TRUE(did_request_animate_);
7315 EXPECT_TRUE(did_request_redraw_); 7402 EXPECT_TRUE(did_request_redraw_);
7316 EXPECT_FALSE(did_request_commit_); 7403 EXPECT_FALSE(did_request_commit_);
7317 7404
7318 // Animate the top controls to the limit. 7405 // Animate the top controls to the limit.
7319 base::TimeTicks animation_time = base::TimeTicks::Now(); 7406 BeginFrameArgs begin_frame_args = CreateBeginFrameArgsForTesting(
7407 BEGINFRAME_FROM_HERE, base::TimeTicks::Now());
7320 while (did_request_animate_) { 7408 while (did_request_animate_) {
7321 did_request_redraw_ = false; 7409 did_request_redraw_ = false;
7322 did_request_animate_ = false; 7410 did_request_animate_ = false;
7323 did_request_commit_ = false; 7411 did_request_commit_ = false;
7324 7412
7325 float old_offset = host_impl_->top_controls_manager()->ControlsTopOffset(); 7413 float old_offset = host_impl_->top_controls_manager()->ControlsTopOffset();
7326 7414
7327 animation_time += base::TimeDelta::FromMilliseconds(5); 7415 begin_frame_args.frame_time += base::TimeDelta::FromMilliseconds(5);
7328 host_impl_->Animate(animation_time); 7416 host_impl_->WillBeginImplFrame(begin_frame_args);
7417 host_impl_->Animate();
7329 7418
7330 float new_offset = host_impl_->top_controls_manager()->ControlsTopOffset(); 7419 float new_offset = host_impl_->top_controls_manager()->ControlsTopOffset();
7331 7420
7332 if (new_offset != old_offset) { 7421 if (new_offset != old_offset) {
7333 EXPECT_TRUE(did_request_redraw_); 7422 EXPECT_TRUE(did_request_redraw_);
7334 EXPECT_TRUE(did_request_commit_); 7423 EXPECT_TRUE(did_request_commit_);
7335 } 7424 }
7425 host_impl_->DidFinishImplFrame();
7336 } 7426 }
7337 EXPECT_FALSE(host_impl_->top_controls_manager()->animation()); 7427 EXPECT_FALSE(host_impl_->top_controls_manager()->animation());
7338 EXPECT_EQ(-top_controls_height_, 7428 EXPECT_EQ(-top_controls_height_,
7339 host_impl_->top_controls_manager()->ControlsTopOffset()); 7429 host_impl_->top_controls_manager()->ControlsTopOffset());
7340 } 7430 }
7341 7431
7342 TEST_F(LayerTreeHostImplWithTopControlsTest, 7432 TEST_F(LayerTreeHostImplWithTopControlsTest,
7343 TopControlsScrollDeltaInOverScroll) { 7433 TopControlsScrollDeltaInOverScroll) {
7344 // Verifies that the overscroll delta should not have accumulated in 7434 // Verifies that the overscroll delta should not have accumulated in
7345 // the top controls if we do a hide and show without releasing finger. 7435 // the top controls if we do a hide and show without releasing finger.
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
7771 external_transform, layer->draw_properties().target_space_transform); 7861 external_transform, layer->draw_properties().target_space_transform);
7772 } 7862 }
7773 7863
7774 TEST_F(LayerTreeHostImplTest, ScrollAnimated) { 7864 TEST_F(LayerTreeHostImplTest, ScrollAnimated) {
7775 SetupScrollAndContentsLayers(gfx::Size(100, 200)); 7865 SetupScrollAndContentsLayers(gfx::Size(100, 200));
7776 DrawFrame(); 7866 DrawFrame();
7777 7867
7778 base::TimeTicks start_time = 7868 base::TimeTicks start_time =
7779 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); 7869 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100);
7780 7870
7871 BeginFrameArgs begin_frame_args =
7872 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
7873
7781 EXPECT_EQ(InputHandler::SCROLL_STARTED, 7874 EXPECT_EQ(InputHandler::SCROLL_STARTED,
7782 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); 7875 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)));
7783 7876
7784 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); 7877 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
7785 7878
7786 host_impl_->Animate(start_time); 7879 begin_frame_args.frame_time = start_time;
7880 host_impl_->WillBeginImplFrame(begin_frame_args);
7881 host_impl_->Animate();
7787 host_impl_->UpdateAnimationState(true); 7882 host_impl_->UpdateAnimationState(true);
7788 7883
7789 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); 7884 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset());
7885 host_impl_->DidFinishImplFrame();
7790 7886
7791 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(50)); 7887 begin_frame_args.frame_time =
7888 start_time + base::TimeDelta::FromMilliseconds(50);
7889 host_impl_->WillBeginImplFrame(begin_frame_args);
7890 host_impl_->Animate();
7792 host_impl_->UpdateAnimationState(true); 7891 host_impl_->UpdateAnimationState(true);
7793 7892
7794 float y = scrolling_layer->CurrentScrollOffset().y(); 7893 float y = scrolling_layer->CurrentScrollOffset().y();
7795 EXPECT_TRUE(y > 1 && y < 49); 7894 EXPECT_TRUE(y > 1 && y < 49);
7796 7895
7797 // Update target. 7896 // Update target.
7798 EXPECT_EQ(InputHandler::SCROLL_STARTED, 7897 EXPECT_EQ(InputHandler::SCROLL_STARTED,
7799 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); 7898 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)));
7899 host_impl_->DidFinishImplFrame();
7800 7900
7801 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(200)); 7901 begin_frame_args.frame_time =
7902 start_time + base::TimeDelta::FromMilliseconds(200);
7903 host_impl_->WillBeginImplFrame(begin_frame_args);
7904 host_impl_->Animate();
7802 host_impl_->UpdateAnimationState(true); 7905 host_impl_->UpdateAnimationState(true);
7803 7906
7804 y = scrolling_layer->CurrentScrollOffset().y(); 7907 y = scrolling_layer->CurrentScrollOffset().y();
7805 EXPECT_TRUE(y > 50 && y < 100); 7908 EXPECT_TRUE(y > 50 && y < 100);
7806 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); 7909 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer());
7910 host_impl_->DidFinishImplFrame();
7807 7911
7808 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250)); 7912 begin_frame_args.frame_time =
7913 start_time + base::TimeDelta::FromMilliseconds(250);
7914 host_impl_->WillBeginImplFrame(begin_frame_args);
7915 host_impl_->Animate();
7809 host_impl_->UpdateAnimationState(true); 7916 host_impl_->UpdateAnimationState(true);
7810 7917
7811 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), 7918 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100),
7812 scrolling_layer->CurrentScrollOffset()); 7919 scrolling_layer->CurrentScrollOffset());
7813 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); 7920 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
7921 host_impl_->DidFinishImplFrame();
7814 } 7922 }
7815 7923
7816 // Evolved from LayerTreeHostImplTest.ScrollAnimated. 7924 // Evolved from LayerTreeHostImplTest.ScrollAnimated.
7817 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) { 7925 TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) {
7818 SetupScrollAndContentsLayers(gfx::Size(100, 200)); 7926 SetupScrollAndContentsLayers(gfx::Size(100, 200));
7819 DrawFrame(); 7927 DrawFrame();
7820 7928
7821 base::TimeTicks start_time = 7929 base::TimeTicks start_time =
7822 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); 7930 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100);
7823 7931
7932 BeginFrameArgs begin_frame_args =
7933 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
7934
7824 EXPECT_EQ(InputHandler::SCROLL_STARTED, 7935 EXPECT_EQ(InputHandler::SCROLL_STARTED,
7825 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); 7936 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)));
7826 7937
7827 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); 7938 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
7828 7939
7829 host_impl_->Animate(start_time); 7940 begin_frame_args.frame_time = start_time;
7941 host_impl_->WillBeginImplFrame(begin_frame_args);
7942 host_impl_->Animate();
7830 host_impl_->UpdateAnimationState(true); 7943 host_impl_->UpdateAnimationState(true);
7831 7944
7832 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset()); 7945 EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset());
7946 host_impl_->DidFinishImplFrame();
7833 7947
7834 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(50)); 7948 begin_frame_args.frame_time =
7949 start_time + base::TimeDelta::FromMilliseconds(50);
7950 host_impl_->WillBeginImplFrame(begin_frame_args);
7951 host_impl_->Animate();
7835 host_impl_->UpdateAnimationState(true); 7952 host_impl_->UpdateAnimationState(true);
7836 7953
7837 float y = scrolling_layer->CurrentScrollOffset().y(); 7954 float y = scrolling_layer->CurrentScrollOffset().y();
7838 EXPECT_TRUE(y > 1 && y < 49); 7955 EXPECT_TRUE(y > 1 && y < 49);
7839 7956
7840 // Update target. 7957 // Update target.
7841 EXPECT_EQ(InputHandler::SCROLL_STARTED, 7958 EXPECT_EQ(InputHandler::SCROLL_STARTED,
7842 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); 7959 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)));
7960 host_impl_->DidFinishImplFrame();
7843 7961
7844 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(200)); 7962 begin_frame_args.frame_time =
7963 start_time + base::TimeDelta::FromMilliseconds(200);
7964 host_impl_->WillBeginImplFrame(begin_frame_args);
7965 host_impl_->Animate();
7845 host_impl_->UpdateAnimationState(true); 7966 host_impl_->UpdateAnimationState(true);
7846 7967
7847 y = scrolling_layer->CurrentScrollOffset().y(); 7968 y = scrolling_layer->CurrentScrollOffset().y();
7848 EXPECT_TRUE(y > 50 && y < 100); 7969 EXPECT_TRUE(y > 50 && y < 100);
7849 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer()); 7970 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer());
7971 host_impl_->DidFinishImplFrame();
7850 7972
7851 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250)); 7973 begin_frame_args.frame_time =
7974 start_time + base::TimeDelta::FromMilliseconds(250);
7975 host_impl_->WillBeginImplFrame(begin_frame_args);
7976 host_impl_->Animate();
7852 host_impl_->UpdateAnimationState(true); 7977 host_impl_->UpdateAnimationState(true);
7853 7978
7854 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), 7979 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100),
7855 scrolling_layer->CurrentScrollOffset()); 7980 scrolling_layer->CurrentScrollOffset());
7856 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); 7981 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
7982 host_impl_->DidFinishImplFrame();
7857 } 7983 }
7858 7984
7859 TEST_F(LayerTreeHostImplTest, InvalidLayerNotAddedToRasterQueue) { 7985 TEST_F(LayerTreeHostImplTest, InvalidLayerNotAddedToRasterQueue) {
7860 host_impl_->CreatePendingTree(); 7986 host_impl_->CreatePendingTree();
7861 7987
7862 Region empty_invalidation; 7988 Region empty_invalidation;
7863 scoped_refptr<RasterSource> pile_with_tiles( 7989 scoped_refptr<RasterSource> pile_with_tiles(
7864 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize( 7990 FakePicturePileImpl::CreateFilledPileWithDefaultTileSize(
7865 gfx::Size(10, 10))); 7991 gfx::Size(10, 10)));
7866 7992
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
8141 const BeginFrameArgs& begin_frame_args() const { return begin_frame_args_; } 8267 const BeginFrameArgs& begin_frame_args() const { return begin_frame_args_; }
8142 8268
8143 bool did_draw_frame() const { return did_draw_frame_; } 8269 bool did_draw_frame() const { return did_draw_frame_; }
8144 8270
8145 private: 8271 private:
8146 BeginFrameArgs begin_frame_args_; 8272 BeginFrameArgs begin_frame_args_;
8147 bool did_draw_frame_ = false; 8273 bool did_draw_frame_ = false;
8148 }; 8274 };
8149 8275
8150 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerInsideFrame) { 8276 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerInsideFrame) {
8151 host_impl_->DidFinishImplFrame();
8152
8153 BeginFrameArgs begin_frame_args = 8277 BeginFrameArgs begin_frame_args =
8154 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); 8278 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
8155 FakeVideoFrameController controller; 8279 FakeVideoFrameController controller;
8156 8280
8157 host_impl_->WillBeginImplFrame(begin_frame_args); 8281 host_impl_->WillBeginImplFrame(begin_frame_args);
8158 EXPECT_FALSE(controller.begin_frame_args().IsValid()); 8282 EXPECT_FALSE(controller.begin_frame_args().IsValid());
8159 host_impl_->AddVideoFrameController(&controller); 8283 host_impl_->AddVideoFrameController(&controller);
8160 EXPECT_TRUE(controller.begin_frame_args().IsValid()); 8284 EXPECT_TRUE(controller.begin_frame_args().IsValid());
8161 host_impl_->DidFinishImplFrame(); 8285 host_impl_->DidFinishImplFrame();
8162 8286
8163 EXPECT_FALSE(controller.did_draw_frame()); 8287 EXPECT_FALSE(controller.did_draw_frame());
8164 LayerTreeHostImpl::FrameData frame; 8288 LayerTreeHostImpl::FrameData frame;
8165 host_impl_->DidDrawAllLayers(frame); 8289 host_impl_->DidDrawAllLayers(frame);
8166 EXPECT_TRUE(controller.did_draw_frame()); 8290 EXPECT_TRUE(controller.did_draw_frame());
8167 8291
8168 controller.OnBeginFrame(begin_frame_args); 8292 controller.OnBeginFrame(begin_frame_args);
8169 EXPECT_FALSE(controller.did_draw_frame()); 8293 EXPECT_FALSE(controller.did_draw_frame());
8170 host_impl_->RemoveVideoFrameController(&controller); 8294 host_impl_->RemoveVideoFrameController(&controller);
8171 host_impl_->DidDrawAllLayers(frame); 8295 host_impl_->DidDrawAllLayers(frame);
8172 EXPECT_FALSE(controller.did_draw_frame()); 8296 EXPECT_FALSE(controller.did_draw_frame());
8173 } 8297 }
8174 8298
8175 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerOutsideFrame) { 8299 TEST_F(LayerTreeHostImplTest, AddVideoFrameControllerOutsideFrame) {
8176 host_impl_->DidFinishImplFrame();
8177
8178 BeginFrameArgs begin_frame_args = 8300 BeginFrameArgs begin_frame_args =
8179 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE); 8301 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE);
8180 FakeVideoFrameController controller; 8302 FakeVideoFrameController controller;
8181 8303
8182 host_impl_->WillBeginImplFrame(begin_frame_args); 8304 host_impl_->WillBeginImplFrame(begin_frame_args);
8183 host_impl_->DidFinishImplFrame(); 8305 host_impl_->DidFinishImplFrame();
8184 8306
8185 EXPECT_FALSE(controller.begin_frame_args().IsValid()); 8307 EXPECT_FALSE(controller.begin_frame_args().IsValid());
8186 host_impl_->AddVideoFrameController(&controller); 8308 host_impl_->AddVideoFrameController(&controller);
8187 EXPECT_FALSE(controller.begin_frame_args().IsValid()); 8309 EXPECT_FALSE(controller.begin_frame_args().IsValid());
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
8288 // Hold an unowned pointer to the output surface to use for mock expectations. 8410 // Hold an unowned pointer to the output surface to use for mock expectations.
8289 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get(); 8411 MockReclaimResourcesOutputSurface* mock_output_surface = output_surface.get();
8290 8412
8291 CreateHostImpl(DefaultSettings(), output_surface.Pass()); 8413 CreateHostImpl(DefaultSettings(), output_surface.Pass());
8292 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1); 8414 EXPECT_CALL(*mock_output_surface, ForceReclaimResources()).Times(1);
8293 host_impl_->BeginCommit(); 8415 host_impl_->BeginCommit();
8294 } 8416 }
8295 8417
8296 } // namespace 8418 } // namespace
8297 } // namespace cc 8419 } // namespace cc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698