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

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

Issue 8619011: Use Authenticator interface in Session and SessionManager (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix unittests Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « remoting/protocol/jingle_session_manager.cc ('k') | remoting/protocol/pepper_session.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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/bind.h" 5 #include "base/bind.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/message_loop_proxy.h" 8 #include "base/message_loop_proxy.h"
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/time.h" 10 #include "base/time.h"
11 #include "base/test/test_timeouts.h" 11 #include "base/test/test_timeouts.h"
12 #include "crypto/nss_util.h" 12 #include "crypto/nss_util.h"
13 #include "crypto/rsa_private_key.h"
13 #include "net/base/completion_callback.h" 14 #include "net/base/completion_callback.h"
14 #include "net/base/io_buffer.h" 15 #include "net/base/io_buffer.h"
15 #include "net/base/net_errors.h" 16 #include "net/base/net_errors.h"
16 #include "net/socket/socket.h" 17 #include "net/socket/socket.h"
17 #include "net/socket/stream_socket.h" 18 #include "net/socket/stream_socket.h"
19 #include "remoting/base/constants.h"
18 #include "remoting/protocol/auth_util.h" 20 #include "remoting/protocol/auth_util.h"
21 #include "remoting/protocol/authenticator.h"
22 #include "remoting/protocol/channel_authenticator.h"
19 #include "remoting/protocol/jingle_session.h" 23 #include "remoting/protocol/jingle_session.h"
20 #include "remoting/protocol/jingle_session_manager.h" 24 #include "remoting/protocol/jingle_session_manager.h"
25 #include "remoting/protocol/v1_authenticator.h"
21 #include "remoting/jingle_glue/jingle_thread.h" 26 #include "remoting/jingle_glue/jingle_thread.h"
22 #include "remoting/jingle_glue/fake_signal_strategy.h" 27 #include "remoting/jingle_glue/fake_signal_strategy.h"
23 #include "testing/gmock/include/gmock/gmock.h" 28 #include "testing/gmock/include/gmock/gmock.h"
24 #include "testing/gtest/include/gtest/gtest.h" 29 #include "testing/gtest/include/gtest/gtest.h"
25 #include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h" 30 #include "third_party/libjingle/source/talk/p2p/client/basicportallocator.h"
26 31
27 using testing::_; 32 using testing::_;
28 using testing::AtMost; 33 using testing::AtMost;
29 using testing::DeleteArg; 34 using testing::DeleteArg;
30 using testing::DoAll; 35 using testing::DoAll;
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 MOCK_METHOD2(OnIncomingSession, 106 MOCK_METHOD2(OnIncomingSession,
102 void(Session*, 107 void(Session*,
103 SessionManager::IncomingSessionResponse*)); 108 SessionManager::IncomingSessionResponse*));
104 }; 109 };
105 110
106 class MockSessionCallback { 111 class MockSessionCallback {
107 public: 112 public:
108 MOCK_METHOD1(OnStateChange, void(Session::State)); 113 MOCK_METHOD1(OnStateChange, void(Session::State));
109 }; 114 };
110 115
116 class FakeChannelAuthenticator : public ChannelAuthenticator {
117 public:
118 FakeChannelAuthenticator(bool accept)
119 : accept_(accept) {
120 }
121 virtual ~FakeChannelAuthenticator() {}
122
123 virtual void SecureAndAuthenticate(
124 net::StreamSocket* socket, const DoneCallback& done_callback) OVERRIDE {
125 if (accept_) {
126 done_callback.Run(net::OK, socket);
127 } else {
128 delete socket;
129 done_callback.Run(net::ERR_FAILED, NULL);
130 }
131 }
132
133 private:
134 bool accept_;
135
136 DISALLOW_COPY_AND_ASSIGN(FakeChannelAuthenticator);
137 };
138
139 class FakeClientAuthenticator : public Authenticator {
140 public:
141 FakeClientAuthenticator(bool accept, bool accept_channel)
142 : accept_(accept),
143 accept_channel_(accept_channel),
144 state_(MESSAGE_READY) {
145 }
146 virtual ~FakeClientAuthenticator() {}
147
148 virtual State state() const OVERRIDE {
149 return state_;
150 }
151
152 virtual void ProcessMessage(const buzz::XmlElement* message) OVERRIDE {
153 EXPECT_EQ(WAITING_MESSAGE, state_);
154 state_ = accept_ ? ACCEPTED : REJECTED;
155 }
156
157 virtual buzz::XmlElement* GetNextMessage() OVERRIDE {
158 EXPECT_EQ(MESSAGE_READY, state_);
159 state_ = WAITING_MESSAGE;
160 return new buzz::XmlElement(
161 buzz::QName(kChromotingXmlNamespace, "authentication"));
162 }
163
164 virtual ChannelAuthenticator* CreateChannelAuthenticator() const OVERRIDE {
165 return new FakeChannelAuthenticator(accept_channel_);
166 }
167
168 protected:
169 bool accept_;
170 bool accept_channel_;
171 State state_;
172
173 DISALLOW_COPY_AND_ASSIGN(FakeClientAuthenticator);
174 };
175
176 class FakeHostAuthenticator : public Authenticator {
177 public:
178 FakeHostAuthenticator(bool accept, bool accept_channel)
179 : accept_(accept),
180 accept_channel_(accept_channel),
181 state_(WAITING_MESSAGE) {
182 }
183 virtual ~FakeHostAuthenticator() {}
184
185 virtual State state() const OVERRIDE {
186 return state_;
187 }
188
189 virtual void ProcessMessage(const buzz::XmlElement* message) OVERRIDE {
190 EXPECT_EQ(WAITING_MESSAGE, state_);
191 state_ = MESSAGE_READY;
192 }
193
194 virtual buzz::XmlElement* GetNextMessage() OVERRIDE {
195 EXPECT_EQ(MESSAGE_READY, state_);
196 state_ = accept_ ? ACCEPTED : REJECTED;
197 return new buzz::XmlElement(
198 buzz::QName(kChromotingXmlNamespace, "authentication"));
199 }
200
201 virtual ChannelAuthenticator* CreateChannelAuthenticator() const OVERRIDE {
202 return new FakeChannelAuthenticator(accept_channel_);
203 }
204
205 protected:
206 bool accept_;
207 bool accept_channel_;
208 State state_;
209
210 DISALLOW_COPY_AND_ASSIGN(FakeHostAuthenticator);
211 };
212
213 class FakeHostAuthenticatorFactory : public AuthenticatorFactory {
214 public:
215 FakeHostAuthenticatorFactory(bool accept, bool accept_channel)
216 : accept_(accept),
217 accept_channel_(accept_channel) {
218 }
219 virtual ~FakeHostAuthenticatorFactory() {}
220
221 virtual Authenticator* CreateAuthenticator(
222 const std::string& remote_jid,
223 const buzz::XmlElement* first_message) OVERRIDE {
224 return new FakeHostAuthenticator(accept_, accept_channel_);
225 }
226
227 private:
228 bool accept_;
229 bool accept_channel_;
230
231 DISALLOW_COPY_AND_ASSIGN(FakeHostAuthenticatorFactory);
232 };
233
111 } // namespace 234 } // namespace
112 235
113 class JingleSessionTest : public testing::Test { 236 class JingleSessionTest : public testing::Test {
114 public: 237 public:
115 JingleSessionTest() 238 JingleSessionTest()
116 : message_loop_(talk_base::Thread::Current()) { 239 : message_loop_(talk_base::Thread::Current()) {
117 } 240 }
118 241
119 // Helper method to copy to set value of client_connection_. 242 // Helper method to copy to set value of client_connection_.
120 void SetHostSession(Session* session) { 243 void SetHostSession(Session* session) {
121 DCHECK(session); 244 DCHECK(session);
122 host_session_.reset(session); 245 host_session_.reset(session);
123 host_session_->SetStateChangeCallback( 246 host_session_->SetStateChangeCallback(
124 base::Bind(&MockSessionCallback::OnStateChange, 247 base::Bind(&MockSessionCallback::OnStateChange,
125 base::Unretained(&host_connection_callback_))); 248 base::Unretained(&host_connection_callback_)));
126 249
127 session->set_config(SessionConfig::GetDefault()); 250 session->set_config(SessionConfig::GetDefault());
128 session->set_shared_secret(kTestSharedSecret);
129 } 251 }
130 252
131 protected: 253 protected:
132 virtual void SetUp() { 254 virtual void SetUp() {
133 } 255 }
134 256
135 virtual void TearDown() { 257 virtual void TearDown() {
136 CloseSessions(); 258 CloseSessions();
137 CloseSessionManager(); 259 CloseSessionManager();
138 } 260 }
139 261
140 void CloseSessions() { 262 void CloseSessions() {
141 if (host_session_.get()) { 263 if (host_session_.get()) {
142 host_session_->Close(); 264 host_session_->Close();
143 host_session_.reset(); 265 host_session_.reset();
144 } 266 }
145 if (client_session_.get()) { 267 if (client_session_.get()) {
146 client_session_->Close(); 268 client_session_->Close();
147 client_session_.reset(); 269 client_session_.reset();
148 } 270 }
149 } 271 }
150 272
151 void CreateServerPair() { 273 void CreateServerPair(bool use_fake_auth) {
152 FilePath certs_dir; 274 FilePath certs_dir;
153 PathService::Get(base::DIR_SOURCE_ROOT, &certs_dir); 275 PathService::Get(base::DIR_SOURCE_ROOT, &certs_dir);
154 certs_dir = certs_dir.AppendASCII("net"); 276 certs_dir = certs_dir.AppendASCII("net");
155 certs_dir = certs_dir.AppendASCII("data"); 277 certs_dir = certs_dir.AppendASCII("data");
156 certs_dir = certs_dir.AppendASCII("ssl"); 278 certs_dir = certs_dir.AppendASCII("ssl");
157 certs_dir = certs_dir.AppendASCII("certificates"); 279 certs_dir = certs_dir.AppendASCII("certificates");
158 280
159 FilePath cert_path = certs_dir.AppendASCII("unittest.selfsigned.der"); 281 FilePath cert_path = certs_dir.AppendASCII("unittest.selfsigned.der");
160 std::string cert_der; 282 std::string cert_der;
161 ASSERT_TRUE(file_util::ReadFileToString(cert_path, &cert_der)); 283 ASSERT_TRUE(file_util::ReadFileToString(cert_path, &cert_der));
(...skipping 11 matching lines...) Expand all
173 host_signal_strategy_.reset(new FakeSignalStrategy(kHostJid)); 295 host_signal_strategy_.reset(new FakeSignalStrategy(kHostJid));
174 client_signal_strategy_.reset(new FakeSignalStrategy(kClientJid)); 296 client_signal_strategy_.reset(new FakeSignalStrategy(kClientJid));
175 FakeSignalStrategy::Connect(host_signal_strategy_.get(), 297 FakeSignalStrategy::Connect(host_signal_strategy_.get(),
176 client_signal_strategy_.get()); 298 client_signal_strategy_.get());
177 299
178 EXPECT_CALL(host_server_listener_, OnSessionManagerInitialized()) 300 EXPECT_CALL(host_server_listener_, OnSessionManagerInitialized())
179 .Times(1); 301 .Times(1);
180 host_server_.reset(new JingleSessionManager( 302 host_server_.reset(new JingleSessionManager(
181 base::MessageLoopProxy::current())); 303 base::MessageLoopProxy::current()));
182 host_server_->Init( 304 host_server_->Init(
183 kHostJid, host_signal_strategy_.get(), &host_server_listener_, 305 kHostJid, host_signal_strategy_.get(), &host_server_listener_, false);
184 private_key.release(), cert_der, false); 306
307 if (use_fake_auth) {
308 host_server_->set_authenticator_factory(
309 new FakeHostAuthenticatorFactory(true, false));
310 } else {
311 host_server_->set_authenticator_factory(
312 new V1HostAuthenticatorFactory(
313 cert_der, private_key.release(), kTestSharedSecret));
314 }
185 315
186 EXPECT_CALL(client_server_listener_, OnSessionManagerInitialized()) 316 EXPECT_CALL(client_server_listener_, OnSessionManagerInitialized())
187 .Times(1); 317 .Times(1);
188 client_server_.reset(new JingleSessionManager( 318 client_server_.reset(new JingleSessionManager(
189 base::MessageLoopProxy::current())); 319 base::MessageLoopProxy::current()));
190 client_server_->Init( 320 client_server_->Init(
191 kClientJid, client_signal_strategy_.get(), &client_server_listener_, 321 kClientJid, client_signal_strategy_.get(),
192 NULL, "", false); 322 &client_server_listener_, false);
193 } 323 }
194 324
195 void CloseSessionManager() { 325 void CloseSessionManager() {
196 if (host_server_.get()) { 326 if (host_server_.get()) {
197 host_server_->Close(); 327 host_server_->Close();
198 host_server_.reset(); 328 host_server_.reset();
199 } 329 }
200 if (client_server_.get()) { 330 if (client_server_.get()) {
201 client_server_->Close(); 331 client_server_->Close();
202 client_server_.reset(); 332 client_server_.reset();
203 } 333 }
204 host_signal_strategy_.reset(); 334 host_signal_strategy_.reset();
205 client_signal_strategy_.reset(); 335 client_signal_strategy_.reset();
206 } 336 }
207 337
208 bool InitiateConnection(const char* shared_secret) { 338 bool InitiateConnection(bool use_fake_auth) {
209 int not_connected_peers = 2; 339 int not_connected_peers = 2;
210 340
211 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _)) 341 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _))
212 .WillOnce(DoAll( 342 .WillOnce(DoAll(
213 WithArg<0>(Invoke( 343 WithArg<0>(Invoke(
214 this, &JingleSessionTest::SetHostSession)), 344 this, &JingleSessionTest::SetHostSession)),
215 SetArgumentPointee<1>(protocol::SessionManager::ACCEPT))); 345 SetArgumentPointee<1>(protocol::SessionManager::ACCEPT)));
216 346
217 { 347 {
218 InSequence dummy; 348 InSequence dummy;
(...skipping 17 matching lines...) Expand all
236 EXPECT_CALL(client_connection_callback_, 366 EXPECT_CALL(client_connection_callback_,
237 OnStateChange(Session::CONNECTED)) 367 OnStateChange(Session::CONNECTED))
238 .Times(1) 368 .Times(1)
239 .WillOnce(QuitThreadOnCounter(&not_connected_peers)); 369 .WillOnce(QuitThreadOnCounter(&not_connected_peers));
240 // Expect that the connection will be closed eventually. 370 // Expect that the connection will be closed eventually.
241 EXPECT_CALL(client_connection_callback_, 371 EXPECT_CALL(client_connection_callback_,
242 OnStateChange(Session::CLOSED)) 372 OnStateChange(Session::CLOSED))
243 .Times(AtMost(1)); 373 .Times(AtMost(1));
244 } 374 }
245 375
376 Authenticator* authenticator;
377 if (use_fake_auth) {
378 authenticator = new FakeClientAuthenticator(true, true);
379 } else {
380 authenticator = new V1ClientAuthenticator(kClientJid, kTestSharedSecret);
381 }
246 client_session_.reset(client_server_->Connect( 382 client_session_.reset(client_server_->Connect(
247 kHostJid, kTestHostPublicKey, 383 kHostJid, authenticator,
248 GenerateSupportAuthToken(kClientJid, kTestSharedSecret),
249 CandidateSessionConfig::CreateDefault(), 384 CandidateSessionConfig::CreateDefault(),
250 base::Bind(&MockSessionCallback::OnStateChange, 385 base::Bind(&MockSessionCallback::OnStateChange,
251 base::Unretained(&client_connection_callback_)))); 386 base::Unretained(&client_connection_callback_))));
252 387
253 client_session_->set_shared_secret(shared_secret);
254
255 return RunMessageLoopWithTimeout(TestTimeouts::action_max_timeout_ms()); 388 return RunMessageLoopWithTimeout(TestTimeouts::action_max_timeout_ms());
256 } 389 }
257 390
258 static void DoNothing() { } 391 static void DoNothing() { }
259 392
260 JingleThreadMessageLoop message_loop_; 393 JingleThreadMessageLoop message_loop_;
261 394
262 scoped_ptr<FakeSignalStrategy> host_signal_strategy_; 395 scoped_ptr<FakeSignalStrategy> host_signal_strategy_;
263 scoped_ptr<FakeSignalStrategy> client_signal_strategy_; 396 scoped_ptr<FakeSignalStrategy> client_signal_strategy_;
264 397
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 base::Bind(&TCPChannelTester::OnChannelReady, 496 base::Bind(&TCPChannelTester::OnChannelReady,
364 base::Unretained(this), 0)); 497 base::Unretained(this), 0));
365 client_session_->CreateStreamChannel( 498 client_session_->CreateStreamChannel(
366 kChannelName, 499 kChannelName,
367 base::Bind(&TCPChannelTester::OnChannelReady, 500 base::Bind(&TCPChannelTester::OnChannelReady,
368 base::Unretained(this), 1)); 501 base::Unretained(this), 1));
369 } 502 }
370 503
371 void OnChannelReady(int id, net::StreamSocket* socket) { 504 void OnChannelReady(int id, net::StreamSocket* socket) {
372 if (!socket) { 505 if (!socket) {
506 host_session_->CancelChannelCreation(kChannelName);
507 client_session_->CancelChannelCreation(kChannelName);
373 Done(); 508 Done();
374 return; 509 return;
375 } 510 }
376 511
377 DCHECK(id >= 0 && id < 2); 512 DCHECK(id >= 0 && id < 2);
378 sockets_[id].reset(socket); 513 sockets_[id].reset(socket);
379 514
380 if (sockets_[0].get() && sockets_[1].get()) { 515 if (sockets_[0].get() && sockets_[1].get()) {
381 InitBuffers(); 516 InitBuffers();
382 DoRead(); 517 DoRead();
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 net::OldCompletionCallbackImpl<UDPChannelTester> read_cb_; 773 net::OldCompletionCallbackImpl<UDPChannelTester> read_cb_;
639 int write_errors_; 774 int write_errors_;
640 int read_errors_; 775 int read_errors_;
641 int packets_sent_; 776 int packets_sent_;
642 int packets_received_; 777 int packets_received_;
643 int broken_packets_; 778 int broken_packets_;
644 }; 779 };
645 780
646 // Verify that we can create and destory server objects without a connection. 781 // Verify that we can create and destory server objects without a connection.
647 TEST_F(JingleSessionTest, CreateAndDestoy) { 782 TEST_F(JingleSessionTest, CreateAndDestoy) {
648 CreateServerPair(); 783 CreateServerPair(false);
649 } 784 }
650 785
651 // Verify that incoming session can be rejected, and that the status 786 // Verify that incoming session can be rejected, and that the status
652 // of the connection is set to CLOSED in this case. 787 // of the connection is set to CLOSED in this case.
653 TEST_F(JingleSessionTest, RejectConnection) { 788 TEST_F(JingleSessionTest, RejectConnection) {
654 CreateServerPair(); 789 CreateServerPair(false);
655 790
656 // Reject incoming session. 791 // Reject incoming session.
657 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _)) 792 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _))
658 .WillOnce(SetArgumentPointee<1>(protocol::SessionManager::DECLINE)); 793 .WillOnce(SetArgumentPointee<1>(protocol::SessionManager::DECLINE));
659 794
660 { 795 {
661 InSequence dummy; 796 InSequence dummy;
662 797
663 EXPECT_CALL(client_connection_callback_, 798 EXPECT_CALL(client_connection_callback_,
664 OnStateChange(Session::CONNECTING)) 799 OnStateChange(Session::CONNECTING))
665 .Times(1); 800 .Times(1);
666 EXPECT_CALL(client_connection_callback_, 801 EXPECT_CALL(client_connection_callback_,
667 OnStateChange(Session::CLOSED)) 802 OnStateChange(Session::CLOSED))
668 .Times(1) 803 .Times(1)
669 .WillOnce(InvokeWithoutArgs(&QuitCurrentThread)); 804 .WillOnce(InvokeWithoutArgs(&QuitCurrentThread));
670 } 805 }
671 806
807 Authenticator* authenticator =
808 new V1ClientAuthenticator(kClientJid, kTestSharedSecretBad);
672 client_session_.reset(client_server_->Connect( 809 client_session_.reset(client_server_->Connect(
673 kHostJid, kTestHostPublicKey, 810 kHostJid, authenticator,
674 GenerateSupportAuthToken(kClientJid, kTestSharedSecret),
675 CandidateSessionConfig::CreateDefault(), 811 CandidateSessionConfig::CreateDefault(),
676 base::Bind(&MockSessionCallback::OnStateChange, 812 base::Bind(&MockSessionCallback::OnStateChange,
677 base::Unretained(&client_connection_callback_)))); 813 base::Unretained(&client_connection_callback_))));
678 814
679 ASSERT_TRUE(RunMessageLoopWithTimeout(TestTimeouts::action_max_timeout_ms())); 815 ASSERT_TRUE(RunMessageLoopWithTimeout(TestTimeouts::action_max_timeout_ms()));
680 } 816 }
681 817
682 // Verify that we can connect two endpoints. 818 // Verify that we can connect two endpoints.
683 TEST_F(JingleSessionTest, Connect) { 819 TEST_F(JingleSessionTest, Connect) {
684 CreateServerPair(); 820 CreateServerPair(false);
685 ASSERT_TRUE(InitiateConnection(kTestSharedSecret)); 821 ASSERT_TRUE(InitiateConnection(false));
686 } 822 }
687 823
688 // Verify that we can't connect two endpoints with mismatched secrets. 824 // Verify that we can't connect two endpoints with mismatched secrets.
689 TEST_F(JingleSessionTest, ConnectBadChannelAuth) { 825 TEST_F(JingleSessionTest, ConnectBadChannelAuth) {
690 CreateServerPair(); 826 CreateServerPair(true);
691 ASSERT_TRUE(InitiateConnection(kTestSharedSecretBad)); 827 ASSERT_TRUE(InitiateConnection(true));
692 scoped_refptr<TCPChannelTester> tester( 828 scoped_refptr<TCPChannelTester> tester(
693 new TCPChannelTester(host_session_.get(), client_session_.get(), 829 new TCPChannelTester(host_session_.get(), client_session_.get(),
694 kMessageSize, kMessages)); 830 kMessageSize, kMessages));
695 tester->Start(); 831 tester->Start();
696 ASSERT_TRUE(tester->WaitFinished()); 832 ASSERT_TRUE(tester->WaitFinished());
697 EXPECT_TRUE(tester->did_initialization_fail()); 833 EXPECT_TRUE(tester->did_initialization_fail());
698 834
699 CloseSessions(); 835 CloseSessions();
700 } 836 }
701 837
702 // Verify that data can be transmitted over the event channel. 838 // Verify that data can be transmitted over the event channel.
703 TEST_F(JingleSessionTest, TestTcpChannel) { 839 TEST_F(JingleSessionTest, TestTcpChannel) {
704 CreateServerPair(); 840 CreateServerPair(false);
705 ASSERT_TRUE(InitiateConnection(kTestSharedSecret)); 841 ASSERT_TRUE(InitiateConnection(false));
706 scoped_refptr<TCPChannelTester> tester( 842 scoped_refptr<TCPChannelTester> tester(
707 new TCPChannelTester(host_session_.get(), client_session_.get(), 843 new TCPChannelTester(host_session_.get(), client_session_.get(),
708 kMessageSize, kMessages)); 844 kMessageSize, kMessages));
709 tester->Start(); 845 tester->Start();
710 ASSERT_TRUE(tester->WaitFinished()); 846 ASSERT_TRUE(tester->WaitFinished());
711 tester->CheckResults(); 847 tester->CheckResults();
712 848
713 // Connections must be closed while |tester| still exists. 849 // Connections must be closed while |tester| still exists.
714 CloseSessions(); 850 CloseSessions();
715 } 851 }
716 852
717 // Verify that data can be transmitted over the video RTP channel. 853 // Verify that data can be transmitted over the video RTP channel.
718 TEST_F(JingleSessionTest, TestUdpChannel) { 854 TEST_F(JingleSessionTest, TestUdpChannel) {
719 CreateServerPair(); 855 CreateServerPair(false);
720 ASSERT_TRUE(InitiateConnection(kTestSharedSecret)); 856 ASSERT_TRUE(InitiateConnection(false));
721 scoped_refptr<UDPChannelTester> tester( 857 scoped_refptr<UDPChannelTester> tester(
722 new UDPChannelTester(host_session_.get(), client_session_.get())); 858 new UDPChannelTester(host_session_.get(), client_session_.get()));
723 tester->Start(); 859 tester->Start();
724 ASSERT_TRUE(tester->WaitFinished()); 860 ASSERT_TRUE(tester->WaitFinished());
725 tester->CheckResults(); 861 tester->CheckResults();
726 862
727 // Connections must be closed while |tester| still exists. 863 // Connections must be closed while |tester| still exists.
728 CloseSessions(); 864 CloseSessions();
729 } 865 }
730 866
731 // Send packets of different size to get the latency for sending data 867 // Send packets of different size to get the latency for sending data
732 // using sockets from JingleSession. 868 // using sockets from JingleSession.
733 TEST_F(JingleSessionTest, FLAKY_TestSpeed) { 869 TEST_F(JingleSessionTest, FLAKY_TestSpeed) {
734 CreateServerPair(); 870 CreateServerPair(false);
735 ASSERT_TRUE(InitiateConnection(kTestSharedSecret)); 871 ASSERT_TRUE(InitiateConnection(false));
736 scoped_refptr<ChannelSpeedTester> tester; 872 scoped_refptr<ChannelSpeedTester> tester;
737 873
738 tester = new ChannelSpeedTester(host_session_.get(), 874 tester = new ChannelSpeedTester(host_session_.get(),
739 client_session_.get(), 512); 875 client_session_.get(), 512);
740 tester->Start(); 876 tester->Start();
741 ASSERT_TRUE(tester->WaitFinished()); 877 ASSERT_TRUE(tester->WaitFinished());
742 LOG(INFO) << "Time for 512 bytes " 878 LOG(INFO) << "Time for 512 bytes "
743 << tester->GetElapsedTime().InMilliseconds() << " ms."; 879 << tester->GetElapsedTime().InMilliseconds() << " ms.";
744 880
745 CloseSessions(); 881 CloseSessions();
746 ASSERT_TRUE(InitiateConnection(kTestSharedSecret)); 882 ASSERT_TRUE(InitiateConnection(false));
747 883
748 tester = new ChannelSpeedTester(host_session_.get(), 884 tester = new ChannelSpeedTester(host_session_.get(),
749 client_session_.get(), 1024); 885 client_session_.get(), 1024);
750 tester->Start(); 886 tester->Start();
751 ASSERT_TRUE(tester->WaitFinished()); 887 ASSERT_TRUE(tester->WaitFinished());
752 LOG(INFO) << "Time for 1024 bytes " 888 LOG(INFO) << "Time for 1024 bytes "
753 << tester->GetElapsedTime().InMilliseconds() << " ms."; 889 << tester->GetElapsedTime().InMilliseconds() << " ms.";
754 890
755 CloseSessions(); 891 CloseSessions();
756 ASSERT_TRUE(InitiateConnection(kTestSharedSecret)); 892 ASSERT_TRUE(InitiateConnection(false));
757 893
758 tester = new ChannelSpeedTester(host_session_.get(), 894 tester = new ChannelSpeedTester(host_session_.get(),
759 client_session_.get(), 51200); 895 client_session_.get(), 51200);
760 tester->Start(); 896 tester->Start();
761 ASSERT_TRUE(tester->WaitFinished()); 897 ASSERT_TRUE(tester->WaitFinished());
762 LOG(INFO) << "Time for 50k bytes " 898 LOG(INFO) << "Time for 50k bytes "
763 << tester->GetElapsedTime().InMilliseconds() << " ms."; 899 << tester->GetElapsedTime().InMilliseconds() << " ms.";
764 900
765 CloseSessions(); 901 CloseSessions();
766 ASSERT_TRUE(InitiateConnection(kTestSharedSecret)); 902 ASSERT_TRUE(InitiateConnection(false));
767 903
768 tester = new ChannelSpeedTester(host_session_.get(), 904 tester = new ChannelSpeedTester(host_session_.get(),
769 client_session_.get(), 512000); 905 client_session_.get(), 512000);
770 tester->Start(); 906 tester->Start();
771 ASSERT_TRUE(tester->WaitFinished()); 907 ASSERT_TRUE(tester->WaitFinished());
772 LOG(INFO) << "Time for 500k bytes " 908 LOG(INFO) << "Time for 500k bytes "
773 << tester->GetElapsedTime().InMilliseconds() << " ms."; 909 << tester->GetElapsedTime().InMilliseconds() << " ms.";
774 910
775 // Connections must be closed while |tester| still exists. 911 // Connections must be closed while |tester| still exists.
776 CloseSessions(); 912 CloseSessions();
777 } 913 }
778 914
779 } // namespace protocol 915 } // namespace protocol
780 } // namespace remoting 916 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/jingle_session_manager.cc ('k') | remoting/protocol/pepper_session.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698