testapp: Use methods of gl.Context rather than package-level OpenGL calls.
The package-level OpenGL calls in golang.org/x/mobile/gl were removed. This change fixes testapp to use their replacement. This change also moves the location of the test taps to be further away from the top of the screen. On my phone (running L), a tap at 50,60 is opens the draggy menu thing that Android has and the running app doesn't see it (which causes the test to not complete). Change-Id: I679c9b61919a332f9b4a53e0950ff96f6aefbbbb Reviewed-on: https://go-review.googlesource.com/15050 Reviewed-by: David Crawshaw <crawshaw@golang.org>
This commit is contained in:
parent
80ead7f4f8
commit
c846a131a8
@ -154,14 +154,14 @@ func TestAndroidApp(t *testing.T) {
|
||||
var x, y int
|
||||
var ty string
|
||||
|
||||
tap(t, 50, 60)
|
||||
tap(t, 50, 260)
|
||||
comm.Recv("touch", &ty, &x, &y)
|
||||
if ty != "begin" || x != 50 || y != 60 {
|
||||
t.Errorf("want touch begin(50, 60), got %s(%d,%d)", ty, x, y)
|
||||
if ty != "begin" || x != 50 || y != 260 {
|
||||
t.Errorf("want touch begin(50, 260), got %s(%d,%d)", ty, x, y)
|
||||
}
|
||||
comm.Recv("touch", &ty, &x, &y)
|
||||
if ty != "end" || x != 50 || y != 60 {
|
||||
t.Errorf("want touch end(50, 60), got %s(%d,%d)", ty, x, y)
|
||||
if ty != "end" || x != 50 || y != 260 {
|
||||
t.Errorf("want touch end(50, 260), got %s(%d,%d)", ty, x, y)
|
||||
}
|
||||
|
||||
comm.Recv("paint", &color)
|
||||
@ -175,7 +175,7 @@ func TestAndroidApp(t *testing.T) {
|
||||
t.Errorf("want orientation %d, got %d", want, orientation)
|
||||
}
|
||||
|
||||
tap(t, 50, 60)
|
||||
tap(t, 50, 260)
|
||||
comm.Recv("touch", &ty, &x, &y) // touch begin
|
||||
comm.Recv("touch", &ty, &x, &y) // touch end
|
||||
comm.Recv("paint", &color)
|
||||
|
@ -22,6 +22,11 @@ import (
|
||||
|
||||
func main() {
|
||||
app.Main(func(a app.App) {
|
||||
var (
|
||||
glctx gl.Context
|
||||
visible bool
|
||||
)
|
||||
|
||||
addr := "127.0.0.1:" + apptest.Port
|
||||
log.Printf("addr: %s", addr)
|
||||
|
||||
@ -49,19 +54,24 @@ func main() {
|
||||
case lifecycle.CrossOn:
|
||||
comm.Send("lifecycle_visible")
|
||||
sendPainting = true
|
||||
visible = true
|
||||
glctx, _ = e.DrawContext.(gl.Context)
|
||||
case lifecycle.CrossOff:
|
||||
comm.Send("lifecycle_not_visible")
|
||||
visible = false
|
||||
}
|
||||
case size.Event:
|
||||
comm.Send("size", e.PixelsPerPt, e.Orientation)
|
||||
case paint.Event:
|
||||
if color == "red" {
|
||||
gl.ClearColor(1, 0, 0, 1)
|
||||
} else {
|
||||
gl.ClearColor(0, 1, 0, 1)
|
||||
if visible {
|
||||
if color == "red" {
|
||||
glctx.ClearColor(1, 0, 0, 1)
|
||||
} else {
|
||||
glctx.ClearColor(0, 1, 0, 1)
|
||||
}
|
||||
glctx.Clear(gl.COLOR_BUFFER_BIT)
|
||||
a.Publish()
|
||||
}
|
||||
gl.Clear(gl.COLOR_BUFFER_BIT)
|
||||
a.Publish()
|
||||
if sendPainting {
|
||||
comm.Send("paint", color)
|
||||
sendPainting = false
|
||||
@ -75,8 +85,9 @@ func main() {
|
||||
color = "red"
|
||||
}
|
||||
sendPainting = true
|
||||
// Send a paint event so the screen gets redrawn.
|
||||
a.Send(paint.Event{})
|
||||
}
|
||||
// TODO: send our own paint Event??
|
||||
}
|
||||
}
|
||||
})
|
||||
|
Loading…
x
Reference in New Issue
Block a user