summaryrefslogtreecommitdiffstats
path: root/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp')
-rw-r--r--tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp57
1 files changed, 51 insertions, 6 deletions
diff --git a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
index 6a2ae4951b..3669935823 100644
--- a/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
+++ b/tests/auto/widgets/widgets/qtextedit/tst_qtextedit.cpp
@@ -199,6 +199,12 @@ private slots:
void findWithRegExpReturnsFalseIfNoMoreResults();
#endif
+#if QT_CONFIG(regularexpression)
+ void findWithRegularExpression();
+ void findBackwardWithRegularExpression();
+ void findWithRegularExpressionReturnsFalseIfNoMoreResults();
+#endif
+
#if QT_CONFIG(wheelevent)
void wheelEvent();
#endif
@@ -276,12 +282,12 @@ void tst_QTextEdit::getSetCheck()
// int QTextEdit::tabStopWidth()
// void QTextEdit::setTabStopWidth(int)
- obj1.setTabStopWidth(0);
- QCOMPARE(0, obj1.tabStopWidth());
- obj1.setTabStopWidth(INT_MIN);
- QCOMPARE(0, obj1.tabStopWidth()); // Makes no sense to set a negative tabstop value
- obj1.setTabStopWidth(INT_MAX);
- QCOMPARE(INT_MAX, obj1.tabStopWidth());
+ obj1.setTabStopDistance(0);
+ QCOMPARE(0, obj1.tabStopDistance());
+ obj1.setTabStopDistance(-1);
+ QCOMPARE(0, obj1.tabStopDistance()); // Makes no sense to set a negative tabstop value
+ obj1.setTabStopDistance(std::numeric_limits<qreal>::max());
+ QCOMPARE(std::numeric_limits<qreal>::max(), obj1.tabStopDistance());
// bool QTextEdit::acceptRichText()
// void QTextEdit::setAcceptRichText(bool)
@@ -2572,6 +2578,45 @@ void tst_QTextEdit::findWithRegExpReturnsFalseIfNoMoreResults()
}
#endif
+#if QT_CONFIG(regularexpression)
+void tst_QTextEdit::findWithRegularExpression()
+{
+ ed->setHtml(QStringLiteral("arbitrary te<span style=\"color:#ff0000\">xt</span>"));
+ QRegularExpression rx("\\w{2}xt");
+
+ bool found = ed->find(rx);
+
+ QVERIFY(found);
+ QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text"));
+}
+
+void tst_QTextEdit::findBackwardWithRegularExpression()
+{
+ ed->setPlainText(QStringLiteral("arbitrary text"));
+ QTextCursor cursor = ed->textCursor();
+ cursor.movePosition(QTextCursor::End);
+ ed->setTextCursor(cursor);
+ QRegularExpression rx("a\\w*t");
+
+ bool found = ed->find(rx, QTextDocument::FindBackward);
+
+ QVERIFY(found);
+ QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("arbit"));
+}
+
+void tst_QTextEdit::findWithRegularExpressionReturnsFalseIfNoMoreResults()
+{
+ ed->setPlainText(QStringLiteral("arbitrary text"));
+ QRegularExpression rx("t.xt");
+ ed->find(rx);
+
+ bool found = ed->find(rx);
+
+ QVERIFY(!found);
+ QCOMPARE(ed->textCursor().selectedText(), QStringLiteral("text"));
+}
+#endif
+
#if QT_CONFIG(wheelevent)
class TextEdit : public QTextEdit