Commit a3741e4a authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add more autotest

parent bed0b06c
Pipeline #147569 passed with stages
in 3 minutes and 22 seconds
......@@ -43,7 +43,6 @@ int FindUtils::replaceAll(QTextEdit *view, const QString &str, const QString &re
while (!c.isNull()) {
c = document->find(str, c, flags);
if (!c.isNull()) {
// find() selects found text, and insertText() replaces selection
c.insertText(replaceStr);
count++;
} else {
......@@ -69,7 +68,6 @@ int FindUtils::replaceAll(QTextEdit *view, const QString &str, const QString &re
if (!documentWithoutRespectDiacriticsTextCursor.isNull()) {
c.setPosition(documentWithoutRespectDiacriticsTextCursor.selectionStart());
c.setPosition(documentWithoutRespectDiacriticsTextCursor.selectionEnd(), QTextCursor::KeepAnchor);
// find() selects found text, and insertText() replaces selection
c.insertText(replaceStr);
documentWithoutRespectDiacriticsTextCursor.insertText(replaceStr);
count++;
......@@ -94,7 +92,6 @@ int FindUtils::replaceAll(QPlainTextEdit *view, const QString &str, const QStrin
while (!c.isNull()) {
c = document->find(str, c, flags);
if (!c.isNull()) {
// find() selects found text, and insertText() replaces selection
c.insertText(replaceStr);
count++;
} else {
......@@ -120,7 +117,6 @@ int FindUtils::replaceAll(QPlainTextEdit *view, const QString &str, const QStrin
if (!documentWithoutRespectDiacriticsTextCursor.isNull()) {
c.setPosition(documentWithoutRespectDiacriticsTextCursor.selectionStart());
c.setPosition(documentWithoutRespectDiacriticsTextCursor.selectionEnd(), QTextCursor::KeepAnchor);
// find() selects found text, and insertText() replaces selection
c.insertText(replaceStr);
documentWithoutRespectDiacriticsTextCursor.insertText(replaceStr);
count++;
......
......@@ -74,6 +74,7 @@ void PlainTextEditFindBarTest::shouldSearchText_data()
QTest::newRow("find-diacritics-1") << QStringLiteral("numéro numéro") << QStringLiteral("numero") << flags << false;
QTest::newRow("find-diacritics-2") << QStringLiteral("numéro numéro") << QStringLiteral("numéro") << flags << true;
QTest::newRow("find-diacritics-3") << QStringLiteral("numéro numéro il est là. Numero numéro") << QStringLiteral("numero") << flags << true;
}
}
......@@ -131,9 +132,21 @@ void PlainTextEditFindBarTest::shouldReplaceAllText_data()
{
KPIMTextEdit::TextEditFindBarBase::FindFlags flags;
flags |= KPIMTextEdit::TextEditFindBarBase::FindWholeWords;
QTest::newRow("wholewords-no-diacritics-2") << QStringLiteral("voiture voiture voiture") << QStringLiteral("réunion") << QStringLiteral("replace")
QTest::newRow("wholewords-no-diacritics-3") << QStringLiteral("voiture voiture voiture") << QStringLiteral("réunion") << QStringLiteral("replace")
<< flags << 0 << QStringLiteral("voiture voiture voiture");
}
{
KPIMTextEdit::TextEditFindBarBase::FindFlags flags;
flags |= KPIMTextEdit::TextEditFindBarBase::FindWholeWords;
QTest::newRow("wholewords-no-diacritics-3") << QStringLiteral("voiture voiture il est là. voiture") << QStringLiteral("voiture")
<< QStringLiteral("replace") << flags << 3 << QStringLiteral("replace replace il est là. replace");
}
{
KPIMTextEdit::TextEditFindBarBase::FindFlags flags;
flags |= KPIMTextEdit::TextEditFindBarBase::FindWholeWords;
QTest::newRow("wholewords-no-diacritics-4") << QStringLiteral("réunion réunion . Test... réunion") << QStringLiteral("réunion")
<< QStringLiteral("replace") << flags << 3 << QStringLiteral("replace replace . Test... replace");
}
}
void PlainTextEditFindBarTest::shouldReplaceAllText()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment