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>
This commit is contained in:
Daniel Martí
2019-10-31 12:00:19 +00:00
committed by Elias Naur
parent b3d4da6229
commit f20c0cc0a6
2 changed files with 100 additions and 10 deletions
+54 -6
View File
@@ -25,7 +25,11 @@ func main() {
}
func loop(w *app.Window) error {
background := color.RGBA{R: 0xde, G: 0xad, B: 0xbe, A: 0xff}
topLeft := color.RGBA{R: 0xde, G: 0xad, B: 0xbe, A: 0xff}
topRight := color.RGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}
botLeft := color.RGBA{R: 0x00, G: 0x00, B: 0x00, A: 0xff}
botRight := color.RGBA{R: 0x00, G: 0x00, B: 0x00, A: 0x80}
ops := new(op.Ops)
for {
e := <-w.Events()
@@ -34,11 +38,55 @@ func loop(w *app.Window) error {
return e.Err
case system.FrameEvent:
ops.Reset()
paint.ColorOp{Color: background}.Add(ops)
paint.PaintOp{Rect: f32.Rectangle{Max: f32.Point{
X: float32(e.Size.X),
Y: float32(e.Size.Y),
}}}.Add(ops)
paint.ColorOp{Color: topLeft}.Add(ops)
paint.PaintOp{Rect: f32.Rectangle{
Min: f32.Point{
X: 0,
Y: 0,
},
Max: f32.Point{
X: float32(e.Size.X)/2,
Y: float32(e.Size.Y)/2,
},
}}.Add(ops)
paint.ColorOp{Color: topRight}.Add(ops)
paint.PaintOp{Rect: f32.Rectangle{
Min: f32.Point{
X: float32(e.Size.X)/2,
Y: 0,
},
Max: f32.Point{
X: float32(e.Size.X),
Y: float32(e.Size.Y)/2,
},
}}.Add(ops)
paint.ColorOp{Color: botLeft}.Add(ops)
paint.PaintOp{Rect: f32.Rectangle{
Min: f32.Point{
X: 0,
Y: float32(e.Size.Y)/2,
},
Max: f32.Point{
X: float32(e.Size.X)/2,
Y: float32(e.Size.Y),
},
}}.Add(ops)
paint.ColorOp{Color: botRight}.Add(ops)
paint.PaintOp{Rect: f32.Rectangle{
Min: f32.Point{
X: float32(e.Size.X)/2,
Y: float32(e.Size.Y)/2,
},
Max: f32.Point{
X: float32(e.Size.X),
Y: float32(e.Size.Y),
},
}}.Add(ops)
e.Frame(ops)
}
}