From e9c6cdefff00daffb8b07e72c47f8e8f845ba436 Mon Sep 17 00:00:00 2001 From: Aqua-sama Date: Tue, 15 Dec 2020 11:51:08 +0200 Subject: Move src/webengine to lib/webengine --- src/webengine/test/form.html | 10 --- src/webengine/test/icon.svg | 7 -- src/webengine/test/profile.cpp | 125 ---------------------------------- src/webengine/test/profilemanager.cpp | 120 -------------------------------- src/webengine/test/sample.html | 7 -- src/webengine/test/testing.profile | 8 --- src/webengine/test/view.cpp | 92 ------------------------- 7 files changed, 369 deletions(-) delete mode 100644 src/webengine/test/form.html delete mode 100644 src/webengine/test/icon.svg delete mode 100644 src/webengine/test/profile.cpp delete mode 100644 src/webengine/test/profilemanager.cpp delete mode 100644 src/webengine/test/sample.html delete mode 100644 src/webengine/test/testing.profile delete mode 100644 src/webengine/test/view.cpp (limited to 'src/webengine/test') 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 @@ - - - - Form completion test - - - -

Form completion test

- - 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 @@ - - - - - - - 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 -#include - -TEST_CASE("loading profile settings") -{ - const QString search = GENERATE(as{}, "https://search.url/t=%1", "https://duckduckgo.com/?q=%1&ia=web", "aaabbbccc"); - const QUrl homepage = GENERATE(as{}, "https://homepage.net", "about:blank", "aaabbbccc"); - const QUrl newtab = GENERATE(as{}, "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(), 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{}, "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{}, "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{}, "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{}, "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 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 -#include - -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 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 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 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 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 @@ - -sample page - -

This is a sample page

- - - 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 -#include -#include -#include -#include - -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(); -} -- cgit v1.2.1