2014-06-13 13:35:19 -07:00
|
|
|
package leap
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hybridgroup/gobot"
|
|
|
|
"io/ioutil"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
2014-06-13 16:01:39 -07:00
|
|
|
func initTestLeapMotionDriver() *LeapMotionDriver {
|
|
|
|
return NewLeapMotionDriver(NewLeapMotionAdaptor("bot", "/dev/null"), "bot")
|
2014-06-13 13:35:19 -07:00
|
|
|
}
|
|
|
|
|
2014-06-13 16:01:39 -07:00
|
|
|
func TestLeapMotionDriverStart(t *testing.T) {
|
2014-06-13 13:35:19 -07:00
|
|
|
t.SkipNow()
|
2014-06-13 16:01:39 -07:00
|
|
|
d := initTestLeapMotionDriver()
|
2014-07-17 11:41:47 -07:00
|
|
|
gobot.Assert(t, d.Start(), true)
|
2014-06-13 13:35:19 -07:00
|
|
|
}
|
|
|
|
|
2014-06-13 16:01:39 -07:00
|
|
|
func TestLeapMotionDriverHalt(t *testing.T) {
|
2014-06-13 13:35:19 -07:00
|
|
|
t.SkipNow()
|
2014-06-13 16:01:39 -07:00
|
|
|
d := initTestLeapMotionDriver()
|
2014-07-17 11:41:47 -07:00
|
|
|
gobot.Assert(t, d.Halt(), true)
|
2014-06-13 13:35:19 -07:00
|
|
|
}
|
|
|
|
|
2014-06-13 16:01:39 -07:00
|
|
|
func TestLeapMotionDriverInit(t *testing.T) {
|
2014-06-13 13:35:19 -07:00
|
|
|
t.SkipNow()
|
2014-06-13 16:01:39 -07:00
|
|
|
d := initTestLeapMotionDriver()
|
2014-07-17 11:41:47 -07:00
|
|
|
gobot.Assert(t, d.Init(), true)
|
2014-06-13 13:35:19 -07:00
|
|
|
}
|
|
|
|
|
2014-06-13 16:01:39 -07:00
|
|
|
func TestLeapMotionDriverParser(t *testing.T) {
|
|
|
|
d := initTestLeapMotionDriver()
|
2014-06-13 13:35:19 -07:00
|
|
|
file, _ := ioutil.ReadFile("./test/support/example_frame.json")
|
|
|
|
parsedFrame := d.ParseFrame(file)
|
|
|
|
|
|
|
|
if parsedFrame.Hands == nil || parsedFrame.Pointables == nil || parsedFrame.Gestures == nil {
|
|
|
|
t.Errorf("ParseFrame incorrectly parsed frame")
|
|
|
|
}
|
|
|
|
|
|
|
|
parsedFrame = d.ParseFrame([]byte{})
|
2014-07-17 11:41:47 -07:00
|
|
|
gobot.Assert(t, parsedFrame.Timestamp, 0)
|
2014-06-13 13:35:19 -07:00
|
|
|
}
|