Now that we use tip due to breaking changes in Go's JS APIs, let's
replace our hacky cleanup list code with 1.14's upcoming
testing.T.Cleanup.
Adding more deliberate uses of tip would ususally be best avoided, but
these will only affect developers working on gio's tests, not regular
users of gio.
While at it, remove some debug t.Logf calls I forgot to remove.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
WebAssembly builds require Go 1.14 since the breaking change in Go,
golang.org/cl/203600.
gofmt -w -s . as well.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This means we can deduplicate some of the logic, and keep it all in one
place.
Start expanding the logic too; the tests are slow, so they should be
skipped on 'go test -short'. The ones we have so far all run in a matter
of seconds on an average laptop today, but future tests will probably
require heavier work like wine or kvm.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Right now, we can only run the e2e gio app with -race, not without
-race, because the flag is hard-coded in the tests.
The reason for this change was that 'GOFLAGS=-race go test' would fail
with the JS test, since js/wasm doesn't support the race detector. Fix
that by skipping the JS test when -race is used.
Now, we can run multiple levels of -race:
go test # no -race at all
go test -race # -race for the tests, not the e2e gio app
GOFLAGS=-race go test # -race for everything (best-effort)
To detect the race detector being on, we use a file with a build tag.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Clicking doesn't quite work yet, but everything else does. We use a
custom sway config to ensure that it's a minimalist setup with no bar or
borders, like the other drivers.
The generic test now adapts to the window's real size when running in
non-headless mode, since tiling window managers resize some drivers like
sway. The default headless mode still expects the exact size that we
specify, as no real windows are at play.
While at it, clean up some now unused code from the x11 file.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
We can instead synchronize with the gio app via stdout. We need three
states, since we need to first invalidate a frame and then print when
the next frame is drawn.
This is not happening on the JS test yet, because stdout printing
crashes in that case. See the comment.
This change should make the X11 test a bit faster on fast machines,
while making it more stable in small or headless machines like CI.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Instead rely on more tiny standalone tools. In this case, scrot lets us
take png screenshots, and works well.
On the plus side, we remove some large X Go deps, and we don't need
nearly as much code.
While at it, skip if any of the tools are missing, and actually defer
the cleanup funcs so that they run when we fail the test early.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
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 vastly simplifies our code, and saves us the ugly math.
While at it, establish that a TestDriver must have a white background,
which is already satisfied by both existing implementations.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
The e2e app now splits the window into four rectangles and paints them
differently.
The first advantage is that we now test that we see the entire Gio app.
Before, with a solid background color, we could be seeing a small part
of the window and we wouldn't tell the difference.
The second advantage is that we test more colors. In particular, the
fourth color includes a different alpha value, which renders the same on
JS and X11.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
Now we implement the "red background" end-to-end test exactly once.
While at it, start using a 800x600 window size, which is a bit more
realistic than 600x600, and will catch if we got either dimension wrong.
The interface only has two methods for now, but it will be expanded in
the future to also support input such as clicks.
Keeping state in the test driver, such as a context or a connection, is
a bit awkward but necessary so that we don't have to repeat arguments
over and over. The same applies to testing.T.
Signed-off-by: Daniel Martí <mvdan@mvdan.cc>