calabash-cucumber 0.9.151 → 0.9.152

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 65d842e54bba4c90f96d1e6e45af63c9d18c6c5e
4
- data.tar.gz: 2ef76a18f37855579f0f1d1211abeca56364a57c
3
+ metadata.gz: 4e5d32bd3de7fc4255e3c73c5c94a1b437445bda
4
+ data.tar.gz: def9cece9fcf16b4e2f1dc552b0cb0faa0e9b095
5
5
  SHA512:
6
- metadata.gz: 065dd85fb3a090d48713c6a7a76bc41d4cbc45aba2b9f48836a420bdbbc063a96fa69143f5752bafadac27a450924828a359284dddb3cd8eeec503474f1e79b4
7
- data.tar.gz: 90f4e515b68e12748210c7b4d66967a715edc021652ead2df6201a4091917e3fbadade7ddd627cc244a44cdd0f17fb4f67f5a57ceb344bc45959285e76153746
6
+ metadata.gz: 24b3c029c87ec6c03e1303726298590e02dd4fcc21d9fdc49f456f2b0cf34e8f7cdfaaa5ac41a23e9dd49a1ed4b7ee41edf7a4d2949a09f3065a85bd7cdc0a71
7
+ data.tar.gz: e83946d9e1bb3725edaa5240541ca55e18a9356a0e063bfd071a48b790a8f04eefc41154882adaeb59f78d78aca04f385238563fe959a1803f2f606414d0b7b1
data/Rakefile CHANGED
@@ -23,7 +23,7 @@ EOF
23
23
 
24
24
  FileUtils.cd(dir) do
25
25
  puts 'Building Server'
26
- cmd = 'xcodebuild build -project calabash.xcodeproj -target Framework -configuration Debug -sdk iphonesimulator6.1'
26
+ cmd = 'xcodebuild build -project calabash.xcodeproj -target Framework -configuration Debug -sdk iphonesimulator7.0'
27
27
  puts cmd
28
28
  puts `#{cmd}`
29
29
 
@@ -56,7 +56,5 @@ EOF
56
56
 
57
57
  end
58
58
 
59
- task :build => [:build_server]
60
- task :install => [:build_server]
61
- task :release => [:build_server]
62
-
59
+ task :install_server => [:build_server]
60
+ task :release_server => [:build_server]
@@ -46,6 +46,11 @@ end
46
46
 
47
47
  def console
48
48
  path = ENV['CALABASH_IRBRC']
49
+ unless path
50
+ if File.exist?('.irbrc')
51
+ path = File.expand_path('.irbrc')
52
+ end
53
+ end
49
54
  unless path
50
55
  path = File.expand_path(File.join(@script_dir,".irbrc"))
51
56
  end
@@ -26,7 +26,7 @@ Gem::Specification.new do |s|
26
26
  s.add_dependency( "location-one", "~>0.0.10")
27
27
  s.add_dependency( "httpclient","~> 2.3.3")
28
28
  s.add_dependency( "bundler", "~> 1.1")
29
- s.add_dependency( "run_loop", "~> 0.0.15" )
29
+ s.add_dependency( "run_loop", "~> 0.0.19" )
30
30
  s.add_dependency( "awesome_print")
31
31
 
32
32
  end
@@ -97,12 +97,16 @@ end
97
97
  ## -- Entering text -- ##
98
98
 
99
99
  Then /^I enter "([^\"]*)" into the "([^\"]*)" field$/ do |text_to_type, field_name|
100
- set_text("textField marked:'#{field_name}'", text_to_type)
100
+ touch("textField marked:'#{field_name}'")
101
+ await_keyboard
102
+ keyboard_enter_text text_to_type
101
103
  sleep(STEP_PAUSE)
102
104
  end
103
105
 
104
106
  Then /^I enter "([^\"]*)" into the "([^\"]*)" (?:text|input) field$/ do |text_to_type, field_name|
105
- set_text("textField placeholder:'#{field_name}'", text_to_type)
107
+ touch("textField marked:'#{field_name}'")
108
+ await_keyboard
109
+ keyboard_enter_text text_to_type
106
110
  sleep(STEP_PAUSE)
107
111
  end
108
112
 
@@ -127,24 +131,33 @@ end
127
131
  Then /^I enter "([^\"]*)" into (?:input|text) field number (\d+)$/ do |text, index|
128
132
  index = index.to_i
129
133
  screenshot_and_raise "Index should be positive (was: #{index})" if (index<=0)
130
- set_text("textField index:#{index-1}",text)
134
+ touch("textField index:#{index-1}")
135
+ await_keyboard()
136
+ keyboard_enter_text text
137
+ sleep(STEP_PAUSE)
131
138
  end
132
139
 
133
140
  Then /^I use the native keyboard to enter "([^\"]*)" into (?:input|text) field number (\d+)$/ do |text_to_type, index|
134
- macro %Q|I touch text field number #{index}|
141
+ idx = index.to_i
142
+ macro %Q|I touch text field number #{idx}|
135
143
  await_keyboard()
136
144
  keyboard_enter_text(text_to_type)
137
145
  sleep(STEP_PAUSE)
138
146
  end
139
147
 
140
148
  When /^I clear "([^\"]*)"$/ do |name|
141
- macro %Q|I enter "" into the "#{name}" text field|
149
+ # definition changed - now uses keyboard_enter_text instead of (deprecated) set_text
150
+ # macro %Q|I enter "" into the "#{name}" text field|
151
+ unless ENV['CALABASH_NO_DEPRECATION'] == '1'
152
+ warn "WARNING: 'When I clear <name>' will be deprecated because it is ambiguous - what should be cleared?"
153
+ end
154
+ clear_text("textField marked:'#{name}'")
142
155
  end
143
156
 
144
157
  Then /^I clear (?:input|text) field number (\d+)$/ do |index|
145
158
  index = index.to_i
146
159
  screenshot_and_raise "Index should be positive (was: #{index})" if (index<=0)
147
- set_text("textField index:#{index-1}","")
160
+ clear_text("textField index:#{index-1}")
148
161
  end
149
162
 
150
163
  # -- See -- #
@@ -176,8 +189,11 @@ Then /^I wait to see a navigation bar titled "([^\"]*)"$/ do |expected_mark|
176
189
  end
177
190
  end
178
191
 
179
- Then /^I wait for the "([^\"]*)" (?:input|text) field$/ do |placeholder|
180
- wait_for(WAIT_TIMEOUT) { element_exists( "textField placeholder:'#{placeholder}'") || element_exists( "textField marked:'#{placeholder}'") }
192
+ Then /^I wait for the "([^\"]*)" (?:input|text) field$/ do |placeholder_or_view_mark|
193
+ wait_for(WAIT_TIMEOUT) {
194
+ element_exists( "textField placeholder:'#{placeholder_or_view_mark}'") ||
195
+ element_exists( "textField marked:'#{placeholder_or_view_mark}'")
196
+ }
181
197
  end
182
198
 
183
199
  Then /^I wait for (\d+) (?:input|text) field(?:s)?$/ do |count|
@@ -1,11 +1,13 @@
1
1
  require 'httpclient'
2
2
  require 'calabash-cucumber/launch/simulator_helper'
3
3
  require 'calabash-cucumber/uia'
4
+ require 'calabash-cucumber/ios7_operations'
4
5
 
5
6
  module Calabash
6
7
  module Cucumber
7
8
  module Core
8
9
  include Calabash::Cucumber::UIA
10
+ include Calabash::Cucumber::IOS7Operations
9
11
 
10
12
  DATA_PATH = File.expand_path(File.dirname(__FILE__))
11
13
  CAL_HTTP_RETRY_COUNT=3
@@ -14,6 +16,7 @@ module Calabash
14
16
  Errno::ECONNREFUSED, Errno::ECONNRESET, Errno::ECONNABORTED,
15
17
  Errno::ETIMEDOUT]
16
18
 
19
+
17
20
  def macro(txt)
18
21
  if self.respond_to? :step
19
22
  step(txt)
@@ -65,30 +68,16 @@ module Calabash
65
68
  map("all #{uiquery}", :query, *args)
66
69
  end
67
70
 
71
+
68
72
  def touch(uiquery, options={})
73
+
74
+
69
75
  if (uiquery.is_a?(Array))
70
76
  raise "No elements to touch in array" if uiquery.empty?
71
77
  uiquery = uiquery.first
72
78
  end
73
79
  if (uiquery.is_a?(Hash))
74
- offset_x = 0
75
- offset_y = 0
76
- if options[:offset]
77
- offset_x += options[:offset][:x] || 0
78
- offset_y += options[:offset][:y] || 0
79
- end
80
- x = offset_x
81
- y = offset_y
82
- rect = uiquery["rect"] || uiquery[:rect]
83
- if rect
84
- x += rect['center_x'] || rect[:center_x] || rect[:x] || 0
85
- y += rect['center_y'] || rect[:center_y] || rect[:y] || 0
86
- else
87
- x += uiquery['center_x'] || uiquery[:center_x] || uiquery[:x] || 0
88
- y += uiquery['center_y'] || uiquery[:center_y] || uiquery[:y] || 0
89
- end
90
-
91
- options[:offset] = {:x => x, :y => y}
80
+ options[:offset] = point_from(uiquery, options)
92
81
  return touch(nil, options)
93
82
  end
94
83
 
@@ -101,58 +90,74 @@ module Calabash
101
90
  end
102
91
 
103
92
  def do_touch(options)
104
- if ENV['OS']=='ios7' || @calabash_launcher && @calabash_launcher.ios_major_version == "7"
105
- options[:uia_gesture] = :tap
93
+ if ios7?
94
+ touch_ios7(options)
95
+ else
96
+ playback("touch", options)
106
97
  end
107
- playback("touch", options)
108
98
  end
109
99
 
110
100
  def swipe(dir, options={})
111
- dir = dir.to_sym
112
- @current_rotation = @current_rotation || :down
113
- if @current_rotation == :left
114
- case dir
115
- when :left then
116
- dir = :down
117
- when :right then
118
- dir = :up
119
- when :up then
120
- dir = :left
121
- when :down then
122
- dir = :right
123
- else
101
+ if ios7?
102
+ swipe_ios7(options.merge(:direction => dir))
103
+ else
104
+ dir = dir.to_sym
105
+ current_orientation = device_orientation().to_sym
106
+ if current_orientation == :left
107
+ case dir
108
+ when :left then
109
+ dir = :down
110
+ when :right then
111
+ dir = :up
112
+ when :up then
113
+ dir = :left
114
+ when :down then
115
+ dir = :right
116
+ else
117
+ end
124
118
  end
125
- end
126
- if @current_rotation == :right
127
- case dir
128
- when :left then
129
- dir = :up
130
- when :right then
131
- dir = :down
132
- when :up then
133
- dir = :right
134
- when :down then
135
- dir = :left
136
- else
119
+ if current_orientation == :right
120
+ case dir
121
+ when :left then
122
+ dir = :up
123
+ when :right then
124
+ dir = :down
125
+ when :up then
126
+ dir = :right
127
+ when :down then
128
+ dir = :left
129
+ else
130
+ end
137
131
  end
138
- end
139
- if @current_rotation == :up
140
- case dir
141
- when :left then
142
- dir = :right
143
- when :right then
144
- dir = :left
145
- when :up then
146
- dir = :down
147
- when :down then
148
- dir = :up
149
- else
132
+ if current_orientation == :up
133
+ case dir
134
+ when :left then
135
+ dir = :right
136
+ when :right then
137
+ dir = :left
138
+ when :up then
139
+ dir = :down
140
+ when :down then
141
+ dir = :up
142
+ else
143
+ end
150
144
  end
145
+ playback("swipe_#{dir}", options)
146
+ end
147
+ end
148
+
149
+ def pan(from, to, options={})
150
+ if ios7?
151
+ pan_ios7(from, to, options)
152
+ else
153
+ interpolate "pan", options.merge(:start => from, :end => to)
151
154
  end
152
- playback("swipe_#{dir}", options)
153
155
  end
154
156
 
155
157
  def cell_swipe(options={})
158
+ if ios7?
159
+ raise "cell_swipe not supported on iOS7, simply use swipe with a query that matches the cell"
160
+ end
156
161
  playback("cell_swipe", options)
157
162
  end
158
163
 
@@ -225,70 +230,119 @@ module Calabash
225
230
  end
226
231
 
227
232
  def pinch(in_out, options={})
228
- file = "pinch_in"
229
- if in_out.to_sym==:out
230
- file = "pinch_out"
233
+ if ios7?
234
+ pinch_ios7(in_out.to_sym, options)
235
+ else
236
+ file = "pinch_in"
237
+ if in_out.to_sym==:out
238
+ file = "pinch_out"
239
+ end
240
+ playback(file, options)
241
+ end
242
+ end
243
+
244
+ def rotation_candidates
245
+ ['rotate_left_home_down', 'rotate_left_home_left',
246
+ 'rotate_left_home_right', 'rotate_left_home_up',
247
+ 'rotate_right_home_down', 'rotate_right_home_left',
248
+ 'rotate_right_home_right', 'rotate_right_home_up']
249
+ end
250
+
251
+ # orientations refer to home button position
252
+ # down ==> bottom
253
+ # up ==> top
254
+ # left ==> landscape with left home button AKA: _right_ landscape*
255
+ # right ==> landscape with right home button AKA: _left_ landscape*
256
+ #
257
+ # * see apple documentation for clarification about where the home button
258
+ # is in left and right landscape orientations
259
+ def rotate_home_button_to(dir)
260
+ dir = dir.to_s
261
+ res = device_orientation
262
+ return res if res.eql? dir
263
+ rotation_candidates.each { |candidate|
264
+ #if ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1'
265
+ # puts "try to rotate to '#{dir}' using '#{candidate}'"
266
+ #end
267
+ playback(candidate)
268
+ # need a longer sleep for cloud testing
269
+ sleep(0.5)
270
+ res = device_orientation
271
+
272
+ ### UNEXPECTED ###
273
+ # device orientation changes when rotation playback is performed
274
+ # _regardless_ of whether or not the rotation succeeded
275
+ #
276
+ # this is an attempt to sync to the device and status bar orientation
277
+ if res.eql? dir
278
+ status_bar = status_bar_orientation
279
+ if status_bar.eql? res
280
+ return res
281
+ else
282
+ return rotate_home_button_to status_bar
283
+ end
284
+ end
285
+
286
+ # return res if res.eql? dir
287
+ }
288
+ if ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1'
289
+ puts "Could not rotate device. Is rotation enabled in app? Will return 'down'"
231
290
  end
232
- playback(file, options)
291
+ 'down'
233
292
  end
234
293
 
235
- #Current position of home button
236
- def current_rotation
237
- @current_rotation
294
+ def device_orientation(force_down=false)
295
+ res = map(nil, :orientation, :device).first
296
+ return res if !res.eql?('unknown')
297
+ return res if !force_down
298
+ rotate_home_button_to(:down)
299
+ end
300
+
301
+ def status_bar_orientation
302
+ map(nil, :orientation, :status_bar).first
238
303
  end
239
304
 
240
305
  def rotate(dir)
241
- @current_rotation = @current_rotation || :down
242
- rotate_cmd = nil
243
- case dir
244
- when :left then
245
- if @current_rotation == :down
246
- rotate_cmd = "left_home_down"
247
- @current_rotation = :right
248
- elsif @current_rotation == :right
249
- rotate_cmd = "left_home_right"
250
- @current_rotation = :up
251
- elsif @current_rotation == :left
252
- rotate_cmd = "left_home_left"
253
- @current_rotation = :down
254
- elsif @current_rotation == :up
255
- rotate_cmd = "left_home_up"
256
- @current_rotation = :left
257
- end
258
- when :right then
259
- if @current_rotation == :down
260
- rotate_cmd = "right_home_down"
261
- @current_rotation = :left
262
- elsif @current_rotation == :left
263
- rotate_cmd = "right_home_left"
264
- @current_rotation = :up
265
- elsif @current_rotation == :right
266
- rotate_cmd = "right_home_right"
267
- @current_rotation = :down
268
- elsif @current_rotation == :up
269
- rotate_cmd = "right_home_up"
270
- @current_rotation = :right
271
- end
272
- end
306
+ if ios7?
307
+ rotate_ios7(dir)
308
+ else
309
+ dir = dir.to_sym
310
+ current_orientation = device_orientation(true).to_sym
311
+ rotate_cmd = nil
312
+ case dir
313
+ when :left then
314
+ if current_orientation == :down
315
+ rotate_cmd = "left_home_down"
316
+ elsif current_orientation == :right
317
+ rotate_cmd = "left_home_right"
318
+ elsif current_orientation == :left
319
+ rotate_cmd = "left_home_left"
320
+ elsif current_orientation == :up
321
+ rotate_cmd = "left_home_up"
322
+ end
323
+ when :right then
324
+ if current_orientation == :down
325
+ rotate_cmd = "right_home_down"
326
+ elsif current_orientation == :left
327
+ rotate_cmd = "right_home_left"
328
+ elsif current_orientation == :right
329
+ rotate_cmd = "right_home_right"
330
+ elsif current_orientation == :up
331
+ rotate_cmd = "right_home_up"
332
+ end
333
+ end
273
334
 
274
- if rotate_cmd.nil?
275
- screenshot_and_raise "Does not support rotating #{dir} when home button is pointing #{@current_rotation}"
335
+ # should this really throw an exception? shouldn't it just report a
336
+ # warning and do nothing?
337
+ if rotate_cmd.nil?
338
+ screenshot_and_raise "Does not support rotating '#{dir}' when home button is pointing '#{current_orientation}'"
339
+ end
340
+ playback("rotate_#{rotate_cmd}")
276
341
  end
277
- playback("rotate_#{rotate_cmd}")
278
342
  end
279
343
 
280
344
  def background(secs)
281
- set_user_pref("__calabash_action", {:action => :background, :duration => secs})
282
- end
283
-
284
- def prepare_dialog_action(opts={:dialog => nil, :answer => "Ok"})
285
- if opts[:dialog].nil? || opts[:dialog].length < 1
286
- raise ":dialog must be specified as a non-empty string (used as regexp to match dialog text)"
287
- end
288
- txt = opts[:answer] || 'Ok'
289
- set_user_pref("__calabash_action", {:action => :dialog,
290
- :text => opts[:dialog],
291
- :answer => txt})
345
+ uia_send_app_to_background(secs)
292
346
  end
293
347
 
294
348
  def move_wheel(opts={})
@@ -348,19 +402,29 @@ module Calabash
348
402
  end
349
403
  end
350
404
 
351
-
352
405
  def load_recording(recording, rec_dir)
353
- data = nil
354
- if (File.exists?(recording))
355
- data = File.read(recording)
356
- elsif (File.exists?("features/#{recording}"))
357
- data = File.read("features/#{recording}")
358
- elsif (File.exists?("#{rec_dir}/#{recording}"))
359
- data = File.read("#{rec_dir}/#{recording}")
360
- elsif (File.exists?("#{DATA_PATH}/resources/#{recording}"))
361
- data = File.read("#{DATA_PATH}/resources/#{recording}")
362
- end
363
- data
406
+ directories = playback_file_directories(rec_dir)
407
+ directories.each { |dir|
408
+ path = "#{dir}/#{recording}"
409
+ if File.exists?(path)
410
+ # useful for debugging recordings, but too verbose for release
411
+ # suggest (yet) another variable CALABASH_DEBUG_PLAYBACK ?
412
+ #if ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1'
413
+ # puts "found compatible playback: '#{path}'"
414
+ #end
415
+ return File.read(path)
416
+ end
417
+ }
418
+ nil
419
+ end
420
+
421
+ def playback_file_directories (rec_dir)
422
+ # rec_dir is either ENV['PLAYBACK_DIR'] or ./features/playback
423
+ [File.expand_path(rec_dir),
424
+ "#{Dir.pwd}",
425
+ "#{Dir.pwd}/features",
426
+ "#{Dir.pwd}/features/playback",
427
+ "#{DATA_PATH}/resources/"].uniq
364
428
  end
365
429
 
366
430
  def load_playback_data(recording_name, options={})
@@ -388,32 +452,48 @@ EOF
388
452
  os = "ios#{major}"
389
453
  end
390
454
 
391
- rec_dir = ENV['PLAYBACK_DIR'] || "#{Dir.pwd}/playback"
455
+ rec_dir = ENV['PLAYBACK_DIR'] || "#{Dir.pwd}/features/playback"
392
456
 
393
- recording = recording_name_for(recording_name, os, device)
394
- data = load_recording(recording, rec_dir)
395
-
396
- if data.nil? and os=="ios6"
397
- recording = recording_name_for(recording_name, "ios5", device)
398
- data = load_recording(recording, rec_dir)
399
- end
457
+ candidates = []
458
+ data = find_compatible_recording(recording_name, os, rec_dir, device, candidates)
400
459
 
401
460
  if data.nil? and device=='ipad'
402
461
  if ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1'
403
462
  puts "Unable to find recording for #{os} and #{device}. Trying with #{os} iphone"
404
463
  end
405
- recording = recording_name_for(recording_name, os, 'iphone')
406
- data = load_recording(recording, rec_dir)
464
+ data = find_compatible_recording(recording_name, os, rec_dir, 'iphone', candidates)
407
465
  end
408
466
 
409
-
410
467
  if data.nil?
411
- screenshot_and_raise "Playback not found: #{recording} (searched for #{recording} in #{Dir.pwd}, #{rec_dir}, #{DATA_PATH}/resources"
468
+ searched_for = " searched for => \n"
469
+ candidates.each { |file| searched_for.concat(" * '#{file}'\n") }
470
+ searched_in = " in directories =>\n"
471
+ playback_file_directories(rec_dir).each { |dir| searched_in.concat(" * '#{dir}'\n") }
472
+ screenshot_and_raise "Playback file not found for: '#{recording_name}'\n#{searched_for}#{searched_in}"
412
473
  end
413
474
 
414
475
  data
415
476
  end
416
477
 
478
+ def find_compatible_recording (recording_name, os, rec_dir, device, candidates)
479
+ recording = recording_name_for(recording_name, os, device)
480
+ data = load_recording(recording, rec_dir)
481
+ if data.nil?
482
+ candidates << recording
483
+ version_counter = os[-1, 1].to_i
484
+ loop do
485
+ version_counter = version_counter - 1
486
+ break if version_counter < 5
487
+ loop_os = "ios#{version_counter}"
488
+ recording = recording_name_for(recording_name, loop_os, device)
489
+ candidates << recording
490
+ data = load_recording(recording, rec_dir)
491
+ break if !data.nil?
492
+ end
493
+ end
494
+ data
495
+ end
496
+
417
497
  def playback(recording, options={})
418
498
  data = load_playback_data(recording)
419
499
 
@@ -434,6 +514,7 @@ EOF
434
514
  res['results']
435
515
  end
436
516
 
517
+ # not called? -jjm 2013-08-16
437
518
  def interpolate(recording, options={})
438
519
  data = load_playback_data(recording)
439
520
 
@@ -484,9 +565,41 @@ EOF
484
565
 
485
566
  file_name = "#{file_name}_#{os}_#{device}.base64"
486
567
  system("/usr/bin/plutil -convert binary1 -o _recording_binary.plist _recording.plist")
487
- system("openssl base64 -in _recording_binary.plist -out #{file_name}")
568
+ system("openssl base64 -in _recording_binary.plist -out '#{file_name}'")
488
569
  system("rm _recording.plist _recording_binary.plist")
489
- file_name
570
+
571
+ rec_dir = ENV['PLAYBACK_DIR'] || "#{Dir.pwd}/features/playback"
572
+ unless File.directory?(rec_dir)
573
+ if ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1'
574
+ puts "creating playback directory at '#{rec_dir}'"
575
+ end
576
+ system("mkdir -p #{rec_dir}")
577
+ end
578
+
579
+ system("mv #{file_name} #{rec_dir}")
580
+ "#{file_name} ==> '#{rec_dir}/#{file_name}'"
581
+
582
+ end
583
+
584
+ def point_from(query_result, options)
585
+ offset_x = 0
586
+ offset_y = 0
587
+ if options[:offset]
588
+ offset_x += options[:offset][:x] || 0
589
+ offset_y += options[:offset][:y] || 0
590
+ end
591
+ x = offset_x
592
+ y = offset_y
593
+ rect = query_result["rect"] || query_result[:rect]
594
+ if rect
595
+ x += rect['center_x'] || rect[:center_x] || rect[:x] || 0
596
+ y += rect['center_y'] || rect[:center_y] || rect[:y] || 0
597
+ else
598
+ x += query_result['center_x'] || query_result[:center_x] || query_result[:x] || 0
599
+ y += query_result['center_y'] || query_result[:center_y] || query_result[:y] || 0
600
+ end
601
+
602
+ {:x => x, :y => y}
490
603
  end
491
604
 
492
605
  def backdoor(sel, arg)
@@ -507,7 +620,7 @@ EOF
507
620
  # or HTTPClient::KeepAliveDisconnected
508
621
  # which needs to be suppressed.
509
622
  begin
510
- http({:method =>:post, :path => 'exit', :retryable_errors => RETRYABLE_ERRORS - [Errno::ECONNREFUSED,HTTPClient::KeepAliveDisconnected]})
623
+ http({:method => :post, :path => 'exit', :retryable_errors => RETRYABLE_ERRORS - [Errno::ECONNREFUSED, HTTPClient::KeepAliveDisconnected]})
511
624
  rescue Errno::ECONNREFUSED, HTTPClient::KeepAliveDisconnected
512
625
  []
513
626
  end
@@ -541,7 +654,7 @@ EOF
541
654
 
542
655
  def stop_test_server
543
656
  if @calabash_launcher
544
- @calabash_launcher.stop
657
+ @calabash_launcher.stop
545
658
  end
546
659
  end
547
660
 
@@ -595,7 +708,7 @@ EOF
595
708
  break
596
709
  rescue Exception => e
597
710
 
598
- if retryable_errors.include?(e) || retryable_errors.any?{|c| e.is_a?(c)}
711
+ if retryable_errors.include?(e) || retryable_errors.any? { |c| e.is_a?(c) }
599
712
 
600
713
  if count < CAL_HTTP_RETRY_COUNT-1
601
714
  if e.is_a?(HTTPClient::TimeoutError)