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 |
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" | |
19 #include "components/scheduler/renderer/renderer_scheduler_impl.h" | 18 #include "components/scheduler/renderer/renderer_scheduler_impl.h" |
20 #include "components/scheduler/renderer/web_frame_scheduler_impl.h" | 19 #include "components/scheduler/renderer/web_frame_scheduler_impl.h" |
21 #include "components/scheduler/renderer/web_view_scheduler_impl.h" | 20 #include "components/scheduler/renderer/web_view_scheduler_impl.h" |
22 #include "testing/gmock/include/gmock/gmock.h" | 21 #include "testing/gmock/include/gmock/gmock.h" |
23 #include "testing/gtest/include/gtest/gtest.h" | 22 #include "testing/gtest/include/gtest/gtest.h" |
24 | 23 |
25 using testing::ElementsAre; | 24 using testing::ElementsAre; |
26 | 25 |
27 namespace scheduler { | 26 namespace scheduler { |
28 | 27 |
(...skipping 417 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 | 445 |
447 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); | 446 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); |
448 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get()); | 447 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get()); |
449 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get()); | 448 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get()); |
450 EXPECT_FALSE(timer_queue_->IsQueueEnabled()); | 449 EXPECT_FALSE(timer_queue_->IsQueueEnabled()); |
451 throttling_helper_->DecreaseThrottleRefCount(timer_queue_.get()); | 450 throttling_helper_->DecreaseThrottleRefCount(timer_queue_.get()); |
452 throttling_helper_->DecreaseThrottleRefCount(timer_queue_.get()); | 451 throttling_helper_->DecreaseThrottleRefCount(timer_queue_.get()); |
453 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); | 452 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); |
454 } | 453 } |
455 | 454 |
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 | |
480 } // namespace scheduler | 455 } // namespace scheduler |
OLD | NEW |