Commit Graph

129 Commits

Author SHA1 Message Date
Daniel Martí 170e86142c cmd/gogio: don't hang on some e2e test errors
For example, if the test app fails to start on wayland, we'd block
~forever (ten minutes) waiting for it to render its first frame.

We don't have a good solution right now. But at least we can use a
relatively short timeout, to help out the human who rightfully expects
a result within ten seconds.

While at it, remove a sway "get_seats" command, which was a leftover
from my debugging of what input devices are available when running
headless.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-01-13 13:36:51 +01:00
Elias Naur 0bfcac9734 cmd,example: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-12 00:48:31 +01:00
Elias Naur 31ebd9e811 cmd,example: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-04 00:32:36 +01:00
Elias Naur 1762e0c07b cmd,example: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 13:20:20 +01:00
Daniel Martí 5bddf66db7 cmd: update the chromedp version
It's a bugfix release, and we want some of the stability fixes in it.
Starting Chrome processes is more reliable now, for example.

See https://github.com/chromedp/chromedp/releases/tag/v0.5.2.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-12-02 11:01:17 +01:00
Greg Pomerantz 8321745de9 app/permission: add documentation and storage permissions
Storage permissions enables the Android permissions
READ_EXTERNAL_STORAGE and WRITE_EXTERNAL_STORAGE.
2019-11-26 12:29:00 +01:00
Daniel Martí 99d97d2ef5 cmd/gogio: remove an unnecessary wait in the js e2e test
We already wait for the app to render itself via the "frame ready"
stdout prints. Waiting for the canvas to be ready isn't really necessary
anymore. It helped us while we had to rely on sleeps, but that's no
longer the case.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-11-25 10:24:49 +01:00
Daniel Martí 726270ab2d cmd: remove js runtime workaround
The js/wasm bug meant that printing to stdout in the e2e app would crash
the runtime, so we couldn't synchronize with the app like in the other
drivers.

Now that the bug is fixed, we can do the same as the other drivers just
fine.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-11-24 20:01:38 +01:00
Elias Naur 6a2b5a8d3b example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-20 20:28:06 +01:00
Elias Naur 76c209b594 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-20 18:36:34 +01:00
Elias Naur 26f34a3331 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-18 15:05:12 +01:00
Elias Naur d8c9cb426c example/gophers: update gio version
gofmt -w -s . as well.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-09 19:46:10 +01:00
Elias Naur 294308d8aa example/gophers: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-08 22:22:41 +01:00
Elias Naur c4416ffbc4 example/gophers: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-08 18:04:56 +01:00
Elias Naur 508f615f0b example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-07 18:51:32 +01:00
Daniel Martí 6fedfaf3af cmd/gogio: start using testing.T.Cleanup
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>
2019-11-07 16:11:38 +01:00
Elias Naur e683b19b29 .builds: use Go 1.14 for the basic tests
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>
2019-11-06 18:35:44 +01:00
Elias Naur b0c29b5489 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-06 18:04:52 +01:00
Daniel Martí 6f860200b9 cmd/gogio: join all endtoend tests as subtests
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>
2019-11-06 18:03:51 +01:00
Elias Naur c3533c3f84 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-06 17:32:21 +01:00
Elias Naur 1438e504cc example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-05 18:25:27 +01:00
Elias Naur 4719d56f86 .builds: fix go fmt test and go fmt -w -s .
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-05 12:50:07 +01:00
Daniel Martí 4d7c89fec3 cmd/gogio: simplify the test -race setup
In an earlier commit, we made it possible to run the e2e tests with the
race detector enabled everywhere via GOFLAGS=-race go test.

However, that's not at all standard; most users will simply use 'go test
-race'. Moreover, having 'go test -race' run the test program with the
race detector, but not the e2e gio app, is a bit useless.

Instead, have the tests detect when they run with the race detector, and
enable the race detector in the test app too. As before, the JS test is
skipped whenever -race is used.

This also means we can test with -race in the same way in each of the
modules, which simplifies CI.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-11-04 22:21:21 +01:00
Elias Naur c2cab4505c example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-04 19:32:07 +01:00
Elias Naur 615840352e example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-04 19:11:32 +01:00
Elias Naur 513b19b2c5 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-04 18:47:18 +01:00
Elias Naur 1110ed1aed example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-04 16:40:09 +01:00
Elias Naur 90de8b6360 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-04 15:17:42 +01:00
Elias Naur 65146a5337 example/kitchen: add CheckBox example
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-04 00:42:02 +01:00
Daniel Martí ec0c2498a1 cmd/gogio: fix a couple of staticcheck positives
Spotted the javac one by chance when reading the code, so I ran the tool
and fixed another small bug while at it.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-11-04 00:09:40 +01:00
Daniel Martí 2a4829d857 cmd/gogio: support running e2e with and without -race
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>
2019-11-03 13:05:06 +01:00
Elias Naur cc4b407647 .build,cmd: add -race to test programs
It's not possible to set GOFLAGS=-race because some programs are
built for webassembly where -race is not supported.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-03 12:09:02 +01:00
Daniel Martí 12ce899bb5 cmd/gogio: first wayland end-to-end tests
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>
2019-11-02 18:12:46 +01:00
Elias Naur dde09b9d74 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-02 16:09:07 +01:00
Daniel Martí 97d13922dd cmd/gogio: remove sleeps in x11 e2e test
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>
2019-11-02 15:00:37 +01:00
Daniel Martí b8e996074b cmd/gogio: rip out cgo deps for x11
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>
2019-11-02 01:19:19 +01:00
Daniel Martí 41402ce524 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>
2019-11-01 22:24:26 +01:00
Greg Pomerantz af353822fa cmd/gogio: add permissions system for Android
Search for imports of the form gioui.org/app/permission/* and add
required permissions to AndroidManifest.xml.

Signed-off-by: Greg Pomerantz <gmp.gio@wow.st>
2019-11-01 18:58:13 +01:00
Greg Pomerantz 3cd633ee44 cmd/gogio: Android: include jar files from dependencies
On Android, in addition to adding jar files found in the source
directory of the program being compiled, cmd/gogio also searches
every dependency for jar files to include in the output APK.

Signed-off-by: Greg Pomerantz <gmp.gio@wow.st>
2019-11-01 17:59:49 +01:00
Daniel Martí 4e71f195ab cmd/gogio: start using layout.Flex in the e2e app
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>
2019-10-31 21:06:34 +01:00
Elias Naur 3a341a3daf cmd/gogio: add -tags nowayland to avoid Wayland in the X11 end-to-end test
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-31 20:57:36 +01:00
Elias Naur f9a3d35184 cmd/gogio/testdate: gofmt -s -w
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-31 14:31:55 +01:00
Elias Naur 34bbf59efa cmd/gogio: double sleep to ensure X11 output is available
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-31 14:24:34 +01:00
Daniel Martí f20c0cc0a6 cmd/gogio: add four colors to the e2e tests
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>
2019-10-31 14:06:05 +01:00
Daniel Martí b3d4da6229 cmd/gogio: start using a TestDriver e2e interface
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>
2019-10-30 23:10:49 +01:00
Elias Naur ff8879ddce example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-30 20:43:45 +01:00
Daniel Martí d6f5902c5e cmd/gogio: send all e2e logs to t.Logf
chromedp was defaulting to log.Printf, which is not good for tests.

The xgb and xgbutil logs were suppressed if -v wasn't given, but they
were sent straight to os.Stderr otherwise:

	=== RUN   TestX11
	=== PAUSE TestX11
	=== CONT  TestX11
	XGB: conn.go:47: Could not get authority info: EOF
	XGB: conn.go:48: Trying connection without authority info...
	--- PASS: TestX11 (0.87s)

Instead, direct their loggers to an io.Writer implementation that sends
its output to t.Logf:

	=== RUN   TestX11
	=== PAUSE TestX11
	=== CONT  TestX11
	    TestX11: x11_test.go:187: XGB: conn.go:47: Could not get authority info: EOF
	    TestX11: x11_test.go:187: XGB: conn.go:48: Trying connection without authority info...
	--- PASS: TestX11 (0.86s)

We do end up with duplicate log prefixes, but at least we don't write
straight to stderr, which will be a problem as we add more concurrent
tests.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-10-30 17:30:58 +01:00
Elias Naur dc7af8fba3 cmd/gogio: use a more difficult color for end-to-end tests
RGB 0xff0000 is too easy to get right by accident.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-30 14:56:37 +01:00
Elias Naur d74be30a90 cmd/gogio: ignore alpha in end-to-end tests
On FreeBSD the X11 test seems to succeed except for the alpha
value:

	--- FAIL: TestX11 (2.04s)
	    js_test.go:138: got 0xffff000000000000 at (5,5), want 0xffff00000000ffff
	    js_test.go:138: got 0xffff000000000000 at (595,595), want 0xffff00000000ffff
	FAIL

Ignore alpha values for now.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-30 14:45:05 +01:00
Elias Naur 3945302b4f example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-30 14:05:56 +01:00