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.Expect(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.Expect(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.Expect(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.Expect(t, d.On(), true)
|
|
|
|
gobot.Expect(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.Expect(t, d.Off(), true)
|
|
|
|
gobot.Expect(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.Expect(t, d.IsOn(), true)
|
|
|
|
d.Toggle()
|
|
|
|
gobot.Expect(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
|
|
|
}
|