Chromium Code Reviews| Index: webrtc/modules/desktop_capture/screen_capturer_integration_test.cc |
| diff --git a/webrtc/modules/desktop_capture/screen_capturer_integration_test.cc b/webrtc/modules/desktop_capture/screen_capturer_integration_test.cc |
| index 64fdd4a08468b15916934db0f57aeb88e915e267..c3712d9c7ac94e8f83ba5cd4ca32ed0b86a9c412 100644 |
| --- a/webrtc/modules/desktop_capture/screen_capturer_integration_test.cc |
| +++ b/webrtc/modules/desktop_capture/screen_capturer_integration_test.cc |
| @@ -12,9 +12,12 @@ |
| #include <algorithm> |
| #include <initializer_list> |
| +#include <iostream> // TODO(zijiehe): Remove once flaky has been resolved. |
| #include <memory> |
| #include <utility> |
| +// TODO(zijiehe): Remove once flaky has been resolved. |
| +#include "webrtc/base/base64.h" |
| #include "webrtc/base/checks.h" |
| #include "webrtc/base/constructormagic.h" |
| #include "webrtc/base/logging.h" |
| @@ -116,7 +119,10 @@ class ScreenCapturerIntegrationTest : public testing::Test { |
| RgbaColor color((c == 0 ? (i & 0xff) : 0x7f), |
| (c == 1 ? (i & 0xff) : 0x7f), |
| (c == 2 ? (i & 0xff) : 0x7f)); |
| - TestCaptureOneFrame(capturers, drawer.get(), rect, color); |
| + if (!TestCaptureOneFrame(capturers, drawer.get(), rect, color)) { |
| + // Fail fast. |
| + return; |
|
Sergey Ulanov
2016/11/18 01:21:42
Not sure why we need to return result here? The ca
Hzj_jie
2016/11/18 04:32:00
Ah, it's simply because I do not know this functio
|
| + } |
| } |
| // A variable-size rectangle. |
| @@ -126,7 +132,10 @@ class ScreenCapturerIntegrationTest : public testing::Test { |
| RgbaColor color((c == 0 ? (i & 0xff) : 0x7f), |
| (c == 1 ? (i & 0xff) : 0x7f), |
| (c == 2 ? (i & 0xff) : 0x7f)); |
| - TestCaptureOneFrame(capturers, drawer.get(), rect, color); |
| + if (!TestCaptureOneFrame(capturers, drawer.get(), rect, color)) { |
| + // Fail fast. |
| + return; |
| + } |
| } |
| } |
| } |
| @@ -170,7 +179,11 @@ class ScreenCapturerIntegrationTest : public testing::Test { |
| // typically 30 seconds, until they succeeded captured a |color| rectangle at |
| // |rect|. This function uses |drawer|->WaitForPendingDraws() between two |
| // attempts to wait for the screen to update. |
| - void TestCaptureOneFrame(std::vector<DesktopCapturer*> capturers, |
| + // |
| + // Returns false to indicate the error. |
| + // TODO(zijiehe): Remove return value of this function once flaky of |
| + // ScreenCapturerIntegrationTest has been resolved. |
| + bool TestCaptureOneFrame(std::vector<DesktopCapturer*> capturers, |
| ScreenDrawer* drawer, |
| DesktopRect rect, |
| RgbaColor color) { |
| @@ -183,15 +196,15 @@ class ScreenCapturerIntegrationTest : public testing::Test { |
| for (size_t j = 0; j < capturers.size(); j++) { |
| if (capturers[j] == nullptr) { |
| // DesktopCapturer should return an empty updated_region() if no |
| - // update detected. So we won't test it again if it has captured |
| - // the rectangle we drew. |
| + // update detected. So we won't test it again if it has captured the |
| + // rectangle we drew. |
| continue; |
| } |
| std::unique_ptr<DesktopFrame> frame = CaptureFrame(capturers[j]); |
| if (!frame) { |
| - // CaptureFrame() has triggered an assertion failure already, we |
| - // only need to return here. |
| - return; |
| + // CaptureFrame() has triggered an assertion failure already, we only |
| + // need to return here. |
| + return false; |
| } |
| if (ArePixelsColoredBy( |
| @@ -199,6 +212,33 @@ class ScreenCapturerIntegrationTest : public testing::Test { |
| capturers[j] = nullptr; |
| succeeded_capturers++; |
| } |
| + // The following else if statement is for debugging purpose only, which |
| + // should be removed after flaky of ScreenCapturerIntegrationTest has |
| + // been resolved. |
| + else if (i == wait_capture_round - 1) { |
| + std::string result; |
| + rtc::Base64::EncodeFromArray(frame->data(), |
| + frame->size().height() * frame->stride(), |
| + &result); |
| + // LOG and ASSERT won't output a long string, so we can only use |
|
Sergey Ulanov
2016/11/18 01:21:42
What do you mean by "long string"? It looks like |
Hzj_jie
2016/11/18 04:32:00
Done.
|
| + // std::out here. |
| + std::cout << frame->size().width() << " x " << frame->size().height() |
| + << std::endl; |
| + // Split the entire string (can be over 4M) into several lines to |
| + // avoid browser from stucking. |
| + static const size_t kLineLength = 32768; |
| + const char* result_end = result.c_str() + result.length(); |
| + for (const char* it = result.c_str(); |
| + it < result_end; |
| + it += kLineLength) { |
| + const size_t max_length = result_end - it; |
| + std::cout << std::string(it, std::min(kLineLength, max_length)) |
| + << std::endl; |
| + } |
| + EXPECT_TRUE(false) << "ScreenCapturerIntegrationTest is flaky. " |
| + "Please disable *all* tests in " |
| + "screen_capturer_integration_test.cc"; |
| + } |
| } |
| if (succeeded_capturers == capturers.size()) { |
| @@ -206,7 +246,8 @@ class ScreenCapturerIntegrationTest : public testing::Test { |
| } |
| } |
| - ASSERT_EQ(succeeded_capturers, capturers.size()); |
| + EXPECT_EQ(succeeded_capturers, capturers.size()); |
| + return succeeded_capturers == capturers.size(); |
| } |
| // Expects |capturer| to successfully capture a frame, and returns it. |