zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. |
| 3 | * |
| 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 |
| 6 | * tree. An additional intellectual property rights grant can be found |
| 7 | * in the file PATENTS. All contributing project authors may |
| 8 | * be found in the AUTHORS file in the root of the source tree. |
| 9 | */ |
| 10 | |
| 11 | #include <string.h> |
| 12 | |
| 13 | #include <algorithm> |
| 14 | #include <initializer_list> |
zijiehe | 2184155 | 2016-11-18 20:31:02 -0800 | [diff] [blame] | 15 | #include <iostream> // TODO(zijiehe): Remove once flaky has been resolved. |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 16 | #include <memory> |
| 17 | #include <utility> |
| 18 | |
zijiehe | 2184155 | 2016-11-18 20:31:02 -0800 | [diff] [blame] | 19 | // TODO(zijiehe): Remove once flaky has been resolved. |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 20 | #include "modules/desktop_capture/desktop_capture_options.h" |
| 21 | #include "modules/desktop_capture/desktop_capturer.h" |
| 22 | #include "modules/desktop_capture/desktop_frame.h" |
| 23 | #include "modules/desktop_capture/desktop_region.h" |
| 24 | #include "modules/desktop_capture/mock_desktop_capturer_callback.h" |
| 25 | #include "modules/desktop_capture/rgba_color.h" |
| 26 | #include "modules/desktop_capture/screen_drawer.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 27 | #include "rtc_base/checks.h" |
Steve Anton | 10542f2 | 2019-01-11 09:11:00 -0800 | [diff] [blame] | 28 | #include "rtc_base/constructor_magic.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 29 | #include "rtc_base/logging.h" |
Artem Titov | a76af0c | 2018-07-23 17:38:12 +0200 | [diff] [blame] | 30 | #include "rtc_base/third_party/base64/base64.h" |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 31 | #include "test/gmock.h" |
| 32 | #include "test/gtest.h" |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 33 | |
| 34 | #if defined(WEBRTC_WIN) |
Mirko Bonadei | 92ea95e | 2017-09-15 06:47:31 +0200 | [diff] [blame] | 35 | #include "modules/desktop_capture/win/screen_capturer_win_directx.h" |
| 36 | #include "rtc_base/win32.h" |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 37 | #endif // defined(WEBRTC_WIN) |
| 38 | |
| 39 | using ::testing::_; |
| 40 | |
| 41 | namespace webrtc { |
| 42 | |
| 43 | namespace { |
| 44 | |
zijiehe | e83f4b3 | 2016-12-08 11:47:01 -0800 | [diff] [blame] | 45 | ACTION_P2(SaveCaptureResult, result, dest) { |
| 46 | *result = arg0; |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 47 | *dest = std::move(*arg1); |
| 48 | } |
| 49 | |
| 50 | // Returns true if color in |rect| of |frame| is |color|. |
| 51 | bool ArePixelsColoredBy(const DesktopFrame& frame, |
| 52 | DesktopRect rect, |
| 53 | RgbaColor color, |
| 54 | bool may_partially_draw) { |
| 55 | if (!may_partially_draw) { |
| 56 | // updated_region() should cover the painted area. |
| 57 | DesktopRegion updated_region(frame.updated_region()); |
| 58 | updated_region.IntersectWith(rect); |
| 59 | if (!updated_region.Equals(DesktopRegion(rect))) { |
| 60 | return false; |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | // Color in the |rect| should be |color|. |
| 65 | uint8_t* row = frame.GetFrameDataAtPos(rect.top_left()); |
| 66 | for (int i = 0; i < rect.height(); i++) { |
| 67 | uint8_t* column = row; |
| 68 | for (int j = 0; j < rect.width(); j++) { |
| 69 | if (color != RgbaColor(column)) { |
| 70 | return false; |
| 71 | } |
| 72 | column += DesktopFrame::kBytesPerPixel; |
| 73 | } |
| 74 | row += frame.stride(); |
| 75 | } |
| 76 | return true; |
| 77 | } |
| 78 | |
| 79 | } // namespace |
| 80 | |
Mirko Bonadei | 6a489f2 | 2019-04-09 15:11:12 +0200 | [diff] [blame] | 81 | class ScreenCapturerIntegrationTest : public ::testing::Test { |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 82 | public: |
| 83 | void SetUp() override { |
zijiehe | 54fd579 | 2016-11-02 14:49:35 -0700 | [diff] [blame] | 84 | capturer_ = DesktopCapturer::CreateScreenCapturer( |
| 85 | DesktopCaptureOptions::CreateDefault()); |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 86 | } |
| 87 | |
| 88 | protected: |
| 89 | void TestCaptureUpdatedRegion( |
zijiehe | 54fd579 | 2016-11-02 14:49:35 -0700 | [diff] [blame] | 90 | std::initializer_list<DesktopCapturer*> capturers) { |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 91 | RTC_DCHECK(capturers.size() > 0); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 92 | // A large enough area for the tests, which should be able to be fulfilled |
| 93 | // by most systems. |
zijiehe | 166e59a | 2016-11-29 14:46:46 -0800 | [diff] [blame] | 94 | #if defined(WEBRTC_WIN) |
| 95 | // On Windows, an interesting warning window may pop up randomly. The root |
| 96 | // cause is still under investigation, so reduce the test area to work |
| 97 | // around. Bug https://bugs.chromium.org/p/webrtc/issues/detail?id=6666. |
| 98 | const int kTestArea = 416; |
| 99 | #else |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 100 | const int kTestArea = 512; |
zijiehe | 166e59a | 2016-11-29 14:46:46 -0800 | [diff] [blame] | 101 | #endif |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 102 | const int kRectSize = 32; |
| 103 | std::unique_ptr<ScreenDrawer> drawer = ScreenDrawer::Create(); |
| 104 | if (!drawer || drawer->DrawableRegion().is_empty()) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 105 | RTC_LOG(LS_WARNING) |
| 106 | << "No ScreenDrawer implementation for current platform."; |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 107 | return; |
| 108 | } |
| 109 | if (drawer->DrawableRegion().width() < kTestArea || |
| 110 | drawer->DrawableRegion().height() < kTestArea) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 111 | RTC_LOG(LS_WARNING) |
| 112 | << "ScreenDrawer::DrawableRegion() is too small for the " |
| 113 | "CaptureUpdatedRegion tests."; |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 114 | return; |
| 115 | } |
| 116 | |
zijiehe | 54fd579 | 2016-11-02 14:49:35 -0700 | [diff] [blame] | 117 | for (DesktopCapturer* capturer : capturers) { |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 118 | capturer->Start(&callback_); |
| 119 | } |
| 120 | |
| 121 | // Draw a set of |kRectSize| by |kRectSize| rectangles at (|i|, |i|), or |
| 122 | // |i| by |i| rectangles at (|kRectSize|, |kRectSize|). One of (controlled |
| 123 | // by |c|) its primary colors is |i|, and the other two are 0x7f. So we |
| 124 | // won't draw a black or white rectangle. |
| 125 | for (int c = 0; c < 3; c++) { |
| 126 | // A fixed size rectangle. |
| 127 | for (int i = 0; i < kTestArea - kRectSize; i += 16) { |
| 128 | DesktopRect rect = DesktopRect::MakeXYWH(i, i, kRectSize, kRectSize); |
| 129 | rect.Translate(drawer->DrawableRegion().top_left()); |
| 130 | RgbaColor color((c == 0 ? (i & 0xff) : 0x7f), |
| 131 | (c == 1 ? (i & 0xff) : 0x7f), |
| 132 | (c == 2 ? (i & 0xff) : 0x7f)); |
zijiehe | 2184155 | 2016-11-18 20:31:02 -0800 | [diff] [blame] | 133 | // Fail fast. |
| 134 | ASSERT_NO_FATAL_FAILURE( |
| 135 | TestCaptureOneFrame(capturers, drawer.get(), rect, color)); |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | // A variable-size rectangle. |
| 139 | for (int i = 0; i < kTestArea - kRectSize; i += 16) { |
| 140 | DesktopRect rect = DesktopRect::MakeXYWH(kRectSize, kRectSize, i, i); |
| 141 | rect.Translate(drawer->DrawableRegion().top_left()); |
| 142 | RgbaColor color((c == 0 ? (i & 0xff) : 0x7f), |
| 143 | (c == 1 ? (i & 0xff) : 0x7f), |
| 144 | (c == 2 ? (i & 0xff) : 0x7f)); |
zijiehe | 2184155 | 2016-11-18 20:31:02 -0800 | [diff] [blame] | 145 | // Fail fast. |
| 146 | ASSERT_NO_FATAL_FAILURE( |
| 147 | TestCaptureOneFrame(capturers, drawer.get(), rect, color)); |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 148 | } |
| 149 | } |
| 150 | } |
| 151 | |
| 152 | void TestCaptureUpdatedRegion() { |
| 153 | TestCaptureUpdatedRegion({capturer_.get()}); |
| 154 | } |
| 155 | |
| 156 | #if defined(WEBRTC_WIN) |
| 157 | // Enable allow_directx_capturer in DesktopCaptureOptions, but let |
zijiehe | 54fd579 | 2016-11-02 14:49:35 -0700 | [diff] [blame] | 158 | // DesktopCapturer::CreateScreenCapturer() to decide whether a DirectX |
| 159 | // capturer should be used. |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 160 | void MaybeCreateDirectxCapturer() { |
| 161 | DesktopCaptureOptions options(DesktopCaptureOptions::CreateDefault()); |
| 162 | options.set_allow_directx_capturer(true); |
zijiehe | 54fd579 | 2016-11-02 14:49:35 -0700 | [diff] [blame] | 163 | capturer_ = DesktopCapturer::CreateScreenCapturer(options); |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 164 | } |
| 165 | |
| 166 | bool CreateDirectxCapturer() { |
| 167 | if (!ScreenCapturerWinDirectx::IsSupported()) { |
Mirko Bonadei | 675513b | 2017-11-09 11:09:25 +0100 | [diff] [blame] | 168 | RTC_LOG(LS_WARNING) << "Directx capturer is not supported"; |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 169 | return false; |
| 170 | } |
| 171 | |
| 172 | MaybeCreateDirectxCapturer(); |
| 173 | return true; |
| 174 | } |
| 175 | |
| 176 | void CreateMagnifierCapturer() { |
| 177 | DesktopCaptureOptions options(DesktopCaptureOptions::CreateDefault()); |
| 178 | options.set_allow_use_magnification_api(true); |
zijiehe | 54fd579 | 2016-11-02 14:49:35 -0700 | [diff] [blame] | 179 | capturer_ = DesktopCapturer::CreateScreenCapturer(options); |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 180 | } |
| 181 | #endif // defined(WEBRTC_WIN) |
| 182 | |
zijiehe | 54fd579 | 2016-11-02 14:49:35 -0700 | [diff] [blame] | 183 | std::unique_ptr<DesktopCapturer> capturer_; |
| 184 | MockDesktopCapturerCallback callback_; |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 185 | |
| 186 | private: |
| 187 | // Repeats capturing the frame by using |capturers| one-by-one for 600 times, |
| 188 | // typically 30 seconds, until they succeeded captured a |color| rectangle at |
| 189 | // |rect|. This function uses |drawer|->WaitForPendingDraws() between two |
| 190 | // attempts to wait for the screen to update. |
zijiehe | 54fd579 | 2016-11-02 14:49:35 -0700 | [diff] [blame] | 191 | void TestCaptureOneFrame(std::vector<DesktopCapturer*> capturers, |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 192 | ScreenDrawer* drawer, |
| 193 | DesktopRect rect, |
| 194 | RgbaColor color) { |
| 195 | const int wait_capture_round = 600; |
| 196 | drawer->Clear(); |
| 197 | size_t succeeded_capturers = 0; |
| 198 | for (int i = 0; i < wait_capture_round; i++) { |
| 199 | drawer->DrawRectangle(rect, color); |
| 200 | drawer->WaitForPendingDraws(); |
| 201 | for (size_t j = 0; j < capturers.size(); j++) { |
| 202 | if (capturers[j] == nullptr) { |
zijiehe | 54fd579 | 2016-11-02 14:49:35 -0700 | [diff] [blame] | 203 | // DesktopCapturer should return an empty updated_region() if no |
zijiehe | 2184155 | 2016-11-18 20:31:02 -0800 | [diff] [blame] | 204 | // update detected. So we won't test it again if it has captured the |
| 205 | // rectangle we drew. |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 206 | continue; |
| 207 | } |
| 208 | std::unique_ptr<DesktopFrame> frame = CaptureFrame(capturers[j]); |
| 209 | if (!frame) { |
zijiehe | 2184155 | 2016-11-18 20:31:02 -0800 | [diff] [blame] | 210 | // CaptureFrame() has triggered an assertion failure already, we only |
| 211 | // need to return here. |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 212 | return; |
| 213 | } |
| 214 | |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 215 | if (ArePixelsColoredBy(*frame, rect, color, |
| 216 | drawer->MayDrawIncompleteShapes())) { |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 217 | capturers[j] = nullptr; |
| 218 | succeeded_capturers++; |
| 219 | } |
zijiehe | 2184155 | 2016-11-18 20:31:02 -0800 | [diff] [blame] | 220 | // The following else if statement is for debugging purpose only, which |
| 221 | // should be removed after flaky of ScreenCapturerIntegrationTest has |
| 222 | // been resolved. |
| 223 | else if (i == wait_capture_round - 1) { |
| 224 | std::string result; |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 225 | rtc::Base64::EncodeFromArray( |
| 226 | frame->data(), frame->size().height() * frame->stride(), &result); |
zijiehe | 2184155 | 2016-11-18 20:31:02 -0800 | [diff] [blame] | 227 | std::cout << frame->size().width() << " x " << frame->size().height() |
| 228 | << std::endl; |
| 229 | // Split the entire string (can be over 4M) into several lines to |
zijiehe | 166e59a | 2016-11-29 14:46:46 -0800 | [diff] [blame] | 230 | // avoid browser from sticking. |
zijiehe | 2184155 | 2016-11-18 20:31:02 -0800 | [diff] [blame] | 231 | static const size_t kLineLength = 32768; |
| 232 | const char* result_end = result.c_str() + result.length(); |
Yves Gerey | 665174f | 2018-06-19 15:03:05 +0200 | [diff] [blame] | 233 | for (const char* it = result.c_str(); it < result_end; |
zijiehe | 2184155 | 2016-11-18 20:31:02 -0800 | [diff] [blame] | 234 | it += kLineLength) { |
| 235 | const size_t max_length = result_end - it; |
| 236 | std::cout << std::string(it, std::min(kLineLength, max_length)) |
| 237 | << std::endl; |
| 238 | } |
zijiehe | 166e59a | 2016-11-29 14:46:46 -0800 | [diff] [blame] | 239 | std::cout << "Failed to capture rectangle " << rect.left() << " x " |
| 240 | << rect.top() << " - " << rect.right() << " x " |
| 241 | << rect.bottom() << " with color (" |
| 242 | << static_cast<int>(color.red) << ", " |
| 243 | << static_cast<int>(color.green) << ", " |
| 244 | << static_cast<int>(color.blue) << ", " |
| 245 | << static_cast<int>(color.alpha) << ")" << std::endl; |
zijiehe | 2184155 | 2016-11-18 20:31:02 -0800 | [diff] [blame] | 246 | ASSERT_TRUE(false) << "ScreenCapturerIntegrationTest may be flaky. " |
zijiehe | e83f4b3 | 2016-12-08 11:47:01 -0800 | [diff] [blame] | 247 | "Please kindly FYI the broken link to " |
| 248 | "zijiehe@chromium.org for investigation. If " |
| 249 | "the failure continually happens, but I have " |
| 250 | "not responded as quick as expected, disable " |
| 251 | "*all* tests in " |
zijiehe | 2184155 | 2016-11-18 20:31:02 -0800 | [diff] [blame] | 252 | "screen_capturer_integration_test.cc to " |
| 253 | "unblock other developers."; |
| 254 | } |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 255 | } |
| 256 | |
| 257 | if (succeeded_capturers == capturers.size()) { |
| 258 | break; |
| 259 | } |
| 260 | } |
| 261 | |
| 262 | ASSERT_EQ(succeeded_capturers, capturers.size()); |
| 263 | } |
| 264 | |
| 265 | // Expects |capturer| to successfully capture a frame, and returns it. |
zijiehe | 54fd579 | 2016-11-02 14:49:35 -0700 | [diff] [blame] | 266 | std::unique_ptr<DesktopFrame> CaptureFrame(DesktopCapturer* capturer) { |
zijiehe | e83f4b3 | 2016-12-08 11:47:01 -0800 | [diff] [blame] | 267 | for (int i = 0; i < 10; i++) { |
| 268 | std::unique_ptr<DesktopFrame> frame; |
| 269 | DesktopCapturer::Result result; |
| 270 | EXPECT_CALL(callback_, OnCaptureResultPtr(_, _)) |
| 271 | .WillOnce(SaveCaptureResult(&result, &frame)); |
| 272 | capturer->CaptureFrame(); |
Mirko Bonadei | 6a489f2 | 2019-04-09 15:11:12 +0200 | [diff] [blame] | 273 | ::testing::Mock::VerifyAndClearExpectations(&callback_); |
zijiehe | e83f4b3 | 2016-12-08 11:47:01 -0800 | [diff] [blame] | 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; |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 284 | } |
| 285 | }; |
| 286 | |
zijiehe | 8d1649d | 2016-12-09 16:00:00 -0800 | [diff] [blame] | 287 | #if defined(WEBRTC_WIN) |
| 288 | // ScreenCapturerWinGdi randomly returns blank screen, the root cause is still |
| 289 | // unknown. Bug, https://bugs.chromium.org/p/webrtc/issues/detail?id=6843. |
Henrik Kjellander | 99f7bfd | 2016-12-12 08:29:55 +0100 | [diff] [blame] | 290 | #define MAYBE_CaptureUpdatedRegion DISABLED_CaptureUpdatedRegion |
zijiehe | 8d1649d | 2016-12-09 16:00:00 -0800 | [diff] [blame] | 291 | #else |
| 292 | #define MAYBE_CaptureUpdatedRegion CaptureUpdatedRegion |
zijiehe | e83f4b3 | 2016-12-08 11:47:01 -0800 | [diff] [blame] | 293 | #endif |
zijiehe | 8d1649d | 2016-12-09 16:00:00 -0800 | [diff] [blame] | 294 | TEST_F(ScreenCapturerIntegrationTest, MAYBE_CaptureUpdatedRegion) { |
| 295 | TestCaptureUpdatedRegion(); |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 296 | } |
| 297 | |
zijiehe | 8d1649d | 2016-12-09 16:00:00 -0800 | [diff] [blame] | 298 | #if defined(WEBRTC_WIN) |
| 299 | // ScreenCapturerWinGdi randomly returns blank screen, the root cause is still |
| 300 | // unknown. Bug, https://bugs.chromium.org/p/webrtc/issues/detail?id=6843. |
Henrik Kjellander | 99f7bfd | 2016-12-12 08:29:55 +0100 | [diff] [blame] | 301 | #define MAYBE_TwoCapturers DISABLED_TwoCapturers |
zijiehe | 8d1649d | 2016-12-09 16:00:00 -0800 | [diff] [blame] | 302 | #else |
| 303 | #define MAYBE_TwoCapturers TwoCapturers |
| 304 | #endif |
| 305 | TEST_F(ScreenCapturerIntegrationTest, MAYBE_TwoCapturers) { |
zijiehe | 54fd579 | 2016-11-02 14:49:35 -0700 | [diff] [blame] | 306 | std::unique_ptr<DesktopCapturer> capturer2 = std::move(capturer_); |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 307 | SetUp(); |
| 308 | TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()}); |
| 309 | } |
| 310 | |
| 311 | #if defined(WEBRTC_WIN) |
| 312 | |
Zijie He | 0cab085 | 2017-08-24 11:30:02 -0700 | [diff] [blame] | 313 | // Windows cannot capture contents on VMs hosted in GCE. See bug |
| 314 | // https://bugs.chromium.org/p/webrtc/issues/detail?id=8153. |
| 315 | TEST_F(ScreenCapturerIntegrationTest, |
| 316 | DISABLED_CaptureUpdatedRegionWithDirectxCapturer) { |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 317 | if (!CreateDirectxCapturer()) { |
| 318 | return; |
| 319 | } |
| 320 | |
| 321 | TestCaptureUpdatedRegion(); |
| 322 | } |
| 323 | |
Zijie He | 0cab085 | 2017-08-24 11:30:02 -0700 | [diff] [blame] | 324 | TEST_F(ScreenCapturerIntegrationTest, DISABLED_TwoDirectxCapturers) { |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 325 | if (!CreateDirectxCapturer()) { |
| 326 | return; |
| 327 | } |
| 328 | |
zijiehe | 54fd579 | 2016-11-02 14:49:35 -0700 | [diff] [blame] | 329 | std::unique_ptr<DesktopCapturer> capturer2 = std::move(capturer_); |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 330 | RTC_CHECK(CreateDirectxCapturer()); |
| 331 | TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()}); |
| 332 | } |
| 333 | |
| 334 | TEST_F(ScreenCapturerIntegrationTest, |
Zijie He | 0cab085 | 2017-08-24 11:30:02 -0700 | [diff] [blame] | 335 | DISABLED_CaptureUpdatedRegionWithMagnifierCapturer) { |
zijiehe | 166e59a | 2016-11-29 14:46:46 -0800 | [diff] [blame] | 336 | // On Windows 8 or later, magnifier APIs return a frame with a border on test |
| 337 | // environment, so disable these tests. |
zijiehe | e83f4b3 | 2016-12-08 11:47:01 -0800 | [diff] [blame] | 338 | // Bug https://bugs.chromium.org/p/webrtc/issues/detail?id=6844 |
zijiehe | 166e59a | 2016-11-29 14:46:46 -0800 | [diff] [blame] | 339 | // TODO(zijiehe): Find the root cause of the border and failure, which cannot |
| 340 | // reproduce on my dev machine. |
| 341 | if (rtc::IsWindows8OrLater()) { |
| 342 | return; |
| 343 | } |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 344 | CreateMagnifierCapturer(); |
| 345 | TestCaptureUpdatedRegion(); |
| 346 | } |
| 347 | |
Zijie He | 0cab085 | 2017-08-24 11:30:02 -0700 | [diff] [blame] | 348 | TEST_F(ScreenCapturerIntegrationTest, DISABLED_TwoMagnifierCapturers) { |
zijiehe | 166e59a | 2016-11-29 14:46:46 -0800 | [diff] [blame] | 349 | // On Windows 8 or later, magnifier APIs return a frame with a border on test |
| 350 | // environment, so disable these tests. |
zijiehe | e83f4b3 | 2016-12-08 11:47:01 -0800 | [diff] [blame] | 351 | // Bug https://bugs.chromium.org/p/webrtc/issues/detail?id=6844 |
zijiehe | 166e59a | 2016-11-29 14:46:46 -0800 | [diff] [blame] | 352 | // TODO(zijiehe): Find the root cause of the border and failure, which cannot |
| 353 | // reproduce on my dev machine. |
| 354 | if (rtc::IsWindows8OrLater()) { |
| 355 | return; |
| 356 | } |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 357 | CreateMagnifierCapturer(); |
zijiehe | 54fd579 | 2016-11-02 14:49:35 -0700 | [diff] [blame] | 358 | std::unique_ptr<DesktopCapturer> capturer2 = std::move(capturer_); |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 359 | CreateMagnifierCapturer(); |
| 360 | TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()}); |
| 361 | } |
| 362 | |
| 363 | TEST_F(ScreenCapturerIntegrationTest, |
Zijie He | 0cab085 | 2017-08-24 11:30:02 -0700 | [diff] [blame] | 364 | DISABLED_MaybeCaptureUpdatedRegionWithDirectxCapturer) { |
zijiehe | e83f4b3 | 2016-12-08 11:47:01 -0800 | [diff] [blame] | 365 | if (!rtc::IsWindows8OrLater()) { |
| 366 | // ScreenCapturerWinGdi randomly returns blank screen, the root cause is |
| 367 | // still unknown. Bug, |
| 368 | // https://bugs.chromium.org/p/webrtc/issues/detail?id=6843. |
| 369 | // On Windows 7 or early version, MaybeCreateDirectxCapturer() always |
| 370 | // creates GDI capturer. |
| 371 | return; |
| 372 | } |
zijiehe | 6be0a65 | 2016-10-27 16:50:35 -0700 | [diff] [blame] | 373 | // Even DirectX capturer is not supported in current system, we should be able |
| 374 | // to select a usable capturer. |
| 375 | MaybeCreateDirectxCapturer(); |
| 376 | TestCaptureUpdatedRegion(); |
| 377 | } |
| 378 | |
| 379 | #endif // defined(WEBRTC_WIN) |
| 380 | |
| 381 | } // namespace webrtc |