cmd/gogio: add gogio test for go import path

Signed-off-by: Walter Werner SCHNEIDER <contact@schnwalter.eu>
This commit is contained in:
Walter Werner SCHNEIDER
2020-11-26 20:05:54 +02:00
committed by Elias Naur
parent 9b54892cc4
commit 4f8150cd59
2 changed files with 16 additions and 10 deletions
+16 -10
View File
@@ -68,33 +68,39 @@ func TestEndToEnd(t *testing.T) {
t.Parallel() t.Parallel()
const (
testdataWithGoImportPkgPath = "gioui.org/cmd/gogio/testdata"
testdataWithRelativePkgPath = "testdata/testdata.go"
)
// Keep this list local, to not reuse TestDriver objects. // Keep this list local, to not reuse TestDriver objects.
subtests := []struct { subtests := []struct {
name string name string
driver TestDriver driver TestDriver
pkgPath string
}{ }{
{"X11", &X11TestDriver{}}, {"X11 using go import path", &X11TestDriver{}, testdataWithGoImportPkgPath},
{"Wayland", &WaylandTestDriver{}}, {"X11", &X11TestDriver{}, testdataWithRelativePkgPath},
{"JS", &JSTestDriver{}}, {"Wayland", &WaylandTestDriver{}, testdataWithRelativePkgPath},
{"Android", &AndroidTestDriver{}}, {"JS", &JSTestDriver{}, testdataWithRelativePkgPath},
{"Windows", &WineTestDriver{}}, {"Android", &AndroidTestDriver{}, testdataWithRelativePkgPath},
{"Windows", &WineTestDriver{}, testdataWithRelativePkgPath},
} }
for _, subtest := range subtests { for _, subtest := range subtests {
t.Run(subtest.name, func(t *testing.T) { t.Run(subtest.name, func(t *testing.T) {
subtest := subtest // copy the changing loop variable subtest := subtest // copy the changing loop variable
t.Parallel() t.Parallel()
runEndToEndTest(t, subtest.driver) runEndToEndTest(t, subtest.driver, subtest.pkgPath)
}) })
} }
} }
func runEndToEndTest(t *testing.T, driver TestDriver) { func runEndToEndTest(t *testing.T, driver TestDriver, pkgPath string) {
size := image.Point{X: 800, Y: 600} size := image.Point{X: 800, Y: 600}
driver.initBase(t, size.X, size.Y) driver.initBase(t, size.X, size.Y)
t.Log("starting driver and gio app") t.Log("starting driver and gio app")
driver.Start("testdata/red.go") driver.Start(pkgPath)
beef := color.NRGBA{R: 0xde, G: 0xad, B: 0xbe, A: 0xff} beef := color.NRGBA{R: 0xde, G: 0xad, B: 0xbe, A: 0xff}
white := color.NRGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff} white := color.NRGBA{R: 0xff, G: 0xff, B: 0xff, A: 0xff}