Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
PIM
PIM Messagelib
Commits
20cfe671
Commit
20cfe671
authored
Apr 17, 2017
by
David Faure
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/Applications/17.04'
parents
de35a1be
2aecb813
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
6 deletions
+13
-6
messageviewer/src/viewer/webengine/autotests/mailwebenginescripttest.cpp
...rc/viewer/webengine/autotests/mailwebenginescripttest.cpp
+11
-4
messageviewer/src/viewer/webengine/mailwebenginescript.cpp
messageviewer/src/viewer/webengine/mailwebenginescript.cpp
+2
-2
No files found.
messageviewer/src/viewer/webengine/autotests/mailwebenginescripttest.cpp
View file @
20cfe671
...
...
@@ -35,14 +35,21 @@ MailWebEngineScriptTest::~MailWebEngineScriptTest()
void
MailWebEngineScriptTest
::
shouldInjectAttachment
()
{
const
QString
result
=
QStringLiteral
(
"qt.jQuery('#bla').append('foo')"
);
QCOMPARE
(
MessageViewer
::
MailWebEngineScript
::
injectAttachments
(
QStringLiteral
(
"foo"
),
QStringLiteral
(
"bla"
)),
result
);
const
QString
expectedResult
=
QStringLiteral
(
"qt.jQuery('#bla').append('foo')"
);
QString
script
=
MessageViewer
::
MailWebEngineScript
::
injectAttachments
(
QStringLiteral
(
"foo"
),
QStringLiteral
(
"bla"
));
// skip the checks at the beginning of the script
script
=
script
.
mid
(
script
.
indexOf
(
QLatin1Char
(
'\n'
))
+
1
);
script
=
script
.
mid
(
script
.
indexOf
(
QLatin1Char
(
'\n'
))
+
1
);
QCOMPARE
(
script
,
expectedResult
);
}
void
MailWebEngineScriptTest
::
shouldReplaceInnerHtml
()
{
const
QString
result
=
QStringLiteral
(
"qt.jQuery('#iconFullGGAddressList').append('<a>hello word</a>')"
);
QCOMPARE
(
MessageViewer
::
MailWebEngineScript
::
replaceInnerHtml
(
QStringLiteral
(
"GG"
),
QStringLiteral
(
"<a>hello word</a>"
)),
result
);
const
QString
expectedResult
=
QStringLiteral
(
"qt.jQuery('#iconFullGGAddressList').append('<a>hello word</a>')"
);
QString
script
=
MessageViewer
::
MailWebEngineScript
::
replaceInnerHtml
(
QStringLiteral
(
"GG"
),
QStringLiteral
(
"<a>hello word</a>"
));
// skip the checks at the beginning of the script
script
=
script
.
mid
(
script
.
indexOf
(
QLatin1Char
(
'\n'
))
+
1
);
QCOMPARE
(
script
,
expectedResult
);
}
QTEST_MAIN
(
MailWebEngineScriptTest
)
messageviewer/src/viewer/webengine/mailwebenginescript.cpp
View file @
20cfe671
...
...
@@ -24,7 +24,7 @@ using namespace MessageViewer;
static
QString
checkJQuery
(
const
char
*
scriptName
)
{
return
QStringLiteral
(
"if (!qt) { console.warn(
\"
%1 executed too early, 'qt' variable unknown
\"
); };"
).
arg
(
QString
::
fromLatin1
(
scriptName
));
return
QStringLiteral
(
"if (!qt) { console.warn(
\"
%1 executed too early, 'qt' variable unknown
\"
); };
\n
"
).
arg
(
QString
::
fromLatin1
(
scriptName
));
}
QString
MailWebEngineScript
::
createShowHideAddressScript
(
const
QString
&
field
,
bool
hide
)
...
...
@@ -72,7 +72,7 @@ QString MailWebEngineScript::manageShowHideAttachments(bool hide)
QString
MailWebEngineScript
::
injectAttachments
(
const
QString
&
delayedHtml
,
const
QString
&
elementStr
)
{
const
QString
source
=
checkJQuery
(
"injectAttachments"
)
+
QString
::
fromLatin1
(
"if (!document.getElementById('%1')) { console.warn('NOT FOUND: %1'); };"
"if (!document.getElementById('%1')) { console.warn('NOT FOUND: %1'); };
\n
"
"qt.jQuery('#%1').append('%2')"
).
arg
(
elementStr
,
delayedHtml
);
return
source
;
}
...
...
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