aboutsummaryrefslogtreecommitdiff
path: root/src/webengine/test/profilemanager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/webengine/test/profilemanager.cpp')
-rw-r--r--src/webengine/test/profilemanager.cpp120
1 files changed, 0 insertions, 120 deletions
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;
-}