Skip to content

Commit fd18e8d

Browse files
committed
go.mobile/gl/glutil: correct image size and switch to testpattern.png
LGTM=nigeltao R=nigeltao CC=golang-codereviews https://golang.org/cl/167910043
1 parent 897e5be commit fd18e8d

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

gl/glutil/glimage_test.go

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func TestImage(t *testing.T) {
2828
// 4. Copy GL texture back into system memory.
2929
// 5. Compare to a pre-computed image.
3030

31-
f, err := os.Open("../../testdata/gophercolor.png")
31+
f, err := os.Open("../../testdata/testpattern.png")
3232
if err != nil {
3333
t.Fatal(err)
3434
}
@@ -42,10 +42,10 @@ func TestImage(t *testing.T) {
4242
defer ctxGL.destroy()
4343

4444
const (
45-
pixW = 300
46-
pixH = 200
47-
ptW = geom.Pt(150)
48-
ptH = geom.Pt(100)
45+
pixW = 100
46+
pixH = 100
47+
ptW = geom.Pt(50)
48+
ptH = geom.Pt(50)
4949
)
5050
geom.PixelsPerPt = float32(pixW) / float32(ptW)
5151
geom.Width = ptW
@@ -68,14 +68,14 @@ func TestImage(t *testing.T) {
6868
gl.Viewport(0, 0, pixW, pixH)
6969

7070
m := NewImage(geom.Point{ptW, ptH})
71-
draw.Draw(m.RGBA, src.Bounds(), src, src.Bounds().Min, draw.Src)
71+
b := m.RGBA.Bounds()
72+
draw.Draw(m.RGBA, b, src, src.Bounds().Min, draw.Src)
7273
m.Upload()
73-
b := src.Bounds()
7474
b.Min.X += 10
7575
b.Max.Y /= 2
7676

77-
ptTopLeft := geom.Point{5, 30}
78-
ptBottomRight := geom.Point{120, 80}
77+
ptTopLeft := geom.Point{3, 15}
78+
ptBottomRight := geom.Point{48, 46}
7979
m.Draw(geom.Rectangle{ptTopLeft, ptBottomRight}, b)
8080

8181
// For unknown reasons, a windowless OpenGL context on darwin
@@ -103,7 +103,7 @@ func TestImage(t *testing.T) {
103103
drawCross(got, int(ptBottomRight.X.Px()), int(ptBottomRight.Y.Px()))
104104
drawCross(got, pixW-1, pixH-1)
105105

106-
const wantPath = "../../testdata/gopherwindow.png"
106+
const wantPath = "../../testdata/testpattern-window.png"
107107
f, err = os.Open(wantPath)
108108
if err != nil {
109109
t.Fatal(err)
@@ -122,7 +122,7 @@ func TestImage(t *testing.T) {
122122

123123
if !imageEq(got, want) {
124124
// Write out the image we got.
125-
f, err = ioutil.TempFile("", "gopherwindow-got")
125+
f, err = ioutil.TempFile("", "testpattern-window-got")
126126
if err != nil {
127127
t.Fatal(err)
128128
}

testdata/gopherwindow.png

-23.2 KB
Binary file not shown.

testdata/testpattern-window.png

6.43 KB
Loading

0 commit comments

Comments
 (0)