aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-03-25 13:13:02 +0530
committerAkshay Nair <phenax5@gmail.com>2025-03-25 18:20:18 +0530
commit4cbaaae7c55e71d2d4db591029394812077eb844 (patch)
tree23574a00f4790332e9aafb4fd86fbc046c0ed85a /spec
parent346c16b4e2ea26f47e0e370a490b7794492a9ebb (diff)
downloadnull-browser-4cbaaae7c55e71d2d4db591029394812077eb844.tar.gz
null-browser-4cbaaae7c55e71d2d4db591029394812077eb844.zip
Add web.history for history navigation
Diffstat (limited to 'spec')
-rw-r--r--spec/WebViewStackSpec.cpp220
1 files changed, 110 insertions, 110 deletions
diff --git a/spec/WebViewStackSpec.cpp b/spec/WebViewStackSpec.cpp
index 134c250..6e46db6 100644
--- a/spec/WebViewStackSpec.cpp
+++ b/spec/WebViewStackSpec.cpp
@@ -23,11 +23,11 @@ private slots:
context("when initialized");
it("opens a single tab") {
Configuration configuration;
- WebViewStack web_view_stack(&configuration);
+ WebViewStack webview_stack(&configuration);
- QCOMPARE(web_view_stack.count(), 1);
- QCOMPARE(web_view_stack.current_url(), configuration.new_tab_url);
- web_view_stack.deleteLater();
+ QCOMPARE(webview_stack.count(), 1);
+ QCOMPARE(webview_stack.current_url(), configuration.new_tab_url);
+ webview_stack.deleteLater();
}
}
@@ -35,48 +35,48 @@ private slots:
context("when openUrl is called without an open type");
it("replaces current tab url with newtab url") {
Configuration configuration;
- WebViewStack web_view_stack(&configuration);
- web_view_stack.open_url(QUrl("http://a.com"), OpenType::OpenUrl);
+ WebViewStack webview_stack(&configuration);
+ webview_stack.open_url(QUrl("http://a.com"), OpenType::OpenUrl);
- web_view_stack.open_url(QUrl(configuration.new_tab_url));
+ webview_stack.open_url(QUrl(configuration.new_tab_url));
- QCOMPARE(web_view_stack.count(), 1);
+ QCOMPARE(webview_stack.count(), 1);
std::vector<QUrl> urls = {QUrl(configuration.new_tab_url)};
- QCOMPARE(web_view_stack.urls(), urls);
- QCOMPARE(web_view_stack.current_web_view_index(), 0);
- QCOMPARE(web_view_stack.current_url(), configuration.new_tab_url);
+ QCOMPARE(webview_stack.urls(), urls);
+ QCOMPARE(webview_stack.current_webview_index(), 0);
+ QCOMPARE(webview_stack.current_url(), configuration.new_tab_url);
}
context("when creating a new webview with a url and focus is false");
it("opens the given url in background") {
Configuration configuration;
- WebViewStack web_view_stack(&configuration);
+ WebViewStack webview_stack(&configuration);
- web_view_stack.open_url(QUrl("https://duckduckgo.com"),
- OpenType::OpenUrlInBgTab);
+ webview_stack.open_url(QUrl("https://duckduckgo.com"),
+ OpenType::OpenUrlInBgTab);
- QCOMPARE(web_view_stack.count(), 2);
+ QCOMPARE(webview_stack.count(), 2);
std::vector<QUrl> urls = {QUrl(configuration.new_tab_url),
QUrl("https://duckduckgo.com")};
- QCOMPARE(web_view_stack.urls(), urls);
- QCOMPARE(web_view_stack.current_web_view_index(), 0);
- QCOMPARE(web_view_stack.current_url(), configuration.new_tab_url);
+ QCOMPARE(webview_stack.urls(), urls);
+ QCOMPARE(webview_stack.current_webview_index(), 0);
+ QCOMPARE(webview_stack.current_url(), configuration.new_tab_url);
}
context("when creating a new webview with a url and focus is true");
it("opens the given url as current view") {
Configuration configuration;
- WebViewStack web_view_stack(&configuration);
+ WebViewStack webview_stack(&configuration);
- web_view_stack.open_url(QUrl("https://duckduckgo.com"),
- OpenType::OpenUrlInTab);
+ webview_stack.open_url(QUrl("https://duckduckgo.com"),
+ OpenType::OpenUrlInTab);
- QCOMPARE(web_view_stack.count(), 2);
+ QCOMPARE(webview_stack.count(), 2);
std::vector<QUrl> urls = {QUrl(configuration.new_tab_url),
QUrl("https://duckduckgo.com")};
- QCOMPARE(web_view_stack.urls(), urls);
- QCOMPARE(web_view_stack.current_web_view_index(), 1);
- QCOMPARE(web_view_stack.current_url(), QUrl("https://duckduckgo.com"));
+ QCOMPARE(webview_stack.urls(), urls);
+ QCOMPARE(webview_stack.current_webview_index(), 1);
+ QCOMPARE(webview_stack.current_url(), QUrl("https://duckduckgo.com"));
}
}
@@ -85,41 +85,41 @@ private slots:
context("- and there is only 1 tab");
it("does nothing") {
Configuration configuration;
- WebViewStack web_view_stack(&configuration);
+ WebViewStack webview_stack(&configuration);
- web_view_stack.next();
+ webview_stack.next();
- QCOMPARE(web_view_stack.current_web_view_index(), 0);
- QCOMPARE(web_view_stack.current_url(), configuration.new_tab_url);
+ QCOMPARE(webview_stack.current_webview_index(), 0);
+ QCOMPARE(webview_stack.current_url(), configuration.new_tab_url);
}
context("when nextWebView is called");
context("- and there are tabs after the current tab");
it("goes to the next tab") {
Configuration configuration;
- WebViewStack web_view_stack(&configuration);
- web_view_stack.open_url(QUrl("http://a1.com"), OpenType::OpenUrlInBgTab);
- web_view_stack.open_url(QUrl("http://a2.com"), OpenType::OpenUrlInBgTab);
+ WebViewStack webview_stack(&configuration);
+ webview_stack.open_url(QUrl("http://a1.com"), OpenType::OpenUrlInBgTab);
+ webview_stack.open_url(QUrl("http://a2.com"), OpenType::OpenUrlInBgTab);
- web_view_stack.next();
+ webview_stack.next();
- QCOMPARE(web_view_stack.current_web_view_index(), 1);
- QCOMPARE(web_view_stack.current_url(), QUrl("http://a1.com"));
+ QCOMPARE(webview_stack.current_webview_index(), 1);
+ QCOMPARE(webview_stack.current_url(), QUrl("http://a1.com"));
}
context("when nextWebView is called");
context("- and current tab is the last tab");
it("jumps to the first tab") {
Configuration configuration;
- WebViewStack web_view_stack(&configuration);
- web_view_stack.open_url(QUrl("http://a1.com"), OpenType::OpenUrlInBgTab);
- web_view_stack.open_url(QUrl("http://a2.com"), OpenType::OpenUrlInTab);
- QCOMPARE(web_view_stack.current_web_view_index(), 2);
+ WebViewStack webview_stack(&configuration);
+ webview_stack.open_url(QUrl("http://a1.com"), OpenType::OpenUrlInBgTab);
+ webview_stack.open_url(QUrl("http://a2.com"), OpenType::OpenUrlInTab);
+ QCOMPARE(webview_stack.current_webview_index(), 2);
- web_view_stack.next();
+ webview_stack.next();
- QCOMPARE(web_view_stack.current_web_view_index(), 0);
- QCOMPARE(web_view_stack.current_url(), configuration.new_tab_url);
+ QCOMPARE(webview_stack.current_webview_index(), 0);
+ QCOMPARE(webview_stack.current_url(), configuration.new_tab_url);
}
}
@@ -128,76 +128,76 @@ private slots:
context("- and there is only 1 tab");
it("does nothing") {
Configuration configuration;
- WebViewStack web_view_stack(&configuration);
+ WebViewStack webview_stack(&configuration);
- web_view_stack.previous();
+ webview_stack.previous();
- QCOMPARE(web_view_stack.current_web_view_index(), 0);
- QCOMPARE(web_view_stack.current_url(), configuration.new_tab_url);
+ QCOMPARE(webview_stack.current_webview_index(), 0);
+ QCOMPARE(webview_stack.current_url(), configuration.new_tab_url);
}
context("when previousWebView is called");
context("- and there are tabs before the current tab");
it("goes to the next tab") {
Configuration configuration;
- WebViewStack web_view_stack(&configuration);
- web_view_stack.open_url(QUrl("http://a1.com"), OpenType::OpenUrlInBgTab);
- web_view_stack.open_url(QUrl("http://a2.com"), OpenType::OpenUrlInTab);
- QCOMPARE(web_view_stack.current_web_view_index(), 2);
+ WebViewStack webview_stack(&configuration);
+ webview_stack.open_url(QUrl("http://a1.com"), OpenType::OpenUrlInBgTab);
+ webview_stack.open_url(QUrl("http://a2.com"), OpenType::OpenUrlInTab);
+ QCOMPARE(webview_stack.current_webview_index(), 2);
- web_view_stack.previous();
+ webview_stack.previous();
- QCOMPARE(web_view_stack.current_web_view_index(), 1);
- QCOMPARE(web_view_stack.current_url(), QUrl("http://a1.com"));
+ QCOMPARE(webview_stack.current_webview_index(), 1);
+ QCOMPARE(webview_stack.current_url(), QUrl("http://a1.com"));
}
context("when previousWebView is called");
context("- and current tab is the last tab");
it("jumps to the last tab") {
Configuration configuration;
- WebViewStack web_view_stack(&configuration);
- web_view_stack.open_url(QUrl("http://a1.com"), OpenType::OpenUrlInBgTab);
- web_view_stack.open_url(QUrl("http://a2.com"), OpenType::OpenUrlInBgTab);
+ WebViewStack webview_stack(&configuration);
+ webview_stack.open_url(QUrl("http://a1.com"), OpenType::OpenUrlInBgTab);
+ webview_stack.open_url(QUrl("http://a2.com"), OpenType::OpenUrlInBgTab);
- web_view_stack.previous();
+ webview_stack.previous();
- QCOMPARE(web_view_stack.current_web_view_index(), 2);
- QCOMPARE(web_view_stack.current_url(), QUrl("http://a2.com"));
+ QCOMPARE(webview_stack.current_webview_index(), 2);
+ QCOMPARE(webview_stack.current_url(), QUrl("http://a2.com"));
}
}
- void test_close_web_view() {
+ void test_close_webview() {
context("when closeWebView is called");
context("- with out of bounds index");
it("does nothing") {
Configuration configuration;
- WebViewStack web_view_stack(&configuration);
- web_view_stack.open_url(QUrl("https://a.com"), OpenType::OpenUrl);
+ WebViewStack webview_stack(&configuration);
+ webview_stack.open_url(QUrl("https://a.com"), OpenType::OpenUrl);
- web_view_stack.close(1);
+ webview_stack.close(1);
- QCOMPARE(web_view_stack.count(), 1);
- QCOMPARE(web_view_stack.urls(),
+ QCOMPARE(webview_stack.count(), 1);
+ QCOMPARE(webview_stack.urls(),
(std::vector<QUrl>{QUrl("https://a.com")}));
- QCOMPARE(web_view_stack.current_web_view_index(), 0);
- QCOMPARE(web_view_stack.current_url(), QUrl("https://a.com"));
+ QCOMPARE(webview_stack.current_webview_index(), 0);
+ QCOMPARE(webview_stack.current_url(), QUrl("https://a.com"));
}
context("when closeWebView is called");
context("- and there is only 1 tab");
it("closes the tab and opens empty tab in its place") {
Configuration configuration;
- WebViewStack web_view_stack(&configuration);
- web_view_stack.open_url(QUrl("https://a.com"), OpenType::OpenUrl);
- QCOMPARE(web_view_stack.count(), 1);
+ WebViewStack webview_stack(&configuration);
+ webview_stack.open_url(QUrl("https://a.com"), OpenType::OpenUrl);
+ QCOMPARE(webview_stack.count(), 1);
- web_view_stack.close(0);
+ webview_stack.close(0);
- QCOMPARE(web_view_stack.count(), 1);
- QCOMPARE(web_view_stack.urls(),
+ QCOMPARE(webview_stack.count(), 1);
+ QCOMPARE(webview_stack.urls(),
(std::vector<QUrl>{configuration.new_tab_url}));
- QCOMPARE(web_view_stack.current_web_view_index(), 0);
- QCOMPARE(web_view_stack.current_url(), configuration.new_tab_url);
+ QCOMPARE(webview_stack.current_webview_index(), 0);
+ QCOMPARE(webview_stack.current_url(), configuration.new_tab_url);
}
context("when closeWebView is called");
@@ -205,20 +205,20 @@ private slots:
context("- and there are some tabs after");
it("closes the tab and focuses the next tab") {
Configuration configuration;
- WebViewStack web_view_stack(&configuration);
- web_view_stack.open_url(QUrl("https://a1.com"), OpenType::OpenUrlInTab);
- web_view_stack.open_url(QUrl("https://a2.com"), OpenType::OpenUrlInBgTab);
- QCOMPARE(web_view_stack.count(), 3);
- QCOMPARE(web_view_stack.current_web_view_index(), 1);
+ WebViewStack webview_stack(&configuration);
+ webview_stack.open_url(QUrl("https://a1.com"), OpenType::OpenUrlInTab);
+ webview_stack.open_url(QUrl("https://a2.com"), OpenType::OpenUrlInBgTab);
+ QCOMPARE(webview_stack.count(), 3);
+ QCOMPARE(webview_stack.current_webview_index(), 1);
- web_view_stack.close(1);
+ webview_stack.close(1);
- QCOMPARE(web_view_stack.count(), 2);
- QCOMPARE(web_view_stack.urls(),
+ QCOMPARE(webview_stack.count(), 2);
+ QCOMPARE(webview_stack.urls(),
(std::vector<QUrl>{configuration.new_tab_url,
QUrl("https://a2.com")}));
- QCOMPARE(web_view_stack.current_web_view_index(), 1);
- QCOMPARE(web_view_stack.current_url(), QUrl("https://a2.com"));
+ QCOMPARE(webview_stack.current_webview_index(), 1);
+ QCOMPARE(webview_stack.current_url(), QUrl("https://a2.com"));
}
context("when closeWebView is called");
@@ -226,20 +226,20 @@ private slots:
context("- which is the last tab");
it("closes the tab and focusses previous tab") {
Configuration configuration;
- WebViewStack web_view_stack(&configuration);
- web_view_stack.open_url(QUrl("https://a1.com"), OpenType::OpenUrlInBgTab);
- web_view_stack.open_url(QUrl("https://a2.com"), OpenType::OpenUrlInTab);
- QCOMPARE(web_view_stack.count(), 3);
- QCOMPARE(web_view_stack.current_web_view_index(), 2);
+ WebViewStack webview_stack(&configuration);
+ webview_stack.open_url(QUrl("https://a1.com"), OpenType::OpenUrlInBgTab);
+ webview_stack.open_url(QUrl("https://a2.com"), OpenType::OpenUrlInTab);
+ QCOMPARE(webview_stack.count(), 3);
+ QCOMPARE(webview_stack.current_webview_index(), 2);
- web_view_stack.close(2);
+ webview_stack.close(2);
- QCOMPARE(web_view_stack.count(), 2);
- QCOMPARE(web_view_stack.urls(),
+ QCOMPARE(webview_stack.count(), 2);
+ QCOMPARE(webview_stack.urls(),
(std::vector<QUrl>{configuration.new_tab_url,
QUrl("https://a1.com")}));
- QCOMPARE(web_view_stack.current_web_view_index(), 1);
- QCOMPARE(web_view_stack.current_url(), QUrl("https://a1.com"));
+ QCOMPARE(webview_stack.current_webview_index(), 1);
+ QCOMPARE(webview_stack.current_url(), QUrl("https://a1.com"));
}
}
@@ -248,43 +248,43 @@ private slots:
context("- of type new tab");
it("opens a new web view and focusses it") {
Configuration configuration;
- WebViewStack web_view_stack(&configuration);
- web_view_stack.open_url(QUrl("https://a.com"), OpenType::OpenUrl);
- auto *webview = web_view_stack.findChild<WebView *>();
- QCOMPARE(web_view_stack.count(), 1);
+ WebViewStack webview_stack(&configuration);
+ webview_stack.open_url(QUrl("https://a.com"), OpenType::OpenUrl);
+ auto *webview = webview_stack.findChild<WebView *>();
+ QCOMPARE(webview_stack.count(), 1);
FakeNewWindowRequest window_request(
FakeNewWindowRequest::DestinationType::InNewTab, QRect(0, 0, 0, 0),
QUrl("https://new.com"), true);
emit webview->page()->newWindowRequested(window_request);
- QCOMPARE(web_view_stack.count(), 2);
+ QCOMPARE(webview_stack.count(), 2);
QCOMPARE(
- web_view_stack.urls(),
+ webview_stack.urls(),
(std::vector<QUrl>{QUrl("https://a.com"), QUrl("https://new.com")}));
- QCOMPARE(web_view_stack.current_web_view_index(), 1);
- QCOMPARE(web_view_stack.current_url(), QUrl("https://new.com"));
+ QCOMPARE(webview_stack.current_webview_index(), 1);
+ QCOMPARE(webview_stack.current_url(), QUrl("https://new.com"));
}
context("when webview emits a newWindowRequested signal");
context("- of type new background tab");
it("opens a new web view in the background") {
Configuration configuration;
- WebViewStack web_view_stack(&configuration);
- web_view_stack.open_url(QUrl("https://a.com"), OpenType::OpenUrl);
- auto *webview = web_view_stack.findChild<WebView *>();
+ WebViewStack webview_stack(&configuration);
+ webview_stack.open_url(QUrl("https://a.com"), OpenType::OpenUrl);
+ auto *webview = webview_stack.findChild<WebView *>();
FakeNewWindowRequest window_request(
FakeNewWindowRequest::DestinationType::InNewBackgroundTab,
QRect(0, 0, 0, 0), QUrl("https://new.com"), true);
emit webview->page()->newWindowRequested(window_request);
- QCOMPARE(web_view_stack.count(), 2);
+ QCOMPARE(webview_stack.count(), 2);
QCOMPARE(
- web_view_stack.urls(),
+ webview_stack.urls(),
(std::vector<QUrl>{QUrl("https://a.com"), QUrl("https://new.com")}));
- QCOMPARE(web_view_stack.current_web_view_index(), 0);
- QCOMPARE(web_view_stack.current_url(), QUrl("https://a.com"));
+ QCOMPARE(webview_stack.current_webview_index(), 0);
+ QCOMPARE(webview_stack.current_url(), QUrl("https://a.com"));
}
}
};