mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 17:35:36 +00:00
cmd/gogio: add the first Windows e2e test via Wine
Since Wine is heavily tied to X11, we build its end-to-end test driver on top of X11's. We use the same mechanism to start an X server, take screenshots, and issue clicks. Its only quirk is that it was difficult to get the screenshots to line up with Gio's window. The comments cover what we ended up with. The display dimensions are now part of driverBase, so that methods other than Start can also use them - this is necessary for the wine driver to crop screenshots. We also use a sleep for now; a comment explains why, and a TODO is left for future Dan to deal with. What we have now works, and I've spent enough hours on this patch as it is. Adding Wine to CI, and ensuring that the test passes there, is left for a follow-up patch. Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
This commit is contained in:
+12
-8
@@ -26,15 +26,15 @@ const appid = "localhost.gogio.endtoend"
|
||||
// tests on. None of its methods return any errors, as the errors are directly
|
||||
// reported to testing.T via methods like Fatal.
|
||||
type TestDriver interface {
|
||||
initBase(*testing.T)
|
||||
initBase(t *testing.T, width, height int)
|
||||
|
||||
// Start opens the Gio app found at path. The driver should attempt to
|
||||
// run the app with the given width and height, and the platform's
|
||||
// background should be white.
|
||||
// run the app with the base driver's width and height, and the
|
||||
// platform's background should be white.
|
||||
//
|
||||
// When the function returns, the gio app must be ready to use on the
|
||||
// platform, with its initial frame fully drawn.
|
||||
Start(path string, width, height int)
|
||||
Start(path string)
|
||||
|
||||
// Screenshot takes a screenshot of the Gio app on the platform.
|
||||
Screenshot() image.Image
|
||||
@@ -48,6 +48,8 @@ type TestDriver interface {
|
||||
type driverBase struct {
|
||||
*testing.T
|
||||
|
||||
width, height int
|
||||
|
||||
// TODO(mvdan): Make this lower-level, so that each driver can simply
|
||||
// send us each line of output from the app. That will let us
|
||||
// deduplicate some code, and also show app output as test logs in a
|
||||
@@ -55,8 +57,9 @@ type driverBase struct {
|
||||
frameNotifs chan bool
|
||||
}
|
||||
|
||||
func (d *driverBase) initBase(t *testing.T) {
|
||||
func (d *driverBase) initBase(t *testing.T, width, height int) {
|
||||
d.T = t
|
||||
d.width, d.height = width, height
|
||||
d.frameNotifs = make(chan bool, 1)
|
||||
}
|
||||
|
||||
@@ -76,6 +79,7 @@ func TestEndToEnd(t *testing.T) {
|
||||
{"Wayland", &WaylandTestDriver{}},
|
||||
{"JS", &JSTestDriver{}},
|
||||
{"Android", &AndroidTestDriver{}},
|
||||
{"Windows", &WineTestDriver{}},
|
||||
}
|
||||
|
||||
for _, subtest := range subtests {
|
||||
@@ -88,11 +92,11 @@ func TestEndToEnd(t *testing.T) {
|
||||
}
|
||||
|
||||
func runEndToEndTest(t *testing.T, driver TestDriver) {
|
||||
driver.initBase(t)
|
||||
|
||||
size := image.Point{X: 800, Y: 600}
|
||||
driver.initBase(t, size.X, size.Y)
|
||||
|
||||
t.Log("starting driver and gio app")
|
||||
driver.Start("testdata/red.go", size.X, size.Y)
|
||||
driver.Start("testdata/red.go")
|
||||
|
||||
beef := color.RGBA{R: 0xde, G: 0xad, B: 0xbe}
|
||||
white := color.RGBA{R: 0xff, G: 0xff, B: 0xff}
|
||||
|
||||
Reference in New Issue
Block a user