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
|
|
|
)
|
|
|
|
|
|
|
|
func initTestKeyboardDriver() *KeyboardDriver {
|
|
|
|
d := NewKeyboardDriver("keyboard")
|
|
|
|
d.connect = func(k *KeyboardDriver) (err error) {
|
|
|
|
k.stdin = &os.File{}
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
d.listen = func(k *KeyboardDriver) {}
|
|
|
|
return d
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestKeyboardDriver(t *testing.T) {
|
|
|
|
d := initTestKeyboardDriver()
|
2016-02-22 13:21:24 +08:00
|
|
|
gobottest.Assert(t, d.Name(), "keyboard")
|
|
|
|
gobottest.Assert(t, d.Connection(), (gobot.Connection)(nil))
|
2015-07-10 02:33:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestKeyboardDriverStart(t *testing.T) {
|
|
|
|
d := initTestKeyboardDriver()
|
2016-02-22 13:21:24 +08:00
|
|
|
gobottest.Assert(t, len(d.Start()), 0)
|
2015-07-10 02:33:46 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestKeyboardDriverHalt(t *testing.T) {
|
|
|
|
d := initTestKeyboardDriver()
|
2016-02-22 13:21:24 +08:00
|
|
|
gobottest.Assert(t, len(d.Halt()), 0)
|
2015-07-10 02:33:46 +08:00
|
|
|
}
|