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

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: Another GYP fix Created 4 years, 5 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/renderer_scheduler_impl.h" 18 #include "platform/scheduler/renderer/renderer_scheduler_impl.h"
19 #include "components/scheduler/renderer/web_frame_scheduler_impl.h" 19 #include "platform/scheduler/renderer/web_frame_scheduler_impl.h"
20 #include "components/scheduler/renderer/web_view_scheduler_impl.h" 20 #include "platform/scheduler/renderer/web_view_scheduler_impl.h"
21 #include "testing/gmock/include/gmock/gmock.h" 21 #include "testing/gmock/include/gmock/gmock.h"
22 #include "testing/gtest/include/gtest/gtest.h" 22 #include "testing/gtest/include/gtest/gtest.h"
23 23
24 using testing::ElementsAre; 24 using testing::ElementsAre;
25 25
26 namespace blink {
26 namespace scheduler { 27 namespace scheduler {
27 28
28 namespace { 29 namespace {
29 void CountingTask(size_t* count, scoped_refptr<TaskQueue> timer_queue) { 30 void CountingTask(size_t* count, scoped_refptr<TaskQueue> timer_queue) {
30 if (++(*count) < 10) { 31 if (++(*count) < 10) {
31 timer_queue->PostTask(FROM_HERE, 32 timer_queue->PostTask(FROM_HERE,
32 base::Bind(&CountingTask, count, timer_queue)); 33 base::Bind(&CountingTask, count, timer_queue));
33 } 34 }
34 } 35 }
35 } 36 }
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
301 302
302 EXPECT_EQ(1u, task_count); 303 EXPECT_EQ(1u, task_count);
303 } 304 }
304 305
305 TEST_F(ThrottlingHelperTest, 306 TEST_F(ThrottlingHelperTest,
306 TwoFutureThrottledTaskPumpedAndRunWithNoExtraneousMessageLoopTasks) { 307 TwoFutureThrottledTaskPumpedAndRunWithNoExtraneousMessageLoopTasks) {
307 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get()); 308 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get());
308 std::vector<base::TimeTicks> run_times; 309 std::vector<base::TimeTicks> run_times;
309 310
310 base::TimeDelta delay(base::TimeDelta::FromSecondsD(15.5)); 311 base::TimeDelta delay(base::TimeDelta::FromSecondsD(15.5));
311 timer_queue_->PostDelayedTask(FROM_HERE, 312 timer_queue_->PostDelayedTask(
312 base::Bind(&TestTask, &run_times, clock_.get()), 313 FROM_HERE, base::Bind(&TestTask, &run_times, clock_.get()), delay);
313 delay);
314 314
315 base::TimeDelta delay2(base::TimeDelta::FromSecondsD(5.5)); 315 base::TimeDelta delay2(base::TimeDelta::FromSecondsD(5.5));
316 timer_queue_->PostDelayedTask(FROM_HERE, 316 timer_queue_->PostDelayedTask(
317 base::Bind(&TestTask, &run_times, clock_.get()), 317 FROM_HERE, base::Bind(&TestTask, &run_times, clock_.get()), delay2);
318 delay2);
319 318
320 size_t task_count = 0; 319 size_t task_count = 0;
321 mock_task_runner_->RunTasksWhile( 320 mock_task_runner_->RunTasksWhile(
322 base::Bind(&MessageLoopTaskCounter, &task_count)); 321 base::Bind(&MessageLoopTaskCounter, &task_count));
323 322
324 EXPECT_EQ(2u, task_count); // There are two since the cancelled task runs in 323 EXPECT_EQ(2u, task_count); // There are two since the cancelled task runs in
325 // the same DoWork batch. 324 // the same DoWork batch.
326 325
327 EXPECT_THAT( 326 EXPECT_THAT(
328 run_times, 327 run_times,
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
434 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); 433 EXPECT_TRUE(timer_queue_->IsQueueEnabled());
435 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get()); 434 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get());
436 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get()); 435 throttling_helper_->IncreaseThrottleRefCount(timer_queue_.get());
437 EXPECT_FALSE(timer_queue_->IsQueueEnabled()); 436 EXPECT_FALSE(timer_queue_->IsQueueEnabled());
438 throttling_helper_->DecreaseThrottleRefCount(timer_queue_.get()); 437 throttling_helper_->DecreaseThrottleRefCount(timer_queue_.get());
439 throttling_helper_->DecreaseThrottleRefCount(timer_queue_.get()); 438 throttling_helper_->DecreaseThrottleRefCount(timer_queue_.get());
440 EXPECT_TRUE(timer_queue_->IsQueueEnabled()); 439 EXPECT_TRUE(timer_queue_->IsQueueEnabled());
441 } 440 }
442 441
443 } // namespace scheduler 442 } // namespace scheduler
443 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698