Commit 2aecb813 authored by David Faure's avatar David Faure
Browse files

[autotests] repair mailwebenginescripttest after my changes in 37b99257

parent 31599b5f
...@@ -35,14 +35,21 @@ MailWebEngineScriptTest::~MailWebEngineScriptTest() ...@@ -35,14 +35,21 @@ MailWebEngineScriptTest::~MailWebEngineScriptTest()
void MailWebEngineScriptTest::shouldInjectAttachment() void MailWebEngineScriptTest::shouldInjectAttachment()
{ {
const QString result = QStringLiteral("qt.jQuery('#bla').append('foo')"); const QString expectedResult = QStringLiteral("qt.jQuery('#bla').append('foo')");
QCOMPARE(MessageViewer::MailWebEngineScript::injectAttachments(QStringLiteral("foo"), QStringLiteral("bla")), result); 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() void MailWebEngineScriptTest::shouldReplaceInnerHtml()
{ {
const QString result = QStringLiteral("qt.jQuery('#iconFullGGAddressList').append('<a>hello word</a>')"); const QString expectedResult = QStringLiteral("qt.jQuery('#iconFullGGAddressList').append('<a>hello word</a>')");
QCOMPARE(MessageViewer::MailWebEngineScript::replaceInnerHtml(QStringLiteral("GG"), QStringLiteral("<a>hello word</a>")), result); 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) QTEST_MAIN(MailWebEngineScriptTest)
...@@ -24,7 +24,7 @@ using namespace MessageViewer; ...@@ -24,7 +24,7 @@ using namespace MessageViewer;
static QString checkJQuery(const char *scriptName) 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) QString MailWebEngineScript::createShowHideAddressScript(const QString &field, bool hide)
...@@ -72,7 +72,7 @@ QString MailWebEngineScript::manageShowHideAttachments(bool hide) ...@@ -72,7 +72,7 @@ QString MailWebEngineScript::manageShowHideAttachments(bool hide)
QString MailWebEngineScript::injectAttachments(const QString &delayedHtml, const QString &elementStr) QString MailWebEngineScript::injectAttachments(const QString &delayedHtml, const QString &elementStr)
{ {
const QString source = checkJQuery("injectAttachments") + QString::fromLatin1( 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); "qt.jQuery('#%1').append('%2')").arg(elementStr, delayedHtml);
return source; return source;
} }
......
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