Hey Joe (CC scheduler-dev FYI),
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.
Cheers,
Gab