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/delay_based_time_source.h" | 5 #include "cc/scheduler/delay_based_time_source.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/test/test_simple_task_runner.h" | 8 #include "base/test/test_simple_task_runner.h" |
9 #include "cc/test/scheduler_test_common.h" | 9 #include "cc/test/scheduler_test_common.h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 | 445 |
446 TEST(DelayBasedTimeSourceTest, TestDeactivateWhilePending) { | 446 TEST(DelayBasedTimeSourceTest, TestDeactivateWhilePending) { |
447 scoped_refptr<base::TestSimpleTaskRunner> task_runner = | 447 scoped_refptr<base::TestSimpleTaskRunner> task_runner = |
448 new base::TestSimpleTaskRunner; | 448 new base::TestSimpleTaskRunner; |
449 FakeTimeSourceClient client; | 449 FakeTimeSourceClient client; |
450 scoped_refptr<FakeDelayBasedTimeSource> timer = | 450 scoped_refptr<FakeDelayBasedTimeSource> timer = |
451 FakeDelayBasedTimeSource::Create(Interval(), task_runner.get()); | 451 FakeDelayBasedTimeSource::Create(Interval(), task_runner.get()); |
452 timer->SetClient(&client); | 452 timer->SetClient(&client); |
453 timer->SetActive(true); // Should post a task. | 453 timer->SetActive(true); // Should post a task. |
454 timer->SetActive(false); | 454 timer->SetActive(false); |
455 timer = NULL; | 455 timer = nullptr; |
456 // Should run the posted task without crashing. | 456 // Should run the posted task without crashing. |
457 EXPECT_TRUE(task_runner->HasPendingTask()); | 457 EXPECT_TRUE(task_runner->HasPendingTask()); |
458 task_runner->RunPendingTasks(); | 458 task_runner->RunPendingTasks(); |
459 } | 459 } |
460 | 460 |
461 TEST(DelayBasedTimeSourceTest, TestDeactivateAndReactivateBeforeNextTickTime) { | 461 TEST(DelayBasedTimeSourceTest, TestDeactivateAndReactivateBeforeNextTickTime) { |
462 scoped_refptr<base::TestSimpleTaskRunner> task_runner = | 462 scoped_refptr<base::TestSimpleTaskRunner> task_runner = |
463 new base::TestSimpleTaskRunner; | 463 new base::TestSimpleTaskRunner; |
464 FakeTimeSourceClient client; | 464 FakeTimeSourceClient client; |
465 scoped_refptr<FakeDelayBasedTimeSource> timer = | 465 scoped_refptr<FakeDelayBasedTimeSource> timer = |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 timer->SetActive(true); | 536 timer->SetActive(true); |
537 task_runner->RunPendingTasks(); | 537 task_runner->RunPendingTasks(); |
538 | 538 |
539 // SetActive should return empty TimeTicks when the timer is deactivated. | 539 // SetActive should return empty TimeTicks when the timer is deactivated. |
540 base::TimeTicks missed_tick_time = timer->SetActive(false); | 540 base::TimeTicks missed_tick_time = timer->SetActive(false); |
541 EXPECT_TRUE(missed_tick_time.is_null()); | 541 EXPECT_TRUE(missed_tick_time.is_null()); |
542 } | 542 } |
543 | 543 |
544 } // namespace | 544 } // namespace |
545 } // namespace cc | 545 } // namespace cc |
OLD | NEW |