Commit 79133830 authored by Laurent Montel's avatar Laurent Montel 😁

Reactivate some tests

parent 388d59fc
...@@ -32,13 +32,14 @@ ...@@ -32,13 +32,14 @@
#include <QLocale> #include <QLocale>
#include <QTimeZone> #include <QTimeZone>
#include <QSignalSpy> #include <QSignalSpy>
#include <QStandardPaths>
using namespace MimeTreeParser; using namespace MimeTreeParser;
TemplateParserJobTest::TemplateParserJobTest(QObject *parent) TemplateParserJobTest::TemplateParserJobTest(QObject *parent)
: QObject(parent) : QObject(parent)
{ {
QStandardPaths::setTestModeEnabled(true);
} }
TemplateParserJobTest::~TemplateParserJobTest() TemplateParserJobTest::~TemplateParserJobTest()
...@@ -47,7 +48,7 @@ TemplateParserJobTest::~TemplateParserJobTest() ...@@ -47,7 +48,7 @@ TemplateParserJobTest::~TemplateParserJobTest()
QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete); QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
} }
#if 0
void TemplateParserJobTest::test_convertedHtml_data() void TemplateParserJobTest::test_convertedHtml_data()
{ {
QTest::addColumn<QString>("mailFileName"); QTest::addColumn<QString>("mailFileName");
...@@ -83,12 +84,18 @@ void TemplateParserJobTest::test_convertedHtml() ...@@ -83,12 +84,18 @@ void TemplateParserJobTest::test_convertedHtml()
QCOMPARE(msg->subject()->as7BitString(false).constData(), "Plain Message Test"); QCOMPARE(msg->subject()->as7BitString(false).constData(), "Plain Message Test");
QCOMPARE(msg->contents().size(), 0); QCOMPARE(msg->contents().size(), 0);
TemplateParser::TemplateParserJob parser(msg, TemplateParser::TemplateParserJob::NewMessage); TemplateParser::TemplateParserJob *parser = new TemplateParser::TemplateParserJob(msg, TemplateParser::TemplateParserJob::NewMessage);
parser.mOtp->parseObjectTree(msg.data()); KIdentityManagement::IdentityManager *identMan = new KIdentityManagement::IdentityManager;
QVERIFY(parser.mOtp->htmlContent().isEmpty()); parser->setIdentityManager(identMan);
QVERIFY(!parser.mOtp->plainTextContent().isEmpty()); parser->mOtp->parseObjectTree(msg.data());
QVERIFY(parser->mOtp->htmlContent().isEmpty());
QVERIFY(!parser->mOtp->plainTextContent().isEmpty());
QSignalSpy spy(parser, &TemplateParser::TemplateParserJob::parsingDone);
parser->processWithTemplate(QString());
QVERIFY(spy.wait());
const QString convertedHtmlContent = parser.htmlMessageText(false, TemplateParser::TemplateParserJob::NoSelectionAllowed); const QString convertedHtmlContent = parser->htmlMessageText(false, TemplateParser::TemplateParserJob::NoSelectionAllowed);
QVERIFY(!convertedHtmlContent.isEmpty()); QVERIFY(!convertedHtmlContent.isEmpty());
QCOMPARE(convertedHtmlContent, referenceData); QCOMPARE(convertedHtmlContent, referenceData);
...@@ -133,19 +140,26 @@ void TemplateParserJobTest::test_replyPlain() ...@@ -133,19 +140,26 @@ void TemplateParserJobTest::test_replyPlain()
// QCOMPARE(msg->subject()->as7BitString(false).constData(), "Plain Message Test"); // QCOMPARE(msg->subject()->as7BitString(false).constData(), "Plain Message Test");
// QCOMPARE(msg->contents().size(), 0); // QCOMPARE(msg->contents().size(), 0);
TemplateParser::TemplateParserJob parser(msg, TemplateParser::TemplateParserJob::Reply); TemplateParser::TemplateParserJob *parser = new TemplateParser::TemplateParserJob(msg, TemplateParser::TemplateParserJob::Reply);
parser.mOtp->parseObjectTree(msg.data()); //KIdentityManagement::IdentityManager *identMan = new KIdentityManagement::IdentityManager;
parser.mOrigMsg = msg; //parser->setIdentityManager(identMan);
// QVERIFY(parser.mOtp->htmlContent().isEmpty());
// QVERIFY(!parser.mOtp->plainTextContent().isEmpty());
QBENCHMARK { parser->mOtp->parseObjectTree(msg.data());
const QString convertedHtmlContent = parser.plainMessageText(false, TemplateParser::TemplateParserJob::NoSelectionAllowed); parser->mOrigMsg = msg;
//QVERIFY(parser->mOtp->htmlContent().isEmpty());
//QVERIFY(!parser->mOtp->plainTextContent().isEmpty());
QCOMPARE(convertedHtmlContent, referenceData); // QSignalSpy spy(parser, &TemplateParser::TemplateParserJob::parsingDone);
} // parser->processWithTemplate(QString());
// QVERIFY(spy.wait());
// QBENCHMARK {
// const QString convertedHtmlContent = parser->plainMessageText(false, TemplateParser::TemplateParserJob::NoSelectionAllowed);
// QCOMPARE(convertedHtmlContent, referenceData);
// }
} }
#endif
void TemplateParserJobTest::test_processWithTemplatesForBody_data() void TemplateParserJobTest::test_processWithTemplatesForBody_data()
{ {
......
...@@ -33,11 +33,11 @@ private Q_SLOTS: ...@@ -33,11 +33,11 @@ private Q_SLOTS:
* checks whether text/plain only mails are converted to a valid HTML * checks whether text/plain only mails are converted to a valid HTML
*/ */
// void test_convertedHtml(); void test_convertedHtml();
// void test_convertedHtml_data(); void test_convertedHtml_data();
// void test_replyPlain(); void test_replyPlain();
// void test_replyPlain_data(); void test_replyPlain_data();
/** /**
* Tests whether templates are returning required body or not * Tests whether templates are returning required body or not
......
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