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

Unified 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 side-by-side diff with in-line comments
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 »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: remoting/protocol/fake_session.cc
diff --git a/remoting/protocol/fake_session.cc b/remoting/protocol/fake_session.cc
index 6b299b05cceef50499b2927570a60edd7e8d910f..46edfe95ce33ef56f2784180bdf9c50e9bb56711 100644
--- a/remoting/protocol/fake_session.cc
+++ b/remoting/protocol/fake_session.cc
@@ -32,14 +32,31 @@ FakeStreamChannelFactory* FakeTransport::GetMultiplexedChannelFactory() {
}
FakeSession::FakeSession()
- : event_handler_(nullptr),
- config_(SessionConfig::ForTest()),
- jid_(kTestJid),
- error_(OK),
- closed_(false) {}
+ : config_(SessionConfig::ForTest()), jid_(kTestJid), weak_factory_(this) {}
FakeSession::~FakeSession() {}
+void FakeSession::SimulateConnection(FakeSession* peer) {
+ peer_ = peer->weak_factory_.GetWeakPtr();
+ peer->peer_ = weak_factory_.GetWeakPtr();
+
+ transport_.GetStreamChannelFactory()->PairWith(
+ peer->transport_.GetStreamChannelFactory());
+ transport_.GetMultiplexedChannelFactory()->PairWith(
+ peer->transport_.GetMultiplexedChannelFactory());
+
+ event_handler_->OnSessionStateChange(CONNECTING);
+ peer->event_handler_->OnSessionStateChange(ACCEPTING);
+ peer->event_handler_->OnSessionStateChange(ACCEPTED);
+ event_handler_->OnSessionStateChange(ACCEPTED);
+ event_handler_->OnSessionStateChange(AUTHENTICATING);
+ peer->event_handler_->OnSessionStateChange(AUTHENTICATING);
+ event_handler_->OnSessionStateChange(AUTHENTICATED);
+ peer->event_handler_->OnSessionStateChange(AUTHENTICATED);
+ event_handler_->OnSessionStateChange(CONNECTED);
+ peer->event_handler_->OnSessionStateChange(CONNECTED);
+}
+
void FakeSession::SetEventHandler(EventHandler* event_handler) {
event_handler_ = event_handler;
}
@@ -63,6 +80,14 @@ FakeTransport* FakeSession::GetTransport() {
void FakeSession::Close(ErrorCode error) {
closed_ = true;
error_ = error;
+ event_handler_->OnSessionStateChange(CLOSED);
+
+ FakeSession* peer = peer_.get();
+ if (peer) {
+ peer->peer_.reset();
+ peer_.reset();
+ peer->Close(error);
+ }
}
} // namespace protocol
« 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