| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. | 2 * Copyright 2013 The WebRTC project authors. All Rights Reserved. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license | 4 * Use of this source code is governed by a BSD-style license |
| 5 * that can be found in the LICENSE file in the root of the source | 5 * that can be found in the LICENSE file in the root of the source |
| 6 * tree. An additional intellectual property rights grant can be found | 6 * tree. An additional intellectual property rights grant can be found |
| 7 * in the file PATENTS. All contributing project authors may | 7 * in the file PATENTS. All contributing project authors may |
| 8 * be found in the AUTHORS file in the root of the source tree. | 8 * be found in the AUTHORS file in the root of the source tree. |
| 9 */ | 9 */ |
| 10 | 10 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 class RemoteVideoCapturerTest : public testing::Test, | 27 class RemoteVideoCapturerTest : public testing::Test, |
| 28 public sigslot::has_slots<> { | 28 public sigslot::has_slots<> { |
| 29 protected: | 29 protected: |
| 30 RemoteVideoCapturerTest() | 30 RemoteVideoCapturerTest() |
| 31 : captured_frame_num_(0), | 31 : captured_frame_num_(0), |
| 32 capture_state_(cricket::CS_STOPPED) {} | 32 capture_state_(cricket::CS_STOPPED) {} |
| 33 | 33 |
| 34 virtual void SetUp() { | 34 virtual void SetUp() { |
| 35 capturer_.SignalStateChange.connect( | 35 capturer_.SignalStateChange.connect( |
| 36 this, &RemoteVideoCapturerTest::OnStateChange); | 36 this, &RemoteVideoCapturerTest::OnStateChange); |
| 37 capturer_.SignalVideoFrame.connect( |
| 38 this, &RemoteVideoCapturerTest::OnVideoFrame); |
| 37 } | 39 } |
| 38 | 40 |
| 39 ~RemoteVideoCapturerTest() { | 41 ~RemoteVideoCapturerTest() { |
| 40 capturer_.SignalStateChange.disconnect(this); | 42 capturer_.SignalStateChange.disconnect(this); |
| 43 capturer_.SignalVideoFrame.disconnect(this); |
| 41 } | 44 } |
| 42 | 45 |
| 43 int captured_frame_num() const { | 46 int captured_frame_num() const { |
| 44 return captured_frame_num_; | 47 return captured_frame_num_; |
| 45 } | 48 } |
| 46 | 49 |
| 47 CaptureState capture_state() const { | 50 CaptureState capture_state() const { |
| 48 return capture_state_; | 51 return capture_state_; |
| 49 } | 52 } |
| 50 | 53 |
| 51 webrtc::RemoteVideoCapturer capturer_; | 54 webrtc::RemoteVideoCapturer capturer_; |
| 52 | 55 |
| 53 private: | 56 private: |
| 54 void OnStateChange(VideoCapturer* capturer, | 57 void OnStateChange(VideoCapturer* capturer, |
| 55 CaptureState capture_state) { | 58 CaptureState capture_state) { |
| 56 EXPECT_EQ(&capturer_, capturer); | 59 EXPECT_EQ(&capturer_, capturer); |
| 57 capture_state_ = capture_state; | 60 capture_state_ = capture_state; |
| 58 } | 61 } |
| 59 | 62 |
| 63 void OnVideoFrame(VideoCapturer* capturer, const VideoFrame* frame) { |
| 64 EXPECT_EQ(&capturer_, capturer); |
| 65 ++captured_frame_num_; |
| 66 } |
| 67 |
| 60 int captured_frame_num_; | 68 int captured_frame_num_; |
| 61 CaptureState capture_state_; | 69 CaptureState capture_state_; |
| 62 }; | 70 }; |
| 63 | 71 |
| 64 TEST_F(RemoteVideoCapturerTest, StartStop) { | 72 TEST_F(RemoteVideoCapturerTest, StartStop) { |
| 65 // Start | 73 // Start |
| 66 EXPECT_TRUE( | 74 EXPECT_TRUE( |
| 67 capturer_.StartCapturing(VideoFormat(kTestFormat))); | 75 capturer_.StartCapturing(VideoFormat(kTestFormat))); |
| 68 EXPECT_TRUE_WAIT((cricket::CS_RUNNING == capture_state()), kMaxWaitMs); | 76 EXPECT_TRUE_WAIT((cricket::CS_RUNNING == capture_state()), kMaxWaitMs); |
| 69 EXPECT_EQ(VideoFormat(kTestFormat), | 77 EXPECT_EQ(VideoFormat(kTestFormat), |
| (...skipping 18 matching lines...) Expand all Loading... |
| 88 TEST_F(RemoteVideoCapturerTest, GetBestCaptureFormat) { | 96 TEST_F(RemoteVideoCapturerTest, GetBestCaptureFormat) { |
| 89 VideoFormat desired = VideoFormat(kTestFormat); | 97 VideoFormat desired = VideoFormat(kTestFormat); |
| 90 EXPECT_FALSE(capturer_.GetBestCaptureFormat(desired, NULL)); | 98 EXPECT_FALSE(capturer_.GetBestCaptureFormat(desired, NULL)); |
| 91 | 99 |
| 92 VideoFormat expected_format = VideoFormat(kTestFormat); | 100 VideoFormat expected_format = VideoFormat(kTestFormat); |
| 93 expected_format.fourcc = cricket::FOURCC_I420; | 101 expected_format.fourcc = cricket::FOURCC_I420; |
| 94 VideoFormat best_format; | 102 VideoFormat best_format; |
| 95 EXPECT_TRUE(capturer_.GetBestCaptureFormat(desired, &best_format)); | 103 EXPECT_TRUE(capturer_.GetBestCaptureFormat(desired, &best_format)); |
| 96 EXPECT_EQ(expected_format, best_format); | 104 EXPECT_EQ(expected_format, best_format); |
| 97 } | 105 } |
| 106 |
| 107 TEST_F(RemoteVideoCapturerTest, InputFrame) { |
| 108 EXPECT_EQ(0, captured_frame_num()); |
| 109 |
| 110 cricket::WebRtcVideoFrame test_frame; |
| 111 capturer_.SignalVideoFrame(&capturer_, &test_frame); |
| 112 EXPECT_EQ(1, captured_frame_num()); |
| 113 capturer_.SignalVideoFrame(&capturer_, &test_frame); |
| 114 EXPECT_EQ(2, captured_frame_num()); |
| 115 } |
| OLD | NEW |