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

Side by Side Diff: cc/scheduler/scheduler_unittest.cc

Issue 951673002: Revert "Pull chromium at 2c3ffb2355a27c32f45e508ef861416b820c823b" (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « cc/scheduler/scheduler.cc ('k') | cc/surfaces/display.h » ('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 "cc/scheduler/scheduler.h" 5 #include "cc/scheduler/scheduler.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 base::TimeDelta CommitToActivateDurationEstimate() override { 154 base::TimeDelta CommitToActivateDurationEstimate() override {
155 return base::TimeDelta(); 155 return base::TimeDelta();
156 } 156 }
157 157
158 void DidBeginImplFrameDeadline() override {} 158 void DidBeginImplFrameDeadline() override {}
159 159
160 void SendBeginFramesToChildren(const BeginFrameArgs& args) override { 160 void SendBeginFramesToChildren(const BeginFrameArgs& args) override {
161 begin_frame_is_sent_to_children_ = true; 161 begin_frame_is_sent_to_children_ = true;
162 } 162 }
163 163
164 void SendBeginMainFrameNotExpectedSoon() override {
165 PushAction("SendBeginMainFrameNotExpectedSoon");
166 }
167
168 base::Callback<bool(void)> ImplFrameDeadlinePending(bool state) { 164 base::Callback<bool(void)> ImplFrameDeadlinePending(bool state) {
169 return base::Bind(&FakeSchedulerClient::ImplFrameDeadlinePendingCallback, 165 return base::Bind(&FakeSchedulerClient::ImplFrameDeadlinePendingCallback,
170 base::Unretained(this), 166 base::Unretained(this),
171 state); 167 state);
172 } 168 }
173 169
174 bool begin_frame_is_sent_to_children() const { 170 bool begin_frame_is_sent_to_children() const {
175 return begin_frame_is_sent_to_children_; 171 return begin_frame_is_sent_to_children_;
176 } 172 }
177 173
(...skipping 336 matching lines...) Expand 10 before | Expand all | Expand 10 after
514 client_->Reset(); 510 client_->Reset();
515 511
516 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) 512 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false)
517 // to avoid excessive toggles. 513 // to avoid excessive toggles.
518 EXPECT_SCOPED(AdvanceFrame()); 514 EXPECT_SCOPED(AdvanceFrame());
519 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); 515 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_);
520 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); 516 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
521 client_->Reset(); 517 client_->Reset();
522 518
523 task_runner().RunPendingTasks(); // Run posted deadline. 519 task_runner().RunPendingTasks(); // Run posted deadline.
524 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); 520 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(false)", client_);
525 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
526 client_->Reset(); 521 client_->Reset();
527 } 522 }
528 523
529 TEST_F(SchedulerTest, RequestCommitAfterSetDeferCommit) { 524 TEST_F(SchedulerTest, RequestCommitAfterSetDeferCommit) {
530 scheduler_settings_.use_external_begin_frame_source = true; 525 scheduler_settings_.use_external_begin_frame_source = true;
531 SetUpScheduler(true); 526 SetUpScheduler(true);
532 527
533 scheduler_->SetCanStart(); 528 scheduler_->SetCanStart();
534 scheduler_->SetVisible(true); 529 scheduler_->SetVisible(true);
535 scheduler_->SetCanDraw(true); 530 scheduler_->SetCanDraw(true);
(...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 EXPECT_FALSE(scheduler_->PrepareTilesPending()); 994 EXPECT_FALSE(scheduler_->PrepareTilesPending());
1000 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); 995 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending());
1001 996
1002 // We need a BeginImplFrame where we don't swap to go idle. 997 // We need a BeginImplFrame where we don't swap to go idle.
1003 client->Reset(); 998 client->Reset();
1004 EXPECT_SCOPED(AdvanceFrame()); 999 EXPECT_SCOPED(AdvanceFrame());
1005 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client); 1000 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client);
1006 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); 1001 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
1007 client->Reset(); 1002 client->Reset();
1008 task_runner().RunPendingTasks(); // Run posted deadline. 1003 task_runner().RunPendingTasks(); // Run posted deadline.
1009 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); 1004 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(false)", client);
1010 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
1011 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); 1005 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending());
1012 EXPECT_EQ(0, client->num_draws()); 1006 EXPECT_EQ(0, client->num_draws());
1013 1007
1014 // Now trigger a PrepareTiles outside of a draw. We will then need 1008 // Now trigger a PrepareTiles outside of a draw. We will then need
1015 // a begin-frame for the PrepareTiles, but we don't need a draw. 1009 // a begin-frame for the PrepareTiles, but we don't need a draw.
1016 client->Reset(); 1010 client->Reset();
1017 EXPECT_FALSE(client->needs_begin_frames()); 1011 EXPECT_FALSE(client->needs_begin_frames());
1018 scheduler_->SetNeedsPrepareTiles(); 1012 scheduler_->SetNeedsPrepareTiles();
1019 EXPECT_TRUE(client->needs_begin_frames()); 1013 EXPECT_TRUE(client->needs_begin_frames());
1020 EXPECT_TRUE(scheduler_->PrepareTilesPending()); 1014 EXPECT_TRUE(scheduler_->PrepareTilesPending());
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
1375 client_->Reset(); 1369 client_->Reset();
1376 1370
1377 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) 1371 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false)
1378 // to avoid excessive toggles. 1372 // to avoid excessive toggles.
1379 task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. 1373 task_runner().RunPendingTasks(); // Run posted BeginRetroFrame.
1380 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); 1374 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_);
1381 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); 1375 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
1382 client_->Reset(); 1376 client_->Reset();
1383 1377
1384 task_runner().RunPendingTasks(); // Run posted deadline. 1378 task_runner().RunPendingTasks(); // Run posted deadline.
1385 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); 1379 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(false)", client_);
1386 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
1387 client_->Reset(); 1380 client_->Reset();
1388 } 1381 }
1389 1382
1390 TEST_F(SchedulerTest, BeginRetroFrame_SwapThrottled) { 1383 TEST_F(SchedulerTest, BeginRetroFrame_SwapThrottled) {
1391 scheduler_settings_.use_external_begin_frame_source = true; 1384 scheduler_settings_.use_external_begin_frame_source = true;
1392 SetUpScheduler(true); 1385 SetUpScheduler(true);
1393 1386
1394 scheduler_->SetEstimatedParentDrawTime(base::TimeDelta::FromMicroseconds(1)); 1387 scheduler_->SetEstimatedParentDrawTime(base::TimeDelta::FromMicroseconds(1));
1395 1388
1396 // To test swap ack throttling, this test disables automatic swap acks. 1389 // To test swap ack throttling, this test disables automatic swap acks.
(...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after
1627 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false) 1620 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false)
1628 // to avoid excessive toggles. 1621 // to avoid excessive toggles.
1629 task_runner().RunPendingTasks(); // Run posted BeginFrame. 1622 task_runner().RunPendingTasks(); // Run posted BeginFrame.
1630 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_); 1623 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_);
1631 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); 1624 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
1632 client_->Reset(); 1625 client_->Reset();
1633 1626
1634 // Make sure SetNeedsBeginFrame isn't called on the client 1627 // Make sure SetNeedsBeginFrame isn't called on the client
1635 // when the BeginFrame is no longer needed. 1628 // when the BeginFrame is no longer needed.
1636 task_runner().RunPendingTasks(); // Run posted deadline. 1629 task_runner().RunPendingTasks(); // Run posted deadline.
1637 EXPECT_SINGLE_ACTION("SendBeginMainFrameNotExpectedSoon", client_); 1630 EXPECT_NO_ACTION(client_);
1638 client_->Reset(); 1631 client_->Reset();
1639 } 1632 }
1640 1633
1641 TEST_F(SchedulerTest, SyntheticBeginFrames) { 1634 TEST_F(SchedulerTest, SyntheticBeginFrames) {
1642 bool use_external_begin_frame_source = false; 1635 bool use_external_begin_frame_source = false;
1643 bool throttle_frame_production = true; 1636 bool throttle_frame_production = true;
1644 BeginFramesNotFromClient(use_external_begin_frame_source, 1637 BeginFramesNotFromClient(use_external_begin_frame_source,
1645 throttle_frame_production); 1638 throttle_frame_production);
1646 } 1639 }
1647 1640
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
1783 1776
1784 client_->Reset(); 1777 client_->Reset();
1785 EXPECT_SCOPED(AdvanceFrame()); 1778 EXPECT_SCOPED(AdvanceFrame());
1786 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 1779 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
1787 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 1780 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
1788 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); 1781 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
1789 1782
1790 client_->Reset(); 1783 client_->Reset();
1791 scheduler_->DidLoseOutputSurface(); 1784 scheduler_->DidLoseOutputSurface();
1792 // Do nothing when impl frame is in deadine pending state. 1785 // Do nothing when impl frame is in deadine pending state.
1793 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); 1786 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(false)", client_);
1794 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
1795 1787
1796 client_->Reset(); 1788 client_->Reset();
1797 scheduler_->NotifyBeginMainFrameStarted(); 1789 scheduler_->NotifyBeginMainFrameStarted();
1798 scheduler_->NotifyReadyToCommit(); 1790 scheduler_->NotifyReadyToCommit();
1799 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 1); 1791 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 1);
1800 1792
1801 client_->Reset(); 1793 client_->Reset();
1802 task_runner().RunPendingTasks(); // Run posted deadline. 1794 task_runner().RunPendingTasks(); // Run posted deadline.
1803 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); 1795 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_);
1804 } 1796 }
(...skipping 10 matching lines...) Expand all
1815 1807
1816 client_->Reset(); 1808 client_->Reset();
1817 EXPECT_SCOPED(AdvanceFrame()); 1809 EXPECT_SCOPED(AdvanceFrame());
1818 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 1810 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
1819 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); 1811 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2);
1820 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); 1812 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
1821 1813
1822 client_->Reset(); 1814 client_->Reset();
1823 scheduler_->DidLoseOutputSurface(); 1815 scheduler_->DidLoseOutputSurface();
1824 // Do nothing when impl frame is in deadine pending state. 1816 // Do nothing when impl frame is in deadine pending state.
1825 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); 1817 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(false)", client_);
1826 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
1827 1818
1828 client_->Reset(); 1819 client_->Reset();
1829 // Run posted deadline. 1820 // Run posted deadline.
1830 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); 1821 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
1831 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); 1822 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true));
1832 // OnBeginImplFrameDeadline didn't schedule any actions because main frame is 1823 // OnBeginImplFrameDeadline didn't schedule any actions because main frame is
1833 // not yet completed. 1824 // not yet completed.
1834 EXPECT_NO_ACTION(client_); 1825 EXPECT_NO_ACTION(client_);
1835 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); 1826 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending());
1836 1827
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 1874
1884 client_->Reset(); 1875 client_->Reset();
1885 scheduler_->NotifyBeginMainFrameStarted(); 1876 scheduler_->NotifyBeginMainFrameStarted();
1886 scheduler_->NotifyReadyToCommit(); 1877 scheduler_->NotifyReadyToCommit();
1887 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); 1878 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_);
1888 1879
1889 client_->Reset(); 1880 client_->Reset();
1890 scheduler_->DidLoseOutputSurface(); 1881 scheduler_->DidLoseOutputSurface();
1891 if (impl_side_painting) { 1882 if (impl_side_painting) {
1892 // Sync tree should be forced to activate. 1883 // Sync tree should be forced to activate.
1893 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 0, 3); 1884 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 0, 2);
1894 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 3); 1885 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 2);
1895 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
1896 } else { 1886 } else {
1897 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); 1887 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(false)", client_);
1898 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
1899 } 1888 }
1900 1889
1901 client_->Reset(); 1890 client_->Reset();
1902 task_runner().RunPendingTasks(); // Run posted deadline. 1891 task_runner().RunPendingTasks(); // Run posted deadline.
1903 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); 1892 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_);
1904 } 1893 }
1905 1894
1906 TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterReadyToCommit) { 1895 TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterReadyToCommit) {
1907 DidLoseOutputSurfaceAfterReadyToCommit(false); 1896 DidLoseOutputSurfaceAfterReadyToCommit(false);
1908 } 1897 }
(...skipping 11 matching lines...) Expand all
1920 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); 1909 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_);
1921 1910
1922 client_->Reset(); 1911 client_->Reset();
1923 EXPECT_SCOPED(AdvanceFrame()); 1912 EXPECT_SCOPED(AdvanceFrame());
1924 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 1913 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
1925 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); 1914 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2);
1926 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); 1915 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
1927 1916
1928 client_->Reset(); 1917 client_->Reset();
1929 scheduler_->DidLoseOutputSurface(); 1918 scheduler_->DidLoseOutputSurface();
1930 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); 1919 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(false)", client_);
1931 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
1932 1920
1933 client_->Reset(); 1921 client_->Reset();
1934 task_runner().RunPendingTasks(); // Run posted deadline. 1922 task_runner().RunPendingTasks(); // Run posted deadline.
1935 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 0, 2); 1923 EXPECT_ACTION("ScheduledActionPrepareTiles", client_, 0, 2);
1936 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 1, 2); 1924 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 1, 2);
1937 } 1925 }
1938 1926
1939 TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterBeginRetroFramePosted) { 1927 TEST_F(SchedulerTest, DidLoseOutputSurfaceAfterBeginRetroFramePosted) {
1940 scheduler_settings_.use_external_begin_frame_source = true; 1928 scheduler_settings_.use_external_begin_frame_source = true;
1941 SetUpScheduler(true); 1929 SetUpScheduler(true);
(...skipping 30 matching lines...) Expand all
1972 // NotifyReadyToCommit should trigger the commit. 1960 // NotifyReadyToCommit should trigger the commit.
1973 client_->Reset(); 1961 client_->Reset();
1974 scheduler_->NotifyBeginMainFrameStarted(); 1962 scheduler_->NotifyBeginMainFrameStarted();
1975 scheduler_->NotifyReadyToCommit(); 1963 scheduler_->NotifyReadyToCommit();
1976 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); 1964 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_);
1977 EXPECT_TRUE(client_->needs_begin_frames()); 1965 EXPECT_TRUE(client_->needs_begin_frames());
1978 1966
1979 client_->Reset(); 1967 client_->Reset();
1980 EXPECT_FALSE(scheduler_->IsBeginRetroFrameArgsEmpty()); 1968 EXPECT_FALSE(scheduler_->IsBeginRetroFrameArgsEmpty());
1981 scheduler_->DidLoseOutputSurface(); 1969 scheduler_->DidLoseOutputSurface();
1982 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 3); 1970 EXPECT_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_, 0, 2);
1983 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 3); 1971 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 1, 2);
1984 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 2, 3);
1985 EXPECT_TRUE(scheduler_->IsBeginRetroFrameArgsEmpty()); 1972 EXPECT_TRUE(scheduler_->IsBeginRetroFrameArgsEmpty());
1986 1973
1987 // Posted BeginRetroFrame is aborted. 1974 // Posted BeginRetroFrame is aborted.
1988 client_->Reset(); 1975 client_->Reset();
1989 task_runner().RunPendingTasks(); 1976 task_runner().RunPendingTasks();
1990 EXPECT_NO_ACTION(client_); 1977 EXPECT_NO_ACTION(client_);
1991 } 1978 }
1992 1979
1993 TEST_F(SchedulerTest, DidLoseOutputSurfaceDuringBeginRetroFrameRunning) { 1980 TEST_F(SchedulerTest, DidLoseOutputSurfaceDuringBeginRetroFrameRunning) {
1994 scheduler_settings_.use_external_begin_frame_source = true; 1981 scheduler_settings_.use_external_begin_frame_source = true;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
2034 client_->Reset(); 2021 client_->Reset();
2035 task_runner().RunPendingTasks(); // Run posted BeginRetroFrame. 2022 task_runner().RunPendingTasks(); // Run posted BeginRetroFrame.
2036 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 2023 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
2037 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); 2024 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2);
2038 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); 2025 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
2039 EXPECT_TRUE(client_->needs_begin_frames()); 2026 EXPECT_TRUE(client_->needs_begin_frames());
2040 2027
2041 client_->Reset(); 2028 client_->Reset();
2042 EXPECT_FALSE(scheduler_->IsBeginRetroFrameArgsEmpty()); 2029 EXPECT_FALSE(scheduler_->IsBeginRetroFrameArgsEmpty());
2043 scheduler_->DidLoseOutputSurface(); 2030 scheduler_->DidLoseOutputSurface();
2044 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); 2031 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(false)", client_);
2045 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
2046 EXPECT_TRUE(scheduler_->IsBeginRetroFrameArgsEmpty()); 2032 EXPECT_TRUE(scheduler_->IsBeginRetroFrameArgsEmpty());
2047 2033
2048 // BeginImplFrame deadline should abort drawing. 2034 // BeginImplFrame deadline should abort drawing.
2049 client_->Reset(); 2035 client_->Reset();
2050 task_runner().RunPendingTasks(); // Run posted deadline. 2036 task_runner().RunPendingTasks(); // Run posted deadline.
2051 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); 2037 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_);
2052 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); 2038 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending());
2053 EXPECT_FALSE(client_->needs_begin_frames()); 2039 EXPECT_FALSE(client_->needs_begin_frames());
2054 2040
2055 // No more BeginRetroFrame because BeginRetroFrame queue is cleared. 2041 // No more BeginRetroFrame because BeginRetroFrame queue is cleared.
(...skipping 20 matching lines...) Expand all
2076 2062
2077 // NotifyReadyToCommit should trigger the commit. 2063 // NotifyReadyToCommit should trigger the commit.
2078 client_->Reset(); 2064 client_->Reset();
2079 scheduler_->NotifyBeginMainFrameStarted(); 2065 scheduler_->NotifyBeginMainFrameStarted();
2080 scheduler_->NotifyReadyToCommit(); 2066 scheduler_->NotifyReadyToCommit();
2081 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_); 2067 EXPECT_SINGLE_ACTION("ScheduledActionCommit", client_);
2082 EXPECT_TRUE(scheduler_->frame_source().NeedsBeginFrames()); 2068 EXPECT_TRUE(scheduler_->frame_source().NeedsBeginFrames());
2083 2069
2084 client_->Reset(); 2070 client_->Reset();
2085 scheduler_->DidLoseOutputSurface(); 2071 scheduler_->DidLoseOutputSurface();
2086 EXPECT_SINGLE_ACTION("SendBeginMainFrameNotExpectedSoon", client_); 2072 EXPECT_NO_ACTION(client_);
2087 EXPECT_FALSE(scheduler_->frame_source().NeedsBeginFrames()); 2073 EXPECT_FALSE(scheduler_->frame_source().NeedsBeginFrames());
2088 2074
2089 client_->Reset(); 2075 client_->Reset();
2090 task_runner().RunPendingTasks(); // Run posted deadline. 2076 task_runner().RunPendingTasks(); // Run posted deadline.
2091 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_); 2077 EXPECT_SINGLE_ACTION("ScheduledActionBeginOutputSurfaceCreation", client_);
2092 EXPECT_FALSE(scheduler_->frame_source().NeedsBeginFrames()); 2078 EXPECT_FALSE(scheduler_->frame_source().NeedsBeginFrames());
2093 } 2079 }
2094 2080
2095 TEST_F(SchedulerTest, ScheduledActionActivateAfterBecomingInvisible) { 2081 TEST_F(SchedulerTest, ScheduledActionActivateAfterBecomingInvisible) {
2096 scheduler_settings_.impl_side_painting = true; 2082 scheduler_settings_.impl_side_painting = true;
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after
2354 EXPECT_SCOPED(AdvanceFrame()); 2340 EXPECT_SCOPED(AdvanceFrame());
2355 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); 2341 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2);
2356 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); 2342 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2);
2357 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); 2343 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
2358 EXPECT_TRUE(client_->needs_begin_frames()); 2344 EXPECT_TRUE(client_->needs_begin_frames());
2359 client_->Reset(); 2345 client_->Reset();
2360 task_runner().RunPendingTasks(); // Run posted deadline. 2346 task_runner().RunPendingTasks(); // Run posted deadline.
2361 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1); 2347 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 0, 1);
2362 } 2348 }
2363 2349
2364 // Tests to ensure that we send a BeginMainFrameNotExpectedSoon when expected.
2365 TEST_F(SchedulerTest, SendBeginMainFrameNotExpectedSoon) {
2366 scheduler_settings_.use_external_begin_frame_source = true;
2367 SetUpScheduler(true);
2368
2369 // SetNeedsCommit should begin the frame on the next BeginImplFrame.
2370 scheduler_->SetNeedsCommit();
2371 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_);
2372 client_->Reset();
2373
2374 // Trigger a frame draw.
2375 EXPECT_SCOPED(AdvanceFrame());
2376 scheduler_->NotifyBeginMainFrameStarted();
2377 scheduler_->NotifyReadyToCommit();
2378 task_runner().RunPendingTasks();
2379 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 5);
2380 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 5);
2381 EXPECT_ACTION("ScheduledActionCommit", client_, 2, 5);
2382 EXPECT_ACTION("ScheduledActionAnimate", client_, 3, 5);
2383 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 4, 5);
2384 client_->Reset();
2385
2386 // The following BeginImplFrame deadline should SetNeedsBeginFrame(false)
2387 // and send a SendBeginMainFrameNotExpectedSoon.
2388 EXPECT_SCOPED(AdvanceFrame());
2389 EXPECT_SINGLE_ACTION("WillBeginImplFrame", client_);
2390 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending());
2391 client_->Reset();
2392
2393 task_runner().RunPendingTasks(); // Run posted deadline.
2394 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2);
2395 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2);
2396 client_->Reset();
2397 }
2398
2399 } // namespace 2350 } // namespace
2400 } // namespace cc 2351 } // namespace cc
OLDNEW
« no previous file with comments | « cc/scheduler/scheduler.cc ('k') | cc/surfaces/display.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698