From fa21a1458883fa91a2eeed6917fd02e9dfa8e4c7 Mon Sep 17 00:00:00 2001 From: Adrian Zankich Date: Thu, 12 Jun 2014 16:07:40 -0700 Subject: [PATCH] Update ardrone tests --- platforms/ardrone/ardrone_adaptor_test.go | 60 ++++++----- platforms/ardrone/ardrone_driver.go | 3 - platforms/ardrone/ardrone_driver_test.go | 117 +++++++++++----------- 3 files changed, 89 insertions(+), 91 deletions(-) diff --git a/platforms/ardrone/ardrone_adaptor_test.go b/platforms/ardrone/ardrone_adaptor_test.go index cc1e043c..33acf51f 100644 --- a/platforms/ardrone/ardrone_adaptor_test.go +++ b/platforms/ardrone/ardrone_adaptor_test.go @@ -1,38 +1,36 @@ package ardrone import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" + "github.com/hybridgroup/gobot" + "testing" ) -var _ = Describe("ArdroneAdaptor", func() { - var ( - adaptor *ArdroneAdaptor - drone *testDrone - ) +var adaptor *ArdroneAdaptor +var d *testDrone - BeforeEach(func() { - drone = &testDrone{} - adaptor = NewArdroneAdaptor("drone") - adaptor.connect = func(a *ArdroneAdaptor) { - a.drone = drone - } - }) +func init() { + d = &testDrone{} + adaptor = NewArdroneAdaptor("drone") + adaptor.connect = func(a *ArdroneAdaptor) { + a.drone = d + } +} - It("Must be able to Finalize", func() { - Expect(adaptor.Finalize()).To(Equal(true)) - }) - It("Must be able to Connect", func() { - Expect(adaptor.Connect()).To(Equal(true)) - }) - It("Must be able to Disconnect", func() { - Expect(adaptor.Disconnect()).To(Equal(true)) - }) - It("Must be able to Reconnect", func() { - Expect(adaptor.Reconnect()).To(Equal(true)) - }) - It("Must be able to return a Drone", func() { - adaptor.Connect() - Expect(adaptor.Drone()).To(Equal(drone)) - }) -}) +func TestFinalize(t *testing.T) { + gobot.Expect(t, adaptor.Finalize(), true) +} +func TestConnect(t *testing.T) { + gobot.Expect(t, adaptor.Connect(), true) +} +func TestDisconnect(t *testing.T) { + gobot.Expect(t, adaptor.Disconnect(), true) +} + +func TestReconnect(t *testing.T) { + gobot.Expect(t, adaptor.Reconnect(), true) +} + +func TestDrone(t *testing.T) { + adaptor.Connect() + gobot.Expect(t, adaptor.Drone(), d) +} diff --git a/platforms/ardrone/ardrone_driver.go b/platforms/ardrone/ardrone_driver.go index 2573b546..be462d10 100644 --- a/platforms/ardrone/ardrone_driver.go +++ b/platforms/ardrone/ardrone_driver.go @@ -31,9 +31,6 @@ func (a *ArdroneDriver) Start() bool { func (a *ArdroneDriver) Halt() bool { return true } -func (a *ArdroneDriver) Init() bool { - return true -} func (a *ArdroneDriver) TakeOff() { gobot.Publish(a.Events["Flying"], gobot.Call(a.Adaptor.Drone(), "Takeoff")) diff --git a/platforms/ardrone/ardrone_driver_test.go b/platforms/ardrone/ardrone_driver_test.go index 0130642c..2bf90e2b 100644 --- a/platforms/ardrone/ardrone_driver_test.go +++ b/platforms/ardrone/ardrone_driver_test.go @@ -1,64 +1,67 @@ package ardrone import ( - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" + "github.com/hybridgroup/gobot" + "testing" ) -var _ = Describe("ArdroneDriver", func() { - var ( - driver *ArdroneDriver - ) +var driver *ArdroneDriver - BeforeEach(func() { - adaptor := NewArdroneAdaptor("drone") - adaptor.connect = func(a *ArdroneAdaptor) { - a.drone = &testDrone{} - } - driver = NewArdroneDriver(adaptor, "drone") - adaptor.Connect() - }) +func init() { + adaptor := NewArdroneAdaptor("drone") + adaptor.connect = func(a *ArdroneAdaptor) { + a.drone = &testDrone{} + } + driver = NewArdroneDriver(adaptor, "drone") + adaptor.Connect() +} - It("Must be able to Start", func() { - Expect(driver.Start()).To(Equal(true)) - }) - It("Must be able to Init", func() { - Expect(driver.Init()).To(Equal(true)) - }) - It("Must be able to Halt", func() { - Expect(driver.Halt()).To(Equal(true)) - }) - It("Must be able to TakeOff", func() { - driver.TakeOff() - }) - It("Must be able to Land", func() { - driver.Land() - }) - It("Must be able to go Up", func() { - driver.Up(1) - }) - It("Must be able to go Down", func() { - driver.Down(1) - }) - It("Must be able to go Left", func() { - driver.Left(1) - }) - It("Must be able to go Right", func() { - driver.Right(1) - }) - It("Must be able to go Forward", func() { - driver.Forward(1) - }) - It("Must be able to go Backward", func() { - driver.Backward(1) - }) - It("Must be able to go Clockwise", func() { - driver.Clockwise(1) - }) - It("Must be able to go CounterClockwise", func() { - driver.CounterClockwise(1) - }) - It("Must be able to Hover", func() { - driver.Hover() - }) -}) +func TestStart(t *testing.T) { + gobot.Expect(t, driver.Start(), true) +} + +func TestHalt(t *testing.T) { + gobot.Expect(t, driver.Halt(), true) +} +func TestTakeOff(t *testing.T) { + driver.TakeOff() +} + +func TestLand(t *testing.T) { + driver.Land() +} +func TestUp(t *testing.T) { + driver.Up(1) +} + +func TestDown(t *testing.T) { + driver.Down(1) +} + +func TestLeft(t *testing.T) { + driver.Left(1) +} + +func TestRight(t *testing.T) { + driver.Right(1) +} + +func TestForward(t *testing.T) { + driver.Forward(1) +} + +func TestBackward(t *testing.T) { + driver.Backward(1) +} + +func TestClockwise(t *testing.T) { + driver.Clockwise(1) +} + +func TestCounterClockwise(t *testing.T) { + driver.CounterClockwise(1) +} + +func TestHover(t *testing.T) { + driver.Hover() +}