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

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: - Created 9 years, 1 month 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
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 12 matching lines...) Expand all
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_->set_allow_local_ips(true); 304 host_server_->set_allow_local_ips(true);
183 host_server_->Init( 305 host_server_->Init(
184 kHostJid, host_signal_strategy_.get(), &host_server_listener_, 306 kHostJid, host_signal_strategy_.get(), &host_server_listener_, false);
185 private_key.release(), cert_der, false); 307
308 if (use_fake_auth) {
309 host_server_->set_authenticator_factory(
310 new FakeHostAuthenticatorFactory(true, false));
311 } else {
312 host_server_->set_authenticator_factory(
313 new V1HostAuthenticatorFactory(
314 cert_der, private_key.release(), kTestSharedSecret));
315 }
186 316
187 EXPECT_CALL(client_server_listener_, OnSessionManagerInitialized()) 317 EXPECT_CALL(client_server_listener_, OnSessionManagerInitialized())
188 .Times(1); 318 .Times(1);
189 client_server_.reset(new JingleSessionManager( 319 client_server_.reset(new JingleSessionManager(
190 base::MessageLoopProxy::current())); 320 base::MessageLoopProxy::current()));
191 client_server_->set_allow_local_ips(true); 321 client_server_->set_allow_local_ips(true);
192 client_server_->Init( 322 client_server_->Init(
193 kClientJid, client_signal_strategy_.get(), &client_server_listener_, 323 kClientJid, client_signal_strategy_.get(),
194 NULL, "", false); 324 &client_server_listener_, false);
195 } 325 }
196 326
197 void CloseSessionManager() { 327 void CloseSessionManager() {
198 if (host_server_.get()) { 328 if (host_server_.get()) {
199 host_server_->Close(); 329 host_server_->Close();
200 host_server_.reset(); 330 host_server_.reset();
201 } 331 }
202 if (client_server_.get()) { 332 if (client_server_.get()) {
203 client_server_->Close(); 333 client_server_->Close();
204 client_server_.reset(); 334 client_server_.reset();
205 } 335 }
206 host_signal_strategy_.reset(); 336 host_signal_strategy_.reset();
207 client_signal_strategy_.reset(); 337 client_signal_strategy_.reset();
208 } 338 }
209 339
210 bool InitiateConnection(const char* shared_secret) { 340 bool InitiateConnection(bool use_fake_auth) {
211 int not_connected_peers = 2; 341 int not_connected_peers = 2;
212 342
213 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _)) 343 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _))
214 .WillOnce(DoAll( 344 .WillOnce(DoAll(
215 WithArg<0>(Invoke( 345 WithArg<0>(Invoke(
216 this, &JingleSessionTest::SetHostSession)), 346 this, &JingleSessionTest::SetHostSession)),
217 SetArgumentPointee<1>(protocol::SessionManager::ACCEPT))); 347 SetArgumentPointee<1>(protocol::SessionManager::ACCEPT)));
218 348
219 { 349 {
220 InSequence dummy; 350 InSequence dummy;
(...skipping 17 matching lines...) Expand all
238 EXPECT_CALL(client_connection_callback_, 368 EXPECT_CALL(client_connection_callback_,
239 OnStateChange(Session::CONNECTED)) 369 OnStateChange(Session::CONNECTED))
240 .Times(1) 370 .Times(1)
241 .WillOnce(QuitThreadOnCounter(&not_connected_peers)); 371 .WillOnce(QuitThreadOnCounter(&not_connected_peers));
242 // Expect that the connection will be closed eventually. 372 // Expect that the connection will be closed eventually.
243 EXPECT_CALL(client_connection_callback_, 373 EXPECT_CALL(client_connection_callback_,
244 OnStateChange(Session::CLOSED)) 374 OnStateChange(Session::CLOSED))
245 .Times(AtMost(1)); 375 .Times(AtMost(1));
246 } 376 }
247 377
378 Authenticator* authenticator;
379 if (use_fake_auth) {
380 authenticator = new FakeClientAuthenticator(true, true);
381 } else {
382 authenticator = new V1ClientAuthenticator(kClientJid, kTestSharedSecret);
383 }
248 client_session_.reset(client_server_->Connect( 384 client_session_.reset(client_server_->Connect(
249 kHostJid, kTestHostPublicKey, 385 kHostJid, authenticator,
250 GenerateSupportAuthToken(kClientJid, kTestSharedSecret),
251 CandidateSessionConfig::CreateDefault(), 386 CandidateSessionConfig::CreateDefault(),
252 base::Bind(&MockSessionCallback::OnStateChange, 387 base::Bind(&MockSessionCallback::OnStateChange,
253 base::Unretained(&client_connection_callback_)))); 388 base::Unretained(&client_connection_callback_))));
254 389
255 client_session_->set_shared_secret(shared_secret);
256
257 return RunMessageLoopWithTimeout(TestTimeouts::action_max_timeout_ms()); 390 return RunMessageLoopWithTimeout(TestTimeouts::action_max_timeout_ms());
258 } 391 }
259 392
260 static void DoNothing() { } 393 static void DoNothing() { }
261 394
262 JingleThreadMessageLoop message_loop_; 395 JingleThreadMessageLoop message_loop_;
263 396
264 scoped_ptr<FakeSignalStrategy> host_signal_strategy_; 397 scoped_ptr<FakeSignalStrategy> host_signal_strategy_;
265 scoped_ptr<FakeSignalStrategy> client_signal_strategy_; 398 scoped_ptr<FakeSignalStrategy> client_signal_strategy_;
266 399
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
640 net::OldCompletionCallbackImpl<UDPChannelTester> read_cb_; 773 net::OldCompletionCallbackImpl<UDPChannelTester> read_cb_;
641 int write_errors_; 774 int write_errors_;
642 int read_errors_; 775 int read_errors_;
643 int packets_sent_; 776 int packets_sent_;
644 int packets_received_; 777 int packets_received_;
645 int broken_packets_; 778 int broken_packets_;
646 }; 779 };
647 780
648 // 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.
649 TEST_F(JingleSessionTest, CreateAndDestoy) { 782 TEST_F(JingleSessionTest, CreateAndDestoy) {
650 CreateServerPair(); 783 CreateServerPair(false);
651 } 784 }
652 785
653 // Verify that incoming session can be rejected, and that the status 786 // Verify that incoming session can be rejected, and that the status
654 // of the connection is set to CLOSED in this case. 787 // of the connection is set to CLOSED in this case.
655 TEST_F(JingleSessionTest, RejectConnection) { 788 TEST_F(JingleSessionTest, RejectConnection) {
656 CreateServerPair(); 789 CreateServerPair(false);
657 790
658 // Reject incoming session. 791 // Reject incoming session.
659 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _)) 792 EXPECT_CALL(host_server_listener_, OnIncomingSession(_, _))
660 .WillOnce(SetArgumentPointee<1>(protocol::SessionManager::DECLINE)); 793 .WillOnce(SetArgumentPointee<1>(protocol::SessionManager::DECLINE));
661 794
662 { 795 {
663 InSequence dummy; 796 InSequence dummy;
664 797
665 EXPECT_CALL(client_connection_callback_, 798 EXPECT_CALL(client_connection_callback_,
666 OnStateChange(Session::CONNECTING)) 799 OnStateChange(Session::CONNECTING))
667 .Times(1); 800 .Times(1);
668 EXPECT_CALL(client_connection_callback_, 801 EXPECT_CALL(client_connection_callback_,
669 OnStateChange(Session::CLOSED)) 802 OnStateChange(Session::CLOSED))
670 .Times(1) 803 .Times(1)
671 .WillOnce(InvokeWithoutArgs(&QuitCurrentThread)); 804 .WillOnce(InvokeWithoutArgs(&QuitCurrentThread));
672 } 805 }
673 806
807 Authenticator* authenticator =
808 new V1ClientAuthenticator(kClientJid, kTestSharedSecretBad);
674 client_session_.reset(client_server_->Connect( 809 client_session_.reset(client_server_->Connect(
675 kHostJid, kTestHostPublicKey, 810 kHostJid, authenticator,
676 GenerateSupportAuthToken(kClientJid, kTestSharedSecret),
677 CandidateSessionConfig::CreateDefault(), 811 CandidateSessionConfig::CreateDefault(),
678 base::Bind(&MockSessionCallback::OnStateChange, 812 base::Bind(&MockSessionCallback::OnStateChange,
679 base::Unretained(&client_connection_callback_)))); 813 base::Unretained(&client_connection_callback_))));
680 814
681 ASSERT_TRUE(RunMessageLoopWithTimeout(TestTimeouts::action_max_timeout_ms())); 815 ASSERT_TRUE(RunMessageLoopWithTimeout(TestTimeouts::action_max_timeout_ms()));
682 } 816 }
683 817
684 // Verify that we can connect two endpoints. 818 // Verify that we can connect two endpoints.
685 TEST_F(JingleSessionTest, Connect) { 819 TEST_F(JingleSessionTest, Connect) {
686 CreateServerPair(); 820 CreateServerPair(false);
687 ASSERT_TRUE(InitiateConnection(kTestSharedSecret)); 821 ASSERT_TRUE(InitiateConnection(false));
688 } 822 }
689 823
690 // Verify that we can't connect two endpoints with mismatched secrets. 824 // Verify that we can't connect two endpoints with mismatched secrets.
691 TEST_F(JingleSessionTest, ConnectBadChannelAuth) { 825 TEST_F(JingleSessionTest, ConnectBadChannelAuth) {
692 CreateServerPair(); 826 CreateServerPair(true);
693 ASSERT_TRUE(InitiateConnection(kTestSharedSecretBad)); 827 ASSERT_TRUE(InitiateConnection(true));
694 scoped_refptr<TCPChannelTester> tester( 828 scoped_refptr<TCPChannelTester> tester(
695 new TCPChannelTester(host_session_.get(), client_session_.get(), 829 new TCPChannelTester(host_session_.get(), client_session_.get(),
696 kMessageSize, kMessages)); 830 kMessageSize, kMessages));
697 tester->Start(); 831 tester->Start();
698 ASSERT_TRUE(tester->WaitFinished()); 832 ASSERT_TRUE(tester->WaitFinished());
699 EXPECT_TRUE(tester->did_initialization_fail()); 833 EXPECT_TRUE(tester->did_initialization_fail());
700 834
701 CloseSessions(); 835 CloseSessions();
702 } 836 }
703 837
704 // Verify that data can be transmitted over the event channel. 838 // Verify that data can be transmitted over the event channel.
705 TEST_F(JingleSessionTest, TestTcpChannel) { 839 TEST_F(JingleSessionTest, TestTcpChannel) {
706 CreateServerPair(); 840 CreateServerPair(false);
707 ASSERT_TRUE(InitiateConnection(kTestSharedSecret)); 841 ASSERT_TRUE(InitiateConnection(false));
708 scoped_refptr<TCPChannelTester> tester( 842 scoped_refptr<TCPChannelTester> tester(
709 new TCPChannelTester(host_session_.get(), client_session_.get(), 843 new TCPChannelTester(host_session_.get(), client_session_.get(),
710 kMessageSize, kMessages)); 844 kMessageSize, kMessages));
711 tester->Start(); 845 tester->Start();
712 ASSERT_TRUE(tester->WaitFinished()); 846 ASSERT_TRUE(tester->WaitFinished());
713 tester->CheckResults(); 847 tester->CheckResults();
714 848
715 // Connections must be closed while |tester| still exists. 849 // Connections must be closed while |tester| still exists.
716 CloseSessions(); 850 CloseSessions();
717 } 851 }
718 852
719 // Verify that data can be transmitted over the video RTP channel. 853 // Verify that data can be transmitted over the video RTP channel.
720 TEST_F(JingleSessionTest, TestUdpChannel) { 854 TEST_F(JingleSessionTest, TestUdpChannel) {
721 CreateServerPair(); 855 CreateServerPair(false);
722 ASSERT_TRUE(InitiateConnection(kTestSharedSecret)); 856 ASSERT_TRUE(InitiateConnection(false));
723 scoped_refptr<UDPChannelTester> tester( 857 scoped_refptr<UDPChannelTester> tester(
724 new UDPChannelTester(host_session_.get(), client_session_.get())); 858 new UDPChannelTester(host_session_.get(), client_session_.get()));
725 tester->Start(); 859 tester->Start();
726 ASSERT_TRUE(tester->WaitFinished()); 860 ASSERT_TRUE(tester->WaitFinished());
727 tester->CheckResults(); 861 tester->CheckResults();
728 862
729 // Connections must be closed while |tester| still exists. 863 // Connections must be closed while |tester| still exists.
730 CloseSessions(); 864 CloseSessions();
731 } 865 }
732 866
733 // 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
734 // using sockets from JingleSession. 868 // using sockets from JingleSession.
735 TEST_F(JingleSessionTest, FLAKY_TestSpeed) { 869 TEST_F(JingleSessionTest, FLAKY_TestSpeed) {
736 CreateServerPair(); 870 CreateServerPair(false);
737 ASSERT_TRUE(InitiateConnection(kTestSharedSecret)); 871 ASSERT_TRUE(InitiateConnection(false));
738 scoped_refptr<ChannelSpeedTester> tester; 872 scoped_refptr<ChannelSpeedTester> tester;
739 873
740 tester = new ChannelSpeedTester(host_session_.get(), 874 tester = new ChannelSpeedTester(host_session_.get(),
741 client_session_.get(), 512); 875 client_session_.get(), 512);
742 tester->Start(); 876 tester->Start();
743 ASSERT_TRUE(tester->WaitFinished()); 877 ASSERT_TRUE(tester->WaitFinished());
744 LOG(INFO) << "Time for 512 bytes " 878 LOG(INFO) << "Time for 512 bytes "
745 << tester->GetElapsedTime().InMilliseconds() << " ms."; 879 << tester->GetElapsedTime().InMilliseconds() << " ms.";
746 880
747 CloseSessions(); 881 CloseSessions();
748 ASSERT_TRUE(InitiateConnection(kTestSharedSecret)); 882 ASSERT_TRUE(InitiateConnection(false));
749 883
750 tester = new ChannelSpeedTester(host_session_.get(), 884 tester = new ChannelSpeedTester(host_session_.get(),
751 client_session_.get(), 1024); 885 client_session_.get(), 1024);
752 tester->Start(); 886 tester->Start();
753 ASSERT_TRUE(tester->WaitFinished()); 887 ASSERT_TRUE(tester->WaitFinished());
754 LOG(INFO) << "Time for 1024 bytes " 888 LOG(INFO) << "Time for 1024 bytes "
755 << tester->GetElapsedTime().InMilliseconds() << " ms."; 889 << tester->GetElapsedTime().InMilliseconds() << " ms.";
756 890
757 CloseSessions(); 891 CloseSessions();
758 ASSERT_TRUE(InitiateConnection(kTestSharedSecret)); 892 ASSERT_TRUE(InitiateConnection(false));
759 893
760 tester = new ChannelSpeedTester(host_session_.get(), 894 tester = new ChannelSpeedTester(host_session_.get(),
761 client_session_.get(), 51200); 895 client_session_.get(), 51200);
762 tester->Start(); 896 tester->Start();
763 ASSERT_TRUE(tester->WaitFinished()); 897 ASSERT_TRUE(tester->WaitFinished());
764 LOG(INFO) << "Time for 50k bytes " 898 LOG(INFO) << "Time for 50k bytes "
765 << tester->GetElapsedTime().InMilliseconds() << " ms."; 899 << tester->GetElapsedTime().InMilliseconds() << " ms.";
766 900
767 CloseSessions(); 901 CloseSessions();
768 ASSERT_TRUE(InitiateConnection(kTestSharedSecret)); 902 ASSERT_TRUE(InitiateConnection(false));
769 903
770 tester = new ChannelSpeedTester(host_session_.get(), 904 tester = new ChannelSpeedTester(host_session_.get(),
771 client_session_.get(), 512000); 905 client_session_.get(), 512000);
772 tester->Start(); 906 tester->Start();
773 ASSERT_TRUE(tester->WaitFinished()); 907 ASSERT_TRUE(tester->WaitFinished());
774 LOG(INFO) << "Time for 500k bytes " 908 LOG(INFO) << "Time for 500k bytes "
775 << tester->GetElapsedTime().InMilliseconds() << " ms."; 909 << tester->GetElapsedTime().InMilliseconds() << " ms.";
776 910
777 // Connections must be closed while |tester| still exists. 911 // Connections must be closed while |tester| still exists.
778 CloseSessions(); 912 CloseSessions();
779 } 913 }
780 914
781 } // namespace protocol 915 } // namespace protocol
782 } // namespace remoting 916 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698