1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-05-06 19:29:15 +08:00
hybridgroup.gobot/platforms/gpio/button_driver_test.go

36 lines
681 B
Go
Raw Normal View History

2014-04-27 19:34:16 -07:00
package gpio
import (
2014-06-12 20:08:06 -07:00
"testing"
2014-09-27 11:45:52 -07:00
"github.com/hybridgroup/gobot"
)
2014-06-13 16:01:39 -07:00
func initTestButtonDriver() *ButtonDriver {
return NewButtonDriver(newGpioTestAdaptor("adaptor"), "bot", "1")
2014-06-12 20:08:06 -07:00
}
2014-06-13 16:01:39 -07:00
func TestButtonDriverStart(t *testing.T) {
d := initTestButtonDriver()
gobot.Assert(t, d.Start(), nil)
2014-06-12 20:08:06 -07:00
}
2014-06-13 16:01:39 -07:00
func TestButtonDriverHalt(t *testing.T) {
d := initTestButtonDriver()
gobot.Assert(t, d.Halt(), nil)
2014-06-12 20:08:06 -07:00
}
2014-06-13 16:01:39 -07:00
func TestButtonDriverReadState(t *testing.T) {
d := initTestButtonDriver()
gobot.Assert(t, d.readState(), 1)
2014-06-12 20:08:06 -07:00
}
2014-06-13 16:01:39 -07:00
func TestButtonDriverActive(t *testing.T) {
d := initTestButtonDriver()
d.update(1)
gobot.Assert(t, d.Active, true)
2014-06-12 20:08:06 -07:00
2014-06-13 16:01:39 -07:00
d.update(0)
gobot.Assert(t, d.Active, false)
2014-06-12 20:08:06 -07:00
}