calabash-cucumber 0.19.2 → 0.20.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/dylibs/libCalabashDyn.dylib +0 -0
  3. data/dylibs/libCalabashDynSim.dylib +0 -0
  4. data/lib/calabash-cucumber.rb +9 -2
  5. data/lib/calabash-cucumber/abstract.rb +23 -0
  6. data/lib/calabash-cucumber/automator/automator.rb +158 -0
  7. data/lib/calabash-cucumber/automator/coordinates.rb +401 -0
  8. data/lib/calabash-cucumber/automator/device_agent.rb +424 -0
  9. data/lib/calabash-cucumber/automator/instruments.rb +441 -0
  10. data/lib/calabash-cucumber/connection_helpers.rb +1 -0
  11. data/lib/calabash-cucumber/core.rb +632 -138
  12. data/lib/calabash-cucumber/device_agent.rb +346 -0
  13. data/lib/calabash-cucumber/dot_dir.rb +1 -0
  14. data/lib/calabash-cucumber/environment.rb +1 -0
  15. data/lib/calabash-cucumber/environment_helpers.rb +4 -3
  16. data/lib/calabash-cucumber/http/http.rb +6 -4
  17. data/lib/calabash-cucumber/keyboard_helpers.rb +97 -679
  18. data/lib/calabash-cucumber/launcher.rb +107 -31
  19. data/lib/calabash-cucumber/log_tailer.rb +46 -0
  20. data/lib/calabash-cucumber/map.rb +7 -1
  21. data/lib/calabash-cucumber/rotation_helpers.rb +47 -139
  22. data/lib/calabash-cucumber/status_bar_helpers.rb +51 -20
  23. data/lib/calabash-cucumber/store/preferences.rb +3 -0
  24. data/lib/calabash-cucumber/uia.rb +333 -2
  25. data/lib/calabash-cucumber/usage_tracker.rb +2 -0
  26. data/lib/calabash-cucumber/version.rb +2 -2
  27. data/lib/calabash-cucumber/wait_helpers.rb +2 -0
  28. data/lib/calabash/formatters/html.rb +6 -1
  29. data/lib/frank-calabash.rb +10 -4
  30. data/scripts/.irbrc +3 -0
  31. data/staticlib/calabash.framework.zip +0 -0
  32. data/staticlib/libFrankCalabash.a +0 -0
  33. metadata +11 -6
  34. data/lib/calabash-cucumber/actions/instruments_actions.rb +0 -155
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8663515ecc8e1606eb80316b167fa1ded4172620
4
- data.tar.gz: 815edb4c91db68b8e41b257685c611f415cfb1d8
3
+ metadata.gz: 3beda8dc174cf33416893af2d2e58ed4a18d58cb
4
+ data.tar.gz: 60902d11897fa82bccba3e46aa869b52f152b9cc
5
5
  SHA512:
6
- metadata.gz: fa781ea6d16d67eca424becf04ec27137efa80590207337de1708f5473bc111e6119b55ca73ed8c5f1b4c883a109fdee101c5f5459dd1d77169d9159a4211f4c
7
- data.tar.gz: aac065435b8117da8e8db4b39c9dadf1961fad1a463482925d82dfa12486f3d07e315ac252627929bb1c465e832585c7bbc0c40f91cc870ee68bd0cb890ce4f1
6
+ metadata.gz: 734473873f98af082e74350e287571804aacb5855adff80bec317eb5cc73083ee6f7da6055f58aba53b3a9e15e9b5a775434febd7dfa18c5785ae89203958d87
7
+ data.tar.gz: 033948ff96011ee84c325adad1d72ceeef5fb4e22fdc607cb88e725ff19a20a17c6c6f7c6ba5c011054ae4f06a2c88e62993bf0eb6122127374615928610d176
Binary file
@@ -1,16 +1,23 @@
1
+ require "calabash-cucumber/abstract"
1
2
  require "calabash-cucumber/environment"
2
3
  require "calabash-cucumber/logging"
4
+ require "calabash-cucumber/log_tailer"
3
5
  require "calabash-cucumber/dot_dir"
4
6
  require "calabash-cucumber/store/preferences"
5
7
  require "calabash-cucumber/usage_tracker.rb"
6
8
  require "calabash-cucumber/dylibs"
7
9
  require "calabash-cucumber/http/http"
8
- require 'calabash-cucumber/core'
9
- require 'calabash-cucumber/tests_helpers'
10
+ require "calabash-cucumber/automator/coordinates"
11
+ require "calabash-cucumber/automator/automator"
12
+ require "calabash-cucumber/automator/instruments"
13
+ require "calabash-cucumber/automator/device_agent"
10
14
  require 'calabash-cucumber/keyboard_helpers'
11
15
  require 'calabash-cucumber/keychain_helpers'
12
16
  require 'calabash-cucumber/wait_helpers'
17
+ require "calabash-cucumber/device_agent"
13
18
  require 'calabash-cucumber/operations'
19
+ require 'calabash-cucumber/core'
20
+ require 'calabash-cucumber/tests_helpers'
14
21
  require 'calabash-cucumber/version'
15
22
  require 'calabash-cucumber/date_picker'
16
23
  require 'calabash-cucumber/ipad_1x_2x'
@@ -0,0 +1,23 @@
1
+
2
+ module Calabash
3
+ module Cucumber
4
+ # @!visibility private
5
+ module Abstract
6
+
7
+ # @!visibility private
8
+ class AbstractMethodError < StandardError; end
9
+
10
+ # @!visibility private
11
+ def abstract_method!
12
+ if Kernel.method_defined?(:caller_locations)
13
+ method_name = caller_locations.first.label
14
+ else
15
+ method_name = caller.first[/\`(.*)\'/, 1]
16
+ end
17
+
18
+ raise AbstractMethodError.new("Abstract method '#{method_name}'")
19
+ end
20
+ end
21
+ end
22
+ end
23
+
@@ -0,0 +1,158 @@
1
+ module Calabash
2
+ module Cucumber
3
+ # @!visibility private
4
+ module Automator
5
+ # @!visibility private
6
+ class Automator
7
+
8
+ require "calabash-cucumber/abstract"
9
+ include Calabash::Cucumber::Abstract
10
+
11
+
12
+ # @!visibility private
13
+ def initialize(*args)
14
+ abstract_method!
15
+ end
16
+
17
+ # @!visibility private
18
+ def name
19
+ abstract_method!
20
+ end
21
+
22
+ # @!visibility private
23
+ def stop
24
+ abstract_method!
25
+ end
26
+
27
+ # @!visibility private
28
+ def running?
29
+ abstract_method!
30
+ end
31
+
32
+ # @!visibility private
33
+ def client
34
+ abstract_method!
35
+ end
36
+
37
+ # @!visibility private
38
+ def touch(options)
39
+ abstract_method!
40
+ end
41
+
42
+ # @!visibility private
43
+ def double_tap(options)
44
+ abstract_method!
45
+ end
46
+
47
+ # @!visibility private
48
+ def two_finger_tap(options)
49
+ abstract_method!
50
+ end
51
+
52
+ # @!visibility private
53
+ def touch_hold(options)
54
+ abstract_method!
55
+ end
56
+
57
+ # @!visibility private
58
+ def flick(options)
59
+ abstract_method!
60
+ end
61
+
62
+ # @!visibility private
63
+ def swipe(direction, options={})
64
+ abstract_method!
65
+ end
66
+
67
+ # @!visibility private
68
+ #
69
+ # Callers must validate the options.
70
+ def pan(from_query, to_query, options={})
71
+ abstract_method!
72
+ end
73
+
74
+ # @!visibility private
75
+ #
76
+ # Callers must validate the options.
77
+ def pan_coordinates(from_point, to_point, options={})
78
+ abstract_method!
79
+ end
80
+
81
+ # @!visibility private
82
+ def pinch(in_or_out, options)
83
+ abstract_method!
84
+ end
85
+
86
+ # @!visibility private
87
+ def send_app_to_background(seconds)
88
+ abstract_method!
89
+ end
90
+
91
+ # @!visibility private
92
+ #
93
+ # It is the caller's responsibility to:
94
+ # 1. expect the keyboard is visible
95
+ # 2. escape the existing text
96
+ def enter_text_with_keyboard(string, options={})
97
+ abstract_method!
98
+ end
99
+
100
+ # @!visibility private
101
+ #
102
+ # Respond to keys like 'Delete' or 'Return'.
103
+ def char_for_keyboard_action(action_key)
104
+ abstract_method!
105
+ end
106
+
107
+ # @!visibility private
108
+ # It is the caller's responsibility to ensure the keyboard is visible.
109
+ def enter_char_with_keyboard(char)
110
+ abstract_method!
111
+ end
112
+
113
+ # @!visibility private
114
+ # It is the caller's responsibility to ensure the keyboard is visible.
115
+ def tap_keyboard_action_key
116
+ abstract_method!
117
+ end
118
+
119
+ # @!visibility private
120
+ # It is the caller's responsibility to ensure the keyboard is visible.
121
+ def tap_keyboard_delete_key
122
+ abstract_method!
123
+ end
124
+
125
+ # @!visibility private
126
+ #
127
+ # Legacy API - can we remove this method?
128
+ #
129
+ # It is the caller's responsibility to ensure the keyboard is visible.
130
+ def fast_enter_text(text)
131
+ abstract_method!
132
+ end
133
+
134
+ # @!visibility private
135
+ #
136
+ # Caller is responsible for limiting calls to iPads and waiting for the
137
+ # keyboard to disappear.
138
+ def dismiss_ipad_keyboard
139
+ abstract_method!
140
+ end
141
+
142
+ # @!visibility private
143
+ #
144
+ # Caller is responsible for providing a valid direction.
145
+ def rotate(direction)
146
+ abstract_method!
147
+ end
148
+
149
+ # @!visibility private
150
+ #
151
+ # Caller is responsible for normalizing and validating the position.
152
+ def rotate_home_button_to(position)
153
+ abstract_method!
154
+ end
155
+ end
156
+ end
157
+ end
158
+ end
@@ -0,0 +1,401 @@
1
+
2
+ module Calabash
3
+ module Cucumber
4
+ module Automator
5
+ # @!visibility private
6
+ class Coordinates
7
+
8
+ require "calabash-cucumber/map"
9
+
10
+ require "calabash-cucumber/status_bar_helpers"
11
+ include Calabash::Cucumber::StatusBarHelpers
12
+
13
+ # @!visibility private
14
+ attr_reader :element
15
+
16
+ # @!visibility private
17
+ def initialize(element)
18
+ @element = element
19
+ end
20
+
21
+ # @!visibility private
22
+ def self.left_point_for_full_screen_pan
23
+ coordinates = Coordinates.instance_without_element
24
+ {
25
+ x: coordinates.send(:min_x),
26
+ y: coordinates.send(:window)[:center_y]
27
+ }
28
+ end
29
+
30
+ # @!visibility private
31
+ def self.right_point_for_full_screen_pan
32
+ coordinates = Coordinates.instance_without_element
33
+ {
34
+ x: coordinates.send(:max_x),
35
+ y: coordinates.send(:window)[:center_y]
36
+ }
37
+ end
38
+
39
+ # @!visibility private
40
+ def self.top_point_for_full_screen_pan
41
+ coordinates = Coordinates.instance_without_element
42
+ {
43
+ x: coordinates.send(:window)[:center_x],
44
+ y: coordinates.send(:min_y)
45
+ }
46
+ end
47
+
48
+ # @!visibility private
49
+ def self.bottom_point_for_full_screen_pan
50
+ coordinates = Coordinates.instance_without_element
51
+ {
52
+ x: coordinates.send(:window)[:center_x],
53
+ y: coordinates.send(:max_y)
54
+ }
55
+ end
56
+
57
+ # @!visibility private
58
+ def self.points_for_full_screen_pan(direction)
59
+ case direction
60
+ when :left
61
+ start_point = Coordinates.right_point_for_full_screen_pan
62
+ end_point = Coordinates.left_point_for_full_screen_pan
63
+ when :right
64
+ start_point = Coordinates.left_point_for_full_screen_pan
65
+ end_point = Coordinates.right_point_for_full_screen_pan
66
+ when :up
67
+ start_point = Coordinates.bottom_point_for_full_screen_pan
68
+ end_point = Coordinates.top_point_for_full_screen_pan
69
+ when :down
70
+ start_point = Coordinates.top_point_for_full_screen_pan
71
+ end_point = Coordinates.bottom_point_for_full_screen_pan
72
+ else
73
+ raise ArgumentError,
74
+ "Direction #{direction} is not supported; use :left, :right, :top, :bottom"
75
+
76
+ end
77
+
78
+ {
79
+ start: start_point,
80
+ end: end_point
81
+ }
82
+ end
83
+
84
+ # @!visibility private
85
+ def left_point_for_full_view_pan
86
+ {
87
+ x: [min_x, element_origin[:x] + 10].max,
88
+ y: element_center[:y]
89
+ }
90
+ end
91
+
92
+ # @!visibility private
93
+ def right_point_for_full_view_pan
94
+ {
95
+ x: [max_x, element_origin[:x] + element_size[:width] - 10].min,
96
+ y: element_center[:y]
97
+ }
98
+ end
99
+
100
+ # @!visibility private
101
+ def top_point_for_full_view_pan
102
+ {
103
+ x: element_center[:x],
104
+ y: [min_y, (element_origin[:y] + 10)].max
105
+ }
106
+ end
107
+
108
+ # @!visibility private
109
+ def bottom_point_for_full_view_pan
110
+ {
111
+ x: element_center[:x],
112
+ y: [max_y, (element_origin[:y] + element_size[:height] - 10)].min
113
+ }
114
+ end
115
+
116
+ # @!visibility private
117
+ def points_for_full_view_pan(direction)
118
+ case direction
119
+ when :left
120
+ start_point = right_point_for_full_view_pan
121
+ end_point = left_point_for_full_view_pan
122
+ when :right
123
+ start_point = left_point_for_full_view_pan
124
+ end_point = right_point_for_full_view_pan
125
+ when :up
126
+ start_point = bottom_point_for_full_view_pan
127
+ end_point = top_point_for_full_view_pan
128
+ when :down
129
+ start_point = top_point_for_full_view_pan
130
+ end_point = bottom_point_for_full_view_pan
131
+ else
132
+ raise ArgumentError,
133
+ "Direction #{direction} is not supported; use :left, :right, :top, :bottom"
134
+
135
+ end
136
+
137
+ {
138
+ start: start_point,
139
+ end: end_point
140
+ }
141
+ end
142
+
143
+ # @!visibility private
144
+ def left_point_for_half_view_pan
145
+ {
146
+ x: [min_x, element_center[:x] - (element_size[:width]/4.0)].max,
147
+ y: element_center[:y]
148
+ }
149
+ end
150
+
151
+ # @!visibility private
152
+ def right_point_for_half_view_pan
153
+ {
154
+ x: [max_x, element_center[:x] + (element_size[:width]/4.0)].min,
155
+ y: element_center[:y]
156
+ }
157
+ end
158
+
159
+ # @!visibility private
160
+ def top_point_for_half_view_pan
161
+ {
162
+ x: element_center[:x],
163
+ y: [min_y, element_center[:y] - (element_size[:height]/4.0)].max
164
+ }
165
+ end
166
+
167
+ # @!visibility private
168
+ def bottom_point_for_half_view_pan
169
+ {
170
+ x: element_center[:x],
171
+ y: [max_y, element_center[:y] + (element_size[:height]/4.0)].min
172
+ }
173
+ end
174
+
175
+ # @!visibility private
176
+ def points_for_half_view_pan(direction)
177
+ case direction
178
+ when :left
179
+ start_point = right_point_for_half_view_pan
180
+ end_point = left_point_for_half_view_pan
181
+ when :right
182
+ start_point = left_point_for_half_view_pan
183
+ end_point = right_point_for_half_view_pan
184
+ when :up
185
+ start_point = bottom_point_for_half_view_pan
186
+ end_point = top_point_for_half_view_pan
187
+ when :down
188
+ start_point = top_point_for_half_view_pan
189
+ end_point = bottom_point_for_half_view_pan
190
+ else
191
+ raise ArgumentError,
192
+ "Direction #{direction} is not supported; use :left, :right, :top, :bottom"
193
+
194
+ end
195
+
196
+ {
197
+ start: start_point,
198
+ end: end_point
199
+ }
200
+ end
201
+
202
+ # @!visibility private
203
+ def left_point_for_small_view_pan
204
+ {
205
+ x: [min_x, element_center[:x] - (element_size[:width]/6.0)].max,
206
+ y: element_center[:y]
207
+ }
208
+ end
209
+
210
+ # @!visibility private
211
+ def right_point_for_small_view_pan
212
+ {
213
+ x: [max_x, element_center[:x] + (element_size[:width]/6.0)].min,
214
+ y: element_center[:y]
215
+ }
216
+ end
217
+
218
+ # @!visibility private
219
+ def top_point_for_small_view_pan
220
+ {
221
+ x: element_center[:x],
222
+ y: [min_y, element_center[:y] - (element_size[:height]/6.0)].max
223
+ }
224
+ end
225
+
226
+ # @!visibility private
227
+ def bottom_point_for_small_view_pan
228
+ {
229
+ x: element_center[:x],
230
+ y: [max_y, element_center[:y] + (element_size[:height]/6.0)].min
231
+ }
232
+ end
233
+
234
+ # @!visibility private
235
+ def points_for_small_view_pan(direction)
236
+ case direction
237
+ when :left
238
+ start_point = right_point_for_small_view_pan
239
+ end_point = left_point_for_small_view_pan
240
+ when :right
241
+ start_point = left_point_for_small_view_pan
242
+ end_point = right_point_for_small_view_pan
243
+ when :up
244
+ start_point = bottom_point_for_small_view_pan
245
+ end_point = top_point_for_small_view_pan
246
+ when :down
247
+ start_point = top_point_for_small_view_pan
248
+ end_point = bottom_point_for_small_view_pan
249
+ else
250
+ raise ArgumentError,
251
+ "Direction #{direction} is not supported; use :left, :right, :top, :bottom"
252
+
253
+ end
254
+
255
+ {
256
+ start: start_point,
257
+ end: end_point
258
+ }
259
+ end
260
+
261
+ # @!visibility private
262
+ def self.end_point_for_swipe(dir, element, force)
263
+ case dir
264
+ when :left
265
+ degrees = 0
266
+ when :up
267
+ degrees = 90
268
+ when :right
269
+ degrees = 180
270
+ when :down
271
+ degrees = 270
272
+ end
273
+ radians = degrees * Math::PI / 180.0
274
+
275
+ case force
276
+ when :light
277
+ scale_radius_by = 0.25
278
+ when :normal
279
+ scale_radius_by = 0.333
280
+ when :strong
281
+ scale_radius_by = 0.5
282
+ end
283
+
284
+ element_width = element["rect"]["width"]
285
+ element_height = element["rect"]["height"]
286
+ x_center = element["rect"]["center_x"]
287
+ y_center = element["rect"]["center_y"]
288
+ radius = ([element_width, element_height].min) * scale_radius_by
289
+ to_x = x_center - (radius * Math.cos(radians))
290
+ to_y = y_center - (radius * Math.sin(radians))
291
+ { :x => to_x, :y => to_y }
292
+ end
293
+
294
+ private
295
+
296
+ # @!visibility private
297
+ def self.instance_without_element
298
+ Coordinates.new(nil)
299
+ end
300
+
301
+ # @!visibility private
302
+ def element_center
303
+ @element_center ||= begin
304
+ {
305
+ x: element["rect"]["center_x"],
306
+ y: element["rect"]["center_y"]
307
+ }
308
+ end
309
+ end
310
+
311
+ # @!visibility private
312
+ def element_origin
313
+ @element_origin ||= begin
314
+ {
315
+ x: element["rect"]["x"],
316
+ y: element["rect"]["y"]
317
+ }
318
+ end
319
+ end
320
+
321
+ # @!visibility private
322
+ def element_size
323
+ @element_size ||= begin
324
+ {
325
+ height: element["rect"]["height"],
326
+ width: element["rect"]["width"]
327
+ }
328
+ end
329
+ end
330
+
331
+ # @!visibility private
332
+ def query_wrapper(query, *args)
333
+ Calabash::Cucumber::Map.map(query, :query, *args)
334
+ end
335
+
336
+ # @!visibility private
337
+ def height_for_view(view_class)
338
+ element = query_wrapper(view_class).first
339
+ if element
340
+ element["rect"]["height"]
341
+ else
342
+ 0
343
+ end
344
+ end
345
+
346
+ # @!visibility private
347
+ def status_bar_height
348
+ @status_bar_height ||= status_bar_details["frame"]["height"]
349
+ end
350
+
351
+ # @!visibility private
352
+ def nav_bar_height
353
+ @nav_bar_height ||= height_for_view("UINavigationBar")
354
+ end
355
+
356
+ # @!visibility private
357
+ def tab_bar_height
358
+ @tab_bar_height ||= height_for_view("UITabBar")
359
+ end
360
+
361
+ # @!visibility private
362
+ def toolbar_height
363
+ @toolbar_height ||= height_for_view("UIToolbar")
364
+ end
365
+
366
+ # @!visibility private
367
+ def window
368
+ @window ||= begin
369
+ element = query_wrapper("*").first
370
+ {
371
+ :height => element["rect"]["height"],
372
+ :width => element["rect"]["width"],
373
+ :center_x => element["rect"]["center_x"],
374
+ :center_y => element["rect"]["center_y"]
375
+ }
376
+ end
377
+ end
378
+
379
+ # @!visibility private
380
+ def min_y
381
+ @min_y ||= status_bar_height + nav_bar_height + 16
382
+ end
383
+
384
+ # @!visibility private
385
+ def max_y
386
+ @max_y ||= window[:height] - (tab_bar_height + toolbar_height + 16)
387
+ end
388
+
389
+ # @!visibility private
390
+ def min_x
391
+ 10
392
+ end
393
+
394
+ # @!visibility private
395
+ def max_x
396
+ @max_x ||= window[:width] - 10
397
+ end
398
+ end
399
+ end
400
+ end
401
+ end