summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2011-05-04 10:52:20 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@nokia.com>2011-05-04 11:20:59 +0200
commit2e0003eda4783f69a40fb4b31e7084c761d9640d (patch)
tree36a9034450b4654891bdf441b61667f4eba700a1 /tests
parent99454287bffcfcf7b0c2c658bea95d8543d2b118 (diff)
Include pixel size of font in exported HTML from QTextDocument
When you copy-pasted rich text in which the font size had been set using setPixelSize() the font size would be mysteriously forgotten. The pixel size property in QTextCharFormat was added ad hoc, and not integrated in the HTML exporter. Task-number: QT-4792 Reviewed-by: Gunnar (cherry picked from commit 5aa5c2e2935c1829cc6965198968699f17c24ec0)
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qtextdocument/tst_qtextdocument.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/auto/qtextdocument/tst_qtextdocument.cpp b/tests/auto/qtextdocument/tst_qtextdocument.cpp
index 6675c99d23..26fa43d137 100644
--- a/tests/auto/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/qtextdocument/tst_qtextdocument.cpp
@@ -180,6 +180,8 @@ private slots:
void escape_data();
void escape();
+ void copiedFontSize();
+
private:
void backgroundImage_checkExpectedHtml(const QTextDocument &doc);
@@ -2734,5 +2736,29 @@ void tst_QTextDocument::escape()
QCOMPARE(Qt::escape(original), expected);
}
+void tst_QTextDocument::copiedFontSize()
+{
+ QTextDocument documentInput;
+ QTextDocument documentOutput;
+
+ QFont fontInput;
+ fontInput.setPixelSize(24); // With pixels font size is not transfered in html
+
+ QTextCursor cursorInput(&documentInput);
+ QTextCharFormat formatInput = cursorInput.charFormat();
+ formatInput.setFont(fontInput);
+ cursorInput.insertText("Should be the same font", formatInput);
+ cursorInput.select(QTextCursor::Document);
+
+ QTextDocumentFragment fragmentInput(cursorInput);
+ QString html = fragmentInput.toHtml();
+
+ QTextCursor cursorOutput(&documentOutput);
+ QTextDocumentFragment fragmentOutput = QTextDocumentFragment::fromHtml(html);
+ cursorOutput.insertFragment(fragmentOutput);
+
+ QCOMPARE(cursorOutput.charFormat().font().pixelSize(), 24);
+}
+
QTEST_MAIN(tst_QTextDocument)
#include "tst_qtextdocument.moc"