aboutsummaryrefslogtreecommitdiff
path: root/src/webengine/test
diff options
context:
space:
mode:
authorAqua-sama <aqua@iserlohn-fortress.net>2020-12-15 11:51:08 +0200
committerAqua-sama <aqua@iserlohn-fortress.net>2020-12-15 15:23:12 +0200
commite9c6cdefff00daffb8b07e72c47f8e8f845ba436 (patch)
treefeb3ec54de25fd2c41ccc6dc1d586642a84babf9 /src/webengine/test
parentCode cleanup (diff)
downloadsmolbote-e9c6cdefff00daffb8b07e72c47f8e8f845ba436.tar.xz
Move src/webengine to lib/webengine
Diffstat (limited to 'src/webengine/test')
-rw-r--r--src/webengine/test/form.html10
-rw-r--r--src/webengine/test/icon.svg7
-rw-r--r--src/webengine/test/profile.cpp125
-rw-r--r--src/webengine/test/profilemanager.cpp120
-rw-r--r--src/webengine/test/sample.html7
-rw-r--r--src/webengine/test/testing.profile8
-rw-r--r--src/webengine/test/view.cpp92
7 files changed, 0 insertions, 369 deletions
diff --git a/src/webengine/test/form.html b/src/webengine/test/form.html
deleted file mode 100644
index 9d8b19e..0000000
--- a/src/webengine/test/form.html
+++ /dev/null
@@ -1,10 +0,0 @@
-<html>
-
-<head>
- <title>Form completion test</title>
-</head>
-
-<body>
-<h2>Form completion test</h2>
-</body>
-</html>
diff --git a/src/webengine/test/icon.svg b/src/webengine/test/icon.svg
deleted file mode 100644
index a348cab..0000000
--- a/src/webengine/test/icon.svg
+++ /dev/null
@@ -1,7 +0,0 @@
-<svg xmlns="http://www.w3.org/2000/svg" width="300" height="300" version="1.1">
- <circle cx="150" cy="150" r="100" stroke="#000000" stroke-width="6" fill="#e60026"></circle>
- <circle cx="150" cy="150" r="87" stroke="#000000" stroke-width="4" fill="#e5e4e2"></circle>
- <path d="M230,150 A80,80 0 0 0 150,70 L150,150 Z" />
- <path d="M70,150 A80,80 0 0 0 150,230 L150,150 Z" />
-</svg>
-
diff --git a/src/webengine/test/profile.cpp b/src/webengine/test/profile.cpp
deleted file mode 100644
index ae3a4e3..0000000
--- a/src/webengine/test/profile.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-#define CATCH_CONFIG_RUNNER
-
-// clazy:excludeall=non-pod-global-static
-
-#include "webprofilemanager.h"
-#include <QApplication>
-#include <catch2/catch.hpp>
-
-TEST_CASE("loading profile settings")
-{
- const QString search = GENERATE(as<QString>{}, "https://search.url/t=%1", "https://duckduckgo.com/?q=%1&ia=web", "aaabbbccc");
- const QUrl homepage = GENERATE(as<QUrl>{}, "https://homepage.net", "about:blank", "aaabbbccc");
- const QUrl newtab = GENERATE(as<QUrl>{}, "https://newtab.net", "about:blank", "aaabbbccc");
-
- auto *settings = WebProfile::load(QString(), search, homepage, newtab);
-
- REQUIRE(settings != nullptr);
- REQUIRE(settings->value("search").toString() == search);
- REQUIRE(settings->value("homepage").toUrl() == homepage);
- REQUIRE(settings->value("newtab").toUrl() == newtab);
-
- delete settings;
-}
-
-SCENARIO("profile properties")
-{
- const QString search{ "about:blank" };
- const QUrl homepage{ "about:blank" };
- const QUrl newtab{ "about:blank" };
- const QString id{ "id" };
-
- REQUIRE(qEnvironmentVariableIsSet("PROFILE"));
-
- // create an empty settings object
- const QString settings_path = GENERATE(as<QString>{}, QString(), qgetenv("PROFILE"));
- auto *settings = WebProfile::load(settings_path, search, homepage, newtab);
- // create the actual profile
- auto *profile = WebProfile::load(id, settings, true);
-
- REQUIRE(profile != nullptr);
- REQUIRE(profile->isOffTheRecord());
-
- WHEN("id constant")
- {
- REQUIRE(profile->getId() == id);
- REQUIRE(profile->property("id").toString() == id);
- }
-
- WHEN("changing profile name")
- {
- const QString name = GENERATE(as<QString>{}, "a", "bb", "ccc");
- profile->setName(name);
- THEN("the name changes")
- {
- REQUIRE(profile->name() == name);
- REQUIRE(settings->value("name").toString() == name);
- }
- }
- WHEN("changing search")
- {
- const QString search = GENERATE(as<QString>{}, "a", "bb", "ccc");
- profile->setSearch(search);
- THEN("the search url changes")
- {
- REQUIRE(profile->search() == search);
- REQUIRE(settings->value("search").toString() == search);
- }
- }
- WHEN("changing homepage url")
- {
- const QUrl url = GENERATE(as<QUrl>{}, "a", "bb", "ccc");
- profile->setHomepage(url);
- THEN("homepage changes")
- {
- REQUIRE(profile->homepage() == url);
- REQUIRE(settings->value("homepage").toUrl() == url);
- }
- }
- WHEN("changing newtab url")
- {
- const QUrl url = GENERATE(as<QUrl>{}, "a", "bb", "ccc");
- profile->setNewtab(url);
- THEN("newtab changes")
- {
- REQUIRE(profile->newtab() == url);
- REQUIRE(settings->value("newtab").toUrl() == url);
- }
- }
-
- WHEN("changing cookies")
- {
- auto list = profile->cookies();
- REQUIRE(list.isEmpty());
- list.append(QNetworkCookie("name", "value").toRawForm());
- profile->setCookies(list);
- THEN("new cookie list gets applied")
- {
- // There is no event loop, so the signals cannot fire and update the cookie list
- //REQUIRE(list == profile->cookies());
- }
- }
-
- WHEN("changing headers")
- {
- QMap<QString, QVariant> headers;
- headers.insert("Dnt", "1");
- headers.insert("unknown", "pair");
-
- profile->setHeaders(headers);
- THEN("headers change")
- {
- REQUIRE(profile->headers() == headers);
- }
- }
-
- delete settings;
- delete profile;
-}
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
- const auto r = Catch::Session().run(argc, argv);
- return r;
-}
diff --git a/src/webengine/test/profilemanager.cpp b/src/webengine/test/profilemanager.cpp
deleted file mode 100644
index 8f6a34f..0000000
--- a/src/webengine/test/profilemanager.cpp
+++ /dev/null
@@ -1,120 +0,0 @@
-#define CATCH_CONFIG_RUNNER
-
-// clazy:excludeall=non-pod-global-static
-
-#include "webprofilemanager.h"
-#include <QApplication>
-#include <catch2/catch.hpp>
-
-SCENARIO("WebProfileManager")
-{
- const QString search{ "https://search.url/t=%1" };
- const QUrl homepage{ "https://homepage.net" };
- const QUrl newtab{ "https://newtab.net" };
- const QString default_id{ "default" };
-
- GIVEN("an empty profile list")
- {
- WebProfileManager<false> profiles({}, default_id, search, homepage, newtab);
-
- REQUIRE(profiles.idList().count() == 1);
- REQUIRE(profiles.profile(default_id) == WebProfile::defaultProfile());
- REQUIRE(profiles.profile("not-in-list") == nullptr);
-
- WHEN("adding a new profile")
- {
- const QString id{ "id" };
- auto *settings = WebProfile::load(QString(), search, homepage, newtab);
- auto *profile = WebProfile::load(id, settings, true);
-
- THEN("doesn't add profile without settings")
- {
- profiles.add(id, profile, nullptr);
- REQUIRE(profiles.idList().count() == 1);
- }
-
- THEN("doesn't add settings without profile")
- {
- profiles.add(id, nullptr, settings);
- REQUIRE(profiles.idList().count() == 1);
- }
-
- THEN("adds new profile with settings")
- {
- profiles.add(id, profile, settings);
- REQUIRE(profiles.idList().count() == 2);
- }
- }
-
- WHEN("moving")
- {
- WebProfileManager<false> other(std::move(profiles));
- THEN("moved has the same number of profiles")
- {
- REQUIRE(other.idList().count() == 1);
- REQUIRE(other.profile(default_id) == WebProfile::defaultProfile());
- REQUIRE(other.profile("not-in-list") == nullptr);
- }
- }
- }
-
- GIVEN("a number of profiles, default undefined")
- {
- REQUIRE(qEnvironmentVariableIsSet("PROFILE"));
-
- WebProfileManager<false> profiles(QString::fromLatin1(qgetenv("PROFILE")).split(';'), default_id, search, homepage, newtab);
-
- REQUIRE(profiles.idList().count() == 2);
- REQUIRE(profiles.profile(default_id) == WebProfile::defaultProfile());
- REQUIRE(profiles.profile("testing") != nullptr);
- REQUIRE(profiles.profile("not-in-list") == nullptr);
-
- WHEN("making global")
- {
- profiles.make_global();
- WebProfileManager other;
-
- THEN("global has the same number of profiles")
- {
- REQUIRE(other.idList().count() == 2);
- REQUIRE(other.profile(default_id) == WebProfile::defaultProfile());
- REQUIRE(other.profile("testing") != nullptr);
- REQUIRE(other.profile("not-in-list") == nullptr);
- }
-
- THEN("walking has no nullptrs")
- {
- other.walk([](const QString &, WebProfile *profile, const QSettings *settings) {
- REQUIRE(profile != nullptr);
- REQUIRE(settings != nullptr);
- });
- }
- }
- }
-
- GIVEN("a number of profiles, default defined")
- {
- REQUIRE(qEnvironmentVariableIsSet("PROFILE"));
-
- WebProfileManager<false> profiles(QString::fromLatin1(qgetenv("PROFILE")).split(';'), "testing", search, homepage, newtab);
-
- REQUIRE(profiles.idList().count() == 1);
- REQUIRE(profiles.profile("testing") == WebProfile::defaultProfile());
- REQUIRE(profiles.profile("not-in-list") == nullptr);
-
- WHEN("walking")
- {
- profiles.walk([](const QString &, WebProfile *profile, const QSettings *settings) {
- REQUIRE(profile != nullptr);
- REQUIRE(settings != nullptr);
- });
- }
- }
-}
-
-int main(int argc, char **argv)
-{
- QApplication app(argc, argv);
- const auto r = Catch::Session().run(argc, argv);
- return r;
-}
diff --git a/src/webengine/test/sample.html b/src/webengine/test/sample.html
deleted file mode 100644
index 54746d5..0000000
--- a/src/webengine/test/sample.html
+++ /dev/null
@@ -1,7 +0,0 @@
-<html>
-<head><title>sample page</title></head>
-<body>
- <h2><img src="icon.svg" />This is a sample page</h2>
- <iframe width="100%" height="80%" src="form.html"></iframe>
-</body>
-</html>
diff --git a/src/webengine/test/testing.profile b/src/webengine/test/testing.profile
deleted file mode 100644
index e345a3e..0000000
--- a/src/webengine/test/testing.profile
+++ /dev/null
@@ -1,8 +0,0 @@
-name=Test Profile
-otr=true
-search=https://duckduckgo.com/?q=%1&ia=web
-homepage=about:blank
-newtab=about:blank
-
-[headers]
-Dnt=1
diff --git a/src/webengine/test/view.cpp b/src/webengine/test/view.cpp
deleted file mode 100644
index 8aa639a..0000000
--- a/src/webengine/test/view.cpp
+++ /dev/null
@@ -1,92 +0,0 @@
-#define CATCH_CONFIG_RUNNER
-
-// clazy:excludeall=non-pod-global-static
-
-#include "webprofile.h"
-#include "webview.h"
-#include <QApplication>
-#include <QMainWindow>
-#include <QTimer>
-#include <QtWebEngine>
-#include <catch2/catch.hpp>
-
-SCENARIO("WebView")
-{
- const QString profile_id{ "default" };
- auto *settings = WebProfile::load(qgetenv("PROFILE"), "about:blank", QUrl{ "about:blank" }, QUrl{ "about:blank" });
- auto *profile = WebProfile::load(profile_id, settings, true);
-
- QMainWindow window;
- auto *view = new WebView(profile, nullptr);
- window.setCentralWidget(view);
- window.show();
- window.resize(800, 600);
-
- WHEN("created")
- {
- THEN("using the default profile")
- {
- REQUIRE(view->profile() == profile);
- }
- THEN("serialized using default profile")
- {
- const auto data = view->serialize();
- REQUIRE(data.profile == profile_id);
- REQUIRE(data.url.isEmpty());
- REQUIRE(!data.history.isEmpty());
- }
- THEN("loading a url")
- {
- // block until a loadFinished signal
- QEventLoop pause;
- QObject::connect(view, &WebView::loadFinished, &pause, &QEventLoop::quit);
- view->load(QUrl{ qgetenv("URL") });
- pause.exec();
-
- REQUIRE(view->isLoaded());
- }
- }
-
- WHEN("changing profiles")
- {
- const QString swap_profile_id{ "swap_profile" };
- auto *swap_settings = WebProfile::load(QString(), "about:blank", QUrl{ "about:blank" }, QUrl{ "about:blank" });
- auto *swap_profile = WebProfile::load(swap_profile_id, swap_settings, true);
-
- view->setProfile(swap_profile);
- THEN("using the swap profile")
- {
- REQUIRE(view->profile() == swap_profile);
- }
- THEN("serialized using swap profile")
- {
- const auto data = view->serialize();
- REQUIRE(data.profile == swap_profile_id);
- REQUIRE(data.url.isEmpty());
- REQUIRE(!data.history.isEmpty());
- }
-
- view->setProfile(profile);
- delete swap_settings;
- delete swap_profile;
- }
-
- // cleanup
- window.close();
- delete view;
- delete settings;
- delete profile;
-}
-
-int main(int argc, char **argv)
-{
- QtWebEngine::initialize();
- QApplication app(argc, argv);
-
- QTimer::singleShot(0, &app, [argc, argv, &app]() {
- const auto n_failed = Catch::Session().run(argc, argv);
- app.exit(n_failed);
- });
-
- return app.exec();
-}