OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "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 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
246 return CallOnBeginFrame(args); | 246 return CallOnBeginFrame(args); |
247 } | 247 } |
248 | 248 |
249 private: | 249 private: |
250 FakeSchedulerClient* client_; | 250 FakeSchedulerClient* client_; |
251 }; | 251 }; |
252 | 252 |
253 class SchedulerTest : public testing::Test { | 253 class SchedulerTest : public testing::Test { |
254 public: | 254 public: |
255 SchedulerTest() | 255 SchedulerTest() |
256 : now_src_(TestNowSource::Create()), | 256 : now_src_(new base::SimpleTestTickClock()), |
257 task_runner_(new OrderedSimpleTaskRunner(now_src_, true)), | 257 task_runner_(new OrderedSimpleTaskRunner(now_src_.get(), true)), |
258 fake_external_begin_frame_source_(nullptr) { | 258 fake_external_begin_frame_source_(nullptr) { |
259 // A bunch of tests require Now() to be > BeginFrameArgs::DefaultInterval() | 259 now_src_->Advance(base::TimeDelta::FromInternalValue(10000)); |
260 now_src_->AdvanceNow(base::TimeDelta::FromMilliseconds(100)); | 260 // A bunch of tests require NowTicks() |
| 261 // to be > BeginFrameArgs::DefaultInterval() |
| 262 now_src_->Advance(base::TimeDelta::FromMilliseconds(100)); |
261 // Fail if we need to run 100 tasks in a row. | 263 // Fail if we need to run 100 tasks in a row. |
262 task_runner_->SetRunTaskLimit(100); | 264 task_runner_->SetRunTaskLimit(100); |
263 } | 265 } |
264 | 266 |
265 ~SchedulerTest() override {} | 267 ~SchedulerTest() override {} |
266 | 268 |
267 protected: | 269 protected: |
268 TestScheduler* CreateScheduler() { | 270 TestScheduler* CreateScheduler() { |
269 scoped_ptr<FakeExternalBeginFrameSource> fake_external_begin_frame_source; | 271 scoped_ptr<FakeExternalBeginFrameSource> fake_external_begin_frame_source; |
270 if (scheduler_settings_.use_external_begin_frame_source) { | 272 if (scheduler_settings_.use_external_begin_frame_source) { |
271 fake_external_begin_frame_source.reset( | 273 fake_external_begin_frame_source.reset( |
272 new FakeExternalBeginFrameSource(client_.get())); | 274 new FakeExternalBeginFrameSource(client_.get())); |
273 fake_external_begin_frame_source_ = | 275 fake_external_begin_frame_source_ = |
274 fake_external_begin_frame_source.get(); | 276 fake_external_begin_frame_source.get(); |
275 } | 277 } |
276 scheduler_ = TestScheduler::Create(now_src_, client_.get(), | 278 scheduler_ = TestScheduler::Create(now_src_.get(), client_.get(), |
277 scheduler_settings_, 0, task_runner_, | 279 scheduler_settings_, 0, task_runner_, |
278 fake_external_begin_frame_source.Pass()); | 280 fake_external_begin_frame_source.Pass()); |
279 DCHECK(scheduler_); | 281 DCHECK(scheduler_); |
280 client_->set_scheduler(scheduler_.get()); | 282 client_->set_scheduler(scheduler_.get()); |
281 return scheduler_.get(); | 283 return scheduler_.get(); |
282 } | 284 } |
283 | 285 |
284 void CreateSchedulerAndInitSurface() { | 286 void CreateSchedulerAndInitSurface() { |
285 CreateScheduler(); | 287 CreateScheduler(); |
286 EXPECT_SCOPED(InitializeOutputSurfaceAndFirstCommit()); | 288 EXPECT_SCOPED(InitializeOutputSurfaceAndFirstCommit()); |
287 } | 289 } |
288 | 290 |
289 void SetUpScheduler(bool initSurface) { | 291 void SetUpScheduler(bool initSurface) { |
290 SetUpScheduler(make_scoped_ptr(new FakeSchedulerClient), initSurface); | 292 SetUpScheduler(make_scoped_ptr(new FakeSchedulerClient), initSurface); |
291 } | 293 } |
292 | 294 |
293 void SetUpScheduler(scoped_ptr<FakeSchedulerClient> client, | 295 void SetUpScheduler(scoped_ptr<FakeSchedulerClient> client, |
294 bool initSurface) { | 296 bool initSurface) { |
295 client_ = client.Pass(); | 297 client_ = client.Pass(); |
296 if (initSurface) | 298 if (initSurface) |
297 CreateSchedulerAndInitSurface(); | 299 CreateSchedulerAndInitSurface(); |
298 else | 300 else |
299 CreateScheduler(); | 301 CreateScheduler(); |
300 } | 302 } |
301 | 303 |
302 OrderedSimpleTaskRunner& task_runner() { return *task_runner_; } | 304 OrderedSimpleTaskRunner& task_runner() { return *task_runner_; } |
303 TestNowSource* now_src() { return now_src_.get(); } | 305 base::SimpleTestTickClock* now_src() { return now_src_.get(); } |
304 | 306 |
305 // As this function contains EXPECT macros, to allow debugging it should be | 307 // As this function contains EXPECT macros, to allow debugging it should be |
306 // called inside EXPECT_SCOPED like so; | 308 // called inside EXPECT_SCOPED like so; |
307 // EXPECT_SCOPED(client.InitializeOutputSurfaceAndFirstCommit(scheduler)); | 309 // EXPECT_SCOPED(client.InitializeOutputSurfaceAndFirstCommit(scheduler)); |
308 void InitializeOutputSurfaceAndFirstCommit() { | 310 void InitializeOutputSurfaceAndFirstCommit() { |
309 TRACE_EVENT0("cc", | 311 TRACE_EVENT0("cc", |
310 "SchedulerUnitTest::InitializeOutputSurfaceAndFirstCommit"); | 312 "SchedulerUnitTest::InitializeOutputSurfaceAndFirstCommit"); |
311 DCHECK(scheduler_); | 313 DCHECK(scheduler_); |
312 | 314 |
313 // Check the client doesn't have any actions queued when calling this | 315 // Check the client doesn't have any actions queued when calling this |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 EXPECT_TRUE(task_runner_->RunTasksWhile( | 399 EXPECT_TRUE(task_runner_->RunTasksWhile( |
398 client_->ImplFrameDeadlinePending(false))); | 400 client_->ImplFrameDeadlinePending(false))); |
399 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 401 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
400 } | 402 } |
401 } | 403 } |
402 | 404 |
403 BeginFrameArgs SendNextBeginFrame() { | 405 BeginFrameArgs SendNextBeginFrame() { |
404 DCHECK(scheduler_->settings().use_external_begin_frame_source); | 406 DCHECK(scheduler_->settings().use_external_begin_frame_source); |
405 // Creep the time forward so that any BeginFrameArgs is not equal to the | 407 // Creep the time forward so that any BeginFrameArgs is not equal to the |
406 // last one otherwise we violate the BeginFrameSource contract. | 408 // last one otherwise we violate the BeginFrameSource contract. |
407 now_src_->AdvanceNow(BeginFrameArgs::DefaultInterval()); | 409 now_src_->Advance(BeginFrameArgs::DefaultInterval()); |
408 BeginFrameArgs args = | 410 BeginFrameArgs args = |
409 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); | 411 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); |
410 fake_external_begin_frame_source_->TestOnBeginFrame(args); | 412 fake_external_begin_frame_source_->TestOnBeginFrame(args); |
411 return args; | 413 return args; |
412 } | 414 } |
413 | 415 |
414 FakeExternalBeginFrameSource* fake_external_begin_frame_source() const { | 416 FakeExternalBeginFrameSource* fake_external_begin_frame_source() const { |
415 return fake_external_begin_frame_source_; | 417 return fake_external_begin_frame_source_; |
416 } | 418 } |
417 | 419 |
418 void MainFrameInHighLatencyMode( | 420 void MainFrameInHighLatencyMode( |
419 int64 begin_main_frame_to_commit_estimate_in_ms, | 421 int64 begin_main_frame_to_commit_estimate_in_ms, |
420 int64 commit_to_activate_estimate_in_ms, | 422 int64 commit_to_activate_estimate_in_ms, |
421 bool impl_latency_takes_priority, | 423 bool impl_latency_takes_priority, |
422 bool should_send_begin_main_frame); | 424 bool should_send_begin_main_frame); |
423 void BeginFramesNotFromClient(bool use_external_begin_frame_source, | 425 void BeginFramesNotFromClient(bool use_external_begin_frame_source, |
424 bool throttle_frame_production); | 426 bool throttle_frame_production); |
425 void BeginFramesNotFromClient_SwapThrottled( | 427 void BeginFramesNotFromClient_SwapThrottled( |
426 bool use_external_begin_frame_source, | 428 bool use_external_begin_frame_source, |
427 bool throttle_frame_production); | 429 bool throttle_frame_production); |
428 void DidLoseOutputSurfaceAfterBeginFrameStartedWithHighLatency( | 430 void DidLoseOutputSurfaceAfterBeginFrameStartedWithHighLatency( |
429 bool impl_side_painting); | 431 bool impl_side_painting); |
430 void DidLoseOutputSurfaceAfterReadyToCommit(bool impl_side_painting); | 432 void DidLoseOutputSurfaceAfterReadyToCommit(bool impl_side_painting); |
431 | 433 |
432 scoped_refptr<TestNowSource> now_src_; | 434 scoped_ptr<base::SimpleTestTickClock> now_src_; |
433 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; | 435 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; |
434 FakeExternalBeginFrameSource* fake_external_begin_frame_source_; | 436 FakeExternalBeginFrameSource* fake_external_begin_frame_source_; |
435 SchedulerSettings scheduler_settings_; | 437 SchedulerSettings scheduler_settings_; |
436 scoped_ptr<FakeSchedulerClient> client_; | 438 scoped_ptr<FakeSchedulerClient> client_; |
437 scoped_ptr<TestScheduler> scheduler_; | 439 scoped_ptr<TestScheduler> scheduler_; |
438 }; | 440 }; |
439 | 441 |
440 TEST_F(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) { | 442 TEST_F(SchedulerTest, InitializeOutputSurfaceDoesNotBeginImplFrame) { |
441 scheduler_settings_.use_external_begin_frame_source = true; | 443 scheduler_settings_.use_external_begin_frame_source = true; |
442 SetUpScheduler(false); | 444 SetUpScheduler(false); |
(...skipping 1368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1811 // Run posted BeginRetroFrame. | 1813 // Run posted BeginRetroFrame. |
1812 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(false)); | 1814 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(false)); |
1813 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 1815 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
1814 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); | 1816 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); |
1815 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1817 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
1816 EXPECT_TRUE(client_->needs_begin_frames()); | 1818 EXPECT_TRUE(client_->needs_begin_frames()); |
1817 client_->Reset(); | 1819 client_->Reset(); |
1818 | 1820 |
1819 // Let time pass sufficiently beyond the regular deadline but not beyond the | 1821 // Let time pass sufficiently beyond the regular deadline but not beyond the |
1820 // late deadline. | 1822 // late deadline. |
1821 now_src()->AdvanceNow(BeginFrameArgs::DefaultInterval() - | 1823 now_src()->Advance(BeginFrameArgs::DefaultInterval() - |
1822 base::TimeDelta::FromMicroseconds(1)); | 1824 base::TimeDelta::FromMicroseconds(1)); |
1823 task_runner().RunUntilTime(now_src()->Now()); | 1825 task_runner().RunUntilTime(now_src()->NowTicks()); |
1824 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1826 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
1825 | 1827 |
1826 // Take us out of a swap throttled state. | 1828 // Take us out of a swap throttled state. |
1827 scheduler_->DidSwapBuffersComplete(); | 1829 scheduler_->DidSwapBuffersComplete(); |
1828 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client_); | 1830 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client_); |
1829 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1831 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
1830 EXPECT_TRUE(client_->needs_begin_frames()); | 1832 EXPECT_TRUE(client_->needs_begin_frames()); |
1831 client_->Reset(); | 1833 client_->Reset(); |
1832 | 1834 |
1833 // Verify that the deadline was rescheduled. | 1835 // Verify that the deadline was rescheduled. |
1834 task_runner().RunUntilTime(now_src()->Now()); | 1836 task_runner().RunUntilTime(now_src()->NowTicks()); |
1835 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); | 1837 EXPECT_SINGLE_ACTION("ScheduledActionDrawAndSwapIfPossible", client_); |
1836 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 1838 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
1837 EXPECT_TRUE(client_->needs_begin_frames()); | 1839 EXPECT_TRUE(client_->needs_begin_frames()); |
1838 client_->Reset(); | 1840 client_->Reset(); |
1839 } | 1841 } |
1840 | 1842 |
1841 TEST_F(SchedulerTest, RetroFrameDoesNotExpireTooEarly) { | 1843 TEST_F(SchedulerTest, RetroFrameDoesNotExpireTooEarly) { |
1842 scheduler_settings_.use_external_begin_frame_source = true; | 1844 scheduler_settings_.use_external_begin_frame_source = true; |
1843 SetUpScheduler(true); | 1845 SetUpScheduler(true); |
1844 | 1846 |
(...skipping 29 matching lines...) Expand all Loading... |
1874 EXPECT_ACTION("ScheduledActionAnimate", client_, 0, 2); | 1876 EXPECT_ACTION("ScheduledActionAnimate", client_, 0, 2); |
1875 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 1, 2); | 1877 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 1, 2); |
1876 | 1878 |
1877 // Keep animating. | 1879 // Keep animating. |
1878 client_->Reset(); | 1880 client_->Reset(); |
1879 scheduler_->SetNeedsAnimate(); | 1881 scheduler_->SetNeedsAnimate(); |
1880 scheduler_->SetNeedsRedraw(); | 1882 scheduler_->SetNeedsRedraw(); |
1881 EXPECT_NO_ACTION(client_); | 1883 EXPECT_NO_ACTION(client_); |
1882 | 1884 |
1883 // Let's advance to the retro frame's deadline. | 1885 // Let's advance to the retro frame's deadline. |
1884 now_src()->AdvanceNow(retro_frame_args.deadline - now_src()->Now()); | 1886 now_src()->Advance(retro_frame_args.deadline - now_src()->NowTicks()); |
1885 | 1887 |
1886 // The retro frame hasn't expired yet. | 1888 // The retro frame hasn't expired yet. |
1887 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(false)); | 1889 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(false)); |
1888 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 1890 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
1889 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); | 1891 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); |
1890 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1892 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
1891 | 1893 |
1892 // This is an immediate deadline case. | 1894 // This is an immediate deadline case. |
1893 client_->Reset(); | 1895 client_->Reset(); |
1894 task_runner().RunPendingTasks(); | 1896 task_runner().RunPendingTasks(); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1932 EXPECT_ACTION("ScheduledActionAnimate", client_, 0, 2); | 1934 EXPECT_ACTION("ScheduledActionAnimate", client_, 0, 2); |
1933 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 1, 2); | 1935 EXPECT_ACTION("ScheduledActionDrawAndSwapIfPossible", client_, 1, 2); |
1934 | 1936 |
1935 // Keep animating. | 1937 // Keep animating. |
1936 client_->Reset(); | 1938 client_->Reset(); |
1937 scheduler_->SetNeedsAnimate(); | 1939 scheduler_->SetNeedsAnimate(); |
1938 scheduler_->SetNeedsRedraw(); | 1940 scheduler_->SetNeedsRedraw(); |
1939 EXPECT_NO_ACTION(client_); | 1941 EXPECT_NO_ACTION(client_); |
1940 | 1942 |
1941 // Let's advance sufficiently past the retro frame's deadline. | 1943 // Let's advance sufficiently past the retro frame's deadline. |
1942 now_src()->AdvanceNow(retro_frame_args.deadline - now_src()->Now() + | 1944 now_src()->Advance(retro_frame_args.deadline - now_src()->NowTicks() + |
1943 base::TimeDelta::FromMicroseconds(1)); | 1945 base::TimeDelta::FromMicroseconds(1)); |
1944 | 1946 |
1945 // The retro frame should've expired. | 1947 // The retro frame should've expired. |
1946 EXPECT_NO_ACTION(client_); | 1948 EXPECT_NO_ACTION(client_); |
1947 } | 1949 } |
1948 | 1950 |
1949 TEST_F(SchedulerTest, MissedFrameDoesNotExpireTooEarly) { | 1951 TEST_F(SchedulerTest, MissedFrameDoesNotExpireTooEarly) { |
1950 scheduler_settings_.use_external_begin_frame_source = true; | 1952 scheduler_settings_.use_external_begin_frame_source = true; |
1951 SetUpScheduler(true); | 1953 SetUpScheduler(true); |
1952 | 1954 |
1953 scheduler_->SetNeedsCommit(); | 1955 scheduler_->SetNeedsCommit(); |
1954 EXPECT_TRUE(client_->needs_begin_frames()); | 1956 EXPECT_TRUE(client_->needs_begin_frames()); |
1955 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); | 1957 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); |
1956 | 1958 |
1957 BeginFrameArgs missed_frame_args = | 1959 BeginFrameArgs missed_frame_args = |
1958 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); | 1960 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); |
1959 missed_frame_args.type = BeginFrameArgs::MISSED; | 1961 missed_frame_args.type = BeginFrameArgs::MISSED; |
1960 | 1962 |
1961 // Advance to the deadline. | 1963 // Advance to the deadline. |
1962 now_src()->AdvanceNow(missed_frame_args.deadline - now_src()->Now()); | 1964 now_src()->Advance(missed_frame_args.deadline - now_src()->NowTicks()); |
1963 | 1965 |
1964 // Missed frame is handled because it's on time. | 1966 // Missed frame is handled because it's on time. |
1965 client_->Reset(); | 1967 client_->Reset(); |
1966 fake_external_begin_frame_source_->TestOnBeginFrame(missed_frame_args); | 1968 fake_external_begin_frame_source_->TestOnBeginFrame(missed_frame_args); |
1967 EXPECT_TRUE( | 1969 EXPECT_TRUE( |
1968 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(false))); | 1970 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(false))); |
1969 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 1971 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
1970 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); | 1972 EXPECT_ACTION("ScheduledActionSendBeginMainFrame", client_, 1, 2); |
1971 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 1973 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
1972 } | 1974 } |
1973 | 1975 |
1974 TEST_F(SchedulerTest, MissedFrameExpiresOnTime) { | 1976 TEST_F(SchedulerTest, MissedFrameExpiresOnTime) { |
1975 scheduler_settings_.use_external_begin_frame_source = true; | 1977 scheduler_settings_.use_external_begin_frame_source = true; |
1976 SetUpScheduler(true); | 1978 SetUpScheduler(true); |
1977 | 1979 |
1978 scheduler_->SetNeedsCommit(); | 1980 scheduler_->SetNeedsCommit(); |
1979 EXPECT_TRUE(client_->needs_begin_frames()); | 1981 EXPECT_TRUE(client_->needs_begin_frames()); |
1980 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); | 1982 EXPECT_SINGLE_ACTION("SetNeedsBeginFrames(true)", client_); |
1981 | 1983 |
1982 BeginFrameArgs missed_frame_args = | 1984 BeginFrameArgs missed_frame_args = |
1983 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); | 1985 CreateBeginFrameArgsForTesting(BEGINFRAME_FROM_HERE, now_src()); |
1984 missed_frame_args.type = BeginFrameArgs::MISSED; | 1986 missed_frame_args.type = BeginFrameArgs::MISSED; |
1985 | 1987 |
1986 // Advance sufficiently past the deadline. | 1988 // Advance sufficiently past the deadline. |
1987 now_src()->AdvanceNow(missed_frame_args.deadline - now_src()->Now() + | 1989 now_src()->Advance(missed_frame_args.deadline - now_src()->NowTicks() + |
1988 base::TimeDelta::FromMicroseconds(1)); | 1990 base::TimeDelta::FromMicroseconds(1)); |
1989 | 1991 |
1990 // Missed frame is dropped because it's too late. | 1992 // Missed frame is dropped because it's too late. |
1991 client_->Reset(); | 1993 client_->Reset(); |
1992 fake_external_begin_frame_source_->TestOnBeginFrame(missed_frame_args); | 1994 fake_external_begin_frame_source_->TestOnBeginFrame(missed_frame_args); |
1993 EXPECT_FALSE( | 1995 EXPECT_FALSE( |
1994 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(false))); | 1996 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(false))); |
1995 EXPECT_NO_ACTION(client_); | 1997 EXPECT_NO_ACTION(client_); |
1996 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 1998 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
1997 } | 1999 } |
1998 | 2000 |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2124 scheduler_->SetNeedsCommit(); | 2126 scheduler_->SetNeedsCommit(); |
2125 scheduler_->SetNeedsRedraw(); | 2127 scheduler_->SetNeedsRedraw(); |
2126 EXPECT_SCOPED(AdvanceFrame()); // Run posted BeginFrame. | 2128 EXPECT_SCOPED(AdvanceFrame()); // Run posted BeginFrame. |
2127 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); | 2129 EXPECT_ACTION("WillBeginImplFrame", client_, 0, 2); |
2128 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); | 2130 EXPECT_ACTION("ScheduledActionAnimate", client_, 1, 2); |
2129 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 2131 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
2130 client_->Reset(); | 2132 client_->Reset(); |
2131 | 2133 |
2132 // Let time pass sufficiently beyond the regular deadline but not beyond the | 2134 // Let time pass sufficiently beyond the regular deadline but not beyond the |
2133 // late deadline. | 2135 // late deadline. |
2134 now_src()->AdvanceNow(BeginFrameArgs::DefaultInterval() - | 2136 now_src()->Advance(BeginFrameArgs::DefaultInterval() - |
2135 base::TimeDelta::FromMicroseconds(1)); | 2137 base::TimeDelta::FromMicroseconds(1)); |
2136 task_runner().RunUntilTime(now_src()->Now()); | 2138 task_runner().RunUntilTime(now_src()->NowTicks()); |
2137 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 2139 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
2138 | 2140 |
2139 // Take us out of a swap throttled state. | 2141 // Take us out of a swap throttled state. |
2140 scheduler_->DidSwapBuffersComplete(); | 2142 scheduler_->DidSwapBuffersComplete(); |
2141 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client_); | 2143 EXPECT_SINGLE_ACTION("ScheduledActionSendBeginMainFrame", client_); |
2142 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 2144 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
2143 client_->Reset(); | 2145 client_->Reset(); |
2144 | 2146 |
2145 // Verify that the deadline was rescheduled. | 2147 // Verify that the deadline was rescheduled. |
2146 // We can't use RunUntilTime(now) here because the next frame is also | 2148 // We can't use RunUntilTime(now) here because the next frame is also |
2147 // scheduled if throttle_frame_production = false. | 2149 // scheduled if throttle_frame_production = false. |
2148 base::TimeTicks before_deadline = now_src()->Now(); | 2150 base::TimeTicks before_deadline = now_src()->NowTicks(); |
2149 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 2151 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
2150 base::TimeTicks after_deadline = now_src()->Now(); | 2152 base::TimeTicks after_deadline = now_src()->NowTicks(); |
2151 EXPECT_EQ(after_deadline, before_deadline); | 2153 EXPECT_EQ(after_deadline, before_deadline); |
2152 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 2154 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
2153 client_->Reset(); | 2155 client_->Reset(); |
2154 } | 2156 } |
2155 | 2157 |
2156 TEST_F(SchedulerTest, SyntheticBeginFrames_SwapThrottled) { | 2158 TEST_F(SchedulerTest, SyntheticBeginFrames_SwapThrottled) { |
2157 bool use_external_begin_frame_source = false; | 2159 bool use_external_begin_frame_source = false; |
2158 bool throttle_frame_production = true; | 2160 bool throttle_frame_production = true; |
2159 BeginFramesNotFromClient_SwapThrottled(use_external_begin_frame_source, | 2161 BeginFramesNotFromClient_SwapThrottled(use_external_begin_frame_source, |
2160 throttle_frame_production); | 2162 throttle_frame_production); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2249 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); | 2251 EXPECT_TRUE(scheduler_->BeginImplFrameDeadlinePending()); |
2250 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); | 2252 task_runner().RunTasksWhile(client_->ImplFrameDeadlinePending(true)); |
2251 // OnBeginImplFrameDeadline didn't schedule output surface creation because | 2253 // OnBeginImplFrameDeadline didn't schedule output surface creation because |
2252 // main frame is not yet completed. | 2254 // main frame is not yet completed. |
2253 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); | 2255 EXPECT_ACTION("SetNeedsBeginFrames(false)", client_, 0, 2); |
2254 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); | 2256 EXPECT_ACTION("SendBeginMainFrameNotExpectedSoon", client_, 1, 2); |
2255 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 2257 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
2256 | 2258 |
2257 // BeginImplFrame is not started. | 2259 // BeginImplFrame is not started. |
2258 client_->Reset(); | 2260 client_->Reset(); |
2259 task_runner().RunUntilTime(now_src()->Now() + | 2261 task_runner().RunUntilTime(now_src()->NowTicks() + |
2260 base::TimeDelta::FromMilliseconds(10)); | 2262 base::TimeDelta::FromMilliseconds(10)); |
2261 EXPECT_NO_ACTION(client_); | 2263 EXPECT_NO_ACTION(client_); |
2262 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); | 2264 EXPECT_FALSE(scheduler_->BeginImplFrameDeadlinePending()); |
2263 | 2265 |
2264 client_->Reset(); | 2266 client_->Reset(); |
2265 scheduler_->NotifyBeginMainFrameStarted(); | 2267 scheduler_->NotifyBeginMainFrameStarted(); |
2266 scheduler_->NotifyReadyToCommit(); | 2268 scheduler_->NotifyReadyToCommit(); |
2267 if (impl_side_painting) { | 2269 if (impl_side_painting) { |
2268 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 3); | 2270 EXPECT_ACTION("ScheduledActionCommit", client_, 0, 3); |
2269 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 3); | 2271 EXPECT_ACTION("ScheduledActionActivateSyncTree", client_, 1, 3); |
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2998 EXPECT_SCOPED(AdvanceFrame()); | 3000 EXPECT_SCOPED(AdvanceFrame()); |
2999 | 3001 |
3000 // At the next BeginFrame, authoritative interval is used instead of previous | 3002 // At the next BeginFrame, authoritative interval is used instead of previous |
3001 // interval. | 3003 // interval. |
3002 EXPECT_NE(initial_interval, scheduler_->BeginImplFrameInterval()); | 3004 EXPECT_NE(initial_interval, scheduler_->BeginImplFrameInterval()); |
3003 EXPECT_EQ(authoritative_interval, scheduler_->BeginImplFrameInterval()); | 3005 EXPECT_EQ(authoritative_interval, scheduler_->BeginImplFrameInterval()); |
3004 } | 3006 } |
3005 | 3007 |
3006 } // namespace | 3008 } // namespace |
3007 } // namespace cc | 3009 } // namespace cc |
OLD | NEW |