Commit 1bb28fe9 authored by Laurent Montel's avatar Laurent Montel 😁
Browse files

Add autotest

parent 99779f09
......@@ -19,16 +19,27 @@
#include "developertooldialogtest.h"
#include "widgets/developertooldialog.h"
#include "widgets/developertoolwidget.h"
#include <QTest>
#include <QStandardPaths>
#include <QVBoxLayout>
#include <QDialogButtonBox>
QTEST_MAIN(DeveloperToolDialogTest)
DeveloperToolDialogTest::DeveloperToolDialogTest(QObject *parent)
: QObject(parent)
{
QStandardPaths::setTestModeEnabled(true);
}
void DeveloperToolDialogTest::shouldHaveDefaultValues()
{
MessageViewer::DeveloperToolDialog d;
//TODO
QVBoxLayout *mainLayout = d.findChild<QVBoxLayout *>(QStringLiteral("mainLayout"));
QVERIFY(mainLayout);
MessageViewer::DeveloperToolWidget *mDeveloperToolWidget = d.findChild<MessageViewer::DeveloperToolWidget *>(QStringLiteral("mDeveloperToolWidget"));
QVERIFY(mDeveloperToolWidget);
QDialogButtonBox *buttonBox = d.findChild<QDialogButtonBox *>(QStringLiteral("buttonBox"));
QVERIFY(buttonBox);
}
......@@ -18,10 +18,30 @@
*/
#include "developertoolwidgettest.h"
#include "widgets/developertoolwidget.h"
#include <QTest>
#include <QVBoxLayout>
#include <QWebEngineView>
#include <QWebEngineSettings>
QTEST_MAIN(DeveloperToolWidgetTest)
DeveloperToolWidgetTest::DeveloperToolWidgetTest(QObject *parent)
: QObject(parent)
{
}
void DeveloperToolWidgetTest::shouldHaveDefaultValues()
{
MessageViewer::DeveloperToolWidget w;
QVBoxLayout *mainLayout = w.findChild<QVBoxLayout *>(QStringLiteral("mainLayout"));
QVERIFY(mainLayout);
QCOMPARE(mainLayout->contentsMargins(), QMargins(0, 0, 0, 0));
QWebEngineView *mWebEngineView = w.findChild<QWebEngineView *>(QStringLiteral("mWebEngineView"));
QVERIFY(mWebEngineView);
mainLayout->addWidget(mWebEngineView);
QWebEnginePage *mEnginePage = w.findChild<QWebEnginePage *>(QStringLiteral("mEnginePage"));
QVERIFY(mEnginePage);
QCOMPARE(mWebEngineView->page(), mEnginePage);
QVERIFY(mEnginePage->settings()->testAttribute(QWebEngineSettings::JavascriptEnabled));
}
......@@ -28,6 +28,8 @@ class DeveloperToolWidgetTest : public QObject
public:
explicit DeveloperToolWidgetTest(QObject *parent = nullptr);
~DeveloperToolWidgetTest() = default;
private Q_SLOTS:
void shouldHaveDefaultValues();
};
#endif // DEVELOPERTOOLWIDGETTEST_H
......@@ -34,6 +34,7 @@ DeveloperToolWidget::DeveloperToolWidget(QWidget *parent)
mWebEngineView->setObjectName(QStringLiteral("mWebEngineView"));
mainLayout->addWidget(mWebEngineView);
mEnginePage = new QWebEnginePage(this);
mEnginePage->setObjectName(QStringLiteral("mEnginePage"));
mEnginePage->settings()->setAttribute(QWebEngineSettings::JavascriptEnabled, true);
mWebEngineView->setPage(mEnginePage);
......
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