v4l2-ruby 0.10.0 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +5 -0
- data/README.md +1 -1
- data/Rakefile +12 -3
- data/ext/v4l2/camera.c +42 -5
- data/ext/v4l2/camera.h +10 -5
- data/ext/v4l2/v4l2.c +146 -80
- data/lib/v4l2/version.rb +1 -1
- data/pkg/.gitkeep +0 -0
- data/tests/config.yml +5 -0
- data/tests/lib/config.rb +21 -0
- data/tests/lib/test_util.rb +10 -0
- data/tests/run_unit.rb +24 -0
- data/tests/template.rb +30 -0
- data/tests/unit/capture/test_start.rb +49 -0
- data/tests/unit/config/test_set_format.rb +48 -0
- data/tests/unit/config/test_set_framerate.rb +57 -0
- data/tests/unit/config/test_set_image_size.rb +85 -0
- data/tests/unit/create_object/test_simple_create.rb +53 -0
- data/tests/unit/device_info/.test_get_bus_name.rb.swp +0 -0
- data/tests/unit/device_info/test_get_bus_name.rb +34 -0
- data/tests/unit/device_info/test_get_controls.rb +92 -0
- data/tests/unit/device_info/test_get_device_name.rb +34 -0
- data/tests/unit/device_info/test_get_driver_name.rb +34 -0
- data/tests/unit/device_info/test_get_formats.rb +58 -0
- data/tests/unit/device_info/test_get_framecap.rb +56 -0
- data/tests/unit/ractor/test_ractor.rb +67 -0
- data/v4l2-ruby.gemspec +3 -3
- metadata +36 -16
data/tests/config.yml
ADDED
data/tests/lib/config.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require 'yaml'
|
5
|
+
|
6
|
+
module Config
|
7
|
+
class << self
|
8
|
+
def config
|
9
|
+
return @config ||= YAML.load_file("config.yml")
|
10
|
+
end
|
11
|
+
private :config
|
12
|
+
|
13
|
+
def device
|
14
|
+
return config["target_device"]
|
15
|
+
end
|
16
|
+
|
17
|
+
def show_data?
|
18
|
+
return config["show_data"]
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/tests/run_unit.rb
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require 'pathname'
|
5
|
+
require 'test/unit'
|
6
|
+
|
7
|
+
require_relative "lib/test_util"
|
8
|
+
require_relative "lib/config"
|
9
|
+
|
10
|
+
raise("target unit is not specified") if ARGV.empty?
|
11
|
+
|
12
|
+
ARGV.each { |arg|
|
13
|
+
target = Pathname(arg)
|
14
|
+
|
15
|
+
case
|
16
|
+
when target.file?
|
17
|
+
require_relative target
|
18
|
+
|
19
|
+
when target.directory?
|
20
|
+
target.find { |file|
|
21
|
+
require_relative file if /^test_.*\.rb$/ =~ file.basename.to_s
|
22
|
+
}
|
23
|
+
end
|
24
|
+
}
|
data/tests/template.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'v4l2'
|
6
|
+
|
7
|
+
using TestUtil
|
8
|
+
|
9
|
+
class TestXX < Test::Unit::TestCase
|
10
|
+
class << self
|
11
|
+
def startup
|
12
|
+
end
|
13
|
+
|
14
|
+
def shutdown
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup
|
19
|
+
end
|
20
|
+
|
21
|
+
def teardown
|
22
|
+
end
|
23
|
+
|
24
|
+
test "smaple" do
|
25
|
+
cam = assert_nothing_raised {klass.open(Config.device)}
|
26
|
+
|
27
|
+
ensure
|
28
|
+
cam&.close if defined? cam
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'v4l2'
|
6
|
+
|
7
|
+
using TestUtil
|
8
|
+
|
9
|
+
class TestStart < Test::Unit::TestCase
|
10
|
+
class << self
|
11
|
+
def startup
|
12
|
+
end
|
13
|
+
|
14
|
+
def shutdown
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup
|
19
|
+
end
|
20
|
+
|
21
|
+
def teardown
|
22
|
+
end
|
23
|
+
|
24
|
+
test "simple start" do
|
25
|
+
cam = assert_nothing_raised {klass.open(Config.device)}
|
26
|
+
|
27
|
+
assert_nothing_raised {
|
28
|
+
cam.start
|
29
|
+
}
|
30
|
+
|
31
|
+
assert_true(cam.ready?)
|
32
|
+
|
33
|
+
ensure
|
34
|
+
cam&.close if defined? cam
|
35
|
+
end
|
36
|
+
|
37
|
+
test "with block" do
|
38
|
+
cam = assert_nothing_raised {klass.open(Config.device)}
|
39
|
+
|
40
|
+
assert_nothing_raised {
|
41
|
+
cam.start {assert_true(cam.ready?)}
|
42
|
+
}
|
43
|
+
|
44
|
+
assert_false(cam.ready?)
|
45
|
+
|
46
|
+
ensure
|
47
|
+
cam&.close if defined? cam
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'v4l2'
|
6
|
+
|
7
|
+
using TestUtil
|
8
|
+
|
9
|
+
class TestFramerate < Test::Unit::TestCase
|
10
|
+
class << self
|
11
|
+
def startup
|
12
|
+
end
|
13
|
+
|
14
|
+
def shutdown
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup
|
19
|
+
end
|
20
|
+
|
21
|
+
def teardown
|
22
|
+
end
|
23
|
+
|
24
|
+
test "set format from capability" do
|
25
|
+
cam = assert_nothing_raised {klass.open(Config.device)}
|
26
|
+
|
27
|
+
assert_nothing_raised {
|
28
|
+
cam.support_formats.each {|fmt| cam.format = fmt.fcc}
|
29
|
+
}
|
30
|
+
|
31
|
+
ensure
|
32
|
+
cam&.close if defined? cam
|
33
|
+
end
|
34
|
+
|
35
|
+
test "set format" do
|
36
|
+
cam = assert_nothing_raised {klass.open(Config.device)}
|
37
|
+
|
38
|
+
assert_nothing_raised {cam.format = "YUYV"}
|
39
|
+
assert_nothing_raised {cam.format = :MJPG}
|
40
|
+
|
41
|
+
assert_raise_kind_of(TypeError) {cam.format = 10}
|
42
|
+
assert_raise_kind_of(TypeError) {cam.format = []}
|
43
|
+
assert_raise_kind_of(TypeError) {cam.format = {}}
|
44
|
+
|
45
|
+
ensure
|
46
|
+
cam&.close if defined? cam
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,57 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'v4l2'
|
6
|
+
|
7
|
+
using TestUtil
|
8
|
+
|
9
|
+
class TestFramerate < Test::Unit::TestCase
|
10
|
+
class << self
|
11
|
+
def startup
|
12
|
+
end
|
13
|
+
|
14
|
+
def shutdown
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup
|
19
|
+
end
|
20
|
+
|
21
|
+
def teardown
|
22
|
+
end
|
23
|
+
|
24
|
+
test "set framerate from capability" do
|
25
|
+
cam = assert_nothing_raised {klass.open(Config.device)}
|
26
|
+
|
27
|
+
assert_nothing_raised {
|
28
|
+
cam.support_formats.each { |fmt|
|
29
|
+
cam.frame_capabilities(fmt.fcc).each { |cap|
|
30
|
+
cap.rate.each { |rate| cam.framerate = rate}
|
31
|
+
}
|
32
|
+
}
|
33
|
+
}
|
34
|
+
|
35
|
+
ensure
|
36
|
+
cam&.close if defined? cam
|
37
|
+
end
|
38
|
+
|
39
|
+
test "set frame rate" do
|
40
|
+
cam = assert_nothing_raised {klass.open(Config.device)}
|
41
|
+
|
42
|
+
assert_nothing_raised {cam.framerate = 10}
|
43
|
+
assert_equal(1/10r, cam.framerate)
|
44
|
+
|
45
|
+
assert_nothing_raised {cam.framerate = 5.0}
|
46
|
+
assert_equal(1/5r, cam.framerate)
|
47
|
+
|
48
|
+
assert_nothing_raised {cam.framerate = 10/1r}
|
49
|
+
assert_equal(1/10r, cam.framerate)
|
50
|
+
|
51
|
+
assert_raise_kind_of(TypeError) {cam.image_width = "10"}
|
52
|
+
assert_raise_kind_of(TypeError) {cam.image_width = :"10"}
|
53
|
+
|
54
|
+
ensure
|
55
|
+
cam&.close if defined? cam
|
56
|
+
end
|
57
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'v4l2'
|
6
|
+
|
7
|
+
using TestUtil
|
8
|
+
|
9
|
+
class TestImageSize < Test::Unit::TestCase
|
10
|
+
class << self
|
11
|
+
def startup
|
12
|
+
end
|
13
|
+
|
14
|
+
def shutdown
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup
|
19
|
+
end
|
20
|
+
|
21
|
+
def teardown
|
22
|
+
end
|
23
|
+
|
24
|
+
test "set image size from capability list" do
|
25
|
+
cam = assert_nothing_raised {klass.open(Config.device)}
|
26
|
+
|
27
|
+
assert_nothing_raised {
|
28
|
+
cam.support_formats.each { |fmt|
|
29
|
+
cam.frame_capabilities(:MJPEG).each { |cap|
|
30
|
+
cam.image_width = cap.width
|
31
|
+
cam.image_height = cap.height
|
32
|
+
}
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
36
|
+
ensure
|
37
|
+
cam&.close if defined? cam
|
38
|
+
end
|
39
|
+
|
40
|
+
test "set width" do
|
41
|
+
cam = assert_nothing_raised {klass.open(Config.device)}
|
42
|
+
|
43
|
+
assert_nothing_raised {cam.image_width = 640}
|
44
|
+
assert_equal(640, cam.image_width);
|
45
|
+
|
46
|
+
assert_nothing_raised {cam.image_width = 320.0}
|
47
|
+
assert_equal(320, cam.image_width);
|
48
|
+
|
49
|
+
assert_nothing_raised {cam.image_width = 1280/2r}
|
50
|
+
assert_equal(640, cam.image_width);
|
51
|
+
|
52
|
+
assert_nothing_raised {cam.image_width = 320 + 0i}
|
53
|
+
assert_equal(320, cam.image_width);
|
54
|
+
|
55
|
+
assert_raise_kind_of(TypeError) {cam.image_width = "123"}
|
56
|
+
assert_raise_kind_of(TypeError) {cam.image_width = :A123}
|
57
|
+
assert_raise_kind_of(RangeError) {cam.image_width = 640i}
|
58
|
+
|
59
|
+
ensure
|
60
|
+
cam&.close if defined? cam
|
61
|
+
end
|
62
|
+
|
63
|
+
test "set height" do
|
64
|
+
cam = assert_nothing_raised {klass.open(Config.device)}
|
65
|
+
|
66
|
+
assert_nothing_raised {cam.image_height = 480}
|
67
|
+
assert_equal(480, cam.image_height);
|
68
|
+
|
69
|
+
assert_nothing_raised {cam.image_height = 240.0}
|
70
|
+
assert_equal(240, cam.image_height);
|
71
|
+
|
72
|
+
assert_nothing_raised {cam.image_height = 960/2r}
|
73
|
+
assert_equal(480, cam.image_height);
|
74
|
+
|
75
|
+
assert_nothing_raised {cam.image_height = 240 + 0i}
|
76
|
+
assert_equal(240, cam.image_height);
|
77
|
+
|
78
|
+
assert_raise_kind_of(TypeError) {cam.image_width = "123"}
|
79
|
+
assert_raise_kind_of(TypeError) {cam.image_width = :A123}
|
80
|
+
assert_raise_kind_of(RangeError) {cam.image_width = 480i}
|
81
|
+
|
82
|
+
ensure
|
83
|
+
cam&.close if defined? cam
|
84
|
+
end
|
85
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'v4l2'
|
6
|
+
|
7
|
+
using TestUtil
|
8
|
+
|
9
|
+
class TestSimpleCreate < Test::Unit::TestCase
|
10
|
+
class << self
|
11
|
+
def startup
|
12
|
+
end
|
13
|
+
|
14
|
+
def shutdown
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup
|
19
|
+
end
|
20
|
+
|
21
|
+
def teardown
|
22
|
+
end
|
23
|
+
|
24
|
+
test "simple create" do
|
25
|
+
cam = assert_nothing_raised {klass.open(Config.device)}
|
26
|
+
|
27
|
+
assert_respond_to(cam, :close)
|
28
|
+
assert_respond_to(cam, :controls)
|
29
|
+
assert_respond_to(cam, :support_formats)
|
30
|
+
assert_respond_to(cam, :frame_capabilities)
|
31
|
+
assert_respond_to(cam, :set_control)
|
32
|
+
assert_respond_to(cam, :get_control)
|
33
|
+
assert_respond_to(cam, :format=)
|
34
|
+
assert_respond_to(cam, :image_width)
|
35
|
+
assert_respond_to(cam, :image_width=)
|
36
|
+
assert_respond_to(cam, :image_height)
|
37
|
+
assert_respond_to(cam, :image_height=)
|
38
|
+
assert_respond_to(cam, :framerate)
|
39
|
+
assert_respond_to(cam, :framerate=)
|
40
|
+
assert_respond_to(cam, :state)
|
41
|
+
assert_respond_to(cam, :start)
|
42
|
+
assert_respond_to(cam, :stop)
|
43
|
+
assert_respond_to(cam, :capture)
|
44
|
+
assert_respond_to(cam, :busy?)
|
45
|
+
assert_respond_to(cam, :error?)
|
46
|
+
assert_respond_to(cam, :name)
|
47
|
+
assert_respond_to(cam, :driver)
|
48
|
+
assert_respond_to(cam, :bus)
|
49
|
+
|
50
|
+
ensure
|
51
|
+
cam&.close
|
52
|
+
end
|
53
|
+
end
|
Binary file
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'v4l2'
|
6
|
+
|
7
|
+
using TestUtil
|
8
|
+
|
9
|
+
class TestGetDriverName < Test::Unit::TestCase
|
10
|
+
class << self
|
11
|
+
def startup
|
12
|
+
end
|
13
|
+
|
14
|
+
def shutdown
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup
|
19
|
+
end
|
20
|
+
|
21
|
+
def teardown
|
22
|
+
end
|
23
|
+
|
24
|
+
test "get driver name" do
|
25
|
+
cam = assert_nothing_raised {klass.open(Config.device)}
|
26
|
+
|
27
|
+
cam.bus if Config.show_data?
|
28
|
+
|
29
|
+
assert_kind_of(String, cam.bus)
|
30
|
+
|
31
|
+
ensure
|
32
|
+
cam&.close
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,92 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'v4l2'
|
6
|
+
|
7
|
+
using TestUtil
|
8
|
+
|
9
|
+
class TestGetControls < Test::Unit::TestCase
|
10
|
+
class << self
|
11
|
+
def startup
|
12
|
+
end
|
13
|
+
|
14
|
+
def shutdown
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup
|
19
|
+
end
|
20
|
+
|
21
|
+
def teardown
|
22
|
+
end
|
23
|
+
|
24
|
+
test "get controls" do
|
25
|
+
cam = assert_nothing_raised {klass.open(Config.device)}
|
26
|
+
|
27
|
+
dat = cam.controls
|
28
|
+
|
29
|
+
pp dat if Config.show_data?
|
30
|
+
|
31
|
+
assert_kind_of(Array, dat)
|
32
|
+
assert_true(dat.all? {|item| item.kind_of?(klass::Control)})
|
33
|
+
|
34
|
+
ensure
|
35
|
+
cam&.close
|
36
|
+
end
|
37
|
+
|
38
|
+
test "atributes" do
|
39
|
+
cam = assert_nothing_raised {klass.open(Config.device)}
|
40
|
+
|
41
|
+
cam.controls.each { |item|
|
42
|
+
case item
|
43
|
+
when klass::IntegerControl
|
44
|
+
assert_respond_to(item, :name)
|
45
|
+
assert_respond_to(item, :id)
|
46
|
+
assert_respond_to(item, :min)
|
47
|
+
assert_respond_to(item, :max)
|
48
|
+
assert_respond_to(item, :step)
|
49
|
+
assert_respond_to(item, :default)
|
50
|
+
|
51
|
+
assert_kind_of(String, item.name)
|
52
|
+
assert_kind_of(Integer, item.id)
|
53
|
+
assert_kind_of(Integer, item.min)
|
54
|
+
assert_kind_of(Integer, item.max)
|
55
|
+
assert_kind_of(Integer, item.step)
|
56
|
+
assert_kind_of(Integer, item.default)
|
57
|
+
|
58
|
+
when klass::BooleanControl
|
59
|
+
assert_respond_to(item, :name)
|
60
|
+
assert_respond_to(item, :id)
|
61
|
+
assert_respond_to(item, :default)
|
62
|
+
|
63
|
+
assert_kind_of(String, item.name)
|
64
|
+
assert_kind_of(Integer, item.id)
|
65
|
+
assert_boolean(item.default)
|
66
|
+
|
67
|
+
when klass::MenuControl
|
68
|
+
assert_respond_to(item, :name)
|
69
|
+
assert_respond_to(item, :id)
|
70
|
+
assert_respond_to(item, :items)
|
71
|
+
assert_respond_to(item, :default)
|
72
|
+
|
73
|
+
assert_kind_of(String, item.name)
|
74
|
+
assert_kind_of(Integer, item.id)
|
75
|
+
assert_kind_of(Array, item.items)
|
76
|
+
|
77
|
+
item.items.each {|mi|
|
78
|
+
assert_respond_to(mi, :name)
|
79
|
+
assert_respond_to(mi, :index)
|
80
|
+
assert_kind_of(String, mi.name)
|
81
|
+
assert_kind_of(Integer, mi.index)
|
82
|
+
}
|
83
|
+
|
84
|
+
else
|
85
|
+
add_failure("found unknown controls item")
|
86
|
+
end
|
87
|
+
}
|
88
|
+
|
89
|
+
ensure
|
90
|
+
cam&.close
|
91
|
+
end
|
92
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'v4l2'
|
6
|
+
|
7
|
+
using TestUtil
|
8
|
+
|
9
|
+
class TestGetDeviceName < Test::Unit::TestCase
|
10
|
+
class << self
|
11
|
+
def startup
|
12
|
+
end
|
13
|
+
|
14
|
+
def shutdown
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup
|
19
|
+
end
|
20
|
+
|
21
|
+
def teardown
|
22
|
+
end
|
23
|
+
|
24
|
+
test "get device name" do
|
25
|
+
cam = assert_nothing_raised {klass.open(Config.device)}
|
26
|
+
|
27
|
+
p cam.name if Config.show_data?
|
28
|
+
|
29
|
+
assert_kind_of(String, cam.name)
|
30
|
+
|
31
|
+
ensure
|
32
|
+
cam&.close
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'v4l2'
|
6
|
+
|
7
|
+
using TestUtil
|
8
|
+
|
9
|
+
class TestGetDriverName < Test::Unit::TestCase
|
10
|
+
class << self
|
11
|
+
def startup
|
12
|
+
end
|
13
|
+
|
14
|
+
def shutdown
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup
|
19
|
+
end
|
20
|
+
|
21
|
+
def teardown
|
22
|
+
end
|
23
|
+
|
24
|
+
test "get driver name" do
|
25
|
+
cam = assert_nothing_raised {klass.open(Config.device)}
|
26
|
+
|
27
|
+
p cam.driver if Config.show_data?
|
28
|
+
|
29
|
+
assert_kind_of(String, cam.driver)
|
30
|
+
|
31
|
+
ensure
|
32
|
+
cam&.close
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'v4l2'
|
6
|
+
|
7
|
+
using TestUtil
|
8
|
+
|
9
|
+
class TestGetFormats < Test::Unit::TestCase
|
10
|
+
class << self
|
11
|
+
def startup
|
12
|
+
end
|
13
|
+
|
14
|
+
def shutdown
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup
|
19
|
+
end
|
20
|
+
|
21
|
+
def teardown
|
22
|
+
end
|
23
|
+
|
24
|
+
test "get formats" do
|
25
|
+
cam = assert_nothing_raised {klass.open(Config.device)}
|
26
|
+
|
27
|
+
dat = cam.support_formats
|
28
|
+
|
29
|
+
pp dat if Config.show_data?
|
30
|
+
|
31
|
+
assert_kind_of(Array, dat)
|
32
|
+
assert_true(dat.all? {|item| item.kind_of?(klass::FormatDescription)})
|
33
|
+
|
34
|
+
ensure
|
35
|
+
cam&.close
|
36
|
+
end
|
37
|
+
|
38
|
+
test "atributes" do
|
39
|
+
cam = assert_nothing_raised {klass.open(Config.device)}
|
40
|
+
|
41
|
+
cam.support_formats.each { |item|
|
42
|
+
if item.kind_of?(klass::FormatDescription)
|
43
|
+
assert_respond_to(item, :description)
|
44
|
+
assert_respond_to(item, :fcc)
|
45
|
+
|
46
|
+
assert_kind_of(String, item.description)
|
47
|
+
assert_kind_of(String, item.fcc)
|
48
|
+
assert_equal(4, item.fcc.size)
|
49
|
+
|
50
|
+
else
|
51
|
+
add_failure("found unknown format item")
|
52
|
+
end
|
53
|
+
}
|
54
|
+
|
55
|
+
ensure
|
56
|
+
cam&.close
|
57
|
+
end
|
58
|
+
end
|
@@ -0,0 +1,56 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
# coding: utf-8
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'v4l2'
|
6
|
+
|
7
|
+
using TestUtil
|
8
|
+
|
9
|
+
class TestGetFrameCapability < Test::Unit::TestCase
|
10
|
+
class << self
|
11
|
+
def startup
|
12
|
+
end
|
13
|
+
|
14
|
+
def shutdown
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def setup
|
19
|
+
end
|
20
|
+
|
21
|
+
def teardown
|
22
|
+
end
|
23
|
+
|
24
|
+
test "get framecapabilities" do
|
25
|
+
cam = assert_nothing_raised {klass.open(Config.device)}
|
26
|
+
|
27
|
+
cam.support_formats.each { |fmt|
|
28
|
+
dat = cam.frame_capabilities(fmt.fcc)
|
29
|
+
|
30
|
+
pp dat if Config.show_data?
|
31
|
+
|
32
|
+
assert_kind_of(Array, dat)
|
33
|
+
assert_true(dat.all? {|item| item.kind_of?(klass::FrameCapability)})
|
34
|
+
}
|
35
|
+
|
36
|
+
ensure
|
37
|
+
cam&.close
|
38
|
+
end
|
39
|
+
|
40
|
+
test "atributes" do
|
41
|
+
cam = assert_nothing_raised {klass.open(Config.device)}
|
42
|
+
|
43
|
+
cam.support_formats.each { |fmt|
|
44
|
+
cam.frame_capabilities(fmt.fcc).each { |item|
|
45
|
+
assert_respond_to(item, :width)
|
46
|
+
assert_respond_to(item, :height)
|
47
|
+
assert_respond_to(item, :rate)
|
48
|
+
|
49
|
+
assert_true(item.rate.all? {|e| e.kind_of?(Rational)})
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
ensure
|
54
|
+
cam&.close
|
55
|
+
end
|
56
|
+
end
|