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

Side by Side Diff: talk/app/webrtc/remotevideocapturer_unittest.cc

Issue 1655793003: Make cricket::VideoCapturer implement VideoSourceInterface (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Addressed comments. Removed AddSink Created 4 years, 10 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
OLDNEW
1 /* 1 /*
2 * libjingle 2 * libjingle
3 * Copyright 2013 Google Inc. 3 * Copyright 2013 Google Inc.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright notice, 8 * 1. Redistributions of source code must retain the above copyright notice,
9 * this list of conditions and the following disclaimer. 9 * this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright notice, 10 * 2. Redistributions in binary form must reproduce the above copyright notice,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 class RemoteVideoCapturerTest : public testing::Test, 44 class RemoteVideoCapturerTest : public testing::Test,
45 public sigslot::has_slots<> { 45 public sigslot::has_slots<> {
46 protected: 46 protected:
47 RemoteVideoCapturerTest() 47 RemoteVideoCapturerTest()
48 : captured_frame_num_(0), 48 : captured_frame_num_(0),
49 capture_state_(cricket::CS_STOPPED) {} 49 capture_state_(cricket::CS_STOPPED) {}
50 50
51 virtual void SetUp() { 51 virtual void SetUp() {
52 capturer_.SignalStateChange.connect( 52 capturer_.SignalStateChange.connect(
53 this, &RemoteVideoCapturerTest::OnStateChange); 53 this, &RemoteVideoCapturerTest::OnStateChange);
54 capturer_.SignalVideoFrame.connect(
55 this, &RemoteVideoCapturerTest::OnVideoFrame);
56 } 54 }
57 55
58 ~RemoteVideoCapturerTest() { 56 ~RemoteVideoCapturerTest() {
59 capturer_.SignalStateChange.disconnect(this); 57 capturer_.SignalStateChange.disconnect(this);
60 capturer_.SignalVideoFrame.disconnect(this);
61 } 58 }
62 59
63 int captured_frame_num() const { 60 int captured_frame_num() const {
64 return captured_frame_num_; 61 return captured_frame_num_;
65 } 62 }
66 63
67 CaptureState capture_state() const { 64 CaptureState capture_state() const {
68 return capture_state_; 65 return capture_state_;
69 } 66 }
70 67
71 webrtc::RemoteVideoCapturer capturer_; 68 webrtc::RemoteVideoCapturer capturer_;
72 69
73 private: 70 private:
74 void OnStateChange(VideoCapturer* capturer, 71 void OnStateChange(VideoCapturer* capturer,
75 CaptureState capture_state) { 72 CaptureState capture_state) {
76 EXPECT_EQ(&capturer_, capturer); 73 EXPECT_EQ(&capturer_, capturer);
77 capture_state_ = capture_state; 74 capture_state_ = capture_state;
78 } 75 }
79 76
80 void OnVideoFrame(VideoCapturer* capturer, const VideoFrame* frame) {
81 EXPECT_EQ(&capturer_, capturer);
82 ++captured_frame_num_;
83 }
84
85 int captured_frame_num_; 77 int captured_frame_num_;
86 CaptureState capture_state_; 78 CaptureState capture_state_;
87 }; 79 };
88 80
89 TEST_F(RemoteVideoCapturerTest, StartStop) { 81 TEST_F(RemoteVideoCapturerTest, StartStop) {
90 // Start 82 // Start
91 EXPECT_TRUE( 83 EXPECT_TRUE(
92 capturer_.StartCapturing(VideoFormat(kTestFormat))); 84 capturer_.StartCapturing(VideoFormat(kTestFormat)));
93 EXPECT_TRUE_WAIT((cricket::CS_RUNNING == capture_state()), kMaxWaitMs); 85 EXPECT_TRUE_WAIT((cricket::CS_RUNNING == capture_state()), kMaxWaitMs);
94 EXPECT_EQ(VideoFormat(kTestFormat), 86 EXPECT_EQ(VideoFormat(kTestFormat),
(...skipping 18 matching lines...) Expand all
113 TEST_F(RemoteVideoCapturerTest, GetBestCaptureFormat) { 105 TEST_F(RemoteVideoCapturerTest, GetBestCaptureFormat) {
114 VideoFormat desired = VideoFormat(kTestFormat); 106 VideoFormat desired = VideoFormat(kTestFormat);
115 EXPECT_FALSE(capturer_.GetBestCaptureFormat(desired, NULL)); 107 EXPECT_FALSE(capturer_.GetBestCaptureFormat(desired, NULL));
116 108
117 VideoFormat expected_format = VideoFormat(kTestFormat); 109 VideoFormat expected_format = VideoFormat(kTestFormat);
118 expected_format.fourcc = cricket::FOURCC_I420; 110 expected_format.fourcc = cricket::FOURCC_I420;
119 VideoFormat best_format; 111 VideoFormat best_format;
120 EXPECT_TRUE(capturer_.GetBestCaptureFormat(desired, &best_format)); 112 EXPECT_TRUE(capturer_.GetBestCaptureFormat(desired, &best_format));
121 EXPECT_EQ(expected_format, best_format); 113 EXPECT_EQ(expected_format, best_format);
122 } 114 }
123
124 TEST_F(RemoteVideoCapturerTest, InputFrame) {
125 EXPECT_EQ(0, captured_frame_num());
126
127 cricket::WebRtcVideoFrame test_frame;
128 capturer_.SignalVideoFrame(&capturer_, &test_frame);
129 EXPECT_EQ(1, captured_frame_num());
130 capturer_.SignalVideoFrame(&capturer_, &test_frame);
131 EXPECT_EQ(2, captured_frame_num());
132 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698