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

Unified Diff: remoting/test/it2me_standalone_host.cc

Issue 1923573006: Implement a dummy host to do capturing and analysis only. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Resolve review commnets Created 4 years, 7 months 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 | « remoting/test/it2me_standalone_host.h ('k') | remoting/test/it2me_standalone_host_main.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..9dbaff3b4da3ffe0563892bd24479f83a45d9949
--- /dev/null
+++ b/remoting/test/it2me_standalone_host.cc
@@ -0,0 +1,100 @@
+// 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 <iostream>
+#include <vector>
+
+#include "base/bind.h"
+#include "base/location.h"
+#include "base/logging.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 {
+
+namespace {
+
+void OutputFakeConnectionEventLogger(const FakeConnectionEventLogger* logger) {
+ DCHECK(logger);
+ std::cout << *logger;
+}
+
+constexpr char kSessionJid[] = "user@domain/rest-of-jid";
+
+} // namespace
+
+using ::remoting::protocol::MockSession;
+
+It2MeStandaloneHost::It2MeStandaloneHost()
+ : context_(ChromotingHostContext::Create(
+ new AutoThreadTaskRunner(
+ message_loop_.task_runner(), run_loop_.QuitClosure()))),
+ main_task_runner_(context_->file_task_runner()),
+ factory_(main_task_runner_,
+ context_->video_capture_task_runner(),
+ context_->input_task_runner(),
+ context_->ui_task_runner()),
+ connection_(base::WrapUnique(new testing::NiceMock<MockSession>())),
+ session_jid_(kSessionJid),
+#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
+ event_logger_(&connection_) {
+ factory_.set_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(event_logger_.audio_stub());
+ connection_.set_video_stub(event_logger_.video_stub());
+ connection_.set_client_stub(event_logger_.client_stub());
+ connection_.set_host_stub(event_logger_.host_stub());
+ connection_.set_video_encode_task_runner(
+ context_->video_encode_task_runner());
+}
+
+It2MeStandaloneHost::~It2MeStandaloneHost() {}
+
+void It2MeStandaloneHost::Run() {
+ main_task_runner_->PostTask(
+ FROM_HERE,
+ base::Bind(&It2MeStandaloneHost::Connect, base::Unretained(this)));
+ run_loop_.Run();
+}
+
+void It2MeStandaloneHost::StartOutputTimer() {
+ timer_.Start(FROM_HERE, base::TimeDelta::FromSeconds(1),
+ base::Bind(&OutputFakeConnectionEventLogger, &event_logger_));
+}
+
+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_);
+}
+
+} // namespace test
+} // namespace remoting
« no previous file with comments | « remoting/test/it2me_standalone_host.h ('k') | remoting/test/it2me_standalone_host_main.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698