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

Side by Side Diff: remoting/host/chromoting_host_unittest.cc

Issue 9827006: Refactor VideoStub interface to accept ownership of video packets. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 9 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 "base/bind.h" 5 #include "base/bind.h"
6 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
7 #include "base/message_loop_proxy.h" 7 #include "base/message_loop_proxy.h"
8 #include "remoting/jingle_glue/mock_objects.h" 8 #include "remoting/jingle_glue/mock_objects.h"
9 #include "remoting/host/capturer_fake.h" 9 #include "remoting/host/capturer_fake.h"
10 #include "remoting/host/chromoting_host.h" 10 #include "remoting/host/chromoting_host.h"
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 EXPECT_CALL(*session2_, Close()) 132 EXPECT_CALL(*session2_, Close())
133 .Times(AnyNumber()); 133 .Times(AnyNumber());
134 134
135 owned_connection_.reset(new MockConnectionToClient( 135 owned_connection_.reset(new MockConnectionToClient(
136 session_, &host_stub_, event_executor_)); 136 session_, &host_stub_, event_executor_));
137 connection_ = owned_connection_.get(); 137 connection_ = owned_connection_.get();
138 owned_connection2_.reset(new MockConnectionToClient( 138 owned_connection2_.reset(new MockConnectionToClient(
139 session2_, &host_stub2_, &event_executor2_)); 139 session2_, &host_stub2_, &event_executor2_));
140 connection2_ = owned_connection2_.get(); 140 connection2_ = owned_connection2_.get();
141 141
142 ON_CALL(video_stub_, ProcessVideoPacket(_, _)) 142 ON_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
143 .WillByDefault(DeleteArg<0>()); 143 .WillByDefault(DeleteArg<0>());
144 ON_CALL(video_stub2_, ProcessVideoPacket(_, _)) 144 ON_CALL(video_stub2_, ProcessVideoPacketPtr(_, _))
145 .WillByDefault(DeleteArg<0>()); 145 .WillByDefault(DeleteArg<0>());
146 ON_CALL(*connection_, video_stub()) 146 ON_CALL(*connection_, video_stub())
147 .WillByDefault(Return(&video_stub_)); 147 .WillByDefault(Return(&video_stub_));
148 ON_CALL(*connection_, client_stub()) 148 ON_CALL(*connection_, client_stub())
149 .WillByDefault(Return(&client_stub_)); 149 .WillByDefault(Return(&client_stub_));
150 ON_CALL(*connection_, session()) 150 ON_CALL(*connection_, session())
151 .WillByDefault(Return(session_)); 151 .WillByDefault(Return(session_));
152 ON_CALL(*connection2_, video_stub()) 152 ON_CALL(*connection2_, video_stub())
153 .WillByDefault(Return(&video_stub2_)); 153 .WillByDefault(Return(&video_stub2_));
154 ON_CALL(*connection2_, client_stub()) 154 ON_CALL(*connection2_, client_stub())
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
270 270
271 TEST_F(ChromotingHostTest, DISABLED_Connect) { 271 TEST_F(ChromotingHostTest, DISABLED_Connect) {
272 host_->Start(); 272 host_->Start();
273 273
274 // When the video packet is received we first shutdown ChromotingHost 274 // When the video packet is received we first shutdown ChromotingHost
275 // then execute the done task. 275 // then execute the done task.
276 { 276 {
277 InSequence s; 277 InSequence s;
278 EXPECT_CALL(*disconnect_window_, Show(_, _)) 278 EXPECT_CALL(*disconnect_window_, Show(_, _))
279 .Times(0); 279 .Times(0);
280 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 280 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
281 .WillOnce(DoAll( 281 .WillOnce(DoAll(
282 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost), 282 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost),
283 RunDoneTask())) 283 RunDoneTask()))
284 .RetiresOnSaturation(); 284 .RetiresOnSaturation();
285 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 285 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
286 .Times(AnyNumber()); 286 .Times(AnyNumber());
287 EXPECT_CALL(*connection_, Disconnect()) 287 EXPECT_CALL(*connection_, Disconnect())
288 .RetiresOnSaturation(); 288 .RetiresOnSaturation();
289 } 289 }
290 SimulateClientConnection(0, true); 290 SimulateClientConnection(0, true);
291 message_loop_.Run(); 291 message_loop_.Run();
292 } 292 }
293 293
294 TEST_F(ChromotingHostTest, DISABLED_Reconnect) { 294 TEST_F(ChromotingHostTest, DISABLED_Reconnect) {
295 host_->Start(); 295 host_->Start();
296 296
297 // When the video packet is received we first disconnect the mock 297 // When the video packet is received we first disconnect the mock
298 // connection. 298 // connection.
299 { 299 {
300 InSequence s; 300 InSequence s;
301 EXPECT_CALL(*disconnect_window_, Show(_, _)) 301 EXPECT_CALL(*disconnect_window_, Show(_, _))
302 .Times(0); 302 .Times(0);
303 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 303 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
304 .WillOnce(DoAll( 304 .WillOnce(DoAll(
305 InvokeWithoutArgs(this, &ChromotingHostTest::RemoveClientSession), 305 InvokeWithoutArgs(this, &ChromotingHostTest::RemoveClientSession),
306 RunDoneTask())) 306 RunDoneTask()))
307 .RetiresOnSaturation(); 307 .RetiresOnSaturation();
308 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 308 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
309 .Times(AnyNumber()); 309 .Times(AnyNumber());
310 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 310 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
311 .Times(AnyNumber()); 311 .Times(AnyNumber());
312 } 312 }
313 313
314 // If Disconnect() is called we can break the main message loop. 314 // If Disconnect() is called we can break the main message loop.
315 EXPECT_CALL(*connection_, Disconnect()) 315 EXPECT_CALL(*connection_, Disconnect())
316 .WillOnce(QuitMainMessageLoop(&message_loop_)) 316 .WillOnce(QuitMainMessageLoop(&message_loop_))
317 .RetiresOnSaturation(); 317 .RetiresOnSaturation();
318 318
319 SimulateClientConnection(0, true); 319 SimulateClientConnection(0, true);
320 message_loop_.Run(); 320 message_loop_.Run();
321 321
322 // Connect the client again. 322 // Connect the client again.
323 { 323 {
324 InSequence s; 324 InSequence s;
325 EXPECT_CALL(*disconnect_window_, Show(_, _)) 325 EXPECT_CALL(*disconnect_window_, Show(_, _))
326 .Times(0); 326 .Times(0);
327 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 327 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
328 .WillOnce(DoAll( 328 .WillOnce(DoAll(
329 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost), 329 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost),
330 RunDoneTask())) 330 RunDoneTask()))
331 .RetiresOnSaturation(); 331 .RetiresOnSaturation();
332 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 332 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
333 .Times(AnyNumber()); 333 .Times(AnyNumber());
334 } 334 }
335 335
336 EXPECT_CALL(*connection_, Disconnect()) 336 EXPECT_CALL(*connection_, Disconnect())
337 .RetiresOnSaturation(); 337 .RetiresOnSaturation();
338 338
339 SimulateClientConnection(0, true); 339 SimulateClientConnection(0, true);
340 message_loop_.Run(); 340 message_loop_.Run();
341 } 341 }
342 342
343 TEST_F(ChromotingHostTest, DISABLED_ConnectTwice) { 343 TEST_F(ChromotingHostTest, DISABLED_ConnectTwice) {
344 host_->Start(); 344 host_->Start();
345 345
346 // When a video packet is received we connect the second mock 346 // When a video packet is received we connect the second mock
347 // connection. 347 // connection.
348 { 348 {
349 InSequence s; 349 InSequence s;
350 EXPECT_CALL(*disconnect_window_, Show(_, _)) 350 EXPECT_CALL(*disconnect_window_, Show(_, _))
351 .Times(0); 351 .Times(0);
352 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 352 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
353 .WillOnce(DoAll( 353 .WillOnce(DoAll(
354 InvokeWithoutArgs( 354 InvokeWithoutArgs(
355 CreateFunctor( 355 CreateFunctor(
356 this, 356 this,
357 &ChromotingHostTest::SimulateClientConnection, 1, true)), 357 &ChromotingHostTest::SimulateClientConnection, 1, true)),
358 RunDoneTask())) 358 RunDoneTask()))
359 .RetiresOnSaturation(); 359 .RetiresOnSaturation();
360 EXPECT_CALL(*disconnect_window_, Show(_, _)) 360 EXPECT_CALL(*disconnect_window_, Show(_, _))
361 .Times(0); 361 .Times(0);
362 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 362 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
363 .Times(AnyNumber()); 363 .Times(AnyNumber());
364 EXPECT_CALL(video_stub2_, ProcessVideoPacket(_, _)) 364 EXPECT_CALL(video_stub2_, ProcessVideoPacketPtr(_, _))
365 .WillOnce(DoAll( 365 .WillOnce(DoAll(
366 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost), 366 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost),
367 RunDoneTask())) 367 RunDoneTask()))
368 .RetiresOnSaturation(); 368 .RetiresOnSaturation();
369 EXPECT_CALL(video_stub2_, ProcessVideoPacket(_, _)) 369 EXPECT_CALL(video_stub2_, ProcessVideoPacketPtr(_, _))
370 .Times(AnyNumber()); 370 .Times(AnyNumber());
371 } 371 }
372 372
373 EXPECT_CALL(*connection_, Disconnect()) 373 EXPECT_CALL(*connection_, Disconnect())
374 .RetiresOnSaturation(); 374 .RetiresOnSaturation();
375 EXPECT_CALL(*connection2_, Disconnect()) 375 EXPECT_CALL(*connection2_, Disconnect())
376 .RetiresOnSaturation(); 376 .RetiresOnSaturation();
377 377
378 SimulateClientConnection(0, true); 378 SimulateClientConnection(0, true);
379 message_loop_.Run(); 379 message_loop_.Run();
380 } 380 }
381 381
382 } // namespace remoting 382 } // namespace remoting
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698