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

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, 8 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/client/rectangle_update_decoder.cc ('k') | remoting/host/screen_recorder.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) 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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 274
275 TEST_F(ChromotingHostTest, DISABLED_Connect) { 275 TEST_F(ChromotingHostTest, DISABLED_Connect) {
276 host_->Start(); 276 host_->Start();
277 277
278 // When the video packet is received we first shutdown ChromotingHost 278 // When the video packet is received we first shutdown ChromotingHost
279 // then execute the done task. 279 // then execute the done task.
280 { 280 {
281 InSequence s; 281 InSequence s;
282 EXPECT_CALL(*disconnect_window_, Show(_, _)) 282 EXPECT_CALL(*disconnect_window_, Show(_, _))
283 .Times(0); 283 .Times(0);
284 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 284 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
285 .WillOnce(DoAll( 285 .WillOnce(DoAll(
286 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost), 286 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost),
287 RunDoneTask())) 287 RunDoneTask()))
288 .RetiresOnSaturation(); 288 .RetiresOnSaturation();
289 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 289 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
290 .Times(AnyNumber()); 290 .Times(AnyNumber());
291 EXPECT_CALL(*connection_, Disconnect()) 291 EXPECT_CALL(*connection_, Disconnect())
292 .RetiresOnSaturation(); 292 .RetiresOnSaturation();
293 } 293 }
294 SimulateClientConnection(0, true); 294 SimulateClientConnection(0, true);
295 message_loop_.Run(); 295 message_loop_.Run();
296 } 296 }
297 297
298 TEST_F(ChromotingHostTest, DISABLED_Reconnect) { 298 TEST_F(ChromotingHostTest, DISABLED_Reconnect) {
299 host_->Start(); 299 host_->Start();
300 300
301 // When the video packet is received we first disconnect the mock 301 // When the video packet is received we first disconnect the mock
302 // connection. 302 // connection.
303 { 303 {
304 InSequence s; 304 InSequence s;
305 EXPECT_CALL(*disconnect_window_, Show(_, _)) 305 EXPECT_CALL(*disconnect_window_, Show(_, _))
306 .Times(0); 306 .Times(0);
307 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 307 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
308 .WillOnce(DoAll( 308 .WillOnce(DoAll(
309 InvokeWithoutArgs(this, &ChromotingHostTest::RemoveClientSession), 309 InvokeWithoutArgs(this, &ChromotingHostTest::RemoveClientSession),
310 RunDoneTask())) 310 RunDoneTask()))
311 .RetiresOnSaturation(); 311 .RetiresOnSaturation();
312 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 312 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
313 .Times(AnyNumber()); 313 .Times(AnyNumber());
314 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 314 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
315 .Times(AnyNumber()); 315 .Times(AnyNumber());
316 } 316 }
317 317
318 // If Disconnect() is called we can break the main message loop. 318 // If Disconnect() is called we can break the main message loop.
319 EXPECT_CALL(*connection_, Disconnect()) 319 EXPECT_CALL(*connection_, Disconnect())
320 .WillOnce(QuitMainMessageLoop(&message_loop_)) 320 .WillOnce(QuitMainMessageLoop(&message_loop_))
321 .RetiresOnSaturation(); 321 .RetiresOnSaturation();
322 322
323 SimulateClientConnection(0, true); 323 SimulateClientConnection(0, true);
324 message_loop_.Run(); 324 message_loop_.Run();
325 325
326 // Connect the client again. 326 // Connect the client again.
327 { 327 {
328 InSequence s; 328 InSequence s;
329 EXPECT_CALL(*disconnect_window_, Show(_, _)) 329 EXPECT_CALL(*disconnect_window_, Show(_, _))
330 .Times(0); 330 .Times(0);
331 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 331 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
332 .WillOnce(DoAll( 332 .WillOnce(DoAll(
333 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost), 333 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost),
334 RunDoneTask())) 334 RunDoneTask()))
335 .RetiresOnSaturation(); 335 .RetiresOnSaturation();
336 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 336 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
337 .Times(AnyNumber()); 337 .Times(AnyNumber());
338 } 338 }
339 339
340 EXPECT_CALL(*connection_, Disconnect()) 340 EXPECT_CALL(*connection_, Disconnect())
341 .RetiresOnSaturation(); 341 .RetiresOnSaturation();
342 342
343 SimulateClientConnection(0, true); 343 SimulateClientConnection(0, true);
344 message_loop_.Run(); 344 message_loop_.Run();
345 } 345 }
346 346
347 TEST_F(ChromotingHostTest, DISABLED_ConnectTwice) { 347 TEST_F(ChromotingHostTest, DISABLED_ConnectTwice) {
348 host_->Start(); 348 host_->Start();
349 349
350 // When a video packet is received we connect the second mock 350 // When a video packet is received we connect the second mock
351 // connection. 351 // connection.
352 { 352 {
353 InSequence s; 353 InSequence s;
354 EXPECT_CALL(*disconnect_window_, Show(_, _)) 354 EXPECT_CALL(*disconnect_window_, Show(_, _))
355 .Times(0); 355 .Times(0);
356 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 356 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
357 .WillOnce(DoAll( 357 .WillOnce(DoAll(
358 InvokeWithoutArgs( 358 InvokeWithoutArgs(
359 CreateFunctor( 359 CreateFunctor(
360 this, 360 this,
361 &ChromotingHostTest::SimulateClientConnection, 1, true)), 361 &ChromotingHostTest::SimulateClientConnection, 1, true)),
362 RunDoneTask())) 362 RunDoneTask()))
363 .RetiresOnSaturation(); 363 .RetiresOnSaturation();
364 EXPECT_CALL(*disconnect_window_, Show(_, _)) 364 EXPECT_CALL(*disconnect_window_, Show(_, _))
365 .Times(0); 365 .Times(0);
366 EXPECT_CALL(video_stub_, ProcessVideoPacket(_, _)) 366 EXPECT_CALL(video_stub_, ProcessVideoPacketPtr(_, _))
367 .Times(AnyNumber()); 367 .Times(AnyNumber());
368 EXPECT_CALL(video_stub2_, ProcessVideoPacket(_, _)) 368 EXPECT_CALL(video_stub2_, ProcessVideoPacketPtr(_, _))
369 .WillOnce(DoAll( 369 .WillOnce(DoAll(
370 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost), 370 InvokeWithoutArgs(this, &ChromotingHostTest::ShutdownHost),
371 RunDoneTask())) 371 RunDoneTask()))
372 .RetiresOnSaturation(); 372 .RetiresOnSaturation();
373 EXPECT_CALL(video_stub2_, ProcessVideoPacket(_, _)) 373 EXPECT_CALL(video_stub2_, ProcessVideoPacketPtr(_, _))
374 .Times(AnyNumber()); 374 .Times(AnyNumber());
375 } 375 }
376 376
377 EXPECT_CALL(*connection_, Disconnect()) 377 EXPECT_CALL(*connection_, Disconnect())
378 .RetiresOnSaturation(); 378 .RetiresOnSaturation();
379 EXPECT_CALL(*connection2_, Disconnect()) 379 EXPECT_CALL(*connection2_, Disconnect())
380 .RetiresOnSaturation(); 380 .RetiresOnSaturation();
381 381
382 SimulateClientConnection(0, true); 382 SimulateClientConnection(0, true);
383 message_loop_.Run(); 383 message_loop_.Run();
384 } 384 }
385 385
386 } // namespace remoting 386 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/client/rectangle_update_decoder.cc ('k') | remoting/host/screen_recorder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698