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

Side by Side 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: Fixing Release Build Break 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "remoting/protocol/fake_connection_to_host.h"
6
7 #include "remoting/protocol/authenticator.h"
8
9 namespace remoting {
10 namespace test {
11
12 FakeConnectionToHost::FakeConnectionToHost()
13 : state_(INITIALIZING),
14 session_config_(protocol::SessionConfig::ForTest()) {
15 }
16
17 FakeConnectionToHost::~FakeConnectionToHost() {
18 }
19
20 void FakeConnectionToHost::set_candidate_config(
21 scoped_ptr<protocol::CandidateSessionConfig> config) {
22 }
23
24 void FakeConnectionToHost::set_client_stub(protocol::ClientStub* client_stub) {
25 }
26
27 void FakeConnectionToHost::set_clipboard_stub(
28 protocol::ClipboardStub* clipboard_stub) {
29 }
30
31 void FakeConnectionToHost::set_video_stub(protocol::VideoStub* video_stub) {
32 }
33
34 void FakeConnectionToHost::set_audio_stub(protocol::AudioStub* audio_stub) {
35 }
36
37 void FakeConnectionToHost::Connect(
38 SignalStrategy* signal_strategy,
39 scoped_ptr<protocol::TransportFactory> transport_factory,
40 scoped_ptr<protocol::Authenticator> authenticator,
41 const std::string& host_jid,
42 HostEventCallback* event_callback) {
43 DCHECK(event_callback);
44
45 event_callback_ = event_callback;
46
47 SetState(CONNECTING, protocol::OK);
48 }
49
50 void FakeConnectionToHost::SignalStateChange(protocol::Session::State state,
51 protocol::ErrorCode error) {
52 DCHECK(event_callback_);
53
54 switch (state) {
55 case protocol::Session::INITIALIZING:
56 case protocol::Session::CONNECTING:
57 case protocol::Session::ACCEPTING:
58 case protocol::Session::AUTHENTICATING:
59 // No updates for these events.
60 break;
61
62 case protocol::Session::CONNECTED:
63 SetState(CONNECTED, error);
64 break;
65
66 case protocol::Session::AUTHENTICATED:
67 SetState(AUTHENTICATED, error);
68 break;
69
70 case protocol::Session::CLOSED:
71 SetState(CLOSED, error);
72 break;
73
74 case protocol::Session::FAILED:
75 DCHECK(error != protocol::ErrorCode::OK);
76 SetState(FAILED, error);
77 break;
78 }
79 }
80
81 void FakeConnectionToHost::SignalConnectionReady(bool ready) {
82 DCHECK(event_callback_);
83
84 event_callback_->OnConnectionReady(ready);
85 }
86
87 const protocol::SessionConfig& FakeConnectionToHost::config() {
88 return session_config_;
89 }
90
91 protocol::ClipboardStub* FakeConnectionToHost::clipboard_forwarder() {
92 return &mock_clipboard_stub_;
93 }
94
95 protocol::HostStub* FakeConnectionToHost::host_stub() {
96 return &mock_host_stub_;
97 }
98
99 protocol::InputStub* FakeConnectionToHost::input_stub() {
100 return &mock_input_stub_;
101 }
102
103 protocol::ConnectionToHost::State FakeConnectionToHost::state() const {
104 return state_;
105 }
106
107 void FakeConnectionToHost::SetState(State state, protocol::ErrorCode error) {
108 // |error| should be specified only when |state| is set to FAILED.
109 DCHECK(state == FAILED || error == protocol::OK);
110
111 if (state != state_) {
112 state_ = state;
113 event_callback_->OnConnectionState(state_, error);
114 }
115 }
116
117 } // namespace test
118 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698