OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "content/browser/renderer_host/media/desktop_capture_device.h" | 5 #include "content/browser/renderer_host/media/desktop_capture_device.h" |
6 | 6 |
7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
8 #include "base/sequenced_task_runner.h" | 8 #include "base/sequenced_task_runner.h" |
9 #include "base/synchronization/waitable_event.h" | 9 #include "base/synchronization/waitable_event.h" |
10 #include "base/test/test_timeouts.h" | 10 #include "base/test/test_timeouts.h" |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 EXPECT_CALL(frame_observer, OnFrameInfo(_)) | 125 EXPECT_CALL(frame_observer, OnFrameInfo(_)) |
126 .WillOnce(SaveArg<0>(&caps)); | 126 .WillOnce(SaveArg<0>(&caps)); |
127 EXPECT_CALL(frame_observer, OnError()) | 127 EXPECT_CALL(frame_observer, OnError()) |
128 .Times(0); | 128 .Times(0); |
129 EXPECT_CALL(frame_observer, OnIncomingCapturedFrame(_, _, _, _, _, _)) | 129 EXPECT_CALL(frame_observer, OnIncomingCapturedFrame(_, _, _, _, _, _)) |
130 .WillRepeatedly(DoAll( | 130 .WillRepeatedly(DoAll( |
131 SaveArg<1>(&frame_size), | 131 SaveArg<1>(&frame_size), |
132 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal))); | 132 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal))); |
133 | 133 |
134 media::VideoCaptureCapability capture_format( | 134 media::VideoCaptureCapability capture_format( |
135 640, 480, kFrameRate, media::VideoCaptureCapability::kI420, 0, false, | 135 640, 480, kFrameRate, media::PIXEL_FORMAT_I420, 0, false, |
136 media::ConstantResolutionVideoCaptureDevice); | 136 media::ConstantResolutionVideoCaptureDevice); |
137 capture_device.Allocate(capture_format, &frame_observer); | 137 capture_device.Allocate(capture_format, &frame_observer); |
138 capture_device.Start(); | 138 capture_device.Start(); |
139 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout())); | 139 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout())); |
140 capture_device.Stop(); | 140 capture_device.Stop(); |
141 capture_device.DeAllocate(); | 141 capture_device.DeAllocate(); |
142 | 142 |
143 EXPECT_GT(caps.width, 0); | 143 EXPECT_GT(caps.width, 0); |
144 EXPECT_GT(caps.height, 0); | 144 EXPECT_GT(caps.height, 0); |
145 EXPECT_EQ(kFrameRate, caps.frame_rate); | 145 EXPECT_EQ(kFrameRate, caps.frame_rate); |
146 EXPECT_EQ(media::VideoCaptureCapability::kARGB, caps.color); | 146 EXPECT_EQ(media::PIXEL_FORMAT_ARGB, caps.color); |
147 EXPECT_FALSE(caps.interlaced); | 147 EXPECT_FALSE(caps.interlaced); |
148 | 148 |
149 EXPECT_EQ(caps.width * caps.height * 4, frame_size); | 149 EXPECT_EQ(caps.width * caps.height * 4, frame_size); |
150 } | 150 } |
151 | 151 |
152 // Test that screen capturer behaves correctly if the source frame size changes | 152 // Test that screen capturer behaves correctly if the source frame size changes |
153 // but the caller cannot cope with variable resolution output. | 153 // but the caller cannot cope with variable resolution output. |
154 TEST_F(DesktopCaptureDeviceTest, ScreenResolutionChangeConstantResolution) { | 154 TEST_F(DesktopCaptureDeviceTest, ScreenResolutionChangeConstantResolution) { |
155 FakeScreenCapturer* mock_capturer = new FakeScreenCapturer(); | 155 FakeScreenCapturer* mock_capturer = new FakeScreenCapturer(); |
156 | 156 |
(...skipping 15 matching lines...) Expand all Loading... |
172 EXPECT_CALL(frame_observer, OnIncomingCapturedFrame(_, _, _, _, _, _)) | 172 EXPECT_CALL(frame_observer, OnIncomingCapturedFrame(_, _, _, _, _, _)) |
173 .After(frame_info_called) | 173 .After(frame_info_called) |
174 .WillRepeatedly(DoAll( | 174 .WillRepeatedly(DoAll( |
175 SaveArg<1>(&frame_size), | 175 SaveArg<1>(&frame_size), |
176 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal))); | 176 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal))); |
177 | 177 |
178 media::VideoCaptureCapability capture_format( | 178 media::VideoCaptureCapability capture_format( |
179 kTestFrameWidth1, | 179 kTestFrameWidth1, |
180 kTestFrameHeight1, | 180 kTestFrameHeight1, |
181 kFrameRate, | 181 kFrameRate, |
182 media::VideoCaptureCapability::kI420, | 182 media::PIXEL_FORMAT_I420, |
183 0, | 183 0, |
184 false, | 184 false, |
185 media::ConstantResolutionVideoCaptureDevice); | 185 media::ConstantResolutionVideoCaptureDevice); |
186 | 186 |
187 capture_device.Allocate(capture_format, &frame_observer); | 187 capture_device.Allocate(capture_format, &frame_observer); |
188 capture_device.Start(); | 188 capture_device.Start(); |
189 | 189 |
190 // Capture at least two frames, to ensure that the source frame size has | 190 // Capture at least two frames, to ensure that the source frame size has |
191 // changed while capturing. | 191 // changed while capturing. |
192 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout())); | 192 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout())); |
193 done_event.Reset(); | 193 done_event.Reset(); |
194 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout())); | 194 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout())); |
195 | 195 |
196 capture_device.Stop(); | 196 capture_device.Stop(); |
197 capture_device.DeAllocate(); | 197 capture_device.DeAllocate(); |
198 | 198 |
199 EXPECT_EQ(kTestFrameWidth1, caps.width); | 199 EXPECT_EQ(kTestFrameWidth1, caps.width); |
200 EXPECT_EQ(kTestFrameHeight1, caps.height); | 200 EXPECT_EQ(kTestFrameHeight1, caps.height); |
201 EXPECT_EQ(kFrameRate, caps.frame_rate); | 201 EXPECT_EQ(kFrameRate, caps.frame_rate); |
202 EXPECT_EQ(media::VideoCaptureCapability::kARGB, caps.color); | 202 EXPECT_EQ(media::PIXEL_FORMAT_ARGB, caps.color); |
203 EXPECT_FALSE(caps.interlaced); | 203 EXPECT_FALSE(caps.interlaced); |
204 | 204 |
205 EXPECT_EQ(caps.width * caps.height * 4, frame_size); | 205 EXPECT_EQ(caps.width * caps.height * 4, frame_size); |
206 } | 206 } |
207 | 207 |
208 // Test that screen capturer behaves correctly if the source frame size changes | 208 // Test that screen capturer behaves correctly if the source frame size changes |
209 // and the caller can cope with variable resolution output. | 209 // and the caller can cope with variable resolution output. |
210 TEST_F(DesktopCaptureDeviceTest, ScreenResolutionChangeVariableResolution) { | 210 TEST_F(DesktopCaptureDeviceTest, ScreenResolutionChangeVariableResolution) { |
211 FakeScreenCapturer* mock_capturer = new FakeScreenCapturer(); | 211 FakeScreenCapturer* mock_capturer = new FakeScreenCapturer(); |
212 | 212 |
(...skipping 22 matching lines...) Expand all Loading... |
235 .Times(0); | 235 .Times(0); |
236 EXPECT_CALL(frame_observer, OnIncomingCapturedFrame(_, _, _, _, _, _)) | 236 EXPECT_CALL(frame_observer, OnIncomingCapturedFrame(_, _, _, _, _, _)) |
237 .After(frame_info_called) | 237 .After(frame_info_called) |
238 .WillRepeatedly( | 238 .WillRepeatedly( |
239 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)); | 239 InvokeWithoutArgs(&done_event, &base::WaitableEvent::Signal)); |
240 | 240 |
241 media::VideoCaptureCapability capture_format( | 241 media::VideoCaptureCapability capture_format( |
242 kTestFrameWidth2, | 242 kTestFrameWidth2, |
243 kTestFrameHeight2, | 243 kTestFrameHeight2, |
244 kFrameRate, | 244 kFrameRate, |
245 media::VideoCaptureCapability::kI420, | 245 media::PIXEL_FORMAT_I420, |
246 0, | 246 0, |
247 false, | 247 false, |
248 media::VariableResolutionVideoCaptureDevice); | 248 media::VariableResolutionVideoCaptureDevice); |
249 | 249 |
250 capture_device.Allocate(capture_format, &frame_observer); | 250 capture_device.Allocate(capture_format, &frame_observer); |
251 capture_device.Start(); | 251 capture_device.Start(); |
252 | 252 |
253 // Capture at least three frames, to ensure that the source frame size has | 253 // Capture at least three frames, to ensure that the source frame size has |
254 // changed at least twice while capturing. | 254 // changed at least twice while capturing. |
255 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout())); | 255 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout())); |
256 done_event.Reset(); | 256 done_event.Reset(); |
257 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout())); | 257 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout())); |
258 done_event.Reset(); | 258 done_event.Reset(); |
259 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout())); | 259 EXPECT_TRUE(done_event.TimedWait(TestTimeouts::action_max_timeout())); |
260 | 260 |
261 capture_device.Stop(); | 261 capture_device.Stop(); |
262 capture_device.DeAllocate(); | 262 capture_device.DeAllocate(); |
263 | 263 |
264 EXPECT_EQ(kTestFrameWidth1, caps.width); | 264 EXPECT_EQ(kTestFrameWidth1, caps.width); |
265 EXPECT_EQ(kTestFrameHeight1, caps.height); | 265 EXPECT_EQ(kTestFrameHeight1, caps.height); |
266 EXPECT_EQ(kFrameRate, caps.frame_rate); | 266 EXPECT_EQ(kFrameRate, caps.frame_rate); |
267 EXPECT_EQ(media::VideoCaptureCapability::kARGB, caps.color); | 267 EXPECT_EQ(media::PIXEL_FORMAT_ARGB, caps.color); |
268 EXPECT_FALSE(caps.interlaced); | 268 EXPECT_FALSE(caps.interlaced); |
269 } | 269 } |
270 | 270 |
271 } // namespace content | 271 } // namespace content |
OLD | NEW |