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

Unified Diff: components/scheduler/renderer/throttling_helper_unittest.cc

Issue 2080563003: (Merge m52) Fix a bug with throttling and timer queue suspension (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2743
Patch Set: Created 4 years, 6 months 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 | « components/scheduler/renderer/throttling_helper.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/scheduler/renderer/throttling_helper_unittest.cc
diff --git a/components/scheduler/renderer/throttling_helper_unittest.cc b/components/scheduler/renderer/throttling_helper_unittest.cc
index 4234d170189c47897ba05c56befcc9197e7c9064..360c13d25da264cbe39c57cef7a9cece72ba2324 100644
--- a/components/scheduler/renderer/throttling_helper_unittest.cc
+++ b/components/scheduler/renderer/throttling_helper_unittest.cc
@@ -371,9 +371,10 @@ TEST_F(ThrottlingHelperTest, TaskQueueDisabledTillPump) {
EXPECT_TRUE(timer_queue_->IsQueueEnabled());
}
-TEST_F(ThrottlingHelperTest, TaskQueueEnabledOnUnthrottle) {
+TEST_F(ThrottlingHelperTest, TaskQueueUnthrottle_InitiallyEnabled) {
timer_queue_->PostTask(FROM_HERE, base::Bind(&NopTask));
+ timer_queue_->SetQueueEnabled(true); // NOP
throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get());
EXPECT_FALSE(timer_queue_->IsQueueEnabled());
@@ -381,4 +382,50 @@ TEST_F(ThrottlingHelperTest, TaskQueueEnabledOnUnthrottle) {
EXPECT_TRUE(timer_queue_->IsQueueEnabled());
}
+TEST_F(ThrottlingHelperTest, TaskQueueUnthrottle_InitiallyDisabled) {
+ timer_queue_->PostTask(FROM_HERE, base::Bind(&NopTask));
+
+ timer_queue_->SetQueueEnabled(false);
+ throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get());
+ EXPECT_FALSE(timer_queue_->IsQueueEnabled());
+
+ throttling_helper_->DecreaseThrottleRefCount(timer_queue_.get());
+ EXPECT_FALSE(timer_queue_->IsQueueEnabled());
+}
+
+TEST_F(ThrottlingHelperTest, SetQueueEnabled_Unthrottled) {
+ timer_queue_->PostTask(FROM_HERE, base::Bind(&NopTask));
+
+ throttling_helper_->SetQueueEnabled(timer_queue_.get(), false);
+ EXPECT_FALSE(timer_queue_->IsQueueEnabled());
+
+ throttling_helper_->SetQueueEnabled(timer_queue_.get(), true);
+ EXPECT_TRUE(timer_queue_->IsQueueEnabled());
+}
+
+TEST_F(ThrottlingHelperTest, SetQueueEnabled_DisabledWhileThrottled) {
+ timer_queue_->PostTask(FROM_HERE, base::Bind(&NopTask));
+
+ throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get());
+ EXPECT_FALSE(timer_queue_->IsQueueEnabled());
+
+ throttling_helper_->SetQueueEnabled(timer_queue_.get(), false);
+ throttling_helper_->DecreaseThrottleRefCount(timer_queue_.get());
+ EXPECT_FALSE(timer_queue_->IsQueueEnabled());
+}
+
+TEST_F(ThrottlingHelperTest, TaskQueueDisabledTillPump_ThenManuallyDisabled) {
+ timer_queue_->PostTask(FROM_HERE, base::Bind(&NopTask));
+
+ EXPECT_TRUE(timer_queue_->IsQueueEnabled());
+ throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get());
+ EXPECT_FALSE(timer_queue_->IsQueueEnabled());
+
+ mock_task_runner_->RunUntilIdle(); // Wait until the pump.
+ EXPECT_TRUE(timer_queue_->IsQueueEnabled());
+
+ throttling_helper_->SetQueueEnabled(timer_queue_.get(), false);
+ EXPECT_FALSE(timer_queue_->IsQueueEnabled());
+}
+
} // namespace scheduler
« no previous file with comments | « components/scheduler/renderer/throttling_helper.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698