flok 0.0.103 → 0.0.105
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/drivers/chrome/config.yml +2 -0
- data/app/drivers/chrome/src/about.js +14 -0
- data/app/drivers/chrome/src/guid.js +9 -0
- data/app/drivers/chrome/src/net.js +25 -3
- data/app/kern/mod/about.js +19 -0
- data/app/kern/mod/hook.js +2 -2
- data/app/kern/mod/udid.js +9 -0
- data/app/kern/services/rest.rb +67 -8
- data/bin/flok +14 -0
- data/docs/mod/about.md +19 -0
- data/docs/mod/net.md +9 -4
- data/docs/mod/ui.md +1 -1
- data/docs/services/rest.md +24 -2
- data/docs/services/vm.md +4 -0
- data/docs/user_handbook/hooks.md +61 -5
- data/lib/flok/hooks_compiler.rb +6 -0
- data/lib/flok/user_compiler.rb +33 -5
- data/lib/flok/user_hook_generators/goto.rb +25 -3
- data/lib/flok/user_hook_generators/pop.rb +99 -0
- data/lib/flok/user_hook_generators/push.rb +119 -0
- data/lib/flok/version.rb +1 -1
- data/spec/iface/driver/about_spec.rb +14 -0
- data/spec/iface/driver/net_spec.rb +91 -2
- data/spec/iface/driver/ping_spec.rb +1 -0
- data/spec/kern/about_spec.rb +30 -0
- data/spec/kern/assets/hook_entry_points/controller0a_push.rb +31 -0
- data/spec/kern/assets/hook_entry_points/controller0b.rb +17 -0
- data/spec/kern/assets/hook_entry_points/controller0bc.rb +27 -0
- data/spec/kern/assets/hook_entry_points/controller_0b_pop.rb +18 -0
- data/spec/kern/assets/hook_entry_points/controller_0b_pop2.rb +66 -0
- data/spec/kern/assets/hook_entry_points/controller_0b_push.rb +15 -0
- data/spec/kern/assets/hook_entry_points/controller_0b_push2.rb +55 -0
- data/spec/kern/assets/rest_service/controller1b.rb +47 -0
- data/spec/kern/hook_entry_points_and_manifest_spec.rb +174 -0
- data/spec/kern/{hook_user_generators_spec.rb → hook_goto_user_generators_spec.rb} +145 -7
- data/spec/kern/hook_pop_user_generators_spec.rb +292 -0
- data/spec/kern/hook_push_user_generators_spec.rb +305 -0
- data/spec/kern/rest_service_spec.rb +97 -1
- data/spec/lib/helpers.rb +5 -3
- metadata +35 -5
- data/lib/flok/user_hook_generators/helpers.rb +0 -46
@@ -9,7 +9,7 @@ require './spec/lib/rspec_extensions.rb'
|
|
9
9
|
require './lib/flok/hooks_compiler.rb'
|
10
10
|
require 'zlib'
|
11
11
|
|
12
|
-
RSpec.describe "kern:
|
12
|
+
RSpec.describe "kern:hook_goto_user_generators_spec" do
|
13
13
|
include Zlib
|
14
14
|
include_context "kern"
|
15
15
|
|
@@ -58,6 +58,31 @@ RSpec.describe "kern:hook_user_geenrators_spec" do
|
|
58
58
|
expect { @driver.ignore_up_to("if_hook_event", 0) }.to raise_error(/Waited for/) # At this point, we should have not received any events for if_hook_event, as we are not selecting the embedded controller
|
59
59
|
end
|
60
60
|
|
61
|
+
it "Can use the :goto hook generator for a controller with the triggered_by constraint for various actions" do
|
62
|
+
#Hook source code
|
63
|
+
hooks_src = %{
|
64
|
+
hook :goto => :goto do
|
65
|
+
triggered_by "back_clicked"
|
66
|
+
end
|
67
|
+
}
|
68
|
+
|
69
|
+
#Get a new js context with the controllers source and the hooks source
|
70
|
+
info = flok_new_user_with_src File.read('./spec/kern/assets/hook_entry_points/controller0.rb'), nil, nil, hooks_src
|
71
|
+
File.write File.expand_path("~/Downloads/src.txt"), info[:src]
|
72
|
+
ctx = info[:ctx]
|
73
|
+
|
74
|
+
#Run the embed function
|
75
|
+
dump = ctx.evald %{
|
76
|
+
dump.base = _embed("my_controller", 0, {}, null); // Embed the controller
|
77
|
+
int_dispatch([]); // Dispatch any events the are pending
|
78
|
+
dump.my_other_controller_base = my_other_controller_base; // Grab the base address of 'my_other_controller'
|
79
|
+
}
|
80
|
+
|
81
|
+
@driver.int "int_event", [ dump["my_other_controller_base"], "back_clicked", {} ]
|
82
|
+
@driver.ignore_up_to("if_hook_event", 0)
|
83
|
+
end
|
84
|
+
|
85
|
+
|
61
86
|
it "Can use the :goto hook generator for a controller with the to_action_responds_to constraint for various actions" do
|
62
87
|
#Hook source code
|
63
88
|
hooks_src = %{
|
@@ -136,6 +161,120 @@ RSpec.describe "kern:hook_user_geenrators_spec" do
|
|
136
161
|
expect { @driver.ignore_up_to("if_hook_event", 0); @driver.get "if_hook_event", 0 }.not_to raise_error
|
137
162
|
end
|
138
163
|
|
164
|
+
it "Can use the :goto hook generator for a controller with the to_action constraint for various actions" do
|
165
|
+
#Hook source code
|
166
|
+
hooks_src = %{
|
167
|
+
hook :goto => :goto do
|
168
|
+
to_action "other"
|
169
|
+
end
|
170
|
+
}
|
171
|
+
|
172
|
+
#Get a new js context with the controllers source and the hooks source
|
173
|
+
info = flok_new_user_with_src File.read('./spec/kern/assets/hook_entry_points/controller0bc.rb'), nil, nil, hooks_src
|
174
|
+
File.write File.expand_path("~/Downloads/src.txt"), info[:src]
|
175
|
+
ctx = info[:ctx]
|
176
|
+
|
177
|
+
#Run the embed function
|
178
|
+
dump = ctx.evald %{
|
179
|
+
dump.base = _embed("my_controller", 0, {}, null); // Embed the controller
|
180
|
+
int_dispatch([]); // Dispatch any events the are pending
|
181
|
+
dump.my_controller_base = my_controller_base;
|
182
|
+
}
|
183
|
+
|
184
|
+
#Should raise a hook at this time
|
185
|
+
expect { @driver.ignore_up_to("if_hook_event", 0) }.to raise_error(/Waited for/)
|
186
|
+
@driver.int "int_event", [ dump["my_controller_base"], "next_clicked", {} ]
|
187
|
+
@driver.int "int_event", [ dump["my_controller_base"], "next_clicked", {} ]
|
188
|
+
|
189
|
+
@driver.ignore_up_to("if_hook_event", 0); @driver.get "if_hook_event", 0
|
190
|
+
expect { @driver.ignore_up_to("if_hook_event", 0); @driver.get "if_hook_event", 0 }.to raise_error /Waited/
|
191
|
+
end
|
192
|
+
|
193
|
+
it "Can use the :goto hook generator for a controller with the to_action constraint for multiple actions" do
|
194
|
+
#Hook source code
|
195
|
+
hooks_src = %{
|
196
|
+
hook :goto => :goto do
|
197
|
+
to_action "other", "other2"
|
198
|
+
end
|
199
|
+
}
|
200
|
+
|
201
|
+
#Get a new js context with the controllers source and the hooks source
|
202
|
+
info = flok_new_user_with_src File.read('./spec/kern/assets/hook_entry_points/controller0bc.rb'), nil, nil, hooks_src
|
203
|
+
File.write File.expand_path("~/Downloads/src.txt"), info[:src]
|
204
|
+
ctx = info[:ctx]
|
205
|
+
|
206
|
+
#Run the embed function
|
207
|
+
dump = ctx.evald %{
|
208
|
+
dump.base = _embed("my_controller", 0, {}, null); // Embed the controller
|
209
|
+
int_dispatch([]); // Dispatch any events the are pending
|
210
|
+
dump.my_controller_base = my_controller_base;
|
211
|
+
}
|
212
|
+
|
213
|
+
#Should raise a hook at this time
|
214
|
+
expect { @driver.ignore_up_to("if_hook_event", 0) }.to raise_error(/Waited for/)
|
215
|
+
@driver.int "int_event", [ dump["my_controller_base"], "next_clicked", {} ]
|
216
|
+
@driver.int "int_event", [ dump["my_controller_base"], "next_clicked", {} ]
|
217
|
+
|
218
|
+
@driver.ignore_up_to("if_hook_event", 0); @driver.get "if_hook_event", 0
|
219
|
+
@driver.ignore_up_to("if_hook_event", 0); @driver.get "if_hook_event", 0
|
220
|
+
end
|
221
|
+
|
222
|
+
|
223
|
+
it "Can use the :goto hook generator for a controller with the from_action constraint for various actions" do
|
224
|
+
#Hook source code
|
225
|
+
hooks_src = %{
|
226
|
+
hook :goto => :goto do
|
227
|
+
from_action "index"
|
228
|
+
end
|
229
|
+
}
|
230
|
+
|
231
|
+
#Get a new js context with the controllers source and the hooks source
|
232
|
+
info = flok_new_user_with_src File.read('./spec/kern/assets/hook_entry_points/controller0b.rb'), nil, nil, hooks_src
|
233
|
+
File.write File.expand_path("~/Downloads/src.txt"), info[:src]
|
234
|
+
ctx = info[:ctx]
|
235
|
+
|
236
|
+
#Run the embed function
|
237
|
+
dump = ctx.evald %{
|
238
|
+
dump.base = _embed("my_controller", 0, {}, null); // Embed the controller
|
239
|
+
int_dispatch([]); // Dispatch any events the are pending
|
240
|
+
dump.my_controller_base = my_controller_base;
|
241
|
+
}
|
242
|
+
|
243
|
+
#Should raise a hook at this time
|
244
|
+
expect { @driver.ignore_up_to("if_hook_event", 0) }.to raise_error(/Waited for/)
|
245
|
+
@driver.int "int_event", [ dump["my_controller_base"], "next_clicked", {} ]
|
246
|
+
expect { @driver.ignore_up_to("if_hook_event", 0); @driver.get "if_hook_event", 0 }.not_to raise_error
|
247
|
+
end
|
248
|
+
|
249
|
+
it "Can use the :goto hook generator for a controller with the from_action constraint for multiple actions" do
|
250
|
+
#Hook source code
|
251
|
+
hooks_src = %{
|
252
|
+
hook :goto => :goto do
|
253
|
+
from_action "index", "other"
|
254
|
+
end
|
255
|
+
}
|
256
|
+
|
257
|
+
#Get a new js context with the controllers source and the hooks source
|
258
|
+
info = flok_new_user_with_src File.read('./spec/kern/assets/hook_entry_points/controller0bc.rb'), nil, nil, hooks_src
|
259
|
+
File.write File.expand_path("~/Downloads/src.txt"), info[:src]
|
260
|
+
ctx = info[:ctx]
|
261
|
+
|
262
|
+
#Run the embed function
|
263
|
+
dump = ctx.evald %{
|
264
|
+
dump.base = _embed("my_controller", 0, {}, null); // Embed the controller
|
265
|
+
int_dispatch([]); // Dispatch any events the are pending
|
266
|
+
dump.my_controller_base = my_controller_base;
|
267
|
+
}
|
268
|
+
|
269
|
+
#Should raise a hook at this time
|
270
|
+
expect { @driver.ignore_up_to("if_hook_event", 0) }.to raise_error(/Waited for/)
|
271
|
+
@driver.int "int_event", [ dump["my_controller_base"], "next_clicked", {} ]
|
272
|
+
@driver.int "int_event", [ dump["my_controller_base"], "next_clicked", {} ]
|
273
|
+
@driver.ignore_up_to("if_hook_event", 0); @driver.get "if_hook_event", 0
|
274
|
+
@driver.ignore_up_to("if_hook_event", 0); @driver.get "if_hook_event", 0
|
275
|
+
end
|
276
|
+
|
277
|
+
|
139
278
|
it "Can use goto to embed a pre and post selectors which will be returned in the hooking response" do
|
140
279
|
#Hook source code
|
141
280
|
hooks_src = %{
|
@@ -179,12 +318,11 @@ RSpec.describe "kern:hook_user_geenrators_spec" do
|
|
179
318
|
@driver.ignore_up_to("if_hook_event", 0)
|
180
319
|
hook_res = @driver.get "if_hook_event", 0
|
181
320
|
|
182
|
-
expect(hook_res[1]).to eq({
|
183
|
-
"
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
})
|
321
|
+
expect(hook_res[1]["views"]).to eq({
|
322
|
+
"foo" => my_other_controller_base,
|
323
|
+
"foo2" => new_controller_base
|
324
|
+
}
|
325
|
+
)
|
188
326
|
end
|
189
327
|
|
190
328
|
it "The goto does not free views via the module until after the completion event is received" do
|
@@ -0,0 +1,292 @@
|
|
1
|
+
#Relating to the conversion of the user's ./config/hooks.rb file into the equivalent HooksManifestEntrie(s) (This may cross-over into
|
2
|
+
#the HooksCompiler itself because we need to test side-effects)
|
3
|
+
|
4
|
+
Dir.chdir File.join File.dirname(__FILE__), '../../'
|
5
|
+
require './spec/env/kern.rb'
|
6
|
+
require './spec/lib/helpers.rb'
|
7
|
+
require './spec/lib/io_extensions.rb'
|
8
|
+
require './spec/lib/rspec_extensions.rb'
|
9
|
+
require './lib/flok/hooks_compiler.rb'
|
10
|
+
require 'zlib'
|
11
|
+
|
12
|
+
RSpec.describe "kern:hook_pop_user_generators_spec" do
|
13
|
+
include Zlib
|
14
|
+
include_context "kern"
|
15
|
+
|
16
|
+
it "Can use the :pop hook generator for all controllers (no matchers)" do
|
17
|
+
hooks_src = %{
|
18
|
+
hook :pop => :pop do
|
19
|
+
#Select all
|
20
|
+
end
|
21
|
+
}
|
22
|
+
|
23
|
+
#Just expect this not to blow up
|
24
|
+
info = flok_new_user_with_src File.read('./spec/kern/assets/hook_entry_points/controller_0b_pop.rb'), nil, nil, hooks_src
|
25
|
+
ctx = info[:ctx]
|
26
|
+
|
27
|
+
#Run the embed function
|
28
|
+
dump = ctx.evald %{
|
29
|
+
dump.base = _embed("my_controller", 0, {}, null); // Embed the controller
|
30
|
+
int_dispatch([]); // Dispatch any events the are pending
|
31
|
+
dump.on_entry_base_pointer = on_entry_base_pointer;
|
32
|
+
}
|
33
|
+
|
34
|
+
@driver.int "int_event", [ dump["on_entry_base_pointer"], "next_clicked", {} ]
|
35
|
+
@driver.int "int_event", [ dump["on_entry_base_pointer"], "back_clicked", {} ]
|
36
|
+
|
37
|
+
@driver.ignore_up_to("if_hook_event", 0)
|
38
|
+
@driver.get "if_hook_event", 0
|
39
|
+
end
|
40
|
+
|
41
|
+
it "Can use the :pop hook generator for one specific controller by name" do
|
42
|
+
hooks_src = %{
|
43
|
+
hook :pop => :pop do
|
44
|
+
controller "my_controller"
|
45
|
+
end
|
46
|
+
}
|
47
|
+
|
48
|
+
#Just expect this not to blow up
|
49
|
+
info = flok_new_user_with_src File.read('./spec/kern/assets/hook_entry_points/controller_0b_pop2.rb'), nil, nil, hooks_src
|
50
|
+
ctx = info[:ctx]
|
51
|
+
|
52
|
+
#Run the embed function
|
53
|
+
dump = ctx.evald %{
|
54
|
+
dump.base = _embed("my_controller", 0, {}, null); // Embed the controller
|
55
|
+
int_dispatch([]); // Dispatch any events the are pending
|
56
|
+
dump.on_entry_base_pointer = on_entry_base_pointer;
|
57
|
+
dump.on_entry_base_pointer2 = on_entry_base_pointer2;
|
58
|
+
}
|
59
|
+
|
60
|
+
@driver.int "int_event", [ dump["on_entry_base_pointer"], "next_clicked", {} ]
|
61
|
+
@driver.int "int_event", [ dump["on_entry_base_pointer2"], "next_clicked", {} ]
|
62
|
+
@driver.int "int_event", [ dump["on_entry_base_pointer"], "back_clicked", {} ]
|
63
|
+
@driver.int "int_event", [ dump["on_entry_base_pointer2"], "back_clicked", {} ]
|
64
|
+
|
65
|
+
@driver.ignore_up_to("if_hook_event", 0)
|
66
|
+
@driver.get "if_hook_event", 0
|
67
|
+
expect {@driver.ignore_up_to("if_hook_event", 0)}.to raise_error /Waited/
|
68
|
+
end
|
69
|
+
|
70
|
+
it "Can use the :pop hook generator for one action that responds to something (coming from thing)" do
|
71
|
+
hooks_src = %{
|
72
|
+
hook :pop => :pop do
|
73
|
+
from_action_responds_to? "olah2"
|
74
|
+
end
|
75
|
+
}
|
76
|
+
|
77
|
+
#Just expect this not to blow up
|
78
|
+
info = flok_new_user_with_src File.read('./spec/kern/assets/hook_entry_points/controller_0b_pop2.rb'), nil, nil, hooks_src
|
79
|
+
ctx = info[:ctx]
|
80
|
+
|
81
|
+
#Run the embed function
|
82
|
+
dump = ctx.evald %{
|
83
|
+
dump.base = _embed("my_controller", 0, {}, null); // Embed the controller
|
84
|
+
int_dispatch([]); // Dispatch any events the are pending
|
85
|
+
dump.on_entry_base_pointer = on_entry_base_pointer;
|
86
|
+
dump.on_entry_base_pointer2 = on_entry_base_pointer2;
|
87
|
+
}
|
88
|
+
|
89
|
+
@driver.int "int_event", [ dump["on_entry_base_pointer"], "next_clicked", {} ]
|
90
|
+
@driver.int "int_event", [ dump["on_entry_base_pointer2"], "next_clicked", {} ]
|
91
|
+
@driver.int "int_event", [ dump["on_entry_base_pointer"], "back_clicked", {} ]
|
92
|
+
@driver.int "int_event", [ dump["on_entry_base_pointer2"], "back_clicked", {} ]
|
93
|
+
|
94
|
+
@driver.ignore_up_to("if_hook_event", 0)
|
95
|
+
res = @driver.get "if_hook_event", 0
|
96
|
+
expect {@driver.ignore_up_to("if_hook_event", 0)}.to raise_error /Waited/
|
97
|
+
end
|
98
|
+
|
99
|
+
it "Can use the :pop hook generator for a controller with the triggered_by constraint for various actions" do
|
100
|
+
#Hook source code
|
101
|
+
hooks_src = %{
|
102
|
+
hook :pop => :pop do
|
103
|
+
triggered_by "back_clicked"
|
104
|
+
end
|
105
|
+
}
|
106
|
+
|
107
|
+
#Get a new js context with the controllers source and the hooks source
|
108
|
+
info = flok_new_user_with_src File.read('./spec/kern/assets/hook_entry_points/controller_0b_pop2.rb'), nil, nil, hooks_src
|
109
|
+
File.write File.expand_path("~/Downloads/src.txt"), info[:src]
|
110
|
+
ctx = info[:ctx]
|
111
|
+
#Run the embed function
|
112
|
+
dump = ctx.evald %{
|
113
|
+
dump.base = _embed("my_controller", 0, {}, null); // Embed the controller
|
114
|
+
int_dispatch([]); // Dispatch any events the are pending
|
115
|
+
dump.on_entry_base_pointer = on_entry_base_pointer; // Grab the base address of 'my_other_controller'
|
116
|
+
}
|
117
|
+
|
118
|
+
@driver.int "int_event", [ dump["on_entry_base_pointer"], "next_clicked", {} ]
|
119
|
+
expect { @driver.ignore_up_to("if_hook_event", 0)}.to raise_error /Waited/
|
120
|
+
|
121
|
+
@driver.int "int_event", [ dump["on_entry_base_pointer"], "back_clicked", {} ]
|
122
|
+
@driver.ignore_up_to("if_hook_event", 0)
|
123
|
+
end
|
124
|
+
|
125
|
+
|
126
|
+
it "can hook into a particualr action we are poping from" do
|
127
|
+
hooks_src = %{
|
128
|
+
hook :pop => :pop do
|
129
|
+
from_action "other2"
|
130
|
+
end
|
131
|
+
}
|
132
|
+
|
133
|
+
#Just expect this not to blow up
|
134
|
+
info = flok_new_user_with_src File.read('./spec/kern/assets/hook_entry_points/controller_0b_pop2.rb'), nil, nil, hooks_src
|
135
|
+
ctx = info[:ctx]
|
136
|
+
|
137
|
+
#Run the embed function
|
138
|
+
dump = ctx.evald %{
|
139
|
+
dump.base = _embed("my_controller", 0, {}, null); // Embed the controller
|
140
|
+
int_dispatch([]); // Dispatch any events the are pending
|
141
|
+
dump.on_entry_base_pointer = on_entry_base_pointer;
|
142
|
+
dump.on_entry_base_pointer2 = on_entry_base_pointer2;
|
143
|
+
}
|
144
|
+
|
145
|
+
@driver.int "int_event", [ dump["on_entry_base_pointer"], "next_clicked", {} ]
|
146
|
+
@driver.int "int_event", [ dump["on_entry_base_pointer2"], "next_clicked", {} ]
|
147
|
+
@driver.int "int_event", [ dump["on_entry_base_pointer"], "back_clicked", {} ]
|
148
|
+
@driver.int "int_event", [ dump["on_entry_base_pointer2"], "back_clicked", {} ]
|
149
|
+
|
150
|
+
@driver.ignore_up_to("if_hook_event", 0); @driver.get "if_hook_event", 0
|
151
|
+
expect {@driver.ignore_up_to("if_hook_event", 0)}.to raise_error /Waited/
|
152
|
+
end
|
153
|
+
|
154
|
+
it "can hook into multiple actions we are poping from" do
|
155
|
+
hooks_src = %{
|
156
|
+
hook :pop => :pop do
|
157
|
+
from_action "other2", "other"
|
158
|
+
end
|
159
|
+
}
|
160
|
+
|
161
|
+
#Just expect this not to blow up
|
162
|
+
info = flok_new_user_with_src File.read('./spec/kern/assets/hook_entry_points/controller_0b_pop2.rb'), nil, nil, hooks_src
|
163
|
+
ctx = info[:ctx]
|
164
|
+
|
165
|
+
#Run the embed function
|
166
|
+
dump = ctx.evald %{
|
167
|
+
dump.base = _embed("my_controller", 0, {}, null); // Embed the controller
|
168
|
+
int_dispatch([]); // Dispatch any events the are pending
|
169
|
+
dump.on_entry_base_pointer = on_entry_base_pointer;
|
170
|
+
dump.on_entry_base_pointer2 = on_entry_base_pointer2;
|
171
|
+
}
|
172
|
+
|
173
|
+
@driver.int "int_event", [ dump["on_entry_base_pointer"], "next_clicked", {} ]
|
174
|
+
@driver.int "int_event", [ dump["on_entry_base_pointer2"], "next_clicked", {} ]
|
175
|
+
@driver.int "int_event", [ dump["on_entry_base_pointer"], "back_clicked", {} ]
|
176
|
+
@driver.int "int_event", [ dump["on_entry_base_pointer2"], "back_clicked", {} ]
|
177
|
+
|
178
|
+
@driver.ignore_up_to("if_hook_event", 0); @driver.get "if_hook_event", 0
|
179
|
+
@driver.ignore_up_to("if_hook_event", 0); @driver.get "if_hook_event", 0
|
180
|
+
end
|
181
|
+
|
182
|
+
|
183
|
+
it "Can use pop to embed a pre and post selectors which will be returned in the hooking response" do
|
184
|
+
#Hook source code
|
185
|
+
hooks_src = %{
|
186
|
+
hook :pop => :pop do
|
187
|
+
controller "my_controller"
|
188
|
+
from_action "other"
|
189
|
+
|
190
|
+
before_views({
|
191
|
+
"my_controller3" => {
|
192
|
+
"__leaf__" => "foo"
|
193
|
+
}
|
194
|
+
})
|
195
|
+
|
196
|
+
after_views({
|
197
|
+
"." => {
|
198
|
+
"__leaf__" => "foo2"
|
199
|
+
}
|
200
|
+
})
|
201
|
+
|
202
|
+
end
|
203
|
+
}
|
204
|
+
|
205
|
+
#Just expect this not to blow up
|
206
|
+
info = flok_new_user_with_src File.read('./spec/kern/assets/hook_entry_points/controller_0b_pop2.rb'), nil, nil, hooks_src
|
207
|
+
ctx = info[:ctx]
|
208
|
+
|
209
|
+
#Run the embed function
|
210
|
+
ctx.evald %{
|
211
|
+
dump.base = _embed("my_controller", 0, {}, null); // Embed the controller
|
212
|
+
int_dispatch([]); // Dispatch any events the are pending
|
213
|
+
}
|
214
|
+
|
215
|
+
|
216
|
+
on_entry_base_pointer = ctx.eval("on_entry_base_pointer")
|
217
|
+
on_entry_base_pointer2 = ctx.eval("on_entry_base_pointer2")
|
218
|
+
|
219
|
+
@driver.int "int_event", [ on_entry_base_pointer, "next_clicked", {} ]
|
220
|
+
on_entry_base_pointer3 = ctx.eval("my_controller3_base")
|
221
|
+
@driver.int "int_event", [ on_entry_base_pointer, "back_clicked", {} ]
|
222
|
+
|
223
|
+
@driver.ignore_up_to("if_hook_event", 0)
|
224
|
+
hook_res = @driver.get "if_hook_event", 0
|
225
|
+
|
226
|
+
expect(hook_res[1]).to eq({
|
227
|
+
"views" => {
|
228
|
+
"foo2" => on_entry_base_pointer2,
|
229
|
+
"foo" => on_entry_base_pointer3
|
230
|
+
}
|
231
|
+
})
|
232
|
+
end
|
233
|
+
|
234
|
+
it "Does not dump the views until *after* the callback is received" do
|
235
|
+
#Hook source code
|
236
|
+
hooks_src = %{
|
237
|
+
hook :pop => :pop do
|
238
|
+
controller "my_controller"
|
239
|
+
from_action "other"
|
240
|
+
|
241
|
+
before_views({
|
242
|
+
"my_controller3" => {
|
243
|
+
"__leaf__" => "foo"
|
244
|
+
}
|
245
|
+
})
|
246
|
+
|
247
|
+
after_views({
|
248
|
+
"." => {
|
249
|
+
"__leaf__" => "foo2"
|
250
|
+
}
|
251
|
+
})
|
252
|
+
|
253
|
+
end
|
254
|
+
}
|
255
|
+
|
256
|
+
#Just expect this not to blow up
|
257
|
+
info = flok_new_user_with_src File.read('./spec/kern/assets/hook_entry_points/controller_0b_pop2.rb'), nil, nil, hooks_src
|
258
|
+
ctx = info[:ctx]
|
259
|
+
|
260
|
+
#Run the embed function
|
261
|
+
ctx.evald %{
|
262
|
+
dump.base = _embed("my_controller", 0, {}, null); // Embed the controller
|
263
|
+
int_dispatch([]); // Dispatch any events the are pending
|
264
|
+
}
|
265
|
+
|
266
|
+
|
267
|
+
on_entry_base_pointer = ctx.eval("on_entry_base_pointer")
|
268
|
+
on_entry_base_pointer2 = ctx.eval("on_entry_base_pointer2")
|
269
|
+
|
270
|
+
@driver.int "int_event", [ on_entry_base_pointer, "next_clicked", {} ]
|
271
|
+
on_entry_base_pointer3 = ctx.eval("my_controller3_base")
|
272
|
+
@driver.int "int_event", [ on_entry_base_pointer, "back_clicked", {} ]
|
273
|
+
|
274
|
+
#Should not have gotten a free view at this point because we popped an intercepted segue
|
275
|
+
#So it should wait for the completion callback to release the views
|
276
|
+
expect {@driver.ignore_up_to("if_free_view", 0)}.to raise_error /Waited/
|
277
|
+
|
278
|
+
@driver.ignore_up_to("if_hook_event", 0)
|
279
|
+
hook_res = @driver.get "if_hook_event", 0
|
280
|
+
|
281
|
+
expect(hook_res[1]["views"]).to eq({
|
282
|
+
"foo2" => on_entry_base_pointer2,
|
283
|
+
"foo" => on_entry_base_pointer3
|
284
|
+
})
|
285
|
+
|
286
|
+
#This should cause the views to be dumped
|
287
|
+
@driver.int "int_event", [hook_res[1]["cep"], "", {}]
|
288
|
+
@driver.ignore_up_to("if_free_view", 0)
|
289
|
+
res = @driver.get("if_free_view", 0)
|
290
|
+
expect(res).to eq([on_entry_base_pointer3+1])
|
291
|
+
end
|
292
|
+
end
|