gobot.io/x/gobot@v1.16.0/drivers/spi/apa102_test.go (about) 1 package spi 2 3 import ( 4 "image/color" 5 "testing" 6 7 "gobot.io/x/gobot" 8 "gobot.io/x/gobot/gobottest" 9 ) 10 11 var _ gobot.Driver = (*APA102Driver)(nil) 12 13 func initTestDriver() *APA102Driver { 14 d := NewAPA102Driver(&TestConnector{}, 10, 31) 15 return d 16 } 17 18 func TestDriverStart(t *testing.T) { 19 d := initTestDriver() 20 gobottest.Assert(t, d.Start(), nil) 21 } 22 23 func TestDriverHalt(t *testing.T) { 24 d := initTestDriver() 25 d.Start() 26 gobottest.Assert(t, d.Halt(), nil) 27 } 28 29 func TestDriverLEDs(t *testing.T) { 30 d := initTestDriver() 31 d.Start() 32 33 d.SetRGBA(0, color.RGBA{255, 255, 255, 15}) 34 d.SetRGBA(1, color.RGBA{255, 255, 255, 15}) 35 d.SetRGBA(2, color.RGBA{255, 255, 255, 15}) 36 d.SetRGBA(3, color.RGBA{255, 255, 255, 15}) 37 38 gobottest.Assert(t, d.Draw(), nil) 39 }