MINT-core 1.0.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +22 -3
- data/Gemfile.lock +98 -22
- data/History.txt +262 -0
- data/LICENSE +30 -0
- data/MINT-core.gemspec +25 -80
- data/Manifest.txt +145 -30
- data/README.rdoc +6 -163
- data/Rakefile +16 -17
- data/bin/mint-aui +3 -3
- data/bin/mint-cui-gfx +3 -2
- data/bin/mint-juggernaut.sh +0 -0
- data/bin/mint-tuplespace +0 -0
- data/lib/MINT-core.rb +53 -15
- data/lib/MINT-core/agent/agent.rb +1 -1
- data/lib/MINT-core/agent/aui.rb +0 -14
- data/lib/MINT-core/agent/auicontrol.rb +91 -38
- data/lib/MINT-core/agent/cui-gfx.rb +3 -3
- data/lib/MINT-core/agent/cuicontrol.rb +94 -24
- data/lib/MINT-core/connector/redis_connector.rb +16 -0
- data/lib/MINT-core/manager/mapping_manager.rb +101 -0
- data/lib/MINT-core/manager/mapping_parser.rb +89 -0
- data/lib/MINT-core/manager/mapping_server.rb +99 -0
- data/lib/MINT-core/manager/position_updater.rb +33 -0
- data/lib/MINT-core/manager/scxml_client.rb +118 -0
- data/lib/MINT-core/manager/scxml_server.rb +86 -0
- data/lib/MINT-core/mapping/action/action.rb +32 -0
- data/lib/MINT-core/mapping/action/backend_action.rb +32 -0
- data/lib/MINT-core/mapping/action/bind_action.rb +88 -0
- data/lib/MINT-core/mapping/action/event_action.rb +40 -0
- data/lib/MINT-core/mapping/complementary_mapping.rb +31 -0
- data/lib/MINT-core/mapping/mapping.rb +170 -34
- data/lib/MINT-core/mapping/observation/negation_observation.rb +64 -0
- data/lib/MINT-core/mapping/observation/observation.rb +219 -0
- data/lib/MINT-core/mapping/sequential.rb +1 -2
- data/lib/MINT-core/mapping/sequential_mapping.rb +60 -0
- data/lib/MINT-core/model/aui/AIChoiceElement.rb +17 -0
- data/lib/MINT-core/model/aui/AICommand.rb +7 -0
- data/lib/MINT-core/model/aui/AIContainer.rb +73 -0
- data/lib/MINT-core/model/aui/AIContext.rb +12 -0
- data/lib/MINT-core/model/aui/AIIN.rb +8 -0
- data/lib/MINT-core/model/aui/AIINContinuous.rb +56 -0
- data/lib/MINT-core/model/aui/AIINDiscrete.rb +8 -0
- data/lib/MINT-core/model/aui/AIMultiChoice.rb +1 -2
- data/lib/MINT-core/model/aui/AIMultiChoiceElement.rb +4 -51
- data/lib/MINT-core/model/aui/AIO.rb +76 -123
- data/lib/MINT-core/model/aui/AIOUT.rb +8 -0
- data/lib/MINT-core/model/aui/AIOUTContinuous.rb +61 -0
- data/lib/MINT-core/model/aui/AIReference.rb +16 -0
- data/lib/MINT-core/model/aui/AISingleChoice.rb +18 -1
- data/lib/MINT-core/model/aui/AISingleChoiceElement.rb +10 -56
- data/lib/MINT-core/model/aui/AISinglePresence.rb +39 -71
- data/lib/MINT-core/model/aui/aicommand.scxml +47 -0
- data/lib/MINT-core/model/aui/aicontainer.scxml +41 -0
- data/lib/MINT-core/model/aui/aicontext.scxml +34 -0
- data/lib/MINT-core/model/aui/aiincontinuous.scxml +59 -0
- data/lib/MINT-core/model/aui/aiinrange.scxml +86 -0
- data/lib/MINT-core/model/aui/aimultichoice.scxml +67 -0
- data/lib/MINT-core/model/aui/aimultichoiceelement.scxml +51 -0
- data/lib/MINT-core/model/aui/aio.scxml +18 -27
- data/lib/MINT-core/model/aui/aioutcontinuous.scxml +66 -0
- data/lib/MINT-core/model/aui/aireference.scxml +28 -0
- data/lib/MINT-core/model/aui/aisinglechoice.scxml +60 -0
- data/lib/MINT-core/model/aui/aisinglechoiceelement.scxml +45 -60
- data/lib/MINT-core/model/aui/aisinglepresence.scxml +15 -24
- data/lib/MINT-core/model/aui/model.rb +15 -38
- data/lib/MINT-core/model/cui/gfx/CIC.rb +34 -10
- data/lib/MINT-core/model/cui/gfx/CIO.rb +66 -115
- data/lib/MINT-core/model/cui/gfx/CarouFredSel.scxml +58 -0
- data/lib/MINT-core/model/cui/gfx/MarkableRadioButton.rb +8 -0
- data/lib/MINT-core/model/cui/gfx/RadioButton.rb +8 -0
- data/lib/MINT-core/model/cui/gfx/RadioButtonGroup.rb +6 -0
- data/lib/MINT-core/model/cui/gfx/button.rb +16 -0
- data/lib/MINT-core/model/cui/gfx/button.scxml +58 -0
- data/lib/MINT-core/model/cui/gfx/caroufredsel.rb +48 -0
- data/lib/MINT-core/model/cui/gfx/cic.scxml +57 -0
- data/lib/MINT-core/model/cui/gfx/cio.scxml +54 -0
- data/lib/MINT-core/model/cui/gfx/markableradiobutton.scxml +67 -0
- data/lib/MINT-core/model/cui/gfx/model.rb +39 -176
- data/lib/MINT-core/model/cui/gfx/radiobutton.scxml +59 -0
- data/lib/MINT-core/model/interactor.rb +167 -46
- data/lib/MINT-core/model/interactor.scxml +3 -0
- data/lib/MINT-core/model/interactor_helpers.rb +25 -0
- data/lib/MINT-core/model/ir/body/OneHandPoseNavigation.rb +15 -0
- data/lib/MINT-core/model/ir/body/body.rb +5 -0
- data/lib/MINT-core/model/ir/body/fingertip.rb +114 -0
- data/lib/MINT-core/model/ir/body/fingertip.scxml +43 -0
- data/lib/MINT-core/model/{body → ir/body}/gesture_button.rb +0 -0
- data/lib/MINT-core/model/ir/body/hand.rb +5 -0
- data/lib/MINT-core/model/ir/body/head.rb +102 -0
- data/lib/MINT-core/model/ir/body/head.scxml +92 -0
- data/lib/MINT-core/model/ir/body/onehandposenavigation.scxml +53 -0
- data/lib/MINT-core/model/ir/body/pose.rb +99 -0
- data/lib/MINT-core/model/ir/browserscreen.rb +27 -0
- data/lib/MINT-core/model/ir/browserscreen.scxml +14 -0
- data/lib/MINT-core/model/{device → ir}/button.rb +1 -1
- data/lib/MINT-core/model/ir/ir.rb +5 -0
- data/lib/MINT-core/model/ir/irmedia.rb +5 -0
- data/lib/MINT-core/model/ir/irmode.rb +5 -0
- data/lib/MINT-core/model/{device → ir}/joypad.rb +1 -1
- data/lib/MINT-core/model/ir/mouse.rb +44 -0
- data/lib/MINT-core/model/ir/mouse.scxml +35 -0
- data/lib/MINT-core/model/{device/mouse.rb → ir/mouse_old.rb} +2 -2
- data/lib/MINT-core/model/{device → ir}/pointer.rb +20 -22
- data/lib/MINT-core/model/ir/pointer.scxml +19 -0
- data/lib/MINT-core/model/ir/screen.rb +5 -0
- data/lib/MINT-core/model/{device → ir}/wheel.rb +1 -1
- data/lib/MINT-core/model/mim/aicommand_activate_to_button_press.xml +13 -0
- data/lib/MINT-core/model/mim/aicommand_deactivate_to_button_release.xml +13 -0
- data/lib/MINT-core/model/mim/aio_defocus_to_cio_unhighlight.xml +13 -0
- data/lib/MINT-core/model/mim/aio_focus_to_cio_highlight.xml +14 -0
- data/lib/MINT-core/model/mim/aio_present_to_cio_display.xml +14 -0
- data/lib/MINT-core/model/mim/aio_suspend_to_cio_hide.xml +13 -0
- data/lib/MINT-core/model/mim/aisinglechoice_present_to_child_present.xml +14 -0
- data/lib/MINT-core/model/mim/aisinglechoiceelement_chosen_to_radiobutton_select.xml +13 -0
- data/lib/MINT-core/model/mim/aisinglechoiceelement_unchosen_to_radiobutton_unselect.xml +13 -0
- data/lib/MINT-core/model/mim/aisinglepresence_children_finished_to_caroufredsel_init_js.xml +14 -0
- data/lib/MINT-core/model/mim/aisinglepresence_present_to_child_present.xml +15 -0
- data/lib/MINT-core/model/mim/browserscreen_reload_to_cuicontrol_refresh_all.xml +12 -0
- data/lib/MINT-core/model/mim/button_press_to_aicommand_activate.xml +12 -0
- data/lib/MINT-core/model/mim/button_release_to_aicommand_deactivate.xml +12 -0
- data/lib/MINT-core/model/mim/caroufredsel_refreshing_to_caroufredsel_init_js.xml +14 -0
- data/lib/MINT-core/model/mim/cio_display_to_aio_defocus.xml +13 -0
- data/lib/MINT-core/model/mim/cio_display_to_aio_present.xml +12 -0
- data/lib/MINT-core/model/mim/cio_display_to_cio_display_cache_add.xml +11 -0
- data/lib/MINT-core/model/mim/cio_hide_to_aio_suspend.xml +12 -0
- data/lib/MINT-core/model/mim/cio_hide_to_cio_display_cache_remove.xml +12 -0
- data/lib/MINT-core/model/mim/cio_highlight_to_aio_focus.xml +13 -0
- data/lib/MINT-core/model/mim/head_looking_left_to_aisinglepresence_prev.xml +14 -0
- data/lib/MINT-core/model/mim/head_looking_right_to_aisinglepresence_next.xml +15 -0
- data/lib/MINT-core/model/mim/head_nodding_to_aisinglepresence_next.xml +15 -0
- data/lib/MINT-core/model/mim/head_tilting_left_to_aisinglepresence_prev.xml +14 -0
- data/lib/MINT-core/model/mim/head_tilting_right_to_aisinglepresence_next.xml +15 -0
- data/lib/MINT-core/model/mim/left_button_aisinglepresence_enter.xml +15 -0
- data/lib/MINT-core/model/mim/left_button_aisinglepresence_next.xml +15 -0
- data/lib/MINT-core/model/mim/mim_default.xml +52 -0
- data/lib/MINT-core/model/mim/mint-mappings.xsd +127 -0
- data/lib/MINT-core/model/mim/mouse_press_to_aicommand_activate.xml +17 -0
- data/lib/MINT-core/model/mim/mouse_press_to_aisinglechoiceelement_choose.xml +17 -0
- data/lib/MINT-core/model/mim/mouse_press_to_aisinglechoiceelement_unchoose.xml +17 -0
- data/lib/MINT-core/model/mim/mouse_release_to_aicommand_deactivate.xml +16 -0
- data/lib/MINT-core/model/mim/mouse_stop_to_cio_highlight.xml +13 -0
- data/lib/MINT-core/model/mim/onehandposnav_confirm_to_aichoiceelement_choose.xml +14 -0
- data/lib/MINT-core/model/mim/onehandposnav_next_to_aio_next.xml +14 -0
- data/lib/MINT-core/model/mim/onehandposnav_previous_to_aio_prev.xml +14 -0
- data/lib/MINT-core/model/mim/radiobutton_selected_to_aisinglechoiceelement_choose.xml +13 -0
- data/lib/MINT-core/model/mim/radiobutton_unselected_to_aisinglechoiceelement_unchoose.xml +13 -0
- data/lib/MINT-core/model/mim/right_button_aisinglepresence_prev.xml +15 -0
- data/lib/MINT-core/model/task.rb +6 -6
- data/script/console +0 -0
- data/script/destroy +0 -0
- data/script/generate +0 -0
- data/spec/AICommand_spec.rb +20 -0
- data/spec/AIContainer_spec.rb +161 -0
- data/spec/AIINContinuous_spec.rb +92 -0
- data/spec/AIOUTContinuous_spec.rb +93 -0
- data/spec/AIO_spec.rb +73 -0
- data/spec/AIReference_spec.rb +105 -0
- data/spec/AISinglePresence_spec.rb +204 -60
- data/spec/Button_spec.rb +114 -0
- data/spec/CIO_spec.rb +145 -0
- data/spec/Interactor_spec.rb +95 -0
- data/spec/MappingManager_spec.rb +126 -0
- data/spec/Spontaneous_spec.rb +53 -0
- data/spec/aio_agent_spec.rb +215 -186
- data/spec/aisinglechoice_spec.rb +147 -88
- data/spec/aisinglechoiceelement_spec.rb +154 -70
- data/spec/complementary_mapping_spec.rb +158 -0
- data/spec/core_spec.rb +27 -15
- data/spec/cui_helper.rb +100 -0
- data/spec/examples/browserscreen_reload_to_cuicontrol_refresh_all.xml +12 -0
- data/spec/examples/mim_streaming_example.xml +9 -0
- data/spec/examples/mouse_highlight.xml +22 -0
- data/spec/examples/performance_mapping.xml +15 -0
- data/spec/examples/reset_click.xml +24 -0
- data/spec/interactor_test.scxml +32 -0
- data/spec/interactor_test_2.scxml +16 -0
- data/spec/mapping_performance_spec.rb +118 -0
- data/spec/mapping_server_spec.rb +161 -0
- data/spec/mapping_spec.rb +307 -0
- data/spec/music_spec.rb +301 -135
- data/spec/performance_counter.scxml +9 -0
- data/spec/sequential_mappings_spec.rb +69 -0
- data/spec/shared/aio_shared.rb +144 -0
- data/spec/spec_helper.rb +22 -3
- data/spec/spontaneous.scxml +11 -0
- data/spec/support/connection_helper.rb +19 -0
- data/spec/support/redis_connector_monkey_patch.rb +1 -0
- data/spec/support/statemachine_helper.rb +84 -0
- data/spec/sync_mappings_spec.rb +96 -0
- metadata +219 -354
- data/lib/MINT-core/mapping/complementary.rb +0 -100
- data/lib/MINT-core/mapping/on_state_change.rb +0 -65
- data/lib/MINT-core/model/aui/AIC.rb +0 -86
- data/lib/MINT-core/model/aui/AIChoice.rb +0 -65
- data/lib/MINT-core/model/aui/AIINChoose.rb +0 -54
- data/lib/MINT-core/model/aui/AIOUTDiscrete.rb +0 -43
- data/lib/MINT-core/model/aui/aic.png +0 -0
- data/lib/MINT-core/model/aui/aic.scxml +0 -50
- data/lib/MINT-core/model/aui/aichoice.png +0 -0
- data/lib/MINT-core/model/aui/aichoice.scxml +0 -60
- data/lib/MINT-core/model/aui/aio.png +0 -0
- data/lib/MINT-core/model/aui/aisinglechoiceelement.png +0 -0
- data/lib/MINT-core/model/aui/aisinglepresence.png +0 -0
- data/lib/MINT-core/model/body/handgesture.rb +0 -279
- data/lib/MINT-core/model/body/head.png +0 -0
- data/lib/MINT-core/model/body/head.rb +0 -51
- data/lib/MINT-core/model/body/head.scxml +0 -28
- data/lib/MINT-core/model/cui/gfx/screen.rb +0 -18
- data/lib/MINT-core/overrides/rinda.rb +0 -34
- data/spec/AIC_spec.rb +0 -69
- data/spec/MINT-core_spec.rb +0 -11
- data/spec/aio_spec.rb +0 -144
- data/spec/cio_spec.rb +0 -369
- data/tasks/rspec.rake +0 -21
data/spec/aisinglechoice_spec.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
3
|
describe 'SingleChoice' do
|
4
|
-
|
5
|
-
|
6
|
-
|
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
|
-
|
38
|
-
|
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
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
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
|
-
|
54
|
-
|
55
|
-
|
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
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
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
|
-
|
65
|
-
|
66
|
-
@e1.new_states.should == [:focused]
|
63
|
+
connect do |redis|
|
64
|
+
require "MINT-core"
|
67
65
|
|
68
|
-
|
69
|
-
|
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
|
79
|
-
|
80
|
-
|
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
|
-
|
83
|
-
|
98
|
+
@e1.process_event(:focus).should == [:focused, :unchosen]
|
99
|
+
@e1.states.should == [:focused, :unchosen]
|
84
100
|
|
85
|
-
|
86
|
-
|
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
|
-
|
92
|
-
|
93
|
-
|
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
|
-
|
96
|
-
|
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
|
-
|
103
|
-
|
113
|
+
@e1.process_event(:drag).should == [:focused, :dragging]
|
114
|
+
@e1.states.should == [:focused, :dragging]
|
104
115
|
|
105
|
-
|
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
|
-
|
108
|
-
e1 = MINT::AISingleChoiceElement.first(:name => "element_1")
|
109
|
-
e1.states.should == [:suspended]
|
121
|
+
end
|
110
122
|
end
|
111
123
|
|
112
|
-
it
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
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
|
-
|
139
|
+
sc = MINT::AISingleChoice.first(:name => "choice")
|
121
140
|
|
122
|
-
|
141
|
+
aic = MINT::AIContainer.create(:name => "container", :states=>[:defocused], :children => "choice")
|
123
142
|
|
124
|
-
|
125
|
-
|
126
|
-
|
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
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
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
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
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
|
-
|
5
|
-
|
4
|
+
|
5
|
+
include EventMachine::SpecHelper
|
6
|
+
|
7
|
+
before :all do
|
8
|
+
connection_options = { :adapter => "redis"}
|
6
9
|
DataMapper.setup(:default, connection_options)
|
7
|
-
|
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
|
-
|
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
|
-
|
16
|
-
|
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
|
-
|
21
|
-
|
36
|
+
connect do |redis|
|
37
|
+
@a = MINT::AISingleChoiceElement.create(:name => "test")
|
38
|
+
class CallbackContext
|
39
|
+
attr_accessor :called
|
22
40
|
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
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
|
-
|
61
|
+
callback = CallbackContext.new
|
44
62
|
|
45
63
|
|
46
|
-
|
47
|
-
|
64
|
+
@a.process_event(:organize,callback).should == [:organized]
|
65
|
+
callback.called.should == false
|
48
66
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
-
|
55
|
-
|
56
|
-
|
72
|
+
@a.process_event(:focus,callback).should == [:focused, :unchosen]
|
73
|
+
@a.new_states.should == [:focused]
|
74
|
+
callback.called.should == false
|
57
75
|
|
58
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
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
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
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
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
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
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
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
|
-
|
103
|
-
|
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
|