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

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

Issue 9240033: Use scoped_ptr<>.Pass() to pass ownership in the remoting protocol code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: - Created 8 years, 11 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
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/pepper_session.h" 5 #include "remoting/protocol/pepper_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 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 EXPECT_CALL(client_connection_callback_, 171 EXPECT_CALL(client_connection_callback_,
172 OnStateChange(Session::AUTHENTICATED)) 172 OnStateChange(Session::AUTHENTICATED))
173 .Times(1); 173 .Times(1);
174 // Expect that the connection will be closed eventually. 174 // Expect that the connection will be closed eventually.
175 EXPECT_CALL(client_connection_callback_, 175 EXPECT_CALL(client_connection_callback_,
176 OnStateChange(Session::CLOSED)) 176 OnStateChange(Session::CLOSED))
177 .Times(AtMost(1)); 177 .Times(AtMost(1));
178 } 178 }
179 } 179 }
180 180
181 Authenticator* authenticator = new FakeAuthenticator( 181 scoped_ptr<Authenticator> authenticator(new FakeAuthenticator(
182 FakeAuthenticator::CLIENT, auth_round_trips, auth_action, true); 182 FakeAuthenticator::CLIENT, auth_round_trips, auth_action, true));
183 183
184 client_session_.reset(client_server_->Connect( 184 client_session_ = client_server_->Connect(
185 kHostJid, authenticator, 185 kHostJid, authenticator.Pass(),
186 CandidateSessionConfig::CreateDefault(), 186 CandidateSessionConfig::CreateDefault(),
187 base::Bind(&MockSessionCallback::OnStateChange, 187 base::Bind(&MockSessionCallback::OnStateChange,
188 base::Unretained(&client_connection_callback_)))); 188 base::Unretained(&client_connection_callback_)));
189 189
190 message_loop_.RunAllPending(); 190 message_loop_.RunAllPending();
191 } 191 }
192 192
193 JingleThreadMessageLoop message_loop_; 193 JingleThreadMessageLoop message_loop_;
194 194
195 scoped_ptr<FakeSignalStrategy> host_signal_strategy_; 195 scoped_ptr<FakeSignalStrategy> host_signal_strategy_;
196 scoped_ptr<FakeSignalStrategy> client_signal_strategy_; 196 scoped_ptr<FakeSignalStrategy> client_signal_strategy_;
197 197
198 scoped_ptr<JingleSessionManager> host_server_; 198 scoped_ptr<JingleSessionManager> host_server_;
(...skipping 27 matching lines...) Expand all
226 InSequence dummy; 226 InSequence dummy;
227 227
228 EXPECT_CALL(client_connection_callback_, 228 EXPECT_CALL(client_connection_callback_,
229 OnStateChange(Session::CONNECTING)) 229 OnStateChange(Session::CONNECTING))
230 .Times(1); 230 .Times(1);
231 EXPECT_CALL(client_connection_callback_, 231 EXPECT_CALL(client_connection_callback_,
232 OnStateChange(Session::FAILED)) 232 OnStateChange(Session::FAILED))
233 .Times(1); 233 .Times(1);
234 } 234 }
235 235
236 Authenticator* authenticator = new FakeAuthenticator( 236 scoped_ptr<Authenticator> authenticator(new FakeAuthenticator(
237 FakeAuthenticator::CLIENT, 1, FakeAuthenticator::ACCEPT, true); 237 FakeAuthenticator::CLIENT, 1, FakeAuthenticator::ACCEPT, true));
238 client_session_.reset(client_server_->Connect( 238 client_session_ = client_server_->Connect(
239 kHostJid, authenticator, 239 kHostJid, authenticator.Pass(), CandidateSessionConfig::CreateDefault(),
240 CandidateSessionConfig::CreateDefault(),
241 base::Bind(&MockSessionCallback::OnStateChange, 240 base::Bind(&MockSessionCallback::OnStateChange,
242 base::Unretained(&client_connection_callback_)))); 241 base::Unretained(&client_connection_callback_)));
243 242
244 message_loop_.RunAllPending(); 243 message_loop_.RunAllPending();
245 } 244 }
246 245
247 // Verify that we can connect two endpoints with single-step authentication. 246 // Verify that we can connect two endpoints with single-step authentication.
248 TEST_F(PepperSessionTest, Connect) { 247 TEST_F(PepperSessionTest, Connect) {
249 CreateSessionManagers(1, FakeAuthenticator::ACCEPT); 248 CreateSessionManagers(1, FakeAuthenticator::ACCEPT);
250 InitiateConnection(1, FakeAuthenticator::ACCEPT, false); 249 InitiateConnection(1, FakeAuthenticator::ACCEPT, false);
251 } 250 }
252 251
(...skipping 10 matching lines...) Expand all
263 } 262 }
264 263
265 // Verify that connection is terminated when multi-step auth fails. 264 // Verify that connection is terminated when multi-step auth fails.
266 TEST_F(PepperSessionTest, ConnectWithBadMultistepAuth) { 265 TEST_F(PepperSessionTest, ConnectWithBadMultistepAuth) {
267 CreateSessionManagers(3, FakeAuthenticator::REJECT); 266 CreateSessionManagers(3, FakeAuthenticator::REJECT);
268 InitiateConnection(3, FakeAuthenticator::ACCEPT, true); 267 InitiateConnection(3, FakeAuthenticator::ACCEPT, true);
269 } 268 }
270 269
271 } // namespace protocol 270 } // namespace protocol
272 } // namespace remoting 271 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698