1
0
mirror of https://github.com/hybridgroup/gobot.git synced 2025-05-06 19:29:15 +08:00
hybridgroup.gobot/platforms/parrot/ardrone/ardrone_adaptor_test.go

51 lines
1.1 KiB
Go
Raw Normal View History

2014-04-28 11:23:12 -07:00
package ardrone
import (
2014-12-18 13:33:33 -08:00
"errors"
"strings"
2014-06-12 16:07:40 -07:00
"testing"
"gobot.io/x/gobot"
"gobot.io/x/gobot/gobottest"
)
var _ gobot.Adaptor = (*Adaptor)(nil)
func initTestArdroneAdaptor() *Adaptor {
a := NewAdaptor()
a.connect = func(a *Adaptor) (drone, error) {
2014-12-18 13:33:33 -08:00
return &testDrone{}, nil
2014-06-12 16:07:40 -07:00
}
2014-06-14 13:55:12 -07:00
return a
2014-06-12 16:07:40 -07:00
}
2014-12-18 13:33:33 -08:00
func TestArdroneAdaptor(t *testing.T) {
a := NewAdaptor()
gobottest.Assert(t, a.config.Ip, "192.168.1.1")
2014-12-18 13:33:33 -08:00
a = NewAdaptor("192.168.100.100")
gobottest.Assert(t, a.config.Ip, "192.168.100.100")
2014-12-18 13:33:33 -08:00
}
func TestArdroneAdaptorConnect(t *testing.T) {
2014-06-14 13:55:12 -07:00
a := initTestArdroneAdaptor()
gobottest.Assert(t, a.Connect(), nil)
2014-12-18 13:33:33 -08:00
a.connect = func(a *Adaptor) (drone, error) {
2014-12-18 13:33:33 -08:00
return nil, errors.New("connection error")
}
gobottest.Assert(t, a.Connect(), errors.New("connection error"))
2014-06-12 16:07:40 -07:00
}
func TestArdroneAdaptorName(t *testing.T) {
a := initTestArdroneAdaptor()
gobottest.Assert(t, strings.HasPrefix(a.Name(), "ARDrone"), true)
a.SetName("NewName")
gobottest.Assert(t, a.Name(), "NewName")
}
2014-12-18 13:33:33 -08:00
func TestArdroneAdaptorFinalize(t *testing.T) {
2014-06-14 13:55:12 -07:00
a := initTestArdroneAdaptor()
gobottest.Assert(t, a.Finalize(), nil)
2014-06-12 16:07:40 -07:00
}