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/profile.cpp | 125 ----------------------------------------- 1 file changed, 125 deletions(-) delete mode 100644 src/webengine/test/profile.cpp (limited to 'src/webengine/test/profile.cpp') 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; -} -- cgit v1.2.1