Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
PIM
KPimTextEdit
Commits
b434f0e3
Commit
b434f0e3
authored
Mar 02, 2022
by
Laurent Montel
😁
Browse files
Add autotests
parent
5647e32f
Pipeline
#144038
passed with stages
in 2 minutes and 29 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
src/texteditor/commonwidget/findutils.h
View file @
b434f0e3
...
...
@@ -7,7 +7,7 @@
#pragma once
#include "kpimtextedit/texteditfindbarbase.h"
#include "kpimtextedit_private_export.h"
#include <QChar>
#include <QStringView>
#include <QTextDocument>
...
...
@@ -27,9 +27,11 @@ namespace FindUtils
*
* @return number of replacements done
*/
Q_REQUIRED_RESULT
int
replaceAll
(
QPlainTextEdit
*
view
,
const
QString
&
str
,
const
QString
&
replaceWidget
,
QTextDocument
::
FindFlags
searchOptions
);
Q_REQUIRED_RESULT
int
replaceAll
(
QTextEdit
*
view
,
const
QString
&
str
,
const
QString
&
replaceWidget
,
QTextDocument
::
FindFlags
searchOptions
);
Q_REQUIRED_RESULT
int
Q_REQUIRED_RESULT
KPIMTEXTEDIT_TESTS_EXPORT
int
replaceAll
(
QPlainTextEdit
*
view
,
const
QString
&
str
,
const
QString
&
replaceWidget
,
QTextDocument
::
FindFlags
searchOptions
);
Q_REQUIRED_RESULT
KPIMTEXTEDIT_TESTS_EXPORT
int
replaceAll
(
QTextEdit
*
view
,
const
QString
&
str
,
const
QString
&
replaceWidget
,
QTextDocument
::
FindFlags
searchOptions
);
Q_REQUIRED_RESULT
KPIMTEXTEDIT_TESTS_EXPORT
int
replaceAll
(
QTextDocument
*
document
,
const
QRegularExpression
&
regExp
,
const
QString
&
replaceWidget
,
QTextDocument
::
FindFlags
searchOptions
);
Q_REQUIRED_RESULT
QString
normalize
(
QStringView
str
);
Q_REQUIRED_RESULT
QChar
normalize
(
QChar
c
);
...
...
src/texteditor/plaintexteditor/autotests/plaintexteditfindbartest.cpp
View file @
b434f0e3
...
...
@@ -5,12 +5,14 @@
*/
#include "plaintexteditfindbartest.h"
#include "texteditor/commonwidget/findutils.h"
#include "texteditor/plaintexteditor/plaintexteditfindbar.h"
#include <QPlainTextEdit>
#include <QTest>
QTEST_MAIN
(
PlainTextEditFindBarTest
)
Q_DECLARE_METATYPE
(
KPIMTextEdit
::
TextEditFindBarBase
::
FindFlags
)
Q_DECLARE_METATYPE
(
QTextDocument
::
FindFlags
)
PlainTextEditFindBarTest
::
PlainTextEditFindBarTest
(
QObject
*
parent
)
:
QObject
{
parent
}
{
...
...
@@ -89,3 +91,29 @@ void PlainTextEditFindBarTest::shouldSearchText()
QCOMPARE
(
w
.
searchInDocument
(
searchText
,
flags
),
found
);
}
void
PlainTextEditFindBarTest
::
shouldReplaceAllText_data
()
{
QTest
::
addColumn
<
QString
>
(
"text"
);
QTest
::
addColumn
<
QString
>
(
"searchText"
);
QTest
::
addColumn
<
QString
>
(
"replaceText"
);
QTest
::
addColumn
<
QTextDocument
::
FindFlags
>
(
"flags"
);
QTest
::
addColumn
<
int
>
(
"nbElement"
);
QTest
::
newRow
(
"empty"
)
<<
QString
()
<<
QStringLiteral
(
"blabla"
)
<<
QStringLiteral
(
"replace"
)
<<
QTextDocument
::
FindFlags
()
<<
0
;
}
void
PlainTextEditFindBarTest
::
shouldReplaceAllText
()
{
QFETCH
(
QString
,
text
);
QFETCH
(
QString
,
searchText
);
QFETCH
(
QString
,
replaceText
);
QFETCH
(
QTextDocument
::
FindFlags
,
flags
);
QFETCH
(
int
,
nbElement
);
QPlainTextEdit
edit
;
PlainTextEditFindBarExample
w
(
&
edit
);
edit
.
setPlainText
(
text
);
QCOMPARE
(
KPIMTextEdit
::
FindUtils
::
replaceAll
(
&
edit
,
searchText
,
replaceText
,
flags
),
nbElement
);
}
src/texteditor/plaintexteditor/autotests/plaintexteditfindbartest.h
View file @
b434f0e3
...
...
@@ -18,4 +18,6 @@ private Q_SLOTS:
void
shouldHaveDefaultValues
();
void
shouldSearchText_data
();
void
shouldSearchText
();
void
shouldReplaceAllText_data
();
void
shouldReplaceAllText
();
};
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment