Chromium Code Reviews| Index: remoting/test/it2me_standalone_host.cc |
| diff --git a/remoting/test/it2me_standalone_host.cc b/remoting/test/it2me_standalone_host.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..92eda839e40f3b49546ffbc90fbda8400bf868d2 |
| --- /dev/null |
| +++ b/remoting/test/it2me_standalone_host.cc |
| @@ -0,0 +1,92 @@ |
| +// Copyright 2016 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 "remoting/test/it2me_standalone_host.h" |
| + |
| +#include <vector> |
| + |
| +#include "base/bind.h" |
| +#include "base/location.h" |
| +#include "base/memory/ptr_util.h" |
| +#include "base/memory/ref_counted.h" |
| +#include "base/time/time.h" |
| +#include "remoting/base/auto_thread_task_runner.h" |
| +#include "remoting/host/chromoting_host_context.h" |
| +#include "remoting/host/host_extension.h" |
| +#include "remoting/protocol/pairing_registry.h" |
| +#include "remoting/protocol/protocol_mock_objects.h" |
| +#include "remoting/protocol/session_config.h" |
| + |
| +namespace remoting { |
| +namespace test { |
| + |
| +using ::remoting::protocol::MockSession; |
| + |
| +It2MeStandaloneHost::It2MeStandaloneHost() |
| + : message_loop_(), |
|
joedow
2016/05/03 22:28:30
Do these need to be included? I thought default i
Hzj_jie
2016/05/04 02:11:57
Done.
|
| + run_loop_(), |
| + context_(ChromotingHostContext::Create( |
| + new AutoThreadTaskRunner( |
| + message_loop_.task_runner(), run_loop_.QuitClosure()))), |
| + factory_(context_->file_task_runner(), |
| + context_->video_capture_task_runner(), |
| + context_->input_task_runner(), |
| + context_->ui_task_runner()), |
| + connection_(base::WrapUnique(new testing::NiceMock<MockSession>())), |
| + session_jid_("user@domain/rest-of-jid"), |
| +#if defined(OS_LINUX) |
| + // We cannot support audio capturing for linux, since a pipe name is |
| + // needed to initialize AudioCapturerLinux. |
| + config_(protocol::SessionConfig::ForTest()), |
| +#else |
| + config_(protocol::SessionConfig::ForTestWithAudio()), |
| +#endif |
| + audio_stub_(), |
|
joedow
2016/05/03 22:28:29
You don't need to include these in the initializer
Hzj_jie
2016/05/04 02:11:56
Done.
|
| + client_stub_(), |
| + host_stub_(), |
| + video_stub_(&connection_), |
| + handler_(), |
| + session_() { |
| + factory_.enable_user_interface(false); |
| + EXPECT_CALL(*static_cast<MockSession*>(connection_.session()), jid()) |
| + .WillRepeatedly(testing::ReturnRef(session_jid_)); |
| + EXPECT_CALL(*static_cast<MockSession*>(connection_.session()), config()) |
| + .WillRepeatedly(testing::ReturnRef(*config_)); |
| + connection_.set_audio_stub(&audio_stub_); |
| + connection_.set_video_stub(&video_stub_); |
| + connection_.set_client_stub(&client_stub_); |
| + connection_.set_host_stub(&host_stub_); |
| + connection_.set_video_encode_task_runner( |
| + context_->video_encode_task_runner()); |
| +} |
| + |
| +void It2MeStandaloneHost::ConnectProxy(It2MeStandaloneHost* host) { |
| + host->Connect(); |
| +} |
| + |
| +void It2MeStandaloneHost::Connect() { |
| + session_.reset(new ClientSession( |
| + &handler_, |
| + context_->audio_task_runner(), |
| + std::unique_ptr<protocol::ConnectionToClient>(&connection_), |
| + &factory_, |
| + base::TimeDelta(), |
| + scoped_refptr<protocol::PairingRegistry>(), |
| + std::vector<HostExtension*>())); |
| + session_->OnConnectionAuthenticated(&connection_); |
| + session_->OnConnectionChannelsConnected(&connection_); |
| + session_->CreateVideoStreams(&connection_); |
| +} |
| + |
| +void It2MeStandaloneHost::Run() { |
|
joedow
2016/05/03 22:28:30
I'd move this file above the private methods in th
Hzj_jie
2016/05/04 02:11:56
Done.
|
| + context_->file_task_runner()->PostTask( |
| + FROM_HERE, |
| + base::Bind(&It2MeStandaloneHost::ConnectProxy, this)); |
|
joedow
2016/05/03 22:28:30
This method doesn't need to be static. Instead of
Hzj_jie
2016/05/04 02:11:57
Done.
|
| + run_loop_.Run(); |
| +} |
| + |
| +It2MeStandaloneHost::~It2MeStandaloneHost() {} |
|
joedow
2016/05/03 22:28:30
d'tor should go below the c'tor
Hzj_jie
2016/05/04 02:11:56
Done.
|
| + |
| +} // namespace test |
| +} // namespace remoting |