1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-04-27 13:48:56 +08:00
hybridgroup.gobot/platforms/joystick/joystick_adaptor_test.go

35 lines
737 B
Go
Raw Normal View History

2014-04-27 18:02:39 -07:00
package joystick
import (
2014-11-19 18:54:31 -08:00
"errors"
2014-06-13 12:54:21 -07:00
"testing"
2014-07-22 13:55:19 -07:00
"github.com/hybridgroup/gobot"
"github.com/hybridgroup/gobot/gobottest"
)
var _ gobot.Adaptor = (*JoystickAdaptor)(nil)
2014-06-13 16:01:39 -07:00
func initTestJoystickAdaptor() *JoystickAdaptor {
2014-07-22 13:55:19 -07:00
a := NewJoystickAdaptor("bot")
2014-11-19 15:45:59 -08:00
a.connect = func(j *JoystickAdaptor) (err error) {
2014-07-22 13:55:19 -07:00
j.joystick = &testJoystick{}
2014-11-19 15:45:59 -08:00
return nil
2014-07-22 13:55:19 -07:00
}
return a
2014-06-13 12:54:21 -07:00
}
2014-06-13 16:01:39 -07:00
func TestJoystickAdaptorConnect(t *testing.T) {
a := initTestJoystickAdaptor()
gobottest.Assert(t, len(a.Connect()), 0)
2014-11-19 18:54:31 -08:00
a = NewJoystickAdaptor("bot")
gobottest.Assert(t, a.Connect()[0], errors.New("No joystick available"))
2014-06-13 12:54:21 -07:00
}
2014-06-13 16:01:39 -07:00
func TestJoystickAdaptorFinalize(t *testing.T) {
a := initTestJoystickAdaptor()
2014-07-22 13:55:19 -07:00
a.Connect()
gobottest.Assert(t, len(a.Finalize()), 0)
2014-06-13 12:54:21 -07:00
}