From 30ddaad191b3c9459ca57e8aad9fa73b24c3ff36 Mon Sep 17 00:00:00 2001 From: Andre Hartmann Date: Tue, 24 Sep 2013 20:51:22 +0200 Subject: [PATCH] ANSI: Test line-overlapping formats. Until endFormatScope() is called, continuation lines keep the last format. Change-Id: Ic68ae6d716519f537189ebae763da4dc2c30978d Reviewed-by: Orgad Shaneh Reviewed-by: Petar Perisin --- .../tst_ansiescapecodehandler.cpp | 28 +++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/tests/auto/utils/ansiescapecodehandler/tst_ansiescapecodehandler.cpp b/tests/auto/utils/ansiescapecodehandler/tst_ansiescapecodehandler.cpp index f07fd85c625..0f1381416d7 100644 --- a/tests/auto/utils/ansiescapecodehandler/tst_ansiescapecodehandler.cpp +++ b/tests/auto/utils/ansiescapecodehandler/tst_ansiescapecodehandler.cpp @@ -55,6 +55,7 @@ public: private Q_SLOTS: void testCase1(); void testCase1_data(); + void testLineOverlappingFormat(); private: const QString red; @@ -128,6 +129,33 @@ void tst_AnsiEscapeCodeHandler::testCase1_data() << StringFormatPair(" text", defaultFormat)); } +void tst_AnsiEscapeCodeHandler::testLineOverlappingFormat() +{ + // Test line-overlapping formats + const QString line1 = "A line of " + bold + "bold text"; + const QString line2 = "A line of " + normal + "normal text"; + + QTextCharFormat defaultFormat; + + AnsiEscapeCodeHandler handler; + ResultList result; + result.append(handler.parseText(line1, defaultFormat)); + result.append(handler.parseText(line2, defaultFormat)); + + QTextCharFormat boldFormat; + boldFormat.setFontWeight(QFont::Bold); + + QCOMPARE(result.size(), 4); + QCOMPARE(result[0].first, QLatin1String("A line of ")); + QCOMPARE(result[0].second, defaultFormat); + QCOMPARE(result[1].first, QLatin1String("bold text")); + QCOMPARE(result[1].second, boldFormat); + QCOMPARE(result[2].first, QLatin1String("A line of ")); + QCOMPARE(result[2].second, boldFormat); + QCOMPARE(result[3].first, QLatin1String("normal text")); + QCOMPARE(result[3].second, defaultFormat); +} + QTEST_APPLESS_MAIN(tst_AnsiEscapeCodeHandler) #include "tst_ansiescapecodehandler.moc"