summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/text
diff options
context:
space:
mode:
authorEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2016-10-14 15:54:13 +0200
committerEskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>2016-10-17 07:29:10 +0000
commitae6681673eb5c7768070cad61f483d2a5405dc9e (patch)
tree60b47153bc84d8b1f1a61e6667c176a261a1ba61 /tests/auto/gui/text
parent9944a12a0f57087ea19ae428ffcd974ac0fed7bc (diff)
Add QTextDocument::toRawText() function
The QTextDocument::toPlainText() converts some characters in the text to ASCII, which can be problematic for use cases where you want to save the precise contents of the document, e.g. in Qt Creator. Since we don't want to change the behavior of toPlainText(), we introduce a new function which returns the raw text contents of the document instead, with no modifications. [ChangeLog][QtGui][Text] Added QTextDocument::toRawText() function. Task-number: QTBUG-56538 Change-Id: Ib6c48a16551c4c71c4c431760f993793d1af6806 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'tests/auto/gui/text')
-rw-r--r--tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
index de5b2a8676..ef1ad76161 100644
--- a/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
+++ b/tests/auto/gui/text/qtextdocument/tst_qtextdocument.cpp
@@ -135,6 +135,7 @@ private slots:
void setPlainText();
void toPlainText();
+ void toRawText();
void deleteTextObjectsOnClear();
@@ -2396,6 +2397,16 @@ void tst_QTextDocument::toPlainText()
QCOMPARE(doc->toPlainText(), QLatin1String("Hello World"));
}
+void tst_QTextDocument::toRawText()
+{
+ doc->setHtml("&nbsp;");
+
+ QString rawText = doc->toRawText();
+ QCOMPARE(rawText.size(), 1);
+ QCOMPARE(rawText.at(0).unicode(), ushort(QChar::Nbsp));
+}
+
+
void tst_QTextDocument::deleteTextObjectsOnClear()
{
QPointer<QTextTable> table = cursor.insertTable(2, 2);