From b5c22ff2327e44fbf346fc2225653ae3a88c4381 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Thu, 6 Feb 2025 13:06:08 +0100 Subject: [PATCH] QtSupport: Fix output formatter test on dark systems Change-Id: If511632de2be26899d2bea824b1a5de6ce1c4947 Reviewed-by: Christian Kandeler --- src/plugins/qtsupport/qtoutputformatter.cpp | 25 ++++++++++++++------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/plugins/qtsupport/qtoutputformatter.cpp b/src/plugins/qtsupport/qtoutputformatter.cpp index 4ff620e3a19..d5a8ce582a0 100644 --- a/src/plugins/qtsupport/qtoutputformatter.cpp +++ b/src/plugins/qtsupport/qtoutputformatter.cpp @@ -425,17 +425,21 @@ static QTextCharFormat blueFormat() return result; } -static QTextCharFormat tweakedBlueFormat() +static QTextCharFormat tweakedFormat(QTextCharFormat format) { // foreground gets tweaked when passing doAppendMessage() - QTextCharFormat tweakedBlue = blueFormat(); - QColor foreground = tweakedBlue.foreground().color(); - const QColor background = tweakedBlue.hasProperty(QTextCharFormat::BackgroundBrush) - ? tweakedBlue.background().color() + QColor foreground = format.foreground().color(); + const QColor background = format.hasProperty(QTextCharFormat::BackgroundBrush) + ? format.background().color() : Utils::creatorColor(Theme::BackgroundColorNormal); foreground = StyleHelper::ensureReadableOn(background, foreground); - tweakedBlue.setForeground(foreground); - return tweakedBlue; + format.setForeground(foreground); + return format; +} + +static QTextCharFormat tweakedBlueFormat() +{ + return tweakedFormat(blueFormat()); } static QTextCharFormat greenFormat() @@ -445,6 +449,11 @@ static QTextCharFormat greenFormat() return result; } +static QTextCharFormat tweakedGreenFormat() +{ + return tweakedFormat(greenFormat()); +} + void QtOutputFormatterTest::testQtOutputFormatter_appendMessage_data() { QTest::addColumn("inputText"); @@ -518,7 +527,7 @@ void QtOutputFormatterTest::testQtOutputFormatter_appendMixedAssertAndAnsi() QCOMPARE(edit.toPlainText(), outputText); edit.moveCursor(QTextCursor::Start); - QCOMPARE(edit.currentCharFormat(), greenFormat()); + QCOMPARE(edit.currentCharFormat(), tweakedGreenFormat()); edit.moveCursor(QTextCursor::WordRight); edit.moveCursor(QTextCursor::Right);