1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-27 13:48:56 +08:00
hybridgroup.gobot/platforms/keyboard/keyboard_driver_test.go
Thomas Kohler 865e724af0
Build(v2): revert move to v2 subfolder (#932)
* revert move to v2 subfolder
* fix CI and adjust CHANGELOG
2023-05-29 19:23:28 +02:00

45 lines
911 B
Go

package keyboard
import (
"os"
"strings"
"testing"
"gobot.io/x/gobot/v2"
"gobot.io/x/gobot/v2/gobottest"
)
var _ gobot.Driver = (*Driver)(nil)
func initTestKeyboardDriver() *Driver {
d := NewDriver()
d.connect = func(k *Driver) (err error) {
k.stdin = &os.File{}
return nil
}
d.listen = func(k *Driver) {}
return d
}
func TestKeyboardDriver(t *testing.T) {
d := initTestKeyboardDriver()
gobottest.Assert(t, d.Connection(), (gobot.Connection)(nil))
}
func TestKeyboardDriverName(t *testing.T) {
d := initTestKeyboardDriver()
gobottest.Assert(t, strings.HasPrefix(d.Name(), "Keyboard"), true)
d.SetName("NewName")
gobottest.Assert(t, d.Name(), "NewName")
}
func TestKeyboardDriverStart(t *testing.T) {
d := initTestKeyboardDriver()
gobottest.Assert(t, d.Start(), nil)
}
func TestKeyboardDriverHalt(t *testing.T) {
d := initTestKeyboardDriver()
gobottest.Assert(t, d.Halt(), nil)
}