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

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

Issue 1197853003: Add P2PDatagramSocket and P2PStreamSocket interfaces. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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
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/jingle_session.h" 5 #include "remoting/protocol/jingle_session.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h" 8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 80
81 class MockSessionEventHandler : public Session::EventHandler { 81 class MockSessionEventHandler : public Session::EventHandler {
82 public: 82 public:
83 MOCK_METHOD1(OnSessionStateChange, void(Session::State)); 83 MOCK_METHOD1(OnSessionStateChange, void(Session::State));
84 MOCK_METHOD2(OnSessionRouteChange, void(const std::string& channel_name, 84 MOCK_METHOD2(OnSessionRouteChange, void(const std::string& channel_name,
85 const TransportRoute& route)); 85 const TransportRoute& route));
86 }; 86 };
87 87
88 class MockChannelCreatedCallback { 88 class MockChannelCreatedCallback {
89 public: 89 public:
90 MOCK_METHOD1(OnDone, void(net::StreamSocket* socket)); 90 MOCK_METHOD1(OnDone, void(P2PStreamSocket* socket));
91 }; 91 };
92 92
93 } // namespace 93 } // namespace
94 94
95 class JingleSessionTest : public testing::Test { 95 class JingleSessionTest : public testing::Test {
96 public: 96 public:
97 JingleSessionTest() { 97 JingleSessionTest() {
98 message_loop_.reset(new base::MessageLoopForIO()); 98 message_loop_.reset(new base::MessageLoopForIO());
99 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop(); 99 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop();
100 } 100 }
101 101
102 // Helper method that handles OnIncomingSession(). 102 // Helper method that handles OnIncomingSession().
103 void SetHostSession(Session* session) { 103 void SetHostSession(Session* session) {
104 DCHECK(session); 104 DCHECK(session);
105 host_session_.reset(session); 105 host_session_.reset(session);
106 host_session_->SetEventHandler(&host_session_event_handler_); 106 host_session_->SetEventHandler(&host_session_event_handler_);
107 107
108 session->set_config(standard_ice_ ? SessionConfig::ForTest() 108 session->set_config(standard_ice_ ? SessionConfig::ForTest()
109 : SessionConfig::WithLegacyIceForTest()); 109 : SessionConfig::WithLegacyIceForTest());
110 } 110 }
111 111
112 void DeleteSession() { 112 void DeleteSession() {
113 host_session_.reset(); 113 host_session_.reset();
114 } 114 }
115 115
116 void OnClientChannelCreated(scoped_ptr<net::StreamSocket> socket) { 116 void OnClientChannelCreated(scoped_ptr<P2PStreamSocket> socket) {
117 client_channel_callback_.OnDone(socket.get()); 117 client_channel_callback_.OnDone(socket.get());
118 client_socket_ = socket.Pass(); 118 client_socket_ = socket.Pass();
119 } 119 }
120 120
121 void OnHostChannelCreated(scoped_ptr<net::StreamSocket> socket) { 121 void OnHostChannelCreated(scoped_ptr<P2PStreamSocket> socket) {
122 host_channel_callback_.OnDone(socket.get()); 122 host_channel_callback_.OnDone(socket.get());
123 host_socket_ = socket.Pass(); 123 host_socket_ = socket.Pass();
124 } 124 }
125 125
126 protected: 126 protected:
127 void SetUp() override {} 127 void SetUp() override {}
128 128
129 void TearDown() override { 129 void TearDown() override {
130 CloseSessions(); 130 CloseSessions();
131 CloseSessionManager(); 131 CloseSessionManager();
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
302 MockSessionManagerListener client_server_listener_; 302 MockSessionManagerListener client_server_listener_;
303 303
304 scoped_ptr<Session> host_session_; 304 scoped_ptr<Session> host_session_;
305 MockSessionEventHandler host_session_event_handler_; 305 MockSessionEventHandler host_session_event_handler_;
306 scoped_ptr<Session> client_session_; 306 scoped_ptr<Session> client_session_;
307 MockSessionEventHandler client_session_event_handler_; 307 MockSessionEventHandler client_session_event_handler_;
308 308
309 MockChannelCreatedCallback client_channel_callback_; 309 MockChannelCreatedCallback client_channel_callback_;
310 MockChannelCreatedCallback host_channel_callback_; 310 MockChannelCreatedCallback host_channel_callback_;
311 311
312 scoped_ptr<net::StreamSocket> client_socket_; 312 scoped_ptr<P2PStreamSocket> client_socket_;
313 scoped_ptr<net::StreamSocket> host_socket_; 313 scoped_ptr<P2PStreamSocket> host_socket_;
314 }; 314 };
315 315
316 316
317 // Verify that we can create and destroy session managers without a 317 // Verify that we can create and destroy session managers without a
318 // connection. 318 // connection.
319 TEST_F(JingleSessionTest, CreateAndDestoy) { 319 TEST_F(JingleSessionTest, CreateAndDestoy) {
320 CreateSessionManagers(1, FakeAuthenticator::ACCEPT); 320 CreateSessionManagers(1, FakeAuthenticator::ACCEPT);
321 } 321 }
322 322
323 // Verify that an incoming session can be rejected, and that the 323 // Verify that an incoming session can be rejected, and that the
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
566 566
567 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), 567 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
568 kMessageSize, 1); 568 kMessageSize, 1);
569 tester.Start(); 569 tester.Start();
570 message_loop_->Run(); 570 message_loop_->Run();
571 tester.CheckResults(); 571 tester.CheckResults();
572 } 572 }
573 573
574 } // namespace protocol 574 } // namespace protocol
575 } // namespace remoting 575 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698