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

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

Issue 2492723002: Add more logging in ScreenCapturerIntegrationTest (Closed)
Patch Set: Resolve review comments Created 4 years, 1 month 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 | webrtc/modules/desktop_capture/screen_drawer_win.cc » ('j') | 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
11 #include <string.h> 11 #include <string.h>
12 12
13 #include <algorithm> 13 #include <algorithm>
14 #include <initializer_list> 14 #include <initializer_list>
15 #include <iostream> // TODO(zijiehe): Remove once flaky has been resolved.
15 #include <memory> 16 #include <memory>
16 #include <utility> 17 #include <utility>
17 18
19 // TODO(zijiehe): Remove once flaky has been resolved.
20 #include "webrtc/base/base64.h"
18 #include "webrtc/base/checks.h" 21 #include "webrtc/base/checks.h"
19 #include "webrtc/base/constructormagic.h" 22 #include "webrtc/base/constructormagic.h"
20 #include "webrtc/base/logging.h" 23 #include "webrtc/base/logging.h"
21 #include "webrtc/modules/desktop_capture/desktop_capturer.h" 24 #include "webrtc/modules/desktop_capture/desktop_capturer.h"
22 #include "webrtc/modules/desktop_capture/desktop_capture_options.h" 25 #include "webrtc/modules/desktop_capture/desktop_capture_options.h"
23 #include "webrtc/modules/desktop_capture/desktop_frame.h" 26 #include "webrtc/modules/desktop_capture/desktop_frame.h"
24 #include "webrtc/modules/desktop_capture/desktop_region.h" 27 #include "webrtc/modules/desktop_capture/desktop_region.h"
25 #include "webrtc/modules/desktop_capture/mock_desktop_capturer_callback.h" 28 #include "webrtc/modules/desktop_capture/mock_desktop_capturer_callback.h"
26 #include "webrtc/modules/desktop_capture/rgba_color.h" 29 #include "webrtc/modules/desktop_capture/rgba_color.h"
27 #include "webrtc/modules/desktop_capture/screen_drawer.h" 30 #include "webrtc/modules/desktop_capture/screen_drawer.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
109 // by |c|) its primary colors is |i|, and the other two are 0x7f. So we 112 // by |c|) its primary colors is |i|, and the other two are 0x7f. So we
110 // won't draw a black or white rectangle. 113 // won't draw a black or white rectangle.
111 for (int c = 0; c < 3; c++) { 114 for (int c = 0; c < 3; c++) {
112 // A fixed size rectangle. 115 // A fixed size rectangle.
113 for (int i = 0; i < kTestArea - kRectSize; i += 16) { 116 for (int i = 0; i < kTestArea - kRectSize; i += 16) {
114 DesktopRect rect = DesktopRect::MakeXYWH(i, i, kRectSize, kRectSize); 117 DesktopRect rect = DesktopRect::MakeXYWH(i, i, kRectSize, kRectSize);
115 rect.Translate(drawer->DrawableRegion().top_left()); 118 rect.Translate(drawer->DrawableRegion().top_left());
116 RgbaColor color((c == 0 ? (i & 0xff) : 0x7f), 119 RgbaColor color((c == 0 ? (i & 0xff) : 0x7f),
117 (c == 1 ? (i & 0xff) : 0x7f), 120 (c == 1 ? (i & 0xff) : 0x7f),
118 (c == 2 ? (i & 0xff) : 0x7f)); 121 (c == 2 ? (i & 0xff) : 0x7f));
119 TestCaptureOneFrame(capturers, drawer.get(), rect, color); 122 // Fail fast.
123 ASSERT_NO_FATAL_FAILURE(
124 TestCaptureOneFrame(capturers, drawer.get(), rect, color));
120 } 125 }
121 126
122 // A variable-size rectangle. 127 // A variable-size rectangle.
123 for (int i = 0; i < kTestArea - kRectSize; i += 16) { 128 for (int i = 0; i < kTestArea - kRectSize; i += 16) {
124 DesktopRect rect = DesktopRect::MakeXYWH(kRectSize, kRectSize, i, i); 129 DesktopRect rect = DesktopRect::MakeXYWH(kRectSize, kRectSize, i, i);
125 rect.Translate(drawer->DrawableRegion().top_left()); 130 rect.Translate(drawer->DrawableRegion().top_left());
126 RgbaColor color((c == 0 ? (i & 0xff) : 0x7f), 131 RgbaColor color((c == 0 ? (i & 0xff) : 0x7f),
127 (c == 1 ? (i & 0xff) : 0x7f), 132 (c == 1 ? (i & 0xff) : 0x7f),
128 (c == 2 ? (i & 0xff) : 0x7f)); 133 (c == 2 ? (i & 0xff) : 0x7f));
129 TestCaptureOneFrame(capturers, drawer.get(), rect, color); 134 // Fail fast.
135 ASSERT_NO_FATAL_FAILURE(
136 TestCaptureOneFrame(capturers, drawer.get(), rect, color));
130 } 137 }
131 } 138 }
132 } 139 }
133 140
134 void TestCaptureUpdatedRegion() { 141 void TestCaptureUpdatedRegion() {
135 TestCaptureUpdatedRegion({capturer_.get()}); 142 TestCaptureUpdatedRegion({capturer_.get()});
136 } 143 }
137 144
138 #if defined(WEBRTC_WIN) 145 #if defined(WEBRTC_WIN)
139 // Enable allow_directx_capturer in DesktopCaptureOptions, but let 146 // Enable allow_directx_capturer in DesktopCaptureOptions, but let
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 RgbaColor color) { 183 RgbaColor color) {
177 const int wait_capture_round = 600; 184 const int wait_capture_round = 600;
178 drawer->Clear(); 185 drawer->Clear();
179 size_t succeeded_capturers = 0; 186 size_t succeeded_capturers = 0;
180 for (int i = 0; i < wait_capture_round; i++) { 187 for (int i = 0; i < wait_capture_round; i++) {
181 drawer->DrawRectangle(rect, color); 188 drawer->DrawRectangle(rect, color);
182 drawer->WaitForPendingDraws(); 189 drawer->WaitForPendingDraws();
183 for (size_t j = 0; j < capturers.size(); j++) { 190 for (size_t j = 0; j < capturers.size(); j++) {
184 if (capturers[j] == nullptr) { 191 if (capturers[j] == nullptr) {
185 // DesktopCapturer should return an empty updated_region() if no 192 // DesktopCapturer should return an empty updated_region() if no
186 // update detected. So we won't test it again if it has captured 193 // update detected. So we won't test it again if it has captured the
187 // the rectangle we drew. 194 // rectangle we drew.
188 continue; 195 continue;
189 } 196 }
190 std::unique_ptr<DesktopFrame> frame = CaptureFrame(capturers[j]); 197 std::unique_ptr<DesktopFrame> frame = CaptureFrame(capturers[j]);
191 if (!frame) { 198 if (!frame) {
192 // CaptureFrame() has triggered an assertion failure already, we 199 // CaptureFrame() has triggered an assertion failure already, we only
193 // only need to return here. 200 // need to return here.
194 return; 201 return;
195 } 202 }
196 203
197 if (ArePixelsColoredBy( 204 if (ArePixelsColoredBy(
198 *frame, rect, color, drawer->MayDrawIncompleteShapes())) { 205 *frame, rect, color, drawer->MayDrawIncompleteShapes())) {
199 capturers[j] = nullptr; 206 capturers[j] = nullptr;
200 succeeded_capturers++; 207 succeeded_capturers++;
201 } 208 }
209 // The following else if statement is for debugging purpose only, which
210 // should be removed after flaky of ScreenCapturerIntegrationTest has
211 // been resolved.
212 else if (i == wait_capture_round - 1) {
213 std::string result;
214 rtc::Base64::EncodeFromArray(frame->data(),
215 frame->size().height() * frame->stride(),
216 &result);
217 std::cout << frame->size().width() << " x " << frame->size().height()
218 << std::endl;
219 // Split the entire string (can be over 4M) into several lines to
220 // avoid browser from stucking.
221 static const size_t kLineLength = 32768;
222 const char* result_end = result.c_str() + result.length();
223 for (const char* it = result.c_str();
224 it < result_end;
225 it += kLineLength) {
226 const size_t max_length = result_end - it;
227 std::cout << std::string(it, std::min(kLineLength, max_length))
228 << std::endl;
229 }
230 ASSERT_TRUE(false) << "ScreenCapturerIntegrationTest may be flaky. "
231 "Please kindly FYI the broken link to "
232 "zijiehe@chromium.org for investigation. If I "
233 "have not responded as quick as expected, "
234 "disable *all* tests in "
235 "screen_capturer_integration_test.cc to "
236 "unblock other developers.";
237 }
202 } 238 }
203 239
204 if (succeeded_capturers == capturers.size()) { 240 if (succeeded_capturers == capturers.size()) {
205 break; 241 break;
206 } 242 }
207 } 243 }
208 244
209 ASSERT_EQ(succeeded_capturers, capturers.size()); 245 ASSERT_EQ(succeeded_capturers, capturers.size());
210 } 246 }
211 247
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 DISABLED_MaybeCaptureUpdatedRegionWithDirectxCapturer) { 319 DISABLED_MaybeCaptureUpdatedRegionWithDirectxCapturer) {
284 // Even DirectX capturer is not supported in current system, we should be able 320 // Even DirectX capturer is not supported in current system, we should be able
285 // to select a usable capturer. 321 // to select a usable capturer.
286 MaybeCreateDirectxCapturer(); 322 MaybeCreateDirectxCapturer();
287 TestCaptureUpdatedRegion(); 323 TestCaptureUpdatedRegion();
288 } 324 }
289 325
290 #endif // defined(WEBRTC_WIN) 326 #endif // defined(WEBRTC_WIN)
291 327
292 } // namespace webrtc 328 } // namespace webrtc
OLDNEW
« no previous file with comments | « no previous file | webrtc/modules/desktop_capture/screen_drawer_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698