Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
KPimTextEdit
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
PIM
KPimTextEdit
Commits
f1b8dc07
Commit
f1b8dc07
authored
Apr 30, 2020
by
Laurent Montel
😁
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add more autotest
parent
27100a11
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
86 additions
and
0 deletions
+86
-0
src/grantleebuilder/autotests/CMakeLists.txt
src/grantleebuilder/autotests/CMakeLists.txt
+1
-0
src/grantleebuilder/autotests/data/object-fill.svg
src/grantleebuilder/autotests/data/object-fill.svg
+15
-0
src/grantleebuilder/autotests/texthtmlbuildertest.cpp
src/grantleebuilder/autotests/texthtmlbuildertest.cpp
+68
-0
src/grantleebuilder/autotests/texthtmlbuildertest.h
src/grantleebuilder/autotests/texthtmlbuildertest.h
+2
-0
No files found.
src/grantleebuilder/autotests/CMakeLists.txt
View file @
f1b8dc07
add_definitions
(
-DGRANTLEEBUILDER_DIR=
"
${
CMAKE_CURRENT_SOURCE_DIR
}
/data"
)
ecm_add_tests
(
texthtmlbuildertest.cpp
NAME_PREFIX
"kpimtextedit-grantleebuilder-"
LINK_LIBRARIES KF5::PimTextEdit Qt5::Test Qt5::Widgets Grantlee5::TextDocument
...
...
src/grantleebuilder/autotests/data/object-fill.svg
0 → 100644
View file @
f1b8dc07
<svg
xmlns=
"http://www.w3.org/2000/svg"
xmlns:xlink=
"http://www.w3.org/1999/xlink"
width=
"12"
height=
"12"
id=
"svg3049"
>
<defs
id=
"defs3051"
>
<linearGradient
id=
"linearGradient4234"
>
<stop
style=
"stop-color:#232629;stop-opacity:1"
offset=
"0"
id=
"stop4236"
/>
<stop
style=
"stop-color:#b3b3b3;stop-opacity:1"
offset=
"1"
id=
"stop4238"
/>
</linearGradient>
<style
id=
"current-color-scheme"
>
.ColorScheme-Text{color:#232629}.ColorScheme-Background{color:#eff0f1}.ColorScheme-Highlight{color:#3daee9}.ColorScheme-ViewText{color:#31363b}.ColorScheme-ViewBackground{color:#fcfcfc}.ColorScheme-ViewHover{color:#93cee9}.ColorScheme-ViewFocus{color:#3daee9}.ColorScheme-ButtonText{color:#31363b}.ColorScheme-ButtonBackground{color:#eff0f1}.ColorScheme-ButtonHover{color:#93cee9}.ColorScheme-ButtonFocus{color:#3daee9}
</style>
<linearGradient
xlink:href=
"#linearGradient4234"
id=
"linearGradient4240"
x1=
"422.714"
y1=
"546.791"
x2=
"432.714"
y2=
"536.791"
gradientUnits=
"userSpaceOnUse"
/>
</defs>
<g
id=
"layer1"
>
<path
style=
"fill:url(#linearGradient4240);fill-opacity:1;stroke:none;stroke-width:.1;stroke-linecap:square;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id=
"rect4232"
d=
"M422.714 536.791H432.714V546.791H422.714z"
transform=
"translate(-421.714 -535.79)"
/>
</g>
</svg>
src/grantleebuilder/autotests/texthtmlbuildertest.cpp
View file @
f1b8dc07
...
...
@@ -721,3 +721,71 @@ void TextHTMLBuilderTest::testNewlinesThroughQTextCursor()
delete
doc
;
}
void
TextHTMLBuilderTest
::
testInsertImage
()
{
auto
doc
=
new
QTextDocument
(
this
);
QTextCursor
cursor
(
doc
);
cursor
.
movePosition
(
QTextCursor
::
Start
);
cursor
.
insertText
(
QStringLiteral
(
"Foo"
));
cursor
.
insertText
(
QStringLiteral
(
"
\n
"
));
cursor
.
insertText
(
QStringLiteral
(
"
\n
"
));
cursor
.
insertText
(
QStringLiteral
(
"
\n
"
));
cursor
.
insertText
(
QStringLiteral
(
"Bar"
));
const
QString
imagePath
=
QStringLiteral
(
GRANTLEEBUILDER_DIR
"/object-fill.svg"
);
const
QImage
image
(
imagePath
);
QString
imageNameToAdd
=
QStringLiteral
(
"imagename"
);
doc
->
addResource
(
QTextDocument
::
ImageResource
,
QUrl
(
imageNameToAdd
),
image
);
cursor
.
insertImage
(
imageNameToAdd
);
auto
hb
=
new
KPIMTextEdit
::
TextHTMLBuilder
();
auto
md
=
new
KPIMTextEdit
::
MarkupDirector
(
hb
);
md
->
processDocument
(
doc
);
auto
result
=
hb
->
getResult
();
auto
regex
=
QRegularExpression
(
QStringLiteral
(
"^<p style=
\"
margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;
\"
>Foo</p>
\\
n<p> <p> <p style=
\"
margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;
\"
>Bar<img src=
\"
imagename
\"
/></p>
\\
n$"
));
QVERIFY
(
regex
.
match
(
result
).
hasMatch
());
delete
md
;
delete
hb
;
delete
doc
;
}
void
TextHTMLBuilderTest
::
testInsertImageWithSize
()
{
auto
doc
=
new
QTextDocument
(
this
);
QTextCursor
cursor
(
doc
);
cursor
.
movePosition
(
QTextCursor
::
Start
);
cursor
.
insertText
(
QStringLiteral
(
"Foo"
));
cursor
.
insertText
(
QStringLiteral
(
"
\n
"
));
cursor
.
insertText
(
QStringLiteral
(
"
\n
"
));
cursor
.
insertText
(
QStringLiteral
(
"
\n
"
));
cursor
.
insertText
(
QStringLiteral
(
"Bar"
));
const
QString
imagePath
=
QStringLiteral
(
GRANTLEEBUILDER_DIR
"/object-fill.svg"
);
const
QImage
image
(
imagePath
);
QString
imageNameToAdd
=
QStringLiteral
(
"imagename"
);
doc
->
addResource
(
QTextDocument
::
ImageResource
,
QUrl
(
imageNameToAdd
),
image
);
QTextImageFormat
format
;
format
.
setName
(
imageNameToAdd
);
format
.
setWidth
(
100
);
format
.
setHeight
(
120
);
cursor
.
insertImage
(
format
);
auto
hb
=
new
KPIMTextEdit
::
TextHTMLBuilder
();
auto
md
=
new
KPIMTextEdit
::
MarkupDirector
(
hb
);
md
->
processDocument
(
doc
);
auto
result
=
hb
->
getResult
();
auto
regex
=
QRegularExpression
(
QStringLiteral
(
"^<p style=
\"
margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;
\"
>Foo</p>
\\
n<p> <p> <p style=
\"
margin-top:0;margin-bottom:0;margin-left:0;margin-right:0;
\"
>Bar<img src=
\"
imagename
\"
width=
\"
100
\"
height=
\"
120
\"
/></p>
\\
n$"
));
QVERIFY
(
regex
.
match
(
result
).
hasMatch
());
delete
md
;
delete
hb
;
delete
doc
;
}
src/grantleebuilder/autotests/texthtmlbuildertest.h
View file @
f1b8dc07
...
...
@@ -54,6 +54,8 @@ private Q_SLOTS:
void
testHorizontalRule
();
void
testNewlines
();
void
testNewlinesThroughQTextCursor
();
void
testInsertImage
();
void
testInsertImageWithSize
();
};
#endif // TEXTHTMLBUILDERTEST_H
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