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

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

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

Powered by Google App Engine
This is Rietveld 408576698