2015-07-10 02:33:46 +08:00
|
|
|
package keyboard
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/hybridgroup/gobot"
|
2016-02-22 13:21:24 +08:00
|
|
|
"github.com/hybridgroup/gobot/gobottest"
|
2015-07-10 02:33:46 +08:00
|
|
|
)
|
|
|
|
|
2016-09-26 03:27:37 +08:00
|
|
|
var _ gobot.Driver = (*Driver)(nil)
|
2016-08-27 17:56:01 +08:00
|
|
|
|
2016-09-26 03:27:37 +08:00
|
|
|
func initTestKeyboardDriver() *Driver {
|
|
|
|
d := NewDriver()
|
|
|
|
d.connect = func(k *Driver) (err error) {
|
2015-07-10 02:33:46 +08:00
|
|
|
k.stdin = &os.File{}
|
|
|
|
return nil
|
|
|
|
}
|
2016-09-26 03:27:37 +08:00
|
|
|
d.listen = func(k *Driver) {}
|
2015-07-10 02:33:46 +08:00
|
|
|
return d
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestKeyboardDriver(t *testing.T) {
|
|
|
|
d := initTestKeyboardDriver()
|
2016-02-22 13:21:24 +08:00
|
|
|
gobottest.Assert(t, d.Connection(), (gobot.Connection)(nil))
|
2015-07-10 02:33:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestKeyboardDriverStart(t *testing.T) {
|
|
|
|
d := initTestKeyboardDriver()
|
2016-11-08 02:35:04 +08:00
|
|
|
gobottest.Assert(t, d.Start(), nil)
|
2015-07-10 02:33:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestKeyboardDriverHalt(t *testing.T) {
|
|
|
|
d := initTestKeyboardDriver()
|
2016-11-08 02:35:04 +08:00
|
|
|
gobottest.Assert(t, d.Halt(), nil)
|
2015-07-10 02:33:46 +08:00
|
|
|
}
|