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

Unified Diff: base/test/scoped_mock_message_loop_task_runner_wrapper.cc

Issue 2494943005: [ash-md] Added a delay between system menu default/detailed view transitions. (Closed)
Patch Set: Addressed review comments from patch set 3. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « base/test/scoped_mock_message_loop_task_runner_wrapper.h ('k') | base/test/test_mock_time_task_runner.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: base/test/scoped_mock_message_loop_task_runner_wrapper.cc
diff --git a/base/test/scoped_mock_message_loop_task_runner_wrapper.cc b/base/test/scoped_mock_message_loop_task_runner_wrapper.cc
new file mode 100644
index 0000000000000000000000000000000000000000..45f8b48a8ef8d356866f089f5092f0af07542698
--- /dev/null
+++ b/base/test/scoped_mock_message_loop_task_runner_wrapper.cc
@@ -0,0 +1,34 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/test/scoped_mock_message_loop_task_runner_wrapper.h"
+
+#include <deque>
+
+#include "base/logging.h"
+#include "base/message_loop/message_loop.h"
+#include "base/test/test_mock_time_task_runner.h"
+#include "base/test/test_pending_task.h"
+#include "base/threading/thread_task_runner_handle.h"
+
+namespace base {
+
+ScopedMockMessageLoopTaskRunnerWrapper::ScopedMockMessageLoopTaskRunnerWrapper()
+ : task_runner_(new TestMockTimeTaskRunner),
+ previous_task_runner_(ThreadTaskRunnerHandle::Get()) {
+ DCHECK(MessageLoop::current());
+ MessageLoop::current()->SetTaskRunner(task_runner_);
+}
+
+ScopedMockMessageLoopTaskRunnerWrapper::
+ ~ScopedMockMessageLoopTaskRunnerWrapper() {
+ DCHECK(previous_task_runner_->RunsTasksOnCurrentThread());
+ DCHECK_EQ(task_runner_, ThreadTaskRunnerHandle::Get());
+ std::deque<TestPendingTask> tasks = task_runner_->TakePendingTasks();
+ for (auto it = tasks.begin(); it != tasks.end(); ++it)
gab 2016/11/15 23:16:59 28-29 => for (const auto& pending_task : task_run
bruthig 2016/11/17 23:57:08 Done.
+ previous_task_runner_->PostDelayedTask(it->location, it->task, it->delay);
gab 2016/11/15 23:16:59 Last parameter consider the time that has passed a
bruthig 2016/11/17 23:57:08 Done.
+ MessageLoop::current()->SetTaskRunner(std::move(previous_task_runner_));
+}
+
+} // namespace base
« no previous file with comments | « base/test/scoped_mock_message_loop_task_runner_wrapper.h ('k') | base/test/test_mock_time_task_runner.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698