calabash-cucumber 0.9.158 → 0.9.159
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/Rakefile +10 -1
- data/features/step_definitions/calabash_steps.rb +47 -3
- data/lib/calabash-cucumber.rb +1 -0
- data/lib/calabash-cucumber/core.rb +63 -40
- data/lib/calabash-cucumber/date_picker.rb +154 -0
- data/lib/calabash-cucumber/device.rb +6 -0
- data/lib/calabash-cucumber/ios7_operations.rb +25 -4
- data/lib/calabash-cucumber/launch/simulator_helper.rb +13 -3
- data/lib/calabash-cucumber/launcher.rb +5 -1
- data/lib/calabash-cucumber/operations.rb +2 -50
- data/lib/calabash-cucumber/version.rb +2 -2
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 0911cf9d43bcfd754b972803519be5c636556be3
|
|
4
|
+
data.tar.gz: 303e1511ed046dfd7c89b5459dfb84da5f7ba1bb
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: ab28b2a1116c354200796982f84435f7a9493eb2de4b93b0d6d7b5fd5530968e70ba2648d59cb50127cdec3ef7aa45044fd9cd6adbccd13b025d9a7a29fac113
|
|
7
|
+
data.tar.gz: 42d1037e8fb4016e7a1b8d3a9d24ffe01f2f99f28fb3bc77460a5b2ed75220caf687dd68256e285ea701c6a56c0c91be3a42e0ba38d8faebae2767d0d32ae8ba
|
data/Rakefile
CHANGED
|
@@ -22,18 +22,27 @@ EOF
|
|
|
22
22
|
end
|
|
23
23
|
|
|
24
24
|
FileUtils.cd(dir) do
|
|
25
|
+
|
|
26
|
+
pwd = FileUtils.pwd
|
|
27
|
+
cmd = "#{pwd}/calabash/gitversioning-before.sh #{pwd}/calabash/LPGitVersionDefines.h"
|
|
28
|
+
puts cmd
|
|
29
|
+
`#{cmd}`
|
|
30
|
+
|
|
25
31
|
puts 'Building Server'
|
|
26
32
|
cmd = 'xcodebuild build -project calabash.xcodeproj -target Framework -configuration Debug -sdk iphonesimulator7.0'
|
|
27
33
|
puts cmd
|
|
28
34
|
puts `#{cmd}`
|
|
29
35
|
|
|
36
|
+
cmd = "#{pwd}/calabash/gitversioning-after.sh #{pwd}/calabash/LPGitVersionDefines.h"
|
|
37
|
+
puts cmd
|
|
38
|
+
`#{cmd}`
|
|
39
|
+
|
|
30
40
|
unless File.exist?(FRAMEWORK)
|
|
31
41
|
raise 'Unable to build framework'
|
|
32
42
|
end
|
|
33
43
|
|
|
34
44
|
puts "Zipping down framework"
|
|
35
45
|
|
|
36
|
-
|
|
37
46
|
zip_cmd = "zip -q -r #{ZIP_FILE} #{FRAMEWORK}"
|
|
38
47
|
puts zip_cmd
|
|
39
48
|
puts `#{zip_cmd}`
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
|
|
1
2
|
WAIT_TIMEOUT = (ENV['WAIT_TIMEOUT'] || 30).to_f
|
|
2
3
|
STEP_PAUSE = (ENV['STEP_PAUSE'] || 0.5).to_f
|
|
3
4
|
|
|
@@ -182,10 +183,14 @@ Then /^I wait for the "([^\"]*)" button to appear$/ do |name|
|
|
|
182
183
|
wait_for(WAIT_TIMEOUT) { element_exists( "button marked:'#{name}'" ) }
|
|
183
184
|
end
|
|
184
185
|
|
|
185
|
-
|
|
186
186
|
Then /^I wait to see a navigation bar titled "([^\"]*)"$/ do |expected_mark|
|
|
187
|
-
|
|
188
|
-
|
|
187
|
+
msg = "waited for '#{WAIT_TIMEOUT}' seconds but did not see the navbar with title '#{expected_mark}'"
|
|
188
|
+
wait_for(:timeout => WAIT_TIMEOUT,
|
|
189
|
+
:timeout_message => msg ) do
|
|
190
|
+
all_items = query("navigationItemView marked:'#{expected_mark}'")
|
|
191
|
+
button_items = query("navigationItemButtonView")
|
|
192
|
+
non_button_items = all_items.delete_if { |item| button_items.include?(item) }
|
|
193
|
+
!non_button_items.empty?
|
|
189
194
|
end
|
|
190
195
|
end
|
|
191
196
|
|
|
@@ -426,3 +431,42 @@ end
|
|
|
426
431
|
Then /^I should see (?:the)? user location$/ do
|
|
427
432
|
check_element_exists("view:'MKUserLocationView'")
|
|
428
433
|
end
|
|
434
|
+
|
|
435
|
+
### Date Picker ###
|
|
436
|
+
|
|
437
|
+
# time_str can be in any format that Time can parse
|
|
438
|
+
Then(/^I change the date picker time to "([^"]*)"$/) do |time_str|
|
|
439
|
+
target_time = Time.parse(time_str)
|
|
440
|
+
current_date = date_time_from_picker()
|
|
441
|
+
current_date = DateTime.new(current_date.year,
|
|
442
|
+
current_date.mon,
|
|
443
|
+
current_date.day,
|
|
444
|
+
target_time.hour,
|
|
445
|
+
target_time.min,
|
|
446
|
+
0,
|
|
447
|
+
target_time.gmt_offset)
|
|
448
|
+
picker_set_date_time current_date
|
|
449
|
+
sleep(STEP_PAUSE)
|
|
450
|
+
end
|
|
451
|
+
|
|
452
|
+
# date_str can be in any format that Date can parse
|
|
453
|
+
Then(/^I change the date picker date to "([^"]*)"$/) do |date_str|
|
|
454
|
+
target_date = Date.parse(date_str)
|
|
455
|
+
current_time = date_time_from_picker()
|
|
456
|
+
date_time = DateTime.new(target_date.year,
|
|
457
|
+
target_date.mon,
|
|
458
|
+
target_date.day,
|
|
459
|
+
current_time.hour,
|
|
460
|
+
current_time.min,
|
|
461
|
+
0,
|
|
462
|
+
Time.now.sec,
|
|
463
|
+
current_time.offset)
|
|
464
|
+
picker_set_date_time date_time
|
|
465
|
+
sleep(STEP_PAUSE)
|
|
466
|
+
end
|
|
467
|
+
|
|
468
|
+
# date_str can be in any format that Date can parse
|
|
469
|
+
Then(/^I change the date picker date to "([^"]*)" at "([^"]*)"$/) do |date_str, time_str|
|
|
470
|
+
macro %Q|I change the date picker time to "#{time_str}"|
|
|
471
|
+
macro %Q|I change the date picker date to "#{date_str}"|
|
|
472
|
+
end
|
data/lib/calabash-cucumber.rb
CHANGED
|
@@ -260,22 +260,32 @@ module Calabash
|
|
|
260
260
|
# is in left and right landscape orientations
|
|
261
261
|
def rotate_home_button_to(dir)
|
|
262
262
|
dir = dir.to_s
|
|
263
|
-
|
|
263
|
+
# *** UNEXPECTED ***
|
|
264
|
+
# do not call device_orientation function here because it does a number
|
|
265
|
+
# of checks that will lead to inconsistent and confusing warnings
|
|
266
|
+
# ******************
|
|
267
|
+
res = map(nil, :orientation, :device).first
|
|
264
268
|
return res if res.eql? dir
|
|
265
269
|
rotation_candidates.each { |candidate|
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
270
|
+
if ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1'
|
|
271
|
+
puts "try to rotate to '#{dir}' using '#{candidate}'"
|
|
272
|
+
end
|
|
269
273
|
playback(candidate)
|
|
270
274
|
# need a longer sleep for cloud testing
|
|
271
275
|
sleep(0.5)
|
|
272
|
-
res = device_orientation
|
|
273
276
|
|
|
274
|
-
|
|
275
|
-
#
|
|
277
|
+
# *** UNEXPECTED ***
|
|
278
|
+
# do not call device_orientation function here because it does a number
|
|
279
|
+
# of checks that will lead to inconsistent and confusing warnings
|
|
280
|
+
# ******************
|
|
281
|
+
res = map(nil, :orientation, :device).first
|
|
282
|
+
|
|
283
|
+
# *** UNEXPECTED ***
|
|
284
|
+
# the device orientation changes when rotation playback is performed
|
|
276
285
|
# _regardless_ of whether or not the rotation succeeded
|
|
277
286
|
#
|
|
278
287
|
# this is an attempt to sync to the device and status bar orientation
|
|
288
|
+
# ******************
|
|
279
289
|
if res.eql? dir
|
|
280
290
|
status_bar = status_bar_orientation
|
|
281
291
|
if status_bar.eql? res
|
|
@@ -285,7 +295,6 @@ module Calabash
|
|
|
285
295
|
end
|
|
286
296
|
end
|
|
287
297
|
|
|
288
|
-
# return res if res.eql? dir
|
|
289
298
|
}
|
|
290
299
|
if ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1'
|
|
291
300
|
puts "Could not rotate device. Is rotation enabled in app? Will return 'down'"
|
|
@@ -295,6 +304,23 @@ module Calabash
|
|
|
295
304
|
|
|
296
305
|
def device_orientation(force_down=false)
|
|
297
306
|
res = map(nil, :orientation, :device).first
|
|
307
|
+
|
|
308
|
+
if ['face up', 'face down'].include?(res)
|
|
309
|
+
if ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1'
|
|
310
|
+
if force_down
|
|
311
|
+
puts "WARN found orientation '#{res}' - will rotate to force orientation to 'down'"
|
|
312
|
+
else
|
|
313
|
+
puts "WARN found orientation '#{res}'"
|
|
314
|
+
puts ' if you did not expect this, you have two options:'
|
|
315
|
+
puts ' 1. position your device in the upright position'
|
|
316
|
+
puts " 2. call device_orientation(true) to force a 'down' orientation"
|
|
317
|
+
end
|
|
318
|
+
end
|
|
319
|
+
|
|
320
|
+
return res if !force_down
|
|
321
|
+
return rotate_home_button_to :down
|
|
322
|
+
end
|
|
323
|
+
|
|
298
324
|
return res if !res.eql?('unknown')
|
|
299
325
|
return res if !force_down
|
|
300
326
|
rotate_home_button_to(:down)
|
|
@@ -305,40 +331,37 @@ module Calabash
|
|
|
305
331
|
end
|
|
306
332
|
|
|
307
333
|
def rotate(dir)
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
rotate_cmd = "right_home_up"
|
|
334
|
-
end
|
|
335
|
-
end
|
|
334
|
+
dir = dir.to_sym
|
|
335
|
+
current_orientation = device_orientation(true).to_sym
|
|
336
|
+
rotate_cmd = nil
|
|
337
|
+
case dir
|
|
338
|
+
when :left then
|
|
339
|
+
if current_orientation == :down
|
|
340
|
+
rotate_cmd = "left_home_down"
|
|
341
|
+
elsif current_orientation == :right
|
|
342
|
+
rotate_cmd = "left_home_right"
|
|
343
|
+
elsif current_orientation == :left
|
|
344
|
+
rotate_cmd = "left_home_left"
|
|
345
|
+
elsif current_orientation == :up
|
|
346
|
+
rotate_cmd = "left_home_up"
|
|
347
|
+
end
|
|
348
|
+
when :right then
|
|
349
|
+
if current_orientation == :down
|
|
350
|
+
rotate_cmd = "right_home_down"
|
|
351
|
+
elsif current_orientation == :left
|
|
352
|
+
rotate_cmd = "right_home_left"
|
|
353
|
+
elsif current_orientation == :right
|
|
354
|
+
rotate_cmd = "right_home_right"
|
|
355
|
+
elsif current_orientation == :up
|
|
356
|
+
rotate_cmd = "right_home_up"
|
|
357
|
+
end
|
|
358
|
+
end
|
|
336
359
|
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
screenshot_and_raise "Does not support rotating '#{dir}' when home button is pointing '#{current_orientation}'"
|
|
360
|
+
if rotate_cmd.nil?
|
|
361
|
+
if ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1'
|
|
362
|
+
puts "Could not rotate device in direction '#{dir}' with orientation '#{current_orientation} - will do nothing"
|
|
341
363
|
end
|
|
364
|
+
else
|
|
342
365
|
playback("rotate_#{rotate_cmd}")
|
|
343
366
|
end
|
|
344
367
|
end
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
require 'date'
|
|
2
|
+
|
|
3
|
+
module Calabash
|
|
4
|
+
module Cucumber
|
|
5
|
+
module DatePicker
|
|
6
|
+
include Calabash::Cucumber::Core
|
|
7
|
+
|
|
8
|
+
# equivalent formats for ruby and objc
|
|
9
|
+
# we convert DateTime object to a string
|
|
10
|
+
# and pass the format that objc can use
|
|
11
|
+
# to convert the string into NSDate
|
|
12
|
+
RUBY_DATE_AND_TIME_FMT = '%Y_%m_%d_%H_%M'
|
|
13
|
+
OBJC_DATE_AND_TIME_FMT = 'yyyy_MM_dd_HH_mm'
|
|
14
|
+
|
|
15
|
+
# picker modes
|
|
16
|
+
UI_DATE_PICKER_MODE_TIME = 0
|
|
17
|
+
UI_DATE_PICKER_MODE_DATE = 1
|
|
18
|
+
UI_DATE_PICKER_MODE_DATE_AND_TIME = 2
|
|
19
|
+
UI_DATE_PICKER_MODE_COUNT_DOWN_TIMER = 3
|
|
20
|
+
|
|
21
|
+
def date_picker_mode(picker_id=nil)
|
|
22
|
+
query_str = should_see_date_picker picker_id
|
|
23
|
+
res = query(query_str, :datePickerMode)
|
|
24
|
+
if res.empty?
|
|
25
|
+
screenshot_and_raise "should be able to get mode from picker with query '#{query_str}'"
|
|
26
|
+
end
|
|
27
|
+
res.first
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def time_mode?(picker_id=nil)
|
|
31
|
+
date_picker_mode(picker_id) == UI_DATE_PICKER_MODE_TIME
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def date_mode?(picker_id=nil)
|
|
35
|
+
date_picker_mode(picker_id) == UI_DATE_PICKER_MODE_DATE
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def date_and_time_mode?(picker_id=nil)
|
|
39
|
+
date_picker_mode(picker_id) == UI_DATE_PICKER_MODE_DATE_AND_TIME
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def countdown_mode?(picker_id=nil)
|
|
43
|
+
date_picker_mode(picker_id) == UI_DATE_PICKER_MODE_COUNT_DOWN_TIMER
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
# ensuring picker is visible
|
|
47
|
+
|
|
48
|
+
def query_string_for_picker (picker_id = nil)
|
|
49
|
+
picker_id.nil? ? 'datePicker' : "datePicker marked:'#{picker_id}'"
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
def should_see_date_picker (picker_id=nil)
|
|
53
|
+
query_str = query_string_for_picker picker_id
|
|
54
|
+
if query(query_str).empty?
|
|
55
|
+
screenshot_and_raise "should see picker with query '#{query_str}'"
|
|
56
|
+
end
|
|
57
|
+
query_str
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
|
|
61
|
+
# minimum and maximum dates
|
|
62
|
+
# appledoc ==> The property is an NSDate object or nil (the default),
|
|
63
|
+
# which means no maximum date.
|
|
64
|
+
def maximum_date_time_from_picker (picker_id = nil)
|
|
65
|
+
if countdown_mode? picker_id
|
|
66
|
+
screenshot_and_raise 'method is not available for pickers that are not in date or date time mode'
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
query_str = should_see_date_picker picker_id
|
|
70
|
+
res = query(query_str, :maximumDate)
|
|
71
|
+
if res.empty?
|
|
72
|
+
screenshot_and_raise "should be able to get max date from picker with query '#{query_str}'"
|
|
73
|
+
end
|
|
74
|
+
return nil if res.first.nil?
|
|
75
|
+
DateTime.parse(res.first)
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
# appledoc ==> The property is an NSDate object or nil (the default),
|
|
79
|
+
# which means no minimum date.
|
|
80
|
+
def minimum_date_time_from_picker (picker_id = nil)
|
|
81
|
+
if countdown_mode? picker_id
|
|
82
|
+
screenshot_and_raise 'method is not available for pickers that are not in date or date time mode'
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
query_str = should_see_date_picker picker_id
|
|
86
|
+
res = query(query_str, :minimumDate)
|
|
87
|
+
if res.empty?
|
|
88
|
+
screenshot_and_raise "should be able to get min date from picker with query '#{query_str}'"
|
|
89
|
+
end
|
|
90
|
+
return nil if res.first.nil?
|
|
91
|
+
DateTime.parse(res.first)
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
# date time from picker
|
|
95
|
+
def date_time_from_picker (picker_id=nil)
|
|
96
|
+
if countdown_mode? picker_id
|
|
97
|
+
screenshot_and_raise 'method is not available for pickers that are not in date or date time mode'
|
|
98
|
+
end
|
|
99
|
+
query_str = query_string_for_picker picker_id
|
|
100
|
+
res = query(query_str, :date)
|
|
101
|
+
if res.empty?
|
|
102
|
+
screenshot_and_raise "should be able to get date from picker with query '#{query_str}'"
|
|
103
|
+
end
|
|
104
|
+
DateTime.parse(res.first)
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
# changing picker date time
|
|
109
|
+
def args_for_change_date_on_picker(options)
|
|
110
|
+
args = []
|
|
111
|
+
if options.has_key?(:notify_targets)
|
|
112
|
+
args << options[:notify_targets] ? 1 : 0
|
|
113
|
+
else
|
|
114
|
+
args << 1
|
|
115
|
+
end
|
|
116
|
+
|
|
117
|
+
if options.has_key?(:animate)
|
|
118
|
+
args << options[:animate] ? 1 : 0
|
|
119
|
+
else
|
|
120
|
+
args << 1
|
|
121
|
+
end
|
|
122
|
+
args
|
|
123
|
+
end
|
|
124
|
+
|
|
125
|
+
# expects a DateTime object
|
|
126
|
+
# notify_targets = true iterates through the target/action pairs and
|
|
127
|
+
# calls performSelector:<action> object:<target> to simulate a UIEvent
|
|
128
|
+
def picker_set_date_time (target_dt, options = {:animate => true,
|
|
129
|
+
:picker_id => nil,
|
|
130
|
+
:notify_targets => true})
|
|
131
|
+
|
|
132
|
+
picker_id = options == nil ? nil : options[:picker_id]
|
|
133
|
+
|
|
134
|
+
if time_mode?(picker_id) == UI_DATE_PICKER_MODE_COUNT_DOWN_TIMER
|
|
135
|
+
pending('picker is in count down mode which is not yet supported')
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
target_str = target_dt.strftime(RUBY_DATE_AND_TIME_FMT).squeeze(' ').strip
|
|
139
|
+
fmt_str = OBJC_DATE_AND_TIME_FMT
|
|
140
|
+
|
|
141
|
+
args = args_for_change_date_on_picker options
|
|
142
|
+
query_str = query_string_for_picker picker_id
|
|
143
|
+
|
|
144
|
+
views_touched = map(query_str, :changeDatePickerDate, target_str, fmt_str, *args)
|
|
145
|
+
|
|
146
|
+
if views_touched.empty? or views_touched.member? '<VOID>'
|
|
147
|
+
screenshot_and_raise "could not change date on picker to '#{target_dt}' using query '#{query_str}' with options '#{options}'"
|
|
148
|
+
end
|
|
149
|
+
|
|
150
|
+
views_touched
|
|
151
|
+
end
|
|
152
|
+
end
|
|
153
|
+
end
|
|
154
|
+
end
|
|
@@ -83,6 +83,12 @@ module Calabash
|
|
|
83
83
|
def ios5?
|
|
84
84
|
ios_major_version.eql?('5')
|
|
85
85
|
end
|
|
86
|
+
|
|
87
|
+
def screen_size
|
|
88
|
+
return { :width => 768, :height => 1024 } if ipad?
|
|
89
|
+
return { :width => 320, :height => 568 } if iphone_5?
|
|
90
|
+
{ :width => 320, :height => 480 }
|
|
91
|
+
end
|
|
86
92
|
end
|
|
87
93
|
end
|
|
88
94
|
end
|
|
@@ -19,11 +19,36 @@ module Calabash
|
|
|
19
19
|
uia_tap_offset(offset)
|
|
20
20
|
else
|
|
21
21
|
el_to_touch = find_or_raise(ui_query)
|
|
22
|
+
rect = el_to_touch['rect']
|
|
23
|
+
normalize_rect_for_orientation(rect)
|
|
22
24
|
touch(el_to_touch, options)
|
|
23
25
|
[el_to_touch]
|
|
24
26
|
end
|
|
25
27
|
end
|
|
26
28
|
|
|
29
|
+
def normalize_rect_for_orientation(rect)
|
|
30
|
+
orientation = device_orientation().to_sym
|
|
31
|
+
launcher = Calabash::Cucumber::Launcher.launcher
|
|
32
|
+
screen_size = launcher.device.screen_size
|
|
33
|
+
case orientation
|
|
34
|
+
when :right
|
|
35
|
+
cx = rect['center_x']
|
|
36
|
+
rect['center_x'] = rect['center_y']
|
|
37
|
+
rect['center_y'] = screen_size[:width] - cx
|
|
38
|
+
when :left
|
|
39
|
+
cx = rect['center_x']
|
|
40
|
+
rect['center_x'] = screen_size[:height] - rect['center_y']
|
|
41
|
+
rect['center_y'] = cx
|
|
42
|
+
when :up
|
|
43
|
+
cy = rect['center_y']
|
|
44
|
+
cx = rect['center_x']
|
|
45
|
+
rect['center_y'] = screen_size[:height] - cy
|
|
46
|
+
rect['center_x'] = screen_size[:width] - cx
|
|
47
|
+
else
|
|
48
|
+
# no-op by design.
|
|
49
|
+
end
|
|
50
|
+
end
|
|
51
|
+
|
|
27
52
|
def swipe_ios7(options)
|
|
28
53
|
ui_query = options[:query]
|
|
29
54
|
offset = options[:offset]
|
|
@@ -58,10 +83,6 @@ module Calabash
|
|
|
58
83
|
[to_result]
|
|
59
84
|
end
|
|
60
85
|
|
|
61
|
-
def rotate_ios7(dir)
|
|
62
|
-
throw NotImplementedError
|
|
63
|
-
end
|
|
64
|
-
|
|
65
86
|
def find_or_raise(ui_query)
|
|
66
87
|
results = query(ui_query)
|
|
67
88
|
if results.empty?
|
|
@@ -208,13 +208,23 @@ module Calabash
|
|
|
208
208
|
# Detect case where there is no such sub directory
|
|
209
209
|
# (i.e. iOS only Xamarin project)
|
|
210
210
|
bin_dir = File.join(project_dir, 'bin')
|
|
211
|
-
if
|
|
212
|
-
(File.directory?(File.join(bin_dir,'iPhoneSimulator')) ||
|
|
213
|
-
File.directory?(File.join(bin_dir,'iPhone')))
|
|
211
|
+
if xamarin_ios_bin_dir?(bin_dir)
|
|
214
212
|
return project_dir ## Looks like iOS bin dir is here
|
|
215
213
|
end
|
|
216
214
|
|
|
215
|
+
sub_dirs = Dir[File.join(project_dir,'*')].select {|dir| File.directory?(dir)}
|
|
216
|
+
|
|
217
|
+
sub_dirs.find do |sub_dir|
|
|
218
|
+
contains_csproj = Dir[File.join(sub_dir,'*.csproj')].first
|
|
219
|
+
contains_csproj && xamarin_ios_bin_dir?(File.join(sub_dir,'bin'))
|
|
220
|
+
end
|
|
221
|
+
|
|
222
|
+
end
|
|
217
223
|
|
|
224
|
+
def self.xamarin_ios_bin_dir?(bin_dir)
|
|
225
|
+
File.directory?(bin_dir) &&
|
|
226
|
+
(File.directory?(File.join(bin_dir,'iPhoneSimulator')) ||
|
|
227
|
+
File.directory?(File.join(bin_dir,'iPhone')))
|
|
218
228
|
end
|
|
219
229
|
|
|
220
230
|
def self.bundle_path_from_xamarin_project(device_build_dir='iPhoneSimulator')
|
|
@@ -87,7 +87,7 @@ class Calabash::Cucumber::Launcher
|
|
|
87
87
|
|
|
88
88
|
if run_with_instruments?(args) && !simulator_target?
|
|
89
89
|
device_tgt = ENV['DEVICE_TARGET']
|
|
90
|
-
if device_tgt.nil? || device_tgt.downcase == 'device'
|
|
90
|
+
if detect_connected_device? && (device_tgt.nil? || device_tgt.downcase == 'device')
|
|
91
91
|
device_tgt = RunLoop::Core.detect_connected_device
|
|
92
92
|
end
|
|
93
93
|
|
|
@@ -104,6 +104,10 @@ class Calabash::Cucumber::Launcher
|
|
|
104
104
|
args
|
|
105
105
|
end
|
|
106
106
|
|
|
107
|
+
def detect_connected_device?
|
|
108
|
+
return ENV['DETECT_CONNECTED_DEVICE'] != '0'
|
|
109
|
+
end
|
|
110
|
+
|
|
107
111
|
def default_launch_method
|
|
108
112
|
return :instruments unless sdk_version || use_instruments_env?
|
|
109
113
|
return :instruments if sdk_version.start_with?('7') # Only instruments supported for iOS7+
|
|
@@ -9,6 +9,7 @@ require 'test/unit/assertions'
|
|
|
9
9
|
require 'json'
|
|
10
10
|
require 'set'
|
|
11
11
|
require 'calabash-cucumber/version'
|
|
12
|
+
require 'calabash-cucumber/date_picker'
|
|
12
13
|
|
|
13
14
|
|
|
14
15
|
if not Object.const_defined?(:CALABASH_COUNT)
|
|
@@ -26,8 +27,7 @@ module Calabash
|
|
|
26
27
|
include Calabash::Cucumber::WaitHelpers
|
|
27
28
|
include Calabash::Cucumber::KeyboardHelpers
|
|
28
29
|
include Calabash::Cucumber::Location
|
|
29
|
-
|
|
30
|
-
|
|
30
|
+
include Calabash::Cucumber::DatePicker
|
|
31
31
|
|
|
32
32
|
def page(clz,*args)
|
|
33
33
|
clz.new(self,*args)
|
|
@@ -51,7 +51,6 @@ module Calabash
|
|
|
51
51
|
str.gsub("'", "\\\\'")
|
|
52
52
|
end
|
|
53
53
|
|
|
54
|
-
|
|
55
54
|
def label(uiquery)
|
|
56
55
|
query(uiquery, :accessibilityLabel)
|
|
57
56
|
end
|
|
@@ -111,51 +110,6 @@ module Calabash
|
|
|
111
110
|
res['results'].first
|
|
112
111
|
end
|
|
113
112
|
|
|
114
|
-
# ha! i recognize this code - jjm
|
|
115
|
-
#not officially supported yet
|
|
116
|
-
#def change_slider_value_to(q, value)
|
|
117
|
-
# target = value.to_f
|
|
118
|
-
# if target < 0
|
|
119
|
-
# pending "value '#{value}' must be >= 0"
|
|
120
|
-
# end
|
|
121
|
-
# min_val = query(q, :minimumValue).first
|
|
122
|
-
# # will not work for min_val != 0
|
|
123
|
-
# if min_val != 0
|
|
124
|
-
# screenshot_and_raise "sliders with non-zero minimum values are not supported - slider '#{q}' has minimum value of '#{min_val}'"
|
|
125
|
-
# end
|
|
126
|
-
# max_val = query(q, :maximumValue).first
|
|
127
|
-
# if target > max_val
|
|
128
|
-
# screenshot_and_raise "cannot change slider '#{q}' to '#{value}' because the maximum allowed value is '#{max_val}'"
|
|
129
|
-
# end
|
|
130
|
-
#
|
|
131
|
-
# val = query(q, :value).first
|
|
132
|
-
# # the x offset is from the middle of the slider.
|
|
133
|
-
# # ex. slider from 0 to 5
|
|
134
|
-
# # to touch 3, x must be 0
|
|
135
|
-
# # to touch 0, x must be -2.5
|
|
136
|
-
# # to touch 5, x must be 2.5
|
|
137
|
-
# width = query(q, :frame).first["width"] - 10
|
|
138
|
-
#
|
|
139
|
-
# cur_x = -width/2.0 + val*width
|
|
140
|
-
# tgt_x = -width/2.0 + target*width
|
|
141
|
-
#
|
|
142
|
-
# interpolate("slide", :start =>q, :end => q,
|
|
143
|
-
# :offset_end => {:x => tgt_x, :y => 1},
|
|
144
|
-
# :offset_start => {:x => cur_x, :y => -1})
|
|
145
|
-
# sleep(0.1)
|
|
146
|
-
#
|
|
147
|
-
# val = query(q, :value).first
|
|
148
|
-
# cur_x = -width/2.0 + val*width
|
|
149
|
-
# tgt_x = -width/2.0 + target*width
|
|
150
|
-
#
|
|
151
|
-
# interpolate("slide", :start =>q, :end => q,
|
|
152
|
-
# :offset_end => {:x => tgt_x, :y => 1},
|
|
153
|
-
# :offset_start => {:x => cur_x, :y => -1})
|
|
154
|
-
#
|
|
155
|
-
#
|
|
156
|
-
#end
|
|
157
|
-
|
|
158
|
-
|
|
159
113
|
#def screencast_begin
|
|
160
114
|
# http({:method=>:post, :path=>'screencast'}, {:action => :start})
|
|
161
115
|
#end
|
|
@@ -167,8 +121,6 @@ module Calabash
|
|
|
167
121
|
# end
|
|
168
122
|
# file_name
|
|
169
123
|
#end
|
|
170
|
-
|
|
171
|
-
|
|
172
124
|
end
|
|
173
125
|
end
|
|
174
126
|
end
|
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.
|
|
4
|
+
version: 0.9.159
|
|
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-
|
|
11
|
+
date: 2013-10-04 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: cucumber
|
|
@@ -229,6 +229,7 @@ files:
|
|
|
229
229
|
- lib/calabash-cucumber/calabash_steps.rb
|
|
230
230
|
- lib/calabash-cucumber/core.rb
|
|
231
231
|
- lib/calabash-cucumber/cucumber.rb
|
|
232
|
+
- lib/calabash-cucumber/date_picker.rb
|
|
232
233
|
- lib/calabash-cucumber/device.rb
|
|
233
234
|
- lib/calabash-cucumber/ibase.rb
|
|
234
235
|
- lib/calabash-cucumber/ios7_operations.rb
|