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); | |
39 } | 37 } |
40 | 38 |
41 ~RemoteVideoCapturerTest() { | 39 ~RemoteVideoCapturerTest() { |
42 capturer_.SignalStateChange.disconnect(this); | 40 capturer_.SignalStateChange.disconnect(this); |
43 capturer_.SignalVideoFrame.disconnect(this); | |
44 } | 41 } |
45 | 42 |
46 int captured_frame_num() const { | 43 int captured_frame_num() const { |
47 return captured_frame_num_; | 44 return captured_frame_num_; |
48 } | 45 } |
49 | 46 |
50 CaptureState capture_state() const { | 47 CaptureState capture_state() const { |
51 return capture_state_; | 48 return capture_state_; |
52 } | 49 } |
53 | 50 |
54 webrtc::RemoteVideoCapturer capturer_; | 51 webrtc::RemoteVideoCapturer capturer_; |
55 | 52 |
56 private: | 53 private: |
57 void OnStateChange(VideoCapturer* capturer, | 54 void OnStateChange(VideoCapturer* capturer, |
58 CaptureState capture_state) { | 55 CaptureState capture_state) { |
59 EXPECT_EQ(&capturer_, capturer); | 56 EXPECT_EQ(&capturer_, capturer); |
60 capture_state_ = capture_state; | 57 capture_state_ = capture_state; |
61 } | 58 } |
62 | 59 |
63 void OnVideoFrame(VideoCapturer* capturer, const VideoFrame* frame) { | |
64 EXPECT_EQ(&capturer_, capturer); | |
65 ++captured_frame_num_; | |
66 } | |
67 | |
68 int captured_frame_num_; | 60 int captured_frame_num_; |
69 CaptureState capture_state_; | 61 CaptureState capture_state_; |
70 }; | 62 }; |
71 | 63 |
72 TEST_F(RemoteVideoCapturerTest, StartStop) { | 64 TEST_F(RemoteVideoCapturerTest, StartStop) { |
73 // Start | 65 // Start |
74 EXPECT_TRUE( | 66 EXPECT_TRUE( |
75 capturer_.StartCapturing(VideoFormat(kTestFormat))); | 67 capturer_.StartCapturing(VideoFormat(kTestFormat))); |
76 EXPECT_TRUE_WAIT((cricket::CS_RUNNING == capture_state()), kMaxWaitMs); | 68 EXPECT_TRUE_WAIT((cricket::CS_RUNNING == capture_state()), kMaxWaitMs); |
77 EXPECT_EQ(VideoFormat(kTestFormat), | 69 EXPECT_EQ(VideoFormat(kTestFormat), |
(...skipping 18 matching lines...) Expand all Loading... |
96 TEST_F(RemoteVideoCapturerTest, GetBestCaptureFormat) { | 88 TEST_F(RemoteVideoCapturerTest, GetBestCaptureFormat) { |
97 VideoFormat desired = VideoFormat(kTestFormat); | 89 VideoFormat desired = VideoFormat(kTestFormat); |
98 EXPECT_FALSE(capturer_.GetBestCaptureFormat(desired, NULL)); | 90 EXPECT_FALSE(capturer_.GetBestCaptureFormat(desired, NULL)); |
99 | 91 |
100 VideoFormat expected_format = VideoFormat(kTestFormat); | 92 VideoFormat expected_format = VideoFormat(kTestFormat); |
101 expected_format.fourcc = cricket::FOURCC_I420; | 93 expected_format.fourcc = cricket::FOURCC_I420; |
102 VideoFormat best_format; | 94 VideoFormat best_format; |
103 EXPECT_TRUE(capturer_.GetBestCaptureFormat(desired, &best_format)); | 95 EXPECT_TRUE(capturer_.GetBestCaptureFormat(desired, &best_format)); |
104 EXPECT_EQ(expected_format, best_format); | 96 EXPECT_EQ(expected_format, best_format); |
105 } | 97 } |
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 |