summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThomas Buckley-Houston <tom@tombh.co.uk>2018-11-09 17:17:35 +0900
committerThomas Buckley-Houston <tom@tombh.co.uk>2019-06-24 09:12:11 +0300
commiteae72e94a635958876e4c115978fc6b39caf2609 (patch)
treed1d2a397fba5c9b768428b132715605955b1c898
parente03923394c5697c89cb2fee8dd218b561b9ab292 (diff)
Adds some Vim-specific integration tests
-rw-r--r--interfacer/src/browsh/frame_builder.go2
-rw-r--r--interfacer/src/browsh/input_box.go2
-rw-r--r--interfacer/src/browsh/tab.go2
-rw-r--r--interfacer/src/browsh/ui.go6
-rw-r--r--interfacer/test/tty/setup.go3
-rw-r--r--interfacer/test/tty/tty_test.go2
-rw-r--r--interfacer/test/tty/vim_test.go51
7 files changed, 60 insertions, 8 deletions
diff --git a/interfacer/src/browsh/frame_builder.go b/interfacer/src/browsh/frame_builder.go
index 37f90ee..e85e869 100644
--- a/interfacer/src/browsh/frame_builder.go
+++ b/interfacer/src/browsh/frame_builder.go
@@ -312,7 +312,7 @@ func (f *frame) maybeFocusInputBox(x, y int) {
left := inputBox.X
right := inputBox.X + inputBox.Width
if x >= left && x < right && y >= top && y < bottom {
- urlBarFocus(false)
+ UrlBarFocus(false)
inputBox.isActive = true
activeInputBox = inputBox
}
diff --git a/interfacer/src/browsh/input_box.go b/interfacer/src/browsh/input_box.go
index 405096e..431297c 100644
--- a/interfacer/src/browsh/input_box.go
+++ b/interfacer/src/browsh/input_box.go
@@ -181,7 +181,7 @@ func (i *inputBox) handleEnterKey(modifier tcell.ModMask) {
} else {
sendMessageToWebExtension("/url_bar," + string(i.text))
}
- urlBarFocus(false)
+ UrlBarFocus(false)
}
if i.isMultiLine() && modifier != tcell.ModAlt {
i.cursorInsertRune([]rune("\n")[0])
diff --git a/interfacer/src/browsh/tab.go b/interfacer/src/browsh/tab.go
index 900b111..d59865b 100644
--- a/interfacer/src/browsh/tab.go
+++ b/interfacer/src/browsh/tab.go
@@ -141,7 +141,7 @@ func createNewEmptyTab() {
CurrentTab = tab
CurrentTab.frame.resetCells()
renderUI()
- urlBarFocus(true)
+ UrlBarFocus(true)
renderCurrentTabWindow()
}
diff --git a/interfacer/src/browsh/ui.go b/interfacer/src/browsh/ui.go
index 6e38a1e..e47d9c8 100644
--- a/interfacer/src/browsh/ui.go
+++ b/interfacer/src/browsh/ui.go
@@ -87,13 +87,13 @@ func renderURLBar() {
func urlBarFocusToggle() {
if urlInputBox.isActive {
- urlBarFocus(false)
+ UrlBarFocus(false)
} else {
- urlBarFocus(true)
+ UrlBarFocus(true)
}
}
-func urlBarFocus(on bool) {
+func UrlBarFocus(on bool) {
if !on {
activeInputBox = nil
urlInputBox.isActive = false
diff --git a/interfacer/test/tty/setup.go b/interfacer/test/tty/setup.go
index b5b0b01..876c4f1 100644
--- a/interfacer/test/tty/setup.go
+++ b/interfacer/test/tty/setup.go
@@ -15,6 +15,7 @@ import (
gomega "github.com/onsi/gomega"
"browsh/interfacer/src/browsh"
+
"github.com/spf13/viper"
)
@@ -144,7 +145,7 @@ func sleepUntilPageLoad(maxTime time.Duration) {
// GotoURL sends the browsh browser to the specified URL
func GotoURL(url string) {
- SpecialKey(tcell.KeyCtrlL)
+ browsh.UrlBarFocus(true)
Keyboard(url)
SpecialKey(tcell.KeyEnter)
WaitForPageLoad()
diff --git a/interfacer/test/tty/tty_test.go b/interfacer/test/tty/tty_test.go
index 8c620c4..417b860 100644
--- a/interfacer/test/tty/tty_test.go
+++ b/interfacer/test/tty/tty_test.go
@@ -8,7 +8,7 @@ import (
. "github.com/onsi/gomega"
)
-func TestIntegration(t *testing.T) {
+func TestMain(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Integration tests")
}
diff --git a/interfacer/test/tty/vim_test.go b/interfacer/test/tty/vim_test.go
new file mode 100644
index 0000000..3487a02
--- /dev/null
+++ b/interfacer/test/tty/vim_test.go
@@ -0,0 +1,51 @@
+package test
+
+import (
+ "testing"
+
+ . "github.com/onsi/ginkgo"
+ . "github.com/onsi/gomega"
+)
+
+func TestVim(t *testing.T) {
+ RegisterFailHandler(Fail)
+ RunSpecs(t, "Integration tests")
+}
+
+var _ = Describe("Vim tests", func() {
+ BeforeEach(func() {
+ GotoURL(testSiteURL + "/smorgasbord/")
+ })
+
+ It("should navigate to a new page by using a link hint", func() {
+ Expect("Another▄page").To(BeInFrameAt(12, 18))
+ Keyboard("f")
+ Keyboard("a")
+ Expect("Another").To(BeInFrameAt(0, 0))
+ })
+
+ It("should scroll the page by one line", func() {
+ Expect("[ˈsmœrɡɔsˌbuːɖ])▄is▄a").To(BeInFrameAt(12, 11))
+ Keyboard("j")
+ Expect("type▄of▄Scandinavian▄").To(BeInFrameAt(12, 11))
+ })
+
+ Describe("Tabs", func() {
+ BeforeEach(func() {
+ ensureOnlyOneTab()
+ })
+
+ It("should create a new tab", func() {
+ Keyboard("t")
+ Expect("New Tab").To(BeInFrameAt(21, 0))
+ })
+
+ It("should cycle to the next tab", func() {
+ Keyboard("t")
+ GotoURL(testSiteURL + "/smorgasbord/another.html")
+ Keyboard("gt")
+ URL := testSiteURL + "/smorgasbord/ "
+ Expect(URL).To(BeInFrameAt(0, 1))
+ })
+ })
+})