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

Side by Side Diff: webrtc/modules/desktop_capture/screen_capturer_integration_test.cc

Issue 2559583002: Enable screen capturer tests for Linux / DirectX capturer / magnifier capturer (Closed)
Patch Set: Resolve review comments Created 4 years 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. 2 * Copyright (c) 2016 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 24 matching lines...) Expand all
35 #include "webrtc/base/win32.h" 35 #include "webrtc/base/win32.h"
36 #include "webrtc/modules/desktop_capture/win/screen_capturer_win_directx.h" 36 #include "webrtc/modules/desktop_capture/win/screen_capturer_win_directx.h"
37 #endif // defined(WEBRTC_WIN) 37 #endif // defined(WEBRTC_WIN)
38 38
39 using ::testing::_; 39 using ::testing::_;
40 40
41 namespace webrtc { 41 namespace webrtc {
42 42
43 namespace { 43 namespace {
44 44
45 ACTION_P(SaveUniquePtrArg, dest) { 45 ACTION_P2(SaveCaptureResult, result, dest) {
46 *result = arg0;
46 *dest = std::move(*arg1); 47 *dest = std::move(*arg1);
47 } 48 }
48 49
49 // Returns true if color in |rect| of |frame| is |color|. 50 // Returns true if color in |rect| of |frame| is |color|.
50 bool ArePixelsColoredBy(const DesktopFrame& frame, 51 bool ArePixelsColoredBy(const DesktopFrame& frame,
51 DesktopRect rect, 52 DesktopRect rect,
52 RgbaColor color, 53 RgbaColor color,
53 bool may_partially_draw) { 54 bool may_partially_draw) {
54 if (!may_partially_draw) { 55 if (!may_partially_draw) {
55 // updated_region() should cover the painted area. 56 // updated_region() should cover the painted area.
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
236 << std::endl; 237 << std::endl;
237 } 238 }
238 std::cout << "Failed to capture rectangle " << rect.left() << " x " 239 std::cout << "Failed to capture rectangle " << rect.left() << " x "
239 << rect.top() << " - " << rect.right() << " x " 240 << rect.top() << " - " << rect.right() << " x "
240 << rect.bottom() << " with color (" 241 << rect.bottom() << " with color ("
241 << static_cast<int>(color.red) << ", " 242 << static_cast<int>(color.red) << ", "
242 << static_cast<int>(color.green) << ", " 243 << static_cast<int>(color.green) << ", "
243 << static_cast<int>(color.blue) << ", " 244 << static_cast<int>(color.blue) << ", "
244 << static_cast<int>(color.alpha) << ")" << std::endl; 245 << static_cast<int>(color.alpha) << ")" << std::endl;
245 ASSERT_TRUE(false) << "ScreenCapturerIntegrationTest may be flaky. " 246 ASSERT_TRUE(false) << "ScreenCapturerIntegrationTest may be flaky. "
246 "If the error message above is " 247 "Please kindly FYI the broken link to "
247 "\"////AP///wD///8A\", it's a known issue, " 248 "zijiehe@chromium.org for investigation. If "
248 "which should be able to recover by rerunning " 249 "the failure continually happens, but I have "
249 "the test. Otherwise please kindly FYI the " 250 "not responded as quick as expected, disable "
250 "broken link to zijiehe@chromium.org for " 251 "*all* tests in "
251 "investigation. If the failure continually "
252 "happens, but I have not responded as quick as "
253 "expected, disable *all* tests in "
254 "screen_capturer_integration_test.cc to " 252 "screen_capturer_integration_test.cc to "
255 "unblock other developers."; 253 "unblock other developers.";
256 } 254 }
257 } 255 }
258 256
259 if (succeeded_capturers == capturers.size()) { 257 if (succeeded_capturers == capturers.size()) {
260 break; 258 break;
261 } 259 }
262 } 260 }
263 261
264 ASSERT_EQ(succeeded_capturers, capturers.size()); 262 ASSERT_EQ(succeeded_capturers, capturers.size());
265 } 263 }
266 264
267 // Expects |capturer| to successfully capture a frame, and returns it. 265 // Expects |capturer| to successfully capture a frame, and returns it.
268 std::unique_ptr<DesktopFrame> CaptureFrame(DesktopCapturer* capturer) { 266 std::unique_ptr<DesktopFrame> CaptureFrame(DesktopCapturer* capturer) {
269 std::unique_ptr<DesktopFrame> frame; 267 for (int i = 0; i < 10; i++) {
270 EXPECT_CALL(callback_, 268 std::unique_ptr<DesktopFrame> frame;
271 OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _)) 269 DesktopCapturer::Result result;
272 .WillOnce(SaveUniquePtrArg(&frame)); 270 EXPECT_CALL(callback_, OnCaptureResultPtr(_, _))
273 capturer->CaptureFrame(); 271 .WillOnce(SaveCaptureResult(&result, &frame));
274 EXPECT_TRUE(frame); 272 capturer->CaptureFrame();
275 return frame; 273 testing::Mock::VerifyAndClearExpectations(&callback_);
274 if (result == DesktopCapturer::Result::SUCCESS) {
275 EXPECT_TRUE(frame);
276 return frame;
277 } else {
278 EXPECT_FALSE(frame);
279 }
280 }
281
282 EXPECT_TRUE(false);
283 return nullptr;
276 } 284 }
277 }; 285 };
278 286
279 #if defined(WEBRTC_WIN) 287 TEST_F(ScreenCapturerIntegrationTest, CaptureUpdatedRegion) {
280 #define MAYBE_CaptureUpdatedRegion DISABLED_CaptureUpdatedRegion 288 #if !defined(WEBRTC_WIN)
281 #else 289 // ScreenCapturerWinGdi randomly returns blank screen, the root cause is still
282 #define MAYBE_CaptureUpdatedRegion CaptureUpdatedRegion 290 // unknown. Bug, https://bugs.chromium.org/p/webrtc/issues/detail?id=6843.
291 TestCaptureUpdatedRegion();
283 #endif 292 #endif
284 TEST_F(ScreenCapturerIntegrationTest, MAYBE_CaptureUpdatedRegion) {
285 TestCaptureUpdatedRegion();
286 } 293 }
287 294
288 #if defined(WEBRTC_WIN) 295 TEST_F(ScreenCapturerIntegrationTest, TwoCapturers) {
289 #define MAYBE_TwoCapturers DISABLED_TwoCapturers 296 #if !defined(WEBRTC_WIN)
290 #else 297 // ScreenCapturerWinGdi randomly returns blank screen, the root cause is still
291 #define MAYBE_TwoCapturers TwoCapturers 298 // unknown. Bug, https://bugs.chromium.org/p/webrtc/issues/detail?id=6843.
292 #endif
293 TEST_F(ScreenCapturerIntegrationTest, MAYBE_TwoCapturers) {
294 std::unique_ptr<DesktopCapturer> capturer2 = std::move(capturer_); 299 std::unique_ptr<DesktopCapturer> capturer2 = std::move(capturer_);
295 SetUp(); 300 SetUp();
296 TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()}); 301 TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()});
302 #endif
297 } 303 }
298 304
299 #if defined(WEBRTC_WIN) 305 #if defined(WEBRTC_WIN)
300 306
301 TEST_F(ScreenCapturerIntegrationTest, 307 TEST_F(ScreenCapturerIntegrationTest, CaptureUpdatedRegionWithDirectxCapturer) {
302 DISABLED_CaptureUpdatedRegionWithDirectxCapturer) {
303 if (!CreateDirectxCapturer()) { 308 if (!CreateDirectxCapturer()) {
304 return; 309 return;
305 } 310 }
306 311
307 TestCaptureUpdatedRegion(); 312 TestCaptureUpdatedRegion();
308 } 313 }
309 314
310 TEST_F(ScreenCapturerIntegrationTest, DISABLED_TwoDirectxCapturers) { 315 TEST_F(ScreenCapturerIntegrationTest, TwoDirectxCapturers) {
311 if (!CreateDirectxCapturer()) { 316 if (!CreateDirectxCapturer()) {
312 return; 317 return;
313 } 318 }
314 319
315 std::unique_ptr<DesktopCapturer> capturer2 = std::move(capturer_); 320 std::unique_ptr<DesktopCapturer> capturer2 = std::move(capturer_);
316 RTC_CHECK(CreateDirectxCapturer()); 321 RTC_CHECK(CreateDirectxCapturer());
317 TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()}); 322 TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()});
318 } 323 }
319 324
320 TEST_F(ScreenCapturerIntegrationTest, 325 TEST_F(ScreenCapturerIntegrationTest,
321 DISABLED_CaptureUpdatedRegionWithMagnifierCapturer) { 326 CaptureUpdatedRegionWithMagnifierCapturer) {
322 // On Windows 8 or later, magnifier APIs return a frame with a border on test 327 // On Windows 8 or later, magnifier APIs return a frame with a border on test
323 // environment, so disable these tests. 328 // environment, so disable these tests.
324 // Bug https://bugs.chromium.org/p/webrtc/issues/detail?id=6666 329 // Bug https://bugs.chromium.org/p/webrtc/issues/detail?id=6844
325 // TODO(zijiehe): Find the root cause of the border and failure, which cannot 330 // TODO(zijiehe): Find the root cause of the border and failure, which cannot
326 // reproduce on my dev machine. 331 // reproduce on my dev machine.
327 if (rtc::IsWindows8OrLater()) { 332 if (rtc::IsWindows8OrLater()) {
328 return; 333 return;
329 } 334 }
330 CreateMagnifierCapturer(); 335 CreateMagnifierCapturer();
331 TestCaptureUpdatedRegion(); 336 TestCaptureUpdatedRegion();
332 } 337 }
333 338
334 TEST_F(ScreenCapturerIntegrationTest, DISABLED_TwoMagnifierCapturers) { 339 TEST_F(ScreenCapturerIntegrationTest, TwoMagnifierCapturers) {
335 // On Windows 8 or later, magnifier APIs return a frame with a border on test 340 // On Windows 8 or later, magnifier APIs return a frame with a border on test
336 // environment, so disable these tests. 341 // environment, so disable these tests.
337 // Bug https://bugs.chromium.org/p/webrtc/issues/detail?id=6666 342 // Bug https://bugs.chromium.org/p/webrtc/issues/detail?id=6844
338 // TODO(zijiehe): Find the root cause of the border and failure, which cannot 343 // TODO(zijiehe): Find the root cause of the border and failure, which cannot
339 // reproduce on my dev machine. 344 // reproduce on my dev machine.
340 if (rtc::IsWindows8OrLater()) { 345 if (rtc::IsWindows8OrLater()) {
341 return; 346 return;
342 } 347 }
343 CreateMagnifierCapturer(); 348 CreateMagnifierCapturer();
344 std::unique_ptr<DesktopCapturer> capturer2 = std::move(capturer_); 349 std::unique_ptr<DesktopCapturer> capturer2 = std::move(capturer_);
345 CreateMagnifierCapturer(); 350 CreateMagnifierCapturer();
346 TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()}); 351 TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()});
347 } 352 }
348 353
349 TEST_F(ScreenCapturerIntegrationTest, 354 TEST_F(ScreenCapturerIntegrationTest,
350 DISABLED_MaybeCaptureUpdatedRegionWithDirectxCapturer) { 355 MaybeCaptureUpdatedRegionWithDirectxCapturer) {
356 if (!rtc::IsWindows8OrLater()) {
357 // ScreenCapturerWinGdi randomly returns blank screen, the root cause is
358 // still unknown. Bug,
359 // https://bugs.chromium.org/p/webrtc/issues/detail?id=6843.
360 // On Windows 7 or early version, MaybeCreateDirectxCapturer() always
361 // creates GDI capturer.
362 return;
363 }
351 // Even DirectX capturer is not supported in current system, we should be able 364 // Even DirectX capturer is not supported in current system, we should be able
352 // to select a usable capturer. 365 // to select a usable capturer.
353 MaybeCreateDirectxCapturer(); 366 MaybeCreateDirectxCapturer();
354 TestCaptureUpdatedRegion(); 367 TestCaptureUpdatedRegion();
355 } 368 }
356 369
357 #endif // defined(WEBRTC_WIN) 370 #endif // defined(WEBRTC_WIN)
358 371
359 } // namespace webrtc 372 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698