From 73eb7846764dc4ac9c0b08d258a3646ec2e08567 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Patrik=20H=C3=B6glund?= Date: Mon, 16 Dec 2019 07:35:41 +0100 Subject: [PATCH] Don't crash the test process when X11 isn't available. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's not great to use asserts in util functions like this because it breaks the arrange-act-assert rule, but using checks is worse because they will crash the test process on failure (= no other tests get run after that). Bug: b/143587130 Change-Id: If4d085311de0792b9fca1584db299fd24199e72e Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/162360 Reviewed-by: Artem Titov Commit-Queue: Patrik Höglund Cr-Commit-Position: refs/heads/master@{#30093} --- modules/desktop_capture/screen_capturer_unittest.cc | 2 +- modules/desktop_capture/screen_drawer_unittest.cc | 2 -- modules/desktop_capture/test_utils_unittest.cc | 4 ++-- modules/desktop_capture/window_capturer_unittest.cc | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/modules/desktop_capture/screen_capturer_unittest.cc b/modules/desktop_capture/screen_capturer_unittest.cc index 4d1dc6d93c..ea77069278 100644 --- a/modules/desktop_capture/screen_capturer_unittest.cc +++ b/modules/desktop_capture/screen_capturer_unittest.cc @@ -35,7 +35,7 @@ class ScreenCapturerTest : public ::testing::Test { void SetUp() override { capturer_ = DesktopCapturer::CreateScreenCapturer( DesktopCaptureOptions::CreateDefault()); - RTC_DCHECK(capturer_); + ASSERT_TRUE(capturer_); } protected: diff --git a/modules/desktop_capture/screen_drawer_unittest.cc b/modules/desktop_capture/screen_drawer_unittest.cc index 42e3587b11..c38eee6991 100644 --- a/modules/desktop_capture/screen_drawer_unittest.cc +++ b/modules/desktop_capture/screen_drawer_unittest.cc @@ -36,8 +36,6 @@ void TestScreenDrawerLock( rtc::FunctionView()> ctor) { constexpr int kLockDurationMs = 100; - RTC_DCHECK(ctor); - std::atomic created(false); std::atomic ready(false); diff --git a/modules/desktop_capture/test_utils_unittest.cc b/modules/desktop_capture/test_utils_unittest.cc index 24d92b6e87..c1326f01cc 100644 --- a/modules/desktop_capture/test_utils_unittest.cc +++ b/modules/desktop_capture/test_utils_unittest.cc @@ -24,8 +24,8 @@ namespace { void PaintDesktopFrame(DesktopFrame* frame, DesktopVector pos, RgbaColor color) { - RTC_DCHECK(frame); - RTC_DCHECK(DesktopRect::MakeSize(frame->size()).Contains(pos)); + ASSERT_TRUE(frame); + ASSERT_TRUE(DesktopRect::MakeSize(frame->size()).Contains(pos)); *reinterpret_cast(frame->GetFrameDataAtPos(pos)) = color.ToUInt32(); } diff --git a/modules/desktop_capture/window_capturer_unittest.cc b/modules/desktop_capture/window_capturer_unittest.cc index a806ada32e..8a611e760a 100644 --- a/modules/desktop_capture/window_capturer_unittest.cc +++ b/modules/desktop_capture/window_capturer_unittest.cc @@ -27,7 +27,7 @@ class WindowCapturerTest : public ::testing::Test, void SetUp() override { capturer_ = DesktopCapturer::CreateWindowCapturer( DesktopCaptureOptions::CreateDefault()); - RTC_DCHECK(capturer_); + ASSERT_TRUE(capturer_); } void TearDown() override {}