Commit Graph

26 Commits

Author SHA1 Message Date
Egon Elbre 2affb6eaa4 cmd,example: fix uses of color.NRGBA
Signed-off-by: Egon Elbre <egonelbre@gmail.com>
2020-11-19 11:35:26 +01:00
Elias Naur dbc0796d02 cmd/gogio,cmd/gogio/testdata: update Gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-11-06 20:56:54 +01:00
Elias Naur bb8bb504d8 cmd,example: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-10 11:29:23 +02:00
Elias Naur 81a84d874b example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-06-09 23:03:36 +02:00
Gordon Klaus 9d2a6c48d8 io/pointer: add InputOp.Types to specify which types of events to receive
Signed-off-by: Gordon Klaus <gordon.klaus@gmail.com>
2020-06-03 15:29:12 +02:00
Elias Naur d8000880c3 example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-23 23:14:46 +02:00
Elias Naur 99080023e4 example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-19 10:16:25 +02:00
Elias Naur dc7a8fd9ea example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-17 19:52:17 +02:00
Daniel Martí 023e022255 cmd/gogio: make e2e test output consistent
Fix a long-standing TODO: instead of each sub-test handling its own
output separately, just make each expose its output via an io.Reader.
Then, the shared driverBase code can tell if any of the lines contain
the magic "gio frame ready" string.

Reduces the amount of code a bit, but most importantly, it keeps the "is
a frame ready?" logic in a single place.

In the future, this also enables us to do more with all the e2e test app
output consistently. For example, we might want to add a -debug flag to
always log output lines as they happen.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2020-05-10 20:32:57 +02:00
Elias Naur a1166e6652 example,cmd: bump gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2020-05-03 21:07:53 +02: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 1762e0c07b cmd,example: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-12-02 13:20:20 +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 26f34a3331 example,cmd: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-11-18 15:05:12 +01:00
Daniel Martí 97d13922dd cmd/gogio: remove sleeps in x11 e2e test
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>
2019-11-02 15:00:37 +01:00
Daniel Martí 41402ce524 cmd/gogio: add clicks to the e2e tests
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>
2019-11-01 22:24:26 +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 f9a3d35184 cmd/gogio/testdate: gofmt -s -w
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-31 14:31:55 +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
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 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 651e31f7e0 cmd/gogio: update gio version
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-10-12 15:42:47 +02:00
Elias Naur beaec661d2 op/paint: move paint package below the op package
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 16:55:47 +02:00
Elias Naur 8cf35a1f97 op: add package op for operations
Extract operation types from package ui into package op.

Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 16:55:47 +02:00
Elias Naur 962bc36dac apps,cmd: update to renamed gioui.org module
Signed-off-by: Elias Naur <mail@eliasnaur.com>
2019-09-30 12:41:29 +02:00
Daniel Martí 687ea833a3 cmd/gogio: add the first end-to-end test for js via chrome
This commit adds the first fully end-to-end test. It builds a very
simple Gio app, loads it on Chrome, and checks that it works.

To control Chrome, we use chromedp, a library in pure Go that takes care
of starting the browser and talking to it via the devtools protocol.

We add the test directly in the cmd module, since it mainly interacts
with the gogio tool, and also because the code might turn into some sort
of 'gogio test' command in the future. This does add chromedp and ui as
test dependencies to go.mod, but GOPROXY should allow a 'go get' of
gogio to not download their entire source code archives.

We don't replace ui with ../../ui in the go.mod, to ensure that testing
the cmd module works from anywhere without unintended differences.

The test app being used is inside a testdata directory, to ensure it's
not go-gettable, and that it doesn't otherwise affect the cmd module.

Finally, the test itself is pretty simple. The app just paints a red
background, and the test verifies that, once loaded, the background of
the browser viewport is indeed red.

The test does currently require Chrome or Chromium to be installed,
which is fine for now. It may also require a GPU, though I don't have a
headless machine to check for sure. The test uses Chrome in headless
mode though, so it doesn't open up any visible browser window.

All in all, the test succeeds in just over a second on my laptop with
Chromium 77.0.3865.75.

Signed-off-by: Daniel Martí <mvdan@mvdan.cc>
2019-09-23 21:23:31 +02:00