Chromium Code Reviews| Index: base/test/scoped_mock_message_loop_task_runner_wrapper.h |
| diff --git a/base/test/scoped_mock_message_loop_task_runner_wrapper.h b/base/test/scoped_mock_message_loop_task_runner_wrapper.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a4fc20c3f611473bbad6f7263428de0bff0b5861 |
| --- /dev/null |
| +++ b/base/test/scoped_mock_message_loop_task_runner_wrapper.h |
| @@ -0,0 +1,45 @@ |
| +// 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. |
| + |
| +#ifndef BASE_TEST_SCOPED_MOCK_MESSAGE_LOOP_TASK_RUNNER_WRAPPER_H_ |
| +#define BASE_TEST_SCOPED_MOCK_MESSAGE_LOOP_TASK_RUNNER_WRAPPER_H_ |
| + |
| +#include <stddef.h> |
| + |
| +#include <memory> |
| +#include <queue> |
| +#include <vector> |
| + |
| +#include "base/macros.h" |
| +#include "base/single_thread_task_runner.h" |
| +#include "base/synchronization/lock.h" |
| +#include "base/test/test_pending_task.h" |
| +#include "base/threading/thread_checker.h" |
| +#include "base/time/time.h" |
| + |
| +namespace base { |
|
gab
2016/11/15 22:02:06
empty line after namespace
bruthig
2016/11/15 22:17:57
Done.
|
| +class TestMockTimeTaskRunner; |
| +class SingleThreadTaskRunner; |
| + |
| +// A scoped wrapper around TestMockTimeTaskRunner that replaces |
| +// MessageLoop::current()'s task runner (and consequently |
| +// ThreadTaskRunnerHandle) with a TestMockTimeTaskRunner and resets it back at |
| +// the end of the scope. |
| +class ScopedMockMessageLoopTaskRunnerWrapper { |
| + public: |
| + ScopedMockMessageLoopTaskRunnerWrapper(); |
| + ~ScopedMockMessageLoopTaskRunnerWrapper(); |
| + |
| + TestMockTimeTaskRunner* task_runner() { return task_runner_.get(); } |
| + |
| + private: |
| + const scoped_refptr<TestMockTimeTaskRunner> task_runner_; |
| + scoped_refptr<SingleThreadTaskRunner> previous_task_runner_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ScopedMockMessageLoopTaskRunnerWrapper); |
| +}; |
| + |
| +} // namespace base |
| + |
| +#endif // BASE_TEST_SCOPED_MOCK_MESSAGE_LOOP_TASK_RUNNER_WRAPPER_H_ |