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

Side by Side Diff: remoting/protocol/fake_session.cc

Issue 1531983002: Replace ice_connection_to_client_unittest.cc with connection_unittest.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
« no previous file with comments | « remoting/protocol/fake_session.h ('k') | remoting/protocol/fake_stream_socket.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "remoting/protocol/fake_session.h" 5 #include "remoting/protocol/fake_session.h"
6 6
7 namespace remoting { 7 namespace remoting {
8 namespace protocol { 8 namespace protocol {
9 9
10 const char kTestJid[] = "host1@gmail.com/chromoting123"; 10 const char kTestJid[] = "host1@gmail.com/chromoting123";
(...skipping 14 matching lines...) Expand all
25 25
26 FakeStreamChannelFactory* FakeTransport::GetStreamChannelFactory() { 26 FakeStreamChannelFactory* FakeTransport::GetStreamChannelFactory() {
27 return &channel_factory_; 27 return &channel_factory_;
28 } 28 }
29 29
30 FakeStreamChannelFactory* FakeTransport::GetMultiplexedChannelFactory() { 30 FakeStreamChannelFactory* FakeTransport::GetMultiplexedChannelFactory() {
31 return &channel_factory_; 31 return &channel_factory_;
32 } 32 }
33 33
34 FakeSession::FakeSession() 34 FakeSession::FakeSession()
35 : event_handler_(nullptr), 35 : config_(SessionConfig::ForTest()), jid_(kTestJid), weak_factory_(this) {}
36 config_(SessionConfig::ForTest()),
37 jid_(kTestJid),
38 error_(OK),
39 closed_(false) {}
40 36
41 FakeSession::~FakeSession() {} 37 FakeSession::~FakeSession() {}
42 38
39 void FakeSession::SimulateConnection(FakeSession* peer) {
40 peer_ = peer->weak_factory_.GetWeakPtr();
41 peer->peer_ = weak_factory_.GetWeakPtr();
42
43 transport_.GetStreamChannelFactory()->PairWith(
44 peer->transport_.GetStreamChannelFactory());
45 transport_.GetMultiplexedChannelFactory()->PairWith(
46 peer->transport_.GetMultiplexedChannelFactory());
47
48 event_handler_->OnSessionStateChange(CONNECTING);
49 peer->event_handler_->OnSessionStateChange(ACCEPTING);
50 peer->event_handler_->OnSessionStateChange(ACCEPTED);
51 event_handler_->OnSessionStateChange(ACCEPTED);
52 event_handler_->OnSessionStateChange(AUTHENTICATING);
53 peer->event_handler_->OnSessionStateChange(AUTHENTICATING);
54 event_handler_->OnSessionStateChange(AUTHENTICATED);
55 peer->event_handler_->OnSessionStateChange(AUTHENTICATED);
56 event_handler_->OnSessionStateChange(CONNECTED);
57 peer->event_handler_->OnSessionStateChange(CONNECTED);
58 }
59
43 void FakeSession::SetEventHandler(EventHandler* event_handler) { 60 void FakeSession::SetEventHandler(EventHandler* event_handler) {
44 event_handler_ = event_handler; 61 event_handler_ = event_handler;
45 } 62 }
46 63
47 ErrorCode FakeSession::error() { 64 ErrorCode FakeSession::error() {
48 return error_; 65 return error_;
49 } 66 }
50 67
51 const std::string& FakeSession::jid() { 68 const std::string& FakeSession::jid() {
52 return jid_; 69 return jid_;
53 } 70 }
54 71
55 const SessionConfig& FakeSession::config() { 72 const SessionConfig& FakeSession::config() {
56 return *config_; 73 return *config_;
57 } 74 }
58 75
59 FakeTransport* FakeSession::GetTransport() { 76 FakeTransport* FakeSession::GetTransport() {
60 return &transport_; 77 return &transport_;
61 } 78 }
62 79
63 void FakeSession::Close(ErrorCode error) { 80 void FakeSession::Close(ErrorCode error) {
64 closed_ = true; 81 closed_ = true;
65 error_ = error; 82 error_ = error;
83 event_handler_->OnSessionStateChange(CLOSED);
84
85 FakeSession* peer = peer_.get();
86 if (peer) {
87 peer->peer_.reset();
88 peer_.reset();
89 peer->Close(error);
90 }
66 } 91 }
67 92
68 } // namespace protocol 93 } // namespace protocol
69 } // namespace remoting 94 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/fake_session.h ('k') | remoting/protocol/fake_stream_socket.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698