MINT-core 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gemtest +0 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +69 -0
- data/History.txt +3 -0
- data/MINT-core.gemspec +58 -0
- data/Manifest.txt +77 -0
- data/PostInstall.txt +7 -0
- data/README.rdoc +63 -0
- data/Rakefile +29 -0
- data/bin/mint-aui +40 -0
- data/bin/mint-cui-gfx +47 -0
- data/bin/mint-juggernaut.sh +4 -0
- data/bin/mint-tuplespace +12 -0
- data/lib/MINT-core.rb +42 -0
- data/lib/MINT-core/agent/agent.rb +28 -0
- data/lib/MINT-core/agent/aui.rb +52 -0
- data/lib/MINT-core/agent/auicontrol.rb +135 -0
- data/lib/MINT-core/agent/cui-gfx.rb +160 -0
- data/lib/MINT-core/agent/cuicontrol.rb +46 -0
- data/lib/MINT-core/mapping/complementary.rb +100 -0
- data/lib/MINT-core/mapping/mapping.rb +47 -0
- data/lib/MINT-core/mapping/on_state_change.rb +65 -0
- data/lib/MINT-core/mapping/sequential.rb +87 -0
- data/lib/MINT-core/model/aui/AIC.rb +86 -0
- data/lib/MINT-core/model/aui/AIChoice.rb +65 -0
- data/lib/MINT-core/model/aui/AIINChoose.rb +54 -0
- data/lib/MINT-core/model/aui/AIMultiChoice.rb +5 -0
- data/lib/MINT-core/model/aui/AIMultiChoiceElement.rb +56 -0
- data/lib/MINT-core/model/aui/AIO.rb +170 -0
- data/lib/MINT-core/model/aui/AIOUTDiscrete.rb +43 -0
- data/lib/MINT-core/model/aui/AISingleChoice.rb +9 -0
- data/lib/MINT-core/model/aui/AISingleChoiceElement.rb +69 -0
- data/lib/MINT-core/model/aui/AISinglePresence.rb +100 -0
- data/lib/MINT-core/model/aui/aic.png +0 -0
- data/lib/MINT-core/model/aui/aic.scxml +50 -0
- data/lib/MINT-core/model/aui/aichoice.png +0 -0
- data/lib/MINT-core/model/aui/aichoice.scxml +60 -0
- data/lib/MINT-core/model/aui/aio.png +0 -0
- data/lib/MINT-core/model/aui/aio.scxml +43 -0
- data/lib/MINT-core/model/aui/aisinglechoiceelement.png +0 -0
- data/lib/MINT-core/model/aui/aisinglechoiceelement.scxml +71 -0
- data/lib/MINT-core/model/aui/aisinglepresence.png +0 -0
- data/lib/MINT-core/model/aui/aisinglepresence.scxml +58 -0
- data/lib/MINT-core/model/aui/model.rb +50 -0
- data/lib/MINT-core/model/body/gesture_button.rb +26 -0
- data/lib/MINT-core/model/body/handgesture.rb +279 -0
- data/lib/MINT-core/model/body/head.png +0 -0
- data/lib/MINT-core/model/body/head.rb +51 -0
- data/lib/MINT-core/model/body/head.scxml +28 -0
- data/lib/MINT-core/model/cui/gfx/CIC.rb +266 -0
- data/lib/MINT-core/model/cui/gfx/CIO.rb +381 -0
- data/lib/MINT-core/model/cui/gfx/model.rb +204 -0
- data/lib/MINT-core/model/cui/gfx/screen.rb +18 -0
- data/lib/MINT-core/model/device/button.rb +20 -0
- data/lib/MINT-core/model/device/joypad.rb +30 -0
- data/lib/MINT-core/model/device/mouse.rb +171 -0
- data/lib/MINT-core/model/device/pointer.rb +85 -0
- data/lib/MINT-core/model/device/wheel.rb +51 -0
- data/lib/MINT-core/model/interactor.rb +167 -0
- data/lib/MINT-core/model/task.rb +71 -0
- data/lib/MINT-core/overrides/rinda.rb +34 -0
- data/script/console +10 -0
- data/script/destroy +14 -0
- data/script/generate +14 -0
- data/spec/AIC_spec.rb +69 -0
- data/spec/AISinglePresence_spec.rb +94 -0
- data/spec/MINT-core_spec.rb +11 -0
- data/spec/aio_agent_spec.rb +234 -0
- data/spec/aio_spec.rb +144 -0
- data/spec/aisinglechoice_spec.rb +152 -0
- data/spec/aisinglechoiceelement_spec.rb +106 -0
- data/spec/cio_spec.rb +369 -0
- data/spec/core_spec.rb +29 -0
- data/spec/music_spec.rb +179 -0
- data/spec/rcov.opts +2 -0
- data/spec/spec.opts +4 -0
- data/spec/spec_helper.rb +7 -0
- data/tasks/rspec.rake +21 -0
- metadata +227 -0
data/spec/AIC_spec.rb
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
include MINT
|
4
|
+
describe 'AUI' do
|
5
|
+
before :each do
|
6
|
+
connection_options = { :adapter => "in_memory"}
|
7
|
+
DataMapper.setup(:default, connection_options)
|
8
|
+
# DataMapper.setup(:default, { :adapter => "rinda",:local =>Rinda::TupleSpace.new})
|
9
|
+
AIC.new(:name=>"a", :childs =>[
|
10
|
+
AIO.new(:name => "e1"),
|
11
|
+
AIO.new(:name => "e2"),
|
12
|
+
AIO.new(:name => "e3")
|
13
|
+
]).save
|
14
|
+
|
15
|
+
@a = AIC.first
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'AIC' do
|
19
|
+
it 'should initialize with initiated' do
|
20
|
+
@a.states.should ==[:initialized]
|
21
|
+
@a.new_states.should == [:initialized]
|
22
|
+
end
|
23
|
+
|
24
|
+
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]
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should support navigation to child' do
|
31
|
+
aio = @a.childs.first
|
32
|
+
aio.states=[:defocused]
|
33
|
+
|
34
|
+
@a.states = [:focused]
|
35
|
+
|
36
|
+
@a.process_event(:child)
|
37
|
+
|
38
|
+
@a.states.should ==[:defocused]
|
39
|
+
aio.states.should ==[:focused]
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
it 'should transform all children to presented if presented' do
|
44
|
+
AUIControl.organize(@a,nil,0)
|
45
|
+
# @a.process_event(:organize).should ==[:organized]
|
46
|
+
@a.states.should == [:organized]
|
47
|
+
@a.new_states.should == [:organized]
|
48
|
+
@a.process_event(:present).should ==[:defocused]
|
49
|
+
@a.childs.each do |c|
|
50
|
+
c.states.should == [:defocused]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should transform all children to suspended if suspended' do
|
55
|
+
@a.childs.each do |c|
|
56
|
+
c.states = [:defocused]
|
57
|
+
end
|
58
|
+
@a.states = [:focused]
|
59
|
+
|
60
|
+
@a.process_event(:suspend).should ==[:suspended]
|
61
|
+
@a.childs.each do |c|
|
62
|
+
c.states.should == [:suspended]
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
include MINT
|
4
|
+
describe 'AUI' do
|
5
|
+
before :each do
|
6
|
+
connection_options = { :adapter => "in_memory"}
|
7
|
+
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
|
16
|
+
end
|
17
|
+
|
18
|
+
describe 'AISinglePresence' do
|
19
|
+
it 'should initialize with initiated' do
|
20
|
+
@a.states.should ==[:initialized]
|
21
|
+
@a.new_states.should == [:initialized]
|
22
|
+
end
|
23
|
+
|
24
|
+
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]
|
28
|
+
end
|
29
|
+
|
30
|
+
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]
|
40
|
+
end
|
41
|
+
|
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]
|
45
|
+
|
46
|
+
AIO.first(:name => "e1").states.should == [:defocused]
|
47
|
+
AIO.first(:name => "e2").states.should == [:suspended]
|
48
|
+
AIO.first(:name => "e3").states.should == [:suspended]
|
49
|
+
|
50
|
+
e3 = AIO.first(:name => "e3")
|
51
|
+
e3.states.should ==[:suspended]
|
52
|
+
e3.process_event(:present).should == [:defocused]
|
53
|
+
|
54
|
+
AIO.first(:name => "e1").states.should == [:suspended]
|
55
|
+
AIO.first(:name => "e2").states.should == [:suspended]
|
56
|
+
AIO.first(:name => "e3").states.should == [:defocused]
|
57
|
+
|
58
|
+
e2 = AIO.first(:name => "e2")
|
59
|
+
e2.states.should ==[:suspended]
|
60
|
+
e2.process_event(:present).should == [:defocused]
|
61
|
+
|
62
|
+
AIO.first(:name => "e1").states.should == [:suspended]
|
63
|
+
AIO.first(:name => "e2").states.should == [:defocused]
|
64
|
+
AIO.first(:name => "e3").states.should == [:suspended]
|
65
|
+
|
66
|
+
end
|
67
|
+
|
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]
|
71
|
+
|
72
|
+
AIO.first(:name => "e1").states.should == [:defocused]
|
73
|
+
AIO.first(:name => "e2").states.should == [:suspended]
|
74
|
+
AIO.first(:name => "e3").states.should == [:suspended]
|
75
|
+
|
76
|
+
@a.process_event(:focus).should == [:waiting]
|
77
|
+
@a.process_event(:enter).should == [:entered]
|
78
|
+
@a.process_event(:next).should == [:entered]
|
79
|
+
|
80
|
+
AIO.first(:name => "e1").states.should == [:suspended]
|
81
|
+
AIO.first(:name => "e2").states.should == [:defocused]
|
82
|
+
AIO.first(:name => "e3").states.should == [:suspended]
|
83
|
+
|
84
|
+
@a.process_event(:prev).should == [:entered]
|
85
|
+
|
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
|
+
end
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,234 @@
|
|
1
|
+
require "spec"
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe 'AUI-Agent' do
|
5
|
+
before :each do
|
6
|
+
connection_options = { :adapter => "in_memory"}
|
7
|
+
DataMapper.setup(:default, connection_options)
|
8
|
+
# DataMapper.setup(:default, { :adapter => "rinda", :host =>"localhost",:port=>4000})
|
9
|
+
# ,:local =>Rinda::TupleSpace.new})
|
10
|
+
# DataMapper::Logger.new("data.log", :debug)
|
11
|
+
@aui = AIC.new(:name=>"RecipeFinder",
|
12
|
+
:childs =>[
|
13
|
+
AIINReference.new(:name=>"RecipeFinder_label",:label=>"Willkommen"),
|
14
|
+
AIOUTContext.new(:name=>"RecipeFinder_description",:text=>"Willkommen beim 4 Sterne Koch Assistenten."),
|
15
|
+
AIC.new(:name=>"RecipeFilter",
|
16
|
+
:childs => [
|
17
|
+
AIINReference.new(:name=>"RecipeFilter_label",:label=>"Suchkriterien"),
|
18
|
+
AIOUTContext.new(:name=>"RecipeFilter_description",:text=>"In diesem Feld können Sie mit genauen Angaben zu Ihrem Gericht-Wunsch die Suche nach Ihrem Rezeptvorschlag eingrenzen."),
|
19
|
+
AIC.new(:name=>"RecipeCuisine",
|
20
|
+
:childs=>[
|
21
|
+
AIINReference.new(:name=>"RecipeCuisine_label",:label=>"Nationale Küche"),
|
22
|
+
AIOUTContext.new(:name=>"RecipeCuisine_description",:text=>"Welche nationale Küche wählen Sie? "),
|
23
|
+
AIMultiChoice.new(:name=>"RecipeCuisine_choice",
|
24
|
+
:childs =>[
|
25
|
+
AIINChoose.new(:name => "French", :label =>"Französisch"),
|
26
|
+
AIINChoose.new(:name => "German",:label =>"Deutsch"),
|
27
|
+
AIINChoose.new(:name => "Italian",:label =>"Italienisch"),
|
28
|
+
AIINChoose.new(:name => "Chinese",:label =>"Chinesisch")
|
29
|
+
]
|
30
|
+
)
|
31
|
+
]),
|
32
|
+
AIC.new(:name=>"RecipeCategory",
|
33
|
+
:childs=>[
|
34
|
+
AIINReference.new(:name=>"RecipeCategory_label",:label=>"Menǘart "),
|
35
|
+
AIOUTContext.new(:name=>"RecipeCategory_description",:text=>" Welche Menǘart möchten Sie kochen? "),
|
36
|
+
AIMultiChoice.new(:name=>"RecipeCategory_choice",
|
37
|
+
:childs =>[
|
38
|
+
AIINChoose.new(:name => "Main", :label =>"Hauptgericht"),
|
39
|
+
AIINChoose.new(:name => "Pastry",:label =>"Gebäck"),
|
40
|
+
AIINChoose.new(:name => "Dessert",:label =>"Nachtisch"),
|
41
|
+
AIINChoose.new(:name => "Starter",:label =>"Vorspeise")
|
42
|
+
]
|
43
|
+
)
|
44
|
+
]),
|
45
|
+
AIC.new(:name=>"RecipeCalories",
|
46
|
+
:childs=>[
|
47
|
+
AIINReference.new(:name=>"RecipeCalories_label",:label=>"gesundheitsbewusst "),
|
48
|
+
AIOUTContext.new(:name=>"RecipeCalories_description",:text=>" Wollen Sie gesundheitsbewusst kochen? "),
|
49
|
+
AISingleChoice.new(:name=>"RecipeCalories_choice",
|
50
|
+
:childs =>[
|
51
|
+
AIINChoose.new(:name => "Diet", :label =>"Hauptgericht"),
|
52
|
+
AIINChoose.new(:name => "Low fat",:label =>"Gebäck"),
|
53
|
+
AIINChoose.new(:name => "Not Relevant",:label =>"Nachtisch"),
|
54
|
+
]
|
55
|
+
)
|
56
|
+
]),
|
57
|
+
]),
|
58
|
+
AIC.new(:name =>"RecipeSelection",
|
59
|
+
:childs => [
|
60
|
+
AIINReference.new(:name=>"RecipeSelection_label",:label=>"Rezeptdetails"),
|
61
|
+
AIOUTContext.new(:name=>"RecipeSelection_description",:text=>"Hier werden Ihre Rezeptvorschläge mit den Details angezeigt und Sie können bestimmen, für wieviele Personen das Rezept berechnet werden soll."),
|
62
|
+
AISingleChoice.new(:name=>"FoundRecipes",
|
63
|
+
:childs =>[
|
64
|
+
AIINChoose.new(:name => "Schweinebraten", :label =>"Schweinebraten"),
|
65
|
+
AIINChoose.new(:name => "Lamkotletts",:label =>"Lammkotletts"),
|
66
|
+
AIINChoose.new(:name => "Spagetti",:label =>"Spagetti"),
|
67
|
+
]
|
68
|
+
),
|
69
|
+
AICommand.new(:name=>"Start",:label=>"Kochassistent starten",:description=>"Hier können Sie den Kochassistenten starten.")
|
70
|
+
])
|
71
|
+
])
|
72
|
+
@aui.save!
|
73
|
+
|
74
|
+
end
|
75
|
+
|
76
|
+
describe 'organizing' do
|
77
|
+
|
78
|
+
it 'should save correctly' do
|
79
|
+
class P <Element
|
80
|
+
|
81
|
+
# belongs_to :c
|
82
|
+
belongs_to :parent, 'C',
|
83
|
+
:parent_key => [ :id ], # in the remote model (Blog)
|
84
|
+
:child_key => [ :c_id ], # local to this model (Post)
|
85
|
+
:required => true
|
86
|
+
|
87
|
+
has 1, :next, P
|
88
|
+
has 1, :previous, P
|
89
|
+
end
|
90
|
+
|
91
|
+
class C < P
|
92
|
+
has n, :childs, 'P',
|
93
|
+
:parent_key => [ :id ], # local to this model (Blog)
|
94
|
+
:child_key => [ :c_id ] # in the remote model (Post)
|
95
|
+
|
96
|
+
end
|
97
|
+
|
98
|
+
t2 = P.new(:name=>"Test2")
|
99
|
+
t1 = C.new(:name=>"Test1", :childs =>[t2],:next=>t2)
|
100
|
+
t2.previous = t1
|
101
|
+
|
102
|
+
t1.childs[0].parent.name.should =="Test1"
|
103
|
+
|
104
|
+
t1.save!
|
105
|
+
|
106
|
+
|
107
|
+
P.first(:name=>"Test2").parent.name.should == "Test1"
|
108
|
+
P.first(:name=>"Test2").previous.name.should == "Test1"
|
109
|
+
C.first(:name=>"Test1").next.name.should == "Test2"
|
110
|
+
end
|
111
|
+
|
112
|
+
it "should organize parental relations correctly" do
|
113
|
+
aic = AIC.new(:name =>"AIC", :childs=>[AIO.new(:name=>"AIO")])
|
114
|
+
aic.save!
|
115
|
+
|
116
|
+
AIO.first(:name=>"AIO").parent.name.should == "AIC"
|
117
|
+
end
|
118
|
+
|
119
|
+
it "should organize parental relations correctly 2" do
|
120
|
+
AIC.new(:name=>"RecipeFinder",
|
121
|
+
:childs =>[
|
122
|
+
AIINReference.new(:name=>"RecipeFinder_label",:label=>"Willkommen")]).save!
|
123
|
+
|
124
|
+
AIO.first(:name=>"RecipeFinder_label").parent.name.should == "RecipeFinder"
|
125
|
+
end
|
126
|
+
|
127
|
+
it "should organize parental relations correctly 3" do
|
128
|
+
AIO.first(:name=>"RecipeFinder_label").parent.name.should == "RecipeFinder"
|
129
|
+
end
|
130
|
+
|
131
|
+
it 'should organize with parental relationships 4' do
|
132
|
+
AIINChoose.first(:name => "Main").parent.name.should == "RecipeCategory_choice"
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'should support next navigation' do
|
136
|
+
pending("get the organize function working")
|
137
|
+
AUIControl.organize(@aui)
|
138
|
+
@aui.save!#.should==true
|
139
|
+
@aui.next.name.should=="RecipeFinder_label"
|
140
|
+
@aui.next.next.next.next.name.should=="RecipeFilter_label"
|
141
|
+
|
142
|
+
|
143
|
+
n = AIO.first(:name => "RecipeFinder")
|
144
|
+
10.times {n=n.next}
|
145
|
+
n.name.should=="French"
|
146
|
+
12.times {n=n.next}
|
147
|
+
n.name.should=="RecipeCalories"
|
148
|
+
14.times {n=n.next}
|
149
|
+
n.name.should=="Start"
|
150
|
+
end
|
151
|
+
|
152
|
+
it "should support previous navigation" do
|
153
|
+
|
154
|
+
AUIControl.organize(@aui)
|
155
|
+
|
156
|
+
@aui.save! # there is still a bug, because save results in false!!
|
157
|
+
#.should==true
|
158
|
+
|
159
|
+
n = AIO.first(:name => "Start")
|
160
|
+
# n = @aui #
|
161
|
+
# 36.times {n=n.next}
|
162
|
+
#n.name.should=="Start"
|
163
|
+
|
164
|
+
10.times {n=n.previous}
|
165
|
+
n.name.should=="Diet"
|
166
|
+
4.times {n=n.previous}
|
167
|
+
n.name.should=="RecipeCalories"
|
168
|
+
22.times {n=n.previous}
|
169
|
+
n.name.should=="RecipeFinder"
|
170
|
+
end
|
171
|
+
|
172
|
+
it 'should support next navigation in organize 2' do
|
173
|
+
pending("get the organize2 function working")
|
174
|
+
AUIControl.organize2(@aui)
|
175
|
+
# @aui.save#.should==true
|
176
|
+
# @aui.next.name.should=="RecipeFinder"
|
177
|
+
# @aui.next.next.next.next.name.should=="RecipeFinder"
|
178
|
+
|
179
|
+
|
180
|
+
n = AIO.first(:name => "RecipeFinder_label")
|
181
|
+
3.times {n=n.next}
|
182
|
+
n.name.should=="RecipeSelection"
|
183
|
+
|
184
|
+
n = AIO.first(:name => "RecipeCalories_label")
|
185
|
+
2.times {n=n.next}
|
186
|
+
n.name.should=="RecipeCalories_choice"
|
187
|
+
|
188
|
+
# n = AIO.first(:name => "Start")
|
189
|
+
# 7.times {n=n.next}
|
190
|
+
# n.name.should=="FoundRecipes"
|
191
|
+
end
|
192
|
+
|
193
|
+
it "should support previous navigation in organize 2" do
|
194
|
+
|
195
|
+
AUIControl.organize2(@aui)
|
196
|
+
|
197
|
+
@aui.save # there is still a bug, because save results in false!!
|
198
|
+
#.should==true
|
199
|
+
|
200
|
+
n = AIO.first(:name => "Start")
|
201
|
+
# n = @aui #
|
202
|
+
# 36.times {n=n.next}
|
203
|
+
#n.name.should=="Start"
|
204
|
+
|
205
|
+
3.times {n=n.previous}
|
206
|
+
n.name.should=="RecipeSelection_label"
|
207
|
+
|
208
|
+
n = AIO.first(:name => "RecipeCalories")
|
209
|
+
2.times {n=n.previous}
|
210
|
+
n.name.should=="RecipeCuisine"
|
211
|
+
|
212
|
+
# n = AIO.first(:name => "RecipeFinder")
|
213
|
+
# 3.times {n=n.previous}
|
214
|
+
# n.name.should=="RecipeFinder"
|
215
|
+
end
|
216
|
+
|
217
|
+
it "should find the correct common aic for only one task in ETS" do
|
218
|
+
AUIControl.find_common(["Start"]).should=="Start"
|
219
|
+
end
|
220
|
+
|
221
|
+
it "should find the correct common aic for a given ETS" do
|
222
|
+
AUIControl.find_common(["RecipeCuisine","RecipeCategory"]).should=="RecipeFilter"
|
223
|
+
AUIControl.find_common(["Schweinebraten","RecipeSelection_description"]).should=="RecipeSelection"
|
224
|
+
AUIControl.find_common(["Italian","Starter"]).should=="RecipeFilter"
|
225
|
+
AUIControl.find_common(["RecipeFinder_label","RecipeFinder_description"]).should=="RecipeFinder"
|
226
|
+
AUIControl.find_common(["Schweinebraten","RecipeCalories_choice","RecipeFinder_description"]).should=="RecipeFinder"
|
227
|
+
end
|
228
|
+
|
229
|
+
it "should find the correct common AIC for a given ETS 2" do
|
230
|
+
AUIControl.find_common(["RecipeCategory","Start", "FoundRecipes"]).should=="RecipeFinder"
|
231
|
+
AUIControl.find_common(["RecipeCategory", "Start", "FoundRecipes", "RecipeCuisine", "RecipeCalories"]).should=="RecipeFinder"
|
232
|
+
end
|
233
|
+
end
|
234
|
+
end
|
data/spec/aio_spec.rb
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe 'AUI' do
|
4
|
+
before :each do
|
5
|
+
connection_options = { :adapter => "in_memory"}
|
6
|
+
DataMapper.setup(:default, connection_options)
|
7
|
+
# DataMapper.setup(:default, { :adapter => "rinda",:local =>Rinda::TupleSpace.new})
|
8
|
+
@a = MINT::AIO.create(:name => "test")
|
9
|
+
|
10
|
+
end
|
11
|
+
|
12
|
+
describe 'AIO' do
|
13
|
+
it 'should initialize with initiated' do
|
14
|
+
@a.states.should ==[:initialized]
|
15
|
+
@a.new_states.should == [:initialized]
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should transform to organizing state for present action' do
|
19
|
+
@a.process_event(:organize).should ==[:organized]
|
20
|
+
@a.states.should == [:organized]
|
21
|
+
@a.new_states.should == [:organized]
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should call back after event has been processed' do
|
25
|
+
class CallbackContext
|
26
|
+
attr_accessor :called
|
27
|
+
|
28
|
+
def initialize
|
29
|
+
@called = false
|
30
|
+
end
|
31
|
+
def focus_next
|
32
|
+
@called = true
|
33
|
+
end
|
34
|
+
def inform_parent_presenting
|
35
|
+
end
|
36
|
+
|
37
|
+
def sync_cio_to_displayed
|
38
|
+
end
|
39
|
+
def sync_cio_to_highlighted
|
40
|
+
end
|
41
|
+
def exists_next
|
42
|
+
true
|
43
|
+
end
|
44
|
+
def exists_prev
|
45
|
+
true
|
46
|
+
end
|
47
|
+
|
48
|
+
end
|
49
|
+
|
50
|
+
callback = CallbackContext.new
|
51
|
+
|
52
|
+
@a.process_event(:organize,callback).should == [:organized]
|
53
|
+
callback.called.should == false
|
54
|
+
|
55
|
+
@a.process_event(:present,callback).should == [:defocused]
|
56
|
+
callback.called.should == false
|
57
|
+
|
58
|
+
@a.process_event(:focus,callback).should == [:focused]
|
59
|
+
callback.called.should == false
|
60
|
+
|
61
|
+
@a.process_event(:next,callback).should == [:defocused]
|
62
|
+
callback.called.should == true
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should recover state after save and reload' do
|
66
|
+
@a.process_event(:organize).should == [:organized]
|
67
|
+
@a.save!
|
68
|
+
b = MINT::AIO.first(:name=>"test")
|
69
|
+
b.states.should == [:organized]
|
70
|
+
b.process_event(:present).should == [:defocused]
|
71
|
+
end
|
72
|
+
|
73
|
+
it 'should store the state' do
|
74
|
+
a = MINT::AIINReference.create(:name=>"RecipeSelection_label",:label=>"Rezeptdetails")
|
75
|
+
a.states.should == [:initialized]
|
76
|
+
a.process_event(:organize)
|
77
|
+
a.states.should == [:organized]
|
78
|
+
a.save!
|
79
|
+
MINT::AIINReference.first(:name=>"RecipeSelection_label").states.should == [:organized]
|
80
|
+
end
|
81
|
+
|
82
|
+
#TODO Bug first sets states to array not sure ahy
|
83
|
+
|
84
|
+
# it "should process after load" do
|
85
|
+
# t = MINT::AIO.create(:name => "p")
|
86
|
+
#
|
87
|
+
# b = MINT::AIO.first(:name => "p")
|
88
|
+
# # b.states.should == [:initialized]
|
89
|
+
# b.process_event(:organized)
|
90
|
+
#
|
91
|
+
# end
|
92
|
+
|
93
|
+
|
94
|
+
it 'should focus to next element' do
|
95
|
+
b = MINT::AIO.create(:name=>"next")
|
96
|
+
@a.next = b
|
97
|
+
b.previous =@a
|
98
|
+
|
99
|
+
@a.process_event(:organize)
|
100
|
+
b.process_event(:organize)
|
101
|
+
|
102
|
+
@a.process_event(:present)
|
103
|
+
b.process_event(:present)
|
104
|
+
|
105
|
+
@a.process_event(:focus).should == [:focused]
|
106
|
+
|
107
|
+
@a.process_event(:next).should == [:defocused]
|
108
|
+
b.states.should ==[:focused]
|
109
|
+
@a.states.should ==[:defocused]
|
110
|
+
end
|
111
|
+
|
112
|
+
it 'should not defocus on next if there is no next element' do
|
113
|
+
@a.states=[:focused]
|
114
|
+
@a.process_event(:next)
|
115
|
+
@a.states.should == [:focused]
|
116
|
+
end
|
117
|
+
|
118
|
+
it 'should not defocus on prev if there is no previous element' do
|
119
|
+
@a.states=[:focused]
|
120
|
+
@a.process_event(:prev).should ==[:focused]
|
121
|
+
end
|
122
|
+
|
123
|
+
it 'should handle previous' do
|
124
|
+
@a.states=[:defocused]
|
125
|
+
b = MINT::AIO.new(:name=>"test", :previous =>@a)
|
126
|
+
b.states= [:focused]
|
127
|
+
b.process_event(:prev)
|
128
|
+
|
129
|
+
@a.states.should ==[:focused]
|
130
|
+
b.states.should ==[:defocused]
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'should handle parent' do
|
134
|
+
@a.states=[:focused]
|
135
|
+
b = MINT::AIC.new(:name=>"parent",:childs =>[@a])
|
136
|
+
b.states = [:defocused]
|
137
|
+
@a.process_event(:parent)
|
138
|
+
|
139
|
+
@a.states.should ==[:defocused]
|
140
|
+
b.states.should ==[:focused]
|
141
|
+
end
|
142
|
+
end
|
143
|
+
|
144
|
+
end
|