summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-02-24 19:57:17 +0100
committerLiang Qi <liang.qi@qt.io>2017-02-24 20:01:42 +0100
commitde49839df8abfba1f3ed3c36ef3177e4a9d6ef00 (patch)
tree71e777ca1e33c58edd9149821e970495ef4b75b2 /tests/auto/gui
parente6234535929c67e7fbfa1ad7ce88f37df0b68d45 (diff)
parent4d3781b640e8fb0a04e96b2d05199247556b8d86 (diff)
Merge remote-tracking branch 'origin/5.8' into 5.9
Conflicts: mkspecs/features/moc.prf Change-Id: Ia71c8e3b3185f7c999bf226d0675051b10b8740b
Diffstat (limited to 'tests/auto/gui')
-rw-r--r--tests/auto/gui/text/qtextformat/tst_qtextformat.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp b/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp
index 71ee980de1..b8afd6a447 100644
--- a/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp
+++ b/tests/auto/gui/text/qtextformat/tst_qtextformat.cpp
@@ -60,6 +60,7 @@ private slots:
void setFont();
void setFont_collection_data();
void setFont_collection();
+ void clearCollection();
};
/*! \internal
@@ -640,5 +641,32 @@ void tst_QTextFormat::setFont_collection()
}
}
+void tst_QTextFormat::clearCollection()
+{
+ QTextFormatCollection collection;
+ QFont f;
+ f.setUnderline(true);
+ collection.setDefaultFont(f);
+ QTextCharFormat charFormat;
+ charFormat.setFontStyleHint(QFont::SansSerif);
+ int formatIndex = collection.indexForFormat(charFormat);
+ QCOMPARE(formatIndex, 0);
+ QTextCharFormat charFormat2;
+ charFormat2.setUnderlineStyle(QTextCharFormat::SingleUnderline);
+ int formatIndex2 = collection.indexForFormat(charFormat2);
+ QCOMPARE(formatIndex2, 1);
+ QCOMPARE(collection.formats.count(), 2);
+ QCOMPARE(collection.hashes.count(), 2);
+ QCOMPARE(collection.defaultFont(), f);
+
+ collection.clear();
+ QCOMPARE(collection.formats.count(), 0);
+ QCOMPARE(collection.hashes.count(), 0);
+ QCOMPARE(collection.indexForFormat(charFormat2), 0);
+ QCOMPARE(collection.formats.count(), 1);
+ QCOMPARE(collection.hashes.count(), 1);
+ QCOMPARE(collection.defaultFont(), f); // kept, QTextDocument::clear or setPlainText should not reset the font set by setDefaultFont
+}
+
QTEST_MAIN(tst_QTextFormat)
#include "tst_qtextformat.moc"