flok 0.0.102 → 0.0.103
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitmodules +3 -0
- data/app/drivers/chrome/pipe.rb +66 -51
- data/app/drivers/chrome/src/controller.js +20 -1
- data/app/drivers/chrome/src/hook.js +10 -12
- data/app/drivers/chrome/src/net.js +4 -4
- data/app/drivers/chrome/src/sockio.js +2 -2
- data/app/drivers/chrome/src/ui.js +18 -15
- data/app/kern/mod/event.js +3 -1
- data/app/kern/mod/hook.js +13 -1
- data/app/kern/mod/ui.js +71 -0
- data/docs/controllers.md +14 -0
- data/docs/dispatch.md +4 -2
- data/docs/kernel_api.md +1 -0
- data/docs/kernel_handbook/find_view.md +34 -0
- data/docs/kernel_handbook/hooks.md +12 -1
- data/docs/mod/controller.md +5 -2
- data/docs/mod/hook.md +4 -3
- data/docs/mod/persist.md +1 -1
- data/docs/mod/ui.md +1 -0
- data/docs/user_handbook/hooks.md +38 -14
- data/flok.gemspec +2 -0
- data/lib/flok/user_compiler.rb +18 -2
- data/lib/flok/user_compiler_templates/ctable.js.erb +1 -0
- data/lib/flok/user_hook_generators/goto.rb +32 -4
- data/lib/flok/version.rb +1 -1
- data/spec/env/iface.rb +38 -0
- data/spec/env/kern.rb +4 -0
- data/spec/iface/driver/controller_spec.rb +25 -6
- data/spec/iface/driver/dispatch_spec.rb +7 -0
- data/spec/iface/driver/hook_spec.rb +83 -7
- data/spec/iface/driver/net_spec.rb +50 -41
- data/spec/iface/driver/persist_spec.rb +47 -4
- data/spec/iface/driver/ping_spec.rb +1 -1
- data/spec/iface/driver/rtc_spec.rb +2 -2
- data/spec/iface/driver/sockio_spec.rb +4 -3
- data/spec/iface/driver/timer_spec.rb +20 -0
- data/spec/iface/driver/ui_spec.rb +27 -4
- data/spec/kern/assets/find_view/controller0.rb +24 -0
- data/spec/kern/assets/find_view/controller1.rb +35 -0
- data/spec/kern/assets/find_view/controller1a.rb +37 -0
- data/spec/kern/assets/find_view/controller2.rb +23 -0
- data/spec/kern/assets/find_view/controller3.rb +38 -0
- data/spec/kern/assets/find_view/controller4.rb +38 -0
- data/spec/kern/assets/find_view/controller5.rb +52 -0
- data/spec/kern/assets/find_view/controller6.rb +37 -0
- data/spec/kern/assets/find_view/controller7.rb +37 -0
- data/spec/kern/assets/find_view/controller8.rb +53 -0
- data/spec/kern/assets/find_view/controller9.rb +67 -0
- data/spec/kern/assets/hook_entry_points/controller0.rb +13 -1
- data/spec/kern/assets/push_count.rb +42 -0
- data/spec/kern/controller_spec.rb +34 -0
- data/spec/kern/find_view_spec.rb +269 -0
- data/spec/kern/hook_entry_points_and_manifest_spec.rb +60 -0
- data/spec/kern/hook_user_generators_spec.rb +100 -0
- data/spec/lib/helpers.rb +1 -2
- metadata +58 -2
@@ -20,6 +20,13 @@ RSpec.describe "iface:driver:dispatch_spec" do
|
|
20
20
|
expect(@pipe).not_to readline_and_equal_json_x_within_y_seconds([], 6.seconds)
|
21
21
|
end
|
22
22
|
|
23
|
+
it "Does automatically dispatch a blank array (signaling int_disptach) when a blank queue is received prefixed with 'i' indicating incomplete-ness but after the queue is processed if it has entries" do
|
24
|
+
@pipe.puts ['i', [0, 0, "ping"]].to_json
|
25
|
+
expect(@pipe).to readline_and_equal_json_x_within_y_seconds([0, "pong"], 10.seconds)
|
26
|
+
expect(@pipe).to readline_and_equal_json_x_within_y_seconds([], 6.seconds)
|
27
|
+
end
|
28
|
+
|
29
|
+
|
23
30
|
#While at first you might think we need to test that int_dispatch called intra-respond of our if_event needs to test whether or not we still send
|
24
31
|
#out blank [] to int_dispatch; this is not the case. In the real world, flok is supposed to also make any necessary if_disptach calls during all
|
25
32
|
#int_dispatch calls. We would always receive back if_dispatch; and thus it would follow the same rules as layed out here
|
@@ -8,26 +8,102 @@ RSpec.describe "iface:driver:hook" do
|
|
8
8
|
module_dep "hook"
|
9
9
|
include_context "iface:driver"
|
10
10
|
|
11
|
-
it "Can receive a hook event request with parameters" do
|
11
|
+
it "Can receive a single hook event request with parameters and respond with the test handler" do
|
12
12
|
@ptr = SecureRandom.hex
|
13
13
|
|
14
|
+
#Wait for response
|
15
|
+
@pipe.puts [[0, 0, "ping"]].to_json; @pipe.readline_timeout
|
16
|
+
|
14
17
|
#Simulate a hook event on the main queue
|
15
|
-
@pipe.puts [[0,
|
18
|
+
@pipe.puts [[0, 2, "if_hook_event", "test", {foo: "bar"}]].to_json
|
19
|
+
|
20
|
+
json = [
|
21
|
+
1,
|
22
|
+
"hook_dump_res",
|
23
|
+
{
|
24
|
+
"name" => "test",
|
25
|
+
"info" => {"foo" => "bar"}
|
26
|
+
}
|
27
|
+
]
|
28
|
+
expect(@pipe).to readline_and_equal_json_x_within_y_seconds(json, 5.seconds)
|
29
|
+
end
|
30
|
+
|
31
|
+
it "Can receive two hook event requests with parameters and respond with the test handler twice" do
|
32
|
+
@ptr = SecureRandom.hex
|
16
33
|
|
17
34
|
#Wait for response
|
18
35
|
@pipe.puts [[0, 0, "ping"]].to_json; @pipe.readline_timeout
|
19
36
|
|
20
|
-
#
|
21
|
-
@pipe.puts [[0,
|
37
|
+
#Simulate a hook event on the main queue
|
38
|
+
@pipe.puts [[0, 2, "if_hook_event", "test", {foo: "bar"}]].to_json
|
22
39
|
|
23
40
|
json = [
|
24
41
|
1,
|
25
|
-
"
|
26
|
-
|
42
|
+
"hook_dump_res",
|
43
|
+
{
|
27
44
|
"name" => "test",
|
28
45
|
"info" => {"foo" => "bar"}
|
29
|
-
}
|
46
|
+
}
|
30
47
|
]
|
31
48
|
expect(@pipe).to readline_and_equal_json_x_within_y_seconds(json, 5.seconds)
|
49
|
+
|
50
|
+
#Simulate a hook event on the main queue
|
51
|
+
@pipe.puts [[0, 2, "if_hook_event", "test", {foo: "bar2"}]].to_json
|
52
|
+
|
53
|
+
json = [
|
54
|
+
1,
|
55
|
+
"hook_dump_res",
|
56
|
+
{
|
57
|
+
"name" => "test",
|
58
|
+
"info" => {"foo" => "bar2"}
|
59
|
+
}
|
60
|
+
]
|
61
|
+
expect(@pipe).to readline_and_equal_json_x_within_y_seconds(json, 5.seconds)
|
62
|
+
end
|
63
|
+
|
64
|
+
it "Can receive two hook event requests with parameters and respond with the test and test2 handler" do
|
65
|
+
@ptr = SecureRandom.hex
|
66
|
+
|
67
|
+
#Wait for response
|
68
|
+
@pipe.puts [[0, 0, "ping"]].to_json; @pipe.readline_timeout
|
69
|
+
|
70
|
+
#Simulate a hook event on the main queue
|
71
|
+
@pipe.puts [[0, 2, "if_hook_event", "test", {foo: "bar"}]].to_json
|
72
|
+
|
73
|
+
json = [
|
74
|
+
1,
|
75
|
+
"hook_dump_res",
|
76
|
+
{
|
77
|
+
"name" => "test",
|
78
|
+
"info" => {"foo" => "bar"}
|
79
|
+
}
|
80
|
+
]
|
81
|
+
expect(@pipe).to readline_and_equal_json_x_within_y_seconds(json, 5.seconds)
|
82
|
+
|
83
|
+
#Simulate a hook event on the main queue
|
84
|
+
@pipe.puts [[0, 2, "if_hook_event", "test2", {foo: "bar2"}]].to_json
|
85
|
+
|
86
|
+
json = [
|
87
|
+
1,
|
88
|
+
"hook_dump_res",
|
89
|
+
{
|
90
|
+
"name" => "test2",
|
91
|
+
"info" => {"foo" => "bar2"}
|
92
|
+
}
|
93
|
+
]
|
94
|
+
expect(@pipe).to readline_and_equal_json_x_within_y_seconds(json, 5.seconds)
|
95
|
+
end
|
96
|
+
|
97
|
+
it "Can receive a hook without a handler and not crash" do
|
98
|
+
@ptr = SecureRandom.hex
|
99
|
+
|
100
|
+
#Wait for response
|
101
|
+
@pipe.puts [[0, 0, "ping"]].to_json; @pipe.readline_timeout
|
102
|
+
|
103
|
+
#Simulate a hook event on the main queue
|
104
|
+
@pipe.puts [[0, 2, "if_hook_event", "test3", {foo: "bar"}]].to_json
|
105
|
+
|
106
|
+
#Wait for response
|
107
|
+
@pipe.puts [[0, 0, "ping"]].to_json; @pipe.readline_timeout
|
32
108
|
end
|
33
109
|
end
|
@@ -9,63 +9,72 @@ RSpec.describe "iface:driver:net" do
|
|
9
9
|
include_context "iface:driver"
|
10
10
|
|
11
11
|
it "Can call a network request" do
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
12
|
+
begin
|
13
|
+
web = Webbing.get "/" do
|
14
|
+
@hit = true
|
15
|
+
{}
|
16
|
+
end
|
16
17
|
|
17
|
-
|
18
|
-
|
18
|
+
@ptr = rand(9999999)
|
19
|
+
@pipe.puts [[1, 4, "if_net_req","GET", "http://127.0.0.1:#{web.port}", {}, @ptr]].to_json
|
19
20
|
|
20
|
-
#Wait for response
|
21
|
-
@pipe.puts [[0, 0, "ping"]].to_json; @pipe.readline_timeout
|
22
21
|
|
23
|
-
|
22
|
+
#Wait for response
|
23
|
+
@pipe.puts [[0, 0, "ping"]].to_json; @pipe.readline_timeout
|
24
|
+
sleep 1
|
24
25
|
|
25
|
-
|
26
|
+
expect(@hit).to eq(true)
|
27
|
+
ensure
|
28
|
+
web.kill
|
29
|
+
end
|
26
30
|
end
|
27
31
|
|
28
32
|
it "Can call a network request with parameters" do
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
+
begin
|
34
|
+
@secret = SecureRandom.hex
|
35
|
+
web = Webbing.get "/" do |params|
|
36
|
+
@rcv_secret = params['secret']
|
37
|
+
{}
|
38
|
+
end
|
39
|
+
|
40
|
+
@ptr = rand(9999999)
|
41
|
+
@pipe.puts [[1, 4, "if_net_req", "GET", "http://127.0.0.1:#{web.port}", {'secret' => @secret}, @ptr]].to_json
|
42
|
+
|
43
|
+
#Wait for response
|
44
|
+
@pipe.puts [[0, 0, "ping"]].to_json; @pipe.readline_timeout
|
45
|
+
sleep 1
|
46
|
+
|
47
|
+
expect(@rcv_secret).to eq(@secret)
|
48
|
+
ensure
|
49
|
+
web.kill
|
33
50
|
end
|
34
|
-
|
35
|
-
@ptr = SecureRandom.hex
|
36
|
-
@pipe.puts [[1, 4, "if_net_req", "GET", "http://127.0.0.1:#{web.port}", {'secret' => @secret}, @ptr]].to_json
|
37
|
-
|
38
|
-
#Wait for response
|
39
|
-
@pipe.puts [[0, 0, "ping"]].to_json; @pipe.readline_timeout
|
40
|
-
|
41
|
-
expect(@rcv_secret).to eq(@secret)
|
42
|
-
|
43
|
-
web.kill
|
44
51
|
end
|
45
52
|
|
46
53
|
it "Does send a network interupt int_net_cb with success and the correct payload" do
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
+
begin
|
55
|
+
@secret = SecureRandom.hex
|
56
|
+
@secret2 = SecureRandom.hex
|
57
|
+
@secret2msg = {"secret2" => @secret2}
|
58
|
+
web = Webbing.get "/" do |params|
|
59
|
+
@rcv_secret = params['secret']
|
60
|
+
|
61
|
+
@secret2msg
|
62
|
+
end
|
63
|
+
|
64
|
+
#Wait for response
|
65
|
+
@ptr = rand(9999999)
|
66
|
+
@pipe.puts [[1, 4, "if_net_req", "GET", "http://127.0.0.1:#{web.port}", {'secret' => @secret}, @ptr]].to_json
|
67
|
+
|
68
|
+
res = [3, "int_net_cb", @ptr, true, @secret2msg]
|
69
|
+
expect(@pipe).to readline_and_equal_json_x_within_y_seconds(res, 5.seconds)
|
70
|
+
ensure
|
71
|
+
web.kill
|
54
72
|
end
|
55
|
-
|
56
|
-
#Wait for response
|
57
|
-
@ptr = SecureRandom.hex
|
58
|
-
@pipe.puts [[1, 4, "if_net_req", "GET", "http://127.0.0.1:#{web.port}", {'secret' => @secret}, @ptr]].to_json
|
59
|
-
|
60
|
-
res = [3, "int_net_cb", @ptr, true, @secret2msg]
|
61
|
-
expect(@pipe).to readline_and_equal_json_x_within_y_seconds(res, 5.seconds)
|
62
|
-
|
63
|
-
web.kill
|
64
73
|
end
|
65
74
|
|
66
75
|
it "Does send a network interupt int_net_cb with error and the correct payload" do
|
67
76
|
#Wait for response
|
68
|
-
|
77
|
+
@ptr = rand(9999999)
|
69
78
|
@pipe.puts [[1, 4, "if_net_req", "GET", "http://no_such_url#{SecureRandom.hex}.com", {}, @ptr]].to_json
|
70
79
|
|
71
80
|
matcher = proc do |x|
|
@@ -8,8 +8,13 @@ RSpec.describe "iface:driver:persist" do
|
|
8
8
|
module_dep "persist"
|
9
9
|
include_context "iface:driver"
|
10
10
|
|
11
|
+
before(:each) do
|
12
|
+
hard_restart_driver
|
13
|
+
end
|
14
|
+
|
11
15
|
it "Can receive persist API messages without crashing" do
|
12
16
|
#Disk is scheduling class 2
|
17
|
+
@pipe.puts [[2, 0, "ping"]].to_json; @pipe.readline_timeout
|
13
18
|
@pipe.puts [[2, 3, "if_per_set", "my_ns", "my_key", "my_value"]].to_json
|
14
19
|
@pipe.puts [[2, 3, "if_per_get", "session", "my_ns", "my_key"]].to_json
|
15
20
|
@pipe.puts [[2, 2, "if_per_del", "my_ns", "my_key"]].to_json
|
@@ -17,9 +22,6 @@ RSpec.describe "iface:driver:persist" do
|
|
17
22
|
|
18
23
|
#These are from the get requests
|
19
24
|
@pipe.readline_timeout
|
20
|
-
|
21
|
-
@pipe.puts [[0, 0, "ping"]].to_json;
|
22
|
-
expect(@pipe).to readline_and_equal_json_x_within_y_seconds([0, "pong"], 8.seconds)
|
23
25
|
end
|
24
26
|
|
25
27
|
it "retuns null when calling get on a blank key" do
|
@@ -34,11 +36,29 @@ RSpec.describe "iface:driver:persist" do
|
|
34
36
|
end
|
35
37
|
|
36
38
|
it "Can set a persist, and then get" do
|
37
|
-
key =
|
39
|
+
key = "persist_key"
|
38
40
|
value = SecureRandom.hex
|
39
41
|
|
40
42
|
#Disk is scheduling class 2
|
41
43
|
@pipe.puts [[2, 3, "if_per_set", "my_ns", key, value]].to_json
|
44
|
+
@pipe.puts [[2, 0, "ping"]].to_json; @pipe.readline_timeout
|
45
|
+
sleep 3
|
46
|
+
restart_driver_but_persist
|
47
|
+
@pipe.puts [[0, 3, "if_per_get", "session", "my_ns", key]].to_json
|
48
|
+
|
49
|
+
#Expect a response
|
50
|
+
res = [4, "int_per_get_res", "session", "my_ns", key, value]
|
51
|
+
expect(@pipe).to readline_and_equal_json_x_within_y_seconds(res, 8.seconds)
|
52
|
+
end
|
53
|
+
|
54
|
+
it "Can set a persist for a dictionary object, and then get" do
|
55
|
+
key = "persist_key"
|
56
|
+
value = {"foo" => "bar"}
|
57
|
+
|
58
|
+
#Disk is scheduling class 2
|
59
|
+
@pipe.puts [[2, 3, "if_per_set", "my_ns", key, value]].to_json
|
60
|
+
@pipe.puts [[2, 0, "ping"]].to_json; @pipe.readline_timeout
|
61
|
+
sleep 3
|
42
62
|
restart_driver_but_persist
|
43
63
|
@pipe.puts [[0, 3, "if_per_get", "session", "my_ns", key]].to_json
|
44
64
|
|
@@ -47,6 +67,24 @@ RSpec.describe "iface:driver:persist" do
|
|
47
67
|
expect(@pipe).to readline_and_equal_json_x_within_y_seconds(res, 8.seconds)
|
48
68
|
end
|
49
69
|
|
70
|
+
|
71
|
+
#Not the bests of tests, but it's really testing the ability of the pipe
|
72
|
+
#interface to properly reset the device's data
|
73
|
+
it "Does not persists between tests (i.e. not restarts but complete new tests)" do
|
74
|
+
key = "persist_key"
|
75
|
+
value = SecureRandom.hex
|
76
|
+
|
77
|
+
#Disk is scheduling class 2
|
78
|
+
@pipe.puts [[2, 3, "if_per_set", "my_ns", key, value]].to_json
|
79
|
+
@pipe.puts [[2, 0, "ping"]].to_json; @pipe.readline_timeout
|
80
|
+
hard_restart_driver
|
81
|
+
@pipe.puts [[0, 3, "if_per_get", "session", "my_ns", key]].to_json
|
82
|
+
|
83
|
+
#Expect a response (with nil)
|
84
|
+
res = [4, "int_per_get_res", "session", "my_ns", key, nil]
|
85
|
+
expect(@pipe).to readline_and_equal_json_x_within_y_seconds(res, 8.seconds)
|
86
|
+
end
|
87
|
+
|
50
88
|
it "Can set a persist, delete the key, and then get" do
|
51
89
|
key = SecureRandom.hex
|
52
90
|
value = SecureRandom.hex
|
@@ -54,6 +92,8 @@ RSpec.describe "iface:driver:persist" do
|
|
54
92
|
#Disk is scheduling class 2
|
55
93
|
@pipe.puts [[2, 3, "if_per_set", "my_ns", key, value]].to_json
|
56
94
|
@pipe.puts [[2, 2, "if_per_del", "my_ns", key]].to_json
|
95
|
+
@pipe.puts [[2, 0, "ping"]].to_json; @pipe.readline_timeout
|
96
|
+
sleep 2
|
57
97
|
restart_driver_but_persist
|
58
98
|
@pipe.puts [[0, 3, "if_per_get", "session", "my_ns", key]].to_json
|
59
99
|
|
@@ -72,6 +112,7 @@ RSpec.describe "iface:driver:persist" do
|
|
72
112
|
@pipe.puts [[2, 3, "if_per_set", "my_ns", key, value]].to_json
|
73
113
|
@pipe.puts [[2, 3, "if_per_set", "my_ns", key2, value2]].to_json
|
74
114
|
@pipe.puts [[2, 2, "if_per_del", "my_ns", key]].to_json
|
115
|
+
@pipe.puts [[2, 0, "ping"]].to_json; @pipe.readline_timeout
|
75
116
|
restart_driver_but_persist
|
76
117
|
@pipe.puts [[0, 3, "if_per_get", "session", "my_ns", key]].to_json
|
77
118
|
@pipe.puts [[0, 3, "if_per_get", "session", "my_ns", key2]].to_json
|
@@ -92,6 +133,8 @@ RSpec.describe "iface:driver:persist" do
|
|
92
133
|
#Disk is scheduling class 2
|
93
134
|
@pipe.puts [[2, 3, "if_per_set", "my_ns", key, value]].to_json
|
94
135
|
@pipe.puts [[2, 1, "if_per_del_ns", "my_ns"]].to_json
|
136
|
+
@pipe.puts [[2, 0, "ping"]].to_json; @pipe.readline_timeout
|
137
|
+
sleep 2
|
95
138
|
restart_driver_but_persist
|
96
139
|
@pipe.puts [[0, 3, "if_per_get", "session", "my_ns", key]].to_json
|
97
140
|
|
@@ -6,7 +6,7 @@ RSpec.describe "iface:driver:ping_spec" do
|
|
6
6
|
|
7
7
|
it "supports ping" do
|
8
8
|
@pipe.puts [[0, 0, "ping"]].to_json
|
9
|
-
expect(@pipe).to readline_and_equal_json_x_within_y_seconds([0, "pong"],
|
9
|
+
expect(@pipe).to readline_and_equal_json_x_within_y_seconds([0, "pong"], 10.seconds)
|
10
10
|
end
|
11
11
|
|
12
12
|
it "supports ping1" do
|
@@ -12,10 +12,10 @@ RSpec.describe "iface:driver:rtc" do
|
|
12
12
|
#Wait for response
|
13
13
|
@pipe.puts [[0, 0, "ping"]].to_json; @pipe.readline_timeout
|
14
14
|
|
15
|
-
@pipe.puts [[0,
|
15
|
+
@pipe.puts [[0, 0, "if_rtc_init"]].to_json
|
16
16
|
|
17
17
|
#Wait to start until after the 1st event fires to make sure timer started up
|
18
|
-
@pipe.
|
18
|
+
@pipe.readline_timeout
|
19
19
|
expect(@pipe).to readline_and_equal_json_x_within_y_seconds([1, "int_rtc", Fixnum], 5.seconds)
|
20
20
|
start_time = Time.now.to_i
|
21
21
|
5.times do
|
@@ -10,8 +10,8 @@ RSpec.describe "iface:driver:sockio_spec" do
|
|
10
10
|
|
11
11
|
it "does allow calling of sockio functions" do
|
12
12
|
@pipe.puts [[0, 2, "if_sockio_init", "test", 0]].to_json
|
13
|
-
@pipe.puts [[0, 3, "if_sockio_fwd",
|
14
|
-
@pipe.puts [[0, 3, "if_sockio_send", "hello", {}]].to_json
|
13
|
+
@pipe.puts [[0, 3, "if_sockio_fwd", 11, "test", 0]].to_json
|
14
|
+
@pipe.puts [[0, 3, "if_sockio_send", 11, "hello", {}]].to_json
|
15
15
|
|
16
16
|
#Wait for response
|
17
17
|
@pipe.puts [[0, 0, "ping"]].to_json; @pipe.readline_timeout
|
@@ -40,7 +40,8 @@ RSpec.describe "iface:driver:sockio_spec" do
|
|
40
40
|
#Start up the node server and wait for a CLIENT CONNECTED response
|
41
41
|
sh2 "node", "./spec/iface/driver/assets/sockio_server.js", /STARTED/ do |server_in, server_out|
|
42
42
|
#Start forwarding information to base pointer 0
|
43
|
-
@pipe.puts [[0, 2, "if_sockio_init", "http://localhost:9998", 0
|
43
|
+
@pipe.puts [[0, 2, "if_sockio_init", "http://localhost:9998", 0]].to_json
|
44
|
+
@pipe.puts [[0, 3, "if_sockio_send", 0, "test", {"hello" => "world"}]].to_json
|
44
45
|
|
45
46
|
#Expect the server to get a client connection
|
46
47
|
expect(server_out).to readline_and_equal_x_within_y_seconds("CLIENT CONNECTED", 10.seconds)
|
@@ -36,4 +36,24 @@ RSpec.describe "iface:driver:timer" do
|
|
36
36
|
expect(end_time - start_time).to be < 10
|
37
37
|
expect(end_time - start_time).to be > 5
|
38
38
|
end
|
39
|
+
|
40
|
+
it "Does support a different ticks-per-second interval" do
|
41
|
+
#Wait for response
|
42
|
+
@pipe.puts [[0, 0, "ping"]].to_json; @pipe.readline_timeout
|
43
|
+
|
44
|
+
#This time, 60 ticks per second
|
45
|
+
@pipe.puts [[3, 1, "if_timer_init", 60]].to_json
|
46
|
+
|
47
|
+
#Wait to start until after the 1st event fires to make sure timer started up
|
48
|
+
expect(@pipe).to readline_and_equal_json_x_within_y_seconds([0, "int_timer"], 5.seconds)
|
49
|
+
start_time = Time.now.to_i
|
50
|
+
300.times do
|
51
|
+
expect(@pipe).to readline_and_equal_json_x_within_y_seconds([0, "int_timer"], 2.seconds)
|
52
|
+
end
|
53
|
+
end_time = Time.now.to_i
|
54
|
+
|
55
|
+
#Just leave some room for connection latency, etc.
|
56
|
+
expect(end_time - start_time).to be < 7
|
57
|
+
expect(end_time - start_time).to be > 2
|
58
|
+
end
|
39
59
|
end
|
@@ -5,7 +5,7 @@ require './spec/lib/helpers.rb'
|
|
5
5
|
require './spec/lib/io_extensions.rb'
|
6
6
|
require './spec/lib/rspec_extensions.rb'
|
7
7
|
|
8
|
-
RSpec.describe "iface:driver:
|
8
|
+
RSpec.describe "iface:driver:ui" do
|
9
9
|
module_dep "ui"
|
10
10
|
include_context "iface:driver"
|
11
11
|
|
@@ -14,14 +14,14 @@ RSpec.describe "iface:driver:net" do
|
|
14
14
|
@pipe.puts [[0, 0, "if_ui_spec_init"]].to_json
|
15
15
|
end
|
16
16
|
|
17
|
-
it "Can create and embed views into the root hierarchy" do
|
17
|
+
it "Can create and embed views into the root hierarchy" do
|
18
18
|
#Create a new view 'spec'
|
19
19
|
@pipe.puts [[0, 4, "if_init_view", "spec_blank", {}, 333, ["main"]]].to_json
|
20
20
|
|
21
21
|
#Attach that view to the root
|
22
22
|
@pipe.puts [[0, 2, "if_attach_view", 333, 0]].to_json
|
23
23
|
|
24
|
-
|
24
|
+
j #Request a listing of all the views on the root node
|
25
25
|
@pipe.puts [[0, 1, "if_ui_spec_views_at_spot", 0]].to_json
|
26
26
|
expect(@pipe).to readline_and_equal_json_x_within_y_seconds([1, "spec", 333], 6.seconds)
|
27
27
|
end
|
@@ -134,7 +134,7 @@ it "Can create and embed views into the root hierarchy" do
|
|
134
134
|
@pipe.puts [[0, 4, "if_init_view", "spec_blank", {}, 335, ["main"]]].to_json
|
135
135
|
|
136
136
|
#Attach the child to the parent view (it should be destoryed with the parent)
|
137
|
-
@pipe.puts [[0, 2, "if_attach_view", 335,
|
137
|
+
@pipe.puts [[0, 2, "if_attach_view", 335, 334]].to_json
|
138
138
|
@pipe.puts [[0, 2, "if_attach_view", 333, 0]].to_json
|
139
139
|
|
140
140
|
#Views should exists
|
@@ -155,3 +155,26 @@ it "Can create and embed views into the root hierarchy" do
|
|
155
155
|
expect(@pipe).to readline_and_equal_json_x_within_y_seconds([1, "spec", false], 6.seconds)
|
156
156
|
end
|
157
157
|
end
|
158
|
+
|
159
|
+
#These are optional specs that may not necessarily match the implementation semantics. These
|
160
|
+
#'typical' semantics include loading the context in a 'views' 'initializer' portion, etc.
|
161
|
+
#RSpec.describe "iface:driver:ui:typical_extra" do
|
162
|
+
#module_dep_defines name:"ui", defines: "ui_typical_extra_specs"
|
163
|
+
#include_context "iface:driver"
|
164
|
+
|
165
|
+
#before(:each) do
|
166
|
+
##Initialize
|
167
|
+
#@pipe.puts [[0, 0, "if_ui_spec_init"]].to_json
|
168
|
+
#end
|
169
|
+
|
170
|
+
##it "Does receive the context in the view initializer" do
|
171
|
+
###Create a new view 'spec'
|
172
|
+
##@pipe.puts [[0, 4, "if_init_view", "spec_blank_sends_context", {}, 333, ["main"]]].to_json
|
173
|
+
|
174
|
+
###Attach that view to the root
|
175
|
+
##@pipe.puts [[0, 2, "if_attach_view", 333, 0]].to_json
|
176
|
+
|
177
|
+
##j #Request a listing of all the views on the root node
|
178
|
+
##expect(@pipe).to readline_and_equal_json_x_within_y_seconds([3, "int_event", 333, "context", {"foo" => "bar"}], 6.seconds)
|
179
|
+
##end
|
180
|
+
#end
|