calabash-cucumber 0.9.163.pre6 → 0.9.163.pre7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/calabash-cucumber.gemspec +1 -1
  3. data/lib/calabash-cucumber/actions/instruments_actions.rb +135 -0
  4. data/lib/calabash-cucumber/actions/playback_actions.rb +104 -0
  5. data/lib/calabash-cucumber/connection.rb +16 -0
  6. data/lib/calabash-cucumber/connection_helpers.rb +17 -0
  7. data/lib/calabash-cucumber/core.rb +80 -553
  8. data/lib/calabash-cucumber/failure_helpers.rb +44 -0
  9. data/lib/calabash-cucumber/http_helpers.rb +102 -0
  10. data/lib/calabash-cucumber/ios7_operations.rb +46 -31
  11. data/lib/calabash-cucumber/keyboard_helpers.rb +26 -16
  12. data/lib/calabash-cucumber/launcher.rb +42 -8
  13. data/lib/calabash-cucumber/map.rb +28 -0
  14. data/lib/calabash-cucumber/operations.rb +0 -4
  15. data/lib/calabash-cucumber/playback_helpers.rb +200 -0
  16. data/lib/calabash-cucumber/query_helpers.rb +32 -0
  17. data/lib/calabash-cucumber/resources/double_tap_ios5_ipad.base64 +15 -0
  18. data/lib/calabash-cucumber/resources/double_tap_ios5_iphone.base64 +15 -0
  19. data/lib/calabash-cucumber/resources/double_tap_ios6_ipad.base64 +22 -0
  20. data/lib/calabash-cucumber/resources/double_tap_ios6_iphone.base64 +22 -0
  21. data/lib/calabash-cucumber/resources/swipe_down_ios5_iphone.base64 +31 -18
  22. data/lib/calabash-cucumber/resources/swipe_down_ios6_ipad.base64 +25 -0
  23. data/lib/calabash-cucumber/resources/swipe_down_ios6_iphone.base64 +25 -0
  24. data/lib/calabash-cucumber/resources/swipe_left_ios5_iphone.base64 +34 -79
  25. data/lib/calabash-cucumber/resources/swipe_left_ios6_ipad.base64 +28 -0
  26. data/lib/calabash-cucumber/resources/swipe_left_ios6_iphone.base64 +28 -0
  27. data/lib/calabash-cucumber/resources/swipe_right_ios6_ipad.base64 +25 -0
  28. data/lib/calabash-cucumber/resources/swipe_right_ios6_iphone.base64 +25 -0
  29. data/lib/calabash-cucumber/resources/swipe_up_ios5_iphone.base64 +28 -34
  30. data/lib/calabash-cucumber/resources/swipe_up_ios6_ipad.base64 +25 -0
  31. data/lib/calabash-cucumber/resources/swipe_up_ios6_iphone.base64 +25 -0
  32. data/lib/calabash-cucumber/resources/touch_hold_ios5_ipad.base64 +9 -0
  33. data/lib/calabash-cucumber/resources/touch_hold_ios5_iphone.base64 +9 -0
  34. data/lib/calabash-cucumber/resources/touch_hold_ios6_ipad.base64 +9 -0
  35. data/lib/calabash-cucumber/resources/touch_hold_ios6_iphone.base64 +9 -0
  36. data/lib/calabash-cucumber/rotation_helpers.rb +112 -0
  37. data/lib/calabash-cucumber/status_bar_helpers.rb +30 -0
  38. data/lib/calabash-cucumber/tests_helpers.rb +3 -42
  39. data/lib/calabash-cucumber/uia.rb +8 -7
  40. data/lib/calabash-cucumber/version.rb +2 -2
  41. data/lib/calabash-cucumber/wait_helpers.rb +19 -2
  42. metadata +31 -4
@@ -0,0 +1,30 @@
1
+ module Calabash
2
+ module Cucumber
3
+ module StatusBarHelpers #=> Map
4
+
5
+ def device_orientation(force_down=false)
6
+ res = map(nil, :orientation, :device).first
7
+
8
+ if ['face up', 'face down'].include?(res)
9
+ if ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1'
10
+ if force_down
11
+ puts "WARN found orientation '#{res}' - will rotate to force orientation to 'down'"
12
+ end
13
+ end
14
+
15
+ return res if !force_down
16
+ return rotate_home_button_to :down
17
+ end
18
+
19
+ return res if !res.eql?('unknown')
20
+ return res if !force_down
21
+ rotate_home_button_to(:down)
22
+ end
23
+
24
+ def status_bar_orientation
25
+ map(nil, :orientation, :status_bar).first
26
+ end
27
+
28
+ end
29
+ end
30
+ end
@@ -1,9 +1,9 @@
1
- require 'calabash-cucumber/core'
1
+ require 'calabash-cucumber/failure_helpers'
2
2
 
3
3
  module Calabash
4
4
  module Cucumber
5
- module TestsHelpers
6
- include Calabash::Cucumber::Core
5
+ module TestsHelpers #=> http
6
+ include Calabash::Cucumber::FailureHelpers
7
7
 
8
8
  def navigation_path(*args)
9
9
 
@@ -51,15 +51,6 @@ module Calabash
51
51
  check_element_exists("view marked:'#{expected_mark}'")
52
52
  end
53
53
 
54
- def screenshot_and_raise(msg, options={:prefix => nil, :name => nil, :label => nil})
55
- screenshot_embed(options)
56
- raise(msg)
57
- end
58
-
59
- def fail(msg="Error. Check log for details.", options={:prefix => nil, :name => nil, :label => nil})
60
- screenshot_and_raise(msg, options)
61
- end
62
-
63
54
  def each_cell(opts={:query => "tableView", :post_scroll => 0.3, :animate => true}, &block)
64
55
  uiquery = opts[:query] || "tableView"
65
56
  skip = opts[:skip_if]
@@ -101,36 +92,6 @@ module Calabash
101
92
  end
102
93
  end
103
94
 
104
-
105
- def screenshot_embed(options={:prefix => nil, :name => nil, :label => nil})
106
- path = screenshot(options)
107
- embed(path, "image/png", options[:label] || File.basename(path))
108
- end
109
-
110
- def screenshot(options={:prefix => nil, :name => nil})
111
- prefix = options[:prefix]
112
- name = options[:name]
113
-
114
- @@screenshot_count ||= 0
115
- res = http({:method => :get, :path => 'screenshot'})
116
- prefix = prefix || ENV['SCREENSHOT_PATH'] || ""
117
- if name.nil?
118
- name = "screenshot"
119
- else
120
- if File.extname(name).downcase == ".png"
121
- name = name.split(".png")[0]
122
- end
123
- end
124
-
125
- path = "#{prefix}#{name}_#{@@screenshot_count}.png"
126
- File.open(path, 'wb') do |f|
127
- f.write res
128
- end
129
- @@screenshot_count += 1
130
- path
131
- end
132
-
133
-
134
95
  end
135
96
  end
136
97
  end
@@ -9,17 +9,11 @@ module Calabash
9
9
  res = http({:method => :post, :path => 'uia'}, {command:command}.merge(options))
10
10
  res = JSON.parse(res)
11
11
  if res['outcome'] != 'SUCCESS'
12
- screenshot_and_raise "uia send failed because: #{res['reason']}\n#{res['details']}"
12
+ screenshot_and_raise "uia action failed because: #{res['reason']}\n#{res['details']}"
13
13
  end
14
14
  res['results'].first
15
15
  end
16
16
 
17
- def send_uia_command(opts ={})
18
- #deprecated, poor method signature
19
- #use uia("uia-js...",options)
20
- uia(opts[:command], opts)
21
- end
22
-
23
17
  def uia_query(*queryparts)
24
18
  #TODO escape '\n etc in query
25
19
  uia_handle_command(:query, queryparts)
@@ -230,6 +224,13 @@ module Calabash
230
224
  escape_quotes string
231
225
  end
232
226
 
227
+ def send_uia_command(opts ={})
228
+ #deprecated, poor method signature
229
+ #use uia("uia-js...",options)
230
+ uia(opts[:command], opts)
231
+ end
232
+
233
+
233
234
  private
234
235
  def validate_hash_is_location!(options)
235
236
  return if options[:latitude] and options[:longitude]
@@ -1,6 +1,6 @@
1
1
  module Calabash
2
2
  module Cucumber
3
- VERSION = '0.9.163.pre6'
4
- FRAMEWORK_VERSION = '0.9.163.pre3'
3
+ VERSION = '0.9.163.pre7'
4
+ FRAMEWORK_VERSION = '0.9.163.pre7'
5
5
  end
6
6
  end
@@ -18,7 +18,7 @@ module Calabash
18
18
  {:timeout => 10,
19
19
  :retry_frequency => 0.2,
20
20
  :post_timeout => 0.1,
21
- :timeout_message => "Timed out waiting...",
21
+ :timeout_message => 'Timed out waiting...',
22
22
  :screenshot_on_error => true}, &block)
23
23
  #note Hash is preferred, number acceptable for backwards compat
24
24
  timeout=options_or_timeout
@@ -43,7 +43,21 @@ module Calabash
43
43
  end
44
44
  sleep(post_timeout) if post_timeout > 0
45
45
  rescue WaitError => e
46
- handle_error_with_options(e,timeout_message, screenshot_on_error)
46
+ msg = timeout_message || e
47
+ if screenshot_on_error
48
+ sleep(retry_frequency)
49
+ path = screenshot
50
+ res = yield
51
+ # Validate after taking screenshot
52
+ if res
53
+ return res
54
+ else
55
+ embed(path)
56
+ raise msg
57
+ end
58
+ else
59
+ raise msg
60
+ end
47
61
  rescue Exception => e
48
62
  handle_error_with_options(e, nil, screenshot_on_error)
49
63
  end
@@ -68,6 +82,9 @@ module Calabash
68
82
 
69
83
  #options for wait_for apply
70
84
  def wait_for_elements_exist(elements_arr, options={})
85
+ if elements_arr.is_a?(String)
86
+ elements_arr = [elements_arr]
87
+ end
71
88
  options[:timeout_message] = options[:timeout_message] || "Timeout waiting for elements: #{elements_arr.join(",")}"
72
89
  wait_for(options) do
73
90
  elements_arr.all? { |q| element_exists(q) }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: calabash-cucumber
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.163.pre6
4
+ version: 0.9.163.pre7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Krukow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-12-19 00:00:00.000000000 Z
11
+ date: 2013-12-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -156,14 +156,14 @@ dependencies:
156
156
  requirements:
157
157
  - - ~>
158
158
  - !ruby/object:Gem::Version
159
- version: 0.1.0.pre4
159
+ version: 0.1.0.pre5
160
160
  type: :runtime
161
161
  prerelease: false
162
162
  version_requirements: !ruby/object:Gem::Requirement
163
163
  requirements:
164
164
  - - ~>
165
165
  - !ruby/object:Gem::Version
166
- version: 0.1.0.pre4
166
+ version: 0.1.0.pre5
167
167
  - !ruby/object:Gem::Dependency
168
168
  name: awesome_print
169
169
  requirement: !ruby/object:Gem::Requirement
@@ -226,21 +226,34 @@ files:
226
226
  - features-skeleton/support/env.rb
227
227
  - features/step_definitions/calabash_steps.rb
228
228
  - lib/calabash-cucumber.rb
229
+ - lib/calabash-cucumber/actions/instruments_actions.rb
230
+ - lib/calabash-cucumber/actions/playback_actions.rb
229
231
  - lib/calabash-cucumber/calabash_steps.rb
232
+ - lib/calabash-cucumber/connection.rb
233
+ - lib/calabash-cucumber/connection_helpers.rb
230
234
  - lib/calabash-cucumber/core.rb
231
235
  - lib/calabash-cucumber/cucumber.rb
232
236
  - lib/calabash-cucumber/date_picker.rb
233
237
  - lib/calabash-cucumber/device.rb
238
+ - lib/calabash-cucumber/failure_helpers.rb
239
+ - lib/calabash-cucumber/http_helpers.rb
234
240
  - lib/calabash-cucumber/ibase.rb
235
241
  - lib/calabash-cucumber/ios7_operations.rb
236
242
  - lib/calabash-cucumber/keyboard_helpers.rb
237
243
  - lib/calabash-cucumber/launch/simulator_helper.rb
238
244
  - lib/calabash-cucumber/launcher.rb
245
+ - lib/calabash-cucumber/map.rb
239
246
  - lib/calabash-cucumber/operations.rb
247
+ - lib/calabash-cucumber/playback_helpers.rb
248
+ - lib/calabash-cucumber/query_helpers.rb
240
249
  - lib/calabash-cucumber/resources/cell_swipe_ios4_ipad.base64
241
250
  - lib/calabash-cucumber/resources/cell_swipe_ios4_iphone.base64
242
251
  - lib/calabash-cucumber/resources/cell_swipe_ios5_ipad.base64
243
252
  - lib/calabash-cucumber/resources/cell_swipe_ios5_iphone.base64
253
+ - lib/calabash-cucumber/resources/double_tap_ios5_ipad.base64
254
+ - lib/calabash-cucumber/resources/double_tap_ios5_iphone.base64
255
+ - lib/calabash-cucumber/resources/double_tap_ios6_ipad.base64
256
+ - lib/calabash-cucumber/resources/double_tap_ios6_iphone.base64
244
257
  - lib/calabash-cucumber/resources/pan_ios5_ipad.base64
245
258
  - lib/calabash-cucumber/resources/pan_ios5_iphone.base64
246
259
  - lib/calabash-cucumber/resources/pan_ios6_ipad.base64
@@ -289,24 +302,36 @@ files:
289
302
  - lib/calabash-cucumber/resources/rotate_right_home_up_ios5_iphone.base64
290
303
  - lib/calabash-cucumber/resources/swipe_down_ios5_ipad.base64
291
304
  - lib/calabash-cucumber/resources/swipe_down_ios5_iphone.base64
305
+ - lib/calabash-cucumber/resources/swipe_down_ios6_ipad.base64
306
+ - lib/calabash-cucumber/resources/swipe_down_ios6_iphone.base64
292
307
  - lib/calabash-cucumber/resources/swipe_left_hard_ios4_ipad.base64
293
308
  - lib/calabash-cucumber/resources/swipe_left_hard_ios4_iphone.base64
294
309
  - lib/calabash-cucumber/resources/swipe_left_ios4_ipad.base64
295
310
  - lib/calabash-cucumber/resources/swipe_left_ios4_iphone.base64
296
311
  - lib/calabash-cucumber/resources/swipe_left_ios5_ipad.base64
297
312
  - lib/calabash-cucumber/resources/swipe_left_ios5_iphone.base64
313
+ - lib/calabash-cucumber/resources/swipe_left_ios6_ipad.base64
314
+ - lib/calabash-cucumber/resources/swipe_left_ios6_iphone.base64
298
315
  - lib/calabash-cucumber/resources/swipe_right_hard_ios4_ipad.base64
299
316
  - lib/calabash-cucumber/resources/swipe_right_hard_ios4_iphone.base64
300
317
  - lib/calabash-cucumber/resources/swipe_right_ios4_ipad.base64
301
318
  - lib/calabash-cucumber/resources/swipe_right_ios4_iphone.base64
302
319
  - lib/calabash-cucumber/resources/swipe_right_ios5_ipad.base64
303
320
  - lib/calabash-cucumber/resources/swipe_right_ios5_iphone.base64
321
+ - lib/calabash-cucumber/resources/swipe_right_ios6_ipad.base64
322
+ - lib/calabash-cucumber/resources/swipe_right_ios6_iphone.base64
304
323
  - lib/calabash-cucumber/resources/swipe_up_ios5_ipad.base64
305
324
  - lib/calabash-cucumber/resources/swipe_up_ios5_iphone.base64
325
+ - lib/calabash-cucumber/resources/swipe_up_ios6_ipad.base64
326
+ - lib/calabash-cucumber/resources/swipe_up_ios6_iphone.base64
306
327
  - lib/calabash-cucumber/resources/touch_done_ios4_ipad.base64
307
328
  - lib/calabash-cucumber/resources/touch_done_ios4_iphone.base64
308
329
  - lib/calabash-cucumber/resources/touch_done_ios5_ipad.base64
309
330
  - lib/calabash-cucumber/resources/touch_done_ios5_iphone.base64
331
+ - lib/calabash-cucumber/resources/touch_hold_ios5_ipad.base64
332
+ - lib/calabash-cucumber/resources/touch_hold_ios5_iphone.base64
333
+ - lib/calabash-cucumber/resources/touch_hold_ios6_ipad.base64
334
+ - lib/calabash-cucumber/resources/touch_hold_ios6_iphone.base64
310
335
  - lib/calabash-cucumber/resources/touch_ios4_ipad.base64
311
336
  - lib/calabash-cucumber/resources/touch_ios4_iphone.base64
312
337
  - lib/calabash-cucumber/resources/touch_ios5_ipad.base64
@@ -321,6 +346,8 @@ files:
321
346
  - lib/calabash-cucumber/resources/wheel_up_ios4_iphone.base64
322
347
  - lib/calabash-cucumber/resources/wheel_up_ios5_ipad.base64
323
348
  - lib/calabash-cucumber/resources/wheel_up_ios5_iphone.base64
349
+ - lib/calabash-cucumber/rotation_helpers.rb
350
+ - lib/calabash-cucumber/status_bar_helpers.rb
324
351
  - lib/calabash-cucumber/tests_helpers.rb
325
352
  - lib/calabash-cucumber/uia.rb
326
353
  - lib/calabash-cucumber/version.rb