| Index: webrtc/modules/desktop_capture/screen_capturer_unittest.cc
|
| diff --git a/webrtc/modules/desktop_capture/screen_capturer_unittest.cc b/webrtc/modules/desktop_capture/screen_capturer_unittest.cc
|
| index fa666a929b95a2357d11ed70beb6b64024fb2dd3..38101b3db704ba91c2be16c240c6f78326d02392 100644
|
| --- a/webrtc/modules/desktop_capture/screen_capturer_unittest.cc
|
| +++ b/webrtc/modules/desktop_capture/screen_capturer_unittest.cc
|
| @@ -51,12 +51,15 @@ ACTION_P(SaveUniquePtrArg, dest) {
|
| // Returns true if color in |rect| of |frame| is |color|.
|
| bool ArePixelsColoredBy(const DesktopFrame& frame,
|
| DesktopRect rect,
|
| - RgbaColor color) {
|
| - // updated_region() should cover the painted area.
|
| - DesktopRegion updated_region(frame.updated_region());
|
| - updated_region.IntersectWith(rect);
|
| - if (!updated_region.Equals(DesktopRegion(rect))) {
|
| - return false;
|
| + RgbaColor color,
|
| + bool may_partially_draw) {
|
| + if (!may_partially_draw) {
|
| + // updated_region() should cover the painted area.
|
| + DesktopRegion updated_region(frame.updated_region());
|
| + updated_region.IntersectWith(rect);
|
| + if (!updated_region.Equals(DesktopRegion(rect))) {
|
| + return false;
|
| + }
|
| }
|
|
|
| // Color in the |rect| should be |color|.
|
| @@ -107,18 +110,28 @@ class ScreenCapturerTest : public testing::Test {
|
| capturer->Start(&callback_);
|
| }
|
|
|
| - // Draw a set of |kRectSize| by |kRectSize| rectangles at (|i|, |i|). One of
|
| - // (controlled by |c|) its primary colors is |i|, and the other two are
|
| - // 0xff. So we won't draw a white rectangle.
|
| + // Draw a set of |kRectSize| by |kRectSize| rectangles at (|i|, |i|), or
|
| + // |i| by |i| rectangles at (|kRectSize|, |kRectSize|). One of (controlled
|
| + // by |c|) its primary colors is |i|, and the other two are 0x7f. So we
|
| + // won't draw a black or white rectangle.
|
| for (int c = 0; c < 3; c++) {
|
| + // A fixed size rectangle.
|
| for (int i = 0; i < kTestArea - kRectSize; i += 16) {
|
| DesktopRect rect = DesktopRect::MakeXYWH(i, i, kRectSize, kRectSize);
|
| rect.Translate(drawer->DrawableRegion().top_left());
|
| RgbaColor color((c == 0 ? (i & 0xff) : 0x7f),
|
| (c == 1 ? (i & 0xff) : 0x7f),
|
| (c == 2 ? (i & 0xff) : 0x7f));
|
| - drawer->Clear();
|
| - drawer->DrawRectangle(rect, color);
|
| + TestCaptureOneFrame(capturers, drawer.get(), rect, color);
|
| + }
|
| +
|
| + // A variable-size rectangle.
|
| + for (int i = 0; i < kTestArea - kRectSize; i += 16) {
|
| + DesktopRect rect = DesktopRect::MakeXYWH(kRectSize, kRectSize, i, i);
|
| + rect.Translate(drawer->DrawableRegion().top_left());
|
| + RgbaColor color((c == 0 ? (i & 0xff) : 0x7f),
|
| + (c == 1 ? (i & 0xff) : 0x7f),
|
| + (c == 2 ? (i & 0xff) : 0x7f));
|
| TestCaptureOneFrame(capturers, drawer.get(), rect, color);
|
| }
|
| }
|
| @@ -166,9 +179,11 @@ class ScreenCapturerTest : public testing::Test {
|
| ScreenDrawer* drawer,
|
| DesktopRect rect,
|
| RgbaColor color) {
|
| - size_t succeeded_capturers = 0;
|
| const int wait_capture_round = 600;
|
| + drawer->Clear();
|
| + size_t succeeded_capturers = 0;
|
| for (int i = 0; i < wait_capture_round; i++) {
|
| + drawer->DrawRectangle(rect, color);
|
| drawer->WaitForPendingDraws();
|
| for (size_t j = 0; j < capturers.size(); j++) {
|
| if (capturers[j] == nullptr) {
|
| @@ -184,7 +199,8 @@ class ScreenCapturerTest : public testing::Test {
|
| return;
|
| }
|
|
|
| - if (ArePixelsColoredBy(*frame, rect, color)) {
|
| + if (ArePixelsColoredBy(
|
| + *frame, rect, color, drawer->MayDrawIncompleteShapes())) {
|
| capturers[j] = nullptr;
|
| succeeded_capturers++;
|
| }
|
| @@ -279,13 +295,13 @@ TEST_F(ScreenCapturerTest, Capture) {
|
|
|
| // Disabled due to being flaky due to the fact that it uses rendering / UI, see
|
| // webrtc/6366.
|
| -TEST_F(ScreenCapturerTest, DISABLED_CaptureUpdatedRegion) {
|
| +TEST_F(ScreenCapturerTest, CaptureUpdatedRegion) {
|
| TestCaptureUpdatedRegion();
|
| }
|
|
|
| // Disabled due to being flaky due to the fact that it uses rendering / UI, see
|
| // webrtc/6366.
|
| -TEST_F(ScreenCapturerTest, DISABLED_TwoCapturers) {
|
| +TEST_F(ScreenCapturerTest, TwoCapturers) {
|
| std::unique_ptr<ScreenCapturer> capturer2 = std::move(capturer_);
|
| SetUp();
|
| TestCaptureUpdatedRegion({capturer_.get(), capturer2.get()});
|
| @@ -358,7 +374,7 @@ TEST_F(ScreenCapturerTest, UseDirectxCapturerWithSharedBuffers) {
|
|
|
| // Disabled due to being flaky due to the fact that it uses rendering / UI, see
|
| // webrtc/6366.
|
| -TEST_F(ScreenCapturerTest, DISABLED_CaptureUpdatedRegionWithDirectxCapturer) {
|
| +TEST_F(ScreenCapturerTest, CaptureUpdatedRegionWithDirectxCapturer) {
|
| if (!CreateDirectxCapturer()) {
|
| return;
|
| }
|
| @@ -368,7 +384,7 @@ TEST_F(ScreenCapturerTest, DISABLED_CaptureUpdatedRegionWithDirectxCapturer) {
|
|
|
| // Disabled due to being flaky due to the fact that it uses rendering / UI, see
|
| // webrtc/6366.
|
| -TEST_F(ScreenCapturerTest, DISABLED_TwoDirectxCapturers) {
|
| +TEST_F(ScreenCapturerTest, TwoDirectxCapturers) {
|
| if (!CreateDirectxCapturer()) {
|
| return;
|
| }
|
| @@ -380,14 +396,14 @@ TEST_F(ScreenCapturerTest, DISABLED_TwoDirectxCapturers) {
|
|
|
| // Disabled due to being flaky due to the fact that it uses rendering / UI, see
|
| // webrtc/6366.
|
| -TEST_F(ScreenCapturerTest, DISABLED_CaptureUpdatedRegionWithMagnifierCapturer) {
|
| +TEST_F(ScreenCapturerTest, CaptureUpdatedRegionWithMagnifierCapturer) {
|
| CreateMagnifierCapturer();
|
| TestCaptureUpdatedRegion();
|
| }
|
|
|
| // Disabled due to being flaky due to the fact that it uses rendering / UI, see
|
| // webrtc/6366.
|
| -TEST_F(ScreenCapturerTest, DISABLED_TwoMagnifierCapturers) {
|
| +TEST_F(ScreenCapturerTest, TwoMagnifierCapturers) {
|
| CreateMagnifierCapturer();
|
| std::unique_ptr<ScreenCapturer> capturer2 = std::move(capturer_);
|
| CreateMagnifierCapturer();
|
|
|