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

Unified Diff: third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler_unittest.cc

Issue 2548483002: [scheduler] Account for disabling throttling in TaskQueueThrottler::IsThrottled (Closed)
Patch Set: Created 4 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler_unittest.cc
diff --git a/third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler_unittest.cc b/third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler_unittest.cc
index 47bcf16d4f9201630fe49ac1ba2e61383fc45a9d..fa5e09bf510c4b1892f563c9f9399d4a3772d6a4 100644
--- a/third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler_unittest.cc
+++ b/third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler_unittest.cc
@@ -992,5 +992,65 @@ TEST_F(TaskQueueThrottlerTest, GrantAdditionalBudget) {
pool->Close();
}
+TEST_F(TaskQueueThrottlerTest, EnableAndDisableThrottlingAndTimeBudgets) {
+ // This test checks that if time budget pool is enabled when throttling
+ // is disabled, it does not throttle the queue.
+ std::vector<base::TimeTicks> run_times;
+
+ task_queue_throttler_->DisableThrottling();
+
+ TaskQueueThrottler::TimeBudgetPool* pool =
+ task_queue_throttler_->CreateTimeBudgetPool("test", base::nullopt,
+ base::nullopt);
+ task_queue_throttler_->IncreaseThrottleRefCount(timer_queue_.get());
+
+ LazyNow lazy_now(clock_.get());
+ pool->DisableThrottling(&lazy_now);
+
+ pool->AddQueue(base::TimeTicks(), timer_queue_.get());
+
+ mock_task_runner_->RunUntilTime(base::TimeTicks() +
+ base::TimeDelta::FromMilliseconds(100));
+
+ lazy_now = LazyNow(clock_.get());
+ pool->EnableThrottling(&lazy_now);
+
+ timer_queue_->PostDelayedTask(FROM_HERE,
+ base::Bind(&TestTask, &run_times, clock_.get()),
+ base::TimeDelta::FromMilliseconds(200));
+
+ mock_task_runner_->RunUntilIdle();
+
+ EXPECT_THAT(run_times, ElementsAre(base::TimeTicks() +
+ base::TimeDelta::FromMilliseconds(300)));
+}
+
+TEST_F(TaskQueueThrottlerTest, AddQueueToBudgetPoolWhenThrottlingDisabled) {
+ // This test checks that a task queue is added to time budget pool
+ // when throttling is disabled, is does not throttle queue.
+ std::vector<base::TimeTicks> run_times;
+
+ task_queue_throttler_->DisableThrottling();
+
+ TaskQueueThrottler::TimeBudgetPool* pool =
+ task_queue_throttler_->CreateTimeBudgetPool("test", base::nullopt,
+ base::nullopt);
+ task_queue_throttler_->IncreaseThrottleRefCount(timer_queue_.get());
+
+ mock_task_runner_->RunUntilTime(base::TimeTicks() +
+ base::TimeDelta::FromMilliseconds(100));
+
+ timer_queue_->PostDelayedTask(FROM_HERE,
+ base::Bind(&TestTask, &run_times, clock_.get()),
+ base::TimeDelta::FromMilliseconds(200));
+
+ pool->AddQueue(base::TimeTicks(), timer_queue_.get());
+
+ mock_task_runner_->RunUntilIdle();
+
+ EXPECT_THAT(run_times, ElementsAre(base::TimeTicks() +
+ base::TimeDelta::FromMilliseconds(300)));
+}
+
} // namespace scheduler
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/platform/scheduler/renderer/task_queue_throttler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698