Commit d522ad75 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Create autotests

parent 76ef56f3
......@@ -7,5 +7,5 @@ ecm_add_test(mailwebengineaccesskeyanchortest.cpp ../mailwebengineaccesskeyanch
ecm_add_test(mailwebengineaccesskeyanchorfromhtmltest.cpp ../mailwebengineaccesskeyanchor.cpp ../mailwebengineaccesskeyutils.cpp
TEST_NAME mailwebengineaccesskeyanchorfromhtmltest
NAME_PREFIX "messageviewer-webengine-"
LINK_LIBRARIES Qt5::Test KF5::MessageViewer
LINK_LIBRARIES Qt5::Test KF5::MessageViewer Qt5::WebEngine Qt5::WebEngineWidgets
)
......@@ -17,7 +17,58 @@
#include "mailwebengineaccesskeyanchorfromhtmltest.h"
#include "../mailwebengineaccesskeyutils.h"
#include <QTest>
#include <QHBoxLayout>
#include <QWebEngineView>
template<typename Arg, typename R, typename C>
struct InvokeWrapper {
R *receiver;
void (C::*memberFunction)(Arg);
void operator()(Arg result)
{
(receiver->*memberFunction)(result);
}
};
template<typename Arg, typename R, typename C>
InvokeWrapper<Arg, R, C> invoke(R *receiver, void (C::*memberFunction)(Arg))
{
InvokeWrapper<Arg, R, C> wrapper = {receiver, memberFunction};
return wrapper;
}
TestWebEngineAccessKey::TestWebEngineAccessKey(QWidget *parent)
: QWidget(parent)
{
QHBoxLayout *hbox = new QHBoxLayout(this);
mEngineView = new QWebEngineView(this);
connect(mEngineView, &QWebEngineView::loadFinished, this, &TestWebEngineAccessKey::loadFinished);
hbox->addWidget(mEngineView);
}
TestWebEngineAccessKey::~TestWebEngineAccessKey()
{
}
void TestWebEngineAccessKey::setHtml(const QString &html)
{
mEngineView->setHtml(html);
}
void TestWebEngineAccessKey::handleSearchAccessKey(const QVariant &var)
{
//TODO
}
void TestWebEngineAccessKey::loadFinished(bool b)
{
mEngineView->page()->runJavaScript(MessageViewer::MailWebEngineAccessKeyUtils::script(), invoke(this, &TestWebEngineAccessKey::handleSearchAccessKey));
//TODO
}
MailWebEngineAccessKeyAnchorFromHtmlTest::MailWebEngineAccessKeyAnchorFromHtmlTest(QObject *parent)
: QObject(parent)
......@@ -30,4 +81,7 @@ void MailWebEngineAccessKeyAnchorFromHtmlTest::shouldNotShowAccessKeyWhenHtmlAsN
}
QTEST_MAIN(MailWebEngineAccessKeyAnchorFromHtmlTest)
......@@ -19,6 +19,26 @@
#define MAILWEBENGINEACCESSKEYANCHORFROMHTMLTEST_H
#include <QObject>
#include <QWidget>
class QWebEngineView;
class TestWebEngineAccessKey : public QWidget
{
Q_OBJECT
public:
explicit TestWebEngineAccessKey(QWidget *parent = Q_NULLPTR);
~TestWebEngineAccessKey();
void setHtml(const QString &html);
private Q_SLOTS:
void loadFinished(bool b);
void handleSearchAccessKey(const QVariant &var);
Q_SIGNALS:
void accessKeySearchFinished();
private:
QWebEngineView *mEngineView;
};
class MailWebEngineAccessKeyAnchorFromHtmlTest : public QObject
{
......
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