mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 17:35:36 +00:00
cmd/gogio: add clicks to the e2e tests
The test app now responds to mouse clicks; clicking on one of the four sections of the app flips it to red color until clicked again. Add a Click method to the TestDriver interface, and implement it in both of the current drivers. Unfortunately, I failed at implementing it in X11 with the xdg library, after a few wasted hours. Instead, start relying on more external tools which are simple to use and not heavy to install. Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
This commit is contained in:
@@ -15,6 +15,7 @@ import (
|
||||
"os/exec"
|
||||
"strings"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
"github.com/chromedp/cdproto/runtime"
|
||||
"github.com/chromedp/chromedp"
|
||||
@@ -118,6 +119,8 @@ func (d *JSTestDriver) Start(t_ *testing.T, path string, width, height int) (cle
|
||||
); err != nil {
|
||||
d.t.Fatal(err)
|
||||
}
|
||||
// TODO(mvdan): synchronize with the app instead
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
|
||||
return cleanups
|
||||
}
|
||||
@@ -136,6 +139,16 @@ func (d *JSTestDriver) Screenshot() image.Image {
|
||||
return img
|
||||
}
|
||||
|
||||
func (d *JSTestDriver) Click(x, y int) {
|
||||
if err := chromedp.Run(d.ctx,
|
||||
chromedp.MouseClickXY(float64(x), float64(y)),
|
||||
); err != nil {
|
||||
d.t.Fatal(err)
|
||||
}
|
||||
// TODO(mvdan): synchronize with the app instead
|
||||
time.Sleep(200 * time.Millisecond)
|
||||
}
|
||||
|
||||
func TestJS(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user