1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-29 13:49:14 +08:00
hybridgroup.gobot/platforms/gpio/button_driver_test.go

40 lines
773 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
"github.com/hybridgroup/gobot"
"testing"
)
2014-06-13 16:01:39 -07:00
func initTestButtonDriver() *ButtonDriver {
return NewButtonDriver(TestAdaptor{}, "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.Expect(t, d.Start(), true)
2014-06-12 20:08:06 -07:00
}
2014-06-13 16:01:39 -07:00
func TestButtonDriverHalt(t *testing.T) {
d := initTestButtonDriver()
gobot.Expect(t, d.Halt(), true)
2014-06-12 20:08:06 -07:00
}
2014-06-13 16:01:39 -07:00
func TestButtonDriverInit(t *testing.T) {
d := initTestButtonDriver()
gobot.Expect(t, d.Init(), true)
2014-06-12 20:08:06 -07:00
}
2014-06-13 16:01:39 -07:00
func TestButtonDriverReadState(t *testing.T) {
d := initTestButtonDriver()
gobot.Expect(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.Expect(t, d.Active, true)
2014-06-12 20:08:06 -07:00
2014-06-13 16:01:39 -07:00
d.update(0)
gobot.Expect(t, d.Active, false)
2014-06-12 20:08:06 -07:00
}