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

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: 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
(...skipping 112 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 =
scherkus (not reviewing) 2012/04/17 17:39:23 nit: this can fit on one line
134 CAPABILITY_SMALL; 134 CAPABILITY_SMALL;
135 135
136 EXPECT_CALL(*client, OnStarted(_)) 136 EXPECT_CALL(*client, OnStarted(_))
137 .WillOnce(Return()); 137 .WillOnce(Return());
138 EXPECT_CALL(*client, OnDeviceInfoReceived(_,_)) 138 EXPECT_CALL(*client, OnDeviceInfoReceived(_,_))
139 .WillOnce(Return()); 139 .WillOnce(Return());
140 140
141 video_capture_impl_->StartCapture(client.get(), capability); 141 video_capture_impl_->StartCapture(client.get(), capability);
142 message_loop_->RunAllPending(); 142 message_loop_->RunAllPending();
143 143
144 EXPECT_CALL(*client, OnStopped(_)) 144 EXPECT_CALL(*client, OnStopped(_))
145 .WillOnce(Return()); 145 .WillOnce(Return());
146 EXPECT_CALL(*client, OnRemoved(_)) 146 EXPECT_CALL(*client, OnRemoved(_))
147 .WillOnce(Return()); 147 .WillOnce(Return());
148 148
149 video_capture_impl_->StopCapture(client.get()); 149 video_capture_impl_->StopCapture(client.get());
150 message_loop_->RunAllPending(); 150 message_loop_->RunAllPending();
151 } 151 }
152 152
153 TEST_F(VideoCaptureImplTest, TwoClientsInSequence) { 153 TEST_F(VideoCaptureImplTest, TwoClientsInSequence) {
154 // Execute SetCapture() and StopCapture() for 2 clients in sequence. 154 // Execute SetCapture() and StopCapture() for 2 clients in sequence.
155 scoped_ptr<MockVideoCaptureClient> client(new MockVideoCaptureClient); 155 scoped_ptr<MockVideoCaptureClient> client(new MockVideoCaptureClient);
156 media::VideoCapture::VideoCaptureCapability capability = 156 media::VideoCaptureCapability capability =
scherkus (not reviewing) 2012/04/17 17:39:23 nit: this can fit on one line
157 CAPABILITY_SMALL; 157 CAPABILITY_SMALL;
158 158
159 EXPECT_CALL(*client, OnStarted(_)) 159 EXPECT_CALL(*client, OnStarted(_))
160 .WillOnce(Return()); 160 .WillOnce(Return());
161 EXPECT_CALL(*client, OnDeviceInfoReceived(_,_)) 161 EXPECT_CALL(*client, OnDeviceInfoReceived(_,_))
162 .WillOnce(Return()); 162 .WillOnce(Return());
163 163
164 video_capture_impl_->StartCapture(client.get(), capability); 164 video_capture_impl_->StartCapture(client.get(), capability);
165 message_loop_->RunAllPending(); 165 message_loop_->RunAllPending();
166 166
(...skipping 20 matching lines...) Expand all
187 187
188 video_capture_impl_->StopCapture(client.get()); 188 video_capture_impl_->StopCapture(client.get());
189 message_loop_->RunAllPending(); 189 message_loop_->RunAllPending();
190 } 190 }
191 191
192 TEST_F(VideoCaptureImplTest, LargeAndSmall) { 192 TEST_F(VideoCaptureImplTest, LargeAndSmall) {
193 // Execute SetCapture() and StopCapture() for 2 clients simultaneously. 193 // Execute SetCapture() and StopCapture() for 2 clients simultaneously.
194 // The large client starts first and stops first. 194 // The large client starts first and stops first.
195 scoped_ptr<MockVideoCaptureClient> client_small(new MockVideoCaptureClient); 195 scoped_ptr<MockVideoCaptureClient> client_small(new MockVideoCaptureClient);
196 scoped_ptr<MockVideoCaptureClient> client_large(new MockVideoCaptureClient); 196 scoped_ptr<MockVideoCaptureClient> client_large(new MockVideoCaptureClient);
197 media::VideoCapture::VideoCaptureCapability capability_small = 197 media::VideoCaptureCapability capability_small =
scherkus (not reviewing) 2012/04/17 17:39:23 nit: this can fit on one line
198 CAPABILITY_SMALL; 198 CAPABILITY_SMALL;
199 media::VideoCapture::VideoCaptureCapability capability_large = 199 media::VideoCaptureCapability capability_large =
scherkus (not reviewing) 2012/04/17 17:39:23 nit: this can fit on one line
200 CAPABILITY_LARGE; 200 CAPABILITY_LARGE;
201 201
202 EXPECT_CALL(*client_large, OnStarted(_)) 202 EXPECT_CALL(*client_large, OnStarted(_))
203 .WillOnce(Return()); 203 .WillOnce(Return());
204 EXPECT_CALL(*client_large, OnDeviceInfoReceived(_,_)) 204 EXPECT_CALL(*client_large, OnDeviceInfoReceived(_,_))
205 .WillOnce(Return()); 205 .WillOnce(Return());
206 EXPECT_CALL(*client_small, OnStarted(_)) 206 EXPECT_CALL(*client_small, OnStarted(_))
207 .WillOnce(Return()); 207 .WillOnce(Return());
208 EXPECT_CALL(*client_small, OnDeviceInfoReceived(_,_)) 208 EXPECT_CALL(*client_small, OnDeviceInfoReceived(_,_))
209 .WillOnce(Return()); 209 .WillOnce(Return());
(...skipping 14 matching lines...) Expand all
224 video_capture_impl_->StopCapture(client_large.get()); 224 video_capture_impl_->StopCapture(client_large.get());
225 video_capture_impl_->StopCapture(client_small.get()); 225 video_capture_impl_->StopCapture(client_small.get());
226 message_loop_->RunAllPending(); 226 message_loop_->RunAllPending();
227 } 227 }
228 228
229 TEST_F(VideoCaptureImplTest, SmallAndLarge) { 229 TEST_F(VideoCaptureImplTest, SmallAndLarge) {
230 // Execute SetCapture() and StopCapture() for 2 clients simultaneously. 230 // Execute SetCapture() and StopCapture() for 2 clients simultaneously.
231 // The small client starts first and stops first. 231 // The small client starts first and stops first.
232 scoped_ptr<MockVideoCaptureClient> client_small(new MockVideoCaptureClient); 232 scoped_ptr<MockVideoCaptureClient> client_small(new MockVideoCaptureClient);
233 scoped_ptr<MockVideoCaptureClient> client_large(new MockVideoCaptureClient); 233 scoped_ptr<MockVideoCaptureClient> client_large(new MockVideoCaptureClient);
234 media::VideoCapture::VideoCaptureCapability capability_small = 234 media::VideoCaptureCapability capability_small =
scherkus (not reviewing) 2012/04/17 17:39:23 ditto for these two
235 CAPABILITY_SMALL; 235 CAPABILITY_SMALL;
236 media::VideoCapture::VideoCaptureCapability capability_large = 236 media::VideoCaptureCapability capability_large =
237 CAPABILITY_LARGE; 237 CAPABILITY_LARGE;
238 238
239 EXPECT_CALL(*client_large, OnStarted(_)) 239 EXPECT_CALL(*client_large, OnStarted(_))
240 .WillOnce(Return()); 240 .WillOnce(Return());
241 EXPECT_CALL(*client_large, OnDeviceInfoReceived(_,_)) 241 EXPECT_CALL(*client_large, OnDeviceInfoReceived(_,_))
242 .WillOnce(Return()); 242 .WillOnce(Return());
243 EXPECT_CALL(*client_small, OnStarted(_)) 243 EXPECT_CALL(*client_small, OnStarted(_))
244 .WillOnce(Return()); 244 .WillOnce(Return());
245 EXPECT_CALL(*client_small, OnDeviceInfoReceived(_,_)) 245 EXPECT_CALL(*client_small, OnDeviceInfoReceived(_,_))
246 .Times(AtLeast(1)) 246 .Times(AtLeast(1))
(...skipping 15 matching lines...) Expand all
262 video_capture_impl_->StopCapture(client_small.get()); 262 video_capture_impl_->StopCapture(client_small.get());
263 video_capture_impl_->StopCapture(client_large.get()); 263 video_capture_impl_->StopCapture(client_large.get());
264 message_loop_->RunAllPending(); 264 message_loop_->RunAllPending();
265 } 265 }
266 266
267 TEST_F(VideoCaptureImplTest, TwoClientsWithSameSize) { 267 TEST_F(VideoCaptureImplTest, TwoClientsWithSameSize) {
268 // Execute SetCapture() and StopCapture() for 2 clients simultaneously. 268 // Execute SetCapture() and StopCapture() for 2 clients simultaneously.
269 // The client1 starts first and stops first. 269 // The client1 starts first and stops first.
270 scoped_ptr<MockVideoCaptureClient> client1(new MockVideoCaptureClient); 270 scoped_ptr<MockVideoCaptureClient> client1(new MockVideoCaptureClient);
271 scoped_ptr<MockVideoCaptureClient> client2(new MockVideoCaptureClient); 271 scoped_ptr<MockVideoCaptureClient> client2(new MockVideoCaptureClient);
272 media::VideoCapture::VideoCaptureCapability capability = CAPABILITY_SMALL; 272 media::VideoCaptureCapability capability = CAPABILITY_SMALL;
273 273
274 EXPECT_CALL(*client1, OnStarted(_)) 274 EXPECT_CALL(*client1, OnStarted(_))
275 .WillOnce(Return()); 275 .WillOnce(Return());
276 EXPECT_CALL(*client1, OnDeviceInfoReceived(_,_)) 276 EXPECT_CALL(*client1, OnDeviceInfoReceived(_,_))
277 .WillOnce(Return()); 277 .WillOnce(Return());
278 EXPECT_CALL(*client2, OnStarted(_)) 278 EXPECT_CALL(*client2, OnStarted(_))
279 .WillOnce(Return()); 279 .WillOnce(Return());
280 EXPECT_CALL(*client2, OnDeviceInfoReceived(_,_)) 280 EXPECT_CALL(*client2, OnDeviceInfoReceived(_,_))
281 .WillOnce(Return()); 281 .WillOnce(Return());
282 282
283 video_capture_impl_->StartCapture(client1.get(), capability); 283 video_capture_impl_->StartCapture(client1.get(), capability);
284 video_capture_impl_->StartCapture(client2.get(), capability); 284 video_capture_impl_->StartCapture(client2.get(), capability);
285 message_loop_->RunAllPending(); 285 message_loop_->RunAllPending();
286 286
287 EXPECT_CALL(*client1, OnStopped(_)) 287 EXPECT_CALL(*client1, OnStopped(_))
288 .WillOnce(Return()); 288 .WillOnce(Return());
289 EXPECT_CALL(*client1, OnRemoved(_)) 289 EXPECT_CALL(*client1, OnRemoved(_))
290 .WillOnce(Return()); 290 .WillOnce(Return());
291 EXPECT_CALL(*client2, OnStopped(_)) 291 EXPECT_CALL(*client2, OnStopped(_))
292 .WillOnce(Return()); 292 .WillOnce(Return());
293 EXPECT_CALL(*client2, OnRemoved(_)) 293 EXPECT_CALL(*client2, OnRemoved(_))
294 .WillOnce(Return()); 294 .WillOnce(Return());
295 295
296 video_capture_impl_->StopCapture(client1.get()); 296 video_capture_impl_->StopCapture(client1.get());
297 video_capture_impl_->StopCapture(client2.get()); 297 video_capture_impl_->StopCapture(client2.get());
298 message_loop_->RunAllPending(); 298 message_loop_->RunAllPending();
299 } 299 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698