| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. | 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/macros.h" | 10 #include "base/macros.h" |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 | 463 |
| 464 TEST_P(ConnectionTest, Events) { | 464 TEST_P(ConnectionTest, Events) { |
| 465 Connect(); | 465 Connect(); |
| 466 | 466 |
| 467 KeyEvent event; | 467 KeyEvent event; |
| 468 event.set_usb_keycode(3); | 468 event.set_usb_keycode(3); |
| 469 event.set_pressed(true); | 469 event.set_pressed(true); |
| 470 | 470 |
| 471 base::RunLoop run_loop; | 471 base::RunLoop run_loop; |
| 472 | 472 |
| 473 EXPECT_CALL(host_event_handler_, OnInputEventReceived(_)); | |
| 474 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsKeyEvent(event))) | 473 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsKeyEvent(event))) |
| 475 .WillOnce(QuitRunLoop(&run_loop)); | 474 .WillOnce(QuitRunLoop(&run_loop)); |
| 476 | 475 |
| 477 // Send key event from the client. | 476 // Send key event from the client. |
| 478 client_connection_->input_stub()->InjectKeyEvent(event); | 477 client_connection_->input_stub()->InjectKeyEvent(event); |
| 479 | 478 |
| 480 run_loop.Run(); | 479 run_loop.Run(); |
| 481 } | 480 } |
| 482 | 481 |
| 483 TEST_P(ConnectionTest, Video) { | 482 TEST_P(ConnectionTest, Video) { |
| (...skipping 24 matching lines...) Expand all Loading... |
| 508 | 507 |
| 509 TEST_P(ConnectionTest, DestroyOnIncomingMessage) { | 508 TEST_P(ConnectionTest, DestroyOnIncomingMessage) { |
| 510 Connect(); | 509 Connect(); |
| 511 | 510 |
| 512 KeyEvent event; | 511 KeyEvent event; |
| 513 event.set_usb_keycode(3); | 512 event.set_usb_keycode(3); |
| 514 event.set_pressed(true); | 513 event.set_pressed(true); |
| 515 | 514 |
| 516 base::RunLoop run_loop; | 515 base::RunLoop run_loop; |
| 517 | 516 |
| 518 EXPECT_CALL(host_event_handler_, OnInputEventReceived(_)); | |
| 519 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsKeyEvent(event))) | 517 EXPECT_CALL(host_input_stub_, InjectKeyEvent(EqualsKeyEvent(event))) |
| 520 .WillOnce(DoAll(InvokeWithoutArgs(this, &ConnectionTest::DestroyHost), | 518 .WillOnce(DoAll(InvokeWithoutArgs(this, &ConnectionTest::DestroyHost), |
| 521 QuitRunLoop(&run_loop))); | 519 QuitRunLoop(&run_loop))); |
| 522 | 520 |
| 523 // Send key event from the client. | 521 // Send key event from the client. |
| 524 client_connection_->input_stub()->InjectKeyEvent(event); | 522 client_connection_->input_stub()->InjectKeyEvent(event); |
| 525 | 523 |
| 526 run_loop.Run(); | 524 run_loop.Run(); |
| 527 } | 525 } |
| 528 | 526 |
| 529 TEST_P(ConnectionTest, VideoStats) { | 527 TEST_P(ConnectionTest, VideoStats) { |
| 530 // Currently this test only works for WebRTC because for ICE connections stats | 528 // Currently this test only works for WebRTC because for ICE connections stats |
| 531 // are reported by SoftwareVideoRenderer which is not used in this test. | 529 // are reported by SoftwareVideoRenderer which is not used in this test. |
| 532 // TODO(sergeyu): Fix this. | 530 // TODO(sergeyu): Fix this. |
| 533 if (!is_using_webrtc()) | 531 if (!is_using_webrtc()) |
| 534 return; | 532 return; |
| 535 | 533 |
| 536 Connect(); | 534 Connect(); |
| 537 | 535 |
| 538 base::TimeTicks start_time = base::TimeTicks::Now(); | 536 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 539 | 537 |
| 538 scoped_refptr<InputEventTimestampsSourceImpl> input_event_timestamps_source = |
| 539 new InputEventTimestampsSourceImpl(); |
| 540 input_event_timestamps_source->OnEventReceived( |
| 541 InputEventTimestamps{start_time, start_time}); |
| 542 |
| 540 std::unique_ptr<VideoStream> video_stream = | 543 std::unique_ptr<VideoStream> video_stream = |
| 541 host_connection_->StartVideoStream( | 544 host_connection_->StartVideoStream( |
| 542 base::MakeUnique<TestScreenCapturer>()); | 545 base::MakeUnique<TestScreenCapturer>()); |
| 543 | 546 video_stream->SetEventTimestampsSource(input_event_timestamps_source); |
| 544 // Simulate an input invent injected at the start. | |
| 545 video_stream->OnInputEventReceived(start_time.ToInternalValue()); | |
| 546 | 547 |
| 547 WaitFirstVideoFrame(); | 548 WaitFirstVideoFrame(); |
| 548 | 549 |
| 549 base::TimeTicks finish_time = base::TimeTicks::Now(); | 550 base::TimeTicks finish_time = base::TimeTicks::Now(); |
| 550 | 551 |
| 551 WaitFirstFrameStats(); | 552 WaitFirstFrameStats(); |
| 552 | 553 |
| 553 const FrameStats& stats = | 554 const FrameStats& stats = |
| 554 client_video_renderer_.GetFrameStatsConsumer()->received_stats().front(); | 555 client_video_renderer_.GetFrameStatsConsumer()->received_stats().front(); |
| 555 | 556 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 585 std::unique_ptr<AudioStream> audio_stream = | 586 std::unique_ptr<AudioStream> audio_stream = |
| 586 host_connection_->StartAudioStream(base::MakeUnique<TestAudioSource>()); | 587 host_connection_->StartAudioStream(base::MakeUnique<TestAudioSource>()); |
| 587 | 588 |
| 588 // Wait for 1 second worth of audio samples. | 589 // Wait for 1 second worth of audio samples. |
| 589 client_audio_player_.WaitForSamples(kAudioSampleRate * 2); | 590 client_audio_player_.WaitForSamples(kAudioSampleRate * 2); |
| 590 client_audio_player_.Verify(); | 591 client_audio_player_.Verify(); |
| 591 } | 592 } |
| 592 | 593 |
| 593 } // namespace protocol | 594 } // namespace protocol |
| 594 } // namespace remoting | 595 } // namespace remoting |
| OLD | NEW |