| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "components/scheduler/renderer/throttling_helper.h" | 5 #include "components/scheduler/renderer/throttling_helper.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 | 10 |
| (...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 353 | 353 |
| 354 mock_task_runner_->RunUntilIdle(); | 354 mock_task_runner_->RunUntilIdle(); |
| 355 | 355 |
| 356 EXPECT_THAT( | 356 EXPECT_THAT( |
| 357 run_times, | 357 run_times, |
| 358 ElementsAre( | 358 ElementsAre( |
| 359 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1000.0), | 359 base::TimeTicks() + base::TimeDelta::FromMilliseconds(1000.0), |
| 360 base::TimeTicks() + base::TimeDelta::FromMilliseconds(3000.0))); | 360 base::TimeTicks() + base::TimeDelta::FromMilliseconds(3000.0))); |
| 361 } | 361 } |
| 362 | 362 |
| 363 TEST_F(ThrottlingHelperTest, ThrottledTasksReportRealTime) { |
| 364 EXPECT_EQ(timer_queue_->GetTimeDomain()->Now(), clock_->NowTicks()); |
| 365 |
| 366 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get()); |
| 367 EXPECT_EQ(timer_queue_->GetTimeDomain()->Now(), clock_->NowTicks()); |
| 368 |
| 369 clock_->Advance(base::TimeDelta::FromMilliseconds(250)); |
| 370 // Make sure the throttled time domain's Now() reports the same as the |
| 371 // underlying clock. |
| 372 EXPECT_EQ(timer_queue_->GetTimeDomain()->Now(), clock_->NowTicks()); |
| 373 } |
| 374 |
| 363 TEST_F(ThrottlingHelperTest, TaskQueueDisabledTillPump) { | 375 TEST_F(ThrottlingHelperTest, TaskQueueDisabledTillPump) { |
| 364 timer_queue_->PostTask(FROM_HERE, base::Bind(&NopTask)); | 376 timer_queue_->PostTask(FROM_HERE, base::Bind(&NopTask)); |
| 365 | 377 |
| 366 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); | 378 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); |
| 367 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get()); | 379 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get()); |
| 368 EXPECT_FALSE(timer_queue_->IsQueueEnabled()); | 380 EXPECT_FALSE(timer_queue_->IsQueueEnabled()); |
| 369 | 381 |
| 370 mock_task_runner_->RunUntilIdle(); // Wait until the pump. | 382 mock_task_runner_->RunUntilIdle(); // Wait until the pump. |
| 371 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); | 383 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); |
| 372 } | 384 } |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); | 446 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); |
| 435 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get()); | 447 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get()); |
| 436 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get()); | 448 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get()); |
| 437 EXPECT_FALSE(timer_queue_->IsQueueEnabled()); | 449 EXPECT_FALSE(timer_queue_->IsQueueEnabled()); |
| 438 throttling_helper_->DecreaseThrottleRefCount(timer_queue_.get()); | 450 throttling_helper_->DecreaseThrottleRefCount(timer_queue_.get()); |
| 439 throttling_helper_->DecreaseThrottleRefCount(timer_queue_.get()); | 451 throttling_helper_->DecreaseThrottleRefCount(timer_queue_.get()); |
| 440 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); | 452 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); |
| 441 } | 453 } |
| 442 | 454 |
| 443 } // namespace scheduler | 455 } // namespace scheduler |
| OLD | NEW |