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

Side by Side Diff: components/scheduler/renderer/throttling_helper_unittest.cc

Issue 2184123002: Change VirtualTimePolicy::PAUSE_IF_NETWORK_FETCHES_PENDING (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased Created 4 years, 4 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
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
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/ptr_util.h" 13 #include "base/memory/ptr_util.h"
14 #include "base/test/simple_test_tick_clock.h" 14 #include "base/test/simple_test_tick_clock.h"
15 #include "cc/test/ordered_simple_task_runner.h" 15 #include "cc/test/ordered_simple_task_runner.h"
16 #include "components/scheduler/base/test_time_source.h" 16 #include "components/scheduler/base/test_time_source.h"
17 #include "components/scheduler/child/scheduler_tqm_delegate_for_test.h" 17 #include "components/scheduler/child/scheduler_tqm_delegate_for_test.h"
18 #include "components/scheduler/renderer/auto_advancing_virtual_time_domain.h"
18 #include "components/scheduler/renderer/renderer_scheduler_impl.h" 19 #include "components/scheduler/renderer/renderer_scheduler_impl.h"
19 #include "components/scheduler/renderer/web_frame_scheduler_impl.h" 20 #include "components/scheduler/renderer/web_frame_scheduler_impl.h"
20 #include "components/scheduler/renderer/web_view_scheduler_impl.h" 21 #include "components/scheduler/renderer/web_view_scheduler_impl.h"
21 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
22 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
23 24
24 using testing::ElementsAre; 25 using testing::ElementsAre;
25 26
26 namespace scheduler { 27 namespace scheduler {
27 28
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 446
446 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); 447 EXPECT_TRUE(timer_queue_->IsQueueEnabled());
447 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get()); 448 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get());
448 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get()); 449 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get());
449 EXPECT_FALSE(timer_queue_->IsQueueEnabled()); 450 EXPECT_FALSE(timer_queue_->IsQueueEnabled());
450 throttling_helper_->DecreaseThrottleRefCount(timer_queue_.get()); 451 throttling_helper_->DecreaseThrottleRefCount(timer_queue_.get());
451 throttling_helper_->DecreaseThrottleRefCount(timer_queue_.get()); 452 throttling_helper_->DecreaseThrottleRefCount(timer_queue_.get());
452 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); 453 EXPECT_TRUE(timer_queue_->IsQueueEnabled());
453 } 454 }
454 455
456 TEST_F(ThrottlingHelperTest, EnableVirtualTimeThenIncrement) {
457 timer_queue_->PostTask(FROM_HERE, base::Bind(&NopTask));
458
459 scheduler_->EnableVirtualTime();
460 EXPECT_EQ(timer_queue_->GetTimeDomain(), scheduler_->GetVirtualTimeDomain());
461
462 EXPECT_TRUE(timer_queue_->IsQueueEnabled());
463 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get());
464 EXPECT_TRUE(timer_queue_->IsQueueEnabled());
465 EXPECT_EQ(timer_queue_->GetTimeDomain(), scheduler_->GetVirtualTimeDomain());
466 }
467
468 TEST_F(ThrottlingHelperTest, IncrementThenEnableVirtualTime) {
469 timer_queue_->PostTask(FROM_HERE, base::Bind(&NopTask));
470
471 EXPECT_TRUE(timer_queue_->IsQueueEnabled());
472 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get());
473 EXPECT_FALSE(timer_queue_->IsQueueEnabled());
474
475 scheduler_->EnableVirtualTime();
476 EXPECT_TRUE(timer_queue_->IsQueueEnabled());
477 EXPECT_EQ(timer_queue_->GetTimeDomain(), scheduler_->GetVirtualTimeDomain());
478 }
479
455 } // namespace scheduler 480 } // namespace scheduler
OLDNEW
« no previous file with comments | « components/scheduler/renderer/throttling_helper.cc ('k') | components/scheduler/renderer/web_frame_scheduler_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698