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

Side by Side Diff: components/scheduler/child/idle_helper_unittest.cc

Issue 2132593002: Remove remaining calls to deprecated MessageLoop methods on Mac. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: h264_vt_encoder_unittest.cc 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/child/idle_helper.h" 5 #include "components/scheduler/child/idle_helper.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/macros.h" 10 #include "base/macros.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/run_loop.h"
12 #include "base/test/simple_test_tick_clock.h" 13 #include "base/test/simple_test_tick_clock.h"
13 #include "cc/test/ordered_simple_task_runner.h" 14 #include "cc/test/ordered_simple_task_runner.h"
14 #include "components/scheduler/base/real_time_domain.h" 15 #include "components/scheduler/base/real_time_domain.h"
15 #include "components/scheduler/base/task_queue.h" 16 #include "components/scheduler/base/task_queue.h"
16 #include "components/scheduler/base/task_queue_manager.h" 17 #include "components/scheduler/base/task_queue_manager.h"
17 #include "components/scheduler/base/test_time_source.h" 18 #include "components/scheduler/base/test_time_source.h"
18 #include "components/scheduler/child/scheduler_helper.h" 19 #include "components/scheduler/child/scheduler_helper.h"
19 #include "components/scheduler/child/scheduler_tqm_delegate_for_test.h" 20 #include "components/scheduler/child/scheduler_tqm_delegate_for_test.h"
20 #include "components/scheduler/child/scheduler_tqm_delegate_impl.h" 21 #include "components/scheduler/child/scheduler_tqm_delegate_impl.h"
21 #include "testing/gmock/include/gmock/gmock.h" 22 #include "testing/gmock/include/gmock/gmock.h"
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 } 209 }
209 210
210 void TearDown() override { 211 void TearDown() override {
211 DCHECK(!mock_task_runner_.get() || !message_loop_.get()); 212 DCHECK(!mock_task_runner_.get() || !message_loop_.get());
212 if (mock_task_runner_.get()) { 213 if (mock_task_runner_.get()) {
213 // Check that all tests stop posting tasks. 214 // Check that all tests stop posting tasks.
214 mock_task_runner_->SetAutoAdvanceNowToPendingTasks(true); 215 mock_task_runner_->SetAutoAdvanceNowToPendingTasks(true);
215 while (mock_task_runner_->RunUntilIdle()) { 216 while (mock_task_runner_->RunUntilIdle()) {
216 } 217 }
217 } else { 218 } else {
218 message_loop_->RunUntilIdle(); 219 base::RunLoop().RunUntilIdle();
219 } 220 }
220 } 221 }
221 222
222 void RunUntilIdle() { 223 void RunUntilIdle() {
223 // Only one of mock_task_runner_ or message_loop_ should be set. 224 // Only one of mock_task_runner_ or message_loop_ should be set.
224 DCHECK(!mock_task_runner_.get() || !message_loop_.get()); 225 DCHECK(!mock_task_runner_.get() || !message_loop_.get());
225 if (mock_task_runner_.get()) 226 if (mock_task_runner_.get())
226 mock_task_runner_->RunUntilIdle(); 227 mock_task_runner_->RunUntilIdle();
227 else 228 else
228 message_loop_->RunUntilIdle(); 229 base::RunLoop().RunUntilIdle();
229 } 230 }
230 231
231 template <typename E> 232 template <typename E>
232 static void CallForEachEnumValue(E first, 233 static void CallForEachEnumValue(E first,
233 E last, 234 E last,
234 const char* (*function)(E)) { 235 const char* (*function)(E)) {
235 for (E val = first; val < last; 236 for (E val = first; val < last;
236 val = static_cast<E>(static_cast<int>(val) + 1)) { 237 val = static_cast<E>(static_cast<int>(val) + 1)) {
237 (*function)(val); 238 (*function)(val);
238 } 239 }
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 for (std::pair<SingleThreadIdleTaskRunner::IdleTask, bool>& pair : *tasks) { 539 for (std::pair<SingleThreadIdleTaskRunner::IdleTask, bool>& pair : *tasks) {
539 if (pair.second) { 540 if (pair.second) {
540 idle_task_runner_->PostIdleTask(FROM_HERE, pair.first); 541 idle_task_runner_->PostIdleTask(FROM_HERE, pair.first);
541 } else { 542 } else {
542 idle_task_runner_->PostNonNestableIdleTask(FROM_HERE, pair.first); 543 idle_task_runner_->PostNonNestableIdleTask(FROM_HERE, pair.first);
543 } 544 }
544 } 545 }
545 idle_helper_->StartIdlePeriod( 546 idle_helper_->StartIdlePeriod(
546 IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, clock_->NowTicks(), 547 IdleHelper::IdlePeriodState::IN_SHORT_IDLE_PERIOD, clock_->NowTicks(),
547 clock_->NowTicks() + base::TimeDelta::FromMilliseconds(10)); 548 clock_->NowTicks() + base::TimeDelta::FromMilliseconds(10));
548 message_loop_->RunUntilIdle(); 549 base::RunLoop().RunUntilIdle();
549 } 550 }
550 551
551 void SetUp() override { 552 void SetUp() override {
552 EXPECT_CALL(*idle_helper_, OnIdlePeriodStarted()).Times(AnyNumber()); 553 EXPECT_CALL(*idle_helper_, OnIdlePeriodStarted()).Times(AnyNumber());
553 EXPECT_CALL(*idle_helper_, OnIdlePeriodEnded()).Times(AnyNumber()); 554 EXPECT_CALL(*idle_helper_, OnIdlePeriodEnded()).Times(AnyNumber());
554 } 555 }
555 556
556 private: 557 private:
557 DISALLOW_COPY_AND_ASSIGN(IdleHelperWithMessageLoopTest); 558 DISALLOW_COPY_AND_ASSIGN(IdleHelperWithMessageLoopTest);
558 }; 559 };
(...skipping 591 matching lines...) Expand 10 before | Expand all | Expand 10 after
1150 EXPECT_EQ(0, run_count); 1151 EXPECT_EQ(0, run_count);
1151 1152
1152 default_task_runner_->PostDelayedTask(FROM_HERE, base::Bind(&NullTask), 1153 default_task_runner_->PostDelayedTask(FROM_HERE, base::Bind(&NullTask),
1153 more_than_min_deadline_duration); 1154 more_than_min_deadline_duration);
1154 idle_helper_->EnableLongIdlePeriod(); 1155 idle_helper_->EnableLongIdlePeriod();
1155 RunUntilIdle(); 1156 RunUntilIdle();
1156 EXPECT_EQ(1, run_count); 1157 EXPECT_EQ(1, run_count);
1157 } 1158 }
1158 1159
1159 } // namespace scheduler 1160 } // namespace scheduler
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698