Don't crash the test process when X11 isn't available.

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 <titovartem@webrtc.org>
Commit-Queue: Patrik Höglund <phoglund@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#30093}
This commit is contained in:
Patrik Höglund 2019-12-16 07:35:41 +01:00 committed by Commit Bot
parent 774fb933a3
commit 73eb784676
4 changed files with 4 additions and 6 deletions

View file

@ -35,7 +35,7 @@ class ScreenCapturerTest : public ::testing::Test {
void SetUp() override {
capturer_ = DesktopCapturer::CreateScreenCapturer(
DesktopCaptureOptions::CreateDefault());
RTC_DCHECK(capturer_);
ASSERT_TRUE(capturer_);
}
protected:

View file

@ -36,8 +36,6 @@ void TestScreenDrawerLock(
rtc::FunctionView<std::unique_ptr<ScreenDrawerLock>()> ctor) {
constexpr int kLockDurationMs = 100;
RTC_DCHECK(ctor);
std::atomic<bool> created(false);
std::atomic<bool> ready(false);

View file

@ -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<uint32_t*>(frame->GetFrameDataAtPos(pos)) =
color.ToUInt32();
}

View file

@ -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 {}