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 <deque> | 5 #include <deque> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/gtest_prod_util.h" | 9 #include "base/gtest_prod_util.h" |
10 #include "base/test/test_simple_task_runner.h" | 10 #include "base/test/test_simple_task_runner.h" |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 | 307 |
308 scoped_refptr<base::trace_event::TracedValue> state = | 308 scoped_refptr<base::trace_event::TracedValue> state = |
309 new base::trace_event::TracedValue(); | 309 new base::trace_event::TracedValue(); |
310 source.AsValueInto(state.get()); | 310 source.AsValueInto(state.get()); |
311 } | 311 } |
312 | 312 |
313 // BackToBackBeginFrameSource testing ----------------------------------------- | 313 // BackToBackBeginFrameSource testing ----------------------------------------- |
314 class TestBackToBackBeginFrameSource : public BackToBackBeginFrameSource { | 314 class TestBackToBackBeginFrameSource : public BackToBackBeginFrameSource { |
315 public: | 315 public: |
316 static scoped_ptr<TestBackToBackBeginFrameSource> Create( | 316 static scoped_ptr<TestBackToBackBeginFrameSource> Create( |
317 scoped_refptr<TestNowSource> now_src, | 317 base::SimpleTestTickClock* now_src, |
318 base::SingleThreadTaskRunner* task_runner) { | 318 base::SingleThreadTaskRunner* task_runner) { |
319 return make_scoped_ptr( | 319 return make_scoped_ptr( |
320 new TestBackToBackBeginFrameSource(now_src, task_runner)); | 320 new TestBackToBackBeginFrameSource(now_src, task_runner)); |
321 } | 321 } |
322 | 322 |
323 protected: | 323 protected: |
324 TestBackToBackBeginFrameSource(scoped_refptr<TestNowSource> now_src, | 324 TestBackToBackBeginFrameSource(base::SimpleTestTickClock* now_src, |
325 base::SingleThreadTaskRunner* task_runner) | 325 base::SingleThreadTaskRunner* task_runner) |
326 : BackToBackBeginFrameSource(task_runner), now_src_(now_src) {} | 326 : BackToBackBeginFrameSource(task_runner), now_src_(now_src) {} |
327 | 327 |
328 base::TimeTicks Now() override { return now_src_->Now(); } | 328 base::TimeTicks Now() override { return now_src_->NowTicks(); } |
329 | 329 |
330 scoped_refptr<TestNowSource> now_src_; | 330 base::SimpleTestTickClock* now_src_; |
331 }; | 331 }; |
332 | 332 |
333 class BackToBackBeginFrameSourceTest : public ::testing::Test { | 333 class BackToBackBeginFrameSourceTest : public ::testing::Test { |
334 public: | 334 public: |
335 static const int64_t kDeadline; | 335 static const int64_t kDeadline; |
336 static const int64_t kInterval; | 336 static const int64_t kInterval; |
337 | 337 |
338 scoped_refptr<TestNowSource> now_src_; | 338 scoped_ptr<base::SimpleTestTickClock> now_src_; |
339 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; | 339 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; |
340 scoped_ptr<TestBackToBackBeginFrameSource> source_; | 340 scoped_ptr<TestBackToBackBeginFrameSource> source_; |
341 scoped_ptr<MockBeginFrameObserver> obs_; | 341 scoped_ptr<MockBeginFrameObserver> obs_; |
342 | 342 |
343 void SetUp() override { | 343 void SetUp() override { |
344 now_src_ = TestNowSource::Create(1000); | 344 now_src_.reset(new base::SimpleTestTickClock()); |
| 345 now_src_->Advance(base::TimeDelta::FromInternalValue(1000)); |
345 task_runner_ = | 346 task_runner_ = |
346 make_scoped_refptr(new OrderedSimpleTaskRunner(now_src_, false)); | 347 make_scoped_refptr(new OrderedSimpleTaskRunner(now_src_.get(), false)); |
347 task_runner_->SetRunTaskLimit(1); | 348 task_runner_->SetRunTaskLimit(1); |
348 source_ = | 349 source_ = TestBackToBackBeginFrameSource::Create(now_src_.get(), |
349 TestBackToBackBeginFrameSource::Create(now_src_, task_runner_.get()); | 350 task_runner_.get()); |
350 obs_ = make_scoped_ptr(new ::testing::StrictMock<MockBeginFrameObserver>()); | 351 obs_ = make_scoped_ptr(new ::testing::StrictMock<MockBeginFrameObserver>()); |
351 source_->AddObserver(obs_.get()); | 352 source_->AddObserver(obs_.get()); |
352 } | 353 } |
353 | 354 |
354 void TearDown() override { obs_.reset(); } | 355 void TearDown() override { obs_.reset(); } |
355 }; | 356 }; |
356 | 357 |
357 const int64_t BackToBackBeginFrameSourceTest::kDeadline = | 358 const int64_t BackToBackBeginFrameSourceTest::kDeadline = |
358 BeginFrameArgs::DefaultInterval().ToInternalValue(); | 359 BeginFrameArgs::DefaultInterval().ToInternalValue(); |
359 | 360 |
360 const int64_t BackToBackBeginFrameSourceTest::kInterval = | 361 const int64_t BackToBackBeginFrameSourceTest::kInterval = |
361 BeginFrameArgs::DefaultInterval().ToInternalValue(); | 362 BeginFrameArgs::DefaultInterval().ToInternalValue(); |
362 | 363 |
363 TEST_F(BackToBackBeginFrameSourceTest, SetNeedsBeginFramesSendsBeginFrame) { | 364 TEST_F(BackToBackBeginFrameSourceTest, SetNeedsBeginFramesSendsBeginFrame) { |
364 EXPECT_BEGIN_FRAME_USED(*obs_, 1000, 1000 + kDeadline, kInterval); | 365 EXPECT_BEGIN_FRAME_USED(*obs_, 1000, 1000 + kDeadline, kInterval); |
365 source_->SetNeedsBeginFrames(true); | 366 source_->SetNeedsBeginFrames(true); |
366 EXPECT_TRUE(task_runner_->HasPendingTasks()); | 367 EXPECT_TRUE(task_runner_->HasPendingTasks()); |
367 task_runner_->RunUntilIdle(); | 368 task_runner_->RunUntilIdle(); |
368 | 369 |
369 EXPECT_BEGIN_FRAME_USED(*obs_, 1100, 1100 + kDeadline, kInterval); | 370 EXPECT_BEGIN_FRAME_USED(*obs_, 1100, 1100 + kDeadline, kInterval); |
370 now_src_->AdvanceNowMicroseconds(100); | 371 now_src_->Advance(base::TimeDelta::FromMicroseconds(100)); |
371 source_->DidFinishFrame(0); | 372 source_->DidFinishFrame(0); |
372 task_runner_->RunUntilIdle(); | 373 task_runner_->RunUntilIdle(); |
373 } | 374 } |
374 | 375 |
375 TEST_F(BackToBackBeginFrameSourceTest, | 376 TEST_F(BackToBackBeginFrameSourceTest, |
376 DidFinishFrameThenSetNeedsBeginFramesProducesNoFrame) { | 377 DidFinishFrameThenSetNeedsBeginFramesProducesNoFrame) { |
377 EXPECT_BEGIN_FRAME_USED(*obs_, 1000, 1000 + kDeadline, kInterval); | 378 EXPECT_BEGIN_FRAME_USED(*obs_, 1000, 1000 + kDeadline, kInterval); |
378 source_->SetNeedsBeginFrames(true); | 379 source_->SetNeedsBeginFrames(true); |
379 task_runner_->RunUntilIdle(); | 380 task_runner_->RunUntilIdle(); |
380 | 381 |
381 source_->SetNeedsBeginFrames(false); | 382 source_->SetNeedsBeginFrames(false); |
382 source_->DidFinishFrame(0); | 383 source_->DidFinishFrame(0); |
383 | 384 |
384 EXPECT_FALSE(task_runner_->HasPendingTasks()); | 385 EXPECT_FALSE(task_runner_->HasPendingTasks()); |
385 } | 386 } |
386 | 387 |
387 TEST_F(BackToBackBeginFrameSourceTest, | 388 TEST_F(BackToBackBeginFrameSourceTest, |
388 SetNeedsBeginFramesThenDidFinishFrameProducesNoFrame) { | 389 SetNeedsBeginFramesThenDidFinishFrameProducesNoFrame) { |
389 EXPECT_BEGIN_FRAME_USED(*obs_, 1000, 1000 + kDeadline, kInterval); | 390 EXPECT_BEGIN_FRAME_USED(*obs_, 1000, 1000 + kDeadline, kInterval); |
390 source_->SetNeedsBeginFrames(true); | 391 source_->SetNeedsBeginFrames(true); |
391 task_runner_->RunUntilIdle(); | 392 task_runner_->RunUntilIdle(); |
392 | 393 |
393 now_src_->AdvanceNowMicroseconds(100); | 394 now_src_->Advance(base::TimeDelta::FromMicroseconds(100)); |
394 source_->DidFinishFrame(0); | 395 source_->DidFinishFrame(0); |
395 source_->SetNeedsBeginFrames(false); | 396 source_->SetNeedsBeginFrames(false); |
396 | 397 |
397 EXPECT_TRUE(task_runner_->HasPendingTasks()); | 398 EXPECT_TRUE(task_runner_->HasPendingTasks()); |
398 task_runner_->RunUntilIdle(); | 399 task_runner_->RunUntilIdle(); |
399 } | 400 } |
400 | 401 |
401 TEST_F(BackToBackBeginFrameSourceTest, | 402 TEST_F(BackToBackBeginFrameSourceTest, |
402 DidFinishFrameThenTogglingSetNeedsBeginFramesProducesCorrectFrame) { | 403 DidFinishFrameThenTogglingSetNeedsBeginFramesProducesCorrectFrame) { |
403 EXPECT_BEGIN_FRAME_USED(*obs_, 1000, 1000 + kDeadline, kInterval); | 404 EXPECT_BEGIN_FRAME_USED(*obs_, 1000, 1000 + kDeadline, kInterval); |
404 source_->SetNeedsBeginFrames(true); | 405 source_->SetNeedsBeginFrames(true); |
405 task_runner_->RunUntilIdle(); | 406 task_runner_->RunUntilIdle(); |
406 | 407 |
407 now_src_->AdvanceNowMicroseconds(100); | 408 now_src_->Advance(base::TimeDelta::FromMicroseconds(100)); |
408 | 409 |
409 source_->SetNeedsBeginFrames(false); | 410 source_->SetNeedsBeginFrames(false); |
410 now_src_->AdvanceNowMicroseconds(10); | 411 now_src_->Advance(base::TimeDelta::FromMicroseconds(10)); |
411 source_->DidFinishFrame(0); | 412 source_->DidFinishFrame(0); |
412 now_src_->AdvanceNowMicroseconds(10); | 413 now_src_->Advance(base::TimeDelta::FromMicroseconds(10)); |
413 source_->SetNeedsBeginFrames(false); | 414 source_->SetNeedsBeginFrames(false); |
414 now_src_->AdvanceNowMicroseconds(10); | 415 now_src_->Advance(base::TimeDelta::FromMicroseconds(10)); |
415 source_->SetNeedsBeginFrames(true); | 416 source_->SetNeedsBeginFrames(true); |
416 | 417 |
417 EXPECT_BEGIN_FRAME_USED(*obs_, 1130, 1130 + kDeadline, kInterval); | 418 EXPECT_BEGIN_FRAME_USED(*obs_, 1130, 1130 + kDeadline, kInterval); |
418 EXPECT_TRUE(task_runner_->HasPendingTasks()); | 419 EXPECT_TRUE(task_runner_->HasPendingTasks()); |
419 task_runner_->RunUntilIdle(); | 420 task_runner_->RunUntilIdle(); |
420 } | 421 } |
421 | 422 |
422 TEST_F(BackToBackBeginFrameSourceTest, | 423 TEST_F(BackToBackBeginFrameSourceTest, |
423 TogglingSetNeedsBeginFramesThenDidFinishFrameProducesCorrectFrame) { | 424 TogglingSetNeedsBeginFramesThenDidFinishFrameProducesCorrectFrame) { |
424 EXPECT_BEGIN_FRAME_USED(*obs_, 1000, 1000 + kDeadline, kInterval); | 425 EXPECT_BEGIN_FRAME_USED(*obs_, 1000, 1000 + kDeadline, kInterval); |
425 source_->SetNeedsBeginFrames(true); | 426 source_->SetNeedsBeginFrames(true); |
426 task_runner_->RunUntilIdle(); | 427 task_runner_->RunUntilIdle(); |
427 | 428 |
428 now_src_->AdvanceNowMicroseconds(100); | 429 now_src_->Advance(base::TimeDelta::FromMicroseconds(100)); |
429 source_->DidFinishFrame(0); | 430 source_->DidFinishFrame(0); |
430 now_src_->AdvanceNowMicroseconds(10); | 431 now_src_->Advance(base::TimeDelta::FromMicroseconds(10)); |
431 source_->SetNeedsBeginFrames(false); | 432 source_->SetNeedsBeginFrames(false); |
432 now_src_->AdvanceNowMicroseconds(10); | 433 now_src_->Advance(base::TimeDelta::FromMicroseconds(10)); |
433 source_->SetNeedsBeginFrames(true); | 434 source_->SetNeedsBeginFrames(true); |
434 now_src_->AdvanceNowMicroseconds(10); | 435 now_src_->Advance(base::TimeDelta::FromMicroseconds(10)); |
435 | 436 |
436 EXPECT_BEGIN_FRAME_USED(*obs_, 1130, 1130 + kDeadline, kInterval); | 437 EXPECT_BEGIN_FRAME_USED(*obs_, 1130, 1130 + kDeadline, kInterval); |
437 EXPECT_TRUE(task_runner_->HasPendingTasks()); | 438 EXPECT_TRUE(task_runner_->HasPendingTasks()); |
438 task_runner_->RunUntilIdle(); | 439 task_runner_->RunUntilIdle(); |
439 } | 440 } |
440 | 441 |
441 TEST_F(BackToBackBeginFrameSourceTest, DidFinishFrameNeedsBeginFrameFalse) { | 442 TEST_F(BackToBackBeginFrameSourceTest, DidFinishFrameNeedsBeginFrameFalse) { |
442 source_->SetNeedsBeginFrames(false); | 443 source_->SetNeedsBeginFrames(false); |
443 source_->DidFinishFrame(0); | 444 source_->DidFinishFrame(0); |
444 EXPECT_FALSE(task_runner_->RunPendingTasks()); | 445 EXPECT_FALSE(task_runner_->RunPendingTasks()); |
445 } | 446 } |
446 | 447 |
447 TEST_F(BackToBackBeginFrameSourceTest, DidFinishFrameRemainingFrames) { | 448 TEST_F(BackToBackBeginFrameSourceTest, DidFinishFrameRemainingFrames) { |
448 EXPECT_BEGIN_FRAME_USED(*obs_, 1000, 1000 + kDeadline, kInterval); | 449 EXPECT_BEGIN_FRAME_USED(*obs_, 1000, 1000 + kDeadline, kInterval); |
449 source_->SetNeedsBeginFrames(true); | 450 source_->SetNeedsBeginFrames(true); |
450 task_runner_->RunUntilIdle(); | 451 task_runner_->RunUntilIdle(); |
451 | 452 |
452 now_src_->AdvanceNowMicroseconds(100); | 453 now_src_->Advance(base::TimeDelta::FromMicroseconds(100)); |
453 | 454 |
454 source_->DidFinishFrame(3); | 455 source_->DidFinishFrame(3); |
455 EXPECT_FALSE(task_runner_->HasPendingTasks()); | 456 EXPECT_FALSE(task_runner_->HasPendingTasks()); |
456 source_->DidFinishFrame(2); | 457 source_->DidFinishFrame(2); |
457 EXPECT_FALSE(task_runner_->HasPendingTasks()); | 458 EXPECT_FALSE(task_runner_->HasPendingTasks()); |
458 source_->DidFinishFrame(1); | 459 source_->DidFinishFrame(1); |
459 EXPECT_FALSE(task_runner_->HasPendingTasks()); | 460 EXPECT_FALSE(task_runner_->HasPendingTasks()); |
460 | 461 |
461 EXPECT_BEGIN_FRAME_USED(*obs_, 1100, 1100 + kDeadline, kInterval); | 462 EXPECT_BEGIN_FRAME_USED(*obs_, 1100, 1100 + kDeadline, kInterval); |
462 source_->DidFinishFrame(0); | 463 source_->DidFinishFrame(0); |
463 EXPECT_EQ(base::TimeDelta(), task_runner_->DelayToNextTaskTime()); | 464 EXPECT_EQ(base::TimeDelta(), task_runner_->DelayToNextTaskTime()); |
464 task_runner_->RunUntilIdle(); | 465 task_runner_->RunUntilIdle(); |
465 } | 466 } |
466 | 467 |
467 TEST_F(BackToBackBeginFrameSourceTest, DidFinishFrameMultipleCallsIdempotent) { | 468 TEST_F(BackToBackBeginFrameSourceTest, DidFinishFrameMultipleCallsIdempotent) { |
468 source_->SetNeedsBeginFrames(true); | 469 source_->SetNeedsBeginFrames(true); |
469 EXPECT_BEGIN_FRAME_USED(*obs_, 1000, 1000 + kDeadline, kInterval); | 470 EXPECT_BEGIN_FRAME_USED(*obs_, 1000, 1000 + kDeadline, kInterval); |
470 task_runner_->RunUntilIdle(); | 471 task_runner_->RunUntilIdle(); |
471 | 472 |
472 now_src_->AdvanceNowMicroseconds(100); | 473 now_src_->Advance(base::TimeDelta::FromMicroseconds(100)); |
473 source_->DidFinishFrame(0); | 474 source_->DidFinishFrame(0); |
474 source_->DidFinishFrame(0); | 475 source_->DidFinishFrame(0); |
475 source_->DidFinishFrame(0); | 476 source_->DidFinishFrame(0); |
476 EXPECT_BEGIN_FRAME_USED(*obs_, 1100, 1100 + kDeadline, kInterval); | 477 EXPECT_BEGIN_FRAME_USED(*obs_, 1100, 1100 + kDeadline, kInterval); |
477 task_runner_->RunUntilIdle(); | 478 task_runner_->RunUntilIdle(); |
478 | 479 |
479 now_src_->AdvanceNowMicroseconds(100); | 480 now_src_->Advance(base::TimeDelta::FromMicroseconds(100)); |
480 source_->DidFinishFrame(0); | 481 source_->DidFinishFrame(0); |
481 source_->DidFinishFrame(0); | 482 source_->DidFinishFrame(0); |
482 source_->DidFinishFrame(0); | 483 source_->DidFinishFrame(0); |
483 EXPECT_BEGIN_FRAME_USED(*obs_, 1200, 1200 + kDeadline, kInterval); | 484 EXPECT_BEGIN_FRAME_USED(*obs_, 1200, 1200 + kDeadline, kInterval); |
484 task_runner_->RunUntilIdle(); | 485 task_runner_->RunUntilIdle(); |
485 } | 486 } |
486 | 487 |
487 TEST_F(BackToBackBeginFrameSourceTest, DelayInPostedTaskProducesCorrectFrame) { | 488 TEST_F(BackToBackBeginFrameSourceTest, DelayInPostedTaskProducesCorrectFrame) { |
488 EXPECT_BEGIN_FRAME_USED(*obs_, 1000, 1000 + kDeadline, kInterval); | 489 EXPECT_BEGIN_FRAME_USED(*obs_, 1000, 1000 + kDeadline, kInterval); |
489 source_->SetNeedsBeginFrames(true); | 490 source_->SetNeedsBeginFrames(true); |
490 task_runner_->RunUntilIdle(); | 491 task_runner_->RunUntilIdle(); |
491 | 492 |
492 now_src_->AdvanceNowMicroseconds(100); | 493 now_src_->Advance(base::TimeDelta::FromMicroseconds(100)); |
493 source_->DidFinishFrame(0); | 494 source_->DidFinishFrame(0); |
494 now_src_->AdvanceNowMicroseconds(50); | 495 now_src_->Advance(base::TimeDelta::FromMicroseconds(50)); |
495 EXPECT_BEGIN_FRAME_USED(*obs_, 1150, 1150 + kDeadline, kInterval); | 496 EXPECT_BEGIN_FRAME_USED(*obs_, 1150, 1150 + kDeadline, kInterval); |
496 | 497 |
497 EXPECT_TRUE(task_runner_->HasPendingTasks()); | 498 EXPECT_TRUE(task_runner_->HasPendingTasks()); |
498 task_runner_->RunUntilIdle(); | 499 task_runner_->RunUntilIdle(); |
499 } | 500 } |
500 | 501 |
501 // SyntheticBeginFrameSource testing ------------------------------------------ | 502 // SyntheticBeginFrameSource testing ------------------------------------------ |
502 class SyntheticBeginFrameSourceTest : public ::testing::Test { | 503 class SyntheticBeginFrameSourceTest : public ::testing::Test { |
503 public: | 504 public: |
504 scoped_refptr<TestNowSource> now_src_; | 505 scoped_ptr<base::SimpleTestTickClock> now_src_; |
505 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; | 506 scoped_refptr<OrderedSimpleTaskRunner> task_runner_; |
506 scoped_ptr<TestSyntheticBeginFrameSource> source_; | 507 scoped_ptr<TestSyntheticBeginFrameSource> source_; |
507 scoped_ptr<MockBeginFrameObserver> obs_; | 508 scoped_ptr<MockBeginFrameObserver> obs_; |
508 | 509 |
509 void SetUp() override { | 510 void SetUp() override { |
510 now_src_ = TestNowSource::Create(1000); | 511 now_src_.reset(new base::SimpleTestTickClock()); |
| 512 now_src_->Advance(base::TimeDelta::FromInternalValue(1000)); |
511 task_runner_ = | 513 task_runner_ = |
512 make_scoped_refptr(new OrderedSimpleTaskRunner(now_src_, false)); | 514 make_scoped_refptr(new OrderedSimpleTaskRunner(now_src_.get(), false)); |
513 source_ = TestSyntheticBeginFrameSource::Create( | 515 source_ = TestSyntheticBeginFrameSource::Create( |
514 now_src_, task_runner_.get(), base::TimeDelta::FromMicroseconds(10000)); | 516 now_src_.get(), task_runner_.get(), |
| 517 base::TimeDelta::FromMicroseconds(10000)); |
515 obs_ = make_scoped_ptr(new MockBeginFrameObserver()); | 518 obs_ = make_scoped_ptr(new MockBeginFrameObserver()); |
516 source_->AddObserver(obs_.get()); | 519 source_->AddObserver(obs_.get()); |
517 } | 520 } |
518 | 521 |
519 void TearDown() override { obs_.reset(); } | 522 void TearDown() override { obs_.reset(); } |
520 }; | 523 }; |
521 | 524 |
522 TEST_F(SyntheticBeginFrameSourceTest, | 525 TEST_F(SyntheticBeginFrameSourceTest, |
523 SetNeedsBeginFramesCallsOnBeginFrameWithMissedTick) { | 526 SetNeedsBeginFramesCallsOnBeginFrameWithMissedTick) { |
524 now_src_->SetNowMicroseconds(10010); | 527 now_src_->Advance(base::TimeDelta::FromInternalValue(9010)); |
525 EXPECT_CALL((*obs_), OnBeginFrame(CreateBeginFrameArgsForTesting( | 528 EXPECT_CALL((*obs_), OnBeginFrame(CreateBeginFrameArgsForTesting( |
526 BEGINFRAME_FROM_HERE, 10000, 20000, 10000, | 529 BEGINFRAME_FROM_HERE, 10000, 20000, 10000, |
527 BeginFrameArgs::MISSED))); | 530 BeginFrameArgs::MISSED))); |
528 source_->SetNeedsBeginFrames(true); // Should cause the last tick to be sent | 531 source_->SetNeedsBeginFrames(true); // Should cause the last tick to be sent |
529 // No tasks should need to be run for this to occur. | 532 // No tasks should need to be run for this to occur. |
530 } | 533 } |
531 | 534 |
532 TEST_F(SyntheticBeginFrameSourceTest, | 535 TEST_F(SyntheticBeginFrameSourceTest, |
533 SetNeedsBeginFramesCallsCausesOnBeginFrame) { | 536 SetNeedsBeginFramesCallsCausesOnBeginFrame) { |
534 source_->SetNeedsBeginFrames(true); | 537 source_->SetNeedsBeginFrames(true); |
535 EXPECT_EQ(10000, task_runner_->NextTaskTime().ToInternalValue()); | 538 EXPECT_EQ(10000, task_runner_->NextTaskTime().ToInternalValue()); |
536 | 539 |
537 EXPECT_BEGIN_FRAME_USED(*obs_, 10000, 20000, 10000); | 540 EXPECT_BEGIN_FRAME_USED(*obs_, 10000, 20000, 10000); |
538 now_src_->SetNowMicroseconds(10010); | 541 now_src_->Advance(base::TimeDelta::FromInternalValue(9010)); |
539 task_runner_->RunPendingTasks(); | 542 task_runner_->RunPendingTasks(); |
540 } | 543 } |
541 | 544 |
542 TEST_F(SyntheticBeginFrameSourceTest, BasicOperation) { | 545 TEST_F(SyntheticBeginFrameSourceTest, BasicOperation) { |
543 task_runner_->SetAutoAdvanceNowToPendingTasks(true); | 546 task_runner_->SetAutoAdvanceNowToPendingTasks(true); |
544 | 547 |
545 source_->SetNeedsBeginFrames(true); | 548 source_->SetNeedsBeginFrames(true); |
546 EXPECT_BEGIN_FRAME_USED(*obs_, 10000, 20000, 10000); | 549 EXPECT_BEGIN_FRAME_USED(*obs_, 10000, 20000, 10000); |
547 EXPECT_BEGIN_FRAME_USED(*obs_, 20000, 30000, 10000); | 550 EXPECT_BEGIN_FRAME_USED(*obs_, 20000, 30000, 10000); |
548 EXPECT_BEGIN_FRAME_USED(*obs_, 30000, 40000, 10000); | 551 EXPECT_BEGIN_FRAME_USED(*obs_, 30000, 40000, 10000); |
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
766 mux_->SetActiveSource(source2_); | 769 mux_->SetActiveSource(source2_); |
767 SEND_BEGIN_FRAME_DROP(*source2_, 750, 1050, 300); | 770 SEND_BEGIN_FRAME_DROP(*source2_, 750, 1050, 300); |
768 SEND_BEGIN_FRAME_USED(*source2_, 1050, 1250, 300); | 771 SEND_BEGIN_FRAME_USED(*source2_, 1050, 1250, 300); |
769 | 772 |
770 mux_->SetActiveSource(source1_); | 773 mux_->SetActiveSource(source1_); |
771 SEND_BEGIN_FRAME_DROP(*source2_, 1100, 1400, 300); | 774 SEND_BEGIN_FRAME_DROP(*source2_, 1100, 1400, 300); |
772 } | 775 } |
773 | 776 |
774 } // namespace | 777 } // namespace |
775 } // namespace cc | 778 } // namespace cc |
OLD | NEW |