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/web_view_scheduler_impl.h" | 5 #include "components/scheduler/renderer/web_view_scheduler_impl.h" |
6 | 6 |
7 #include "base/callback.h" | 7 #include "base/callback.h" |
8 #include "base/memory/scoped_ptr.h" | 8 #include "base/memory/scoped_ptr.h" |
9 #include "base/test/simple_test_tick_clock.h" | 9 #include "base/test/simple_test_tick_clock.h" |
10 #include "cc/test/ordered_simple_task_runner.h" | 10 #include "cc/test/ordered_simple_task_runner.h" |
(...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
260 web_view_scheduler_->setPageVisible(false); | 260 web_view_scheduler_->setPageVisible(false); |
261 base::TimeTicks initial_real_time = scheduler_->tick_clock()->NowTicks(); | 261 base::TimeTicks initial_real_time = scheduler_->tick_clock()->NowTicks(); |
262 | 262 |
263 int run_count = 0; | 263 int run_count = 0; |
264 web_frame_scheduler_->timerTaskRunner()->postDelayedTask( | 264 web_frame_scheduler_->timerTaskRunner()->postDelayedTask( |
265 BLINK_FROM_HERE, | 265 BLINK_FROM_HERE, |
266 new RepeatingTask(web_frame_scheduler_->timerTaskRunner(), &run_count), | 266 new RepeatingTask(web_frame_scheduler_->timerTaskRunner(), &run_count), |
267 1.0); | 267 1.0); |
268 | 268 |
269 mock_task_runner_->RunTasksWhile(mock_task_runner_->TaskRunCountBelow(2000)); | 269 mock_task_runner_->RunTasksWhile(mock_task_runner_->TaskRunCountBelow(2000)); |
| 270 // Virtual time means page visibility is ignored. |
270 EXPECT_EQ(1999, run_count); | 271 EXPECT_EQ(1999, run_count); |
271 | 272 |
272 // The global tick clock has not moved, yet we ran a large number of "delayed" | 273 // The global tick clock has not moved, yet we ran a large number of "delayed" |
273 // tasks despite calling setPageVisible(false). | 274 // tasks despite calling setPageVisible(false). |
274 EXPECT_EQ(initial_real_time, scheduler_->tick_clock()->NowTicks()); | 275 EXPECT_EQ(initial_real_time, scheduler_->tick_clock()->NowTicks()); |
275 } | 276 } |
276 | 277 |
277 namespace { | 278 namespace { |
278 class RunOrderTask : public blink::WebTaskRunner::Task { | 279 class RunOrderTask : public blink::WebTaskRunner::Task { |
279 public: | 280 public: |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 // it will prevent further tasks from running (i.e. the RepeatingTask) by | 456 // it will prevent further tasks from running (i.e. the RepeatingTask) by |
456 // deleting the WebFrameScheduler. | 457 // deleting the WebFrameScheduler. |
457 timer_task_runner->postDelayedTask(BLINK_FROM_HERE, delete_frame_task, | 458 timer_task_runner->postDelayedTask(BLINK_FROM_HERE, delete_frame_task, |
458 9990.0); | 459 9990.0); |
459 | 460 |
460 mock_task_runner_->RunForPeriod(base::TimeDelta::FromSeconds(100)); | 461 mock_task_runner_->RunForPeriod(base::TimeDelta::FromSeconds(100)); |
461 EXPECT_EQ(10, run_count); | 462 EXPECT_EQ(10, run_count); |
462 } | 463 } |
463 | 464 |
464 } // namespace scheduler | 465 } // namespace scheduler |
OLD | NEW |