New issue
Advanced search Search tips
Note: Color blocks (like or ) mean that a user may not be available. Tooltip shows the reason.

Issue 690504 link

Starred by 2 users

Issue metadata

Status: Fixed
Owner:
Last visit > 30 days ago
Closed: Feb 2017
Cc:
Components:
EstimatedDays: ----
NextAction: ----
OS: ----
Pri: 3
Type: Bug



Sign in to add a comment

ScopedTaskScheduler should allow reassigning MessageLoop::task_runner after it's created

Project Member Reported by joenotcharles@chromium.org, Feb 9 2017

Issue description

From https://groups.google.com/a/chromium.org/d/msg/scheduler-dev/I6xoPn32JkM/mn56yVTABgAJ, gab@chromium.org said:

You can combine this with a base::ScopedTaskScheduler to mock time for tasks posted to TaskScheduler.

Thinking about it it's currently slightly convoluted though as you'll need to do the following in this specific order in your test fixture:
 private:
  base::MessageLoop message_loop_;
  base::ScopedMockTimeMessageLoopTaskRunner_ mock_time_task_runner_;
  base::ScopedTaskScheduler scoped_task_scheduler_;

Ideally we could do:
 private:
  base::ScopedTaskScheduler scoped_task_scheduler_;
  base::ScopedMockTimeMessageLoopTaskRunner_ mock_time_task_runner_;

Just like we can currently do:
 private:
  base::TestBrowserThreadBundle thread_bundle_;
  base::ScopedMockTimeMessageLoopTaskRunner_ mock_time_task_runner_;

The reason it's currently convoluted is that ScopedTaskScheduler takes a reference to MessageLoop::task_runner() when it's constructed so the mock needs to already be in place by the time ScopedTaskScheduler is constructed.
 
Project Member

Comment 1 by bugdroid1@chromium.org, Feb 16 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/74b6455bacd6648d765d251d486b2e5cfba60eb1

commit 74b6455bacd6648d765d251d486b2e5cfba60eb1
Author: joenotcharles <joenotcharles@chromium.org>
Date: Thu Feb 16 16:14:04 2017

Allow ScopedTaskScheduler to be created before a class that overrides MessageLoop::current() such as ScopedMockTimeMessageLoopTaskRunner.

BUG= 690504 

Review-Url: https://codereview.chromium.org/2684273002
Cr-Commit-Position: refs/heads/master@{#450981}

[modify] https://crrev.com/74b6455bacd6648d765d251d486b2e5cfba60eb1/base/test/scoped_task_scheduler.cc
[modify] https://crrev.com/74b6455bacd6648d765d251d486b2e5cfba60eb1/base/test/scoped_task_scheduler_unittest.cc

Status: Fixed (was: Started)
Status: Started (was: Fixed)
Re-opening because this broke a unit test in https://codereview.chromium.org/2565873002/
Project Member

Comment 4 by bugdroid1@chromium.org, Feb 22 2017

The following revision refers to this bug:
  https://chromium.googlesource.com/chromium/src.git/+/3c23304fa3f46c328792413ea3de60ea86e27fbd

commit 3c23304fa3f46c328792413ea3de60ea86e27fbd
Author: joenotcharles <joenotcharles@chromium.org>
Date: Wed Feb 22 22:07:17 2017

Use the saved task runner if TestTaskScheduler is re-entered from a task executed by RunTask.

BUG= 690504 

Review-Url: https://codereview.chromium.org/2713513003
Cr-Commit-Position: refs/heads/master@{#452226}

[modify] https://crrev.com/3c23304fa3f46c328792413ea3de60ea86e27fbd/base/test/scoped_task_scheduler.cc
[modify] https://crrev.com/3c23304fa3f46c328792413ea3de60ea86e27fbd/base/test/scoped_task_scheduler_unittest.cc

Status: Fixed (was: Started)

Sign in to add a comment