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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « components/scheduler/renderer/throttling_helper.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 timer_queue_->PostTask(FROM_HERE, base::Bind(&NopTask)); 364 timer_queue_->PostTask(FROM_HERE, base::Bind(&NopTask));
365 365
366 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); 366 EXPECT_TRUE(timer_queue_->IsQueueEnabled());
367 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get()); 367 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get());
368 EXPECT_FALSE(timer_queue_->IsQueueEnabled()); 368 EXPECT_FALSE(timer_queue_->IsQueueEnabled());
369 369
370 mock_task_runner_->RunUntilIdle(); // Wait until the pump. 370 mock_task_runner_->RunUntilIdle(); // Wait until the pump.
371 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); 371 EXPECT_TRUE(timer_queue_->IsQueueEnabled());
372 } 372 }
373 373
374 TEST_F(ThrottlingHelperTest, TaskQueueEnabledOnUnthrottle) { 374 TEST_F(ThrottlingHelperTest, TaskQueueUnthrottle_InitiallyEnabled) {
375 timer_queue_->PostTask(FROM_HERE, base::Bind(&NopTask)); 375 timer_queue_->PostTask(FROM_HERE, base::Bind(&NopTask));
376 376
377 timer_queue_->SetQueueEnabled(true); // NOP
377 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get()); 378 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get());
378 EXPECT_FALSE(timer_queue_->IsQueueEnabled()); 379 EXPECT_FALSE(timer_queue_->IsQueueEnabled());
379 380
380 throttling_helper_->DecreaseThrottleRefCount(timer_queue_.get()); 381 throttling_helper_->DecreaseThrottleRefCount(timer_queue_.get());
381 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); 382 EXPECT_TRUE(timer_queue_->IsQueueEnabled());
382 } 383 }
383 384
385 TEST_F(ThrottlingHelperTest, TaskQueueUnthrottle_InitiallyDisabled) {
386 timer_queue_->PostTask(FROM_HERE, base::Bind(&NopTask));
387
388 timer_queue_->SetQueueEnabled(false);
389 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get());
390 EXPECT_FALSE(timer_queue_->IsQueueEnabled());
391
392 throttling_helper_->DecreaseThrottleRefCount(timer_queue_.get());
393 EXPECT_FALSE(timer_queue_->IsQueueEnabled());
394 }
395
396 TEST_F(ThrottlingHelperTest, SetQueueEnabled_Unthrottled) {
397 timer_queue_->PostTask(FROM_HERE, base::Bind(&NopTask));
398
399 throttling_helper_->SetQueueEnabled(timer_queue_.get(), false);
400 EXPECT_FALSE(timer_queue_->IsQueueEnabled());
401
402 throttling_helper_->SetQueueEnabled(timer_queue_.get(), true);
403 EXPECT_TRUE(timer_queue_->IsQueueEnabled());
404 }
405
406 TEST_F(ThrottlingHelperTest, SetQueueEnabled_DisabledWhileThrottled) {
407 timer_queue_->PostTask(FROM_HERE, base::Bind(&NopTask));
408
409 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get());
410 EXPECT_FALSE(timer_queue_->IsQueueEnabled());
411
412 throttling_helper_->SetQueueEnabled(timer_queue_.get(), false);
413 throttling_helper_->DecreaseThrottleRefCount(timer_queue_.get());
414 EXPECT_FALSE(timer_queue_->IsQueueEnabled());
415 }
416
417 TEST_F(ThrottlingHelperTest, TaskQueueDisabledTillPump_ThenManuallyDisabled) {
418 timer_queue_->PostTask(FROM_HERE, base::Bind(&NopTask));
419
420 EXPECT_TRUE(timer_queue_->IsQueueEnabled());
421 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get());
422 EXPECT_FALSE(timer_queue_->IsQueueEnabled());
423
424 mock_task_runner_->RunUntilIdle(); // Wait until the pump.
425 EXPECT_TRUE(timer_queue_->IsQueueEnabled());
426
427 throttling_helper_->SetQueueEnabled(timer_queue_.get(), false);
428 EXPECT_FALSE(timer_queue_->IsQueueEnabled());
429 }
430
384 } // namespace scheduler 431 } // namespace scheduler
OLDNEW
« 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