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

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

Issue 2494943005: [ash-md] Added a delay between system menu default/detailed view transitions. (Closed)
Patch Set: Addressed danakj@ comments. Created 4 years, 1 month 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/test/scoped_mock_time_message_loop_task_runner.h"
6
7 #include <deque>
8
9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h"
11 #include "base/run_loop.h"
12 #include "base/test/test_pending_task.h"
13 #include "base/threading/thread_task_runner_handle.h"
14 #include "base/time/time.h"
15
16 namespace base {
17
18 ScopedMockTimeMessageLoopTaskRunner::ScopedMockTimeMessageLoopTaskRunner()
19 : task_runner_(new TestMockTimeTaskRunner),
20 previous_task_runner_(ThreadTaskRunnerHandle::Get()) {
21 DCHECK(MessageLoop::current());
22 // To ensure that we process any initialization tasks posted to the
23 // MessageLoop by a test fixture before replacing its TaskRunner.
24 RunLoop().RunUntilIdle();
25 MessageLoop::current()->SetTaskRunner(task_runner_);
26 }
27
28 ScopedMockTimeMessageLoopTaskRunner::~ScopedMockTimeMessageLoopTaskRunner() {
29 DCHECK(previous_task_runner_->RunsTasksOnCurrentThread());
30 DCHECK_EQ(task_runner_, ThreadTaskRunnerHandle::Get());
31 for (const auto& pending_task : task_runner_->TakePendingTasks()) {
32 previous_task_runner_->PostDelayedTask(
33 pending_task.location, pending_task.task,
34 pending_task.GetTimeToRun() - task_runner_->NowTicks());
35 }
36 MessageLoop::current()->SetTaskRunner(std::move(previous_task_runner_));
37 }
38
39 } // namespace base
OLDNEW
« no previous file with comments | « base/test/scoped_mock_time_message_loop_task_runner.h ('k') | base/test/scoped_mock_time_message_loop_task_runner_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698