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

Unified Diff: remoting/protocol/fake_connection_to_host.cc

Issue 976233003: Adding the base ChromotingInstance implementation and unittests. This class will be used by the ap… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressing Sergey's feedback Created 5 years, 9 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
Index: remoting/protocol/fake_connection_to_host.cc
diff --git a/remoting/protocol/fake_connection_to_host.cc b/remoting/protocol/fake_connection_to_host.cc
new file mode 100644
index 0000000000000000000000000000000000000000..baec4773d99c990a6519f1a4c7280b5d7b2ef5b8
--- /dev/null
+++ b/remoting/protocol/fake_connection_to_host.cc
@@ -0,0 +1,84 @@
+// 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 "remoting/protocol/fake_connection_to_host.h"
+
+#include "remoting/protocol/authenticator.h"
+
+namespace remoting {
+namespace test {
+
+FakeConnectionToHost::FakeConnectionToHost()
+ : session_state_change_error_code_(protocol::ErrorCode::OK),
+ session_config_(protocol::SessionConfig::ForTest()) {
+}
+
+FakeConnectionToHost::~FakeConnectionToHost() {
+}
+
+void FakeConnectionToHost::Connect(
+ SignalStrategy* signal_strategy,
+ scoped_ptr<protocol::TransportFactory> transport_factory,
+ scoped_ptr<protocol::Authenticator> authenticator,
+ const std::string& host_jid,
+ HostEventCallback* event_callback) {
+ DCHECK(CalledOnValidThread());
+ DCHECK(event_callback);
+
+ event_callback_ = event_callback;
+
+ SetState(CONNECTING, protocol::OK);
+}
+
+void FakeConnectionToHost::OnSessionStateChange(
Sergey Ulanov 2015/03/11 00:09:51 I'm not sure why you need this. FakeConnectionToHo
joedow 2015/03/11 19:06:39 Done.
+ protocol::Session::State state) {
+ DCHECK(CalledOnValidThread());
+ DCHECK(event_callback_);
+
+ switch (state) {
+ case protocol::Session::INITIALIZING:
+ case protocol::Session::CONNECTING:
+ case protocol::Session::ACCEPTING:
+ case protocol::Session::AUTHENTICATING:
+ // No updates for these events.
+ break;
+
+ case protocol::Session::CONNECTED:
+ SetState(CONNECTED, protocol::ErrorCode::OK);
+ break;
+
+ case protocol::Session::AUTHENTICATED:
+ SetState(AUTHENTICATED, protocol::ErrorCode::OK);
+ break;
+
+ case protocol::Session::CLOSED:
+ SetState(CLOSED, protocol::ErrorCode::OK);
+ break;
+
+ case protocol::Session::FAILED:
+ // session_state_change_error_code_ must be set before sending a FAILED
+ // session state.
+ DCHECK(session_state_change_error_code_ != protocol::ErrorCode::OK);
+ SetState(FAILED, session_state_change_error_code_);
+ break;
+ }
+}
+
+void FakeConnectionToHost::OnVideoChannelStatus(bool active) {
+ DCHECK(CalledOnValidThread());
+ DCHECK(event_callback_);
+
+ event_callback_->OnConnectionReady(active);
+}
+
+const protocol::SessionConfig& FakeConnectionToHost::config() {
+ return session_config_;
+}
+
+protocol::HostStub* FakeConnectionToHost::host_stub() {
+ return &mock_host_stub_;
+}
+
+} // namespace test
+} // namespace remoting

Powered by Google App Engine
This is Rietveld 408576698