Commit Graph

152 Commits

Author SHA1 Message Date
Elias Naur 84d4800a16 cmd/gogio: match Android window background with default Gio color
While launching an app on Android, the hard-coded theme is used for
the color. That color is by default black, and results in a jarring
transition to the actual app background.

The default Gio color is white, so use that for the theme background
as well.

This change will break for "dark mode" programs and similar.  A future
improvement would be to reflect the actual app background in the theme.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-24 15:59:30 +02:00
Elias Naur cf6e128d48 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-23 21:15:17 +02:00
Elias Naur 2b1935d657 cmd/gogio: include Android themes in .aar outputs
Not strictly necessary, but makes embedding a Gio Android Activity
easier; adding

	<activity android:name="org.gioui.GioActivity"
		android:theme="@style/Theme.GioApp"
		android:configChanges="orientation|keyboardHidden"
		android:windowSoftInputMode="adjustResize">
		<intent-filter>
			<action android:name="android.intent.action.MAIN" />
			<category android:name="android.intent.category.LAUNCHER" />
		</intent-filter>
	</activity>

should be enough.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-18 20:24:42 +02:00
Elias Naur 1a3bbd5d92 example,cmd: update gio
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-04-01 13:21:55 +02:00
Daniel Martí acfe91ec3e CI: add wine on Linux for the Windows e2e test
Installing it on Debian was enough, with the only wrinkle that
propagating -race won't work when we're cross-compiling, since
cross-compilation disables CGo by default.

For now, just skip the test in that edge case. If we want to use the
race detector on Windows in the future, we need to get a Windows CI
builder somehow.

Tested on my fork; see https://builds.sr.ht/~mvdan/job/164899.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-03-08 10:52:08 +01:00
Daniel Martí 49000ae4a3 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>
2020-03-05 09:49:02 +01:00
Daniel Martí 9bbeb92b61 cmd/gogio: reuse the test binary to call gogio in the e2e tests
We were using 'go run . <args>' before, which works fine, but does mean
re-linking a new binary and throwing it away at each invocation. Given
that the end-to-end tests don't do all that much work besides building
the tiny red.go app, this amount of extra work was noticeable.

We can obtain statistics for the JS sub-test, which used 'go run', via
the perflock and benchcmd tools:

	$ go test -c
	$ perflock -governorp% benchcmd EndToEnd/JS ./gogio.test -test.run=EndToEnd/JS

After capturing those numbers before and after the change, we can then
compare them with benchstat. The CPU cost of the subtest is halved:

	name         old time/op         new time/op         delta
	EndToEnd/JS          1.42s ± 2%          1.07s ± 3%  -25.04%  (p=0.008 n=5+5)

	name         old user-time/op    new user-time/op    delta
	EndToEnd/JS          1.46s ± 3%          0.75s ± 5%  -48.34%  (p=0.008 n=5+5)

	name         old sys-time/op     new sys-time/op     delta
	EndToEnd/JS          366ms ±13%          224ms ± 7%  -38.79%  (p=0.008 n=5+5)

An alternative here would have been to refactor main.go to allow being
called directly. However, that would have required a non-trivial
refactor, since flag parsing is done via globals. Given that the
TestMain method is asy and keeps the main function simple, we've
decided to avoid a refactor.

While at it, remove the sleep in the Android driver to wait for the app
to come up on screen. Since we retry screenshots now, we no longer need
a static sleep. On average, we still need one retry for the initial
screenshot, but that's just 100ms versus the old 500ms. The maximum wait
time is also 2s here, which should scale better for slower devices.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-03-02 17:34:59 +01:00
Daniel Martí b064899967 cmd/gogio: groundwork for Windows e2e tests on Wine
First, move from debian unstable to testing, since sway was promoted to
testing as of earlier this week.

Second, use the --sync option when using xdotool to move an X11 mouse.
This makes the command block until the mouse has finished moving to the
specified location, removing a potential race with the following
'xdotool click' command.

Third, deduplicate some logic into driverBase: tempDir to create a
temporary directory within a test, and needPrograms to skip a test if
the required programs aren't available.

Lastly, split the code that starts the X11 server into a method, so that
the future Wine e2e driver can reuse it. Since Wine is tightly coupled
with X11, we can reuse a good part of the code, including the X11 server
and the xdotool mechanisms.

We also add a TODO to perhaps improve the handling of the app's output
under each of the e2e test cases.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-03-02 10:29:17 +01:00
Elias Naur 48eb5c666c example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 16:17:27 +01:00
Elias Naur 3738aa43a8 example,cmd: bump gio version 2020-02-29 15:57:27 +01:00
Elias Naur c1048a3a54 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 13:03:20 +01:00
Elias Naur 0160bba020 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-29 10:53:20 +01:00
Elias Naur 330705a423 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-28 15:24:07 +01:00
Elias Naur 5ae68d2127 example, cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-28 09:59:34 +01:00
Elias Naur 27c77f1baf example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-27 21:56:17 +01:00
Daniel Martí f38dbfca54 cmd/gogio: introduce retries with backoff to the e2e tests
Right now, this was badly needed for the wayland subtest, as it seems
like waiting for a frame to be ready wasn't enough for the screenshot to
show what we want. In practice, even if the machine was idle, it could
sometimes take a few extra milliseconds for the app to first appear on
the display.

This was worse when the machine is under stress, which is often the case
with CI. For example, the command below showed a ~20% failure rate on my
laptop with four cores:

	go test -c -o test && stress ./test -test.run EndToEnd/Wayland

Add a generic withRetries helper function, which allows us to keep
trying some action up to a timeout, with sleeps in between that start at
100ms and keep doubling until 2s. The function also logs before each
sleep, in case the user is confused why their test is stuck for
potentially may seconds at once.

Refactor the wantColors function into a separate function that returns
an error, as we can no longer directly report errors via *testing.T. It
still reports all the mismatches at once, which is useful. It can now be
used on to pof withRetries with a thin wrapper.

While at it, make the X11 subtest use withRetries to wait for the X
server to be ready. It was using a simpler method with a fixed number of
static sleeps. It's now more consistent, and a bit better overall.

With the changes above, the 'stress' command from earlier can get past
100 runs on my laptop with no failures at all.

Finally, fix a rogue log.Fatal call I had somehow missed.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-02-10 18:31:53 +01:00
Elias Naur cad51f4d22 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-10 18:25:16 +01:00
Elias Naur 140888ec86 example/glfw: add example demonstrating GLFW integration
Updates gio#26

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-02-07 23:15:05 +01:00
Daniel Martí ed8a0c4909 cmd/gogio: extract endtoend driver base into a type
This type contains all the common bits, such as *testing.T, as well as
the channel and method used to wait for blocking until a frame is ready.

It also allows us to initialise this base separately from Start, which
keeps the exported method simpler to understand.

The base type is embedded into the specific driver types, so that the
code remains simple. While at it, start embedding *testing.T too, so
that we can write d.Fatalf instead of d.t.Fatalf. The drivers will only
have a small number of exported methods as per the interface, so it's
easy to keep those from colliding with the method set on T.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-02-06 08:15:32 +01:00
Daniel Martí 8d1e53cfa9 cmd/gogio: add the first Android end-to-end test
It passes the whole e2e test flow on my real device, a OnePlus 5 running
LineageOS 16.0 (Android 9).

I was also successful at running it against an x86-64 Android 8.0
emulator, but I'm not including any of that just yet. A patch later this
week will include a piece of code to set up and start an emulator, which
CI can then use to run the test.

Also stop requiring the screen dimensions to be enforced when running in
non-headless mode. An Android emulator can run at an arbitrary
resolution, and even in headless mode, but a real Android device will
have its own predefined resolution. Forcing the test user to set the
-headless=false flag to not get annoying "unexpected dimensions" errors
would be annoying.

That check doesn't really mean much, as our test app doesn't care about
the screen resolution. And we were only doing the check sometimes. Drop
it entirely, making the resolution parameters merely a hint so that we
can keep the drivers a bit more consistent.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-01-29 14:50:42 +01:00
Aaron Bieber ff6c798a28 app: Extend CI to build on OpenBSD now that golang.org/x/sys is updated.
I was able to get the Pipe2 syscall added for OpenBSD:
https://go.googlesource.com/sys/+/9fbb57f87de9ccfe3a99d4e3270ce8a926ebba4f

This also updates the dependencies to include the latest sys and gio.

I submitted a patch to the builder environment to include the xshare sets on
OpenBSD. Once that is in it will mean the "install_deps" block can be removed.

  https://lists.sr.ht/~sircmpwn/sr.ht-dev/patches/9640

Here is a link to a successful build: https://builds.sr.ht/~qbit/job/143004

Signed-off-by: Aaron Bieber <aaron@bolddaemon.com>
2020-01-28 17:21:01 +01:00
Daniel Martí 6819dea21c cmd/gogio: attempt to fix timeout failures on CI
I've seen a couple of "timed out waiting for a frame to be ready" errors
on CI in the past week. I think two seconds is a bit low, if the machine
in question is not very powerful or under stress - which is common for
CI environments.

Raise the timeout to 5s.

While at it, add some log lines to each e2e test, and mark waitForFrame
as a helper func, so that its errors show up at the caller's location.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-01-28 15:27:50 +01:00
Elias Naur 761ab68868 cmd/gogio: support newer NDKs
Newer Windows NDKs add the "x86_64" platform suffix like other
OS'es. Remove the special case.

Newer NDKs are also installed in "ndk/x.y.z" versioned directories
instead of in "ndk-bundle". Support that.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-01-27 17:34:43 +00:00
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