OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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.h" | 5 #include "cc/trees/layer_tree_host.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "cc/debug/test_context_provider.h" | 8 #include "cc/debug/test_context_provider.h" |
9 #include "cc/debug/test_web_graphics_context_3d.h" | 9 #include "cc/debug/test_web_graphics_context_3d.h" |
10 #include "cc/layers/content_layer.h" | 10 #include "cc/layers/content_layer.h" |
(...skipping 1619 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1630 | 1630 |
1631 SINGLE_AND_MULTI_THREAD_TEST_F( | 1631 SINGLE_AND_MULTI_THREAD_TEST_F( |
1632 LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface); | 1632 LayerTreeHostTestCannotCreateIfCannotCreateOutputSurface); |
1633 | 1633 |
1634 class UIResourceLostTest : public LayerTreeHostContextTest { | 1634 class UIResourceLostTest : public LayerTreeHostContextTest { |
1635 public: | 1635 public: |
1636 UIResourceLostTest() : time_step_(0) {} | 1636 UIResourceLostTest() : time_step_(0) {} |
1637 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } | 1637 virtual void BeginTest() OVERRIDE { PostSetNeedsCommitToMainThread(); } |
1638 virtual void AfterTest() OVERRIDE {} | 1638 virtual void AfterTest() OVERRIDE {} |
1639 | 1639 |
| 1640 // This is called on the main thread after each commit and |
| 1641 // DidActivateTreeOnThread, with the value of time_step_ at the time |
| 1642 // of the call to DidActivateTreeOnThread. Similar tests will do |
| 1643 // work on the main thread in DidCommit but that is unsuitable because |
| 1644 // the main thread work for these tests must happen after |
| 1645 // DidActivateTreeOnThread, which happens after DidCommit with impl-side |
| 1646 // painting. |
| 1647 virtual void StepCompleteOnMainThread(int time_step) = 0; |
| 1648 |
| 1649 // Called after DidActivateTreeOnThread. If this is done during the commit, |
| 1650 // the call to StepCompleteOnMainThread will not occur until after |
| 1651 // the commit completes, because the main thread is blocked. |
| 1652 void PostStepCompleteToMainThread() { |
| 1653 proxy()->MainThreadTaskRunner()->PostTask( |
| 1654 FROM_HERE, |
| 1655 base::Bind( |
| 1656 &UIResourceLostTest::StepCompleteOnMainThreadInternal, |
| 1657 base::Unretained(this), |
| 1658 time_step_)); |
| 1659 } |
| 1660 |
| 1661 void PostLoseContextToImplThread() { |
| 1662 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); |
| 1663 base::SingleThreadTaskRunner* task_runner = |
| 1664 HasImplThread() ? ImplThreadTaskRunner() |
| 1665 : base::MessageLoopProxy::current(); |
| 1666 task_runner->PostTask( |
| 1667 FROM_HERE, |
| 1668 base::Bind( |
| 1669 &LayerTreeHostContextTest::LoseContext, |
| 1670 base::Unretained(this))); |
| 1671 } |
| 1672 |
1640 protected: | 1673 protected: |
1641 int time_step_; | 1674 int time_step_; |
1642 scoped_ptr<FakeScopedUIResource> ui_resource_; | 1675 scoped_ptr<FakeScopedUIResource> ui_resource_; |
| 1676 |
| 1677 private: |
| 1678 void StepCompleteOnMainThreadInternal(int step) { |
| 1679 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); |
| 1680 StepCompleteOnMainThread(step); |
| 1681 } |
| 1682 }; |
| 1683 |
| 1684 class UIResourceLostTestSimple : public UIResourceLostTest { |
| 1685 public: |
| 1686 // This is called when the commit is complete and the new layer tree has been |
| 1687 // activated. |
| 1688 virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) = 0; |
| 1689 |
| 1690 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 1691 if (!layer_tree_host()->settings().impl_side_painting) { |
| 1692 StepCompleteOnImplThread(impl); |
| 1693 PostStepCompleteToMainThread(); |
| 1694 ++time_step_; |
| 1695 } |
| 1696 } |
| 1697 |
| 1698 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 1699 if (layer_tree_host()->settings().impl_side_painting) { |
| 1700 StepCompleteOnImplThread(impl); |
| 1701 PostStepCompleteToMainThread(); |
| 1702 ++time_step_; |
| 1703 } |
| 1704 } |
1643 }; | 1705 }; |
1644 | 1706 |
1645 // Losing context after an UI resource has been created. | 1707 // Losing context after an UI resource has been created. |
1646 class UIResourceLostAfterCommit : public UIResourceLostTest { | 1708 class UIResourceLostAfterCommit : public UIResourceLostTestSimple { |
1647 public: | 1709 public: |
1648 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1710 virtual void StepCompleteOnMainThread(int step) OVERRIDE { |
1649 LayerTreeHostContextTest::CommitCompleteOnThread(impl); | 1711 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); |
1650 switch (time_step_) { | 1712 switch (step) { |
1651 case 0: | 1713 case 0: |
1652 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); | 1714 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); |
1653 // Expects a valid UIResourceId. | 1715 // Expects a valid UIResourceId. |
1654 EXPECT_NE(0, ui_resource_->id()); | 1716 EXPECT_NE(0, ui_resource_->id()); |
1655 PostSetNeedsCommitToMainThread(); | 1717 PostSetNeedsCommitToMainThread(); |
1656 break; | 1718 break; |
| 1719 case 4: |
| 1720 // Release resource before ending the test. |
| 1721 ui_resource_.reset(); |
| 1722 EndTest(); |
| 1723 break; |
| 1724 case 5: |
| 1725 // Make sure no extra commits happened. |
| 1726 NOTREACHED(); |
| 1727 } |
| 1728 } |
| 1729 |
| 1730 virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 1731 LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
| 1732 switch (time_step_) { |
1657 case 1: | 1733 case 1: |
1658 // The resource should have been created on LTHI after the commit. | 1734 // The resource should have been created on LTHI after the commit. |
1659 if (!layer_tree_host()->settings().impl_side_painting) | 1735 EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
1660 EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); | |
1661 PostSetNeedsCommitToMainThread(); | 1736 PostSetNeedsCommitToMainThread(); |
1662 break; | 1737 break; |
1663 case 2: | 1738 case 2: |
1664 LoseContext(); | 1739 LoseContext(); |
1665 break; | 1740 break; |
1666 case 3: | 1741 case 3: |
1667 // The resources should have been recreated. The bitmap callback should | 1742 // The resources should have been recreated. The bitmap callback should |
1668 // have been called once with the resource_lost flag set to true. | 1743 // have been called once with the resource_lost flag set to true. |
1669 EXPECT_EQ(1, ui_resource_->lost_resource_count); | 1744 EXPECT_EQ(1, ui_resource_->lost_resource_count); |
1670 // Resource Id on the impl-side have been recreated as well. Note | 1745 // Resource Id on the impl-side have been recreated as well. Note |
1671 // that the same UIResourceId persists after the context lost. | 1746 // that the same UIResourceId persists after the context lost. |
1672 if (!layer_tree_host()->settings().impl_side_painting) | 1747 EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
1673 EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); | |
1674 PostSetNeedsCommitToMainThread(); | 1748 PostSetNeedsCommitToMainThread(); |
1675 break; | 1749 break; |
1676 case 4: | |
1677 // Release resource before ending test. | |
1678 ui_resource_.reset(); | |
1679 EndTest(); | |
1680 break; | |
1681 } | 1750 } |
1682 } | 1751 } |
1683 | |
1684 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { | |
1685 LayerTreeHostContextTest::DidActivateTreeOnThread(impl); | |
1686 switch (time_step_) { | |
1687 case 1: | |
1688 if (layer_tree_host()->settings().impl_side_painting) | |
1689 EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); | |
1690 break; | |
1691 case 3: | |
1692 if (layer_tree_host()->settings().impl_side_painting) | |
1693 EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); | |
1694 break; | |
1695 } | |
1696 ++time_step_; | |
1697 } | |
1698 }; | 1752 }; |
1699 | 1753 |
1700 SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostAfterCommit); | 1754 SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostAfterCommit); |
1701 | 1755 |
1702 // Losing context before UI resource requests can be commited. Three sequences | 1756 // Losing context before UI resource requests can be commited. Three sequences |
1703 // of creation/deletion are considered: | 1757 // of creation/deletion are considered: |
1704 // 1. Create one resource -> Context Lost => Expect the resource to have been | 1758 // 1. Create one resource -> Context Lost => Expect the resource to have been |
1705 // created. | 1759 // created. |
1706 // 2. Delete an exisiting resource (test_id0_) -> create a second resource | 1760 // 2. Delete an exisiting resource (test_id0_) -> create a second resource |
1707 // (test_id1_) -> Context Lost => Expect the test_id0_ to be removed and | 1761 // (test_id1_) -> Context Lost => Expect the test_id0_ to be removed and |
1708 // test_id1_ to have been created. | 1762 // test_id1_ to have been created. |
1709 // 3. Create one resource -> Delete that same resource -> Context Lost => Expect | 1763 // 3. Create one resource -> Delete that same resource -> Context Lost => Expect |
1710 // the resource to not exist in the manager. | 1764 // the resource to not exist in the manager. |
1711 class UIResourceLostBeforeCommit : public UIResourceLostTest { | 1765 class UIResourceLostBeforeCommit : public UIResourceLostTestSimple { |
1712 public: | 1766 public: |
1713 UIResourceLostBeforeCommit() | 1767 UIResourceLostBeforeCommit() |
1714 : test_id0_(0), | 1768 : test_id0_(0), |
1715 test_id1_(0) {} | 1769 test_id1_(0) {} |
1716 | 1770 |
1717 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1771 virtual void StepCompleteOnMainThread(int step) OVERRIDE { |
1718 LayerTreeHostContextTest::CommitCompleteOnThread(impl); | 1772 switch (step) { |
1719 switch (time_step_) { | |
1720 case 0: | 1773 case 0: |
1721 // Sequence 1: | |
1722 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); | 1774 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); |
1723 LoseContext(); | 1775 // Lose the context on the impl thread before the commit. |
1724 // Resource Id on the impl-side should no longer be valid after | 1776 PostLoseContextToImplThread(); |
1725 // context is lost. | |
1726 EXPECT_EQ(0u, impl->ResourceIdForUIResource(ui_resource_->id())); | |
1727 break; | |
1728 case 1: | |
1729 // The resources should have been recreated. | |
1730 EXPECT_EQ(2, ui_resource_->resource_create_count); | |
1731 // "resource lost" callback was called once for the resource in the | |
1732 // resource map. | |
1733 EXPECT_EQ(1, ui_resource_->lost_resource_count); | |
1734 // Resource Id on the impl-side have been recreated as well. Note | |
1735 // that the same UIResourceId persists after the context lost. | |
1736 if (!layer_tree_host()->settings().impl_side_painting) | |
1737 EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); | |
1738 PostSetNeedsCommitToMainThread(); | |
1739 break; | 1777 break; |
1740 case 2: | 1778 case 2: |
1741 // Sequence 2: | 1779 // Sequence 2: |
1742 // Currently one resource has been created. | 1780 // Currently one resource has been created. |
1743 test_id0_ = ui_resource_->id(); | 1781 test_id0_ = ui_resource_->id(); |
1744 // Delete this resource. | 1782 // Delete this resource. |
1745 ui_resource_.reset(); | 1783 ui_resource_.reset(); |
1746 // Create another resource. | 1784 // Create another resource. |
1747 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); | 1785 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); |
1748 test_id1_ = ui_resource_->id(); | 1786 test_id1_ = ui_resource_->id(); |
1749 // Sanity check that two resource creations return different ids. | 1787 // Sanity check that two resource creations return different ids. |
1750 EXPECT_NE(test_id0_, test_id1_); | 1788 EXPECT_NE(test_id0_, test_id1_); |
1751 // Lose the context before commit. | 1789 // Lose the context on the impl thread before the commit. |
1752 LoseContext(); | 1790 PostLoseContextToImplThread(); |
1753 break; | 1791 break; |
1754 case 3: | 1792 case 3: |
1755 if (!layer_tree_host()->settings().impl_side_painting) { | |
1756 // The previous resource should have been deleted. | |
1757 EXPECT_EQ(0u, impl->ResourceIdForUIResource(test_id0_)); | |
1758 // The second resource should have been created. | |
1759 EXPECT_NE(0u, impl->ResourceIdForUIResource(test_id1_)); | |
1760 } | |
1761 | |
1762 // The second resource called the resource callback once and since the | |
1763 // context is lost, a "resource lost" callback was also issued. | |
1764 EXPECT_EQ(2, ui_resource_->resource_create_count); | |
1765 EXPECT_EQ(1, ui_resource_->lost_resource_count); | |
1766 // Clear the manager of resources. | 1793 // Clear the manager of resources. |
1767 ui_resource_.reset(); | 1794 ui_resource_.reset(); |
1768 PostSetNeedsCommitToMainThread(); | 1795 PostSetNeedsCommitToMainThread(); |
1769 break; | 1796 break; |
1770 case 4: | 1797 case 4: |
1771 // Sequence 3: | 1798 // Sequence 3: |
1772 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); | 1799 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); |
1773 test_id0_ = ui_resource_->id(); | 1800 test_id0_ = ui_resource_->id(); |
1774 // Sanity check the UIResourceId should not be 0. | 1801 // Sanity check the UIResourceId should not be 0. |
1775 EXPECT_NE(0, test_id0_); | 1802 EXPECT_NE(0, test_id0_); |
1776 // Usually ScopedUIResource are deleted from the manager in their | 1803 // Usually ScopedUIResource are deleted from the manager in their |
1777 // destructor (so usually ui_resource_.reset()). But here we need | 1804 // destructor (so usually ui_resource_.reset()). But here we need |
1778 // ui_resource_ for the next step, so call DeleteUIResource directly. | 1805 // ui_resource_ for the next step, so call DeleteUIResource directly. |
1779 layer_tree_host()->DeleteUIResource(test_id0_); | 1806 layer_tree_host()->DeleteUIResource(test_id0_); |
1780 LoseContext(); | 1807 // Delete the resouce and then lose the context. |
| 1808 PostLoseContextToImplThread(); |
1781 break; | 1809 break; |
1782 case 5: | 1810 case 5: |
| 1811 // Release resource before ending the test. |
| 1812 ui_resource_.reset(); |
| 1813 EndTest(); |
| 1814 break; |
| 1815 case 6: |
| 1816 // Single thread proxy issues extra commits after context lost. |
| 1817 // http://crbug.com/287250 |
| 1818 if (HasImplThread()) |
| 1819 NOTREACHED(); |
| 1820 break; |
| 1821 case 8: |
| 1822 NOTREACHED(); |
| 1823 } |
| 1824 } |
| 1825 |
| 1826 virtual void StepCompleteOnImplThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 1827 LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
| 1828 switch (time_step_) { |
| 1829 case 1: |
| 1830 // Sequence 1 (continued): |
| 1831 if (HasImplThread()) { |
| 1832 // The resources should have been recreated. |
| 1833 EXPECT_EQ(2, ui_resource_->resource_create_count); |
| 1834 // The "resource lost" callback was called once for the resource in |
| 1835 // the resource map. |
| 1836 EXPECT_EQ(1, ui_resource_->lost_resource_count); |
| 1837 } else { |
| 1838 // The extra commit that happens at context lost in the single thread |
| 1839 // proxy changes the timing so that the resource recreation callback |
| 1840 // is skipped. |
| 1841 // http://crbug.com/287250 |
| 1842 EXPECT_EQ(1, ui_resource_->resource_create_count); |
| 1843 EXPECT_EQ(0, ui_resource_->lost_resource_count); |
| 1844 } |
| 1845 // Resource Id on the impl-side have been recreated as well. Note |
| 1846 // that the same UIResourceId persists after the context lost. |
| 1847 EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
| 1848 PostSetNeedsCommitToMainThread(); |
| 1849 break; |
| 1850 case 3: |
| 1851 // Sequence 2 (continued): |
| 1852 // The previous resource should have been deleted. |
| 1853 EXPECT_EQ(0u, impl->ResourceIdForUIResource(test_id0_)); |
| 1854 // The second resource should have been created. |
| 1855 EXPECT_NE(0u, impl->ResourceIdForUIResource(test_id1_)); |
| 1856 if (HasImplThread()) { |
| 1857 // The second resource called the resource callback once and since the |
| 1858 // context is lost, a "resource lost" callback was also issued. |
| 1859 EXPECT_EQ(2, ui_resource_->resource_create_count); |
| 1860 EXPECT_EQ(1, ui_resource_->lost_resource_count); |
| 1861 } else { |
| 1862 // The extra commit that happens at context lost in the single thread |
| 1863 // proxy changes the timing so that the resource recreation callback |
| 1864 // is skipped. |
| 1865 // http://crbug.com/287250 |
| 1866 EXPECT_EQ(1, ui_resource_->resource_create_count); |
| 1867 EXPECT_EQ(0, ui_resource_->lost_resource_count); |
| 1868 } |
| 1869 break; |
| 1870 case 5: |
| 1871 // Sequence 3 (continued): |
1783 // Expect the resource callback to have been called once. | 1872 // Expect the resource callback to have been called once. |
1784 EXPECT_EQ(1, ui_resource_->resource_create_count); | 1873 EXPECT_EQ(1, ui_resource_->resource_create_count); |
1785 // No "resource lost" callbacks. | 1874 // No "resource lost" callbacks. |
1786 EXPECT_EQ(0, ui_resource_->lost_resource_count); | 1875 EXPECT_EQ(0, ui_resource_->lost_resource_count); |
1787 if (!layer_tree_host()->settings().impl_side_painting) { | 1876 // The UI resource id should not be valid |
1788 // The UI resource id should not be valid | 1877 EXPECT_EQ(0u, impl->ResourceIdForUIResource(test_id0_)); |
1789 EXPECT_EQ(0u, impl->ResourceIdForUIResource(test_id0_)); | |
1790 } | |
1791 PostSetNeedsCommitToMainThread(); | |
1792 break; | |
1793 case 6: | |
1794 ui_resource_.reset(); | |
1795 EndTest(); | |
1796 break; | 1878 break; |
1797 } | 1879 } |
1798 } | 1880 } |
1799 | 1881 |
1800 virtual void DidActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { | |
1801 LayerTreeHostContextTest::DidActivateTreeOnThread(impl); | |
1802 switch (time_step_) { | |
1803 case 1: | |
1804 if (layer_tree_host()->settings().impl_side_painting) | |
1805 EXPECT_NE(0u, impl->ResourceIdForUIResource(ui_resource_->id())); | |
1806 break; | |
1807 case 3: | |
1808 if (layer_tree_host()->settings().impl_side_painting) { | |
1809 EXPECT_EQ(0u, impl->ResourceIdForUIResource(test_id0_)); | |
1810 EXPECT_NE(0u, impl->ResourceIdForUIResource(test_id1_)); | |
1811 } | |
1812 break; | |
1813 case 5: | |
1814 if (layer_tree_host()->settings().impl_side_painting) | |
1815 EXPECT_EQ(0u, impl->ResourceIdForUIResource(test_id0_)); | |
1816 break; | |
1817 } | |
1818 ++time_step_; | |
1819 } | |
1820 | |
1821 private: | 1882 private: |
1822 UIResourceId test_id0_; | 1883 UIResourceId test_id0_; |
1823 UIResourceId test_id1_; | 1884 UIResourceId test_id1_; |
1824 }; | 1885 }; |
1825 | 1886 |
1826 SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostBeforeCommit); | 1887 SINGLE_AND_MULTI_THREAD_TEST_F(UIResourceLostBeforeCommit); |
1827 | 1888 |
1828 // Losing UI resource before the pending trees is activated but after the | 1889 // Losing UI resource before the pending trees is activated but after the |
1829 // commit. Impl-side-painting only. | 1890 // commit. Impl-side-painting only. |
1830 class UIResourceLostBeforeActivateTree : public UIResourceLostTest { | 1891 class UIResourceLostBeforeActivateTree : public UIResourceLostTest { |
1831 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1892 virtual void StepCompleteOnMainThread(int step) OVERRIDE { |
1832 LayerTreeHostContextTest::CommitCompleteOnThread(impl); | 1893 EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread()); |
1833 switch (time_step_) { | 1894 switch (step) { |
1834 case 0: | 1895 case 0: |
1835 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); | 1896 ui_resource_ = FakeScopedUIResource::Create(layer_tree_host()); |
1836 PostSetNeedsCommitToMainThread(); | 1897 PostSetNeedsCommitToMainThread(); |
1837 break; | 1898 break; |
1838 case 2: | |
1839 PostSetNeedsCommitToMainThread(); | |
1840 break; | |
1841 case 3: | 1899 case 3: |
1842 test_id_ = ui_resource_->id(); | 1900 test_id_ = ui_resource_->id(); |
1843 ui_resource_.reset(); | 1901 ui_resource_.reset(); |
1844 PostSetNeedsCommitToMainThread(); | 1902 PostSetNeedsCommitToMainThread(); |
1845 break; | 1903 break; |
| 1904 case 5: |
| 1905 // Release resource before ending the test. |
| 1906 ui_resource_.reset(); |
| 1907 EndTest(); |
| 1908 break; |
| 1909 case 6: |
| 1910 // Make sure no extra commits happened. |
| 1911 NOTREACHED(); |
| 1912 } |
| 1913 } |
| 1914 |
| 1915 virtual void CommitCompleteOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
| 1916 LayerTreeHostContextTest::CommitCompleteOnThread(impl); |
| 1917 switch (time_step_) { |
| 1918 case 2: |
| 1919 PostSetNeedsCommitToMainThread(); |
| 1920 break; |
1846 case 4: | 1921 case 4: |
1847 PostSetNeedsCommitToMainThread(); | 1922 PostSetNeedsCommitToMainThread(); |
1848 break; | 1923 break; |
1849 case 5: | |
1850 EndTest(); | |
1851 break; | |
1852 } | 1924 } |
1853 } | 1925 } |
1854 | 1926 |
1855 virtual void WillActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { | 1927 virtual void WillActivateTreeOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
1856 switch (time_step_) { | 1928 switch (time_step_) { |
1857 case 0: | |
1858 break; | |
1859 case 1: | 1929 case 1: |
1860 // The resource creation callback has been called. | 1930 // The resource creation callback has been called. |
1861 EXPECT_EQ(1, ui_resource_->resource_create_count); | 1931 EXPECT_EQ(1, ui_resource_->resource_create_count); |
1862 // The resource is not yet lost (sanity check). | 1932 // The resource is not yet lost (sanity check). |
1863 EXPECT_EQ(0, ui_resource_->lost_resource_count); | 1933 EXPECT_EQ(0, ui_resource_->lost_resource_count); |
1864 // The resource should not have been created yet on the impl-side. | 1934 // The resource should not have been created yet on the impl-side. |
1865 EXPECT_EQ(0u, impl->ResourceIdForUIResource(ui_resource_->id())); | 1935 EXPECT_EQ(0u, impl->ResourceIdForUIResource(ui_resource_->id())); |
1866 LoseContext(); | 1936 LoseContext(); |
1867 break; | 1937 break; |
1868 case 3: | 1938 case 3: |
(...skipping 12 matching lines...) Expand all Loading... |
1881 case 2: | 1951 case 2: |
1882 // The "lost resource" callback should have been called once. | 1952 // The "lost resource" callback should have been called once. |
1883 EXPECT_EQ(1, ui_resource_->lost_resource_count); | 1953 EXPECT_EQ(1, ui_resource_->lost_resource_count); |
1884 break; | 1954 break; |
1885 case 4: | 1955 case 4: |
1886 // The resource is deleted and should not be in the manager. Use | 1956 // The resource is deleted and should not be in the manager. Use |
1887 // test_id_ since ui_resource_ has been deleted. | 1957 // test_id_ since ui_resource_ has been deleted. |
1888 EXPECT_EQ(0u, impl->ResourceIdForUIResource(test_id_)); | 1958 EXPECT_EQ(0u, impl->ResourceIdForUIResource(test_id_)); |
1889 break; | 1959 break; |
1890 } | 1960 } |
| 1961 |
| 1962 PostStepCompleteToMainThread(); |
1891 ++time_step_; | 1963 ++time_step_; |
1892 } | 1964 } |
1893 | 1965 |
1894 private: | 1966 private: |
1895 UIResourceId test_id_; | 1967 UIResourceId test_id_; |
1896 }; | 1968 }; |
1897 | 1969 |
1898 TEST_F(UIResourceLostBeforeActivateTree, | 1970 TEST_F(UIResourceLostBeforeActivateTree, |
1899 RunMultiThread_DirectRenderer_ImplSidePaint) { | 1971 RunMultiThread_DirectRenderer_ImplSidePaint) { |
1900 RunTest(true, false, true); | 1972 RunTest(true, false, true); |
1901 } | 1973 } |
1902 | 1974 |
1903 TEST_F(UIResourceLostBeforeActivateTree, | 1975 TEST_F(UIResourceLostBeforeActivateTree, |
1904 RunMultiThread_DelegatingRenderer_ImplSidePaint) { | 1976 RunMultiThread_DelegatingRenderer_ImplSidePaint) { |
1905 RunTest(true, true, true); | 1977 RunTest(true, true, true); |
1906 } | 1978 } |
1907 | 1979 |
1908 } // namespace | 1980 } // namespace |
1909 } // namespace cc | 1981 } // namespace cc |
OLD | NEW |