@@ -94,25 +94,29 @@ defmodule Scenic.Component.Input.TextFieldTest do
94
94
:_pong_ = GenServer . call ( vp_pid , :_ping_ )
95
95
end
96
96
97
- test "press_in captures and starts editing" , % { vp: vp , pid: pid } do
97
+ test "press_in captures, starts editing and fire focus event " , % { vp: vp , pid: pid } do
98
98
assert Input . fetch_captures! ( vp ) == { :ok , [ ] }
99
99
Input . send ( vp , @ press_in )
100
100
force_sync ( vp . pid , pid )
101
+
101
102
assert Input . fetch_captures! ( vp ) ~> { :ok , sorted_list ( [ :codepoint , :cursor_button , :key ] ) }
103
+ assert_receive ( { :fwd_event , { :focus , :text_field } } , 200 )
102
104
103
105
Input . send ( vp , @ cp_k )
104
106
assert_receive ( { :fwd_event , { :value_changed , :text_field , "kInitial value" } } , 200 )
105
107
end
106
108
107
- test "press_out releases and ends editing" , % { vp: vp , pid: pid } do
109
+ test "press_out releases, ends editing and fire blur event " , % { vp: vp , pid: pid } do
108
110
Input . send ( vp , @ press_in )
109
111
force_sync ( vp . pid , pid )
110
112
111
113
assert Input . fetch_captures! ( vp ) ~> { :ok , sorted_list ( [ :codepoint , :cursor_button , :key ] ) }
114
+ assert_receive ( { :fwd_event , { :focus , :text_field } } , 200 )
112
115
113
116
Input . send ( vp , @ press_out )
114
117
force_sync ( vp . pid , pid )
115
118
assert Input . fetch_captures! ( vp ) == { :ok , [ ] }
119
+ assert_receive ( { :fwd_event , { :blur , :text_field } } , 200 )
116
120
117
121
Input . send ( vp , @ cp_k )
118
122
refute_receive ( _ , 10 )
@@ -121,6 +125,7 @@ defmodule Scenic.Component.Input.TextFieldTest do
121
125
test "pressing in the field moves the cursor to the nearst character gap" , % { vp: vp , pid: pid } do
122
126
Input . send ( vp , @ press_in )
123
127
force_sync ( vp . pid , pid )
128
+ assert_receive ( { :fwd_event , { :focus , :text_field } } , 200 )
124
129
125
130
Input . send ( vp , @ cp_k )
126
131
assert_receive ( { :fwd_event , { :value_changed , :text_field , "kInitial value" } } , 200 )
@@ -201,6 +206,7 @@ defmodule Scenic.Component.Input.TextFieldTest do
201
206
test "backspace does nothing at the start of the string" , % { vp: vp , pid: pid } do
202
207
Input . send ( vp , @ press_in )
203
208
force_sync ( vp . pid , pid )
209
+ assert_receive ( { :fwd_event , { :focus , :text_field } } , 200 )
204
210
205
211
Input . send ( vp , @ key_backspace )
206
212
refute_receive ( _ , 10 )
@@ -217,6 +223,7 @@ defmodule Scenic.Component.Input.TextFieldTest do
217
223
test "delete does nothing at the end of the field" , % { vp: vp , pid: pid } do
218
224
Input . send ( vp , @ press_in )
219
225
force_sync ( vp . pid , pid )
226
+ assert_receive ( { :fwd_event , { :focus , :text_field } } , 200 )
220
227
221
228
Input . send ( vp , @ key_end )
222
229
Input . send ( vp , @ key_delete )
@@ -229,6 +236,7 @@ defmodule Scenic.Component.Input.TextFieldTest do
229
236
230
237
Input . send ( vp , { :cursor_button , { :btn_left , 1 , [ ] , { 20 , 60 } } } )
231
238
force_sync ( vp . pid , pid )
239
+ assert_receive ( { :fwd_event , { :focus , :number_field } } , 200 )
232
240
233
241
Input . send ( vp , { :codepoint , { "a" , [ ] } } )
234
242
refute_receive ( _ , 10 )
@@ -248,6 +256,7 @@ defmodule Scenic.Component.Input.TextFieldTest do
248
256
249
257
Input . send ( vp , { :cursor_button , { :btn_left , 1 , [ ] , { 14 , 86 } } } )
250
258
force_sync ( vp . pid , pid )
259
+ assert_receive ( { :fwd_event , { :focus , :integer_field } } , 200 )
251
260
252
261
Input . send ( vp , { :codepoint , { "a" , [ ] } } )
253
262
refute_receive ( _ , 10 )
@@ -267,6 +276,7 @@ defmodule Scenic.Component.Input.TextFieldTest do
267
276
268
277
Input . send ( vp , { :cursor_button , { :btn_left , 1 , [ ] , { 14 , 121 } } } )
269
278
force_sync ( vp . pid , pid )
279
+ assert_receive ( { :fwd_event , { :focus , :abcdefg_field } } , 200 )
270
280
271
281
Input . send ( vp , { :codepoint , { "a" , [ ] } } )
272
282
assert_receive ( { :fwd_event , { :value_changed , :abcdefg_field , "a" } } , 200 )
@@ -284,6 +294,7 @@ defmodule Scenic.Component.Input.TextFieldTest do
284
294
285
295
Input . send ( vp , { :cursor_button , { :btn_left , 1 , [ ] , { 14 , 171 } } } )
286
296
force_sync ( vp . pid , pid )
297
+ assert_receive ( { :fwd_event , { :focus , :fn_field } } , 200 )
287
298
288
299
Input . send ( vp , { :codepoint , { "a" , [ ] } } )
289
300
refute_receive ( _ , 10 )
0 commit comments