MD Downloads: prevent search text from overlapping with the cancel search (X)
[chromium-blink-merge.git] / remoting / protocol / jingle_session_unittest.cc
blob54702e89d376a514088061ce77f7416b13845b11
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
3 // found in the LICENSE file.
5 #include "remoting/protocol/jingle_session.h"
7 #include "base/bind.h"
8 #include "base/message_loop/message_loop.h"
9 #include "base/run_loop.h"
10 #include "base/test/test_timeouts.h"
11 #include "base/time/time.h"
12 #include "jingle/glue/thread_wrapper.h"
13 #include "net/socket/socket.h"
14 #include "net/socket/stream_socket.h"
15 #include "net/url_request/url_request_context_getter.h"
16 #include "remoting/base/constants.h"
17 #include "remoting/protocol/authenticator.h"
18 #include "remoting/protocol/channel_authenticator.h"
19 #include "remoting/protocol/chromium_port_allocator.h"
20 #include "remoting/protocol/connection_tester.h"
21 #include "remoting/protocol/fake_authenticator.h"
22 #include "remoting/protocol/jingle_session_manager.h"
23 #include "remoting/protocol/libjingle_transport_factory.h"
24 #include "remoting/protocol/network_settings.h"
25 #include "remoting/protocol/p2p_stream_socket.h"
26 #include "remoting/protocol/stream_channel_factory.h"
27 #include "remoting/signaling/fake_signal_strategy.h"
28 #include "testing/gmock/include/gmock/gmock.h"
29 #include "testing/gtest/include/gtest/gtest.h"
31 using testing::_;
32 using testing::AtLeast;
33 using testing::AtMost;
34 using testing::DeleteArg;
35 using testing::DoAll;
36 using testing::InSequence;
37 using testing::Invoke;
38 using testing::InvokeWithoutArgs;
39 using testing::Return;
40 using testing::SaveArg;
41 using testing::SetArgumentPointee;
42 using testing::WithArg;
44 namespace remoting {
45 namespace protocol {
47 namespace {
49 const char kHostJid[] = "host1@gmail.com/123";
50 const char kClientJid[] = "host2@gmail.com/321";
52 // Send 100 messages 1024 bytes each. UDP messages are sent with 10ms delay
53 // between messages (about 1 second for 100 messages).
54 const int kMessageSize = 1024;
55 const int kMessages = 100;
56 const char kChannelName[] = "test_channel";
58 void QuitCurrentThread() {
59 base::MessageLoop::current()->PostTask(FROM_HERE,
60 base::MessageLoop::QuitClosure());
63 ACTION(QuitThread) {
64 QuitCurrentThread();
67 ACTION_P(QuitThreadOnCounter, counter) {
68 --(*counter);
69 EXPECT_GE(*counter, 0);
70 if (*counter == 0)
71 QuitCurrentThread();
74 class MockSessionManagerListener : public SessionManager::Listener {
75 public:
76 MOCK_METHOD0(OnSessionManagerReady, void());
77 MOCK_METHOD2(OnIncomingSession,
78 void(Session*,
79 SessionManager::IncomingSessionResponse*));
82 class MockSessionEventHandler : public Session::EventHandler {
83 public:
84 MOCK_METHOD1(OnSessionStateChange, void(Session::State));
85 MOCK_METHOD2(OnSessionRouteChange, void(const std::string& channel_name,
86 const TransportRoute& route));
89 class MockChannelCreatedCallback {
90 public:
91 MOCK_METHOD1(OnDone, void(P2PStreamSocket* socket));
94 } // namespace
96 class JingleSessionTest : public testing::Test {
97 public:
98 JingleSessionTest() {
99 message_loop_.reset(new base::MessageLoopForIO());
100 jingle_glue::JingleThreadWrapper::EnsureForCurrentMessageLoop();
103 // Helper method that handles OnIncomingSession().
104 void SetHostSession(Session* session) {
105 DCHECK(session);
106 host_session_.reset(session);
107 host_session_->SetEventHandler(&host_session_event_handler_);
110 void DeleteSession() {
111 host_session_.reset();
114 void OnClientChannelCreated(scoped_ptr<P2PStreamSocket> socket) {
115 client_channel_callback_.OnDone(socket.get());
116 client_socket_ = socket.Pass();
119 void OnHostChannelCreated(scoped_ptr<P2PStreamSocket> socket) {
120 host_channel_callback_.OnDone(socket.get());
121 host_socket_ = socket.Pass();
124 protected:
125 void SetUp() override {}
127 void TearDown() override {
128 CloseSessions();
129 CloseSessionManager();
130 base::RunLoop().RunUntilIdle();
133 void CloseSessions() {
134 host_socket_.reset();
135 host_session_.reset();
136 client_socket_.reset();
137 client_session_.reset();
140 void CreateSessionManagers(int auth_round_trips, int messages_till_start,
141 FakeAuthenticator::Action auth_action) {
142 host_signal_strategy_.reset(new FakeSignalStrategy(kHostJid));
143 client_signal_strategy_.reset(new FakeSignalStrategy(kClientJid));
144 FakeSignalStrategy::Connect(host_signal_strategy_.get(),
145 client_signal_strategy_.get());
147 EXPECT_CALL(host_server_listener_, OnSessionManagerReady())
148 .Times(1);
150 NetworkSettings network_settings(NetworkSettings::NAT_TRAVERSAL_OUTGOING);
152 scoped_ptr<TransportFactory> host_transport(new LibjingleTransportFactory(
153 nullptr,
154 ChromiumPortAllocator::Create(nullptr, network_settings).Pass(),
155 network_settings, TransportRole::SERVER));
156 host_server_.reset(new JingleSessionManager(host_transport.Pass()));
157 host_server_->Init(host_signal_strategy_.get(), &host_server_listener_);
159 scoped_ptr<AuthenticatorFactory> factory(
160 new FakeHostAuthenticatorFactory(auth_round_trips,
161 messages_till_start, auth_action, true));
162 host_server_->set_authenticator_factory(factory.Pass());
164 EXPECT_CALL(client_server_listener_, OnSessionManagerReady())
165 .Times(1);
166 scoped_ptr<TransportFactory> client_transport(new LibjingleTransportFactory(
167 nullptr,
168 ChromiumPortAllocator::Create(nullptr, network_settings).Pass(),
169 network_settings, TransportRole::CLIENT));
170 client_server_.reset(
171 new JingleSessionManager(client_transport.Pass()));
172 client_server_->Init(client_signal_strategy_.get(),
173 &client_server_listener_);
176 void CreateSessionManagers(int auth_round_trips,
177 FakeAuthenticator::Action auth_action) {
178 CreateSessionManagers(auth_round_trips, 0, auth_action);
181 void CloseSessionManager() {
182 if (host_server_.get()) {
183 host_server_->Close();
184 host_server_.reset();
186 if (client_server_.get()) {
187 client_server_->Close();
188 client_server_.reset();
190 host_signal_strategy_.reset();
191 client_signal_strategy_.reset();
194 void InitiateConnection(int auth_round_trips,
195 FakeAuthenticator::Action auth_action,
196 bool expect_fail) {
197 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _))
198 .WillOnce(DoAll(
199 WithArg<0>(Invoke(this, &JingleSessionTest::SetHostSession)),
200 SetArgumentPointee<1>(protocol::SessionManager::ACCEPT)));
203 InSequence dummy;
205 EXPECT_CALL(host_session_event_handler_,
206 OnSessionStateChange(Session::CONNECTED))
207 .Times(AtMost(1));
208 EXPECT_CALL(host_session_event_handler_,
209 OnSessionStateChange(Session::AUTHENTICATING))
210 .Times(AtMost(1));
211 if (expect_fail) {
212 EXPECT_CALL(host_session_event_handler_,
213 OnSessionStateChange(Session::FAILED))
214 .Times(1);
215 } else {
216 EXPECT_CALL(host_session_event_handler_,
217 OnSessionStateChange(Session::AUTHENTICATED))
218 .Times(1);
219 // Expect that the connection will be closed eventually.
220 EXPECT_CALL(host_session_event_handler_,
221 OnSessionStateChange(Session::CLOSED))
222 .Times(AtMost(1));
227 InSequence dummy;
229 EXPECT_CALL(client_session_event_handler_,
230 OnSessionStateChange(Session::CONNECTED))
231 .Times(AtMost(1));
232 EXPECT_CALL(client_session_event_handler_,
233 OnSessionStateChange(Session::AUTHENTICATING))
234 .Times(AtMost(1));
235 if (expect_fail) {
236 EXPECT_CALL(client_session_event_handler_,
237 OnSessionStateChange(Session::FAILED))
238 .Times(1);
239 } else {
240 EXPECT_CALL(client_session_event_handler_,
241 OnSessionStateChange(Session::AUTHENTICATED))
242 .Times(1);
243 // Expect that the connection will be closed eventually.
244 EXPECT_CALL(client_session_event_handler_,
245 OnSessionStateChange(Session::CLOSED))
246 .Times(AtMost(1));
250 scoped_ptr<Authenticator> authenticator(new FakeAuthenticator(
251 FakeAuthenticator::CLIENT, auth_round_trips, auth_action, true));
253 client_session_ = client_server_->Connect(kHostJid, authenticator.Pass());
254 client_session_->SetEventHandler(&client_session_event_handler_);
256 base::RunLoop().RunUntilIdle();
259 void CreateChannel() {
260 client_session_->GetTransportChannelFactory()->CreateChannel(
261 kChannelName, base::Bind(&JingleSessionTest::OnClientChannelCreated,
262 base::Unretained(this)));
263 host_session_->GetTransportChannelFactory()->CreateChannel(
264 kChannelName, base::Bind(&JingleSessionTest::OnHostChannelCreated,
265 base::Unretained(this)));
267 int counter = 2;
268 ExpectRouteChange(kChannelName);
269 EXPECT_CALL(client_channel_callback_, OnDone(_))
270 .WillOnce(QuitThreadOnCounter(&counter));
271 EXPECT_CALL(host_channel_callback_, OnDone(_))
272 .WillOnce(QuitThreadOnCounter(&counter));
273 message_loop_->Run();
275 EXPECT_TRUE(client_socket_.get());
276 EXPECT_TRUE(host_socket_.get());
279 void ExpectRouteChange(const std::string& channel_name) {
280 EXPECT_CALL(host_session_event_handler_,
281 OnSessionRouteChange(channel_name, _))
282 .Times(AtLeast(1));
283 EXPECT_CALL(client_session_event_handler_,
284 OnSessionRouteChange(channel_name, _))
285 .Times(AtLeast(1));
288 scoped_ptr<base::MessageLoopForIO> message_loop_;
290 scoped_ptr<FakeSignalStrategy> host_signal_strategy_;
291 scoped_ptr<FakeSignalStrategy> client_signal_strategy_;
293 scoped_ptr<JingleSessionManager> host_server_;
294 MockSessionManagerListener host_server_listener_;
295 scoped_ptr<JingleSessionManager> client_server_;
296 MockSessionManagerListener client_server_listener_;
298 scoped_ptr<Session> host_session_;
299 MockSessionEventHandler host_session_event_handler_;
300 scoped_ptr<Session> client_session_;
301 MockSessionEventHandler client_session_event_handler_;
303 MockChannelCreatedCallback client_channel_callback_;
304 MockChannelCreatedCallback host_channel_callback_;
306 scoped_ptr<P2PStreamSocket> client_socket_;
307 scoped_ptr<P2PStreamSocket> host_socket_;
311 // Verify that we can create and destroy session managers without a
312 // connection.
313 TEST_F(JingleSessionTest, CreateAndDestoy) {
314 CreateSessionManagers(1, FakeAuthenticator::ACCEPT);
317 // Verify that an incoming session can be rejected, and that the
318 // status of the connection is set to FAILED in this case.
319 TEST_F(JingleSessionTest, RejectConnection) {
320 CreateSessionManagers(1, FakeAuthenticator::ACCEPT);
322 // Reject incoming session.
323 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _))
324 .WillOnce(SetArgumentPointee<1>(protocol::SessionManager::DECLINE));
327 InSequence dummy;
328 EXPECT_CALL(client_session_event_handler_,
329 OnSessionStateChange(Session::FAILED))
330 .Times(1);
333 scoped_ptr<Authenticator> authenticator(new FakeAuthenticator(
334 FakeAuthenticator::CLIENT, 1, FakeAuthenticator::ACCEPT, true));
335 client_session_ = client_server_->Connect(kHostJid, authenticator.Pass());
336 client_session_->SetEventHandler(&client_session_event_handler_);
338 base::RunLoop().RunUntilIdle();
341 // Verify that we can connect two endpoints with single-step authentication.
342 TEST_F(JingleSessionTest, Connect) {
343 CreateSessionManagers(1, FakeAuthenticator::ACCEPT);
344 InitiateConnection(1, FakeAuthenticator::ACCEPT, false);
346 // Verify that the client specified correct initiator value.
347 ASSERT_GT(host_signal_strategy_->received_messages().size(), 0U);
348 const buzz::XmlElement* initiate_xml =
349 host_signal_strategy_->received_messages().front();
350 const buzz::XmlElement* jingle_element =
351 initiate_xml->FirstNamed(buzz::QName("urn:xmpp:jingle:1", "jingle"));
352 ASSERT_TRUE(jingle_element);
353 ASSERT_EQ(kClientJid,
354 jingle_element->Attr(buzz::QName(std::string(), "initiator")));
357 // Verify that we can connect two endpoints with multi-step authentication.
358 TEST_F(JingleSessionTest, ConnectWithMultistep) {
359 CreateSessionManagers(3, FakeAuthenticator::ACCEPT);
360 InitiateConnection(3, FakeAuthenticator::ACCEPT, false);
363 // Verify that connection is terminated when single-step auth fails.
364 TEST_F(JingleSessionTest, ConnectWithBadAuth) {
365 CreateSessionManagers(1, FakeAuthenticator::REJECT);
366 InitiateConnection(1, FakeAuthenticator::ACCEPT, true);
369 // Verify that connection is terminated when multi-step auth fails.
370 TEST_F(JingleSessionTest, ConnectWithBadMultistepAuth) {
371 CreateSessionManagers(3, FakeAuthenticator::REJECT);
372 InitiateConnection(3, FakeAuthenticator::ACCEPT, true);
375 // Verify that data can be sent over stream channel.
376 TEST_F(JingleSessionTest, TestStreamChannel) {
377 CreateSessionManagers(1, FakeAuthenticator::ACCEPT);
378 ASSERT_NO_FATAL_FAILURE(
379 InitiateConnection(1, FakeAuthenticator::ACCEPT, false));
381 ASSERT_NO_FATAL_FAILURE(CreateChannel());
383 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
384 kMessageSize, kMessages);
385 tester.Start();
386 message_loop_->Run();
387 tester.CheckResults();
390 // Verify that incompatible protocol configuration is handled properly.
391 TEST_F(JingleSessionTest, TestIncompatibleProtocol) {
392 CreateSessionManagers(1, FakeAuthenticator::ACCEPT);
394 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _)).Times(0);
396 EXPECT_CALL(client_session_event_handler_,
397 OnSessionStateChange(Session::FAILED))
398 .Times(1);
400 scoped_ptr<Authenticator> authenticator(new FakeAuthenticator(
401 FakeAuthenticator::CLIENT, 1, FakeAuthenticator::ACCEPT, true));
403 scoped_ptr<CandidateSessionConfig> config =
404 CandidateSessionConfig::CreateDefault();
405 // Disable all video codecs so the host will reject connection.
406 config->mutable_video_configs()->clear();
407 client_server_->set_protocol_config(config.Pass());
408 client_session_ = client_server_->Connect(kHostJid, authenticator.Pass());
409 client_session_->SetEventHandler(&client_session_event_handler_);
411 base::RunLoop().RunUntilIdle();
413 EXPECT_EQ(INCOMPATIBLE_PROTOCOL, client_session_->error());
414 EXPECT_FALSE(host_session_);
417 // Verify that GICE-only client is rejected with an appropriate error code.
418 TEST_F(JingleSessionTest, TestLegacyIceConnection) {
419 CreateSessionManagers(1, FakeAuthenticator::ACCEPT);
421 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _)).Times(0);
423 EXPECT_CALL(client_session_event_handler_,
424 OnSessionStateChange(Session::FAILED))
425 .Times(1);
427 scoped_ptr<Authenticator> authenticator(new FakeAuthenticator(
428 FakeAuthenticator::CLIENT, 1, FakeAuthenticator::ACCEPT, true));
430 scoped_ptr<CandidateSessionConfig> config =
431 CandidateSessionConfig::CreateDefault();
432 config->set_standard_ice(false);
433 client_server_->set_protocol_config(config.Pass());
434 client_session_ = client_server_->Connect(kHostJid, authenticator.Pass());
435 client_session_->SetEventHandler(&client_session_event_handler_);
437 base::RunLoop().RunUntilIdle();
439 EXPECT_EQ(INCOMPATIBLE_PROTOCOL, client_session_->error());
440 EXPECT_FALSE(host_session_);
443 TEST_F(JingleSessionTest, DeleteSessionOnIncomingConnection) {
444 CreateSessionManagers(3, FakeAuthenticator::ACCEPT);
446 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _))
447 .WillOnce(DoAll(
448 WithArg<0>(Invoke(this, &JingleSessionTest::SetHostSession)),
449 SetArgumentPointee<1>(protocol::SessionManager::ACCEPT)));
451 EXPECT_CALL(host_session_event_handler_,
452 OnSessionStateChange(Session::CONNECTED))
453 .Times(AtMost(1));
455 EXPECT_CALL(host_session_event_handler_,
456 OnSessionStateChange(Session::AUTHENTICATING))
457 .WillOnce(InvokeWithoutArgs(this, &JingleSessionTest::DeleteSession));
459 scoped_ptr<Authenticator> authenticator(new FakeAuthenticator(
460 FakeAuthenticator::CLIENT, 3, FakeAuthenticator::ACCEPT, true));
462 client_session_ = client_server_->Connect(kHostJid, authenticator.Pass());
464 base::RunLoop().RunUntilIdle();
467 TEST_F(JingleSessionTest, DeleteSessionOnAuth) {
468 // Same as the previous test, but set messages_till_started to 2 in
469 // CreateSessionManagers so that the session will goes into the
470 // AUTHENTICATING state after two message exchanges.
471 CreateSessionManagers(3, 2, FakeAuthenticator::ACCEPT);
473 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _))
474 .WillOnce(DoAll(
475 WithArg<0>(Invoke(this, &JingleSessionTest::SetHostSession)),
476 SetArgumentPointee<1>(protocol::SessionManager::ACCEPT)));
478 EXPECT_CALL(host_session_event_handler_,
479 OnSessionStateChange(Session::CONNECTED))
480 .Times(AtMost(1));
482 EXPECT_CALL(host_session_event_handler_,
483 OnSessionStateChange(Session::AUTHENTICATING))
484 .WillOnce(InvokeWithoutArgs(this, &JingleSessionTest::DeleteSession));
486 scoped_ptr<Authenticator> authenticator(new FakeAuthenticator(
487 FakeAuthenticator::CLIENT, 3, FakeAuthenticator::ACCEPT, true));
489 client_session_ = client_server_->Connect(kHostJid, authenticator.Pass());
490 base::RunLoop().RunUntilIdle();
493 // Verify that data can be sent over a multiplexed channel.
494 TEST_F(JingleSessionTest, TestMuxStreamChannel) {
495 CreateSessionManagers(1, FakeAuthenticator::ACCEPT);
496 ASSERT_NO_FATAL_FAILURE(
497 InitiateConnection(1, FakeAuthenticator::ACCEPT, false));
499 client_session_->GetMultiplexedChannelFactory()->CreateChannel(
500 kChannelName, base::Bind(&JingleSessionTest::OnClientChannelCreated,
501 base::Unretained(this)));
502 host_session_->GetMultiplexedChannelFactory()->CreateChannel(
503 kChannelName, base::Bind(&JingleSessionTest::OnHostChannelCreated,
504 base::Unretained(this)));
506 int counter = 2;
507 ExpectRouteChange("mux");
508 EXPECT_CALL(client_channel_callback_, OnDone(_))
509 .WillOnce(QuitThreadOnCounter(&counter));
510 EXPECT_CALL(host_channel_callback_, OnDone(_))
511 .WillOnce(QuitThreadOnCounter(&counter));
512 message_loop_->Run();
514 EXPECT_TRUE(client_socket_.get());
515 EXPECT_TRUE(host_socket_.get());
517 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
518 kMessageSize, kMessages);
519 tester.Start();
520 message_loop_->Run();
521 tester.CheckResults();
524 // Verify that data can be sent over a QUIC channel.
525 TEST_F(JingleSessionTest, TestQuicStreamChannel) {
526 CreateSessionManagers(1, FakeAuthenticator::ACCEPT);
528 scoped_ptr<CandidateSessionConfig> config =
529 CandidateSessionConfig::CreateDefault();
530 config->PreferTransport(ChannelConfig::TRANSPORT_QUIC_STREAM);
531 client_server_->set_protocol_config(config.Pass());
533 ASSERT_NO_FATAL_FAILURE(
534 InitiateConnection(1, FakeAuthenticator::ACCEPT, false));
536 int counter = 2;
537 ExpectRouteChange(kQuicChannelName);
538 EXPECT_CALL(client_channel_callback_, OnDone(_))
539 .WillOnce(QuitThreadOnCounter(&counter));
540 EXPECT_CALL(host_channel_callback_, OnDone(_))
541 .WillOnce(QuitThreadOnCounter(&counter));
543 client_session_->GetQuicChannelFactory()->CreateChannel(
544 kChannelName, base::Bind(&JingleSessionTest::OnClientChannelCreated,
545 base::Unretained(this)));
546 host_session_->GetQuicChannelFactory()->CreateChannel(
547 kChannelName, base::Bind(&JingleSessionTest::OnHostChannelCreated,
548 base::Unretained(this)));
550 message_loop_->Run();
552 EXPECT_TRUE(client_socket_.get());
553 EXPECT_TRUE(host_socket_.get());
555 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
556 kMessageSize, kMessages);
557 tester.Start();
558 message_loop_->Run();
559 tester.CheckResults();
562 // Verify that we can connect channels with multistep auth.
563 TEST_F(JingleSessionTest, TestMultistepAuthStreamChannel) {
564 CreateSessionManagers(3, FakeAuthenticator::ACCEPT);
565 ASSERT_NO_FATAL_FAILURE(
566 InitiateConnection(3, FakeAuthenticator::ACCEPT, false));
568 ASSERT_NO_FATAL_FAILURE(CreateChannel());
570 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
571 kMessageSize, kMessages);
572 tester.Start();
573 message_loop_->Run();
574 tester.CheckResults();
577 // Verify that we shutdown properly when channel authentication fails.
578 TEST_F(JingleSessionTest, TestFailedChannelAuth) {
579 CreateSessionManagers(1, FakeAuthenticator::REJECT_CHANNEL);
580 ASSERT_NO_FATAL_FAILURE(
581 InitiateConnection(1, FakeAuthenticator::ACCEPT, false));
583 client_session_->GetTransportChannelFactory()->CreateChannel(
584 kChannelName, base::Bind(&JingleSessionTest::OnClientChannelCreated,
585 base::Unretained(this)));
586 host_session_->GetTransportChannelFactory()->CreateChannel(
587 kChannelName, base::Bind(&JingleSessionTest::OnHostChannelCreated,
588 base::Unretained(this)));
590 // Terminate the message loop when we get rejection notification
591 // from the host.
592 EXPECT_CALL(host_channel_callback_, OnDone(nullptr))
593 .WillOnce(QuitThread());
594 ExpectRouteChange(kChannelName);
596 message_loop_->Run();
598 client_session_->GetTransportChannelFactory()->CancelChannelCreation(
599 kChannelName);
601 EXPECT_TRUE(!host_socket_.get());
604 TEST_F(JingleSessionTest, TestCancelChannelCreation) {
605 CreateSessionManagers(1, FakeAuthenticator::REJECT_CHANNEL);
606 ASSERT_NO_FATAL_FAILURE(
607 InitiateConnection(1, FakeAuthenticator::ACCEPT, false));
609 client_session_->GetTransportChannelFactory()->CreateChannel(
610 kChannelName, base::Bind(&JingleSessionTest::OnClientChannelCreated,
611 base::Unretained(this)));
612 client_session_->GetTransportChannelFactory()->CancelChannelCreation(
613 kChannelName);
615 EXPECT_TRUE(!client_socket_.get());
618 // Verify that we can still connect even when there is a delay in signaling
619 // messages delivery.
620 TEST_F(JingleSessionTest, TestDelayedSignaling) {
621 CreateSessionManagers(1, FakeAuthenticator::ACCEPT);
622 ASSERT_NO_FATAL_FAILURE(
623 InitiateConnection(1, FakeAuthenticator::ACCEPT, false));
625 host_signal_strategy_->set_send_delay(
626 base::TimeDelta::FromMilliseconds(100));
628 ASSERT_NO_FATAL_FAILURE(CreateChannel());
630 StreamConnectionTester tester(host_socket_.get(), client_socket_.get(),
631 kMessageSize, 1);
632 tester.Start();
633 message_loop_->Run();
634 tester.CheckResults();
637 } // namespace protocol
638 } // namespace remoting