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/Button_spec.rb
ADDED
@@ -0,0 +1,114 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
require "em-spec/rspec"
|
4
|
+
|
5
|
+
require "cui_helper"
|
6
|
+
|
7
|
+
|
8
|
+
describe 'CUI' do
|
9
|
+
include EventMachine::SpecHelper
|
10
|
+
|
11
|
+
before :all do
|
12
|
+
connection_options = { :adapter => "redis"}
|
13
|
+
DataMapper.setup(:default, connection_options)
|
14
|
+
|
15
|
+
|
16
|
+
connect do |redis|
|
17
|
+
require "MINT-core"
|
18
|
+
require "support/redis_connector_monkey_patch" # TODO dirty patch for a bug that i have not found :(
|
19
|
+
|
20
|
+
DataMapper.finalize
|
21
|
+
DataMapper::Model.raise_on_save_failure = true
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe 'Button' do
|
26
|
+
|
27
|
+
it 'should initialize' do
|
28
|
+
connect true do |redis|
|
29
|
+
require "MINT-core"
|
30
|
+
|
31
|
+
DataMapper.finalize
|
32
|
+
|
33
|
+
test_state_flow redis,"Interactor.CIO.Button.test" ,%w(initialized) do
|
34
|
+
|
35
|
+
MINT::Button.create(:name => "test")
|
36
|
+
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
it 'should highlight based on AICommand update to focus' do
|
41
|
+
connect true,120 do |redis|
|
42
|
+
|
43
|
+
parser = MINT::MappingParser.new
|
44
|
+
m = parser.build_from_scxml File.dirname(__FILE__)+"/../lib/MINT-core/model/mim/aio_present_to_cio_display.xml"
|
45
|
+
m.start
|
46
|
+
|
47
|
+
# Sync AIO to focused
|
48
|
+
parser = MINT::MappingParser.new
|
49
|
+
m = parser.build_from_scxml File.dirname(__FILE__)+"/../lib/MINT-core/model/mim/aio_focus_to_cio_highlight.xml"
|
50
|
+
m.start
|
51
|
+
|
52
|
+
test_state_flow redis,"Interactor.CIO.Button.reset" ,[["p", "b", "displaying", "d", "released", "init_js"] ,"displayed","highlighted"] do
|
53
|
+
MINT::Button.create(:name=>"reset",:height =>60, :width => 200, :x=>380, :y => 150, :states=>[:positioned], :highlightable =>true)
|
54
|
+
c = MINT::AICommand.create(:name=>"reset", :states=>[:organized])
|
55
|
+
c.process_event :present
|
56
|
+
c.process_event :focus
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'should sync to pressed and released based on AICommand' do
|
62
|
+
connect true,120 do |redis|
|
63
|
+
|
64
|
+
parser = MINT::MappingParser.new
|
65
|
+
m = parser.build_from_scxml File.dirname(__FILE__)+"/../lib/MINT-core/model/mim/aio_present_to_cio_display.xml"
|
66
|
+
m.start
|
67
|
+
|
68
|
+
parser = MINT::MappingParser.new
|
69
|
+
m = parser.build_from_scxml File.dirname(__FILE__)+"/../lib/MINT-core/model/mim/aio_focus_to_cio_highlight.xml"
|
70
|
+
m.start
|
71
|
+
|
72
|
+
parser = MINT::MappingParser.new
|
73
|
+
m = parser.build_from_scxml File.dirname(__FILE__)+"/../lib/MINT-core/model/mim/aicommand_activate_to_button_press.xml"
|
74
|
+
m.start
|
75
|
+
|
76
|
+
parser = MINT::MappingParser.new
|
77
|
+
m = parser.build_from_scxml File.dirname(__FILE__)+"/../lib/MINT-core/model/mim/aicommand_deactivate_to_button_release.xml"
|
78
|
+
m.start
|
79
|
+
|
80
|
+
|
81
|
+
test_state_flow redis,"Interactor.CIO.Button.reset" ,[["p", "b", "displaying", "d", "released", "init_js"],"displayed","highlighted","pressed","released"] do
|
82
|
+
MINT::Button.create(:name=>"reset",:height =>60, :width => 200, :x=>380, :y => 150, :states=>[:positioned], :highlightable =>true)
|
83
|
+
c = MINT::AICommand.create(:name=>"reset", :states=>[:organized])
|
84
|
+
c.process_event :present
|
85
|
+
c.process_event :focus
|
86
|
+
c.process_event :activate
|
87
|
+
c.process_event :deactivate
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
it 'should highlight' do
|
95
|
+
connect true do |redis|
|
96
|
+
require "MINT-core"
|
97
|
+
|
98
|
+
DataMapper.finalize
|
99
|
+
|
100
|
+
test_state_flow redis,"Interactor.CIO.Button.reset" ,[["p", "b", "displaying", "d", "released", "init_js"],"displayed","highlighted"] do
|
101
|
+
|
102
|
+
b = MINT::Button.create(:name=>"reset",:height =>60, :width => 200, :x=>380, :y => 150, :states=>[:positioned], :highlightable =>true)
|
103
|
+
b.process_event :display
|
104
|
+
b.process_event :highlight
|
105
|
+
|
106
|
+
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
|
111
|
+
end
|
112
|
+
end
|
113
|
+
|
114
|
+
end
|
data/spec/CIO_spec.rb
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
require "em-spec/rspec"
|
4
|
+
|
5
|
+
require "cui_helper"
|
6
|
+
|
7
|
+
|
8
|
+
describe 'CUI' do
|
9
|
+
include EventMachine::SpecHelper
|
10
|
+
|
11
|
+
before :all do
|
12
|
+
connection_options = { :adapter => "redis"}
|
13
|
+
DataMapper.setup(:default, connection_options)
|
14
|
+
|
15
|
+
|
16
|
+
connect do |redis|
|
17
|
+
require "MINT-core"
|
18
|
+
class Logging
|
19
|
+
def self.log(mapping,data)
|
20
|
+
p "log: #{mapping} #{data}"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
DataMapper.finalize
|
24
|
+
DataMapper::Model.raise_on_save_failure = true
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
describe 'CIO' do
|
29
|
+
|
30
|
+
it 'should accept and save user and device with position event' do
|
31
|
+
pending "user and device still need to be defined - will be moved to AIO!!!"
|
32
|
+
connect do |redis|
|
33
|
+
require "MINT-core"
|
34
|
+
|
35
|
+
DataMapper.finalize
|
36
|
+
|
37
|
+
test_state_flow redis,"Interactor.CIO" ,%w(initialized positioning)
|
38
|
+
|
39
|
+
MINT::CIO.create(:name => "center")
|
40
|
+
@c = MINT::CIO.first
|
41
|
+
|
42
|
+
@c.process_event_vars(:position,"testuser","testdevice").should ==[:positioning]
|
43
|
+
@c = MINT::CIO.first
|
44
|
+
|
45
|
+
@c.user.should =="testuser"
|
46
|
+
@c.device.should == "testdevice"
|
47
|
+
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
|
53
|
+
it 'should serialize to JSON' do
|
54
|
+
require 'dm-serializer'
|
55
|
+
# => { "id": 1, "name": "Berta" }
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should initialize with initiated' do
|
59
|
+
connect do |redis|
|
60
|
+
center = CUIHelper.create_structure
|
61
|
+
|
62
|
+
center.states.should == [:initialized]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should transform to display state after sequence of position,calculate, ready events ' do
|
67
|
+
connect do |redis|
|
68
|
+
CUIHelper.create_structure
|
69
|
+
center = MINT::CIO.first(:name => "center")
|
70
|
+
center.process_event(:position).should ==[:positioning]
|
71
|
+
center.process_event(:calculated).should ==[:positioned]
|
72
|
+
center.process_event(:display).should ==[:displayed]
|
73
|
+
center.states.should == [:displayed]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
describe "highlighting" do
|
80
|
+
|
81
|
+
it 'should move highlight to up and down' do
|
82
|
+
connect do |redis|
|
83
|
+
center=CUIHelper.create_structure_w_highlighted
|
84
|
+
center.process_event("up").should ==[:displayed]
|
85
|
+
|
86
|
+
up = MINT::CIO.first(:name=>"up")
|
87
|
+
up.states.should ==[:highlighted]
|
88
|
+
|
89
|
+
up.process_event("down").should == [:displayed]
|
90
|
+
MINT::CIO.first(:name=>"center").states.should ==[:highlighted]
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
it 'should move highlight to left and right' do
|
95
|
+
connect do |redis|
|
96
|
+
center = CUIHelper.create_structure_w_highlighted
|
97
|
+
center.process_event("left").should ==[:displayed]
|
98
|
+
|
99
|
+
left = MINT::CIO.first(:name=>"left")
|
100
|
+
left.states.should ==[:highlighted]
|
101
|
+
|
102
|
+
left.process_event("right").should == [:displayed]
|
103
|
+
MINT::CIO.first(:name=>"center").states.should ==[:highlighted]
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
end
|
111
|
+
|
112
|
+
describe 'mouse' do
|
113
|
+
it "should highlight CIOs based on coordinates retrieved by mouse" do
|
114
|
+
connect do |redis|
|
115
|
+
|
116
|
+
MINT::AIO.create(:name=>"left_2x",:states =>[:presented])
|
117
|
+
a= MINT::CIO.create(:name=>"left_2x",:x=>1,:y =>1, :width=>390,:height =>800,:states => [:displayed], :highlightable => true)
|
118
|
+
MINT::AIO.create(:name=>"right_2x",:states =>[:presented])
|
119
|
+
b= MINT::CIO.create(:name=>"right_2x",:x=>400,:y =>2, :width=>389,:height =>799,:states => [:displayed], :highlightable => true)
|
120
|
+
|
121
|
+
puts b.pos.Xvalue
|
122
|
+
|
123
|
+
CUIControl.fill_active_cio_cache
|
124
|
+
|
125
|
+
Result = Struct.new(:x, :y)
|
126
|
+
|
127
|
+
CUIControl.find_cio_from_coordinates(Result.new(10,10))
|
128
|
+
|
129
|
+
a = MINT::CIO.first(:name=>"left_2x")
|
130
|
+
a.states.should==[:highlighted]
|
131
|
+
MINT::CIO.first(:name=>"right_2x").states.should==[:displayed]
|
132
|
+
|
133
|
+
CUIControl.find_cio_from_coordinates(Result.new(410,10))
|
134
|
+
|
135
|
+
MINT::CIO.first(:name=>"left_2x").states.should==[:displayed]
|
136
|
+
MINT::CIO.first(:name=>"right_2x").states.should==[:highlighted]
|
137
|
+
|
138
|
+
CUIControl.find_cio_from_coordinates(Result.new(395,10))
|
139
|
+
|
140
|
+
MINT::CIO.first(:name=>"left_2x").states.should==[:displayed]
|
141
|
+
MINT::CIO.first(:name=>"right_2x").states.should==[:displayed]
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
require "em-spec/rspec"
|
4
|
+
|
5
|
+
|
6
|
+
describe 'Interactor' do
|
7
|
+
include EventMachine::SpecHelper
|
8
|
+
|
9
|
+
before :all do
|
10
|
+
|
11
|
+
connection_options = { :adapter => "redis"}
|
12
|
+
DataMapper.setup(:default, connection_options)
|
13
|
+
|
14
|
+
connect do |redis|
|
15
|
+
require "MINT-core"
|
16
|
+
require "support/redis_connector_monkey_patch" # TODO dirty patch for a bug that i have not found :(
|
17
|
+
|
18
|
+
class InteractorTest < MINT::Interactor
|
19
|
+
def getSCXML
|
20
|
+
"#{File.dirname(__FILE__)}/interactor_test.scxml"
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
DataMapper.finalize
|
25
|
+
DataMapper::Model.raise_on_save_failure = true
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
describe 'synchronized with RedisDB' do
|
31
|
+
it 'should initialize with initiated' do
|
32
|
+
connect do |redis|
|
33
|
+
|
34
|
+
@a = InteractorTest.create(:name => "test")
|
35
|
+
@a.states.should ==[:initialized]
|
36
|
+
@a.abstract_states.should =="InteractorTest|root"
|
37
|
+
|
38
|
+
@a.new_states.should == [:initialized]
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
it 'should transform to organizing and presenting state' do
|
43
|
+
connect do |redis|
|
44
|
+
@a = InteractorTest.create(:name => "test")
|
45
|
+
@a.process_event(:organize)
|
46
|
+
@a.abstract_states.should == "InteractorTest|root"
|
47
|
+
@a.new_states.should == [:organized]
|
48
|
+
@a.process_event(:present)
|
49
|
+
@a.new_states.should == [:defocused, :in, :presenting, :f, :g]
|
50
|
+
@a.abstract_states.should == "InteractorTest|root|presenting|f|g"
|
51
|
+
@a.process_event(:out)
|
52
|
+
@a.new_states.should == [:out]
|
53
|
+
@a.abstract_states.should == "InteractorTest|root|presenting|f|g"
|
54
|
+
@a.process_event(:focus)
|
55
|
+
@a.new_states.should == [:focused]
|
56
|
+
@a.abstract_states.should == "InteractorTest|root|presenting|f|g"
|
57
|
+
@a.process_event(:suspend)
|
58
|
+
@a.new_states.should == [:suspended]
|
59
|
+
@a.abstract_states.should == "InteractorTest|root"
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
describe 'synchronized with Redis-PubSub' do
|
65
|
+
it 'should initialize with initiated' do
|
66
|
+
connect true do |redis|
|
67
|
+
|
68
|
+
test_state_flow RedisConnector.redis,"Interactor.InteractorTest.test" ,%w(initialized) do
|
69
|
+
|
70
|
+
@a = InteractorTest.create(:name => "test")
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
|
77
|
+
it 'should transform to organizing state for present action' do
|
78
|
+
connect true do |redis|
|
79
|
+
|
80
|
+
test_state_flow redis,"Interactor.InteractorTest.test" ,["initialized", "organized", ["presenting", "f", "g", "defocused", "in"],"out"] do
|
81
|
+
@a = InteractorTest.create(:name => "test")
|
82
|
+
@a.process_event(:organize)
|
83
|
+
@a.process_event(:present)
|
84
|
+
@a.process_event(:out)
|
85
|
+
|
86
|
+
end
|
87
|
+
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
@@ -0,0 +1,126 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
require "em-spec/rspec"
|
3
|
+
|
4
|
+
describe 'MappingManager' do
|
5
|
+
include EventMachine::SpecHelper
|
6
|
+
|
7
|
+
before :all do
|
8
|
+
connection_options = { :adapter => "redis"}
|
9
|
+
DataMapper.setup(:default, connection_options)
|
10
|
+
|
11
|
+
|
12
|
+
connect do |redis|
|
13
|
+
require "MINT-core"
|
14
|
+
require "support/redis_connector_monkey_patch" # TODO dirty patch for a bug that i have not found :(
|
15
|
+
DataMapper.finalize
|
16
|
+
DataMapper::Model.raise_on_save_failure = true
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
it 'should register and call callback for loaded' do
|
22
|
+
connect true do |redis|
|
23
|
+
m = MappingManager.new
|
24
|
+
@data = []
|
25
|
+
|
26
|
+
def my_callback(mapping_name,data)
|
27
|
+
if mapping_name.eql? "Reset Click"
|
28
|
+
@data << data
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
m.register_callback("Reset Click", method(:my_callback))
|
33
|
+
m.load(File.dirname(__FILE__) +"/examples/mim_streaming_example.xml")
|
34
|
+
d = @data.shift
|
35
|
+
d[:mapping_state].should == :loaded
|
36
|
+
@data.length.should == 0
|
37
|
+
done
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
|
42
|
+
it 'should register and call callback for loaded and started' do
|
43
|
+
connect true do |redis|
|
44
|
+
|
45
|
+
m = MappingManager.new
|
46
|
+
@data = []
|
47
|
+
|
48
|
+
def my_callback(mapping_name,data)
|
49
|
+
if mapping_name.eql? "Mouse Interactor Highlighting"
|
50
|
+
@data << data
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
m.register_callback("Mouse Interactor Highlighting", method(:my_callback))
|
55
|
+
m.load(File.dirname(__FILE__) +"/examples/mim_streaming_example.xml")
|
56
|
+
|
57
|
+
d = @data.shift
|
58
|
+
d[:mapping_state].should == :loaded
|
59
|
+
|
60
|
+
d = @data.shift
|
61
|
+
d[:mapping_state].should == :started
|
62
|
+
#There are other callbacks @data.length.should == 0
|
63
|
+
done
|
64
|
+
end
|
65
|
+
|
66
|
+
end
|
67
|
+
|
68
|
+
it 'should activate observations after mapping has been started' do
|
69
|
+
# pending "Needs to be fixed by Jessica"
|
70
|
+
connect true,120 do |redis|
|
71
|
+
|
72
|
+
|
73
|
+
m = MappingManager.new
|
74
|
+
@counter = 0
|
75
|
+
|
76
|
+
# we need to move all checks into the callback, since after the mapping is started, we are async...
|
77
|
+
def my_callback(mapping_name,data)
|
78
|
+
if mapping_name.eql? "Mouse Interactor Highlighting"
|
79
|
+
p @counter
|
80
|
+
case @counter
|
81
|
+
when 0
|
82
|
+
data[:mapping_state].should == :loaded
|
83
|
+
when 1
|
84
|
+
data[:mapping_state].should == :started
|
85
|
+
when 2
|
86
|
+
data[:id].should == "111"
|
87
|
+
data[:state].should == :activated
|
88
|
+
|
89
|
+
@mouse = MINT::Mouse.create(:name =>"mouse") # previously activated observation should be false
|
90
|
+
|
91
|
+
when 3
|
92
|
+
data[:id].should == "111"
|
93
|
+
data[:state].should == :false
|
94
|
+
@mouse.process_event :connect # observation should be true
|
95
|
+
when 4
|
96
|
+
data[:id].should == "111"
|
97
|
+
data[:state].should == :true
|
98
|
+
when 5
|
99
|
+
data[:id].should == "2222"
|
100
|
+
data[:state].should == :activated
|
101
|
+
when 6
|
102
|
+
data[:id].should == "2222"
|
103
|
+
data[:state].should == :succeeded
|
104
|
+
when 7
|
105
|
+
data[:id].should == "33113"
|
106
|
+
data[:mapping_state].should == :succeeded
|
107
|
+
when 8
|
108
|
+
data[:id].should == "33113"
|
109
|
+
data[:mapping_state].should == :restarted #cool would be :restarted for this case
|
110
|
+
when 9
|
111
|
+
data[:id].should == "111"
|
112
|
+
data[:state].should == :activated
|
113
|
+
p "terminate"
|
114
|
+
done
|
115
|
+
end
|
116
|
+
@counter +=1
|
117
|
+
end
|
118
|
+
end
|
119
|
+
|
120
|
+
m.register_callback("Mouse Interactor Highlighting",method(:my_callback))
|
121
|
+
m.load(File.dirname(__FILE__) +"/examples/mim_streaming_example.xml")
|
122
|
+
|
123
|
+
|
124
|
+
end
|
125
|
+
end
|
126
|
+
end
|