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

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

Issue 10823323: Add support for multiplexed channels in remoting::protocol::Session interface. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/jingle_session.cc ('k') | remoting/protocol/protobuf_video_reader.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/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.h" 8 #include "base/message_loop.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "base/test/test_timeouts.h" 10 #include "base/test/test_timeouts.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
221 221
222 client_session_ = client_server_->Connect( 222 client_session_ = client_server_->Connect(
223 kHostJid, authenticator.Pass(), 223 kHostJid, authenticator.Pass(),
224 CandidateSessionConfig::CreateDefault()); 224 CandidateSessionConfig::CreateDefault());
225 client_session_->SetEventHandler(&client_session_event_handler_); 225 client_session_->SetEventHandler(&client_session_event_handler_);
226 226
227 message_loop_->RunAllPending(); 227 message_loop_->RunAllPending();
228 } 228 }
229 229
230 void CreateChannel() { 230 void CreateChannel() {
231 client_session_->CreateStreamChannel(kChannelName, base::Bind( 231 client_session_->GetTransportChannelFactory()->CreateStreamChannel(
232 &JingleSessionTest::OnClientChannelCreated, base::Unretained(this))); 232 kChannelName, base::Bind(&JingleSessionTest::OnClientChannelCreated,
233 host_session_->CreateStreamChannel(kChannelName, base::Bind( 233 base::Unretained(this)));
234 &JingleSessionTest::OnHostChannelCreated, base::Unretained(this))); 234 host_session_->GetTransportChannelFactory()->CreateStreamChannel(
235 kChannelName, base::Bind(&JingleSessionTest::OnHostChannelCreated,
236 base::Unretained(this)));
235 237
236 int counter = 2; 238 int counter = 2;
237 ExpectRouteChange(); 239 ExpectRouteChange(kChannelName);
238 EXPECT_CALL(client_channel_callback_, OnDone(_)) 240 EXPECT_CALL(client_channel_callback_, OnDone(_))
239 .WillOnce(QuitThreadOnCounter(&counter)); 241 .WillOnce(QuitThreadOnCounter(&counter));
240 EXPECT_CALL(host_channel_callback_, OnDone(_)) 242 EXPECT_CALL(host_channel_callback_, OnDone(_))
241 .WillOnce(QuitThreadOnCounter(&counter)); 243 .WillOnce(QuitThreadOnCounter(&counter));
242 message_loop_->Run(); 244 message_loop_->Run();
243 245
244 EXPECT_TRUE(client_socket_.get()); 246 EXPECT_TRUE(client_socket_.get());
245 EXPECT_TRUE(host_socket_.get()); 247 EXPECT_TRUE(host_socket_.get());
246 } 248 }
247 249
248 void ExpectRouteChange() { 250 void ExpectRouteChange(const std::string& channel_name) {
249 EXPECT_CALL(host_session_event_handler_, 251 EXPECT_CALL(host_session_event_handler_,
250 OnSessionRouteChange(kChannelName, _)) 252 OnSessionRouteChange(channel_name, _))
251 .Times(AtLeast(1)); 253 .Times(AtLeast(1));
252 EXPECT_CALL(client_session_event_handler_, 254 EXPECT_CALL(client_session_event_handler_,
253 OnSessionRouteChange(kChannelName, _)) 255 OnSessionRouteChange(channel_name, _))
254 .Times(AtLeast(1)); 256 .Times(AtLeast(1));
255 } 257 }
256 258
257 scoped_ptr<MessageLoopForIO> message_loop_; 259 scoped_ptr<MessageLoopForIO> message_loop_;
258 260
259 scoped_ptr<FakeSignalStrategy> host_signal_strategy_; 261 scoped_ptr<FakeSignalStrategy> host_signal_strategy_;
260 scoped_ptr<FakeSignalStrategy> client_signal_strategy_; 262 scoped_ptr<FakeSignalStrategy> client_signal_strategy_;
261 263
262 scoped_ptr<JingleSessionManager> host_server_; 264 scoped_ptr<JingleSessionManager> host_server_;
263 MockSessionManagerListener host_server_listener_; 265 MockSessionManagerListener host_server_listener_;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 352
351 ASSERT_NO_FATAL_FAILURE(CreateChannel()); 353 ASSERT_NO_FATAL_FAILURE(CreateChannel());
352 354
353 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), 355 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
354 kMessageSize, kMessages); 356 kMessageSize, kMessages);
355 tester.Start(); 357 tester.Start();
356 message_loop_->Run(); 358 message_loop_->Run();
357 tester.CheckResults(); 359 tester.CheckResults();
358 } 360 }
359 361
362 // Verify that data can be sent over a multiplexed channel.
363 TEST_F(JingleSessionTest, TestMuxStreamChannel) {
364 CreateSessionManagers(1, FakeAuthenticator::ACCEPT);
365 ASSERT_NO_FATAL_FAILURE(
366 InitiateConnection(1, FakeAuthenticator::ACCEPT, false));
367
368 client_session_->GetMultiplexedChannelFactory()->CreateStreamChannel(
369 kChannelName, base::Bind(&JingleSessionTest::OnClientChannelCreated,
370 base::Unretained(this)));
371 host_session_->GetMultiplexedChannelFactory()->CreateStreamChannel(
372 kChannelName, base::Bind(&JingleSessionTest::OnHostChannelCreated,
373 base::Unretained(this)));
374
375 int counter = 2;
376 ExpectRouteChange("mux");
377 EXPECT_CALL(client_channel_callback_, OnDone(_))
378 .WillOnce(QuitThreadOnCounter(&counter));
379 EXPECT_CALL(host_channel_callback_, OnDone(_))
380 .WillOnce(QuitThreadOnCounter(&counter));
381 message_loop_->Run();
382
383 EXPECT_TRUE(client_socket_.get());
384 EXPECT_TRUE(host_socket_.get());
385
386 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
387 kMessageSize, kMessages);
388 tester.Start();
389 message_loop_->Run();
390 tester.CheckResults();
391 }
392
360 // Verify that we can connect channels with multistep auth. 393 // Verify that we can connect channels with multistep auth.
361 TEST_F(JingleSessionTest, TestMultistepAuthStreamChannel) { 394 TEST_F(JingleSessionTest, TestMultistepAuthStreamChannel) {
362 CreateSessionManagers(3, FakeAuthenticator::ACCEPT); 395 CreateSessionManagers(3, FakeAuthenticator::ACCEPT);
363 ASSERT_NO_FATAL_FAILURE( 396 ASSERT_NO_FATAL_FAILURE(
364 InitiateConnection(3, FakeAuthenticator::ACCEPT, false)); 397 InitiateConnection(3, FakeAuthenticator::ACCEPT, false));
365 398
366 ASSERT_NO_FATAL_FAILURE(CreateChannel()); 399 ASSERT_NO_FATAL_FAILURE(CreateChannel());
367 400
368 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(), 401 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
369 kMessageSize, kMessages); 402 kMessageSize, kMessages);
370 tester.Start(); 403 tester.Start();
371 message_loop_->Run(); 404 message_loop_->Run();
372 tester.CheckResults(); 405 tester.CheckResults();
373 } 406 }
374 407
375 // Verify that we shutdown properly when channel authentication fails. 408 // Verify that we shutdown properly when channel authentication fails.
376 TEST_F(JingleSessionTest, TestFailedChannelAuth) { 409 TEST_F(JingleSessionTest, TestFailedChannelAuth) {
377 CreateSessionManagers(1, FakeAuthenticator::REJECT_CHANNEL); 410 CreateSessionManagers(1, FakeAuthenticator::REJECT_CHANNEL);
378 ASSERT_NO_FATAL_FAILURE( 411 ASSERT_NO_FATAL_FAILURE(
379 InitiateConnection(1, FakeAuthenticator::ACCEPT, false)); 412 InitiateConnection(1, FakeAuthenticator::ACCEPT, false));
380 413
381 client_session_->CreateStreamChannel(kChannelName, base::Bind( 414 client_session_->GetTransportChannelFactory()->CreateStreamChannel(
382 &JingleSessionTest::OnClientChannelCreated, base::Unretained(this))); 415 kChannelName, base::Bind(&JingleSessionTest::OnClientChannelCreated,
383 host_session_->CreateStreamChannel(kChannelName, base::Bind( 416 base::Unretained(this)));
384 &JingleSessionTest::OnHostChannelCreated, base::Unretained(this))); 417 host_session_->GetTransportChannelFactory()->CreateStreamChannel(
418 kChannelName, base::Bind(&JingleSessionTest::OnHostChannelCreated,
419 base::Unretained(this)));
385 420
386 // Terminate the message loop when we get rejection notification 421 // Terminate the message loop when we get rejection notification
387 // from the host. 422 // from the host.
388 EXPECT_CALL(host_channel_callback_, OnDone(NULL)) 423 EXPECT_CALL(host_channel_callback_, OnDone(NULL))
389 .WillOnce(QuitThread()); 424 .WillOnce(QuitThread());
390 EXPECT_CALL(client_channel_callback_, OnDone(_)) 425 EXPECT_CALL(client_channel_callback_, OnDone(_))
391 .Times(AtMost(1)); 426 .Times(AtMost(1));
392 ExpectRouteChange(); 427 ExpectRouteChange(kChannelName);
393 428
394 message_loop_->Run(); 429 message_loop_->Run();
395 430
396 EXPECT_TRUE(!host_socket_.get()); 431 EXPECT_TRUE(!host_socket_.get());
397 } 432 }
398 433
399 } // namespace protocol 434 } // namespace protocol
400 } // namespace remoting 435 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/jingle_session.cc ('k') | remoting/protocol/protobuf_video_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698