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
@@ -1,9 +1,10 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe 'SingleChoice' do
4
- before :each do
5
- connection_options = { :adapter => "in_memory"}
6
- DataMapper.setup(:default, connection_options)
4
+
5
+ include EventMachine::SpecHelper
6
+
7
+ before :all do
7
8
  class CallbackContext
8
9
  attr_accessor :called
9
10
 
@@ -34,118 +35,176 @@ describe 'SingleChoice' do
34
35
  end
35
36
  @callback = CallbackContext.new
36
37
 
37
- @sc =MINT::AISingleChoice.new(:name => "choice",
38
- :childs => [
39
- MINT::AISingleChoiceElement.new(:name => "element_1"),
40
- MINT::AISingleChoiceElement.new(:name => "element_2"),
41
- MINT::AISingleChoiceElement.new(:name => "element_3"),
42
- MINT::AISingleChoiceElement.new(:name => "element_4")]
43
- )
44
- AUIControl.organize(@sc,nil, 0)
45
- @sc.save
46
- end
38
+ connection_options = { :adapter => "redis"}
39
+ DataMapper.setup(:default, connection_options)
47
40
 
48
- describe "child relations" do
49
- before :each do
50
- @sc.process_event(:present).should == [:defocused, :listing]
51
- @sc.states.should == [:defocused, :listing]
41
+ class ::Helper
42
+ def self.create_structure
43
+ MINT::AISingleChoice.create(:name => "choice", :children => "element_1|element_2|element_3|element_4")
44
+ MINT::AISingleChoiceElement.create(:name => "element_1", :parent=>"choice")
45
+ MINT::AISingleChoiceElement.create(:name => "element_2", :parent=>"choice")
46
+ MINT::AISingleChoiceElement.create(:name => "element_3", :parent=>"choice")
47
+ MINT::AISingleChoiceElement.create(:name => "element_4", :parent=>"choice")
48
+ MINT::AISingleChoice.first
49
+ end
52
50
 
53
- @e1 = MINT::AISingleChoiceElement.first(:name => "element_1")
54
- @e2 = MINT::AISingleChoiceElement.first(:name => "element_2")
55
- @e3 = MINT::AISingleChoiceElement.first(:name => "element_3")
56
- @e4 = MINT::AISingleChoiceElement.first(:name => "element_4")
51
+ def self.initialize_main_structure
52
+ @sc = Helper.create_structure
53
+ AUIControl.organize(@sc,nil,0)
57
54
 
58
- @e1.process_event(:present)
59
- @e2.process_event(:present)
60
- @e3.process_event(:present)
61
- @e4.process_event(:present)
55
+ @sc.process_event(:present).should == [:wait_for_children, :listing]
56
+ @sc.process_event :children_finished
57
+ @sc.present_children
58
+ @sc.states.should == [:defocused, :listing]
59
+ @sc
60
+ end
62
61
  end
63
62
 
64
- it 'should deactivate other chosen elements on choose' do
65
- @e1.process_event(:focus).should == [:focused, :unchosen]
66
- @e1.new_states.should == [:focused]
63
+ connect do |redis|
64
+ require "MINT-core"
67
65
 
68
- @e1.process_event(:choose).should == [:focused, :chosen]
69
- @e2.process_event(:choose).should == [:defocused, :chosen]
70
-
71
-
72
- # TODO: state actualization should be done withnt :suspend, out re-querying?
73
- @e1 = MINT::AISingleChoiceElement.first(:name => "element_1")
74
- @e1.states.should == [:focused, :unchosen]
66
+ DataMapper.finalize
67
+ DataMapper::Model.raise_on_save_failure = true
68
+ end
69
+ end
75
70
 
71
+ describe "child relationpresents" do
72
+ it 'should deactivate other chosen elements on choose' do
73
+ connect do |redis|
74
+ Helper.initialize_main_structure
75
+ @e1 = MINT::AISingleChoiceElement.first(:name => "element_1")
76
+ @e2 = MINT::AISingleChoiceElement.first(:name => "element_2")
77
+
78
+ @e1.process_event(:focus).should == [:focused, :unchosen]
79
+ @e1.new_states.should == [:focused]
80
+ @e2.process_event(:focus).should == [:focused, :unchosen]
81
+ @e2.new_states.should == [:focused]
82
+
83
+ @e1.process_event(:choose).should == [:focused, :chosen]
84
+ @e2.process_event(:choose).should == [:focused, :chosen]
85
+
86
+ # TODO: state actualization should be done withnt :suspend, out re-querying?
87
+ @e1 = MINT::AISingleChoiceElement.first(:name => "element_1")
88
+ @e1.states.should == [:focused, :unchosen]
89
+ end
76
90
  end
77
91
 
78
- it 'should accept drag event in unchosen or chosen' do
79
- @e1.process_event(:focus).should == [:focused, :unchosen]
80
- @e1.states.should == [:focused, :unchosen]
92
+ it 'should accept drag event in listed or chosen' do
93
+ connect do |redis|
94
+ Helper.initialize_main_structure
95
+ @e1 = MINT::AISingleChoiceElement.first(:name => "element_1")
96
+ sc =MINT::AISingleChoice.first(:name => "choice")
81
97
 
82
- @e1.process_event(:drag).should == [:dragging, :chosen]
83
- @e1.states.should == [:dragging, :chosen]
98
+ @e1.process_event(:focus).should == [:focused, :unchosen]
99
+ @e1.states.should == [:focused, :unchosen]
84
100
 
85
- @e1.process_event(:drop).should == [:defocused, :chosen]
86
- @e1.states.should == [:defocused, :chosen]
101
+ @e1.process_event(:drag).should == [:focused, :dragging]
102
+ @e1.states.should == [:focused, :dragging]
87
103
 
88
- @e1.process_event(:focus).should == [:focused, :chosen]
89
- @e1.states.should == [:focused, :chosen]
90
104
 
91
- @e1.process_event(:drag).should == [:dragging, :chosen]
92
- @e1.states.should == [:dragging, :chosen]
93
- end
105
+ sc.process_event(:focus).should == [:focused, :listing]
106
+ sc.process_event(:drop).should == [:defocused, :listing]
107
+ @e1 = MINT::AISingleChoiceElement.first(:name => "element_1")
108
+ @e1.states.should == [:focused, :unchosen]
94
109
 
95
- it 'should hide child elements on suspend' do
96
- sc =MINT::AISingleChoice.first(:name => "choice")
97
- sc.process_event(:suspend).should == [:suspended]
98
- e1 = MINT::AISingleChoiceElement.first(:name => "element_1")
99
- e1.states.should == [:suspended]
100
- end
110
+ @e1.process_event(:choose).should == [:focused, :chosen]
111
+ @e1.states.should == [:focused, :chosen]
101
112
 
102
- it 'should hide if suspend is called from parent AIC' do
103
- sc =MINT::AISingleChoice.first(:name => "choice")
113
+ @e1.process_event(:drag).should == [:focused, :dragging]
114
+ @e1.states.should == [:focused, :dragging]
104
115
 
105
- aic = MINT::AIC.create(:name => "container", :states=>[:defocused],:childs =>[sc])
116
+ sc.process_event(:focus).should == [:focused, :listing]
117
+ sc.process_event(:drop).should == [:defocused, :listing]
118
+ @e1 = MINT::AISingleChoiceElement.first(:name => "element_1")
119
+ @e1.states.should == [:focused, :unchosen]
106
120
 
107
- aic.process_event(:suspend).should == [:suspended]
108
- e1 = MINT::AISingleChoiceElement.first(:name => "element_1")
109
- e1.states.should == [:suspended]
121
+ end
110
122
  end
111
123
 
112
- it "should sync suspend to CUI" do
113
- MINT::RadioButtonGroup.create(:name =>"choice", :states => [:presenting,:listed])
114
- MINT::Selectable.create(:name =>"element_1", :states =>[:displayed,:listed])
115
- MINT::Selectable.create(:name =>"element_2", :states =>[:displayed,:listed])
116
- MINT::Selectable.create(:name =>"element_3", :states =>[:displayed,:listed])
117
- MINT::Selectable.create(:name =>"element_4", :states =>[:displayed,:listed])
124
+ it 'should hide child elements on suspend' do
125
+ connect do |redis|
126
+ Helper.initialize_main_structure
127
+
128
+ sc =MINT::AISingleChoice.first(:name => "choice")
129
+ sc.process_event(:suspend).should == [:suspended]
130
+ e1 = MINT::AISingleChoiceElement.first(:name => "element_1")
131
+ e1.states.should == [:suspended]
132
+ end
133
+ end
118
134
 
135
+ it 'should hide if suspend is called from parent AIContainer' do
136
+ connect do |redis|
137
+ Helper.initialize_main_structure
119
138
 
120
- sc =MINT::AISingleChoice.first(:name => "choice")
139
+ sc = MINT::AISingleChoice.first(:name => "choice")
121
140
 
122
- aic = MINT::AIC.create(:name => "container", :states=>[:defocused],:childs =>[sc])
141
+ aic = MINT::AIContainer.create(:name => "container", :states=>[:defocused], :children => "choice")
123
142
 
124
- aic.process_event(:suspend).should == [:suspended]
125
- e1 = MINT::AISingleChoiceElement.first(:name => "element_1")
126
- e1.states.should == [:suspended]
143
+ aic.process_event(:suspend).should == [:suspended]
144
+ e1 = MINT::AISingleChoiceElement.first(:name => "element_1")
145
+ e1.states.should == [:suspended]
146
+ end
147
+ end
127
148
 
128
- s4=MINT::Selectable.first(:name =>"element_4")
129
- s4.states.should ==[:hidden]
130
- rbg = MINT::RadioButtonGroup.first(:name=>"choice")
131
- rbg.states.should == [:hidden]
149
+ it "should sync suspend to CUI" do
150
+ connect true do |redis|
151
+
152
+ parser = MINT::MappingParser.new
153
+ m = parser.build_from_scxml File.dirname(__FILE__) +"/../lib/MINT-core/model/mim/aio_suspend_to_cio_hide.xml"
154
+ m.start
155
+ #TODO Find out from where these RadioButtonGroup states come from
156
+ sc = Helper.initialize_main_structure
157
+
158
+ MINT::RadioButtonGroup.create(:name =>"choice", :states => [:displayed])
159
+ MINT::RadioButton.create(:name =>"element_1", :states =>[:displayed,:unselected])
160
+ MINT::RadioButton.create(:name =>"element_2", :states =>[:displayed,:unselected])
161
+ MINT::RadioButton.create(:name =>"element_3", :states =>[:displayed,:unselected])
162
+ MINT::RadioButton.create(:name =>"element_4", :states =>[:displayed,:unselected])
163
+ aic = MINT::AIContainer.create(:name => "container", :states=>[:defocused], :children => "choice")
164
+ MINT::CIC.create(:name => "container", :states =>[:displayed])
165
+
166
+ check_result = Proc.new {
167
+ e1 = MINT::AISingleChoiceElement.first(:name => "element_1")
168
+ e1.states.should == [:suspended]
169
+
170
+ s4 = MINT::RadioButton.first(:name =>"element_4")
171
+ s4.states.should == [:hidden]
172
+ rbg = MINT::RadioButtonGroup.first(:name=>"choice")
173
+ rbg.states.should == [:hidden]
174
+
175
+ done
176
+ }
177
+
178
+ test_complex_state_flow_w_name redis,[["Interactor.CIO.RadioButton","element_2" ,["hidden"]]],check_result do |count|
179
+ aic.process_event(:suspend).should == [:suspended]
180
+ end
181
+ end
132
182
  end
133
183
 
134
184
  it "should remove elements that have been dropped elsewhere" do
135
- pending("get drop from drag n drop working")
136
- sc =MINT::AISingleChoice.first(:name => "choice")
137
- e1 = MINT::AISingleChoiceElement.first(:name => "element_1")
138
- e1.process_event(:drag)
139
- #e1.process_event(:drop)
140
- dest =MINT::AISingleChoice.create(:name => "choice_dest",:states => [:defocused,:unchosen])
141
- dest.process_event(:drop)
142
- #dest.childs << e1
143
- #p dest.childs.save
144
- sc.childs.length.should ==3
145
- dest.childs.length.should ==1
146
- p sc.childs.inspect
147
- e1 = MINT::AISingleChoiceElement.first(:name => "element_1").should_not == nil
148
-
185
+ connect do |redis|
186
+ #TODO Figure out how to make the AISingleChoice.add work again
187
+ Helper.initialize_main_structure
188
+
189
+ sc = MINT::AISingleChoice.first(:name => "choice")
190
+ e1 = MINT::AISingleChoiceElement.first(:name => "element_1")
191
+ e1.process_event(:focus)
192
+ e1.process_event(:drag)
193
+ dest = MINT::AISingleChoice.create(:name => "choice_dest")
194
+ AUIControl.organize(dest,nil, 0)
195
+ dest.process_event(:present)
196
+ dest.process_event :children_finished
197
+ dest.process_event(:focus)
198
+ dest.process_event(:drop)
199
+
200
+ sc = MINT::AISingleChoice.first(:name => "choice")
201
+ sc.children.length.should == 3
202
+
203
+ dest = MINT::AISingleChoice.first(:name => "choice_dest")
204
+ dest.children.length.should == 1
205
+ p sc.children.inspect
206
+ e1 = MINT::AISingleChoiceElement.first(:name => "element_1").should_not == nil
207
+ end
149
208
  end
150
209
  end
151
210
 
@@ -1,106 +1,190 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe 'SingleChoiceElement' do
4
- before :each do
5
- connection_options = { :adapter => "in_memory"}
4
+
5
+ include EventMachine::SpecHelper
6
+
7
+ before :all do
8
+ connection_options = { :adapter => "redis"}
6
9
  DataMapper.setup(:default, connection_options)
7
- @a = MINT::AISingleChoiceElement.create(:name => "test")
10
+
11
+ connect do |redis|
12
+ require "MINT-core"
13
+
14
+ DataMapper.finalize
15
+ DataMapper::Model.raise_on_save_failure = true
16
+
17
+ end
8
18
  end
9
19
 
10
20
  it 'should initialize with initiated' do
11
- @a.states.should == [:initialized]
21
+ connect do |redis|
22
+ @a = MINT::AISingleChoiceElement.create(:name => "test")
23
+ @a.states.should == [:initialized]
24
+ end
12
25
  end
13
26
 
14
27
  it 'should transform to organizing state for present action' do
15
- @a.process_event(:organize).should == [:organized]
16
- @a.states.should == [:organized]
28
+ connect do |redis|
29
+ @a = MINT::AISingleChoiceElement.create(:name => "test")
30
+ @a.process_event(:organize).should == [:organized]
31
+ @a.states.should == [:organized]
32
+ end
17
33
  end
18
34
 
19
35
  it 'should call back after event has been processed' do
20
- class CallbackContext
21
- attr_accessor :called
36
+ connect do |redis|
37
+ @a = MINT::AISingleChoiceElement.create(:name => "test")
38
+ class CallbackContext
39
+ attr_accessor :called
22
40
 
23
- def initialize
24
- @called = false
25
- end
26
- def focus_next
27
- @called = true
28
- end
29
- def sync_cio_to_displayed
30
- end
31
- def sync_cio_to_highlighted
32
- end
33
- def sync_cio_to_listed
41
+ def initialize
42
+ @called = false
43
+ end
44
+ def focus_next
45
+ @called = true
46
+ end
47
+ def sync_cio_to_displayed
48
+ end
49
+ def sync_cio_to_highlighted
50
+ end
51
+ def sync_cio_to_unchosen
52
+ end
53
+ def exists_next
54
+ true
55
+ end
56
+ def exists_prev
57
+ true
58
+ end
34
59
  end
35
- def exists_next
36
- true
37
- end
38
- def exists_prev
39
- true
40
- end
41
- end
42
60
 
43
- callback = CallbackContext.new
61
+ callback = CallbackContext.new
44
62
 
45
63
 
46
- @a.process_event(:organize,callback).should == [:organized]
47
- callback.called.should == false
64
+ @a.process_event(:organize,callback).should == [:organized]
65
+ callback.called.should == false
48
66
 
49
- @a.process_event(:present,callback).should == [:defocused, :unchosen]
50
- @a.states.should == [:defocused, :unchosen]
51
- @a.new_states.should == [:defocused, :unchosen, :p_t, :presenting, :selection_H]
52
- callback.called.should == false
67
+ @a.process_event(:present,callback).should == [:defocused, :unchosen]
68
+ @a.states.should == [:defocused, :unchosen]
69
+ @a.new_states.should == [:defocused, :unchosen, :p, :presenting, :choice, :c]
70
+ callback.called.should == false
53
71
 
54
- @a.process_event(:focus,callback).should == [:focused, :unchosen]
55
- @a.new_states.should == [:focused]
56
- callback.called.should == false
72
+ @a.process_event(:focus,callback).should == [:focused, :unchosen]
73
+ @a.new_states.should == [:focused]
74
+ callback.called.should == false
57
75
 
58
- @a.process_event(:next,callback).should == [:defocused, :unchosen]
59
- @a.new_states.should == [:defocused]
60
- callback.called.should == true
76
+ @a.process_event(:next,callback).should == [:defocused, :unchosen]
77
+ @a.new_states.should == [:defocused]
78
+ callback.called.should == true
79
+ end
61
80
  end
62
81
 
63
82
  it 'should recover state after save and reload' do
64
- @a.process_event(:organize).should == [:organized]
65
- @a.save!
66
- b = MINT::AIO.first(:name=>"test")
67
- b.states.should == [:organized]
68
- b.new_states.should == [:organized]
69
- b.process_event(:present).should == [:defocused, :unchosen]
70
- b.new_states.should == [:defocused, :unchosen, :p_t, :presenting, :selection_H]
71
-
83
+ connect do |redis|
84
+ @a = MINT::AISingleChoiceElement.create(:name => "test")
85
+ @a.process_event(:organize).should == [:organized]
86
+ @a.save!
87
+ b = MINT::AIO.first(:name=>"test")
88
+ b.states.should == [:organized]
89
+ b.new_states.should == [:organized]
90
+ b.process_event(:present).should == [:defocused, :unchosen]
91
+ b.new_states.should == [:defocused, :unchosen, :p, :presenting, :choice, :c]
92
+ end
72
93
  end
73
94
 
74
95
  it 'should recover state after save and reload from inside parallel state' do
75
- @a.process_event(:organize).should == [:organized]
76
- @a.process_event(:present).should == [:defocused, :unchosen]
77
- @a.process_event(:focus).should == [:focused, :unchosen]
78
- @a.save!
79
- b = MINT::AIO.first(:name=>"test")
80
- b.states.should ==[:focused, :unchosen]
81
- b.process_event(:defocus).should == [:defocused, :unchosen]
82
- #b.process_event(:choose).should == [:presented, :choosing]
96
+ connect do |redis|
97
+ @a = MINT::AISingleChoiceElement.create(:name => "test")
98
+ @a.process_event(:organize).should == [:organized]
99
+ @a.process_event(:present).should == [:defocused, :unchosen]
100
+ @a.process_event(:focus).should == [:focused, :unchosen]
101
+ @a.save!
102
+ b = MINT::AIO.first(:name=>"test")
103
+ b.states.should ==[:focused, :unchosen]
104
+ b.process_event(:defocus).should == [:defocused, :unchosen]
105
+ #b.process_event(:choose).should == [:presented, :choosing]
106
+ end
83
107
  end
108
+
84
109
  it 'should support for query-based selection' do
85
- @a.process_event(:organize).should == [:organized]
86
- @a.process_event(:present).should == [:defocused, :unchosen]
87
- @a.save!
88
- b = MINT::AIO.first(:states=>/unchosen/)
89
- b.name.should == "test"
90
- c = MINT::AIO.first(:states=>/defocused/)
91
- c.name.should == "test"
110
+ connect do |redis|
111
+ @a = MINT::AISingleChoiceElement.create(:name => "test")
112
+ @a.process_event(:organize).should == [:organized]
113
+ @a.process_event(:present).should == [:defocused, :unchosen]
114
+ @a.save!
115
+ b = MINT::AIO.first(:states=>/unchosen/)
116
+ b.name.should == "test"
117
+ c = MINT::AIO.first(:states=>/defocused/)
118
+ c.name.should == "test"
119
+ end
92
120
  end
121
+
93
122
  it 'should support for querying for superstates' do
94
- @a.process_event(:organize).should == [:organized]
95
- @a.process_event(:present).should == [:defocused, :unchosen]
96
- @a.save!
97
- puts @a.abstract_states
98
- b = MINT::AIO.first(:abstract_states=>/presenting/)
99
- b.name.should == "test"
123
+ connect do |redis|
124
+ @a = MINT::AISingleChoiceElement.create(:name => "test")
125
+ @a.process_event(:organize).should == [:organized]
126
+ @a.process_event(:present).should == [:defocused, :unchosen]
127
+ @a.save!
128
+ puts @a.abstract_states
129
+ b = MINT::AIO.first(:abstract_states=>/presenting/)
130
+ b.name.should == "test"
131
+ end
100
132
  end
133
+
101
134
  it "should save abstract states property upon initial element creation" do
102
- @a = MINT::AISingleChoiceElement.create(:name => "test")
103
- puts @a.abstract_states
135
+ connect do |redis|
136
+ @a = MINT::AISingleChoiceElement.create(:name => "test")
137
+ @a.abstract_states.should == "AISingleChoiceElement|root"
138
+ end
139
+ end
140
+
141
+ it "should retrieve the correct abstract states after entering parallel states" do
142
+ connect do |redis|
143
+ @a = MINT::AISingleChoiceElement.create(:name => "test")
144
+ @a.process_event(:organize).should == [:organized]
145
+ @a.process_event(:present).should == [:defocused, :unchosen]
146
+ @a.abstract_states.should == "AISingleChoiceElement|root|p|presenting|choice|c"
147
+ end
148
+ end
149
+
150
+ it "should retrieve the correct abstract states after leaving parallel states" do
151
+ connect do |redis|
152
+ @a = MINT::AISingleChoiceElement.create(:name => "test")
153
+ @a.process_event(:organize).should == [:organized]
154
+ @a.process_event(:present).should == [:defocused, :unchosen]
155
+ @a.process_event(:suspend).should == [:suspended]
156
+ @a.abstract_states.should == "AISingleChoiceElement|root"
157
+ end
158
+ end
159
+
160
+ it "should remove itself from parent choice if it enters dragging state (case: choice with just one element)" do
161
+ connect do |redis|
162
+ @a = MINT::AISingleChoiceElement.create(:name => "test",:parent=>"choice",:states=> [:focused, :chosen])
163
+ @c = MINT::AISingleChoice.create(:name => "choice",:children=>"test",:states=>[:defocused,:listing])
164
+
165
+ @a.process_event(:drag).should == [:focused,:dragging]
104
166
 
167
+ MINT::AISingleChoiceElement.first.parent.should == nil
168
+ MINT::AISingleChoice.first.children.to_a.empty?.should ==true
169
+
170
+ end
105
171
  end
172
+
173
+ it "should remove itself from parent choice if it enters dragging state (case: choice with several elements)" do
174
+ connect do |redis|
175
+ MINT::AISingleChoiceElement.create(:name => "A",:parent=>"choice",:states=> [:focused, :chosen])
176
+ @a = MINT::AISingleChoiceElement.create(:name => "B",:parent=>"choice",:states=> [:focused, :chosen])
177
+ MINT::AISingleChoiceElement.create(:name => "C",:parent=>"choice",:states=> [:focused, :chosen])
178
+
179
+ @c = MINT::AISingleChoice.create(:name => "choice",:children=>"A|B|C",:states=>[:defocused,:listing])
180
+
181
+ @a.process_event(:drag).should == [:focused,:dragging]
182
+
183
+ MINT::AISingleChoiceElement.get("aui","B").parent.should == nil
184
+ MINT::AISingleChoice.first.children.length.should == 2
185
+
186
+ end
187
+ end
188
+
189
+
106
190
  end