summaryrefslogtreecommitdiffstats
path: root/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp')
-rw-r--r--tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp41
1 files changed, 25 insertions, 16 deletions
diff --git a/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp b/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp
index cc6722af40..8f5cacae4a 100644
--- a/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp
+++ b/tests/auto/gui/text/qtextcursor/tst_qtextcursor.cpp
@@ -1,5 +1,5 @@
// Copyright (C) 2016 The Qt Company Ltd.
-// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
#include <QTest>
@@ -39,7 +39,9 @@ private slots:
void navigation7();
void navigation8();
void navigation9();
+#ifndef QT_NO_TEXTHTMLPARSER
void navigation10();
+#endif
void movePositionEndOfLine();
void insertBlock();
void insertWithBlockSeparator1();
@@ -431,6 +433,7 @@ void tst_QTextCursor::navigation9()
QCOMPARE(cursor.position(), 15);
}
+#ifndef QT_NO_TEXTHTMLPARSER
void tst_QTextCursor::navigation10()
{
doc->setHtml("<html><p>just a simple paragraph.</p>"
@@ -542,6 +545,7 @@ void tst_QTextCursor::navigation10()
QVERIFY(ok);
QCOMPARE(cursor.position(), 1); // a
}
+#endif
void tst_QTextCursor::insertBlock()
{
@@ -1545,15 +1549,20 @@ void tst_QTextCursor::insertMarkdown_data()
<< 6 << QString("0) eggs\n1) maple syrup\n")
<< QString("bread\u2029eggs\u2029maple syrup\u2029milk")
<< QString("bread\neggs\nmaple syrup\nmilk")
- << QString("1) bread\n2) eggs\n1) maple syrup\n2) milk\n");
- // renumbering would happen if we re-read the whole document
+ << QString("1) bread\n2) eggs\n0) maple syrup\n1) milk\n");
+ // Renumbering would happen if we re-read the whole document.
+ // Currently insertion only uses the new list format after a paragraph separator.
+ // For that reason "bread" and "eggs" use the original list format, while "maple syrup" and
+ // "milk" use the format from the just inserted list.
QTest::newRow("list after a list")
<< "1) bread\n2) milk\n\n" << 2
<< 13 << QString("\n0) eggs\n1) maple syrup\n")
<< QString("bread\u2029milk\u2029eggs\u2029maple syrup")
<< QString("bread\nmilk\neggs\nmaple syrup")
- << QString("1) bread\n2) milk\n3) eggs\n1) maple syrup\n");
+ << QString("1) bread\n2) milk\n3) eggs\n0) maple syrup\n");
+ // Same behavior as above. "eggs" uses the original list format, but "maple syrup" uses the
+ // format of the inserted list, which means "maple syrup" now has a start of 0.
const QString markdownHeadingString("# Hello\nWorld\n");
@@ -1754,26 +1763,26 @@ void tst_QTextCursor::update_data()
QTest::newRow("removeInsideSelection")
<< text
<< /*position*/ 0
- << /*anchor*/ int(text.length())
+ << /*anchor*/ int(text.size())
// delete 'big'
<< 6
<< 6 + charsToDelete
<< QString() // don't insert anything, just remove
<< /*expectedPosition*/ 0
- << /*expectedAnchor*/ int(text.length() - charsToDelete)
+ << /*expectedAnchor*/ int(text.size() - charsToDelete)
;
text = "Hello big world";
charsToDelete = 3;
QTest::newRow("removeInsideSelectionWithSwappedAnchorAndPosition")
<< text
- << /*position*/ int(text.length())
+ << /*position*/ int(text.size())
<< /*anchor*/ 0
// delete 'big'
<< 6
<< 6 + charsToDelete
<< QString() // don't insert anything, just remove
- << /*expectedPosition*/ int(text.length() - charsToDelete)
+ << /*expectedPosition*/ int(text.size() - charsToDelete)
<< /*expectedAnchor*/ 0
;
@@ -1784,13 +1793,13 @@ void tst_QTextCursor::update_data()
QTest::newRow("replaceInsideSelection")
<< text
<< /*position*/ 0
- << /*anchor*/ int(text.length())
+ << /*anchor*/ int(text.size())
// delete 'big' ...
<< 6
<< 6 + charsToDelete
<< textToInsert // ... and replace 'big' with 'small'
<< /*expectedPosition*/ 0
- << /*expectedAnchor*/ int(text.length() - charsToDelete + textToInsert.length())
+ << /*expectedAnchor*/ int(text.size() - charsToDelete + textToInsert.size())
;
text = "Hello big world";
@@ -1798,13 +1807,13 @@ void tst_QTextCursor::update_data()
textToInsert = "small";
QTest::newRow("replaceInsideSelectionWithSwappedAnchorAndPosition")
<< text
- << /*position*/ int(text.length())
+ << /*position*/ int(text.size())
<< /*anchor*/ 0
// delete 'big' ...
<< 6
<< 6 + charsToDelete
<< textToInsert // ... and replace 'big' with 'small'
- << /*expectedPosition*/ int(text.length() - charsToDelete + textToInsert.length())
+ << /*expectedPosition*/ int(text.size() - charsToDelete + textToInsert.size())
<< /*expectedAnchor*/ 0
;
@@ -1813,14 +1822,14 @@ void tst_QTextCursor::update_data()
charsToDelete = 3;
QTest::newRow("removeBeforeSelection")
<< text
- << /*position*/ int(text.length() - 5)
- << /*anchor*/ int(text.length())
+ << /*position*/ int(text.size() - 5)
+ << /*anchor*/ int(text.size())
// delete 'big'
<< 6
<< 6 + charsToDelete
<< QString() // don't insert anything, just remove
- << /*expectedPosition*/ int(text.length() - 5 - charsToDelete)
- << /*expectedAnchor*/ int(text.length() - charsToDelete)
+ << /*expectedPosition*/ int(text.size() - 5 - charsToDelete)
+ << /*expectedAnchor*/ int(text.size() - charsToDelete)
;
text = "Hello big world";