reflexion 0.1.20 → 0.1.24
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.doc/ext/reflex/capture_event.cpp +6 -5
- data/.doc/ext/reflex/contact_event.cpp +18 -16
- data/.doc/ext/reflex/draw_event.cpp +10 -8
- data/.doc/ext/reflex/event.cpp +10 -10
- data/.doc/ext/reflex/focus_event.cpp +18 -17
- data/.doc/ext/reflex/frame_event.cpp +17 -17
- data/.doc/ext/reflex/key_event.cpp +227 -28
- data/.doc/ext/reflex/native.cpp +2 -0
- data/.doc/ext/reflex/pointer.cpp +158 -0
- data/.doc/ext/reflex/pointer_event.cpp +32 -91
- data/.doc/ext/reflex/scroll_event.cpp +14 -17
- data/.doc/ext/reflex/selector.cpp +8 -0
- data/.doc/ext/reflex/timer.cpp +9 -1
- data/.doc/ext/reflex/timer_event.cpp +4 -13
- data/.doc/ext/reflex/update_event.cpp +6 -5
- data/.doc/ext/reflex/view.cpp +57 -0
- data/.doc/ext/reflex/wheel_event.cpp +39 -22
- data/.doc/ext/reflex/window.cpp +41 -0
- data/VERSION +1 -1
- data/ext/reflex/capture_event.cpp +6 -5
- data/ext/reflex/contact_event.cpp +18 -16
- data/ext/reflex/draw_event.cpp +9 -7
- data/ext/reflex/event.cpp +11 -11
- data/ext/reflex/focus_event.cpp +18 -17
- data/ext/reflex/frame_event.cpp +16 -16
- data/ext/reflex/key_event.cpp +228 -28
- data/ext/reflex/native.cpp +2 -0
- data/ext/reflex/pointer.cpp +170 -0
- data/ext/reflex/pointer_event.cpp +31 -96
- data/ext/reflex/scroll_event.cpp +15 -18
- data/ext/reflex/selector.cpp +9 -0
- data/ext/reflex/timer.cpp +15 -6
- data/ext/reflex/timer_event.cpp +9 -19
- data/ext/reflex/update_event.cpp +6 -5
- data/ext/reflex/view.cpp +67 -3
- data/ext/reflex/wheel_event.cpp +40 -21
- data/ext/reflex/window.cpp +49 -3
- data/include/reflex/defs.h +140 -106
- data/include/reflex/event.h +232 -124
- data/include/reflex/pointer.h +107 -0
- data/include/reflex/ruby/pointer.h +41 -0
- data/include/reflex/ruby/view.h +9 -0
- data/include/reflex/ruby/window.h +9 -0
- data/include/reflex/selector.h +1 -1
- data/include/reflex/shape.h +2 -2
- data/include/reflex/view.h +6 -4
- data/include/reflex/window.h +14 -8
- data/lib/reflex/application.rb +3 -3
- data/lib/reflex/autoinit.rb +1 -1
- data/lib/reflex/button.rb +7 -7
- data/lib/reflex/capture_event.rb +7 -7
- data/lib/reflex/contact_event.rb +10 -10
- data/lib/reflex/draw_event.rb +2 -2
- data/lib/reflex/ellipse_shape.rb +2 -2
- data/lib/reflex/focus_event.rb +11 -11
- data/lib/reflex/frame_event.rb +5 -5
- data/lib/reflex/helper.rb +20 -20
- data/lib/reflex/image_view.rb +2 -2
- data/lib/reflex/key_event.rb +12 -12
- data/lib/reflex/model.rb +22 -22
- data/lib/reflex/model_owner.rb +7 -7
- data/lib/reflex/model_view.rb +1 -1
- data/lib/reflex/module.rb +5 -5
- data/lib/reflex/pointer.rb +107 -0
- data/lib/reflex/pointer_event.rb +16 -54
- data/lib/reflex/polygon_shape.rb +2 -2
- data/lib/reflex/reflex.rb +3 -3
- data/lib/reflex/scroll_event.rb +1 -1
- data/lib/reflex/selector.rb +4 -4
- data/lib/reflex/shape.rb +13 -13
- data/lib/reflex/style.rb +11 -11
- data/lib/reflex/style_length.rb +1 -1
- data/lib/reflex/text_view.rb +2 -2
- data/lib/reflex/timer.rb +2 -2
- data/lib/reflex/timer_event.rb +3 -2
- data/lib/reflex/update_event.rb +1 -1
- data/lib/reflex/view.rb +32 -32
- data/lib/reflex/wheel_event.rb +2 -10
- data/lib/reflex/window.rb +8 -7
- data/lib/reflex.rb +1 -0
- data/lib/reflexion.rb +17 -17
- data/reflex.gemspec +5 -5
- data/samples/reflexion/noise.rb +1 -1
- data/samples/tree.rb +1 -1
- data/src/event.cpp +792 -86
- data/src/event.h +47 -0
- data/src/image_view.cpp +2 -2
- data/src/ios/event.h +15 -3
- data/src/ios/event.mm +126 -11
- data/src/ios/view_controller.mm +51 -23
- data/src/ios/window.mm +18 -0
- data/src/osx/event.h +15 -4
- data/src/osx/event.mm +214 -24
- data/src/osx/native_window.mm +85 -18
- data/src/osx/window.mm +22 -0
- data/src/pointer.cpp +203 -0
- data/src/pointer.h +26 -0
- data/src/selector.cpp +1 -1
- data/src/shape.cpp +11 -13
- data/src/shape.h +1 -1
- data/src/view.cpp +205 -118
- data/src/view.h +5 -10
- data/src/window.cpp +346 -104
- data/src/window.h +28 -3
- data/src/world.cpp +6 -4
- data/test/helper.rb +3 -3
- data/test/test_application.rb +1 -1
- data/test/test_capture_event.rb +22 -6
- data/test/test_contact_event.rb +40 -0
- data/test/test_draw_event.rb +35 -0
- data/test/test_event.rb +33 -5
- data/test/test_focus_event.rb +34 -0
- data/test/test_frame_event.rb +38 -0
- data/test/test_has_frame.rb +11 -11
- data/test/test_key_event.rb +33 -0
- data/test/test_pointer.rb +149 -0
- data/test/test_pointer_event.rb +70 -104
- data/test/test_reflex.rb +1 -1
- data/test/test_scroll_event.rb +39 -0
- data/test/test_selector.rb +15 -8
- data/test/test_shape.rb +8 -8
- data/test/test_style.rb +13 -13
- data/test/test_style_length.rb +5 -5
- data/test/test_timer_event.rb +38 -0
- data/test/test_update_event.rb +29 -0
- data/test/test_view.rb +57 -30
- data/test/test_wheel_event.rb +40 -0
- data/test/test_window.rb +45 -26
- metadata +64 -35
@@ -0,0 +1,39 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
require_relative 'helper'
|
5
|
+
|
6
|
+
|
7
|
+
class TestScrollEvent < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def event(*args)
|
10
|
+
Reflex::ScrollEvent.new(*args)
|
11
|
+
end
|
12
|
+
|
13
|
+
def point(*args)
|
14
|
+
Rays::Point.new(*args)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_initialize()
|
18
|
+
e = event 1, 2, 3, 4, 5, 6
|
19
|
+
assert_equal 1, e.x
|
20
|
+
assert_equal 2, e.y
|
21
|
+
assert_equal 3, e.z
|
22
|
+
assert_equal 4, e.dx
|
23
|
+
assert_equal 5, e.dy
|
24
|
+
assert_equal 6, e.dz
|
25
|
+
assert_equal point(1, 2, 3), e. scroll
|
26
|
+
assert_equal point(4, 5, 6), e.dscroll
|
27
|
+
end
|
28
|
+
|
29
|
+
def test_dup()
|
30
|
+
e1 = event 1, 2, 3, 4, 5, 6
|
31
|
+
e2 = e1.dup
|
32
|
+
e1.block
|
33
|
+
e3 = e1.dup
|
34
|
+
assert_true e1.blocked?
|
35
|
+
assert_false e2.blocked?
|
36
|
+
assert_true e3.blocked?
|
37
|
+
end
|
38
|
+
|
39
|
+
end# TestScrollEvent
|
data/test/test_selector.rb
CHANGED
@@ -6,11 +6,11 @@ require_relative 'helper'
|
|
6
6
|
|
7
7
|
class TestSelector < Test::Unit::TestCase
|
8
8
|
|
9
|
-
def sel
|
10
|
-
Reflex::Selector.new
|
9
|
+
def sel(*args, &block)
|
10
|
+
Reflex::Selector.new(*args, &block)
|
11
11
|
end
|
12
12
|
|
13
|
-
def test_initialize
|
13
|
+
def test_initialize()
|
14
14
|
assert_equal 'A', sel(name: :A).name
|
15
15
|
assert_equal 'B', sel(name: :A){set name: :B}.name
|
16
16
|
assert_equal %w[T1], sel(tag: :T1 ).tags.to_a
|
@@ -19,14 +19,14 @@ class TestSelector < Test::Unit::TestCase
|
|
19
19
|
assert_equal %w[T1 T2], sel(tags: [:T1, :T2]).tags.to_a
|
20
20
|
end
|
21
21
|
|
22
|
-
def test_name
|
22
|
+
def test_name()
|
23
23
|
s = sel
|
24
24
|
assert_equal nil, s.name
|
25
25
|
s.name = 'Test'
|
26
26
|
assert_equal 'Test', s.name
|
27
27
|
end
|
28
28
|
|
29
|
-
def test_tags
|
29
|
+
def test_tags()
|
30
30
|
s = sel
|
31
31
|
assert_equal [], s.tags.to_a
|
32
32
|
s.tag 'A'
|
@@ -40,13 +40,20 @@ class TestSelector < Test::Unit::TestCase
|
|
40
40
|
assert_equal %w[a d], s.tags.map(&:downcase).to_a
|
41
41
|
end
|
42
42
|
|
43
|
-
def test_clear_tags
|
43
|
+
def test_clear_tags()
|
44
44
|
s = sel tag: [:T1, :T2]
|
45
45
|
s.clear_tags
|
46
46
|
assert_equal [], s.tags.to_a
|
47
47
|
end
|
48
48
|
|
49
|
-
def
|
49
|
+
def test_empty()
|
50
|
+
assert_equal true, sel .empty?
|
51
|
+
assert_equal false, sel(name: :A ).empty?
|
52
|
+
assert_equal false, sel( tag: :T).empty?
|
53
|
+
assert_equal false, sel(name: :A, tag: :T).empty?
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_contains()
|
50
57
|
assert_not sel.contains(sel name: :A, tag: :T)
|
51
58
|
assert sel(name: :A).contains(sel name: :A)
|
52
59
|
assert_not sel(name: :A).contains(sel name: :B)
|
@@ -61,7 +68,7 @@ class TestSelector < Test::Unit::TestCase
|
|
61
68
|
assert_not sel(tag: :T1).contains(sel name: :A, tag: :T1)
|
62
69
|
end
|
63
70
|
|
64
|
-
def test_compare
|
71
|
+
def test_compare()
|
65
72
|
assert_equal sel(name: :A), sel(name: :A)
|
66
73
|
assert_not_equal sel(name: :A), sel(name: :X)
|
67
74
|
assert_equal sel(tag: [:A, :B]), sel(tag: [:A, :B])
|
data/test/test_shape.rb
CHANGED
@@ -6,11 +6,11 @@ require_relative 'helper'
|
|
6
6
|
|
7
7
|
class TestShape < Test::Unit::TestCase
|
8
8
|
|
9
|
-
def shape
|
10
|
-
Reflex::RectShape.new
|
9
|
+
def shape(*args, &block)
|
10
|
+
Reflex::RectShape.new(*args, &block)
|
11
11
|
end
|
12
12
|
|
13
|
-
def test_density
|
13
|
+
def test_density()
|
14
14
|
s = shape
|
15
15
|
assert_equal 0, s.density
|
16
16
|
s.density = 1
|
@@ -19,7 +19,7 @@ class TestShape < Test::Unit::TestCase
|
|
19
19
|
assert_equal 2, s.density
|
20
20
|
end
|
21
21
|
|
22
|
-
def test_friction
|
22
|
+
def test_friction()
|
23
23
|
s = shape
|
24
24
|
assert_equal 0, s.friction
|
25
25
|
s.friction = 1
|
@@ -28,7 +28,7 @@ class TestShape < Test::Unit::TestCase
|
|
28
28
|
assert_equal 2, s.friction
|
29
29
|
end
|
30
30
|
|
31
|
-
def test_restitution
|
31
|
+
def test_restitution()
|
32
32
|
s = shape
|
33
33
|
assert_equal 0, s.restitution
|
34
34
|
s.restitution = 1
|
@@ -37,7 +37,7 @@ class TestShape < Test::Unit::TestCase
|
|
37
37
|
assert_equal 2, s.restitution
|
38
38
|
end
|
39
39
|
|
40
|
-
def test_sensor
|
40
|
+
def test_sensor()
|
41
41
|
s = shape
|
42
42
|
assert_equal false, s.sensor?
|
43
43
|
s.sensor = true
|
@@ -46,7 +46,7 @@ class TestShape < Test::Unit::TestCase
|
|
46
46
|
assert_equal false, s.sensor?
|
47
47
|
end
|
48
48
|
|
49
|
-
def test_category
|
49
|
+
def test_category()
|
50
50
|
s = shape
|
51
51
|
assert_equal 0b1, s.category_bits
|
52
52
|
s.category_bits = 0b1010
|
@@ -57,7 +57,7 @@ class TestShape < Test::Unit::TestCase
|
|
57
57
|
assert_equal 0b1100, s.category_bits
|
58
58
|
end
|
59
59
|
|
60
|
-
def test_collision
|
60
|
+
def test_collision()
|
61
61
|
s = shape
|
62
62
|
assert_equal 0xffff, s.collision_mask
|
63
63
|
s.collision_mask = 0b1010
|
data/test/test_style.rb
CHANGED
@@ -6,15 +6,15 @@ require_relative 'helper'
|
|
6
6
|
|
7
7
|
class TestStyle < Test::Unit::TestCase
|
8
8
|
|
9
|
-
def style
|
10
|
-
Reflex::Style.new
|
9
|
+
def style(*args, &block)
|
10
|
+
Reflex::Style.new(*args, &block)
|
11
11
|
end
|
12
12
|
|
13
|
-
def color
|
14
|
-
Reflex::Color.new
|
13
|
+
def color(*args)
|
14
|
+
Reflex::Color.new(*args)
|
15
15
|
end
|
16
16
|
|
17
|
-
def setup
|
17
|
+
def setup()
|
18
18
|
{
|
19
19
|
rgb100: color(1, 0, 0),
|
20
20
|
rgb010: color(0, 1, 0)
|
@@ -23,18 +23,18 @@ class TestStyle < Test::Unit::TestCase
|
|
23
23
|
end
|
24
24
|
end
|
25
25
|
|
26
|
-
def test_initialize
|
26
|
+
def test_initialize()
|
27
27
|
assert_equal nil, style.name
|
28
28
|
assert_equal 'A', style(name: :A).name
|
29
29
|
assert_equal 'A', style{self.name = :A}.name
|
30
30
|
end
|
31
31
|
|
32
|
-
def test_selector
|
32
|
+
def test_selector()
|
33
33
|
assert_equal 'A', style(name: :A).selector.name
|
34
34
|
assert_equal %w[T], style(tag: :T).selector.tags.to_a
|
35
35
|
end
|
36
36
|
|
37
|
-
def test_flow
|
37
|
+
def test_flow()
|
38
38
|
s = style
|
39
39
|
assert_equal [:none, :none], s.flow
|
40
40
|
|
@@ -57,12 +57,12 @@ class TestStyle < Test::Unit::TestCase
|
|
57
57
|
assert_raise(ArgumentError) {s.flow = [:right, :down, :none]}
|
58
58
|
end
|
59
59
|
|
60
|
-
def test_position
|
60
|
+
def test_position()
|
61
61
|
s = style
|
62
62
|
assert_equal [0, 0, 0, 0], s.position.map(&:value)
|
63
63
|
end
|
64
64
|
|
65
|
-
def test_margin_padding
|
65
|
+
def test_margin_padding()
|
66
66
|
s = style
|
67
67
|
|
68
68
|
assert_equal [0, 0, 0, 0], s.margin.to_a.map(&:value)
|
@@ -90,7 +90,7 @@ class TestStyle < Test::Unit::TestCase
|
|
90
90
|
=end
|
91
91
|
end
|
92
92
|
|
93
|
-
def test_foreground
|
93
|
+
def test_foreground()
|
94
94
|
s, white, transp = style, color(1, 1, 1, 1), color(0, 0, 0, 0)
|
95
95
|
|
96
96
|
assert_equal white, s.foreground_fill
|
@@ -112,7 +112,7 @@ class TestStyle < Test::Unit::TestCase
|
|
112
112
|
assert_equal [color(1, 0, 0), color(0, 1, 0)], s.foreground
|
113
113
|
end
|
114
114
|
|
115
|
-
def test_background
|
115
|
+
def test_background()
|
116
116
|
s, transp = style, color(0, 0, 0, 0)
|
117
117
|
|
118
118
|
assert_equal transp, s.background_fill
|
@@ -134,7 +134,7 @@ class TestStyle < Test::Unit::TestCase
|
|
134
134
|
assert_equal [color(1, 0, 0), color(0, 1, 0)], s.background
|
135
135
|
end
|
136
136
|
|
137
|
-
def test_image
|
137
|
+
def test_image()
|
138
138
|
assert_equal nil, style.image
|
139
139
|
end
|
140
140
|
|
data/test/test_style_length.rb
CHANGED
@@ -6,11 +6,11 @@ require_relative 'helper'
|
|
6
6
|
|
7
7
|
class TestStyleLength < Test::Unit::TestCase
|
8
8
|
|
9
|
-
def len
|
10
|
-
Reflex::StyleLength.new
|
9
|
+
def len(*args, &block)
|
10
|
+
Reflex::StyleLength.new(*args, &block)
|
11
11
|
end
|
12
12
|
|
13
|
-
def test_initialize
|
13
|
+
def test_initialize()
|
14
14
|
assert_equal nil, len.type
|
15
15
|
assert_equal 0, len.value
|
16
16
|
|
@@ -48,7 +48,7 @@ class TestStyleLength < Test::Unit::TestCase
|
|
48
48
|
assert_raise(ArgumentError) {len 'fit 0.5'}
|
49
49
|
end
|
50
50
|
|
51
|
-
def test_to_s
|
51
|
+
def test_to_s()
|
52
52
|
assert_equal '', len.to_s
|
53
53
|
assert_equal '', len(nil).to_s
|
54
54
|
assert_equal '100px', len('100px').to_s
|
@@ -59,7 +59,7 @@ class TestStyleLength < Test::Unit::TestCase
|
|
59
59
|
assert_equal '0.5fill', len('0.5 fill').to_s
|
60
60
|
end
|
61
61
|
|
62
|
-
def test_inspect
|
62
|
+
def test_inspect()
|
63
63
|
assert_nothing_raised {len.inspect}
|
64
64
|
end
|
65
65
|
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
require_relative 'helper'
|
5
|
+
|
6
|
+
|
7
|
+
class TestTimerEvent < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def event(*args)
|
10
|
+
Reflex::TimerEvent.new(*args)
|
11
|
+
end
|
12
|
+
|
13
|
+
def timer(seconds = 0, count = 1)
|
14
|
+
Reflex::View.new.timeout(seconds, count: count)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_initialize()
|
18
|
+
t = timer 1, 2
|
19
|
+
e = event t
|
20
|
+
assert_equal t, e.timer
|
21
|
+
assert_equal t.owner, e.owner
|
22
|
+
assert_equal t.id, e.id
|
23
|
+
assert_equal 1, e.interval
|
24
|
+
assert_equal 2, e.count
|
25
|
+
assert_false e.finished?
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_dup()
|
29
|
+
e1 = event timer
|
30
|
+
e2 = e1.dup
|
31
|
+
e1.block
|
32
|
+
e3 = e1.dup
|
33
|
+
assert_true e1.blocked?
|
34
|
+
assert_false e2.blocked?
|
35
|
+
assert_true e3.blocked?
|
36
|
+
end
|
37
|
+
|
38
|
+
end# TestTimerEvent
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
require_relative 'helper'
|
5
|
+
|
6
|
+
|
7
|
+
class TestUpdateEvent < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def event(*args)
|
10
|
+
Reflex::UpdateEvent.new(*args)
|
11
|
+
end
|
12
|
+
|
13
|
+
def test_initialize()
|
14
|
+
e = event 1, 2
|
15
|
+
assert_equal 1, e.now
|
16
|
+
assert_equal 2, e.dt
|
17
|
+
end
|
18
|
+
|
19
|
+
def test_dup()
|
20
|
+
e1 = event 1, 2
|
21
|
+
e2 = e1.dup
|
22
|
+
e1.block
|
23
|
+
e3 = e1.dup
|
24
|
+
assert_true e1.blocked?
|
25
|
+
assert_false e2.blocked?
|
26
|
+
assert_true e3.blocked?
|
27
|
+
end
|
28
|
+
|
29
|
+
end# TestUpdateEvent
|
data/test/test_view.rb
CHANGED
@@ -6,26 +6,30 @@ require_relative 'helper'
|
|
6
6
|
|
7
7
|
class TestView < Test::Unit::TestCase
|
8
8
|
|
9
|
-
def view
|
10
|
-
Reflex::View.new
|
9
|
+
def view(*a, **k, &b)
|
10
|
+
Reflex::View.new(*a, **k, &b)
|
11
11
|
end
|
12
12
|
|
13
|
-
def
|
14
|
-
Reflex::
|
13
|
+
def window(*a, **k, &b)
|
14
|
+
Reflex::Window.new(*a, **k, &b)
|
15
15
|
end
|
16
16
|
|
17
|
-
def
|
18
|
-
Reflex::
|
17
|
+
def style(*a, **k, &b)
|
18
|
+
Reflex::Style.new(*a, **k, &b)
|
19
19
|
end
|
20
20
|
|
21
|
-
def
|
22
|
-
Reflex::
|
21
|
+
def shape(*a, **k, &b)
|
22
|
+
Reflex::RectShape.new(*a, **k, &b)
|
23
23
|
end
|
24
24
|
|
25
|
-
def
|
26
|
-
|
25
|
+
def selector(*a, **k, &b)
|
26
|
+
Reflex::Selector.new(*a, **k, &b)
|
27
|
+
end
|
28
|
+
|
29
|
+
def point(*a) Rays::Point.new(*a) end
|
30
|
+
def bounds(*a) Rays::Bounds.new(*a) end
|
27
31
|
|
28
|
-
def
|
32
|
+
def test_show_hide_hidden()
|
29
33
|
v = view
|
30
34
|
assert_equal false, v.hidden?
|
31
35
|
v.hide
|
@@ -34,7 +38,7 @@ class TestView < Test::Unit::TestCase
|
|
34
38
|
assert_equal false, v.hidden?
|
35
39
|
end
|
36
40
|
|
37
|
-
def test_hidden_count
|
41
|
+
def test_hidden_count()
|
38
42
|
v = view
|
39
43
|
v.show
|
40
44
|
assert_equal false, v.hidden?
|
@@ -44,7 +48,30 @@ class TestView < Test::Unit::TestCase
|
|
44
48
|
assert_equal true, v.hidden?
|
45
49
|
end
|
46
50
|
|
47
|
-
def
|
51
|
+
def test_coord_conversion()
|
52
|
+
w = window x: 100, y: 200
|
53
|
+
v1 = view x: 10, y: 20
|
54
|
+
v2 = view x: 1, y: 2
|
55
|
+
|
56
|
+
assert_raise(Rucy::NativeError) {v2.from_parent 0}
|
57
|
+
assert_raise(Rucy::NativeError) {v2. to_parent 0}
|
58
|
+
assert_raise(Rucy::NativeError) {v2.from_window 0}
|
59
|
+
assert_raise(Rucy::NativeError) {v2. to_window 0}
|
60
|
+
assert_raise(Rucy::NativeError) {v2.from_screen 0}
|
61
|
+
assert_raise(Rucy::NativeError) {v2. to_screen 0}
|
62
|
+
|
63
|
+
w .add v1
|
64
|
+
v1.add v2
|
65
|
+
|
66
|
+
assert_equal [4, 3], v2.from_parent(5) .to_a
|
67
|
+
assert_equal [6, 7], v2. to_parent(5) .to_a
|
68
|
+
assert_equal [39, 28], v2.from_window(50) .to_a
|
69
|
+
assert_equal [61, 72], v2. to_window(50) .to_a
|
70
|
+
assert_equal [389, 278], v2.from_screen(500).to_a
|
71
|
+
assert_equal [611, 722], v2. to_screen(500).to_a
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_add_child()
|
48
75
|
assert_raise(ArgumentError) {view.add_child}
|
49
76
|
assert_raise(TypeError) {view.add_child nil}
|
50
77
|
assert_raise(TypeError) {view.add_child 1}
|
@@ -53,7 +80,7 @@ class TestView < Test::Unit::TestCase
|
|
53
80
|
assert_nothing_raised {v.add_child view}
|
54
81
|
end
|
55
82
|
|
56
|
-
def test_remove_child
|
83
|
+
def test_remove_child()
|
57
84
|
assert_raise(ArgumentError) {view.remove_child}
|
58
85
|
assert_raise(TypeError) {view.remove_child nil}
|
59
86
|
assert_raise(TypeError) {view.remove_child 1}
|
@@ -64,13 +91,13 @@ class TestView < Test::Unit::TestCase
|
|
64
91
|
assert_nothing_raised {v.remove_child child}
|
65
92
|
end
|
66
93
|
|
67
|
-
def test_find_children
|
94
|
+
def test_find_children()
|
68
95
|
v = view
|
69
96
|
v.add_child child = view(:name => :Test)
|
70
97
|
assert_equal [child], v.find_children(:Test)
|
71
98
|
end
|
72
99
|
|
73
|
-
def test_children
|
100
|
+
def test_children()
|
74
101
|
me = self
|
75
102
|
v = view
|
76
103
|
v.add view{set name: '1'}
|
@@ -78,7 +105,7 @@ class TestView < Test::Unit::TestCase
|
|
78
105
|
assert_equal %w[1 2], v.children.map(&:name)
|
79
106
|
end
|
80
107
|
|
81
|
-
def test_style
|
108
|
+
def test_style()
|
82
109
|
v = view
|
83
110
|
s = v.style
|
84
111
|
assert_equal 0, s.margin_left.value
|
@@ -91,7 +118,7 @@ class TestView < Test::Unit::TestCase
|
|
91
118
|
assert_equal '100px', s.margin_left.to_s
|
92
119
|
end
|
93
120
|
|
94
|
-
def test_add_remove_style
|
121
|
+
def test_add_remove_style()
|
95
122
|
v, s = view, style(name: :N)
|
96
123
|
assert_equal 0, v.styles.to_a.size
|
97
124
|
|
@@ -104,7 +131,7 @@ class TestView < Test::Unit::TestCase
|
|
104
131
|
assert_not_includes v.find_styles(selector name: :N), s
|
105
132
|
end
|
106
133
|
|
107
|
-
def test_shape
|
134
|
+
def test_shape()
|
108
135
|
s = shape
|
109
136
|
assert_equal 0, s.density
|
110
137
|
s.density = 1
|
@@ -127,7 +154,7 @@ class TestView < Test::Unit::TestCase
|
|
127
154
|
assert_raise(Rucy::NativeError) {v.density = 3}
|
128
155
|
end
|
129
156
|
|
130
|
-
def test_content_bounds_with_shapes
|
157
|
+
def test_content_bounds_with_shapes()
|
131
158
|
v = view
|
132
159
|
assert_equal Reflex::Bounds.invalid, v.content_bounds
|
133
160
|
|
@@ -153,7 +180,7 @@ class TestView < Test::Unit::TestCase
|
|
153
180
|
assert_equal [-10, -20, 200, 210], v.content_bounds.to_a
|
154
181
|
end
|
155
182
|
|
156
|
-
def test_add_remove_shape
|
183
|
+
def test_add_remove_shape()
|
157
184
|
s = shape name: :S
|
158
185
|
s.density = 1
|
159
186
|
assert_equal 1, s.density
|
@@ -176,7 +203,7 @@ class TestView < Test::Unit::TestCase
|
|
176
203
|
assert_equal 0, v.shapes.to_a.size
|
177
204
|
end
|
178
205
|
|
179
|
-
def test_name
|
206
|
+
def test_name()
|
180
207
|
v = view
|
181
208
|
assert_equal nil, v.name
|
182
209
|
v.name = 'A'
|
@@ -186,7 +213,7 @@ class TestView < Test::Unit::TestCase
|
|
186
213
|
assert_equal 'C', view(:name => 'C').name
|
187
214
|
end
|
188
215
|
|
189
|
-
def test_frame
|
216
|
+
def test_frame()
|
190
217
|
v = view
|
191
218
|
b = v.frame.dup
|
192
219
|
assert_equal b, v.frame
|
@@ -215,14 +242,14 @@ class TestView < Test::Unit::TestCase
|
|
215
242
|
v.frame = [bounds(1, 2, 3, 4, 5, 6)]; assert_equal [1, 2, 3, 4, 5, 6], v.frame.to_a(3)
|
216
243
|
end
|
217
244
|
|
218
|
-
def test_parent
|
245
|
+
def test_parent()
|
219
246
|
parent, child = view, view
|
220
247
|
parent.add_child child
|
221
248
|
assert_nil parent.parent
|
222
249
|
assert_equal parent, child.parent
|
223
250
|
end
|
224
251
|
|
225
|
-
def test_density
|
252
|
+
def test_density()
|
226
253
|
v = view
|
227
254
|
assert_equal 0, v.density
|
228
255
|
v.density = 1
|
@@ -231,7 +258,7 @@ class TestView < Test::Unit::TestCase
|
|
231
258
|
assert_equal 2, v.density
|
232
259
|
end
|
233
260
|
|
234
|
-
def test_friction
|
261
|
+
def test_friction()
|
235
262
|
v = view
|
236
263
|
assert_equal 0, v.friction
|
237
264
|
v.friction = 1
|
@@ -240,7 +267,7 @@ class TestView < Test::Unit::TestCase
|
|
240
267
|
assert_equal 2, v.friction
|
241
268
|
end
|
242
269
|
|
243
|
-
def test_restitution
|
270
|
+
def test_restitution()
|
244
271
|
v = view
|
245
272
|
assert_equal 0, v.restitution
|
246
273
|
v.restitution = 1
|
@@ -249,7 +276,7 @@ class TestView < Test::Unit::TestCase
|
|
249
276
|
assert_equal 2, v.restitution
|
250
277
|
end
|
251
278
|
|
252
|
-
def test_sensor
|
279
|
+
def test_sensor()
|
253
280
|
v = view
|
254
281
|
assert_equal false, v.sensor?
|
255
282
|
v.sensor = true
|
@@ -258,13 +285,13 @@ class TestView < Test::Unit::TestCase
|
|
258
285
|
assert_equal false, v.sensor?
|
259
286
|
end
|
260
287
|
|
261
|
-
def test_category
|
288
|
+
def test_category()
|
262
289
|
p, v = view, view
|
263
290
|
p.add v
|
264
291
|
assert_equal [:all], v.category
|
265
292
|
end
|
266
293
|
|
267
|
-
def test_collision
|
294
|
+
def test_collision()
|
268
295
|
p, v = view, view
|
269
296
|
p.add v
|
270
297
|
#assert_equal [:all], v.collision
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
|
3
|
+
|
4
|
+
require_relative 'helper'
|
5
|
+
|
6
|
+
|
7
|
+
class TestWheelEvent < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def event(*args)
|
10
|
+
Reflex::WheelEvent.new(*args)
|
11
|
+
end
|
12
|
+
|
13
|
+
def point(*args)
|
14
|
+
Rays::Point.new(*args)
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_initialize()
|
18
|
+
e = event 1, 2, 3, 4, 5, 6, 7
|
19
|
+
assert_equal 1, e.x
|
20
|
+
assert_equal 2, e.y
|
21
|
+
assert_equal 3, e.z
|
22
|
+
assert_equal 4, e.dx
|
23
|
+
assert_equal 5, e.dy
|
24
|
+
assert_equal 6, e.dz
|
25
|
+
assert_equal 7, e.modifiers
|
26
|
+
assert_equal point(1, 2, 3), e. position
|
27
|
+
assert_equal point(4, 5, 6), e.dposition
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_dup()
|
31
|
+
e1 = event 1, 2, 3, 4, 5, 6, 7
|
32
|
+
e2 = e1.dup
|
33
|
+
e1.block
|
34
|
+
e3 = e1.dup
|
35
|
+
assert_true e1.blocked?
|
36
|
+
assert_false e2.blocked?
|
37
|
+
assert_true e3.blocked?
|
38
|
+
end
|
39
|
+
|
40
|
+
end# TestWheelEvent
|