diff options
| author | Akshay Nair <phenax5@gmail.com> | 2025-03-09 00:15:18 +0530 |
|---|---|---|
| committer | Akshay Nair <phenax5@gmail.com> | 2025-03-09 00:15:18 +0530 |
| commit | 319908623e47b4e73f9af4aa4369cb895bd8df8f (patch) | |
| tree | 86d40d633bf86b5bc70876c1044ac0e030524e96 /spec | |
| parent | 6d3ee55638164df6521a60b6392a26f855d5f924 (diff) | |
| download | null-browser-319908623e47b4e73f9af4aa4369cb895bd8df8f.tar.gz null-browser-319908623e47b4e73f9af4aa4369cb895bd8df8f.zip | |
Fix command input ui to fix to top
Diffstat (limited to '')
| -rw-r--r-- | spec/CommandInputSpec.cpp | 39 |
1 files changed, 36 insertions, 3 deletions
diff --git a/spec/CommandInputSpec.cpp b/spec/CommandInputSpec.cpp index 7d15f25..f6f7f3a 100644 --- a/spec/CommandInputSpec.cpp +++ b/spec/CommandInputSpec.cpp @@ -26,24 +26,57 @@ private slots: 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 spy(&inputWidget, &CommandInput::submitted); + QSignalSpy submitSignal(&inputWidget, &CommandInput::submitted); auto input = inputWidget.findChild<QLineEdit *>(); QTest::keyClicks(input, " updated"); QTest::keyClick(&inputWidget, Qt::Key_Return); - QCOMPARE(spy.count(), 1); - QCOMPARE(spy.takeFirst().at(0).toString(), + 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") { |
