Commit Graph

808 Commits

Author SHA1 Message Date
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
Elias Naur b53c2a7c9d app/internal/window: introduce and use nilEGLDisplay
Updates gio#52

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-30 20:41:20 +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 6bbfe288aa .builds: remove go fmt test from freebsd image
There is no reason to run platform independent tests on FreeBSD.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-30 14:11:24 +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
Elias Naur 3425b25ecc app/internal: add FreeBSD support
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-30 14:01:02 +01:00
Elias Naur 1cc1fb1c72 app/internal/window: replace ppoll with poll
We're about to add FreeBSD where ppoll is not supported.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-30 13:44:59 +01:00
Elias Naur c131a7f423 .builds: remove existing $PATH from PATH settings
$PATH is not expanded anyway, and it's better to be explicit.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-30 11:49:44 +01:00
Elias Naur 7939f142bd .builds: remove unused path from PATH
It was left over from when the builds didn't use the distro version
of Go.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-30 11:41:24 +01:00
Elias Naur 6d9dccdbaa cmd,example: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-30 00:58:35 +01:00
Elias Naur 2e605f2dcb app: ensure the previous frame is complete before accepting another
It matters for end-to-end tests that rely on the window contents.

Before this change, tests had to wait for 2 extra frames. This change
ensures that the first completed FrameEvent.Frame call guarantees
the previous frame is complete.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-30 00:53:21 +01:00
Daniel Martí d31a129bf9 cmd/gogio: fix a couple of x11 e2e TODOs
First, pick a random display number between 1 and 100,000. The pool is
large enough that we don't need to think about collisions for now.

Second, wait for the X server to expose its socket for up to 1s, instead
of doing a single static sleep of 200ms. The average time we actually
need to sleep on my laptop is around 5ms, so this gives a noticeable
speed-up.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-10-30 00:35:47 +01:00
Elias Naur fe54f3df4e .builds: add xvfb package to the linux builder for X11 end-to-end test
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-29 20:04:47 +01:00
Daniel Martí cea8dc374b cmd/gogio: add the first end-to-end X11 test
Right now it's very similar to the JS test on Chrome. Like it, this one
just runs the "red.go" gio app, takes a screenshot, and expects to see
red.

It also supports the -headless flag; when true, Xvfb is used and it's
entirely headless and hidden. Otherwise, Xephyr is used and once can see
the test in action. If the tool isn't installed, the test is skipped.

We need to add xgb as a dependency, so that we can connect to the X
server and interact with it, like taking screenshots.

Finally, this is an initial version, and a number of TODOs are left for
a later time. They'll get fixed in follow-up patches.

While at it, start making all tests parallel, since the end-to-end tests
take about a second each and neither are very cpu-intensive.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-10-29 20:01:52 +01:00
Elias Naur b8edf2ee04 .builds: switch from fedora/latest to debian/testing
Fedora builds kept failing at package installation. See
~sircmpwn/builds.sr.ht#220.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-29 17:48:12 +01:00
Daniel Martí 95c47aba55 cmd/gogio: clarify the need for --use-gl=egl in the e2e tests
After some investigation, it turns out that both Alpine and Arch suffer
from the same bug - their packages completely lack SwiftShader.

The current workaround is still the best that we have right now. But at
least we can actually provide a good explanation why, and a TODO to
improve this once the issues filed with the distros are fixed.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-10-29 15:35:23 +01:00
Elias Naur 4793faeadd cmd,example: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-29 14:08:38 +01:00
Daniel Martí 4641607cd6 cmd/gogio: log chrome's console messages in TestJSOnChrome
For example, if the browser doesn't have webgl at all, the gio app will
fail to load. This will result in the screenshot being incorrect,
without an apparent reason:

	--- FAIL: TestJSOnChrome (0.89s)
	    js_test.go:122: got 0xffffffffffffffff at (5,5), want 0xffff00000000ffff
	    js_test.go:122: got 0xffffffffffffffff at (595,595), want 0xffff00000000ffff

The underlying webgl error was accessible if one added a sleep and ran
'go test -headless=false', allowing to open the console and see the
error messages.

Instead, capture them via chromedp and print them to the test's logger:

	--- FAIL: TestJSOnChrome (0.89s)
	    js_test.go:79: console log: "2019/10/29 12:41:07 app: webgl is not supported"
	    js_test.go:79: console warning: "exit code:", 1
	    js_test.go:122: got 0xffffffffffffffff at (5,5), want 0xffff00000000ffff
	    js_test.go:122: got 0xffffffffffffffff at (595,595), want 0xffff00000000ffff

JS Exceptions are a completely different mechanism, so they're not
covered by this patch. We can add them at a later time if needed.

While at it, update to the latest tagged version of chromedp.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-10-29 14:06:30 +01:00
Denis Bernard e834a78ab2 app/internal/window: X11 fix black window on Xephyr
On Xephyr, when fitst entering x11Window.loop(), syscall.Ppoll would
block forever while XPending() would still return a non zero value.
This commit refactors the loop so that XPending() gets called first,
then fallback to waiting in ppoll if there are no pending draw events.

This has the added benefit of reducing the number of calls to ppoll when
receiving a lot of events.

Signed-off-by: Denis Bernard <db047h@gmail.com>
2019-10-29 14:04:20 +01:00
Elias Naur 2eb233dda6 .builds: remove -v from a tar command
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-29 01:45:05 +01:00
Elias Naur b46206e60a cmd,example: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-29 01:38:16 +01:00
Elias Naur a7ae8b6e3d app/internal/window: move -Werror from LDFLAGS to CFLAGS
Discovered by the builders, yay:

+ gogio -target android ./kitchen
gogio: go build -ldflags=-w -s  -buildmode=c-shared -o /tmp/gogio-485830478/jni/arm64-v8a/libgio.so ./kitchen failed: go build gioui.org/app/internal/window: invalid flag in #cgo LDFLAGS: -Werror

(https://builds.sr.ht/~eliasnaur/job/101366)

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-29 01:35:39 +01:00
Elias Naur 9671406cdd .builds: combine curl and tar to avoid temporary files
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-29 01:20:38 +01:00
Elias Naur 48e0a5315d .builds: fix apple.yml again
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-28 22:40:45 +01:00
Elias Naur 3f66d34599 app/internal/window: (Wayland) handle EAGAIN from wl_display_flush
Fixes gio#50

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-28 22:36:08 +01:00
Elias Naur f353c8c780 .builds: fix apple.yml builder
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-28 22:15:45 +01:00
Elias Naur 754db8c3d7 .builds: add macOS+iOS builder
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-28 22:08:27 +01:00
Elias Naur 4ba6b1a20c example/go.*: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-28 22:05:47 +01:00
Elias Naur 7115b448e8 app/internal/window: don't use module imports in framework header
Using the module import syntax "@import UIKit" results in a complaint
from the compiler:

> warning: use of '@import' in framework header is discouraged,
> including this header requires -fmodules [-Watimport-in-framework-header]

Use the regular #include syntax instead.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-28 18:26:07 +01:00
Elias Naur a6e452d6d5 cmd/gogio: add -Werror to main.m build
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-28 18:24:27 +01:00
Elias Naur 439d3e652c app/internal: consolidate CFLAGS and move -Werror to #cgo directives
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-28 13:30:51 +01:00
Elias Naur ddba67cc90 example: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-28 11:47:49 +01:00
Elias Naur 4a26bdad5d cmd/gogio: build for iOS/macOS without -fmodules and -fobjc-arc
The `gogio` tool adds the `-fmodules -fobjc-arc` flags to the Cgo
C flags. Unfortunately, that masks problems where Cgo packages
accidentally didn't have the flags in their #cgo directives such
as package log.

Move the flags so they're only explicitly mentioned when `gogio`
invokes the host compiler to build the `main.m` shim.

Fix package log to include the missing flags.

While we're here, silence OpenGL ES deprecation warnings on iOS, just
as we do for macOS. The warnings are normally not visible because
the gogio tool suppress output from the go tool.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-28 11:40:53 +01:00
Daniel Martí a0692d74af cmd/gogio: improve the UX of the e2e tests
First, add a headless boolean flag that defaults to true. That way, one
can run 'go test -headless=false' to, for example, see how Chrome runs
the webassembly endtoend test.

Second, skip the Chrome test if the browser isn't installed.

While at it, run 'gofmt -s' on the package.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-10-27 21:31:53 +01:00
Elias Naur 8fab2f8cb1 .builds: add automatic testing script
Add fedora.yml for testing on linux and windows.

Add android.yml for testing `gogio -target android`.

Add a build badge to the README.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-27 19:12:50 +01:00
Elias Naur f4c6ec4fbe README.md: add sr.ht related documentation from gioui.org
Use https for the Unlicense URL and add one for MIT as well.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-27 16:29:36 +01:00
Elias Naur 3de204b8ef cmd/gogio/testdata: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-27 15:42:18 +01:00
Elias Naur a8e5e7a788 example: update gio version (X11 support!)
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-27 15:12:15 +01:00
Denis Bernard 547ff2e484 app/internal/window: x11 driver
This driver still lacks fling support and dp/sp configuration.

By default, linux builds will try to use the Wayland driver then
fallback to X11 if it fails. Drivers can be disabled by using either the
nowayland or nox11 build tags.

Signed-off-by: Denis Bernard <db047h@gmail.com>
2019-10-27 15:06:53 +01:00
Elias Naur ec672ca06a README.md: remove documentation and link to gioui.org
There is now a real website on gioui.org. Use that for documentation.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-26 21:43:49 +02:00
Denis Bernard b78d144119 app/internal/window: add needVSync() to eglDriver interface
This enables calling eglSwapInterval with an interval value of 0 or 1
on a per driver basis.

Signed-off-by: Denis Bernard <db047h@gmail.com>
2019-10-26 15:45:03 +02:00