artoo 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitignore +25 -0
- data/Gemfile +26 -0
- data/Gemfile.lock +144 -0
- data/Guardfile +15 -0
- data/LICENSE +13 -0
- data/README.md +97 -0
- data/Rakefile +11 -0
- data/api/assets/compass.rb +25 -0
- data/api/assets/javascripts/artoo/controllers/robot.js.coffee +27 -0
- data/api/assets/javascripts/artoo/routes.js.coffee +23 -0
- data/api/assets/javascripts/core.js.coffee +6 -0
- data/api/assets/javascripts/vendor/angular.min.js +161 -0
- data/api/assets/javascripts/vendor/bootstrap.min.js +6 -0
- data/api/assets/javascripts/vendor/jquery.min.js +5 -0
- data/api/assets/stylesheets/artoo/_core.css.scss +3 -0
- data/api/assets/stylesheets/artoo/_font-awesome.scss +534 -0
- data/api/assets/stylesheets/artoo/_variables.scss +8 -0
- data/api/assets/stylesheets/core.scss +70 -0
- data/api/public/core.css +9848 -0
- data/api/public/core.js +259 -0
- data/api/public/favicon.ico +0 -0
- data/api/public/font/FontAwesome.otf +0 -0
- data/api/public/font/fontawesome-webfont.eot +0 -0
- data/api/public/font/fontawesome-webfont.svg +284 -0
- data/api/public/font/fontawesome-webfont.ttf +0 -0
- data/api/public/font/fontawesome-webfont.woff +0 -0
- data/api/public/html5shiv.js +8 -0
- data/api/public/images/devices/ardrone.jpg +0 -0
- data/api/public/images/devices/arduino.jpg +0 -0
- data/api/public/images/devices/sphero.png +0 -0
- data/api/public/images/glyphicons-halflings-white.png +0 -0
- data/api/public/images/glyphicons-halflings.png +0 -0
- data/api/public/index.html +36 -0
- data/api/public/partials/robot-detail.html +111 -0
- data/api/public/partials/robot-device-detail.html +0 -0
- data/api/public/partials/robot-index.html +26 -0
- data/artoo.gemspec +21 -0
- data/bin/retry.sh +8 -0
- data/bin/sphero.sh +8 -0
- data/examples/ardrone.rb +12 -0
- data/examples/ardrone_nav.rb +22 -0
- data/examples/ardrone_nav_video.rb +33 -0
- data/examples/ardrone_video.rb +22 -0
- data/examples/conway_sphero.rb +65 -0
- data/examples/firmata.rb +13 -0
- data/examples/firmata_button.rb +9 -0
- data/examples/hello.rb +12 -0
- data/examples/hello_api.rb +9 -0
- data/examples/hello_api_multiple.rb +25 -0
- data/examples/hello_modular.rb +16 -0
- data/examples/hello_multiple.rb +22 -0
- data/examples/notifications.rb +9 -0
- data/examples/sphero.rb +11 -0
- data/examples/sphero_color.rb +13 -0
- data/examples/sphero_firmata.rb +17 -0
- data/examples/sphero_messages.rb +22 -0
- data/examples/sphero_multiple.rb +33 -0
- data/examples/wiiclassic.rb +94 -0
- data/lib/artoo.rb +3 -0
- data/lib/artoo/adaptors/adaptor.rb +54 -0
- data/lib/artoo/adaptors/ardrone.rb +32 -0
- data/lib/artoo/adaptors/ardrone_navigation.rb +26 -0
- data/lib/artoo/adaptors/ardrone_video.rb +27 -0
- data/lib/artoo/adaptors/firmata.rb +25 -0
- data/lib/artoo/adaptors/loopback.rb +8 -0
- data/lib/artoo/adaptors/sphero.rb +46 -0
- data/lib/artoo/api.rb +48 -0
- data/lib/artoo/api_route_helpers.rb +197 -0
- data/lib/artoo/connection.rb +70 -0
- data/lib/artoo/delegator.rb +49 -0
- data/lib/artoo/device.rb +61 -0
- data/lib/artoo/device_event_client.rb +27 -0
- data/lib/artoo/drivers/ardrone.rb +9 -0
- data/lib/artoo/drivers/ardrone_navigation.rb +21 -0
- data/lib/artoo/drivers/ardrone_video.rb +22 -0
- data/lib/artoo/drivers/button.rb +40 -0
- data/lib/artoo/drivers/driver.rb +48 -0
- data/lib/artoo/drivers/led.rb +37 -0
- data/lib/artoo/drivers/passthru.rb +9 -0
- data/lib/artoo/drivers/pinger.rb +19 -0
- data/lib/artoo/drivers/pinger2.rb +18 -0
- data/lib/artoo/drivers/sphero.rb +57 -0
- data/lib/artoo/drivers/wiichuck.rb +29 -0
- data/lib/artoo/drivers/wiiclassic.rb +137 -0
- data/lib/artoo/main.rb +32 -0
- data/lib/artoo/master.rb +16 -0
- data/lib/artoo/port.rb +51 -0
- data/lib/artoo/robot.rb +299 -0
- data/lib/artoo/utility.rb +39 -0
- data/lib/artoo/version.rb +5 -0
- data/test/adaptors/adaptor_test.rb +18 -0
- data/test/adaptors/ardrone_test.rb +24 -0
- data/test/adaptors/firmata_test.rb +25 -0
- data/test/adaptors/loopback_test.rb +18 -0
- data/test/adaptors/sphero_test.rb +24 -0
- data/test/api_test.rb +61 -0
- data/test/artoo_test.rb +12 -0
- data/test/connection_test.rb +28 -0
- data/test/delegator_test.rb +71 -0
- data/test/device_test.rb +41 -0
- data/test/drivers/ardrone_navigation_test.rb +11 -0
- data/test/drivers/ardrone_test.rb +11 -0
- data/test/drivers/ardrone_video_test.rb +11 -0
- data/test/drivers/driver_test.rb +21 -0
- data/test/drivers/led_test.rb +52 -0
- data/test/drivers/sphero_test.rb +54 -0
- data/test/drivers/wiichuck_test.rb +11 -0
- data/test/port_test.rb +33 -0
- data/test/robot_test.rb +96 -0
- data/test/test_helper.rb +8 -0
- data/test/utility_test.rb +27 -0
- metadata +185 -0
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
|
|
2
|
+
require 'artoo/adaptors/adaptor'
|
|
3
|
+
|
|
4
|
+
describe Artoo::Adaptors::Adaptor do
|
|
5
|
+
before do
|
|
6
|
+
@adaptor = Artoo::Adaptors::Adaptor.new(:port => '1234')
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it 'Artoo::Adaptors::Adaptor#connect' do
|
|
10
|
+
@adaptor.connect
|
|
11
|
+
@adaptor.connected?.must_equal true
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'Artoo::Adaptors::Adaptor#disconnect' do
|
|
15
|
+
@adaptor.disconnect
|
|
16
|
+
@adaptor.connected?.must_equal false
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
|
|
2
|
+
require 'artoo/adaptors/ardrone'
|
|
3
|
+
require 'argus'
|
|
4
|
+
|
|
5
|
+
describe Artoo::Adaptors::Ardrone do
|
|
6
|
+
before do
|
|
7
|
+
@port = Artoo::Port.new('/dev/awesome')
|
|
8
|
+
@adaptor = Artoo::Adaptors::Ardrone.new(:port => @port)
|
|
9
|
+
@ardrone = mock('ardrone')
|
|
10
|
+
Argus::Drone.stubs(:new).returns(@ardrone)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'Artoo::Adaptors::Ardrone#connect' do
|
|
14
|
+
@adaptor.connect.must_equal true
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'Artoo::Adaptors::Ardrone#disconnect' do
|
|
18
|
+
@adaptor.connect
|
|
19
|
+
|
|
20
|
+
@ardrone.expects(:stop)
|
|
21
|
+
@adaptor.disconnect
|
|
22
|
+
@adaptor.connected?.must_equal false
|
|
23
|
+
end
|
|
24
|
+
end
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
|
|
2
|
+
require 'artoo/adaptors/firmata'
|
|
3
|
+
require 'firmata'
|
|
4
|
+
|
|
5
|
+
describe Artoo::Adaptors::Firmata do
|
|
6
|
+
before do
|
|
7
|
+
@port = Artoo::Port.new('/dev/awesome')
|
|
8
|
+
@adaptor = Artoo::Adaptors::Firmata.new(:port => @port)
|
|
9
|
+
@firmata = mock('firmata')
|
|
10
|
+
Firmata::Board.stubs(:new).returns(@firmata)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'Artoo::Adaptors::Firmata#connect' do
|
|
14
|
+
@firmata.expects(:connect)
|
|
15
|
+
@adaptor.connect.must_equal true
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'Artoo::Adaptors::Firmata#disconnect' do
|
|
19
|
+
@firmata.stubs(:connect)
|
|
20
|
+
@adaptor.connect
|
|
21
|
+
@adaptor.disconnect
|
|
22
|
+
|
|
23
|
+
@adaptor.connected?.must_equal false
|
|
24
|
+
end
|
|
25
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
|
|
2
|
+
require 'artoo/adaptors/loopback'
|
|
3
|
+
|
|
4
|
+
describe Artoo::Adaptors::Loopback do
|
|
5
|
+
before do
|
|
6
|
+
@adaptor = Artoo::Adaptors::Loopback.new(:port => '1234')
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it 'Artoo::Adaptors::Loopback#connect' do
|
|
10
|
+
@adaptor.connect
|
|
11
|
+
@adaptor.connected?.must_equal true
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'Artoo::Adaptors::Loopback#disconnect' do
|
|
15
|
+
@adaptor.disconnect
|
|
16
|
+
@adaptor.connected?.must_equal false
|
|
17
|
+
end
|
|
18
|
+
end
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
|
|
2
|
+
require 'artoo/adaptors/sphero'
|
|
3
|
+
require 'sphero'
|
|
4
|
+
|
|
5
|
+
describe Artoo::Adaptors::Sphero do
|
|
6
|
+
before do
|
|
7
|
+
@port = Artoo::Port.new('/dev/awesome')
|
|
8
|
+
@adaptor = Artoo::Adaptors::Sphero.new(:port => @port)
|
|
9
|
+
@sphero = mock('sphero')
|
|
10
|
+
Sphero.stubs(:new).returns(@sphero)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'Artoo::Adaptors::Sphero#connect' do
|
|
14
|
+
@adaptor.connect.must_equal true
|
|
15
|
+
end
|
|
16
|
+
|
|
17
|
+
it 'Artoo::Adaptors::Sphero#disconnect' do
|
|
18
|
+
@adaptor.connect
|
|
19
|
+
|
|
20
|
+
@sphero.expects(:close)
|
|
21
|
+
@adaptor.disconnect
|
|
22
|
+
@adaptor.connected?.must_equal false
|
|
23
|
+
end
|
|
24
|
+
end
|
data/test/api_test.rb
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/test_helper")
|
|
2
|
+
require File.expand_path(File.dirname(__FILE__) + "/../lib/artoo/api")
|
|
3
|
+
|
|
4
|
+
class ExampleRequest
|
|
5
|
+
extend Forwardable
|
|
6
|
+
def_delegators :@headers, :[], :[]=
|
|
7
|
+
attr_accessor :method, :path, :version, :body
|
|
8
|
+
|
|
9
|
+
def initialize(method = :get, path = "/", version = "1.1", headers = {}, body = nil)
|
|
10
|
+
@method = method.to_s.upcase
|
|
11
|
+
@path = path
|
|
12
|
+
@version = "1.1"
|
|
13
|
+
@headers = {
|
|
14
|
+
'Host' => 'www.example.com',
|
|
15
|
+
'Connection' => 'keep-alive',
|
|
16
|
+
'User-Agent' => 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.78 S',
|
|
17
|
+
'Accept' => 'text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8',
|
|
18
|
+
'Accept-Encoding' => 'gzip,deflate,sdch',
|
|
19
|
+
'Accept-Language' => 'en-US,en;q=0.8',
|
|
20
|
+
'Accept-Charset' => 'ISO-8859-1,utf-8;q=0.7,*;q=0.3'
|
|
21
|
+
}.merge(headers)
|
|
22
|
+
|
|
23
|
+
@body = nil
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def to_s
|
|
27
|
+
if @body && !@headers['Content-Length']
|
|
28
|
+
@headers['Content-Length'] = @body.length
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
"#{@method} #{@path} HTTP/#{@version}\r\n" <<
|
|
32
|
+
@headers.map { |k, v| "#{k}: #{v}" }.join("\r\n") << "\r\n\r\n" <<
|
|
33
|
+
(@body ? @body : '')
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
describe Artoo::Api do
|
|
38
|
+
describe Artoo::ApiRouteHelpers do
|
|
39
|
+
|
|
40
|
+
class DummyClass
|
|
41
|
+
include Artoo::ApiRouteHelpers
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
it "should have a list of routes" do
|
|
45
|
+
DummyClass.routes.class.must_equal Hash
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
it "should be able to define methods" do
|
|
49
|
+
DummyClass.instance_eval <<-EOE
|
|
50
|
+
get '/' do
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
get_ws '/sock' do
|
|
54
|
+
end
|
|
55
|
+
EOE
|
|
56
|
+
|
|
57
|
+
DummyClass.routes['GET'].length.must_equal 2
|
|
58
|
+
end
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
end
|
data/test/artoo_test.rb
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/test_helper")
|
|
2
|
+
require 'artoo/delegator'
|
|
3
|
+
|
|
4
|
+
describe Artoo do
|
|
5
|
+
it 'must create a new Artoo::Robot subclass on new' do
|
|
6
|
+
robot = Artoo.new {
|
|
7
|
+
connection :test_connection
|
|
8
|
+
work { puts 'Hello World' }
|
|
9
|
+
}
|
|
10
|
+
robot.superclass.must_equal Artoo::Robot
|
|
11
|
+
end
|
|
12
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/test_helper")
|
|
2
|
+
|
|
3
|
+
class ConnectionTestRobot < Artoo::Robot
|
|
4
|
+
connection :test_connection
|
|
5
|
+
end
|
|
6
|
+
|
|
7
|
+
describe Artoo::Connection do
|
|
8
|
+
before do
|
|
9
|
+
@robot = ConnectionTestRobot.new
|
|
10
|
+
@connection = @robot.default_connection
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
it 'Artoo::Connection#connect' do
|
|
14
|
+
@connection.connect
|
|
15
|
+
@connection.adaptor.must_be_kind_of Artoo::Adaptors::Loopback
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'Artoo::Connection#disconnect' do
|
|
19
|
+
@connection.connect
|
|
20
|
+
@connection.disconnect
|
|
21
|
+
@connection.connected?.must_equal false
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
it 'Artoo::Connection#as_json' do
|
|
25
|
+
MultiJson.load(@connection.as_json, :symbolize_keys => true)[:name].must_equal "test_connection"
|
|
26
|
+
MultiJson.load(@connection.as_json, :symbolize_keys => true)[:connected].must_equal false
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/test_helper")
|
|
2
|
+
|
|
3
|
+
class DelegatorTest < MiniTest::Unit::TestCase
|
|
4
|
+
class Mirror
|
|
5
|
+
attr_reader :last_call
|
|
6
|
+
def method_missing(*a, &b)
|
|
7
|
+
@last_call = [*a.map(&:to_s)]
|
|
8
|
+
@last_call << b if b
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
def self.delegates(name)
|
|
13
|
+
define_method "test_delegates_#{name}" do
|
|
14
|
+
m = mirror { send name }
|
|
15
|
+
assert_equal [name.to_s], m.last_call
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
define_method "test_delegates_#{name}_with_arguments" do
|
|
19
|
+
m = mirror { send name, "foo", "bar" }
|
|
20
|
+
assert_equal [name.to_s, "foo", "bar"], m.last_call
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
define_method "test_delegates_#{name}_with_block" do
|
|
24
|
+
block = proc { }
|
|
25
|
+
m = mirror { send(name, &block) }
|
|
26
|
+
assert_equal [name.to_s, block], m.last_call
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def setup
|
|
31
|
+
@target_was = Artoo::Delegator.target
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def teardown
|
|
35
|
+
Artoo::Delegator.target = @target_was
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def delegation_robot(&block)
|
|
39
|
+
mock_robot { Artoo::Delegator.target = self }
|
|
40
|
+
delegate(&block)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def mirror(&block)
|
|
44
|
+
mirror = Mirror.new
|
|
45
|
+
Artoo::Delegator.target = mirror
|
|
46
|
+
delegate(&block)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def delegate(&block)
|
|
50
|
+
assert Artoo::Delegator.target != Artoo::MainRobot
|
|
51
|
+
Object.new.extend(Artoo::Delegator).instance_eval(&block) if block
|
|
52
|
+
Artoo::Delegator.target
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
def target
|
|
56
|
+
Artoo::Delegator.target
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
def test_defaults_to_mainrobot_as_target
|
|
60
|
+
assert_equal Artoo::MainRobot, Artoo::Delegator.target
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
def test_delegates_crazy_method_names
|
|
64
|
+
Artoo::Delegator.delegate "foo:bar:"
|
|
65
|
+
method = mirror { send "foo:bar:" }.last_call.first
|
|
66
|
+
assert_equal "foo:bar:", method
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
delegates 'work'
|
|
70
|
+
delegates 'device'
|
|
71
|
+
end
|
data/test/device_test.rb
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/test_helper")
|
|
2
|
+
|
|
3
|
+
class DeviceTestRobot < Artoo::Robot
|
|
4
|
+
connection :test_connection
|
|
5
|
+
device :test_device_1
|
|
6
|
+
device :test_device_2
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
class MultipleDeviceConnectionTestRobot < Artoo::Robot
|
|
10
|
+
connection :test_connection
|
|
11
|
+
connection :test_connection2
|
|
12
|
+
device :test_device_1, :connection => :test_connection
|
|
13
|
+
device :test_device_2, :connection => :test_connection2
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe Artoo::Device do
|
|
17
|
+
before do
|
|
18
|
+
@robot = DeviceTestRobot.new(:name => 'devicebot')
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
it 'Artoo::Device#default_connection' do
|
|
22
|
+
@robot.devices[:test_device_1].default_connection.must_equal @robot.default_connection
|
|
23
|
+
@robot.devices[:test_device_2].default_connection.must_equal @robot.default_connection
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it 'Artoo::Device#connect' do
|
|
27
|
+
@robot2 = MultipleDeviceConnectionTestRobot.new
|
|
28
|
+
@robot2.devices[:test_device_1].connection.must_equal @robot2.connections[:test_connection]
|
|
29
|
+
@robot2.devices[:test_device_2].connection.must_equal @robot2.connections[:test_connection2]
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
it 'Artoo::Device#event_topic_name' do
|
|
33
|
+
@device = @robot.devices[:test_device_1]
|
|
34
|
+
@device.event_topic_name("happy").must_equal "devicebot_test_device_1_happy"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
it 'Artoo::Device#as_json' do
|
|
38
|
+
@device = @robot.devices[:test_device_1]
|
|
39
|
+
MultiJson.load(@device.as_json, :symbolize_keys => true)[:name].must_equal "test_device_1"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
|
|
2
|
+
require 'artoo/drivers/ardrone_navigation'
|
|
3
|
+
|
|
4
|
+
describe Artoo::Drivers::ArdroneNavigation do
|
|
5
|
+
before do
|
|
6
|
+
@device = mock('device')
|
|
7
|
+
@driver = Artoo::Drivers::ArdroneNavigation.new(:parent => @device)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it 'must do things'
|
|
11
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
|
|
2
|
+
require 'artoo/drivers/ardrone'
|
|
3
|
+
|
|
4
|
+
describe Artoo::Drivers::Ardrone do
|
|
5
|
+
before do
|
|
6
|
+
@device = mock('device')
|
|
7
|
+
@driver = Artoo::Drivers::Ardrone.new(:parent => @device)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it 'must do things'
|
|
11
|
+
end
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
|
|
2
|
+
require 'artoo/drivers/ardrone_video'
|
|
3
|
+
|
|
4
|
+
describe Artoo::Drivers::ArdroneVideo do
|
|
5
|
+
before do
|
|
6
|
+
@device = mock('device')
|
|
7
|
+
@driver = Artoo::Drivers::ArdroneVideo.new(:parent => @device)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it 'must do things'
|
|
11
|
+
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
|
|
2
|
+
require 'artoo/drivers/driver'
|
|
3
|
+
|
|
4
|
+
describe Artoo::Drivers::Driver do
|
|
5
|
+
before do
|
|
6
|
+
@device = mock('device')
|
|
7
|
+
@driver = Artoo::Drivers::Driver.new(:parent => @device)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
it 'Driver#connection' do
|
|
11
|
+
@connection = mock('connection')
|
|
12
|
+
@device.expects(:connection).returns(@connection)
|
|
13
|
+
@driver.connection.must_equal @connection
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
it 'Driver#pin' do
|
|
17
|
+
@pin = 13
|
|
18
|
+
@device.expects(:pin).returns(@pin)
|
|
19
|
+
@driver.pin.must_equal @pin
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + "/../test_helper")
|
|
2
|
+
require 'artoo/drivers/led'
|
|
3
|
+
|
|
4
|
+
describe Artoo::Drivers::Led do
|
|
5
|
+
before do
|
|
6
|
+
@device = mock('device')
|
|
7
|
+
@pin = 13
|
|
8
|
+
@device.stubs(:pin).returns(@pin)
|
|
9
|
+
@led = Artoo::Drivers::Led.new(:parent => @device)
|
|
10
|
+
@connection = mock('connection')
|
|
11
|
+
@device.stubs(:connection).returns(@connection)
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
it 'Led#is_on? default' do
|
|
15
|
+
@led.is_on?.must_equal false
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it 'Led#is_off? default' do
|
|
19
|
+
@led.is_off?.must_equal true
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it 'Led#on' do
|
|
23
|
+
@connection.expects(:set_pin_mode).with(@pin, Firmata::Board::OUTPUT)
|
|
24
|
+
@connection.expects(:digital_write).with(@pin, Firmata::Board::HIGH)
|
|
25
|
+
@led.on
|
|
26
|
+
@led.is_on?.must_equal true
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
it 'Led#off' do
|
|
30
|
+
@connection.expects(:set_pin_mode).with(@pin, Firmata::Board::OUTPUT)
|
|
31
|
+
@connection.expects(:digital_write).with(@pin, Firmata::Board::LOW)
|
|
32
|
+
@led.off
|
|
33
|
+
@led.is_off?.must_equal true
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
it 'Led#toggle' do
|
|
37
|
+
@connection.stubs(:set_pin_mode)
|
|
38
|
+
@connection.stubs(:digital_write)
|
|
39
|
+
@led.is_off?.must_equal true
|
|
40
|
+
@led.toggle
|
|
41
|
+
@led.is_on?.must_equal true
|
|
42
|
+
@led.toggle
|
|
43
|
+
@led.is_off?.must_equal true
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it 'Led#brightness' do
|
|
47
|
+
val = 100
|
|
48
|
+
@connection.expects(:set_pin_mode).with(@pin, Firmata::Board::PWM)
|
|
49
|
+
@connection.expects(:analog_write).with(@pin, val)
|
|
50
|
+
@led.brightness(val)
|
|
51
|
+
end
|
|
52
|
+
end
|