hybridgroup.gobot/platforms/gpio/led_driver_test.go

53 lines
1007 B
Go
Raw Normal View History

2014-04-28 10:34:16 +08:00
package gpio
import (
2014-06-13 11:08:06 +08:00
"testing"
2014-07-10 09:19:58 +08:00
"github.com/hybridgroup/gobot"
2014-04-28 10:34:16 +08:00
)
2014-06-14 07:01:39 +08:00
func initTestLedDriver() *LedDriver {
2014-07-10 09:19:58 +08:00
return NewLedDriver(newGpioTestAdaptor("adaptor"), "myLed", "1")
2014-06-13 11:08:06 +08:00
}
2014-06-14 07:01:39 +08:00
func TestLedDriverStart(t *testing.T) {
d := initTestLedDriver()
gobot.Assert(t, d.Start(), true)
2014-06-13 11:08:06 +08:00
}
2014-06-14 07:01:39 +08:00
func TestLedDriverHalt(t *testing.T) {
d := initTestLedDriver()
gobot.Assert(t, d.Halt(), true)
2014-06-13 11:08:06 +08:00
}
2014-06-14 07:01:39 +08:00
func TestLedDriverInit(t *testing.T) {
d := initTestLedDriver()
gobot.Assert(t, d.Init(), true)
2014-06-13 11:08:06 +08:00
}
2014-06-14 07:01:39 +08:00
func TestLedDriverOn(t *testing.T) {
d := initTestLedDriver()
gobot.Assert(t, d.On(), true)
gobot.Assert(t, d.IsOn(), true)
2014-06-13 11:08:06 +08:00
}
2014-06-14 07:01:39 +08:00
func TestLedDriverOff(t *testing.T) {
d := initTestLedDriver()
gobot.Assert(t, d.Off(), true)
gobot.Assert(t, d.IsOff(), true)
2014-06-13 11:08:06 +08:00
}
2014-06-14 07:01:39 +08:00
func TestLedDriverToggle(t *testing.T) {
d := initTestLedDriver()
d.Off()
d.Toggle()
gobot.Assert(t, d.IsOn(), true)
2014-06-14 07:01:39 +08:00
d.Toggle()
gobot.Assert(t, d.IsOff(), true)
2014-06-13 11:08:06 +08:00
}
2014-06-14 07:01:39 +08:00
func TestLedDriverBrightness(t *testing.T) {
d := initTestLedDriver()
d.Brightness(150)
2014-06-13 11:08:06 +08:00
}