Commit 638b48e2 authored by fdoray's avatar fdoray Committed by Commit bot

Use ScopedTaskEnvironment instead of MessageLoopForUI in remoting tests.

ScopedTaskEnvironment allows usage of ThreadTaskRunnerHandle and
base/task_scheduler/post_task.h within its scope. It should be
instantiated in everytest that uses either of these APIs
(i.e. no test should instantiate a MessageLoop directly).

Motivation for ScopedTaskEnvironment can be found in:
https://docs.google.com/document/d/1QabRo8c7D9LsYY3cEcaPQbOCLo8Tu-6VLykYXyl3Pkk/edit

BUG=708584
R=gab@chromium.org
TBR=garykac@chromium.org

Review-Url: https://codereview.chromium.org/2846943002
Cr-Commit-Position: refs/heads/master@{#468018}
parent e17ef94d
...@@ -173,6 +173,7 @@ if (enable_remoting_host && !is_android && !is_chromeos) { ...@@ -173,6 +173,7 @@ if (enable_remoting_host && !is_android && !is_chromeos) {
deps = [ deps = [
":fake_connection_event_logger", ":fake_connection_event_logger",
"//base/test:test_support",
"//third_party/webrtc/modules/desktop_capture", "//third_party/webrtc/modules/desktop_capture",
] ]
......
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/memory/ptr_util.h" #include "base/memory/ptr_util.h"
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/threading/thread_task_runner_handle.h"
#include "base/time/time.h" #include "base/time/time.h"
#include "remoting/base/auto_thread_task_runner.h" #include "remoting/base/auto_thread_task_runner.h"
#include "remoting/host/chromoting_host_context.h" #include "remoting/host/chromoting_host_context.h"
...@@ -36,9 +37,11 @@ constexpr char kSessionJid[] = "user@domain/rest-of-jid"; ...@@ -36,9 +37,11 @@ constexpr char kSessionJid[] = "user@domain/rest-of-jid";
using ::remoting::protocol::MockSession; using ::remoting::protocol::MockSession;
It2MeStandaloneHost::It2MeStandaloneHost() It2MeStandaloneHost::It2MeStandaloneHost()
: context_(ChromotingHostContext::Create( : scoped_task_environment_(
new AutoThreadTaskRunner( base::test::ScopedTaskEnvironment::MainThreadType::UI),
message_loop_.task_runner(), run_loop_.QuitClosure()))), context_(ChromotingHostContext::Create(
new AutoThreadTaskRunner(base::ThreadTaskRunnerHandle::Get(),
run_loop_.QuitClosure()))),
main_task_runner_(context_->file_task_runner()), main_task_runner_(context_->file_task_runner()),
factory_(main_task_runner_, factory_(main_task_runner_,
context_->video_capture_task_runner(), context_->video_capture_task_runner(),
......
...@@ -9,8 +9,8 @@ ...@@ -9,8 +9,8 @@
#include <string> #include <string>
#include "base/memory/ref_counted.h" #include "base/memory/ref_counted.h"
#include "base/message_loop/message_loop.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/test/scoped_task_environment.h"
#include "base/timer/timer.h" #include "base/timer/timer.h"
#include "remoting/host/host_mock_objects.h" #include "remoting/host/host_mock_objects.h"
#include "remoting/host/it2me_desktop_environment.h" #include "remoting/host/it2me_desktop_environment.h"
...@@ -43,7 +43,7 @@ class It2MeStandaloneHost { ...@@ -43,7 +43,7 @@ class It2MeStandaloneHost {
private: private:
void Connect(); void Connect();
base::MessageLoopForUI message_loop_; base::test::ScopedTaskEnvironment scoped_task_environment_;
base::RunLoop run_loop_; base::RunLoop run_loop_;
std::unique_ptr<ChromotingHostContext> context_; std::unique_ptr<ChromotingHostContext> context_;
scoped_refptr<AutoThreadTaskRunner> main_task_runner_; scoped_refptr<AutoThreadTaskRunner> main_task_runner_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment