| 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..dc3ae7d8d2e80469df7cd830e15904a269be92b2
|
| --- /dev/null
|
| +++ b/remoting/protocol/fake_connection_to_host.cc
|
| @@ -0,0 +1,79 @@
|
| +// 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) {}
|
| +
|
| +FakeConnectionToHost::~FakeConnectionToHost() {}
|
| +
|
| +void FakeConnectionToHost::ConnectPtr(
|
| + SignalStrategy* signal_strategy,
|
| + protocol::TransportFactory* transport_factory,
|
| + protocol::Authenticator* authenticator,
|
| + const std::string& host_jid,
|
| + HostEventCallback* event_callback) {
|
| + DCHECK(CalledOnValidThread());
|
| +
|
| + // WARNING: Do not store |transport_factory| or |authenticator|.
|
| + // This function is given raw pointers for these params instead of a
|
| + // scoped_ptr so the method can be called using GMock macros. Since we cannot
|
| + // take ownership of the pointer, it isn't safe to assign them here for later
|
| + // use.
|
| + // |event_callback| and |signal_strategy| are OK to use as they are both raw
|
| + // ptrs in the original method signature.
|
| + event_callback_ = event_callback;
|
| +
|
| + SetState(CONNECTING, protocol::OK);
|
| +}
|
| +
|
| +void FakeConnectionToHost::OnSessionStateChange(
|
| + 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);
|
| +}
|
| +
|
| +} // namespace test
|
| +} // namespace remoting
|
|
|