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