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

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

Issue 2513213002: Enable ScreenCapturerIntegrationTests (Closed)
Patch Set: Append bug id to magnifier capturer tests 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 14 matching lines...) Expand all
25 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" 25 #include "webrtc/modules/desktop_capture/desktop_capture_options.h"
26 #include "webrtc/modules/desktop_capture/desktop_frame.h" 26 #include "webrtc/modules/desktop_capture/desktop_frame.h"
27 #include "webrtc/modules/desktop_capture/desktop_region.h" 27 #include "webrtc/modules/desktop_capture/desktop_region.h"
28 #include "webrtc/modules/desktop_capture/mock_desktop_capturer_callback.h" 28 #include "webrtc/modules/desktop_capture/mock_desktop_capturer_callback.h"
29 #include "webrtc/modules/desktop_capture/rgba_color.h" 29 #include "webrtc/modules/desktop_capture/rgba_color.h"
30 #include "webrtc/modules/desktop_capture/screen_drawer.h" 30 #include "webrtc/modules/desktop_capture/screen_drawer.h"
31 #include "webrtc/test/gmock.h" 31 #include "webrtc/test/gmock.h"
32 #include "webrtc/test/gtest.h" 32 #include "webrtc/test/gtest.h"
33 33
34 #if defined(WEBRTC_WIN) 34 #if defined(WEBRTC_WIN)
35 #include "webrtc/base/win32.h"
35 #include "webrtc/modules/desktop_capture/win/screen_capturer_win_directx.h" 36 #include "webrtc/modules/desktop_capture/win/screen_capturer_win_directx.h"
36 #endif // defined(WEBRTC_WIN) 37 #endif // defined(WEBRTC_WIN)
37 38
38 using ::testing::_; 39 using ::testing::_;
39 40
40 namespace webrtc { 41 namespace webrtc {
41 42
42 namespace { 43 namespace {
43 44
44 ACTION_P(SaveUniquePtrArg, dest) { 45 ACTION_P(SaveUniquePtrArg, dest) {
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 capturer_ = DesktopCapturer::CreateScreenCapturer( 83 capturer_ = DesktopCapturer::CreateScreenCapturer(
83 DesktopCaptureOptions::CreateDefault()); 84 DesktopCaptureOptions::CreateDefault());
84 } 85 }
85 86
86 protected: 87 protected:
87 void TestCaptureUpdatedRegion( 88 void TestCaptureUpdatedRegion(
88 std::initializer_list<DesktopCapturer*> capturers) { 89 std::initializer_list<DesktopCapturer*> capturers) {
89 RTC_DCHECK(capturers.size() > 0); 90 RTC_DCHECK(capturers.size() > 0);
90 // A large enough area for the tests, which should be able to be fulfilled 91 // A large enough area for the tests, which should be able to be fulfilled
91 // by most systems. 92 // by most systems.
93 #if defined(WEBRTC_WIN)
94 // On Windows, an interesting warning window may pop up randomly. The root
95 // cause is still under investigation, so reduce the test area to work
96 // around. Bug https://bugs.chromium.org/p/webrtc/issues/detail?id=6666.
97 const int kTestArea = 416;
98 #else
92 const int kTestArea = 512; 99 const int kTestArea = 512;
100 #endif
93 const int kRectSize = 32; 101 const int kRectSize = 32;
94 std::unique_ptr<ScreenDrawer> drawer = ScreenDrawer::Create(); 102 std::unique_ptr<ScreenDrawer> drawer = ScreenDrawer::Create();
95 if (!drawer || drawer->DrawableRegion().is_empty()) { 103 if (!drawer || drawer->DrawableRegion().is_empty()) {
96 LOG(LS_WARNING) << "No ScreenDrawer implementation for current platform."; 104 LOG(LS_WARNING) << "No ScreenDrawer implementation for current platform.";
97 return; 105 return;
98 } 106 }
99 if (drawer->DrawableRegion().width() < kTestArea || 107 if (drawer->DrawableRegion().width() < kTestArea ||
100 drawer->DrawableRegion().height() < kTestArea) { 108 drawer->DrawableRegion().height() < kTestArea) {
101 LOG(LS_WARNING) << "ScreenDrawer::DrawableRegion() is too small for the " 109 LOG(LS_WARNING) << "ScreenDrawer::DrawableRegion() is too small for the "
102 "CaptureUpdatedRegion tests."; 110 "CaptureUpdatedRegion tests.";
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 // should be removed after flaky of ScreenCapturerIntegrationTest has 218 // should be removed after flaky of ScreenCapturerIntegrationTest has
211 // been resolved. 219 // been resolved.
212 else if (i == wait_capture_round - 1) { 220 else if (i == wait_capture_round - 1) {
213 std::string result; 221 std::string result;
214 rtc::Base64::EncodeFromArray(frame->data(), 222 rtc::Base64::EncodeFromArray(frame->data(),
215 frame->size().height() * frame->stride(), 223 frame->size().height() * frame->stride(),
216 &result); 224 &result);
217 std::cout << frame->size().width() << " x " << frame->size().height() 225 std::cout << frame->size().width() << " x " << frame->size().height()
218 << std::endl; 226 << std::endl;
219 // Split the entire string (can be over 4M) into several lines to 227 // Split the entire string (can be over 4M) into several lines to
220 // avoid browser from stucking. 228 // avoid browser from sticking.
221 static const size_t kLineLength = 32768; 229 static const size_t kLineLength = 32768;
222 const char* result_end = result.c_str() + result.length(); 230 const char* result_end = result.c_str() + result.length();
223 for (const char* it = result.c_str(); 231 for (const char* it = result.c_str();
224 it < result_end; 232 it < result_end;
225 it += kLineLength) { 233 it += kLineLength) {
226 const size_t max_length = result_end - it; 234 const size_t max_length = result_end - it;
227 std::cout << std::string(it, std::min(kLineLength, max_length)) 235 std::cout << std::string(it, std::min(kLineLength, max_length))
228 << std::endl; 236 << std::endl;
229 } 237 }
238 std::cout << "Failed to capture rectangle " << rect.left() << " x "
239 << rect.top() << " - " << rect.right() << " x "
240 << rect.bottom() << " with color ("
241 << static_cast<int>(color.red) << ", "
242 << static_cast<int>(color.green) << ", "
243 << static_cast<int>(color.blue) << ", "
244 << static_cast<int>(color.alpha) << ")" << std::endl;
230 ASSERT_TRUE(false) << "ScreenCapturerIntegrationTest may be flaky. " 245 ASSERT_TRUE(false) << "ScreenCapturerIntegrationTest may be flaky. "
231 "Please kindly FYI the broken link to " 246 "If the error message above is "
232 "zijiehe@chromium.org for investigation. If I " 247 "\"////AP///wD///8A\", it's a known issue, "
233 "have not responded as quick as expected, " 248 "which should be able to recover by rerunning "
234 "disable *all* tests in " 249 "the test. Otherwise please kindly FYI the "
250 "broken link to zijiehe@chromium.org for "
251 "investigation. If the failure continually "
252 "happens, but I have not responded as quick as "
253 "expected, disable *all* tests in "
235 "screen_capturer_integration_test.cc to " 254 "screen_capturer_integration_test.cc to "
236 "unblock other developers."; 255 "unblock other developers.";
237 } 256 }
238 } 257 }
239 258
240 if (succeeded_capturers == capturers.size()) { 259 if (succeeded_capturers == capturers.size()) {
241 break; 260 break;
242 } 261 }
243 } 262 }
244 263
245 ASSERT_EQ(succeeded_capturers, capturers.size()); 264 ASSERT_EQ(succeeded_capturers, capturers.size());
246 } 265 }
247 266
248 // Expects |capturer| to successfully capture a frame, and returns it. 267 // Expects |capturer| to successfully capture a frame, and returns it.
249 std::unique_ptr<DesktopFrame> CaptureFrame(DesktopCapturer* capturer) { 268 std::unique_ptr<DesktopFrame> CaptureFrame(DesktopCapturer* capturer) {
250 std::unique_ptr<DesktopFrame> frame; 269 std::unique_ptr<DesktopFrame> frame;
251 EXPECT_CALL(callback_, 270 EXPECT_CALL(callback_,
252 OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _)) 271 OnCaptureResultPtr(DesktopCapturer::Result::SUCCESS, _))
253 .WillOnce(SaveUniquePtrArg(&frame)); 272 .WillOnce(SaveUniquePtrArg(&frame));
254 capturer->CaptureFrame(); 273 capturer->CaptureFrame();
255 EXPECT_TRUE(frame); 274 EXPECT_TRUE(frame);
256 return frame; 275 return frame;
257 } 276 }
258 }; 277 };
259 278
260 // Disabled because it's flaky. 279 TEST_F(ScreenCapturerIntegrationTest, CaptureUpdatedRegion) {
261 // https://bugs.chromium.org/p/webrtc/issues/detail?id=6666
262 TEST_F(ScreenCapturerIntegrationTest, DISABLED_CaptureUpdatedRegion) {
263 TestCaptureUpdatedRegion(); 280 TestCaptureUpdatedRegion();
264 } 281 }
265 282
266 // Disabled because it's flaky. 283 TEST_F(ScreenCapturerIntegrationTest, TwoCapturers) {
267 // https://bugs.chromium.org/p/webrtc/issues/detail?id=6666
268 TEST_F(ScreenCapturerIntegrationTest, DISABLED_TwoCapturers) {
269 std::unique_ptr<DesktopCapturer> capturer2 = std::move(capturer_); 284 std::unique_ptr<DesktopCapturer> capturer2 = std::move(capturer_);
270 SetUp(); 285 SetUp();
271 TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()}); 286 TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()});
272 } 287 }
273 288
274 #if defined(WEBRTC_WIN) 289 #if defined(WEBRTC_WIN)
275 290
276 // Disabled because it's flaky.
277 // https://bugs.chromium.org/p/webrtc/issues/detail?id=6666
278 TEST_F(ScreenCapturerIntegrationTest, 291 TEST_F(ScreenCapturerIntegrationTest,
279 DISABLED_CaptureUpdatedRegionWithDirectxCapturer) { 292 CaptureUpdatedRegionWithDirectxCapturer) {
280 if (!CreateDirectxCapturer()) { 293 if (!CreateDirectxCapturer()) {
281 return; 294 return;
282 } 295 }
283 296
284 TestCaptureUpdatedRegion(); 297 TestCaptureUpdatedRegion();
285 } 298 }
286 299
287 // Disabled because it's flaky. 300 TEST_F(ScreenCapturerIntegrationTest, TwoDirectxCapturers) {
288 // https://bugs.chromium.org/p/webrtc/issues/detail?id=6666
289 TEST_F(ScreenCapturerIntegrationTest, DISABLED_TwoDirectxCapturers) {
290 if (!CreateDirectxCapturer()) { 301 if (!CreateDirectxCapturer()) {
291 return; 302 return;
292 } 303 }
293 304
294 std::unique_ptr<DesktopCapturer> capturer2 = std::move(capturer_); 305 std::unique_ptr<DesktopCapturer> capturer2 = std::move(capturer_);
295 RTC_CHECK(CreateDirectxCapturer()); 306 RTC_CHECK(CreateDirectxCapturer());
296 TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()}); 307 TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()});
297 } 308 }
298 309
299 // Disabled because it's flaky.
300 // https://bugs.chromium.org/p/webrtc/issues/detail?id=6666
301 TEST_F(ScreenCapturerIntegrationTest, 310 TEST_F(ScreenCapturerIntegrationTest,
302 DISABLED_CaptureUpdatedRegionWithMagnifierCapturer) { 311 CaptureUpdatedRegionWithMagnifierCapturer) {
312 // On Windows 8 or later, magnifier APIs return a frame with a border on test
313 // environment, so disable these tests.
314 // Bug https://bugs.chromium.org/p/webrtc/issues/detail?id=6666
315 // TODO(zijiehe): Find the root cause of the border and failure, which cannot
316 // reproduce on my dev machine.
317 if (rtc::IsWindows8OrLater()) {
318 return;
319 }
303 CreateMagnifierCapturer(); 320 CreateMagnifierCapturer();
304 TestCaptureUpdatedRegion(); 321 TestCaptureUpdatedRegion();
305 } 322 }
306 323
307 // Disabled because it's flaky. 324 TEST_F(ScreenCapturerIntegrationTest, TwoMagnifierCapturers) {
308 // https://bugs.chromium.org/p/webrtc/issues/detail?id=6666 325 // On Windows 8 or later, magnifier APIs return a frame with a border on test
309 TEST_F(ScreenCapturerIntegrationTest, DISABLED_TwoMagnifierCapturers) { 326 // environment, so disable these tests.
327 // Bug https://bugs.chromium.org/p/webrtc/issues/detail?id=6666
328 // TODO(zijiehe): Find the root cause of the border and failure, which cannot
329 // reproduce on my dev machine.
330 if (rtc::IsWindows8OrLater()) {
331 return;
332 }
310 CreateMagnifierCapturer(); 333 CreateMagnifierCapturer();
311 std::unique_ptr<DesktopCapturer> capturer2 = std::move(capturer_); 334 std::unique_ptr<DesktopCapturer> capturer2 = std::move(capturer_);
312 CreateMagnifierCapturer(); 335 CreateMagnifierCapturer();
313 TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()}); 336 TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()});
314 } 337 }
315 338
316 // Disabled because it's flaky.
317 // https://bugs.chromium.org/p/webrtc/issues/detail?id=6666
318 TEST_F(ScreenCapturerIntegrationTest, 339 TEST_F(ScreenCapturerIntegrationTest,
319 DISABLED_MaybeCaptureUpdatedRegionWithDirectxCapturer) { 340 MaybeCaptureUpdatedRegionWithDirectxCapturer) {
320 // Even DirectX capturer is not supported in current system, we should be able 341 // Even DirectX capturer is not supported in current system, we should be able
321 // to select a usable capturer. 342 // to select a usable capturer.
322 MaybeCreateDirectxCapturer(); 343 MaybeCreateDirectxCapturer();
323 TestCaptureUpdatedRegion(); 344 TestCaptureUpdatedRegion();
324 } 345 }
325 346
326 #endif // defined(WEBRTC_WIN) 347 #endif // defined(WEBRTC_WIN)
327 348
328 } // namespace webrtc 349 } // 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