MINT-core 1.0.1 → 2.0.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.
Files changed (214) hide show
  1. data/Gemfile +22 -3
  2. data/Gemfile.lock +98 -22
  3. data/History.txt +262 -0
  4. data/LICENSE +30 -0
  5. data/MINT-core.gemspec +25 -80
  6. data/Manifest.txt +145 -30
  7. data/README.rdoc +6 -163
  8. data/Rakefile +16 -17
  9. data/bin/mint-aui +3 -3
  10. data/bin/mint-cui-gfx +3 -2
  11. data/bin/mint-juggernaut.sh +0 -0
  12. data/bin/mint-tuplespace +0 -0
  13. data/lib/MINT-core.rb +53 -15
  14. data/lib/MINT-core/agent/agent.rb +1 -1
  15. data/lib/MINT-core/agent/aui.rb +0 -14
  16. data/lib/MINT-core/agent/auicontrol.rb +91 -38
  17. data/lib/MINT-core/agent/cui-gfx.rb +3 -3
  18. data/lib/MINT-core/agent/cuicontrol.rb +94 -24
  19. data/lib/MINT-core/connector/redis_connector.rb +16 -0
  20. data/lib/MINT-core/manager/mapping_manager.rb +101 -0
  21. data/lib/MINT-core/manager/mapping_parser.rb +89 -0
  22. data/lib/MINT-core/manager/mapping_server.rb +99 -0
  23. data/lib/MINT-core/manager/position_updater.rb +33 -0
  24. data/lib/MINT-core/manager/scxml_client.rb +118 -0
  25. data/lib/MINT-core/manager/scxml_server.rb +86 -0
  26. data/lib/MINT-core/mapping/action/action.rb +32 -0
  27. data/lib/MINT-core/mapping/action/backend_action.rb +32 -0
  28. data/lib/MINT-core/mapping/action/bind_action.rb +88 -0
  29. data/lib/MINT-core/mapping/action/event_action.rb +40 -0
  30. data/lib/MINT-core/mapping/complementary_mapping.rb +31 -0
  31. data/lib/MINT-core/mapping/mapping.rb +170 -34
  32. data/lib/MINT-core/mapping/observation/negation_observation.rb +64 -0
  33. data/lib/MINT-core/mapping/observation/observation.rb +219 -0
  34. data/lib/MINT-core/mapping/sequential.rb +1 -2
  35. data/lib/MINT-core/mapping/sequential_mapping.rb +60 -0
  36. data/lib/MINT-core/model/aui/AIChoiceElement.rb +17 -0
  37. data/lib/MINT-core/model/aui/AICommand.rb +7 -0
  38. data/lib/MINT-core/model/aui/AIContainer.rb +73 -0
  39. data/lib/MINT-core/model/aui/AIContext.rb +12 -0
  40. data/lib/MINT-core/model/aui/AIIN.rb +8 -0
  41. data/lib/MINT-core/model/aui/AIINContinuous.rb +56 -0
  42. data/lib/MINT-core/model/aui/AIINDiscrete.rb +8 -0
  43. data/lib/MINT-core/model/aui/AIMultiChoice.rb +1 -2
  44. data/lib/MINT-core/model/aui/AIMultiChoiceElement.rb +4 -51
  45. data/lib/MINT-core/model/aui/AIO.rb +76 -123
  46. data/lib/MINT-core/model/aui/AIOUT.rb +8 -0
  47. data/lib/MINT-core/model/aui/AIOUTContinuous.rb +61 -0
  48. data/lib/MINT-core/model/aui/AIReference.rb +16 -0
  49. data/lib/MINT-core/model/aui/AISingleChoice.rb +18 -1
  50. data/lib/MINT-core/model/aui/AISingleChoiceElement.rb +10 -56
  51. data/lib/MINT-core/model/aui/AISinglePresence.rb +39 -71
  52. data/lib/MINT-core/model/aui/aicommand.scxml +47 -0
  53. data/lib/MINT-core/model/aui/aicontainer.scxml +41 -0
  54. data/lib/MINT-core/model/aui/aicontext.scxml +34 -0
  55. data/lib/MINT-core/model/aui/aiincontinuous.scxml +59 -0
  56. data/lib/MINT-core/model/aui/aiinrange.scxml +86 -0
  57. data/lib/MINT-core/model/aui/aimultichoice.scxml +67 -0
  58. data/lib/MINT-core/model/aui/aimultichoiceelement.scxml +51 -0
  59. data/lib/MINT-core/model/aui/aio.scxml +18 -27
  60. data/lib/MINT-core/model/aui/aioutcontinuous.scxml +66 -0
  61. data/lib/MINT-core/model/aui/aireference.scxml +28 -0
  62. data/lib/MINT-core/model/aui/aisinglechoice.scxml +60 -0
  63. data/lib/MINT-core/model/aui/aisinglechoiceelement.scxml +45 -60
  64. data/lib/MINT-core/model/aui/aisinglepresence.scxml +15 -24
  65. data/lib/MINT-core/model/aui/model.rb +15 -38
  66. data/lib/MINT-core/model/cui/gfx/CIC.rb +34 -10
  67. data/lib/MINT-core/model/cui/gfx/CIO.rb +66 -115
  68. data/lib/MINT-core/model/cui/gfx/CarouFredSel.scxml +58 -0
  69. data/lib/MINT-core/model/cui/gfx/MarkableRadioButton.rb +8 -0
  70. data/lib/MINT-core/model/cui/gfx/RadioButton.rb +8 -0
  71. data/lib/MINT-core/model/cui/gfx/RadioButtonGroup.rb +6 -0
  72. data/lib/MINT-core/model/cui/gfx/button.rb +16 -0
  73. data/lib/MINT-core/model/cui/gfx/button.scxml +58 -0
  74. data/lib/MINT-core/model/cui/gfx/caroufredsel.rb +48 -0
  75. data/lib/MINT-core/model/cui/gfx/cic.scxml +57 -0
  76. data/lib/MINT-core/model/cui/gfx/cio.scxml +54 -0
  77. data/lib/MINT-core/model/cui/gfx/markableradiobutton.scxml +67 -0
  78. data/lib/MINT-core/model/cui/gfx/model.rb +39 -176
  79. data/lib/MINT-core/model/cui/gfx/radiobutton.scxml +59 -0
  80. data/lib/MINT-core/model/interactor.rb +167 -46
  81. data/lib/MINT-core/model/interactor.scxml +3 -0
  82. data/lib/MINT-core/model/interactor_helpers.rb +25 -0
  83. data/lib/MINT-core/model/ir/body/OneHandPoseNavigation.rb +15 -0
  84. data/lib/MINT-core/model/ir/body/body.rb +5 -0
  85. data/lib/MINT-core/model/ir/body/fingertip.rb +114 -0
  86. data/lib/MINT-core/model/ir/body/fingertip.scxml +43 -0
  87. data/lib/MINT-core/model/{body → ir/body}/gesture_button.rb +0 -0
  88. data/lib/MINT-core/model/ir/body/hand.rb +5 -0
  89. data/lib/MINT-core/model/ir/body/head.rb +102 -0
  90. data/lib/MINT-core/model/ir/body/head.scxml +92 -0
  91. data/lib/MINT-core/model/ir/body/onehandposenavigation.scxml +53 -0
  92. data/lib/MINT-core/model/ir/body/pose.rb +99 -0
  93. data/lib/MINT-core/model/ir/browserscreen.rb +27 -0
  94. data/lib/MINT-core/model/ir/browserscreen.scxml +14 -0
  95. data/lib/MINT-core/model/{device → ir}/button.rb +1 -1
  96. data/lib/MINT-core/model/ir/ir.rb +5 -0
  97. data/lib/MINT-core/model/ir/irmedia.rb +5 -0
  98. data/lib/MINT-core/model/ir/irmode.rb +5 -0
  99. data/lib/MINT-core/model/{device → ir}/joypad.rb +1 -1
  100. data/lib/MINT-core/model/ir/mouse.rb +44 -0
  101. data/lib/MINT-core/model/ir/mouse.scxml +35 -0
  102. data/lib/MINT-core/model/{device/mouse.rb → ir/mouse_old.rb} +2 -2
  103. data/lib/MINT-core/model/{device → ir}/pointer.rb +20 -22
  104. data/lib/MINT-core/model/ir/pointer.scxml +19 -0
  105. data/lib/MINT-core/model/ir/screen.rb +5 -0
  106. data/lib/MINT-core/model/{device → ir}/wheel.rb +1 -1
  107. data/lib/MINT-core/model/mim/aicommand_activate_to_button_press.xml +13 -0
  108. data/lib/MINT-core/model/mim/aicommand_deactivate_to_button_release.xml +13 -0
  109. data/lib/MINT-core/model/mim/aio_defocus_to_cio_unhighlight.xml +13 -0
  110. data/lib/MINT-core/model/mim/aio_focus_to_cio_highlight.xml +14 -0
  111. data/lib/MINT-core/model/mim/aio_present_to_cio_display.xml +14 -0
  112. data/lib/MINT-core/model/mim/aio_suspend_to_cio_hide.xml +13 -0
  113. data/lib/MINT-core/model/mim/aisinglechoice_present_to_child_present.xml +14 -0
  114. data/lib/MINT-core/model/mim/aisinglechoiceelement_chosen_to_radiobutton_select.xml +13 -0
  115. data/lib/MINT-core/model/mim/aisinglechoiceelement_unchosen_to_radiobutton_unselect.xml +13 -0
  116. data/lib/MINT-core/model/mim/aisinglepresence_children_finished_to_caroufredsel_init_js.xml +14 -0
  117. data/lib/MINT-core/model/mim/aisinglepresence_present_to_child_present.xml +15 -0
  118. data/lib/MINT-core/model/mim/browserscreen_reload_to_cuicontrol_refresh_all.xml +12 -0
  119. data/lib/MINT-core/model/mim/button_press_to_aicommand_activate.xml +12 -0
  120. data/lib/MINT-core/model/mim/button_release_to_aicommand_deactivate.xml +12 -0
  121. data/lib/MINT-core/model/mim/caroufredsel_refreshing_to_caroufredsel_init_js.xml +14 -0
  122. data/lib/MINT-core/model/mim/cio_display_to_aio_defocus.xml +13 -0
  123. data/lib/MINT-core/model/mim/cio_display_to_aio_present.xml +12 -0
  124. data/lib/MINT-core/model/mim/cio_display_to_cio_display_cache_add.xml +11 -0
  125. data/lib/MINT-core/model/mim/cio_hide_to_aio_suspend.xml +12 -0
  126. data/lib/MINT-core/model/mim/cio_hide_to_cio_display_cache_remove.xml +12 -0
  127. data/lib/MINT-core/model/mim/cio_highlight_to_aio_focus.xml +13 -0
  128. data/lib/MINT-core/model/mim/head_looking_left_to_aisinglepresence_prev.xml +14 -0
  129. data/lib/MINT-core/model/mim/head_looking_right_to_aisinglepresence_next.xml +15 -0
  130. data/lib/MINT-core/model/mim/head_nodding_to_aisinglepresence_next.xml +15 -0
  131. data/lib/MINT-core/model/mim/head_tilting_left_to_aisinglepresence_prev.xml +14 -0
  132. data/lib/MINT-core/model/mim/head_tilting_right_to_aisinglepresence_next.xml +15 -0
  133. data/lib/MINT-core/model/mim/left_button_aisinglepresence_enter.xml +15 -0
  134. data/lib/MINT-core/model/mim/left_button_aisinglepresence_next.xml +15 -0
  135. data/lib/MINT-core/model/mim/mim_default.xml +52 -0
  136. data/lib/MINT-core/model/mim/mint-mappings.xsd +127 -0
  137. data/lib/MINT-core/model/mim/mouse_press_to_aicommand_activate.xml +17 -0
  138. data/lib/MINT-core/model/mim/mouse_press_to_aisinglechoiceelement_choose.xml +17 -0
  139. data/lib/MINT-core/model/mim/mouse_press_to_aisinglechoiceelement_unchoose.xml +17 -0
  140. data/lib/MINT-core/model/mim/mouse_release_to_aicommand_deactivate.xml +16 -0
  141. data/lib/MINT-core/model/mim/mouse_stop_to_cio_highlight.xml +13 -0
  142. data/lib/MINT-core/model/mim/onehandposnav_confirm_to_aichoiceelement_choose.xml +14 -0
  143. data/lib/MINT-core/model/mim/onehandposnav_next_to_aio_next.xml +14 -0
  144. data/lib/MINT-core/model/mim/onehandposnav_previous_to_aio_prev.xml +14 -0
  145. data/lib/MINT-core/model/mim/radiobutton_selected_to_aisinglechoiceelement_choose.xml +13 -0
  146. data/lib/MINT-core/model/mim/radiobutton_unselected_to_aisinglechoiceelement_unchoose.xml +13 -0
  147. data/lib/MINT-core/model/mim/right_button_aisinglepresence_prev.xml +15 -0
  148. data/lib/MINT-core/model/task.rb +6 -6
  149. data/script/console +0 -0
  150. data/script/destroy +0 -0
  151. data/script/generate +0 -0
  152. data/spec/AICommand_spec.rb +20 -0
  153. data/spec/AIContainer_spec.rb +161 -0
  154. data/spec/AIINContinuous_spec.rb +92 -0
  155. data/spec/AIOUTContinuous_spec.rb +93 -0
  156. data/spec/AIO_spec.rb +73 -0
  157. data/spec/AIReference_spec.rb +105 -0
  158. data/spec/AISinglePresence_spec.rb +204 -60
  159. data/spec/Button_spec.rb +114 -0
  160. data/spec/CIO_spec.rb +145 -0
  161. data/spec/Interactor_spec.rb +95 -0
  162. data/spec/MappingManager_spec.rb +126 -0
  163. data/spec/Spontaneous_spec.rb +53 -0
  164. data/spec/aio_agent_spec.rb +215 -186
  165. data/spec/aisinglechoice_spec.rb +147 -88
  166. data/spec/aisinglechoiceelement_spec.rb +154 -70
  167. data/spec/complementary_mapping_spec.rb +158 -0
  168. data/spec/core_spec.rb +27 -15
  169. data/spec/cui_helper.rb +100 -0
  170. data/spec/examples/browserscreen_reload_to_cuicontrol_refresh_all.xml +12 -0
  171. data/spec/examples/mim_streaming_example.xml +9 -0
  172. data/spec/examples/mouse_highlight.xml +22 -0
  173. data/spec/examples/performance_mapping.xml +15 -0
  174. data/spec/examples/reset_click.xml +24 -0
  175. data/spec/interactor_test.scxml +32 -0
  176. data/spec/interactor_test_2.scxml +16 -0
  177. data/spec/mapping_performance_spec.rb +118 -0
  178. data/spec/mapping_server_spec.rb +161 -0
  179. data/spec/mapping_spec.rb +307 -0
  180. data/spec/music_spec.rb +301 -135
  181. data/spec/performance_counter.scxml +9 -0
  182. data/spec/sequential_mappings_spec.rb +69 -0
  183. data/spec/shared/aio_shared.rb +144 -0
  184. data/spec/spec_helper.rb +22 -3
  185. data/spec/spontaneous.scxml +11 -0
  186. data/spec/support/connection_helper.rb +19 -0
  187. data/spec/support/redis_connector_monkey_patch.rb +1 -0
  188. data/spec/support/statemachine_helper.rb +84 -0
  189. data/spec/sync_mappings_spec.rb +96 -0
  190. metadata +219 -354
  191. data/lib/MINT-core/mapping/complementary.rb +0 -100
  192. data/lib/MINT-core/mapping/on_state_change.rb +0 -65
  193. data/lib/MINT-core/model/aui/AIC.rb +0 -86
  194. data/lib/MINT-core/model/aui/AIChoice.rb +0 -65
  195. data/lib/MINT-core/model/aui/AIINChoose.rb +0 -54
  196. data/lib/MINT-core/model/aui/AIOUTDiscrete.rb +0 -43
  197. data/lib/MINT-core/model/aui/aic.png +0 -0
  198. data/lib/MINT-core/model/aui/aic.scxml +0 -50
  199. data/lib/MINT-core/model/aui/aichoice.png +0 -0
  200. data/lib/MINT-core/model/aui/aichoice.scxml +0 -60
  201. data/lib/MINT-core/model/aui/aio.png +0 -0
  202. data/lib/MINT-core/model/aui/aisinglechoiceelement.png +0 -0
  203. data/lib/MINT-core/model/aui/aisinglepresence.png +0 -0
  204. data/lib/MINT-core/model/body/handgesture.rb +0 -279
  205. data/lib/MINT-core/model/body/head.png +0 -0
  206. data/lib/MINT-core/model/body/head.rb +0 -51
  207. data/lib/MINT-core/model/body/head.scxml +0 -28
  208. data/lib/MINT-core/model/cui/gfx/screen.rb +0 -18
  209. data/lib/MINT-core/overrides/rinda.rb +0 -34
  210. data/spec/AIC_spec.rb +0 -69
  211. data/spec/MINT-core_spec.rb +0 -11
  212. data/spec/aio_spec.rb +0 -144
  213. data/spec/cio_spec.rb +0 -369
  214. data/tasks/rspec.rake +0 -21
@@ -0,0 +1,73 @@
1
+ require "spec_helper"
2
+
3
+ require "em-spec/rspec"
4
+ require File.expand_path(File.join(File.dirname(__FILE__), 'shared/aio_shared'))
5
+
6
+ describe 'AUI' do
7
+
8
+ before :each do
9
+ Redis.connect.flushall
10
+ @interactor_class = MINT::AIO
11
+ end
12
+
13
+ it_should_behave_like 'An AIO interactor'
14
+
15
+ describe 'AIO' do
16
+
17
+ it 'should call back after event has been processed' do
18
+ connect do |redis|
19
+ class CallbackContext
20
+ attr_accessor :called
21
+
22
+ def initialize
23
+ @called = false
24
+ end
25
+ def focus_next
26
+ @called = true
27
+ end
28
+ def inform_parent_presenting
29
+ end
30
+
31
+ def sync_cio_to_displayed
32
+ end
33
+ def sync_cio_to_highlighted
34
+ end
35
+ def exists_next
36
+ true
37
+ end
38
+ def exists_prev
39
+ true
40
+ end
41
+
42
+ end
43
+
44
+ callback = CallbackContext.new
45
+
46
+ @a = MINT::AIO.create(:name => "test")
47
+ @a.process_event(:organize,callback).should == [:organized]
48
+ callback.called.should == false
49
+
50
+ @a.process_event(:present,callback).should == [:defocused]
51
+ callback.called.should == false
52
+
53
+ @a.process_event(:focus,callback).should == [:focused]
54
+ callback.called.should == false
55
+
56
+ @a.process_event(:next,callback).should == [:defocused]
57
+ callback.called.should == true
58
+ end
59
+ end
60
+
61
+ it 'should serialize to JSON' do
62
+ connect do |redis|
63
+ @a = MINT::AIO.create(:name => "test")
64
+ require 'dm-serializer'
65
+ @a.states=[:focused]
66
+
67
+ puts @a.to_json # => { "id": 1, "name": "Berta" }
68
+ end
69
+ end
70
+
71
+ end
72
+
73
+ end
@@ -0,0 +1,105 @@
1
+ require "spec_helper"
2
+
3
+ require "em-spec/rspec"
4
+
5
+
6
+ describe 'AUI' do
7
+ include EventMachine::SpecHelper
8
+
9
+ before :all do
10
+ connection_options = { :adapter => "redis"}
11
+ DataMapper.setup(:default, connection_options)
12
+
13
+ connect do |redis|
14
+ require "MINT-core"
15
+ require "support/redis_connector_monkey_patch" # TODO dirty patch for a bug that i have not found :(
16
+
17
+ DataMapper.finalize
18
+ DataMapper::Model.raise_on_save_failure = true
19
+ end
20
+ end
21
+
22
+ describe 'AIReference' do
23
+ it 'should initialize with initiated' do
24
+ connect do |redis|
25
+ @a = MINT::AIReference.create(:name=>"ref")
26
+
27
+ @a.states.should ==[:initialized]
28
+ @a.new_states.should == [:initialized]
29
+ end
30
+ end
31
+
32
+ it 'should refer to correct object' do
33
+ connect do |redis|
34
+ @a = MINT::AIReference.create(:name=>"ref",:refers=>"target")
35
+ MINT::AIO.create(:name=>"target")
36
+
37
+ @a.refers.name.should == "target"
38
+ end
39
+ end
40
+
41
+ it 'should focus referred object' do
42
+ connect do |redis|
43
+ @a = MINT::AIReference.create(:name=>"ref",:refers=>"target")
44
+ MINT::AIO.create(:name=>"target")
45
+
46
+ #Todo ask Sebastian about the functioning of AIReference
47
+ @a.process_event(:organize)
48
+ @a.refers.process_event(:organize)
49
+ @a.process_event(:present)
50
+ @a.refers.process_event(:present)
51
+ @a.process_event(:focus)
52
+ @a.refers.states.should == [:focused]
53
+ end
54
+ end
55
+
56
+ describe 'without refers' do
57
+
58
+ it 'should return to defocused in case there is no referred object' do
59
+ connect do |redis|
60
+ @a = MINT::AIReference.create(:name=>"ref")
61
+ @a.process_event(:organize)
62
+ @a.process_event(:present)
63
+ @a.process_event(:focus)
64
+ @a.states.should == [:defocused]
65
+ end
66
+ end
67
+ end
68
+
69
+ describe 'with refers' do
70
+ it 'should initialize with initiated and store reference correctly' do
71
+ connect true do |redis|
72
+ @a = MINT::AIReference.create(:name=>"ref")
73
+
74
+ test_state_flow redis,"Interactor.AIO.test" ,%w(initialized) do
75
+
76
+ @r = MINT::AIO.create(:name => "test")
77
+ @a = MINT::AIReference.create(:name=>"reference", :refers => "test")
78
+
79
+ @a.states.should ==[:initialized]
80
+ @a.new_states.should == [:initialized]
81
+ @a.refers.name.should=="test"
82
+ end
83
+ end
84
+
85
+ end
86
+
87
+ it 'should forward focus' do
88
+ connect true do |redis|
89
+
90
+ test_state_flow redis,"Interactor.AIO.AIIN.AIINDiscrete.AIReference.reference" ,[["presenting", "defocused"],"focused", "defocused"] do
91
+ @r = MINT::AIO.create(:name => "test",:states=>[:defocused])
92
+ @a = MINT::AIReference.create(:name=>"reference", :refers => "test",:states=>[:organized])
93
+ @a.process_event :present
94
+ @a.process_event :focus
95
+ @a.states.should ==[:defocused]
96
+ MINT::AIO.get("aui","test").states.should ==[:focused]
97
+ end
98
+ end
99
+
100
+ end
101
+
102
+ end
103
+
104
+ end
105
+ end
@@ -1,94 +1,238 @@
1
1
  require "spec_helper"
2
2
 
3
- include MINT
3
+ require "em-spec/rspec"
4
+
5
+
6
+
4
7
  describe 'AUI' do
5
- before :each do
6
- connection_options = { :adapter => "in_memory"}
8
+ include EventMachine::SpecHelper
9
+
10
+ before :all do
11
+ class ::AISinglePresenceHelper
12
+ def self.create_data
13
+ MINT::AISinglePresence.create(:name=>"a", :children =>"e1|e2|e3")
14
+
15
+ MINT::AIO.create(:name => "e1",:parent=>"a")
16
+ MINT::AIO.create(:name => "e2",:parent=>"a")
17
+ MINT::AIO.create(:name => "e3",:parent=>"a")
18
+
19
+ @a = MINT::AISinglePresence.first
20
+ @a
21
+ end
22
+
23
+ end
24
+ connection_options = { :adapter => "redis"}
7
25
  DataMapper.setup(:default, connection_options)
8
- # DataMapper.setup(:default, { :adapter => "rinda",:local =>Rinda::TupleSpace.new})
9
- AISinglePresence.new(:name=>"a", :childs =>[
10
- AIO.new(:name => "e1"),
11
- AIO.new(:name => "e2"),
12
- AIO.new(:name => "e3")
13
- ]).save
14
-
15
- @a = AISinglePresence.first
26
+
27
+
28
+ connect do |redis|
29
+ require "MINT-core"
30
+ require "support/redis_connector_monkey_patch" # TODO dirty patch for a bug that i have not found :(
31
+
32
+ DataMapper.finalize
33
+ DataMapper::Model.raise_on_save_failure = true
34
+ end
16
35
  end
17
36
 
37
+
38
+
18
39
  describe 'AISinglePresence' do
19
- it 'should initialize with initiated' do
20
- @a.states.should ==[:initialized]
21
- @a.new_states.should == [:initialized]
40
+ it 'should initialize with initiated' do
41
+ connect do |redis|
42
+ @a = AISinglePresenceHelper.create_data
43
+ @a.states.should ==[:initialized]
44
+ @a.new_states.should == [:initialized]
45
+ end
22
46
  end
23
47
 
24
48
  it 'should transform to organizing state ' do
25
- @a.process_event(:organize).should ==[:organized]
26
- @a.states.should == [:organized]
27
- @a.new_states.should == [:organized]
49
+ connect do |redis|
50
+ @a = AISinglePresenceHelper.create_data
51
+ @a.process_event(:organize).should ==[:organized]
52
+ @a.states.should == [:organized]
53
+ @a.new_states.should == [:organized]
54
+ end
28
55
  end
29
56
 
30
57
  it 'should transform first child to presented if presented and rest to suspended' do
31
- AUIControl.organize(@a,nil,0)
32
- # @a.process_event(:organize).should ==[:organized]
33
- @a.states.should == [:organized]
34
- @a.new_states.should == [:organized]
35
- @a.process_event(:present).should ==[:defocused]
36
- children = @a.childs
37
- children[0].states.should == [:defocused]
38
- children[1].states.should == [:suspended]
39
- children[2].states.should == [:suspended]
58
+ connect true do |redis|
59
+ # Sync AIO to defocused
60
+ parser = MINT::MappingParser.new
61
+ m = parser.build_from_scxml File.dirname(__FILE__) +"/../lib/MINT-core/model/mim/aisinglepresence_present_to_child_present.xml"
62
+ m.start
63
+
64
+
65
+ check_result = Proc.new {
66
+ MINT::AIO.first(:name=>"e1").states.should ==[:defocused]
67
+ MINT::AIO.first(:name=>"e2").states.should ==[:suspended]
68
+ MINT::AIO.first(:name=>"e3").states.should ==[:suspended]
69
+
70
+ done
71
+ }
72
+
73
+ test_complex_state_flow_w_name redis,[["Interactor.AIO.AIOUT.AIContainer.AISinglePresence","a" ,["initialized","organized",["presenting", "wait_for_children"],"children_finished","defocused"]],["Interactor.AIO","e1" ,["initialized","organized",["presenting", "defocused"]]]],check_result do |count|
74
+ @a = AISinglePresenceHelper.create_data
75
+
76
+ AUIControl.organize(@a,nil,0)
77
+ # @a.process_event(:organize).should ==[:organized]
78
+ @a.states.should == [:organized]
79
+ @a.new_states.should == [:organized]
80
+ @a.process_event(:present).should ==[:wait_for_children]
81
+
82
+ end
83
+ end
40
84
  end
41
85
 
42
- it 'should hide the other elements if a child is presented' do
43
- AUIControl.organize(@a,nil,0)
44
- @a.process_event(:present).should == [:defocused]
86
+ it 'should hide the other elements if a child is presented using present' do
87
+ pending "requires child to inform parent about presenting"
88
+ connect true do |redis|
89
+ # Sync AIO to defocused
90
+ parser = MINT::MappingParser.new
91
+ m = parser.build_from_scxml File.dirname(__FILE__) +"/../lib/MINT-core/model/mim/aisinglepresence_present_to_child_present.xml"
92
+ m.start
93
+
45
94
 
46
- AIO.first(:name => "e1").states.should == [:defocused]
47
- AIO.first(:name => "e2").states.should == [:suspended]
48
- AIO.first(:name => "e3").states.should == [:suspended]
95
+ check_result = Proc.new {
96
+ MINT::AIO.first(:name => "e1").states.should == [:suspended]
97
+ MINT::AIO.first(:name => "e2").states.should == [:defocused]
98
+ MINT::AIO.first(:name => "e3").states.should == [:suspended]
49
99
 
50
- e3 = AIO.first(:name => "e3")
51
- e3.states.should ==[:suspended]
52
- e3.process_event(:present).should == [:defocused]
100
+ done
101
+ }
53
102
 
54
- AIO.first(:name => "e1").states.should == [:suspended]
55
- AIO.first(:name => "e2").states.should == [:suspended]
56
- AIO.first(:name => "e3").states.should == [:defocused]
103
+ test_complex_state_flow_w_name redis,[["Interactor.AIO","e1" ,["initialized","organized",["presenting", "defocused"],"suspended"]]],check_result do |count|
104
+ @a = AISinglePresenceHelper.create_data
57
105
 
58
- e2 = AIO.first(:name => "e2")
59
- e2.states.should ==[:suspended]
60
- e2.process_event(:present).should == [:defocused]
106
+ AUIControl.organize(@a,nil,0)
107
+ @a.process_event(:present).should == [:wait_for_children]
61
108
 
62
- AIO.first(:name => "e1").states.should == [:suspended]
63
- AIO.first(:name => "e2").states.should == [:defocused]
64
- AIO.first(:name => "e3").states.should == [:suspended]
109
+ e3 = MINT::AIO.first(:name => "e3")
110
+ e3.process_event(:present).should == [:defocused]
111
+ e2 = MINT::AIO.first(:name => "e2")
112
+ e2.process_event(:present).should == [:defocused]
113
+ end
114
+ end
65
115
 
66
116
  end
67
117
 
68
- it 'should hide the other elements if a child is presented (using next and prev events)' do
69
- AUIControl.organize(@a,nil,0)
70
- @a.process_event(:present).should == [:defocused]
118
+ it 'should permit navigation before the first child ' do
119
+ connect true do |redis|
120
+ # Sync AIO to defocused
121
+ parser = MINT::MappingParser.new
122
+ m = parser.build_from_scxml File.dirname(__FILE__) +"/../lib/MINT-core/model/mim/aisinglepresence_present_to_child_present.xml"
123
+ m.start
124
+
125
+
126
+ check_result = Proc.new {
127
+ @a = MINT::AISinglePresence.first
128
+ @a.process_event :focus
129
+ @a.process_event :enter
130
+ @a.process_event :next
131
+ MINT::AIO.first(:name => "e2").states.should == [:defocused]
132
+
133
+ @a.process_event :prev
134
+ MINT::AIO.first(:name => "e2").states.should == [:suspended]
135
+ MINT::AIO.first(:name => "e1").states.should == [:defocused]
136
+
137
+ @a.process_event :prev
138
+ MINT::AIO.first(:name => "e2").states.should == [:suspended]
139
+ MINT::AIO.first(:name => "e1").states.should == [:defocused]
71
140
 
72
- AIO.first(:name => "e1").states.should == [:defocused]
73
- AIO.first(:name => "e2").states.should == [:suspended]
74
- AIO.first(:name => "e3").states.should == [:suspended]
141
+ @a.process_event :next
142
+ MINT::AIO.first(:name => "e1").states.should == [:suspended]
143
+ MINT::AIO.first(:name => "e2").states.should == [:defocused]
144
+ done
145
+ }
75
146
 
76
- @a.process_event(:focus).should == [:waiting]
77
- @a.process_event(:enter).should == [:entered]
78
- @a.process_event(:next).should == [:entered]
147
+ test_complex_state_flow_w_name redis,[["Interactor.AIO.AIOUT.AIContainer.AISinglePresence","a" ,["initialized","organized",["presenting", "wait_for_children"],"children_finished","defocused"]]],check_result do |count|
148
+ @a = AISinglePresenceHelper.create_data
79
149
 
80
- AIO.first(:name => "e1").states.should == [:suspended]
81
- AIO.first(:name => "e2").states.should == [:defocused]
82
- AIO.first(:name => "e3").states.should == [:suspended]
150
+ AUIControl.organize(@a,nil,0)
151
+ # @a.process_event(:organize).should ==[:organized]
152
+ @a.states.should == [:organized]
153
+ @a.new_states.should == [:organized]
154
+ @a.process_event(:present).should ==[:wait_for_children]
83
155
 
84
- @a.process_event(:prev).should == [:entered]
156
+ end
157
+ end
85
158
 
86
- AIO.first(:name => "e1").states.should == [:defocused]
87
- AIO.first(:name => "e2").states.should == [:suspended]
88
- AIO.first(:name => "e3").states.should == [:suspended]
89
159
  end
90
160
 
91
161
 
162
+ it 'should hide the other elements if a child is presented with next and prev events' do
163
+ connect true do |redis|
164
+ # Sync AIO to defocused
165
+ parser = MINT::MappingParser.new
166
+ m = parser.build_from_scxml File.dirname(__FILE__) +"/../lib/MINT-core/model/mim/aisinglepresence_present_to_child_present.xml"
167
+ m.start
168
+
169
+ check_result2 = Proc.new {
170
+ MINT::AIO.first(:name => "e1").states.should == [:defocused]
171
+ MINT::AIO.first(:name => "e2").states.should == [:suspended]
172
+ MINT::AISinglePresence.first(:name => "a").active_child == "e1"
173
+ done
174
+ }
175
+
176
+ check_result = Proc.new {
177
+ redis.pubsub.unsubscribe("Interactor.AIO.AIOUT.AIContainer.AISinglePresence")
178
+
179
+ a = MINT::AISinglePresence.first(:name => "a")
180
+ a.process_event(:focus).should == [:waiting]
181
+
182
+ test_complex_state_flow_w_name redis,[["Interactor.AIO","e1" ,["suspended",["presenting", "defocused"]]],["Interactor.AIO","e2" ,[["presenting", "defocused"],"suspended"]]],check_result2 do |count|
183
+ a.process_event(:enter).should == [:entered]
184
+ a.process_event(:next).should == [:entered]
185
+ a.process_event(:prev).should == [:entered]
186
+ end
187
+ }
188
+
189
+ test_complex_state_flow_w_name redis,[["Interactor.AIO.AIOUT.AIContainer.AISinglePresence","a" ,["initialized","organized",["presenting", "wait_for_children"],"children_finished","defocused"]]],check_result do |count|
190
+ @a = AISinglePresenceHelper.create_data
191
+
192
+ AUIControl.organize(@a,nil,0)
193
+ @a.process_event(:present).should == [:wait_for_children]
194
+ end
195
+ end
196
+
197
+
198
+ end
199
+
200
+ describe 'synchronized with Redis-PubSub' do
201
+ it 'should transform first child to presented if presented and rest to suspended' do
202
+ connect true do |redis|
203
+
204
+ parser = MINT::MappingParser.new
205
+ m = parser.build_from_scxml File.dirname(__FILE__) +"/../lib/MINT-core/model/mim/aisinglepresence_present_to_child_present.xml"
206
+ m.start
207
+
208
+ check_result = Proc.new {
209
+ test_state_flow redis,"Interactor.AIO.AIOUT.AIContainer.AISinglePresence" ,
210
+ ["defocused",["focused", "waiting"], "entered"] do
211
+ @a.process_event(:focus)
212
+
213
+ @a.process_event(:enter)
214
+ end
215
+ done
216
+
217
+ }
218
+
219
+ test_complex_state_flow_w_name redis,[["Interactor.AIO.AIOUT.AIContainer.AISinglePresence" ,"a",
220
+ ["initialized", "organized", ["presenting", "wait_for_children"] ,"children_finished","defocused"] ]],check_result do |count|
221
+
222
+ @a = AISinglePresenceHelper.create_data
223
+ AUIControl.organize(@a,nil,0)
224
+
225
+ @a.process_event(:present)
226
+
227
+
228
+
229
+ end
230
+
231
+
232
+ end
233
+ end
234
+
235
+ end
92
236
 
93
237
  end
94
238
  end