From cdb42f0d6b47a60ceb647e3ac6a6ce66352dbae4 Mon Sep 17 00:00:00 2001 From: "kali kaneko (leap communications)" Date: Thu, 18 Jun 2020 20:42:29 +0200 Subject: [test] minimal qml tests just a minimal boilerplate. the idea is to import the qml files and assert that the states/widgets change accordingly if we mock the backend status. - Closes: #300 --- tests/test_ui.cpp | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 tests/test_ui.cpp (limited to 'tests/test_ui.cpp') diff --git a/tests/test_ui.cpp b/tests/test_ui.cpp new file mode 100644 index 0000000..f9f960a --- /dev/null +++ b/tests/test_ui.cpp @@ -0,0 +1,52 @@ +// test_ui.cpp +#include +#include +#include + +#include "../gui/qjsonmodel.h" +#include "../lib/libgoshim.h" + +class Helper : public QObject +{ + Q_OBJECT + +public: + explicit Helper(QObject *parent = 0); + +public slots: + Q_INVOKABLE QString refreshContext(); +}; + +Helper::Helper(QObject *parent) : QObject(parent) +{ +} + +Q_INVOKABLE QString Helper::refreshContext() +{ + return QString(RefreshContext()); +} + +class Setup : public QObject +{ + Q_OBJECT + +public: + Setup() {} + +public slots: + void qmlEngineAvailable(QQmlEngine *engine) + { + QQmlContext *ctx = engine->rootContext(); + QJsonModel *model = new QJsonModel; + Helper *helper = new Helper(this); + + InitializeTestBitmaskContext(); + + ctx->setContextProperty("jsonModel", model); + ctx->setContextProperty("helper", helper); + } +}; + +QUICK_TEST_MAIN_WITH_SETUP(ui, Setup) + +#include "test_ui.moc" -- cgit v1.2.3