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

Side by Side Diff: third_party/WebKit/Source/platform/scheduler/renderer/throttling_helper_unittest.cc

Issue 2118903002: scheduler: Move the Blink scheduler into Blink (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 "platform/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 "platform/scheduler/base/test_time_source.h"
17 #include "components/scheduler/child/scheduler_tqm_delegate_for_test.h" 17 #include "platform/scheduler/child/scheduler_tqm_delegate_for_test.h"
18 #include "components/scheduler/renderer/auto_advancing_virtual_time_domain.h" 18 #include "platform/scheduler/renderer/auto_advancing_virtual_time_domain.h"
19 #include "components/scheduler/renderer/renderer_scheduler_impl.h" 19 #include "platform/scheduler/renderer/renderer_scheduler_impl.h"
20 #include "components/scheduler/renderer/web_frame_scheduler_impl.h" 20 #include "platform/scheduler/renderer/web_frame_scheduler_impl.h"
21 #include "components/scheduler/renderer/web_view_scheduler_impl.h" 21 #include "platform/scheduler/renderer/web_view_scheduler_impl.h"
22 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
23 #include "testing/gtest/include/gtest/gtest.h" 23 #include "testing/gtest/include/gtest/gtest.h"
24 24
25 using testing::ElementsAre; 25 using testing::ElementsAre;
26 26
27 namespace blink {
27 namespace scheduler { 28 namespace scheduler {
28 29
29 namespace { 30 namespace {
30 void CountingTask(size_t* count, scoped_refptr<TaskQueue> timer_queue) { 31 void CountingTask(size_t* count, scoped_refptr<TaskQueue> timer_queue) {
31 if (++(*count) < 10) { 32 if (++(*count) < 10) {
32 timer_queue->PostTask(FROM_HERE, 33 timer_queue->PostTask(FROM_HERE,
33 base::Bind(&CountingTask, count, timer_queue)); 34 base::Bind(&CountingTask, count, timer_queue));
34 } 35 }
35 } 36 }
36 } 37 }
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 303
303 EXPECT_EQ(1u, task_count); 304 EXPECT_EQ(1u, task_count);
304 } 305 }
305 306
306 TEST_F(ThrottlingHelperTest, 307 TEST_F(ThrottlingHelperTest,
307 TwoFutureThrottledTaskPumpedAndRunWithNoExtraneousMessageLoopTasks) { 308 TwoFutureThrottledTaskPumpedAndRunWithNoExtraneousMessageLoopTasks) {
308 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get()); 309 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get());
309 std::vector<base::TimeTicks> run_times; 310 std::vector<base::TimeTicks> run_times;
310 311
311 base::TimeDelta delay(base::TimeDelta::FromSecondsD(15.5)); 312 base::TimeDelta delay(base::TimeDelta::FromSecondsD(15.5));
312 timer_queue_->PostDelayedTask(FROM_HERE, 313 timer_queue_->PostDelayedTask(
313 base::Bind(&TestTask, &run_times, clock_.get()), 314 FROM_HERE, base::Bind(&TestTask, &run_times, clock_.get()), delay);
314 delay);
315 315
316 base::TimeDelta delay2(base::TimeDelta::FromSecondsD(5.5)); 316 base::TimeDelta delay2(base::TimeDelta::FromSecondsD(5.5));
317 timer_queue_->PostDelayedTask(FROM_HERE, 317 timer_queue_->PostDelayedTask(
318 base::Bind(&TestTask, &run_times, clock_.get()), 318 FROM_HERE, base::Bind(&TestTask, &run_times, clock_.get()), delay2);
319 delay2);
320 319
321 size_t task_count = 0; 320 size_t task_count = 0;
322 mock_task_runner_->RunTasksWhile( 321 mock_task_runner_->RunTasksWhile(
323 base::Bind(&MessageLoopTaskCounter, &task_count)); 322 base::Bind(&MessageLoopTaskCounter, &task_count));
324 323
325 EXPECT_EQ(2u, task_count); // There are two since the cancelled task runs in 324 EXPECT_EQ(2u, task_count); // There are two since the cancelled task runs in
326 // the same DoWork batch. 325 // the same DoWork batch.
327 326
328 EXPECT_THAT( 327 EXPECT_THAT(
329 run_times, 328 run_times,
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); 470 EXPECT_TRUE(timer_queue_->IsQueueEnabled());
472 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get()); 471 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get());
473 EXPECT_FALSE(timer_queue_->IsQueueEnabled()); 472 EXPECT_FALSE(timer_queue_->IsQueueEnabled());
474 473
475 scheduler_->EnableVirtualTime(); 474 scheduler_->EnableVirtualTime();
476 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); 475 EXPECT_TRUE(timer_queue_->IsQueueEnabled());
477 EXPECT_EQ(timer_queue_->GetTimeDomain(), scheduler_->GetVirtualTimeDomain()); 476 EXPECT_EQ(timer_queue_->GetTimeDomain(), scheduler_->GetVirtualTimeDomain());
478 } 477 }
479 478
480 } // namespace scheduler 479 } // namespace scheduler
480 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698