aboutsummaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorAkshay Nair <phenax5@gmail.com>2025-03-11 11:31:14 +0530
committerAkshay Nair <phenax5@gmail.com>2025-03-11 11:44:31 +0530
commit12d0ce37db7323e8efd56d6a698a98abcb8d680b (patch)
treeec2102d40326a332b2ecb976869585f81cba8574 /spec
parent971854bfefad4c644ac3d5f5d6003f24d551bf1d (diff)
downloadnull-browser-12d0ce37db7323e8efd56d6a698a98abcb8d680b.tar.gz
null-browser-12d0ce37db7323e8efd56d6a698a98abcb8d680b.zip
Add command+url adapter and switching
Diffstat (limited to '')
-rw-r--r--spec/CommandInputSpec.cpp104
-rw-r--r--spec/InputLineSpec.cpp104
2 files changed, 104 insertions, 104 deletions
diff --git a/spec/CommandInputSpec.cpp b/spec/CommandInputSpec.cpp
deleted file mode 100644
index e687f70..0000000
--- a/spec/CommandInputSpec.cpp
+++ /dev/null
@@ -1,104 +0,0 @@
-#include "testUtils.h"
-
-#include "widgets/CommandInput.hpp"
-
-class CommandInputSpec : public QObject {
- Q_OBJECT
-
-private slots:
- void testWithInitialInput() {
- context("when initialized with some text");
- it("sets the initial input text") {
- CommandInput inputWidget("Initial content", new QWidget());
-
- QCOMPARE(inputWidget.getInputCommand(), QString("Initial content"));
- }
- }
-
- void testInputUpdate() {
- context("when user types in input");
- it("updates input command") {
- CommandInput inputWidget("Initial content", new QWidget());
-
- auto input = inputWidget.findChild<QLineEdit *>();
- QTest::keyClicks(input, " updated");
-
- QCOMPARE(inputWidget.getInputCommand(),
- QString("Initial content updated"));
- }
-
- context("when setInputText is called");
- it("sets input command") {
- CommandInput inputWidget("Initial content", new QWidget());
-
- inputWidget.setInputText("New content");
-
- QCOMPARE(inputWidget.getInputCommand(), QString("New content"));
- }
- }
-
- void testSubmitSignalOnReturnKey() {
- context("when user hits return key");
- it("emits the submitted signal with the input command") {
- CommandInput inputWidget("Initial content", new QWidget());
- QSignalSpy submitSignal(&inputWidget, &CommandInput::submitted);
-
- auto input = inputWidget.findChild<QLineEdit *>();
- QTest::keyClicks(input, " updated");
- QTest::keyClick(&inputWidget, Qt::Key_Return);
-
- QCOMPARE(submitSignal.count(), 1);
- QCOMPARE(submitSignal.takeFirst().at(0).toString(),
- QString("Initial content updated"));
- }
- }
-
- void testCancelSignalOnEscapeKey() {
- context("when user hits escape key");
- it("emits 'cancelled' signal") {
- CommandInput inputWidget("Initial content", new QWidget());
- QSignalSpy cancelSignal(&inputWidget, &CommandInput::cancelled);
-
- auto input = inputWidget.findChild<QLineEdit *>();
- QTest::keyClick(&inputWidget, Qt::Key_Escape);
-
- QCOMPARE(cancelSignal.count(), 1);
- }
-
- context("when user hits ctrl+l key");
- it("emits 'cancelled' signal") {
- CommandInput inputWidget("Initial content", new QWidget());
- QSignalSpy cancelSignal(&inputWidget, &CommandInput::cancelled);
-
- auto input = inputWidget.findChild<QLineEdit *>();
- QTest::keyClick(&inputWidget, Qt::Key_L, Qt::ControlModifier);
-
- QCOMPARE(cancelSignal.count(), 1);
- }
- }
-
- void testSetFocus() {
- context("when setInputFocus is called with true");
- xit("focusses input field") {
- CommandInput inputWidget("Initial content", new QWidget());
-
- inputWidget.setInputFocus(true);
- QApplication::processEvents();
-
- QVERIFY(inputWidget.isInputFocussed());
- }
-
- context("when setInputFocus is called with false");
- xit("unfocusses input field") {
- CommandInput inputWidget("Initial content", new QWidget());
-
- inputWidget.setInputFocus(false);
- QApplication::processEvents();
-
- QVERIFY(!inputWidget.isInputFocussed());
- }
- }
-};
-
-QTEST_REGISTER(CommandInputSpec)
-#include "CommandInputSpec.moc"
diff --git a/spec/InputLineSpec.cpp b/spec/InputLineSpec.cpp
new file mode 100644
index 0000000..e4eb9a5
--- /dev/null
+++ b/spec/InputLineSpec.cpp
@@ -0,0 +1,104 @@
+#include "testUtils.h"
+
+#include "widgets/InputLine.hpp"
+
+class InputLineSpec : public QObject {
+ Q_OBJECT
+
+private slots:
+ void testWithInitialInput() {
+ context("when initialized with some text");
+ it("sets the initial input text") {
+ InputLine inputWidget("Initial content", new QWidget());
+
+ QCOMPARE(inputWidget.getInputCommand(), QString("Initial content"));
+ }
+ }
+
+ void testInputUpdate() {
+ context("when user types in input");
+ it("updates input command") {
+ InputLine inputWidget("Initial content", new QWidget());
+
+ auto input = inputWidget.findChild<QLineEdit *>();
+ QTest::keyClicks(input, " updated");
+
+ QCOMPARE(inputWidget.getInputCommand(),
+ QString("Initial content updated"));
+ }
+
+ context("when setInputText is called");
+ it("sets input command") {
+ InputLine inputWidget("Initial content", new QWidget());
+
+ inputWidget.setInputText("New content");
+
+ QCOMPARE(inputWidget.getInputCommand(), QString("New content"));
+ }
+ }
+
+ void testSubmitSignalOnReturnKey() {
+ context("when user hits return key");
+ it("emits the submitted signal with the input command") {
+ InputLine inputWidget("Initial content", new QWidget());
+ QSignalSpy submitSignal(&inputWidget, &InputLine::submitted);
+
+ auto input = inputWidget.findChild<QLineEdit *>();
+ QTest::keyClicks(input, " updated");
+ QTest::keyClick(&inputWidget, Qt::Key_Return);
+
+ QCOMPARE(submitSignal.count(), 1);
+ QCOMPARE(submitSignal.takeFirst().at(0).toString(),
+ QString("Initial content updated"));
+ }
+ }
+
+ void testCancelSignalOnEscapeKey() {
+ context("when user hits escape key");
+ it("emits 'cancelled' signal") {
+ InputLine inputWidget("Initial content", new QWidget());
+ QSignalSpy cancelSignal(&inputWidget, &InputLine::cancelled);
+
+ auto input = inputWidget.findChild<QLineEdit *>();
+ QTest::keyClick(&inputWidget, Qt::Key_Escape);
+
+ QCOMPARE(cancelSignal.count(), 1);
+ }
+
+ context("when user hits ctrl+l key");
+ it("emits 'cancelled' signal") {
+ InputLine inputWidget("Initial content", new QWidget());
+ QSignalSpy cancelSignal(&inputWidget, &InputLine::cancelled);
+
+ auto input = inputWidget.findChild<QLineEdit *>();
+ QTest::keyClick(&inputWidget, Qt::Key_L, Qt::ControlModifier);
+
+ QCOMPARE(cancelSignal.count(), 1);
+ }
+ }
+
+ void testSetFocus() {
+ context("when setInputFocus is called with true");
+ xit("focusses input field") {
+ InputLine inputWidget("Initial content", new QWidget());
+
+ inputWidget.setInputFocus(true);
+ QApplication::processEvents();
+
+ QVERIFY(inputWidget.isInputFocussed());
+ }
+
+ context("when setInputFocus is called with false");
+ xit("unfocusses input field") {
+ InputLine inputWidget("Initial content", new QWidget());
+
+ inputWidget.setInputFocus(false);
+ QApplication::processEvents();
+
+ QVERIFY(!inputWidget.isInputFocussed());
+ }
+ }
+};
+
+QTEST_REGISTER(InputLineSpec)
+#include "InputLineSpec.moc"