aboutsummaryrefslogtreecommitdiff
path: root/spec/InputMediatorSpec.cpp
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-03-18 21:19:28 +0530
committerAkshay Nair <phenax5@gmail.com>2025-03-18 21:19:47 +0530
commit4c762b2516bc664293c2aec072074f1e34dda8c3 (patch)
treeebe441f7af8c1f4c49f04630538312d55f18f63b /spec/InputMediatorSpec.cpp
parent056b0b16947ac19a0c425aa9d2ff8f589378d3bc (diff)
downloadnull-browser-4c762b2516bc664293c2aec072074f1e34dda8c3.tar.gz
null-browser-4c762b2516bc664293c2aec072074f1e34dda8c3.zip
Remove all the ui bits because screw it, lets unix a bit more
Diffstat (limited to '')
-rw-r--r--spec/InputMediatorSpec.cpp158
1 files changed, 0 insertions, 158 deletions
diff --git a/spec/InputMediatorSpec.cpp b/spec/InputMediatorSpec.cpp
index abc2232..b48b008 100644
--- a/spec/InputMediatorSpec.cpp
+++ b/spec/InputMediatorSpec.cpp
@@ -1,170 +1,12 @@
#include "InputMediator.hpp"
#include "LuaRuntime.hpp"
#include "testUtils.h"
-#include "widgets/InputLine.hpp"
#include "widgets/WebViewStack.hpp"
class InputMediatorSpec : public QObject {
Q_OBJECT
private slots:
- void testInputTypes() {
- context("when showCommandInput is called");
- it("shows url input with default command") {
- InputLine inputLine;
- Configuration configuration;
- WebViewStack webViewStack(&configuration);
- auto luaRuntime = LuaRuntime::instance();
- InputMediator inputMediator(&inputLine, &webViewStack, luaRuntime);
- QCOMPARE(inputLine.isHidden(), true);
-
- inputMediator.showCommandInput("open");
-
- QCOMPARE(inputLine.isHidden(), false);
- QCOMPARE(inputLine.prompt(), "[exec]");
- QCOMPARE(inputLine.getInputText(), "open");
- }
-
- context("when showURLInput is called");
- it("shows url input with default url") {
- InputLine inputLine;
- Configuration configuration;
- WebViewStack webViewStack(&configuration);
- auto luaRuntime = LuaRuntime::instance();
- InputMediator inputMediator(&inputLine, &webViewStack, luaRuntime);
- QCOMPARE(inputLine.isHidden(), true);
-
- inputMediator.showURLInput("http://a.com");
-
- QCOMPARE(inputLine.isHidden(), false);
- QCOMPARE(inputLine.prompt(), "[url]");
- QCOMPARE(inputLine.getInputText(), "http://a.com");
- }
- }
-
- void testCommandEvaluationOpen() {
- context("when command open is executed");
- context("- without args");
- it("opens url input") {
- InputLine inputLine;
- Configuration configuration;
- WebViewStack webViewStack(&configuration);
- auto luaRuntime = LuaRuntime::instance();
- InputMediator inputMediator(&inputLine, &webViewStack, luaRuntime);
-
- inputMediator.showCommandInput();
- emit inputLine.submitted("open");
-
- QCOMPARE(inputLine.prompt(), "[url]");
- }
-
- context("when command open is executed");
- context("- with url as an arg");
- it("opens url in current tab") {
- InputLine inputLine;
- Configuration configuration;
- WebViewStack webViewStack(&configuration);
- auto luaRuntime = LuaRuntime::instance();
- InputMediator inputMediator(&inputLine, &webViewStack, luaRuntime);
-
- inputMediator.showCommandInput();
- emit inputLine.submitted("open http://a.com");
-
- std::vector<QUrl> urls = {QUrl("http://a.com")};
- QCOMPARE(webViewStack.urls(), urls);
- QCOMPARE(webViewStack.currentWebViewIndex(), 0);
- }
- }
-
- void testCommandEvaluationTabOpen() {
- context("when command tabopen is run");
- context("- without args");
- it("opens url in a new tab") {
- InputLine inputLine;
- Configuration configuration;
- WebViewStack webViewStack(&configuration);
- auto luaRuntime = LuaRuntime::instance();
- InputMediator inputMediator(&inputLine, &webViewStack, luaRuntime);
-
- inputMediator.showCommandInput();
- emit inputLine.submitted("tabopen");
-
- QCOMPARE(inputLine.prompt(), "[url]");
- }
-
- context("when command tabopen is executed");
- context("- with url as an arg");
- it("opens url in a new tab") {
- InputLine inputLine;
- Configuration configuration;
- WebViewStack webViewStack(&configuration);
- auto luaRuntime = LuaRuntime::instance();
- InputMediator inputMediator(&inputLine, &webViewStack, luaRuntime);
-
- inputMediator.showCommandInput();
- emit inputLine.submitted("tabopen http://a.com");
-
- std::vector<QUrl> urls = {QUrl(configuration.newTabUrl),
- QUrl("http://a.com")};
- QCOMPARE(webViewStack.urls(), urls);
- QCOMPARE(webViewStack.currentWebViewIndex(), 1);
- }
- }
-
- void testCommandEvaluationTabNextPrev() {
- context("when command tabnext is executed");
- it("jumps to next tab") {
- InputLine inputLine;
- Configuration configuration;
- WebViewStack webViewStack(&configuration);
- auto luaRuntime = LuaRuntime::instance();
- InputMediator inputMediator(&inputLine, &webViewStack, luaRuntime);
- webViewStack.openUrl(QUrl("https://a1.com"), OpenType::OpenUrl);
- webViewStack.openUrl(QUrl("https://a2.com"), OpenType::OpenUrlInTab);
- webViewStack.openUrl(QUrl("https://a2.com"), OpenType::OpenUrlInBgTab);
- QCOMPARE(webViewStack.currentWebViewIndex(), 1);
-
- inputMediator.showCommandInput();
- emit inputLine.submitted("tabnext");
-
- QCOMPARE(webViewStack.currentWebViewIndex(), 2);
- }
-
- context("when command tabprev is executed");
- it("jumps to previous tab") {
- InputLine inputLine;
- Configuration configuration;
- WebViewStack webViewStack(&configuration);
- auto luaRuntime = LuaRuntime::instance();
- InputMediator inputMediator(&inputLine, &webViewStack, luaRuntime);
- webViewStack.openUrl(QUrl("https://a1.com"), OpenType::OpenUrl);
- webViewStack.openUrl(QUrl("https://a2.com"), OpenType::OpenUrlInTab);
- webViewStack.openUrl(QUrl("https://a2.com"), OpenType::OpenUrlInBgTab);
- QCOMPARE(webViewStack.currentWebViewIndex(), 1);
-
- inputMediator.showCommandInput();
- emit inputLine.submitted("tabprev");
-
- QCOMPARE(webViewStack.currentWebViewIndex(), 0);
- }
- }
-
- void testHideInputLine() {
- context("when hideInputLine is called");
- it("hides input") {
- InputLine inputLine;
- Configuration configuration;
- WebViewStack webViewStack(&configuration);
- auto luaRuntime = LuaRuntime::instance();
- InputMediator inputMediator(&inputLine, &webViewStack, luaRuntime);
- inputMediator.showURLInput();
- QCOMPARE(inputLine.isHidden(), false);
-
- inputMediator.hideInputLine();
-
- QCOMPARE(inputLine.isHidden(), true);
- }
- }
};
QTEST_REGISTER(InputMediatorSpec)