2018-04-06 15:16:15 +00:00
|
|
|
package test
|
2018-04-01 08:31:25 +00:00
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/gdamore/tcell"
|
|
|
|
. "github.com/onsi/ginkgo"
|
|
|
|
. "github.com/onsi/gomega"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestIntegration(t *testing.T) {
|
|
|
|
RegisterFailHandler(Fail)
|
|
|
|
RunSpecs(t, "Integration tests")
|
|
|
|
}
|
|
|
|
|
2018-04-06 15:16:15 +00:00
|
|
|
var _ = Describe("Showing a basic webpage", func() {
|
2018-04-01 08:31:25 +00:00
|
|
|
BeforeEach(func() {
|
2018-04-06 15:16:15 +00:00
|
|
|
GotoURL(testSiteURL + "/smorgasbord/")
|
2018-07-11 09:00:06 +00:00
|
|
|
})
|
2018-04-06 15:16:15 +00:00
|
|
|
|
|
|
|
Describe("Browser UI", func() {
|
2018-05-24 10:45:07 +00:00
|
|
|
It("should have the page title and current URL", func() {
|
2018-04-06 15:16:15 +00:00
|
|
|
Expect("Smörgåsbord").To(BeInFrameAt(0, 0))
|
|
|
|
URL := testSiteURL + "/smorgasbord/"
|
2018-05-24 10:45:07 +00:00
|
|
|
Expect(URL).To(BeInFrameAt(0, 1))
|
2018-04-06 15:16:15 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
Describe("Interaction", func() {
|
|
|
|
It("should navigate to a new page by using the URL bar", func() {
|
|
|
|
SpecialKey(tcell.KeyCtrlL)
|
|
|
|
Keyboard(testSiteURL + "/smorgasbord/another.html")
|
|
|
|
SpecialKey(tcell.KeyEnter)
|
|
|
|
Expect("Another").To(BeInFrameAt(0, 0))
|
|
|
|
})
|
2018-04-01 08:31:25 +00:00
|
|
|
|
2018-04-06 15:16:15 +00:00
|
|
|
It("should navigate to a new page by clicking a link", func() {
|
2018-06-04 09:02:15 +00:00
|
|
|
Expect("Another▄page").To(BeInFrameAt(12, 18))
|
|
|
|
mouseClick(12, 18)
|
2018-04-06 15:16:15 +00:00
|
|
|
Expect("Another").To(BeInFrameAt(0, 0))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("should scroll the page by one line", func() {
|
|
|
|
SpecialKey(tcell.KeyDown)
|
2018-04-18 13:11:04 +00:00
|
|
|
Expect("meal,▄originating▄in▄").To(BeInFrameAt(12, 11))
|
2018-04-06 15:16:15 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
It("should scroll the page by one page", func() {
|
|
|
|
SpecialKey(tcell.KeyPgDn)
|
2018-06-04 09:02:15 +00:00
|
|
|
Expect("continuing▄with▄a▄variety▄of▄fish").To(BeInFrameAt(12, 13))
|
2018-04-06 15:16:15 +00:00
|
|
|
})
|
2018-05-20 13:17:33 +00:00
|
|
|
|
|
|
|
Describe("Text Input", func() {
|
2018-06-02 10:47:37 +00:00
|
|
|
Describe("Single line", func() {
|
|
|
|
BeforeEach(func() {
|
|
|
|
SpecialKey(tcell.KeyDown)
|
|
|
|
SpecialKey(tcell.KeyDown)
|
2018-06-04 09:02:15 +00:00
|
|
|
simScreen.InjectMouse(12, 16, tcell.Button1, tcell.ModNone)
|
2018-06-02 10:47:37 +00:00
|
|
|
})
|
2018-05-20 13:17:33 +00:00
|
|
|
|
2018-06-02 10:47:37 +00:00
|
|
|
It("should have basic cursor movement", func() {
|
|
|
|
Keyboard("|||")
|
|
|
|
SpecialKey(tcell.KeyLeft)
|
|
|
|
Keyboard("2")
|
|
|
|
SpecialKey(tcell.KeyLeft)
|
|
|
|
SpecialKey(tcell.KeyLeft)
|
|
|
|
Keyboard("1")
|
2018-06-04 09:02:15 +00:00
|
|
|
Expect("|1|2|").To(BeInFrameAt(12, 16))
|
2018-06-02 10:47:37 +00:00
|
|
|
})
|
2018-05-20 13:17:33 +00:00
|
|
|
|
2018-06-02 10:47:37 +00:00
|
|
|
It("should scroll single line boxes on overflow", func() {
|
|
|
|
Keyboard("12345678901234567890")
|
2018-06-04 09:02:15 +00:00
|
|
|
Expect("45678901234567890").To(BeInFrameAt(12, 16))
|
2018-06-02 10:47:37 +00:00
|
|
|
})
|
2018-05-28 14:03:33 +00:00
|
|
|
|
2018-06-02 10:47:37 +00:00
|
|
|
It("should scroll overflowed boxes to the left and right", func() {
|
|
|
|
Keyboard("12345678901234567890")
|
|
|
|
for i := 0; i < 19; i++ {
|
|
|
|
SpecialKey(tcell.KeyLeft)
|
|
|
|
}
|
2018-06-04 09:02:15 +00:00
|
|
|
Expect("23456789012345678").To(BeInFrameAt(12, 16))
|
2018-06-02 10:47:37 +00:00
|
|
|
for i := 0; i < 19; i++ {
|
|
|
|
SpecialKey(tcell.KeyRight)
|
|
|
|
}
|
2018-06-04 09:02:15 +00:00
|
|
|
Expect("45678901234567890").To(BeInFrameAt(12, 16))
|
2018-06-02 10:47:37 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
It("should submit text into an input box", func() {
|
2018-06-04 09:02:15 +00:00
|
|
|
Expect("Unsubmitted").To(BeInFrameAt(12, 20))
|
2018-06-02 10:47:37 +00:00
|
|
|
Keyboard("Reverse Me!")
|
|
|
|
SpecialKey(tcell.KeyEnter)
|
2018-06-04 09:02:15 +00:00
|
|
|
Expect("!eM▄esreveR").To(BeInFrameAt(12, 20))
|
2018-06-02 10:47:37 +00:00
|
|
|
})
|
2018-05-28 14:03:33 +00:00
|
|
|
})
|
|
|
|
|
2018-06-02 10:47:37 +00:00
|
|
|
Describe("Multi line", func() {
|
|
|
|
BeforeEach(func() {
|
|
|
|
GotoURL(testSiteURL + "/smorgasbord/textarea.html")
|
|
|
|
mouseClick(2, 3)
|
|
|
|
})
|
|
|
|
|
|
|
|
It("should enter multiple lines of text", func() {
|
|
|
|
Keyboard(`So here is a lot of text that will hopefully split across lines`)
|
|
|
|
Expect("So here is a lot of").To(BeInFrameAt(1, 3))
|
|
|
|
Expect("text that will").To(BeInFrameAt(1, 4))
|
|
|
|
Expect("hopefully split across").To(BeInFrameAt(1, 5))
|
|
|
|
Expect("lines").To(BeInFrameAt(1, 6))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("should scroll multiple lines of text", func() {
|
|
|
|
Keyboard(`So here is a lot of text that will hopefully split across lines`)
|
|
|
|
SpecialKey(tcell.KeyEnter)
|
|
|
|
Keyboard(`And here is even more filler, it's endless!`)
|
2018-06-04 09:02:15 +00:00
|
|
|
Expect("filler, it's endless!").To(BeInFrameAt(1, 6))
|
2018-06-02 10:47:37 +00:00
|
|
|
for i := 1; i <= 6; i++ {
|
|
|
|
SpecialKey(tcell.KeyUp)
|
|
|
|
}
|
|
|
|
Expect("lines").To(BeInFrameAt(1, 6))
|
|
|
|
})
|
2018-05-20 13:17:33 +00:00
|
|
|
})
|
|
|
|
})
|
2018-05-24 10:45:07 +00:00
|
|
|
|
|
|
|
Describe("Tabs", func() {
|
|
|
|
BeforeEach(func() {
|
|
|
|
SpecialKey(tcell.KeyCtrlT)
|
|
|
|
})
|
|
|
|
|
|
|
|
AfterEach(func() {
|
2018-05-25 07:08:25 +00:00
|
|
|
ensureOnlyOneTab()
|
2018-05-24 10:45:07 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
It("should create a new tab", func() {
|
|
|
|
Expect("New Tab").To(BeInFrameAt(21, 0))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("should be able to goto a new URL", func() {
|
|
|
|
Keyboard(testSiteURL + "/smorgasbord/another.html")
|
|
|
|
SpecialKey(tcell.KeyEnter)
|
|
|
|
Expect("Another").To(BeInFrameAt(21, 0))
|
|
|
|
})
|
|
|
|
|
|
|
|
It("should cycle to the next tab", func() {
|
|
|
|
Expect(" ").To(BeInFrameAt(0, 1))
|
|
|
|
SpecialKey(tcell.KeyCtrlL)
|
2018-05-25 07:08:25 +00:00
|
|
|
GotoURL(testSiteURL + "/smorgasbord/another.html")
|
2018-05-24 10:45:07 +00:00
|
|
|
simScreen.InjectKey(9, 0, tcell.ModNone)
|
2018-05-25 07:08:25 +00:00
|
|
|
URL := testSiteURL + "/smorgasbord/ "
|
2018-05-24 10:45:07 +00:00
|
|
|
Expect(URL).To(BeInFrameAt(0, 1))
|
|
|
|
})
|
|
|
|
})
|
2018-04-06 15:16:15 +00:00
|
|
|
})
|
2018-04-01 08:31:25 +00:00
|
|
|
})
|
|
|
|
|
2018-04-06 15:16:15 +00:00
|
|
|
Describe("Rendering", func() {
|
2018-04-18 13:11:04 +00:00
|
|
|
It("should reset page scroll to zero on page load", func() {
|
|
|
|
SpecialKey(tcell.KeyPgDn)
|
2018-06-04 09:02:15 +00:00
|
|
|
Expect("continuing▄with▄a▄variety▄of▄fish").To(BeInFrameAt(12, 13))
|
2018-04-18 13:11:04 +00:00
|
|
|
GotoURL(testSiteURL + "/smorgasbord/another.html")
|
|
|
|
Expect("Another▄webpage").To(BeInFrameAt(1, 3))
|
|
|
|
})
|
|
|
|
|
2018-04-06 15:16:15 +00:00
|
|
|
It("should render dynamic content", func() {
|
2018-04-28 11:02:40 +00:00
|
|
|
var greens, pinks int
|
|
|
|
var colours [10][3]int32
|
|
|
|
for i := 0; i < 10; i++ {
|
|
|
|
colours[i] = GetFgColour(39, 3)
|
|
|
|
waitForNextFrame()
|
|
|
|
}
|
|
|
|
for i := 0; i < 10; i++ {
|
2018-07-11 09:00:06 +00:00
|
|
|
if colours[i] == [3]int32{0, 255, 255} {
|
|
|
|
greens++
|
|
|
|
}
|
|
|
|
if colours[i] == [3]int32{255, 0, 255} {
|
|
|
|
pinks++
|
|
|
|
}
|
2018-04-28 11:02:40 +00:00
|
|
|
}
|
|
|
|
Expect(greens).To(BeNumerically(">=", 1))
|
|
|
|
Expect(pinks).To(BeNumerically(">=", 1))
|
2018-04-06 15:16:15 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
It("should switch to monochrome mode", func() {
|
2018-04-28 11:02:40 +00:00
|
|
|
simScreen.InjectKey(tcell.KeyRune, 'm', tcell.ModAlt)
|
2018-04-06 15:16:15 +00:00
|
|
|
waitForNextFrame()
|
|
|
|
Expect([3]int32{0, 0, 0}).To(Equal(GetBgColour(0, 2)))
|
|
|
|
Expect([3]int32{255, 255, 255}).To(Equal(GetFgColour(12, 11)))
|
|
|
|
})
|
|
|
|
|
|
|
|
Describe("Text positioning", func() {
|
|
|
|
It("should position the left/right-aligned coloumns", func() {
|
2018-04-18 13:11:04 +00:00
|
|
|
Expect("Smörgåsbord▄(Swedish:").To(BeInFrameAt(12, 10))
|
|
|
|
Expect("The▄Swedish▄word").To(BeInFrameAt(42, 10))
|
2018-04-06 15:16:15 +00:00
|
|
|
})
|
2018-04-01 08:31:25 +00:00
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|