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

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

Issue 8116021: Switch remoting/protocol to new callbacks (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 9 years, 2 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_manager.cc ('k') | remoting/protocol/message_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) 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"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 public: 114 public:
115 JingleSessionTest() 115 JingleSessionTest()
116 : message_loop_(talk_base::Thread::Current()) { 116 : message_loop_(talk_base::Thread::Current()) {
117 } 117 }
118 118
119 // Helper method to copy to set value of client_connection_. 119 // Helper method to copy to set value of client_connection_.
120 void SetHostSession(Session* session) { 120 void SetHostSession(Session* session) {
121 DCHECK(session); 121 DCHECK(session);
122 host_session_.reset(session); 122 host_session_.reset(session);
123 host_session_->SetStateChangeCallback( 123 host_session_->SetStateChangeCallback(
124 NewCallback(&host_connection_callback_, 124 base::Bind(&MockSessionCallback::OnStateChange,
125 &MockSessionCallback::OnStateChange)); 125 base::Unretained(&host_connection_callback_)));
126 126
127 session->set_config(SessionConfig::GetDefault()); 127 session->set_config(SessionConfig::GetDefault());
128 session->set_shared_secret(kTestSharedSecret); 128 session->set_shared_secret(kTestSharedSecret);
129 } 129 }
130 130
131 protected: 131 protected:
132 virtual void SetUp() { 132 virtual void SetUp() {
133 } 133 }
134 134
135 virtual void TearDown() { 135 virtual void TearDown() {
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 } 271 }
272 // Expect that the connection will be closed eventually. 272 // Expect that the connection will be closed eventually.
273 EXPECT_CALL(client_connection_callback_, 273 EXPECT_CALL(client_connection_callback_,
274 OnStateChange(Session::CLOSED)) 274 OnStateChange(Session::CLOSED))
275 .Times(1); 275 .Times(1);
276 } 276 }
277 277
278 client_session_.reset(client_server_->Connect( 278 client_session_.reset(client_server_->Connect(
279 kHostJid, kTestHostPublicKey, kTestToken, 279 kHostJid, kTestHostPublicKey, kTestToken,
280 CandidateSessionConfig::CreateDefault(), 280 CandidateSessionConfig::CreateDefault(),
281 NewCallback(&client_connection_callback_, 281 base::Bind(&MockSessionCallback::OnStateChange,
282 &MockSessionCallback::OnStateChange))); 282 base::Unretained(&client_connection_callback_))));
283 283
284 client_session_->set_shared_secret(shared_secret); 284 client_session_->set_shared_secret(shared_secret);
285 285
286 return RunMessageLoopWithTimeout(TestTimeouts::action_max_timeout_ms()); 286 return RunMessageLoopWithTimeout(TestTimeouts::action_max_timeout_ms());
287 } 287 }
288 288
289 static void DoNothing() { } 289 static void DoNothing() { }
290 290
291 JingleThreadMessageLoop message_loop_; 291 JingleThreadMessageLoop message_loop_;
292 292
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after
691 .Times(1); 691 .Times(1);
692 EXPECT_CALL(client_connection_callback_, 692 EXPECT_CALL(client_connection_callback_,
693 OnStateChange(Session::CLOSED)) 693 OnStateChange(Session::CLOSED))
694 .Times(1) 694 .Times(1)
695 .WillOnce(InvokeWithoutArgs(&QuitCurrentThread)); 695 .WillOnce(InvokeWithoutArgs(&QuitCurrentThread));
696 } 696 }
697 697
698 client_session_.reset(client_server_->Connect( 698 client_session_.reset(client_server_->Connect(
699 kHostJid, kTestHostPublicKey, kTestToken, 699 kHostJid, kTestHostPublicKey, kTestToken,
700 CandidateSessionConfig::CreateDefault(), 700 CandidateSessionConfig::CreateDefault(),
701 NewCallback(&client_connection_callback_, 701 base::Bind(&MockSessionCallback::OnStateChange,
702 &MockSessionCallback::OnStateChange))); 702 base::Unretained(&client_connection_callback_))));
703 703
704 ASSERT_TRUE(RunMessageLoopWithTimeout(TestTimeouts::action_max_timeout_ms())); 704 ASSERT_TRUE(RunMessageLoopWithTimeout(TestTimeouts::action_max_timeout_ms()));
705 } 705 }
706 706
707 // Verify that we can connect two endpoints. 707 // Verify that we can connect two endpoints.
708 TEST_F(JingleSessionTest, Connect) { 708 TEST_F(JingleSessionTest, Connect) {
709 CreateServerPair(); 709 CreateServerPair();
710 ASSERT_TRUE(InitiateConnection(kTestSharedSecret)); 710 ASSERT_TRUE(InitiateConnection(kTestSharedSecret));
711 } 711 }
712 712
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 ASSERT_TRUE(tester->WaitFinished()); 788 ASSERT_TRUE(tester->WaitFinished());
789 LOG(INFO) << "Time for 500k bytes " 789 LOG(INFO) << "Time for 500k bytes "
790 << tester->GetElapsedTime().InMilliseconds() << " ms."; 790 << tester->GetElapsedTime().InMilliseconds() << " ms.";
791 791
792 // Connections must be closed while |tester| still exists. 792 // Connections must be closed while |tester| still exists.
793 CloseSessions(); 793 CloseSessions();
794 } 794 }
795 795
796 } // namespace protocol 796 } // namespace protocol
797 } // namespace remoting 797 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/protocol/jingle_session_manager.cc ('k') | remoting/protocol/message_reader.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698