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

Side by Side Diff: base/test/scoped_task_scheduler_unittest.cc

Issue 2713513003: Use the saved task runner if TestTaskScheduler is re-entered from a task executed by RunTask. (Closed)
Patch Set: Unit test Created 3 years, 10 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 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "base/test/scoped_task_scheduler.h" 5 #include "base/test/scoped_task_scheduler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/macros.h" 9 #include "base/macros.h"
10 #include "base/run_loop.h" 10 #include "base/run_loop.h"
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 PostDelayedTask(FROM_HERE, Bind(TestTaskRan, Unretained(&second_task_ran)), 289 PostDelayedTask(FROM_HERE, Bind(TestTaskRan, Unretained(&second_task_ran)),
290 TimeDelta()); 290 TimeDelta());
291 291
292 RunLoop().RunUntilIdle(); 292 RunLoop().RunUntilIdle();
293 293
294 // We never pumped |mock_time_task_runner| so the first task should not have 294 // We never pumped |mock_time_task_runner| so the first task should not have
295 // run. 295 // run.
296 EXPECT_FALSE(first_task_ran); 296 EXPECT_FALSE(first_task_ran);
297 EXPECT_TRUE(second_task_ran); 297 EXPECT_TRUE(second_task_ran);
298 } 298 }
299 299
fdoray 2017/02/22 16:23:52 // Verify that a task can be posted from a task ru
300 TEST(ScopedTaskSchedulerTest, ReentrantTaskRunner) {
301 bool task_ran = false;
302 ScopedTaskScheduler scoped_task_scheduler;
303 PostTask(FROM_HERE, Bind(
304 [](bool* task_ran) {
305 PostTask(
306 FROM_HERE,
307 Bind([](bool* task_ran) { *task_ran = true; },
308 Unretained(task_ran)));
309 },
310 Unretained(&task_ran)));
311 RunLoop().RunUntilIdle();
312 EXPECT_TRUE(task_ran);
313 }
314
fdoray 2017/02/22 16:23:52 // Verify that ScopedTaskScheduler posts to the la
Joe Mason 2017/02/22 20:23:30 This test does the same thing as ReassignCurrentTa
300 } // namespace test 315 } // namespace test
301 } // namespace base 316 } // namespace base
OLDNEW
« base/test/scoped_task_scheduler.cc ('K') | « base/test/scoped_task_scheduler.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698