OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "base/time.h" | 5 #include "base/time.h" |
6 #include "base/waitable_event.h" | 6 #include "base/waitable_event.h" |
7 #include "base/test/test_timeouts.h" | 7 #include "base/test/test_timeouts.h" |
8 #include "net/base/completion_callback.h" | 8 #include "net/base/completion_callback.h" |
9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
10 #include "net/base/net_errors.h" | 10 #include "net/base/net_errors.h" |
11 #include "net/socket/socket.h" | 11 #include "net/socket/socket.h" |
12 #include "remoting/protocol/jingle_chromotocol_connection.h" | 12 #include "remoting/protocol/jingle_session.h" |
13 #include "remoting/protocol/jingle_chromotocol_server.h" | 13 #include "remoting/protocol/jingle_session_manager.h" |
14 #include "remoting/protocol/session_manager_pair.h" | 14 #include "remoting/protocol/session_manager_pair.h" |
15 #include "remoting/jingle_glue/jingle_thread.h" | 15 #include "remoting/jingle_glue/jingle_thread.h" |
16 #include "testing/gmock/include/gmock/gmock.h" | 16 #include "testing/gmock/include/gmock/gmock.h" |
17 #include "testing/gtest/include/gtest/gtest.h" | 17 #include "testing/gtest/include/gtest/gtest.h" |
18 #include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h" | 18 #include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h" |
19 | 19 |
20 using testing::_; | 20 using testing::_; |
21 using testing::DoAll; | 21 using testing::DoAll; |
22 using testing::Invoke; | 22 using testing::Invoke; |
23 using testing::InvokeWithoutArgs; | 23 using testing::InvokeWithoutArgs; |
24 using testing::Return; | 24 using testing::Return; |
25 using testing::SaveArg; | 25 using testing::SaveArg; |
26 using testing::SetArgumentPointee; | 26 using testing::SetArgumentPointee; |
27 using testing::WithArg; | 27 using testing::WithArg; |
28 | 28 |
29 namespace remoting { | 29 namespace remoting { |
30 class JingleChromotocolConnectionTest; | 30 namespace protocol { |
| 31 class JingleSessionTest; |
| 32 } // namespace protocol |
31 } // namespace remoting | 33 } // namespace remoting |
32 | 34 |
33 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::JingleChromotocolConnectionTest); | 35 DISABLE_RUNNABLE_METHOD_REFCOUNT(remoting::protocol::JingleSessionTest); |
34 | 36 |
35 namespace remoting { | 37 namespace remoting { |
36 | 38 |
| 39 namespace protocol { |
| 40 |
37 namespace { | 41 namespace { |
38 // Send 100 messages 1024 bytes each. UDP messages are sent with 10ms delay | 42 // Send 100 messages 1024 bytes each. UDP messages are sent with 10ms delay |
39 // between messages (about 1 second for 100 messages). | 43 // between messages (about 1 second for 100 messages). |
40 const int kMessageSize = 1024; | 44 const int kMessageSize = 1024; |
41 const int kMessages = 100; | 45 const int kMessages = 100; |
42 const int kTestDataSize = kMessages * kMessageSize; | 46 const int kTestDataSize = kMessages * kMessageSize; |
43 const int kUdpWriteDelayMs = 10; | 47 const int kUdpWriteDelayMs = 10; |
44 } // namespace | 48 } // namespace |
45 | 49 |
46 class MockServerCallback { | 50 class MockSessionManagerCallback { |
47 public: | 51 public: |
48 MOCK_METHOD2(OnIncomingConnection, | 52 MOCK_METHOD2(OnIncomingSession, |
49 void(ChromotocolConnection*, | 53 void(Session*, |
50 ChromotocolServer::IncomingConnectionResponse*)); | 54 SessionManager::IncomingSessionResponse*)); |
51 }; | 55 }; |
52 | 56 |
53 class MockConnectionCallback { | 57 class MockSessionCallback { |
54 public: | 58 public: |
55 MOCK_METHOD1(OnStateChange, void(ChromotocolConnection::State)); | 59 MOCK_METHOD1(OnStateChange, void(Session::State)); |
56 }; | 60 }; |
57 | 61 |
58 class JingleChromotocolConnectionTest : public testing::Test { | 62 class JingleSessionTest : public testing::Test { |
59 public: | 63 public: |
60 // Helper method to copy to set value of client_connection_. | 64 // Helper method to copy to set value of client_connection_. |
61 void SetHostConnection(ChromotocolConnection* connection) { | 65 void SetHostSession(Session* session) { |
62 DCHECK(connection); | 66 DCHECK(session); |
63 host_connection_ = connection; | 67 host_session_ = session; |
64 host_connection_->SetStateChangeCallback( | 68 host_session_->SetStateChangeCallback( |
65 NewCallback(&host_connection_callback_, | 69 NewCallback(&host_connection_callback_, |
66 &MockConnectionCallback::OnStateChange)); | 70 &MockSessionCallback::OnStateChange)); |
67 | 71 |
68 connection->set_config(ChromotocolConfig::CreateDefault()); | 72 session->set_config(ChromotocolConfig::CreateDefault()); |
69 } | 73 } |
70 | 74 |
71 protected: | 75 protected: |
72 virtual void SetUp() { | 76 virtual void SetUp() { |
73 thread_.Start(); | 77 thread_.Start(); |
74 } | 78 } |
75 | 79 |
76 virtual void TearDown() { | 80 virtual void TearDown() { |
77 CloseConnections(); | 81 CloseSessions(); |
78 | 82 |
79 if (host_server_) { | 83 if (host_server_) { |
80 host_server_->Close(NewRunnableFunction( | 84 host_server_->Close(NewRunnableFunction( |
81 &JingleChromotocolConnectionTest::DoNothing)); | 85 &JingleSessionTest::DoNothing)); |
82 } | 86 } |
83 if (client_server_) { | 87 if (client_server_) { |
84 client_server_->Close(NewRunnableFunction( | 88 client_server_->Close(NewRunnableFunction( |
85 &JingleChromotocolConnectionTest::DoNothing)); | 89 &JingleSessionTest::DoNothing)); |
86 } | 90 } |
87 thread_.Stop(); | 91 thread_.Stop(); |
88 } | 92 } |
89 | 93 |
90 void CreateServerPair() { | 94 void CreateServerPair() { |
91 // SessionManagerPair must be initialized on the jingle thread. | 95 // SessionManagerPair must be initialized on the jingle thread. |
92 thread_.message_loop()->PostTask( | 96 thread_.message_loop()->PostTask( |
93 FROM_HERE, NewRunnableMethod( | 97 FROM_HERE, NewRunnableMethod( |
94 this, &JingleChromotocolConnectionTest::DoCreateServerPair)); | 98 this, &JingleSessionTest::DoCreateServerPair)); |
95 SyncWithJingleThread(); | 99 SyncWithJingleThread(); |
96 } | 100 } |
97 | 101 |
98 void CloseConnections() { | 102 void CloseSessions() { |
99 if (host_connection_) { | 103 if (host_session_) { |
100 host_connection_->Close(NewRunnableFunction( | 104 host_session_->Close(NewRunnableFunction( |
101 &JingleChromotocolConnectionTest::DoNothing)); | 105 &JingleSessionTest::DoNothing)); |
102 } | 106 } |
103 if (client_connection_) { | 107 if (client_session_) { |
104 client_connection_->Close(NewRunnableFunction( | 108 client_session_->Close(NewRunnableFunction( |
105 &JingleChromotocolConnectionTest::DoNothing)); | 109 &JingleSessionTest::DoNothing)); |
106 } | 110 } |
107 SyncWithJingleThread(); | 111 SyncWithJingleThread(); |
108 } | 112 } |
109 | 113 |
110 void DoCreateServerPair() { | 114 void DoCreateServerPair() { |
111 session_manager_pair_ = new SessionManagerPair(&thread_); | 115 session_manager_pair_ = new SessionManagerPair(&thread_); |
112 session_manager_pair_->Init(); | 116 session_manager_pair_->Init(); |
113 host_server_ = new JingleChromotocolServer(&thread_); | 117 host_server_ = new JingleSessionManager(&thread_); |
114 host_server_->set_allow_local_ips(true); | 118 host_server_->set_allow_local_ips(true); |
115 host_server_->Init(SessionManagerPair::kHostJid, | 119 host_server_->Init(SessionManagerPair::kHostJid, |
116 session_manager_pair_->host_session_manager(), | 120 session_manager_pair_->host_session_manager(), |
117 NewCallback(&host_server_callback_, | 121 NewCallback(&host_server_callback_, |
118 &MockServerCallback::OnIncomingConnection)); | 122 &MockSessionManagerCallback::OnIncomingSession)); |
119 client_server_ = new JingleChromotocolServer(&thread_); | 123 |
| 124 client_server_ = new JingleSessionManager(&thread_); |
120 client_server_->set_allow_local_ips(true); | 125 client_server_->set_allow_local_ips(true); |
121 client_server_->Init( | 126 client_server_->Init( |
122 SessionManagerPair::kClientJid, | 127 SessionManagerPair::kClientJid, |
123 session_manager_pair_->client_session_manager(), | 128 session_manager_pair_->client_session_manager(), |
124 NewCallback(&client_server_callback_, | 129 NewCallback(&client_server_callback_, |
125 &MockServerCallback::OnIncomingConnection)); | 130 &MockSessionManagerCallback::OnIncomingSession)); |
126 } | 131 } |
127 | 132 |
128 bool InitiateConnection() { | 133 bool InitiateConnection() { |
129 EXPECT_CALL(host_server_callback_, OnIncomingConnection(_, _)) | 134 EXPECT_CALL(host_server_callback_, OnIncomingSession(_, _)) |
130 .WillOnce(DoAll( | 135 .WillOnce(DoAll( |
131 WithArg<0>(Invoke( | 136 WithArg<0>(Invoke( |
132 this, &JingleChromotocolConnectionTest::SetHostConnection)), | 137 this, &JingleSessionTest::SetHostSession)), |
133 SetArgumentPointee<1>(ChromotocolServer::ACCEPT))); | 138 SetArgumentPointee<1>(protocol::SessionManager::ACCEPT))); |
134 | 139 |
135 base::WaitableEvent host_connected_event(false, false); | 140 base::WaitableEvent host_connected_event(false, false); |
136 EXPECT_CALL(host_connection_callback_, | 141 EXPECT_CALL(host_connection_callback_, |
137 OnStateChange(ChromotocolConnection::CONNECTING)) | 142 OnStateChange(Session::CONNECTING)) |
138 .Times(1); | 143 .Times(1); |
139 EXPECT_CALL(host_connection_callback_, | 144 EXPECT_CALL(host_connection_callback_, |
140 OnStateChange(ChromotocolConnection::CONNECTED)) | 145 OnStateChange(Session::CONNECTED)) |
141 .Times(1) | 146 .Times(1) |
142 .WillOnce(InvokeWithoutArgs(&host_connected_event, | 147 .WillOnce(InvokeWithoutArgs(&host_connected_event, |
143 &base::WaitableEvent::Signal)); | 148 &base::WaitableEvent::Signal)); |
144 // Expect that the connection will be closed eventually. | 149 // Expect that the connection will be closed eventually. |
145 EXPECT_CALL(host_connection_callback_, | 150 EXPECT_CALL(host_connection_callback_, |
146 OnStateChange(ChromotocolConnection::CLOSED)) | 151 OnStateChange(Session::CLOSED)) |
147 .Times(1); | 152 .Times(1); |
148 | 153 |
149 base::WaitableEvent client_connected_event(false, false); | 154 base::WaitableEvent client_connected_event(false, false); |
150 EXPECT_CALL(client_connection_callback_, | 155 EXPECT_CALL(client_connection_callback_, |
151 OnStateChange(ChromotocolConnection::CONNECTING)) | 156 OnStateChange(Session::CONNECTING)) |
152 .Times(1); | 157 .Times(1); |
153 EXPECT_CALL(client_connection_callback_, | 158 EXPECT_CALL(client_connection_callback_, |
154 OnStateChange(ChromotocolConnection::CONNECTED)) | 159 OnStateChange(Session::CONNECTED)) |
155 .Times(1) | 160 .Times(1) |
156 .WillOnce(InvokeWithoutArgs(&client_connected_event, | 161 .WillOnce(InvokeWithoutArgs(&client_connected_event, |
157 &base::WaitableEvent::Signal)); | 162 &base::WaitableEvent::Signal)); |
158 // Expect that the connection will be closed eventually. | 163 // Expect that the connection will be closed eventually. |
159 EXPECT_CALL(client_connection_callback_, | 164 EXPECT_CALL(client_connection_callback_, |
160 OnStateChange(ChromotocolConnection::CLOSED)) | 165 OnStateChange(Session::CLOSED)) |
161 .Times(1); | 166 .Times(1); |
162 | 167 |
163 client_connection_ = client_server_->Connect( | 168 client_session_ = client_server_->Connect( |
164 SessionManagerPair::kHostJid, | 169 SessionManagerPair::kHostJid, |
165 CandidateChromotocolConfig::CreateDefault(), | 170 CandidateChromotocolConfig::CreateDefault(), |
166 NewCallback(&client_connection_callback_, | 171 NewCallback(&client_connection_callback_, |
167 &MockConnectionCallback::OnStateChange)); | 172 &MockSessionCallback::OnStateChange)); |
168 | 173 |
169 return host_connected_event.TimedWait(base::TimeDelta::FromMilliseconds( | 174 return host_connected_event.TimedWait(base::TimeDelta::FromMilliseconds( |
170 TestTimeouts::action_max_timeout_ms())) && | 175 TestTimeouts::action_max_timeout_ms())) && |
171 client_connected_event.TimedWait(base::TimeDelta::FromMilliseconds( | 176 client_connected_event.TimedWait(base::TimeDelta::FromMilliseconds( |
172 TestTimeouts::action_max_timeout_ms())); | 177 TestTimeouts::action_max_timeout_ms())); |
173 } | 178 } |
174 | 179 |
175 static void SignalEvent(base::WaitableEvent* event) { | 180 static void SignalEvent(base::WaitableEvent* event) { |
176 event->Signal(); | 181 event->Signal(); |
177 } | 182 } |
178 | 183 |
179 static void DoNothing() { } | 184 static void DoNothing() { } |
180 | 185 |
181 void SyncWithJingleThread() { | 186 void SyncWithJingleThread() { |
182 base::WaitableEvent event(true, false); | 187 base::WaitableEvent event(true, false); |
183 thread_.message_loop()->PostTask( | 188 thread_.message_loop()->PostTask( |
184 FROM_HERE, NewRunnableFunction(&SignalEvent, &event)); | 189 FROM_HERE, NewRunnableFunction(&SignalEvent, &event)); |
185 event.Wait(); | 190 event.Wait(); |
186 } | 191 } |
187 | 192 |
188 JingleThread thread_; | 193 JingleThread thread_; |
189 scoped_refptr<SessionManagerPair> session_manager_pair_; | 194 scoped_refptr<SessionManagerPair> session_manager_pair_; |
190 scoped_refptr<JingleChromotocolServer> host_server_; | 195 scoped_refptr<JingleSessionManager> host_server_; |
191 MockServerCallback host_server_callback_; | 196 MockSessionManagerCallback host_server_callback_; |
192 scoped_refptr<JingleChromotocolServer> client_server_; | 197 scoped_refptr<JingleSessionManager> client_server_; |
193 MockServerCallback client_server_callback_; | 198 MockSessionManagerCallback client_server_callback_; |
194 | 199 |
195 scoped_refptr<ChromotocolConnection> host_connection_; | 200 scoped_refptr<Session> host_session_; |
196 MockConnectionCallback host_connection_callback_; | 201 MockSessionCallback host_connection_callback_; |
197 scoped_refptr<ChromotocolConnection> client_connection_; | 202 scoped_refptr<Session> client_session_; |
198 MockConnectionCallback client_connection_callback_; | 203 MockSessionCallback client_connection_callback_; |
199 }; | 204 }; |
200 | 205 |
201 class ChannelTesterBase : public base::RefCountedThreadSafe<ChannelTesterBase> { | 206 class ChannelTesterBase : public base::RefCountedThreadSafe<ChannelTesterBase> { |
202 public: | 207 public: |
203 enum ChannelType { | 208 enum ChannelType { |
204 CONTROL, | 209 CONTROL, |
205 EVENT, | 210 EVENT, |
206 VIDEO, | 211 VIDEO, |
207 VIDEO_RTP, | 212 VIDEO_RTP, |
208 VIDEO_RTCP, | 213 VIDEO_RTCP, |
209 }; | 214 }; |
210 | 215 |
211 ChannelTesterBase(MessageLoop* message_loop, | 216 ChannelTesterBase(MessageLoop* message_loop, |
212 ChromotocolConnection* host_connection, | 217 Session* host_session, |
213 ChromotocolConnection* client_connection) | 218 Session* client_session) |
214 : message_loop_(message_loop), | 219 : message_loop_(message_loop), |
215 host_connection_(host_connection), | 220 host_session_(host_session), |
216 client_connection_(client_connection), | 221 client_session_(client_session), |
217 done_event_(true, false) { | 222 done_event_(true, false) { |
218 } | 223 } |
219 | 224 |
220 virtual ~ChannelTesterBase() { } | 225 virtual ~ChannelTesterBase() { } |
221 | 226 |
222 void Start(ChannelType channel) { | 227 void Start(ChannelType channel) { |
223 message_loop_->PostTask( | 228 message_loop_->PostTask( |
224 FROM_HERE, NewRunnableMethod(this, &ChannelTesterBase::DoStart, | 229 FROM_HERE, NewRunnableMethod(this, &ChannelTesterBase::DoStart, |
225 channel)); | 230 channel)); |
226 } | 231 } |
227 | 232 |
228 bool WaitFinished() { | 233 bool WaitFinished() { |
229 return done_event_.TimedWait(base::TimeDelta::FromMilliseconds( | 234 return done_event_.TimedWait(base::TimeDelta::FromMilliseconds( |
230 TestTimeouts::action_max_timeout_ms())); | 235 TestTimeouts::action_max_timeout_ms())); |
231 } | 236 } |
232 | 237 |
233 virtual void CheckResults() = 0; | 238 virtual void CheckResults() = 0; |
234 | 239 |
235 protected: | 240 protected: |
236 void DoStart(ChannelType channel) { | 241 void DoStart(ChannelType channel) { |
237 socket_1_ = SelectChannel(host_connection_, channel); | 242 socket_1_ = SelectChannel(host_session_, channel); |
238 socket_2_ = SelectChannel(client_connection_, channel); | 243 socket_2_ = SelectChannel(client_session_, channel); |
239 | 244 |
240 InitBuffers(); | 245 InitBuffers(); |
241 DoRead(); | 246 DoRead(); |
242 DoWrite(); | 247 DoWrite(); |
243 } | 248 } |
244 | 249 |
245 virtual void InitBuffers() = 0; | 250 virtual void InitBuffers() = 0; |
246 virtual void DoWrite() = 0; | 251 virtual void DoWrite() = 0; |
247 virtual void DoRead() = 0; | 252 virtual void DoRead() = 0; |
248 | 253 |
249 net::Socket* SelectChannel(ChromotocolConnection* connection, | 254 net::Socket* SelectChannel(Session* session, |
250 ChannelType channel) { | 255 ChannelType channel) { |
251 switch (channel) { | 256 switch (channel) { |
252 case CONTROL: | 257 case CONTROL: |
253 return connection->control_channel(); | 258 return session->control_channel(); |
254 case EVENT: | 259 case EVENT: |
255 return connection->event_channel(); | 260 return session->event_channel(); |
256 case VIDEO: | 261 case VIDEO: |
257 return connection->video_channel(); | 262 return session->video_channel(); |
258 case VIDEO_RTP: | 263 case VIDEO_RTP: |
259 return connection->video_rtp_channel(); | 264 return session->video_rtp_channel(); |
260 case VIDEO_RTCP: | 265 case VIDEO_RTCP: |
261 return connection->video_rtcp_channel(); | 266 return session->video_rtcp_channel(); |
262 default: | 267 default: |
263 NOTREACHED(); | 268 NOTREACHED(); |
264 return NULL; | 269 return NULL; |
265 } | 270 } |
266 } | 271 } |
267 | 272 |
268 MessageLoop* message_loop_; | 273 MessageLoop* message_loop_; |
269 scoped_refptr<ChromotocolConnection> host_connection_; | 274 scoped_refptr<Session> host_session_; |
270 scoped_refptr<ChromotocolConnection> client_connection_; | 275 scoped_refptr<Session> client_session_; |
271 net::Socket* socket_1_; | 276 net::Socket* socket_1_; |
272 net::Socket* socket_2_; | 277 net::Socket* socket_2_; |
273 base::WaitableEvent done_event_; | 278 base::WaitableEvent done_event_; |
274 }; | 279 }; |
275 | 280 |
276 class TCPChannelTester : public ChannelTesterBase { | 281 class TCPChannelTester : public ChannelTesterBase { |
277 public: | 282 public: |
278 TCPChannelTester(MessageLoop* message_loop, | 283 TCPChannelTester(MessageLoop* message_loop, |
279 ChromotocolConnection* host_connection, | 284 Session* host_session, |
280 ChromotocolConnection* client_connection) | 285 Session* client_session) |
281 : ChannelTesterBase(message_loop, host_connection, client_connection), | 286 : ChannelTesterBase(message_loop, host_session, client_session), |
282 ALLOW_THIS_IN_INITIALIZER_LIST( | 287 ALLOW_THIS_IN_INITIALIZER_LIST( |
283 write_cb_(this, &TCPChannelTester::OnWritten)), | 288 write_cb_(this, &TCPChannelTester::OnWritten)), |
284 ALLOW_THIS_IN_INITIALIZER_LIST( | 289 ALLOW_THIS_IN_INITIALIZER_LIST( |
285 read_cb_(this, &TCPChannelTester::OnRead)), | 290 read_cb_(this, &TCPChannelTester::OnRead)), |
286 write_errors_(0), | 291 write_errors_(0), |
287 read_errors_(0) { | 292 read_errors_(0) { |
288 } | 293 } |
289 | 294 |
290 virtual ~TCPChannelTester() { } | 295 virtual ~TCPChannelTester() { } |
291 | 296 |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 383 |
379 net::CompletionCallbackImpl<TCPChannelTester> write_cb_; | 384 net::CompletionCallbackImpl<TCPChannelTester> write_cb_; |
380 net::CompletionCallbackImpl<TCPChannelTester> read_cb_; | 385 net::CompletionCallbackImpl<TCPChannelTester> read_cb_; |
381 int write_errors_; | 386 int write_errors_; |
382 int read_errors_; | 387 int read_errors_; |
383 }; | 388 }; |
384 | 389 |
385 class UDPChannelTester : public ChannelTesterBase { | 390 class UDPChannelTester : public ChannelTesterBase { |
386 public: | 391 public: |
387 UDPChannelTester(MessageLoop* message_loop, | 392 UDPChannelTester(MessageLoop* message_loop, |
388 ChromotocolConnection* host_connection, | 393 Session* host_session, |
389 ChromotocolConnection* client_connection) | 394 Session* client_session) |
390 : ChannelTesterBase(message_loop, host_connection, client_connection), | 395 : ChannelTesterBase(message_loop, host_session, client_session), |
391 ALLOW_THIS_IN_INITIALIZER_LIST( | 396 ALLOW_THIS_IN_INITIALIZER_LIST( |
392 write_cb_(this, &UDPChannelTester::OnWritten)), | 397 write_cb_(this, &UDPChannelTester::OnWritten)), |
393 ALLOW_THIS_IN_INITIALIZER_LIST( | 398 ALLOW_THIS_IN_INITIALIZER_LIST( |
394 read_cb_(this, &UDPChannelTester::OnRead)), | 399 read_cb_(this, &UDPChannelTester::OnRead)), |
395 write_errors_(0), | 400 write_errors_(0), |
396 read_errors_(0), | 401 read_errors_(0), |
397 packets_sent_(0), | 402 packets_sent_(0), |
398 packets_received_(0), | 403 packets_received_(0), |
399 broken_packets_(0) { | 404 broken_packets_(0) { |
400 } | 405 } |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
502 net::CompletionCallbackImpl<UDPChannelTester> write_cb_; | 507 net::CompletionCallbackImpl<UDPChannelTester> write_cb_; |
503 net::CompletionCallbackImpl<UDPChannelTester> read_cb_; | 508 net::CompletionCallbackImpl<UDPChannelTester> read_cb_; |
504 int write_errors_; | 509 int write_errors_; |
505 int read_errors_; | 510 int read_errors_; |
506 int packets_sent_; | 511 int packets_sent_; |
507 int packets_received_; | 512 int packets_received_; |
508 int broken_packets_; | 513 int broken_packets_; |
509 }; | 514 }; |
510 | 515 |
511 // Verify that we can create and destory server objects without a connection. | 516 // Verify that we can create and destory server objects without a connection. |
512 TEST_F(JingleChromotocolConnectionTest, CreateAndDestoy) { | 517 TEST_F(JingleSessionTest, CreateAndDestoy) { |
513 CreateServerPair(); | 518 CreateServerPair(); |
514 } | 519 } |
515 | 520 |
516 // Verify that incoming connection can be rejected, and that the status | 521 // Verify that incoming session can be rejected, and that the status |
517 // of the connection is set to CLOSED in this case. | 522 // of the connection is set to CLOSED in this case. |
518 TEST_F(JingleChromotocolConnectionTest, RejectConnection) { | 523 TEST_F(JingleSessionTest, RejectConnection) { |
519 CreateServerPair(); | 524 CreateServerPair(); |
520 | 525 |
521 // Reject incoming connection. | 526 // Reject incoming session. |
522 EXPECT_CALL(host_server_callback_, OnIncomingConnection(_, _)) | 527 EXPECT_CALL(host_server_callback_, OnIncomingSession(_, _)) |
523 .WillOnce(SetArgumentPointee<1>(ChromotocolServer::DECLINE)); | 528 .WillOnce(SetArgumentPointee<1>(protocol::SessionManager::DECLINE)); |
524 | 529 |
525 base::WaitableEvent done_event(false, false); | 530 base::WaitableEvent done_event(false, false); |
526 EXPECT_CALL(client_connection_callback_, | 531 EXPECT_CALL(client_connection_callback_, |
527 OnStateChange(ChromotocolConnection::CONNECTING)) | 532 OnStateChange(Session::CONNECTING)) |
528 .Times(1); | 533 .Times(1); |
529 EXPECT_CALL(client_connection_callback_, | 534 EXPECT_CALL(client_connection_callback_, |
530 OnStateChange(ChromotocolConnection::CLOSED)) | 535 OnStateChange(Session::CLOSED)) |
531 .Times(1) | 536 .Times(1) |
532 .WillOnce(InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)); | 537 .WillOnce(InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)); |
533 | 538 |
534 client_connection_ = client_server_->Connect( | 539 client_session_ = client_server_->Connect( |
535 SessionManagerPair::kHostJid, | 540 SessionManagerPair::kHostJid, |
536 CandidateChromotocolConfig::CreateDefault(), | 541 CandidateChromotocolConfig::CreateDefault(), |
537 NewCallback(&client_connection_callback_, | 542 NewCallback(&client_connection_callback_, |
538 &MockConnectionCallback::OnStateChange)); | 543 &MockSessionCallback::OnStateChange)); |
539 | 544 |
540 ASSERT_TRUE( | 545 ASSERT_TRUE( |
541 done_event.TimedWait(base::TimeDelta::FromMilliseconds( | 546 done_event.TimedWait(base::TimeDelta::FromMilliseconds( |
542 TestTimeouts::action_max_timeout_ms()))); | 547 TestTimeouts::action_max_timeout_ms()))); |
543 } | 548 } |
544 | 549 |
545 // Verify that we can connect two endpoints. | 550 // Verify that we can connect two endpoints. |
546 TEST_F(JingleChromotocolConnectionTest, Connect) { | 551 TEST_F(JingleSessionTest, Connect) { |
547 CreateServerPair(); | 552 CreateServerPair(); |
548 ASSERT_TRUE(InitiateConnection()); | 553 ASSERT_TRUE(InitiateConnection()); |
549 } | 554 } |
550 | 555 |
551 // Verify that data can be transmitted over the event channel. | 556 // Verify that data can be transmitted over the event channel. |
552 TEST_F(JingleChromotocolConnectionTest, TestControlChannel) { | 557 TEST_F(JingleSessionTest, TestControlChannel) { |
553 CreateServerPair(); | 558 CreateServerPair(); |
554 ASSERT_TRUE(InitiateConnection()); | 559 ASSERT_TRUE(InitiateConnection()); |
555 scoped_refptr<TCPChannelTester> tester( | 560 scoped_refptr<TCPChannelTester> tester( |
556 new TCPChannelTester(thread_.message_loop(), host_connection_, | 561 new TCPChannelTester(thread_.message_loop(), host_session_, |
557 client_connection_)); | 562 client_session_)); |
558 tester->Start(ChannelTesterBase::CONTROL); | 563 tester->Start(ChannelTesterBase::CONTROL); |
559 ASSERT_TRUE(tester->WaitFinished()); | 564 ASSERT_TRUE(tester->WaitFinished()); |
560 tester->CheckResults(); | 565 tester->CheckResults(); |
561 | 566 |
562 // Connections must be closed while |tester| still exists. | 567 // Connections must be closed while |tester| still exists. |
563 CloseConnections(); | 568 CloseSessions(); |
564 } | 569 } |
565 | 570 |
566 | 571 |
567 // Verify that data can be transmitted over the video channel. | 572 // Verify that data can be transmitted over the video channel. |
568 TEST_F(JingleChromotocolConnectionTest, TestVideoChannel) { | 573 TEST_F(JingleSessionTest, TestVideoChannel) { |
569 CreateServerPair(); | 574 CreateServerPair(); |
570 ASSERT_TRUE(InitiateConnection()); | 575 ASSERT_TRUE(InitiateConnection()); |
571 scoped_refptr<TCPChannelTester> tester( | 576 scoped_refptr<TCPChannelTester> tester( |
572 new TCPChannelTester(thread_.message_loop(), host_connection_, | 577 new TCPChannelTester(thread_.message_loop(), host_session_, |
573 client_connection_)); | 578 client_session_)); |
574 tester->Start(ChannelTesterBase::VIDEO); | 579 tester->Start(ChannelTesterBase::VIDEO); |
575 ASSERT_TRUE(tester->WaitFinished()); | 580 ASSERT_TRUE(tester->WaitFinished()); |
576 tester->CheckResults(); | 581 tester->CheckResults(); |
577 | 582 |
578 // Connections must be closed while |tester| still exists. | 583 // Connections must be closed while |tester| still exists. |
579 CloseConnections(); | 584 CloseSessions(); |
580 } | 585 } |
581 | 586 |
582 // Verify that data can be transmitted over the event channel. | 587 // Verify that data can be transmitted over the event channel. |
583 TEST_F(JingleChromotocolConnectionTest, TestEventChannel) { | 588 TEST_F(JingleSessionTest, TestEventChannel) { |
584 CreateServerPair(); | 589 CreateServerPair(); |
585 ASSERT_TRUE(InitiateConnection()); | 590 ASSERT_TRUE(InitiateConnection()); |
586 scoped_refptr<TCPChannelTester> tester( | 591 scoped_refptr<TCPChannelTester> tester( |
587 new TCPChannelTester(thread_.message_loop(), host_connection_, | 592 new TCPChannelTester(thread_.message_loop(), host_session_, |
588 client_connection_)); | 593 client_session_)); |
589 tester->Start(ChannelTesterBase::EVENT); | 594 tester->Start(ChannelTesterBase::EVENT); |
590 ASSERT_TRUE(tester->WaitFinished()); | 595 ASSERT_TRUE(tester->WaitFinished()); |
591 tester->CheckResults(); | 596 tester->CheckResults(); |
592 | 597 |
593 // Connections must be closed while |tester| still exists. | 598 // Connections must be closed while |tester| still exists. |
594 CloseConnections(); | 599 CloseSessions(); |
595 } | 600 } |
596 | 601 |
597 // Verify that data can be transmitted over the video RTP channel. | 602 // Verify that data can be transmitted over the video RTP channel. |
598 TEST_F(JingleChromotocolConnectionTest, TestVideoRtpChannel) { | 603 TEST_F(JingleSessionTest, TestVideoRtpChannel) { |
599 CreateServerPair(); | 604 CreateServerPair(); |
600 ASSERT_TRUE(InitiateConnection()); | 605 ASSERT_TRUE(InitiateConnection()); |
601 scoped_refptr<UDPChannelTester> tester( | 606 scoped_refptr<UDPChannelTester> tester( |
602 new UDPChannelTester(thread_.message_loop(), host_connection_, | 607 new UDPChannelTester(thread_.message_loop(), host_session_, |
603 client_connection_)); | 608 client_session_)); |
604 tester->Start(ChannelTesterBase::VIDEO_RTP); | 609 tester->Start(ChannelTesterBase::VIDEO_RTP); |
605 ASSERT_TRUE(tester->WaitFinished()); | 610 ASSERT_TRUE(tester->WaitFinished()); |
606 tester->CheckResults(); | 611 tester->CheckResults(); |
607 | 612 |
608 // Connections must be closed while |tester| still exists. | 613 // Connections must be closed while |tester| still exists. |
609 CloseConnections(); | 614 CloseSessions(); |
610 } | 615 } |
611 | 616 |
| 617 } // namespace protocol |
| 618 |
612 } // namespace remoting | 619 } // namespace remoting |
OLD | NEW |