diff options
author | kali kaneko (leap communications) <kali@leap.se> | 2020-10-02 13:22:07 +0200 |
---|---|---|
committer | Ruben Pollan <meskio@sindominio.net> | 2020-10-02 19:31:54 +0200 |
commit | ac30c6954a55347677d04ad2d8485b8ce85c9a55 (patch) | |
tree | 8cacc84deafa7e25c3c7572d71f86fa1ac5b75cb /tests/test_ui.cpp | |
parent | 7ef59391594be905f8340cb5fef2afe2c25ddba9 (diff) |
[test] update ui smoke test, add it to ci
Diffstat (limited to 'tests/test_ui.cpp')
-rw-r--r-- | tests/test_ui.cpp | 34 |
1 files changed, 33 insertions, 1 deletions
diff --git a/tests/test_ui.cpp b/tests/test_ui.cpp index f9f960a..7642157 100644 --- a/tests/test_ui.cpp +++ b/tests/test_ui.cpp @@ -6,6 +6,23 @@ #include "../gui/qjsonmodel.h" #include "../lib/libgoshim.h" + +GoString _toGoStr(QString s) +{ + const char *c = s.toUtf8().constData(); + return (GoString){c, (long int)strlen(c)}; +} + +QString getAppName(QJsonValue info, QString provider) { + for (auto p: info.toArray()) { + QJsonObject item = p.toObject(); + if (item["name"] == provider) { + return item["applicationName"].toString(); + } + } + return "BitmaskVPN"; +} + class Helper : public QObject { Q_OBJECT @@ -40,9 +57,24 @@ public slots: QJsonModel *model = new QJsonModel; Helper *helper = new Helper(this); - InitializeTestBitmaskContext(); + /* load providers json */ + QFile providerJson (":/providers.json"); + providerJson.open(QIODevice::ReadOnly | QIODevice::Text); + QJsonModel *providers = new QJsonModel; + QByteArray providerJsonBytes = providerJson.readAll(); + providers->loadJson(providerJsonBytes); + QJsonValue defaultProvider = providers->json().object().value("default"); + QJsonValue providersInfo = providers->json().object().value("providers"); + QString appName = getAppName(providersInfo, defaultProvider.toString()); + + InitializeTestBitmaskContext( + _toGoStr(defaultProvider.toString()), + (char*)providerJsonBytes.data(), providerJsonBytes.length()); ctx->setContextProperty("jsonModel", model); + ctx->setContextProperty("providers", providers); + + /* helper for tests */ ctx->setContextProperty("helper", helper); } }; |