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

Side by Side Diff: content/renderer/media/video_capture_impl_unittest.cc

Issue 10108009: Move VideoCapture::VideoCaptureCapability to video_capture_types.h (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix content_unittests build failure Created 8 years, 8 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 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/message_loop.h" 5 #include "base/message_loop.h"
6 #include "content/common/media/video_capture_messages.h" 6 #include "content/common/media/video_capture_messages.h"
7 #include "content/renderer/media/video_capture_impl.h" 7 #include "content/renderer/media/video_capture_impl.h"
8 #include "testing/gmock/include/gmock/gmock.h" 8 #include "testing/gmock/include/gmock/gmock.h"
9 #include "testing/gtest/include/gtest/gtest.h" 9 #include "testing/gtest/include/gtest/gtest.h"
10 10
11 using ::testing::_; 11 using ::testing::_;
12 using ::testing::AtLeast; 12 using ::testing::AtLeast;
13 using ::testing::Return; 13 using ::testing::Return;
14 14
15 #define CAPABILITY_SMALL {176, 144, 30, 0, media::VideoFrame::I420, \ 15 #define CAPABILITY_SMALL {176, 144, 30, media::VideoFrame::I420, 0, \
16 false } 16 false }
17 #define CAPABILITY_LARGE {320, 240, 30, 0, media::VideoFrame::I420, \ 17 #define CAPABILITY_LARGE {320, 240, 30, media::VideoFrame::I420, 0, \
18 false } 18 false }
19 19
20 class MockVideoCaptureMessageFilter : public VideoCaptureMessageFilter { 20 class MockVideoCaptureMessageFilter : public VideoCaptureMessageFilter {
21 public: 21 public:
22 MockVideoCaptureMessageFilter() : VideoCaptureMessageFilter() {} 22 MockVideoCaptureMessageFilter() : VideoCaptureMessageFilter() {}
23 virtual ~MockVideoCaptureMessageFilter() {} 23 virtual ~MockVideoCaptureMessageFilter() {}
24 24
25 // Filter implementation. 25 // Filter implementation.
26 MOCK_METHOD1(Send, bool(IPC::Message* message)); 26 MOCK_METHOD1(Send, bool(IPC::Message* message));
27 27
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 media::VideoCaptureSessionId session_id_; 123 media::VideoCaptureSessionId session_id_;
124 MockVideoCaptureImpl* video_capture_impl_; 124 MockVideoCaptureImpl* video_capture_impl_;
125 125
126 private: 126 private:
127 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImplTest); 127 DISALLOW_COPY_AND_ASSIGN(VideoCaptureImplTest);
128 }; 128 };
129 129
130 TEST_F(VideoCaptureImplTest, Simple) { 130 TEST_F(VideoCaptureImplTest, Simple) {
131 // Execute SetCapture() and StopCapture() for one client. 131 // Execute SetCapture() and StopCapture() for one client.
132 scoped_ptr<MockVideoCaptureClient> client(new MockVideoCaptureClient); 132 scoped_ptr<MockVideoCaptureClient> client(new MockVideoCaptureClient);
133 media::VideoCapture::VideoCaptureCapability capability = 133 media::VideoCaptureCapability capability = CAPABILITY_SMALL;
134 CAPABILITY_SMALL;
135 134
136 EXPECT_CALL(*client, OnStarted(_)) 135 EXPECT_CALL(*client, OnStarted(_))
137 .WillOnce(Return()); 136 .WillOnce(Return());
138 EXPECT_CALL(*client, OnDeviceInfoReceived(_,_)) 137 EXPECT_CALL(*client, OnDeviceInfoReceived(_,_))
139 .WillOnce(Return()); 138 .WillOnce(Return());
140 139
141 video_capture_impl_->StartCapture(client.get(), capability); 140 video_capture_impl_->StartCapture(client.get(), capability);
142 message_loop_->RunAllPending(); 141 message_loop_->RunAllPending();
143 142
144 EXPECT_CALL(*client, OnStopped(_)) 143 EXPECT_CALL(*client, OnStopped(_))
145 .WillOnce(Return()); 144 .WillOnce(Return());
146 EXPECT_CALL(*client, OnRemoved(_)) 145 EXPECT_CALL(*client, OnRemoved(_))
147 .WillOnce(Return()); 146 .WillOnce(Return());
148 147
149 video_capture_impl_->StopCapture(client.get()); 148 video_capture_impl_->StopCapture(client.get());
150 message_loop_->RunAllPending(); 149 message_loop_->RunAllPending();
151 } 150 }
152 151
153 TEST_F(VideoCaptureImplTest, TwoClientsInSequence) { 152 TEST_F(VideoCaptureImplTest, TwoClientsInSequence) {
154 // Execute SetCapture() and StopCapture() for 2 clients in sequence. 153 // Execute SetCapture() and StopCapture() for 2 clients in sequence.
155 scoped_ptr<MockVideoCaptureClient> client(new MockVideoCaptureClient); 154 scoped_ptr<MockVideoCaptureClient> client(new MockVideoCaptureClient);
156 media::VideoCapture::VideoCaptureCapability capability = 155 media::VideoCaptureCapability capability = CAPABILITY_SMALL;
157 CAPABILITY_SMALL;
158 156
159 EXPECT_CALL(*client, OnStarted(_)) 157 EXPECT_CALL(*client, OnStarted(_))
160 .WillOnce(Return()); 158 .WillOnce(Return());
161 EXPECT_CALL(*client, OnDeviceInfoReceived(_,_)) 159 EXPECT_CALL(*client, OnDeviceInfoReceived(_,_))
162 .WillOnce(Return()); 160 .WillOnce(Return());
163 161
164 video_capture_impl_->StartCapture(client.get(), capability); 162 video_capture_impl_->StartCapture(client.get(), capability);
165 message_loop_->RunAllPending(); 163 message_loop_->RunAllPending();
166 164
167 EXPECT_CALL(*client, OnStopped(_)) 165 EXPECT_CALL(*client, OnStopped(_))
(...skipping 19 matching lines...) Expand all
187 185
188 video_capture_impl_->StopCapture(client.get()); 186 video_capture_impl_->StopCapture(client.get());
189 message_loop_->RunAllPending(); 187 message_loop_->RunAllPending();
190 } 188 }
191 189
192 TEST_F(VideoCaptureImplTest, LargeAndSmall) { 190 TEST_F(VideoCaptureImplTest, LargeAndSmall) {
193 // Execute SetCapture() and StopCapture() for 2 clients simultaneously. 191 // Execute SetCapture() and StopCapture() for 2 clients simultaneously.
194 // The large client starts first and stops first. 192 // The large client starts first and stops first.
195 scoped_ptr<MockVideoCaptureClient> client_small(new MockVideoCaptureClient); 193 scoped_ptr<MockVideoCaptureClient> client_small(new MockVideoCaptureClient);
196 scoped_ptr<MockVideoCaptureClient> client_large(new MockVideoCaptureClient); 194 scoped_ptr<MockVideoCaptureClient> client_large(new MockVideoCaptureClient);
197 media::VideoCapture::VideoCaptureCapability capability_small = 195 media::VideoCaptureCapability capability_small = CAPABILITY_SMALL;
198 CAPABILITY_SMALL; 196 media::VideoCaptureCapability capability_large = CAPABILITY_LARGE;
199 media::VideoCapture::VideoCaptureCapability capability_large =
200 CAPABILITY_LARGE;
201 197
202 EXPECT_CALL(*client_large, OnStarted(_)) 198 EXPECT_CALL(*client_large, OnStarted(_))
203 .WillOnce(Return()); 199 .WillOnce(Return());
204 EXPECT_CALL(*client_large, OnDeviceInfoReceived(_,_)) 200 EXPECT_CALL(*client_large, OnDeviceInfoReceived(_,_))
205 .WillOnce(Return()); 201 .WillOnce(Return());
206 EXPECT_CALL(*client_small, OnStarted(_)) 202 EXPECT_CALL(*client_small, OnStarted(_))
207 .WillOnce(Return()); 203 .WillOnce(Return());
208 EXPECT_CALL(*client_small, OnDeviceInfoReceived(_,_)) 204 EXPECT_CALL(*client_small, OnDeviceInfoReceived(_,_))
209 .WillOnce(Return()); 205 .WillOnce(Return());
210 206
(...skipping 13 matching lines...) Expand all
224 video_capture_impl_->StopCapture(client_large.get()); 220 video_capture_impl_->StopCapture(client_large.get());
225 video_capture_impl_->StopCapture(client_small.get()); 221 video_capture_impl_->StopCapture(client_small.get());
226 message_loop_->RunAllPending(); 222 message_loop_->RunAllPending();
227 } 223 }
228 224
229 TEST_F(VideoCaptureImplTest, SmallAndLarge) { 225 TEST_F(VideoCaptureImplTest, SmallAndLarge) {
230 // Execute SetCapture() and StopCapture() for 2 clients simultaneously. 226 // Execute SetCapture() and StopCapture() for 2 clients simultaneously.
231 // The small client starts first and stops first. 227 // The small client starts first and stops first.
232 scoped_ptr<MockVideoCaptureClient> client_small(new MockVideoCaptureClient); 228 scoped_ptr<MockVideoCaptureClient> client_small(new MockVideoCaptureClient);
233 scoped_ptr<MockVideoCaptureClient> client_large(new MockVideoCaptureClient); 229 scoped_ptr<MockVideoCaptureClient> client_large(new MockVideoCaptureClient);
234 media::VideoCapture::VideoCaptureCapability capability_small = 230 media::VideoCaptureCapability capability_small = CAPABILITY_SMALL;
235 CAPABILITY_SMALL; 231 media::VideoCaptureCapability capability_large = CAPABILITY_LARGE;
236 media::VideoCapture::VideoCaptureCapability capability_large =
237 CAPABILITY_LARGE;
238 232
239 EXPECT_CALL(*client_large, OnStarted(_)) 233 EXPECT_CALL(*client_large, OnStarted(_))
240 .WillOnce(Return()); 234 .WillOnce(Return());
241 EXPECT_CALL(*client_large, OnDeviceInfoReceived(_,_)) 235 EXPECT_CALL(*client_large, OnDeviceInfoReceived(_,_))
242 .WillOnce(Return()); 236 .WillOnce(Return());
243 EXPECT_CALL(*client_small, OnStarted(_)) 237 EXPECT_CALL(*client_small, OnStarted(_))
244 .WillOnce(Return()); 238 .WillOnce(Return());
245 EXPECT_CALL(*client_small, OnDeviceInfoReceived(_,_)) 239 EXPECT_CALL(*client_small, OnDeviceInfoReceived(_,_))
246 .Times(AtLeast(1)) 240 .Times(AtLeast(1))
247 .WillRepeatedly(Return()); 241 .WillRepeatedly(Return());
(...skipping 14 matching lines...) Expand all
262 video_capture_impl_->StopCapture(client_small.get()); 256 video_capture_impl_->StopCapture(client_small.get());
263 video_capture_impl_->StopCapture(client_large.get()); 257 video_capture_impl_->StopCapture(client_large.get());
264 message_loop_->RunAllPending(); 258 message_loop_->RunAllPending();
265 } 259 }
266 260
267 TEST_F(VideoCaptureImplTest, TwoClientsWithSameSize) { 261 TEST_F(VideoCaptureImplTest, TwoClientsWithSameSize) {
268 // Execute SetCapture() and StopCapture() for 2 clients simultaneously. 262 // Execute SetCapture() and StopCapture() for 2 clients simultaneously.
269 // The client1 starts first and stops first. 263 // The client1 starts first and stops first.
270 scoped_ptr<MockVideoCaptureClient> client1(new MockVideoCaptureClient); 264 scoped_ptr<MockVideoCaptureClient> client1(new MockVideoCaptureClient);
271 scoped_ptr<MockVideoCaptureClient> client2(new MockVideoCaptureClient); 265 scoped_ptr<MockVideoCaptureClient> client2(new MockVideoCaptureClient);
272 media::VideoCapture::VideoCaptureCapability capability = CAPABILITY_SMALL; 266 media::VideoCaptureCapability capability = CAPABILITY_SMALL;
273 267
274 EXPECT_CALL(*client1, OnStarted(_)) 268 EXPECT_CALL(*client1, OnStarted(_))
275 .WillOnce(Return()); 269 .WillOnce(Return());
276 EXPECT_CALL(*client1, OnDeviceInfoReceived(_,_)) 270 EXPECT_CALL(*client1, OnDeviceInfoReceived(_,_))
277 .WillOnce(Return()); 271 .WillOnce(Return());
278 EXPECT_CALL(*client2, OnStarted(_)) 272 EXPECT_CALL(*client2, OnStarted(_))
279 .WillOnce(Return()); 273 .WillOnce(Return());
280 EXPECT_CALL(*client2, OnDeviceInfoReceived(_,_)) 274 EXPECT_CALL(*client2, OnDeviceInfoReceived(_,_))
281 .WillOnce(Return()); 275 .WillOnce(Return());
282 276
283 video_capture_impl_->StartCapture(client1.get(), capability); 277 video_capture_impl_->StartCapture(client1.get(), capability);
284 video_capture_impl_->StartCapture(client2.get(), capability); 278 video_capture_impl_->StartCapture(client2.get(), capability);
285 message_loop_->RunAllPending(); 279 message_loop_->RunAllPending();
286 280
287 EXPECT_CALL(*client1, OnStopped(_)) 281 EXPECT_CALL(*client1, OnStopped(_))
288 .WillOnce(Return()); 282 .WillOnce(Return());
289 EXPECT_CALL(*client1, OnRemoved(_)) 283 EXPECT_CALL(*client1, OnRemoved(_))
290 .WillOnce(Return()); 284 .WillOnce(Return());
291 EXPECT_CALL(*client2, OnStopped(_)) 285 EXPECT_CALL(*client2, OnStopped(_))
292 .WillOnce(Return()); 286 .WillOnce(Return());
293 EXPECT_CALL(*client2, OnRemoved(_)) 287 EXPECT_CALL(*client2, OnRemoved(_))
294 .WillOnce(Return()); 288 .WillOnce(Return());
295 289
296 video_capture_impl_->StopCapture(client1.get()); 290 video_capture_impl_->StopCapture(client1.get());
297 video_capture_impl_->StopCapture(client2.get()); 291 video_capture_impl_->StopCapture(client2.get());
298 message_loop_->RunAllPending(); 292 message_loop_->RunAllPending();
299 } 293 }
OLDNEW
« no previous file with comments | « content/renderer/media/video_capture_impl.cc ('k') | content/renderer/media/video_capture_module_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698