-
-
Notifications
You must be signed in to change notification settings - Fork 410
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed zoom bug by writing some tests. Also moved thigns around a lot.
- Loading branch information
Showing
11 changed files
with
247 additions
and
280 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,4 @@ build/ | |
*.log | ||
*.out | ||
blank.png | ||
stdin_forward | ||
xzoom/xzoom_debug | ||
interfacer/interfacer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,95 @@ | ||
package main | ||
|
||
import ( | ||
"github.com/nsf/termbox-go" | ||
. "github.com/onsi/ginkgo" | ||
. "github.com/onsi/gomega" | ||
"testing" | ||
) | ||
|
||
func TestMouseInput(t *testing.T) { | ||
RegisterFailHandler(Fail) | ||
RunSpecs(t, "Mouse Input Suite") | ||
} | ||
|
||
var _ = Describe("Mouse Input", func() { | ||
BeforeEach(func() { | ||
err := termbox.Init() | ||
if err != nil { | ||
panic(err) | ||
} | ||
initialise() | ||
hipWidth = 90 | ||
hipHeight = 30 | ||
setCurrentDesktopCoords() | ||
}) | ||
|
||
AfterEach(func(){ | ||
termbox.Close() | ||
}) | ||
|
||
Describe("Mouse position", func(){ | ||
It("Should work in the top left", func() { | ||
curev.MouseX = 30 | ||
curev.MouseY = 10 | ||
setCurrentDesktopCoords() | ||
Expect(roundedDesktopX).To(Equal(533)) | ||
Expect(roundedDesktopY).To(Equal(400)) | ||
}) | ||
It("Should work in the middle", func() { | ||
curev.MouseX = 45 | ||
curev.MouseY = 15 | ||
setCurrentDesktopCoords() | ||
Expect(roundedDesktopX).To(Equal(800)) | ||
Expect(roundedDesktopY).To(Equal(600)) | ||
}) | ||
It("Should work in the bottom right", func() { | ||
curev.MouseX = 60 | ||
curev.MouseY = 20 | ||
setCurrentDesktopCoords() | ||
Expect(roundedDesktopX).To(Equal(1067)) | ||
Expect(roundedDesktopY).To(Equal(800)) | ||
}) | ||
}) | ||
|
||
Describe("Zooming", func() { | ||
BeforeEach(func(){ | ||
curev.MouseX = 30 | ||
curev.MouseY = 10 | ||
setCurrentDesktopCoords() | ||
}) | ||
It("Should zoom in once", func() { | ||
Expect(getXGrab()).To(Equal(0)) | ||
Expect(getYGrab()).To(Equal(0)) | ||
Expect(roundedDesktopX).To(Equal(533)) | ||
Expect(roundedDesktopY).To(Equal(400)) | ||
zoom("in") | ||
setCurrentDesktopCoords() | ||
Expect(getXGrab()).To(Equal(266)) | ||
Expect(getYGrab()).To(Equal(200)) | ||
Expect(roundedDesktopX).To(Equal(533)) | ||
Expect(roundedDesktopY).To(Equal(400)) | ||
}) | ||
It("Should zoom in then out", func() { | ||
zoom("in") | ||
setCurrentDesktopCoords() | ||
zoom("out") | ||
zoom("out") | ||
setCurrentDesktopCoords() | ||
Expect(getXGrab()).To(Equal(0)) | ||
Expect(getYGrab()).To(Equal(0)) | ||
Expect(roundedDesktopX).To(Equal(533)) | ||
Expect(roundedDesktopY).To(Equal(400)) | ||
}) | ||
It("Should zoom near an edge without breaking out", func() { | ||
curev.MouseX = 0 | ||
curev.MouseY = 0 | ||
setCurrentDesktopCoords() | ||
zoom("in") | ||
Expect(getXGrab()).To(Equal(0)) | ||
Expect(getYGrab()).To(Equal(0)) | ||
Expect(roundedDesktopX).To(Equal(0)) | ||
Expect(roundedDesktopY).To(Equal(0)) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.