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

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

Issue 13983010: Use webrtc::DesktopCapturer for screen capturer implementation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 7 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/host/desktop_session_win.cc ('k') | remoting/host/ipc_video_frame_capturer.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) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/callback.h" 7 #include "base/callback.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 14 matching lines...) Expand all
25 #include "remoting/host/desktop_process.h" 25 #include "remoting/host/desktop_process.h"
26 #include "remoting/host/desktop_session.h" 26 #include "remoting/host/desktop_session.h"
27 #include "remoting/host/desktop_session_connector.h" 27 #include "remoting/host/desktop_session_connector.h"
28 #include "remoting/host/desktop_session_proxy.h" 28 #include "remoting/host/desktop_session_proxy.h"
29 #include "remoting/host/host_mock_objects.h" 29 #include "remoting/host/host_mock_objects.h"
30 #include "remoting/host/ipc_desktop_environment.h" 30 #include "remoting/host/ipc_desktop_environment.h"
31 #include "remoting/protocol/protocol_mock_objects.h" 31 #include "remoting/protocol/protocol_mock_objects.h"
32 #include "testing/gmock/include/gmock/gmock.h" 32 #include "testing/gmock/include/gmock/gmock.h"
33 #include "testing/gtest/include/gtest/gtest.h" 33 #include "testing/gtest/include/gtest/gtest.h"
34 #include "third_party/skia/include/core/SkRegion.h" 34 #include "third_party/skia/include/core/SkRegion.h"
35 #include "third_party/webrtc/modules/desktop_capture/desktop_geometry.h"
36 #include "third_party/webrtc/modules/desktop_capture/desktop_region.h"
35 37
36 using testing::_; 38 using testing::_;
37 using testing::AnyNumber; 39 using testing::AnyNumber;
38 using testing::AtLeast; 40 using testing::AtLeast;
39 using testing::AtMost; 41 using testing::AtMost;
40 using testing::Return; 42 using testing::Return;
41 using testing::ReturnRef; 43 using testing::ReturnRef;
42 44
43 namespace remoting { 45 namespace remoting {
44 46
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 194
193 // Represents the desktop process running in a user session. 195 // Represents the desktop process running in a user session.
194 scoped_ptr<DesktopProcess> desktop_process_; 196 scoped_ptr<DesktopProcess> desktop_process_;
195 197
196 // Input injector owned by |desktop_process_|. 198 // Input injector owned by |desktop_process_|.
197 MockInputInjector* remote_input_injector_; 199 MockInputInjector* remote_input_injector_;
198 200
199 // The last |terminal_id| passed to ConnectTermina(); 201 // The last |terminal_id| passed to ConnectTermina();
200 int terminal_id_; 202 int terminal_id_;
201 203
202 media::MockScreenCapturerDelegate screen_capturer_delegate_; 204 media::MockScreenCapturerCallback screen_capturer_callback_;
203 205
204 MockClientSessionControl client_session_control_; 206 MockClientSessionControl client_session_control_;
205 base::WeakPtrFactory<ClientSessionControl> client_session_control_factory_; 207 base::WeakPtrFactory<ClientSessionControl> client_session_control_factory_;
206 }; 208 };
207 209
208 IpcDesktopEnvironmentTest::IpcDesktopEnvironmentTest() 210 IpcDesktopEnvironmentTest::IpcDesktopEnvironmentTest()
209 : message_loop_(base::MessageLoop::TYPE_UI), 211 : message_loop_(base::MessageLoop::TYPE_UI),
210 client_jid_("user@domain/rest-of-jid"), 212 client_jid_("user@domain/rest-of-jid"),
211 clipboard_stub_(NULL), 213 clipboard_stub_(NULL),
212 remote_input_injector_(NULL), 214 remote_input_injector_(NULL),
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
433 435
434 // Tests that the video capturer receives a frame over IPC. 436 // Tests that the video capturer receives a frame over IPC.
435 TEST_F(IpcDesktopEnvironmentTest, CaptureFrame) { 437 TEST_F(IpcDesktopEnvironmentTest, CaptureFrame) {
436 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( 438 scoped_ptr<protocol::MockClipboardStub> clipboard_stub(
437 new protocol::MockClipboardStub()); 439 new protocol::MockClipboardStub());
438 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) 440 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_))
439 .Times(0); 441 .Times(0);
440 442
441 // Start the input injector and screen capturer. 443 // Start the input injector and screen capturer.
442 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>()); 444 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>());
443 video_capturer_->Start(&screen_capturer_delegate_); 445 video_capturer_->Start(&screen_capturer_callback_);
444 446
445 // Run the message loop until the desktop is attached. 447 // Run the message loop until the desktop is attached.
446 setup_run_loop_->Run(); 448 setup_run_loop_->Run();
447 449
448 // Input injector should receive no events. 450 // Input injector should receive no events.
449 EXPECT_CALL(*remote_input_injector_, InjectClipboardEvent(_)) 451 EXPECT_CALL(*remote_input_injector_, InjectClipboardEvent(_))
450 .Times(0); 452 .Times(0);
451 EXPECT_CALL(*remote_input_injector_, InjectKeyEvent(_)) 453 EXPECT_CALL(*remote_input_injector_, InjectKeyEvent(_))
452 .Times(0); 454 .Times(0);
453 EXPECT_CALL(*remote_input_injector_, InjectMouseEvent(_)) 455 EXPECT_CALL(*remote_input_injector_, InjectMouseEvent(_))
454 .Times(0); 456 .Times(0);
455 457
456 // Stop the test when the first frame is captured. 458 // Stop the test when the first frame is captured.
457 EXPECT_CALL(screen_capturer_delegate_, OnCaptureCompleted(_)) 459 EXPECT_CALL(screen_capturer_callback_, OnCaptureCompleted(_))
458 .WillOnce(InvokeWithoutArgs( 460 .WillOnce(InvokeWithoutArgs(
459 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); 461 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment));
460 462
461 // Capture a single frame. 463 // Capture a single frame.
462 video_capturer_->CaptureFrame(); 464 video_capturer_->Capture(webrtc::DesktopRegion());
463 465
464 task_runner_ = NULL; 466 task_runner_ = NULL;
465 io_task_runner_ = NULL; 467 io_task_runner_ = NULL;
466 main_run_loop_.Run(); 468 main_run_loop_.Run();
467 } 469 }
468 470
469 // Tests that attaching to a new desktop works. 471 // Tests that attaching to a new desktop works.
470 TEST_F(IpcDesktopEnvironmentTest, Reattach) { 472 TEST_F(IpcDesktopEnvironmentTest, Reattach) {
471 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( 473 scoped_ptr<protocol::MockClipboardStub> clipboard_stub(
472 new protocol::MockClipboardStub()); 474 new protocol::MockClipboardStub());
473 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) 475 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_))
474 .Times(0); 476 .Times(0);
475 477
476 // Start the input injector and screen capturer. 478 // Start the input injector and screen capturer.
477 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>()); 479 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>());
478 video_capturer_->Start(&screen_capturer_delegate_); 480 video_capturer_->Start(&screen_capturer_callback_);
479 481
480 // Run the message loop until the desktop is attached. 482 // Run the message loop until the desktop is attached.
481 setup_run_loop_->Run(); 483 setup_run_loop_->Run();
482 484
483 // Create and start a new desktop process object. 485 // Create and start a new desktop process object.
484 setup_run_loop_.reset(new base::RunLoop()); 486 setup_run_loop_.reset(new base::RunLoop());
485 DestoyDesktopProcess(); 487 DestoyDesktopProcess();
486 CreateDesktopProcess(); 488 CreateDesktopProcess();
487 setup_run_loop_->Run(); 489 setup_run_loop_->Run();
488 490
(...skipping 20 matching lines...) Expand all
509 clipboard_stub_ = clipboard_stub.get(); 511 clipboard_stub_ = clipboard_stub.get();
510 512
511 // Stop the test when a clipboard event is received from the desktop process. 513 // Stop the test when a clipboard event is received from the desktop process.
512 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) 514 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_))
513 .Times(1) 515 .Times(1)
514 .WillOnce(InvokeWithoutArgs( 516 .WillOnce(InvokeWithoutArgs(
515 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); 517 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment));
516 518
517 // Start the input injector and screen capturer. 519 // Start the input injector and screen capturer.
518 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>()); 520 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>());
519 video_capturer_->Start(&screen_capturer_delegate_); 521 video_capturer_->Start(&screen_capturer_callback_);
520 522
521 // Run the message loop until the desktop is attached. 523 // Run the message loop until the desktop is attached.
522 setup_run_loop_->Run(); 524 setup_run_loop_->Run();
523 525
524 // Expect a single clipboard event. 526 // Expect a single clipboard event.
525 EXPECT_CALL(*remote_input_injector_, InjectClipboardEvent(_)) 527 EXPECT_CALL(*remote_input_injector_, InjectClipboardEvent(_))
526 .Times(1) 528 .Times(1)
527 .WillOnce(Invoke(this, 529 .WillOnce(Invoke(this,
528 &IpcDesktopEnvironmentTest::ReflectClipboardEvent)); 530 &IpcDesktopEnvironmentTest::ReflectClipboardEvent));
529 EXPECT_CALL(*remote_input_injector_, InjectKeyEvent(_)) 531 EXPECT_CALL(*remote_input_injector_, InjectKeyEvent(_))
(...skipping 14 matching lines...) Expand all
544 546
545 // Tests injection of key events. 547 // Tests injection of key events.
546 TEST_F(IpcDesktopEnvironmentTest, InjectKeyEvent) { 548 TEST_F(IpcDesktopEnvironmentTest, InjectKeyEvent) {
547 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( 549 scoped_ptr<protocol::MockClipboardStub> clipboard_stub(
548 new protocol::MockClipboardStub()); 550 new protocol::MockClipboardStub());
549 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) 551 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_))
550 .Times(0); 552 .Times(0);
551 553
552 // Start the input injector and screen capturer. 554 // Start the input injector and screen capturer.
553 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>()); 555 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>());
554 video_capturer_->Start(&screen_capturer_delegate_); 556 video_capturer_->Start(&screen_capturer_callback_);
555 557
556 // Run the message loop until the desktop is attached. 558 // Run the message loop until the desktop is attached.
557 setup_run_loop_->Run(); 559 setup_run_loop_->Run();
558 560
559 // Expect a single key event. 561 // Expect a single key event.
560 EXPECT_CALL(*remote_input_injector_, InjectClipboardEvent(_)) 562 EXPECT_CALL(*remote_input_injector_, InjectClipboardEvent(_))
561 .Times(0); 563 .Times(0);
562 EXPECT_CALL(*remote_input_injector_, InjectKeyEvent(_)) 564 EXPECT_CALL(*remote_input_injector_, InjectKeyEvent(_))
563 .Times(AtLeast(1)) 565 .Times(AtLeast(1))
564 .WillRepeatedly(InvokeWithoutArgs( 566 .WillRepeatedly(InvokeWithoutArgs(
(...skipping 14 matching lines...) Expand all
579 581
580 // Tests injection of mouse events. 582 // Tests injection of mouse events.
581 TEST_F(IpcDesktopEnvironmentTest, InjectMouseEvent) { 583 TEST_F(IpcDesktopEnvironmentTest, InjectMouseEvent) {
582 scoped_ptr<protocol::MockClipboardStub> clipboard_stub( 584 scoped_ptr<protocol::MockClipboardStub> clipboard_stub(
583 new protocol::MockClipboardStub()); 585 new protocol::MockClipboardStub());
584 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_)) 586 EXPECT_CALL(*clipboard_stub, InjectClipboardEvent(_))
585 .Times(0); 587 .Times(0);
586 588
587 // Start the input injector and screen capturer. 589 // Start the input injector and screen capturer.
588 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>()); 590 input_injector_->Start(clipboard_stub.PassAs<protocol::ClipboardStub>());
589 video_capturer_->Start(&screen_capturer_delegate_); 591 video_capturer_->Start(&screen_capturer_callback_);
590 592
591 // Run the message loop until the desktop is attached. 593 // Run the message loop until the desktop is attached.
592 setup_run_loop_->Run(); 594 setup_run_loop_->Run();
593 595
594 // Expect a single mouse event. 596 // Expect a single mouse event.
595 EXPECT_CALL(*remote_input_injector_, InjectClipboardEvent(_)) 597 EXPECT_CALL(*remote_input_injector_, InjectClipboardEvent(_))
596 .Times(0); 598 .Times(0);
597 EXPECT_CALL(*remote_input_injector_, InjectKeyEvent(_)) 599 EXPECT_CALL(*remote_input_injector_, InjectKeyEvent(_))
598 .Times(0); 600 .Times(0);
599 EXPECT_CALL(*remote_input_injector_, InjectMouseEvent(_)) 601 EXPECT_CALL(*remote_input_injector_, InjectMouseEvent(_))
600 .Times(1) 602 .Times(1)
601 .WillOnce(InvokeWithoutArgs( 603 .WillOnce(InvokeWithoutArgs(
602 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment)); 604 this, &IpcDesktopEnvironmentTest::DeleteDesktopEnvironment));
603 605
604 // Send a mouse event. 606 // Send a mouse event.
605 protocol::MouseEvent event; 607 protocol::MouseEvent event;
606 event.set_x(0); 608 event.set_x(0);
607 event.set_y(0); 609 event.set_y(0);
608 input_injector_->InjectMouseEvent(event); 610 input_injector_->InjectMouseEvent(event);
609 611
610 task_runner_ = NULL; 612 task_runner_ = NULL;
611 io_task_runner_ = NULL; 613 io_task_runner_ = NULL;
612 main_run_loop_.Run(); 614 main_run_loop_.Run();
613 } 615 }
614 616
615 } // namespace remoting 617 } // namespace remoting
OLDNEW
« no previous file with comments | « remoting/host/desktop_session_win.cc ('k') | remoting/host/ipc_video_frame_capturer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698