| 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, TaskQueueDisabledTillPump) { |
| 364 timer_queue_->PostTask(FROM_HERE, base::Bind(&NopTask)); |
| 365 |
| 366 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); |
| 367 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get()); |
| 368 EXPECT_FALSE(timer_queue_->IsQueueEnabled()); |
| 369 |
| 370 mock_task_runner_->RunUntilIdle(); // Wait until the pump. |
| 371 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); |
| 372 } |
| 373 |
| 374 TEST_F(ThrottlingHelperTest, TaskQueueEnabledOnUnthrottle) { |
| 375 timer_queue_->PostTask(FROM_HERE, base::Bind(&NopTask)); |
| 376 |
| 377 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get()); |
| 378 EXPECT_FALSE(timer_queue_->IsQueueEnabled()); |
| 379 |
| 380 throttling_helper_->DecreaseThrottleRefCount(timer_queue_.get()); |
| 381 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); |
| 382 } |
| 383 |
| 363 } // namespace scheduler | 384 } // namespace scheduler |
| OLD | NEW |