aboutsummaryrefslogtreecommitdiff
path: root/src/webengine/test/profile.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/webengine/test/profile.cpp')
-rw-r--r--src/webengine/test/profile.cpp145
1 files changed, 73 insertions, 72 deletions
diff --git a/src/webengine/test/profile.cpp b/src/webengine/test/profile.cpp
index 7351f66..ae3a4e3 100644
--- a/src/webengine/test/profile.cpp
+++ b/src/webengine/test/profile.cpp
@@ -22,98 +22,99 @@ TEST_CASE("loading profile settings")
delete settings;
}
-SCENARIO("loading individual profiles")
+SCENARIO("profile properties")
{
- GIVEN("no profile preset")
- {
- 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");
+ const QString search{ "about:blank" };
+ const QUrl homepage{ "about:blank" };
+ const QUrl newtab{ "about:blank" };
+ const QString id{ "id" };
+
+ REQUIRE(qEnvironmentVariableIsSet("PROFILE"));
- const QString id{ "id" };
- auto *settings = WebProfile::load(QString(), search, homepage, newtab);
- auto *profile = WebProfile::load(id, settings, true);
+ // 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 != nullptr);
+ REQUIRE(profile->isOffTheRecord());
+
+ WHEN("id constant")
+ {
REQUIRE(profile->getId() == id);
REQUIRE(profile->property("id").toString() == id);
- REQUIRE(profile->name() == id);
- REQUIRE(profile->search() == search);
- REQUIRE(profile->homepage() == homepage);
- REQUIRE(profile->newtab() == newtab);
-
- REQUIRE(profile->isOffTheRecord());
- delete settings;
- delete profile;
}
- GIVEN("an off-the-record profile preset")
+ WHEN("changing profile name")
{
- REQUIRE(qEnvironmentVariableIsSet("PROFILE"));
-
- const QString id{ "id" };
- auto *settings = WebProfile::load(qgetenv("PROFILE"), QString(), QUrl(), QUrl());
- auto *profile = WebProfile::load(id, settings, true);
-
- REQUIRE(profile != nullptr);
- REQUIRE(profile->getId() == id);
- REQUIRE(profile->isOffTheRecord());
-
- WHEN("created")
+ const QString name = GENERATE(as<QString>{}, "a", "bb", "ccc");
+ profile->setName(name);
+ THEN("the name changes")
{
- THEN("uses default values")
- {
- REQUIRE(profile->name() == "Test Profile");
- REQUIRE(profile->search() == "https://duckduckgo.com/?q=%1&ia=web");
- REQUIRE(profile->homepage() == QUrl("about:blank"));
- REQUIRE(profile->newtab() == QUrl("about:blank"));
- }
+ REQUIRE(profile->name() == name);
+ REQUIRE(settings->value("name").toString() == name);
}
-
- WHEN("changing profile name")
+ }
+ WHEN("changing search")
+ {
+ const QString search = GENERATE(as<QString>{}, "a", "bb", "ccc");
+ profile->setSearch(search);
+ THEN("the search url changes")
{
- 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);
- }
+ REQUIRE(profile->search() == search);
+ REQUIRE(settings->value("search").toString() == search);
}
- WHEN("changing search url")
+ }
+ WHEN("changing homepage url")
+ {
+ const QUrl url = GENERATE(as<QUrl>{}, "a", "bb", "ccc");
+ profile->setHomepage(url);
+ THEN("homepage changes")
{
- 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);
- }
+ REQUIRE(profile->homepage() == url);
+ REQUIRE(settings->value("homepage").toUrl() == url);
}
- WHEN("changing homepage")
+ }
+ WHEN("changing newtab url")
+ {
+ const QUrl url = GENERATE(as<QUrl>{}, "a", "bb", "ccc");
+ profile->setNewtab(url);
+ THEN("newtab changes")
{
- 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);
- }
+ REQUIRE(profile->newtab() == url);
+ REQUIRE(settings->value("newtab").toUrl() == url);
}
- WHEN("changing newtab")
+ }
+
+ 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")
{
- 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);
- }
+ // There is no event loop, so the signals cannot fire and update the cookie list
+ //REQUIRE(list == profile->cookies());
}
+ }
- delete settings;
- delete profile;
+ 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)