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>
To keep text legible on low DPI monitors, the number of pixels
per dp or sp is not is not allowed to go below minDensity. However,
a minimum density of 1.25 leads to too big text and widgets on a
baseline ~96 DPI monitor. Lower the minimum to 1.0, where text is still
legible.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
macOS and Windows already applies monitorScale to sp values. Wayland
didn't apply the monitorScale when font scale detection fails. Do that.
Run gofmt -s -w . as well.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
If creating a GPU instance fails for some reason, we need to
receive the incoming frame from the application before reporting
the error in a DestroyEvent. If we don't, the a deadlock will occur
where the app is waiting for FrameEvent.Frame to complete, while
the Window waits for the app the receive a DestroyEvent.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
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>
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>
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>
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>
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>
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>
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>