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>
Before this change, Gio tries hard to come up with a reasonable UI scale
factor on desktop OSes derived from the physical dimensions and
resolution of connected monitors. Gio also attempts to detect the user
specified system UI scale and apply it.
However, all that is complex and misguided:
- The UI scale should not depend on whatever monitor is connected at
program startup - For multiple monitors, it's unclear which one to base
the scale off. - Applying both a monitor derived scale *and* the user
specified scale is wrong, because the user scale is relative to some
fixed scale, not Gio's derived scale. - With an automatic scale, Gio
does not respect user preference and will not have a similar scale to
other programs on the desktop.
Get rid of the the automatic UI scale detection and rely only on the
user scale.
Updates gio#53
Signed-off-by: Elias Naur <mail@eliasnaur.com>
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>
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>
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>
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>
As discussed in gio#53, Linux font scales conflate two settings: the fractional
UI scale and the user preference as a result of conditions such as impaired
vision. The former setting should apply to both dps and sps, while the latter
only to sps. However, with the assumption that more users presumable change the
font scale for the former reason rather than the latter, we should apply the
font scale to both dps and sps in Gio.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
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>
Determining the enabled state of a widget from whether its Clicked method has
been called only works for button-like widgets. For example, it's not clear a
Clicked method is appropriate for a CheckBox.
Remove the feature for now, and let's find a better design in the future.
As a nice side effect, we can now process events in Layout methods, so that
buttons react to user input even when Clicked is not called.
Signed-off-by: Elias Naur <mail@eliasnaur.com>
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>
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>