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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
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>
Some versions of eglplatform.h don't support the MESA_EGL_NO_X11_HEADER
define for cross-platform definitions of the EGL types. Remove the
define and use an explicit cast instead.
Fixes gio#46
Signed-off-by: Elias Naur <mail@eliasnaur.com>
Registering the font as a side effect of importing the gofont package
was too magic. Require an explicit Register call instead. As a side
effect, it is more clear which font is the default (the first one
registered).
Signed-off-by: Elias Naur <mail@eliasnaur.com>