From 383c2205d0cde9e766723619c354e8014755cd1c Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Fri, 3 Feb 2023 12:22:38 +0100 Subject: [PATCH] QtSupport: Fix output formatter test Broke with 8655603c2e1e5394773160ac1b6756bc89382373. Change-Id: I87a366065e5764ecd62d2a2799f408af4341f20b Reviewed-by: Christian Kandeler --- src/plugins/qtsupport/qtoutputformatter.cpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/src/plugins/qtsupport/qtoutputformatter.cpp b/src/plugins/qtsupport/qtoutputformatter.cpp index d7aeda828e5..e54f8470574 100644 --- a/src/plugins/qtsupport/qtoutputformatter.cpp +++ b/src/plugins/qtsupport/qtoutputformatter.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -412,6 +413,16 @@ static QTextCharFormat blueFormat() return result; } +static QTextCharFormat tweakedBlueFormat() +{ + // foreground gets tweaked when passing doAppendMessage() + QTextCharFormat tweakedBlue = blueFormat(); + QColor foreground = tweakedBlue.foreground().color(); + foreground = StyleHelper::ensureReadableOn(tweakedBlue.background().color(), foreground); + tweakedBlue.setForeground(foreground); + return tweakedBlue; +} + static QTextCharFormat greenFormat() { QTextCharFormat result; @@ -440,12 +451,12 @@ void QtSupportPlugin::testQtOutputFormatter_appendMessage_data() << "blue da ba dee" << "blue da ba dee" << blueFormat() - << blueFormat(); + << tweakedBlueFormat(); QTest::newRow("ANSI color change") << "\x1b[38;2;0;0;127mHello" << "Hello" << QTextCharFormat() - << blueFormat(); + << tweakedBlueFormat(); } void QtSupportPlugin::testQtOutputFormatter_appendMessage() @@ -500,7 +511,7 @@ void QtSupportPlugin::testQtOutputFormatter_appendMixedAssertAndAnsi() OutputFormatter::linkFormat(QTextCharFormat(), "file://test.cpp:123")); edit.moveCursor(QTextCursor::End); - QCOMPARE(edit.currentCharFormat(), blueFormat()); + QCOMPARE(edit.currentCharFormat(), tweakedBlueFormat()); } } // namespace QtSupport