calabash-cucumber 0.9.169.pre5 → 0.9.169.pre6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5720c3a1025782b5d07f6b2283414c8b2e0986a0
4
- data.tar.gz: 556933f7a91bcb3a05539d9048daf2360e550512
3
+ metadata.gz: 35ea078d42c9b70dfbdd979ea489e9f10b28d928
4
+ data.tar.gz: 075d9e64b5f26ff76fa490291c7f877609d199fd
5
5
  SHA512:
6
- metadata.gz: bd03a7ed163acfa246b53da1a8ee41a181e968f9e6f5d0594bbeba4480a1901be7939392b04f6088a69f3536ec7f4dc9ec12199339873eeeedd1eb207fbe2e99
7
- data.tar.gz: 21367d4e5a072e303f70bb26b75c254906df900c80f4af75d8c76b08780d72e673f1983320ca6f6f98a571ce57311afe851e4d12547ff5ae6344c98606f922ec
6
+ metadata.gz: 3594493a413ac63b8d0dc459d792638495161b2331b456b2420bcf4b5ac63ed64b4186f4489b2de351ddb3d2a5dc825716f469f8f0646ea090ba57ecb5627e59
7
+ data.tar.gz: 17d36a67d16b288a5fbc56abe0612ba0090097b950ab254640e3ba7e3b54764a56b6400ed2d8150cae8b107bfa4048a642244562abd61e28e5b40e9e86e0e209
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency('json')
22
22
  s.add_dependency('edn')
23
23
  s.add_dependency('CFPropertyList')
24
- s.add_dependency('sim_launcher', '~> 0.4.9')
24
+ s.add_dependency('sim_launcher', '~> 0.4.10')
25
25
  s.add_dependency('slowhandcuke')
26
26
  s.add_dependency('geocoder', '~>1.1.8')
27
27
  s.add_dependency('httpclient', '~> 2.3.3')
@@ -4,13 +4,11 @@
4
4
  # #
5
5
  # When running calabash-ios tests at #
6
6
  # www.xamarin.com/test-cloud #
7
- # this file will be overwritten by #
8
- # a file which automates #
9
- # app launch on devices. #
10
- # #
11
- # Don't rely on this file being #
12
- # present when running at #
13
- # Xamarin Test Cloud #
7
+ # the methods invoked by #
8
+ # CalabashLauncher are overriden. #
9
+ # It will automatically ensure #
10
+ # running on device, installing apps #
11
+ # etc. #
14
12
  # #
15
13
  ########################################
16
14
 
@@ -13,6 +13,10 @@ class Calabash::Cucumber::InstrumentsActions
13
13
  query_action(options, :uia_tap_offset)
14
14
  end
15
15
 
16
+ def wait_tap(options)
17
+ uia_wait_tap(options[:query], options)
18
+ end
19
+
16
20
  def double_tap(options)
17
21
  query_action(options, :uia_double_tap_offset)
18
22
  end
@@ -13,6 +13,10 @@ class Calabash::Cucumber::PlaybackActions
13
13
  playback('touch', options)
14
14
  end
15
15
 
16
+ def wait_tap(options)
17
+ touch(options)
18
+ end
19
+
16
20
  def double_tap(options)
17
21
  playback('double_tap', options)
18
22
  end
@@ -46,6 +46,10 @@ module Calabash
46
46
  map(uiquery, :query, *args)
47
47
  end
48
48
 
49
+ def q(uiquery, *args)
50
+ query(uiquery, *args)
51
+ end
52
+
49
53
  # causes all views matched by the +query+ to briefly change colors making
50
54
  # them visually identifiable.
51
55
  #
@@ -81,6 +85,16 @@ module Calabash
81
85
  query_action_with_options(:touch, uiquery, options)
82
86
  end
83
87
 
88
+ def wait_tap(uiquery, options={})
89
+ _uiquery, options = extract_query_and_options(uiquery, options)
90
+ launcher.actions.wait_tap(options)
91
+ end
92
+
93
+ def t(uiquery, options={})
94
+ wait_tap(uiquery, options)
95
+ end
96
+
97
+
84
98
  def double_tap(uiquery, options={})
85
99
  query_action_with_options(:double_tap, uiquery, options)
86
100
  end
@@ -232,23 +232,25 @@ class Calabash::Cucumber::Launcher
232
232
  :launch_retries => 5
233
233
  }
234
234
 
235
- #:device_target will be set
235
+ device_tgt = ENV['DEVICE_TARGET']
236
+ if run_with_instruments?(args)
237
+ if simulator_target?
238
+ args[:device_target] = device_tgt
239
+ args[:udid] = nil
240
+ else
241
+ if detect_connected_device? && (device_tgt.nil? || device_tgt.downcase == 'device')
242
+ device_tgt = RunLoop::Core.detect_connected_device
243
+ end
236
244
 
237
- if run_with_instruments?(args) && !simulator_target?
238
- device_tgt = ENV['DEVICE_TARGET']
239
- if detect_connected_device? && (device_tgt.nil? || device_tgt.downcase == 'device')
240
- device_tgt = RunLoop::Core.detect_connected_device
245
+ if device_tgt
246
+ args[:device_target] = args[:udid] = device_tgt
247
+ end
241
248
  end
249
+ end
242
250
 
243
- if device_tgt
244
- args[:device_target] = args[:udid] = device_tgt
245
- else
246
- args[:device_target] = 'simulator'
247
- end
248
- else
251
+ if args[:device_target].nil?
249
252
  args[:device_target] = 'simulator'
250
253
  end
251
-
252
254
  args
253
255
  end
254
256
 
@@ -309,14 +311,14 @@ class Calabash::Cucumber::Launcher
309
311
  args[:app] = File.expand_path(args[:app])
310
312
  else
311
313
  # args[:app] is not a directory so must be a bundle id
312
- if args[:device_target] == 'simulator' ## bundle id set, but simulator target
314
+ if simulator_target?(args) ## bundle id set, but simulator target
313
315
  args[:app] = app_path || detect_app_bundle_from_args(args)
314
316
  end
315
317
  end
316
318
  end
317
319
 
318
320
  unless args[:app]
319
- if args[:device_target]=='simulator'
321
+ if simulator_target?(args)
320
322
  device_xamarin_build_dir = 'iPhoneSimulator'
321
323
  else
322
324
  device_xamarin_build_dir = 'iPhone'
@@ -333,7 +335,7 @@ class Calabash::Cucumber::Launcher
333
335
 
334
336
 
335
337
  if args[:privacy_settings]
336
- if args[:device_target]=='simulator'
338
+ if simulator_target?(args)
337
339
  update_privacy_settings(args[:bundle_id], args[:privacy_settings])
338
340
  else
339
341
  #Not supported on device
@@ -383,7 +385,7 @@ class Calabash::Cucumber::Launcher
383
385
 
384
386
  # todo this method should be migrated to the Simulator Launcher
385
387
  def detect_app_bundle_from_args(args)
386
- if args[:device_target]=='simulator'
388
+ if simulator_target?(args)
387
389
  device_xamarin_build_dir = 'iPhoneSimulator'
388
390
  else
389
391
  device_xamarin_build_dir = 'iPhone'
@@ -63,7 +63,17 @@ module Calabash
63
63
  touch("view marked:'#{label}'", *args)
64
64
  end
65
65
 
66
- def tap(label, *args)
66
+ def tap(hash_or_string, *args)
67
+ if hash_or_string.is_a?(String)
68
+ tap_mark(hash_or_string, *args)
69
+ elsif hash_or_string.respond_to?(:[])
70
+ wait_tap(hash_or_string[:query], hash_or_string)
71
+ else
72
+ raise(ArgumentError, "first parameter to tap must be a string or a hash. Was: #{hash_or_string.class}, #{hash_or_string}")
73
+ end
74
+ end
75
+
76
+ def tap_mark(label, *args)
67
77
  simple_touch(label, *args)
68
78
  end
69
79
 
@@ -19,6 +19,15 @@ module Calabash
19
19
  res['results'].first
20
20
  end
21
21
 
22
+ def uia_wait_tap(query, options={})
23
+ res = http({:method => :post, :path => 'uia-tap'}, {:query => query}.merge(options))
24
+ res = JSON.parse(res)
25
+ if res['outcome'] != 'SUCCESS'
26
+ raise "uia-tap action failed because: #{res['reason']}\n#{res['details']}"
27
+ end
28
+ res['results'].first
29
+ end
30
+
22
31
  def uia_query(*queryparts)
23
32
  #TODO escape '\n etc in query
24
33
  uia_handle_command(:query, queryparts)
@@ -1,6 +1,7 @@
1
1
  require 'calabash-cucumber/utils/xctools'
2
2
  require 'calabash-cucumber/utils/plist_buddy'
3
3
  require 'sim_launcher'
4
+ require 'cfpropertylist'
4
5
 
5
6
  module Calabash
6
7
  module Cucumber
@@ -48,7 +49,7 @@ module Calabash
48
49
  quit_simulator
49
50
  sim_lib_path = File.join(simulator_app_support_dir(), 'Library')
50
51
  FileUtils.rm_rf(sim_lib_path)
51
- simulator_support_sdk_dirs.each do |dir|
52
+ existing_simulator_support_sdk_dirs.each do |dir|
52
53
  FileUtils.rm_rf(dir)
53
54
  end
54
55
 
@@ -63,7 +64,7 @@ module Calabash
63
64
  counter = 0
64
65
  loop do
65
66
  break if counter == 80
66
- dirs = simulator_support_sdk_dirs
67
+ dirs = existing_simulator_support_sdk_dirs
67
68
  if dirs.count == 0
68
69
  sleep(0.2)
69
70
  else
@@ -88,13 +89,21 @@ module Calabash
88
89
  # ~/Library/Application Support/iPhone Simulator/Library/7.0.3-64
89
90
  # ~/Library/Application Support/iPhone Simulator/Library/7.1
90
91
  #
92
+ # a simulator is 'possible' if the SDK is available in the Xcode version.
93
+ #
94
+ # this method merges (uniquely) the possible and existing SDKs.
95
+ #
91
96
  # this method also hides the AXInspector.
97
+ #
92
98
  # @param [Hash] opts controls the behavior of the method
93
99
  # @option opts [Boolean] :verbose controls logging output
94
100
  # @return [Boolean] true iff enabling accessibility worked on all sdk
95
101
  # directories
96
102
  def enable_accessibility_on_simulators(opts={})
97
- results = simulator_support_sdk_dirs.map do |dir|
103
+ possible = possible_simulator_support_sdk_dirs
104
+ existing = existing_simulator_support_sdk_dirs
105
+ dirs = (possible + existing).uniq
106
+ results = dirs.map do |dir|
98
107
  enable_accessibility_in_sdk_dir(dir, opts)
99
108
  end
100
109
  results.all? { |elm| elm }
@@ -107,13 +116,14 @@ module Calabash
107
116
  #
108
117
  # WARNING: this will quit the simulator
109
118
  #
110
- # path = '~/Library/Application Support/iPhone Simulator/Library/6.1'
119
+ # path = '/6.1'
111
120
  # enable_accessibility_in_sdk_dir(path)
112
121
  #
113
122
  # this method also hides the AXInspector.
114
123
  #
115
- # if the Library/Preferences/com.apple.Accessibility.plist does not exist,
116
- # this method returns false.
124
+ # if the Library/Preferences/com.apple.Accessibility.plist does not exist
125
+ # this method will create a Library/Preferences/com.apple.Accessibility.plist
126
+ # that (oddly) the Simulator will _not_ overwrite.
117
127
  #
118
128
  # @see enable_accessibility_on_simulators for the public API.
119
129
  #
@@ -128,72 +138,47 @@ module Calabash
128
138
  default_opts = {:verbose => false}
129
139
  merged = default_opts.merge(opts)
130
140
 
131
- plist_path = File.expand_path("#{sim_app_support_sdk_dir}/Library/Preferences/com.apple.Accessibility.plist")
141
+ quit_simulator
132
142
 
133
143
  verbose = merged[:verbose]
134
-
135
144
  sdk = File.basename(sim_app_support_sdk_dir)
136
145
  msgs = ["cannot enable accessibility for #{sdk} SDK"]
137
- unless File.exists?(plist_path)
138
- if verbose
139
- msgs << "expected plist to exist at #{plist_path}"
140
- calabash_warn(msgs.join("\n"))
141
- end
142
- return false
143
- end
144
146
 
145
- quit_simulator
147
+ plist_path = File.expand_path("#{sim_app_support_sdk_dir}/Library/Preferences/com.apple.Accessibility.plist")
146
148
 
147
149
  hash = accessibility_properties_hash()
148
150
 
149
- unless plist_set(hash[:access_enabled], 'bool', 'true', plist_path)
150
- if verbose
151
- msgs << "could not set '#{hash[:access_enabled]}' to YES"
152
- calabash_warn(msgs.join("\n"))
151
+ if File.exist?(plist_path)
152
+ res = hash.map do |hash_key, settings|
153
+ success = plist_set(settings[:key], settings[:type], settings[:value], plist_path)
154
+ unless success
155
+ if verbose
156
+ if settings[:type] == 'bool'
157
+ value = settings[:value] ? 'YES' : 'NO'
158
+ else
159
+ value = settings[:value]
160
+ end
161
+ msgs << "could not set #{hash_key} => '#{settings[:key]}' to #{value}"
162
+ calabash_warn(msgs.join("\n"))
163
+ end
164
+ end
165
+ success
153
166
  end
154
- return false
167
+ res.all? { |elm| elm }
168
+ else
169
+ FileUtils.mkdir_p("#{sim_app_support_sdk_dir}/Library/Preferences")
170
+ plist = CFPropertyList::List.new
171
+ data = {}
172
+ # CFPropertyList gem is super wonky
173
+ # it matches Boolean to a string type with 'true/false' values
174
+ # - stick with PlistBuddy
175
+ # hash.each do |_, settings|
176
+ # data[settings[:key]] = settings[:value]
177
+ # end
178
+ plist.value = CFPropertyList.guess(data)
179
+ plist.save(plist_path, CFPropertyList::List::FORMAT_BINARY)
180
+ enable_accessibility_in_sdk_dir(sim_app_support_sdk_dir)
155
181
  end
156
-
157
- unless plist_set(hash[:app_access_enabled], 'bool', 'true', plist_path)
158
- if verbose
159
- msgs << "could not set '#{hash[:app_access_enabled]}' to YES"
160
- calabash_warn(msgs.join("\n"))
161
- end
162
- return false
163
- end
164
-
165
- unless plist_set(hash[:automation_enabled], 'bool', 'true', plist_path)
166
- if verbose
167
- msgs << "could not set '#{hash[:automation_enabled]}' to YES"
168
- calabash_warn(msgs.join("\n"))
169
- end
170
- return false
171
- end
172
-
173
- unless plist_set(hash[:inspector_showing], 'bool', 'false', plist_path)
174
- if verbose
175
- msgs << "could not set '#{hash[:inspector_showing]}' to NO"
176
- calabash_warn(msgs.join("\n"))
177
- end
178
- return false
179
- end
180
-
181
- unless plist_set(hash[:inspector_full_size], 'bool', 'false', plist_path)
182
- if verbose
183
- msgs << "could not set '#{hash[:inspector_full_size]}' to NO"
184
- calabash_warn(msgs.join("\n"))
185
- end
186
- return false
187
- end
188
-
189
- res = plist_set(hash[:inspector_frame], 'string', '{{270, -13}, {276, 166}}', plist_path)
190
- unless res
191
- if verbose
192
- msgs << "could not set '#{hash[:inspector_frame]}'"
193
- calabash_warn(msgs.join("\n"))
194
- end
195
- end
196
- res
197
182
  end
198
183
 
199
184
 
@@ -204,29 +189,50 @@ module Calabash
204
189
  def accessibility_properties_hash
205
190
  {
206
191
  # this is required
207
- :access_enabled => 'AccessibilityEnabled',
192
+ :access_enabled => {:key => 'AccessibilityEnabled',
193
+ :value => 'true',
194
+ :type => 'bool'},
208
195
  # i _think_ this is legacy
209
- :app_access_enabled => 'ApplicationAccessibilityEnabled',
196
+ :app_access_enabled => {:key => 'ApplicationAccessibilityEnabled',
197
+ :value => 'true',
198
+ :type => 'bool'},
210
199
 
211
200
  # i don't know what this does
212
- :automation_enabled => 'AutomationEnabled',
201
+ :automation_enabled => {:key => 'AutomationEnabled',
202
+ :value => 'true',
203
+ :type => 'bool'},
213
204
 
214
205
  # determines if the Accessibility Inspector is showing
215
- :inspector_showing => 'AXInspectorEnabled',
206
+ :inspector_showing => {:key => 'AXInspectorEnabled',
207
+ :value => 'false',
208
+ :type => 'bool'},
209
+
216
210
  # controls if the Accessibility Inspector is expanded or not expanded
217
- :inspector_full_size => 'AXInspector.enabled',
211
+ :inspector_full_size => {:key => 'AXInspector.enabled',
212
+ :value => 'false',
213
+ :type => 'bool'},
214
+
218
215
  # controls the frame of the Accessibility Inspector
219
216
  # this is a 'string' => {{0, 0}, {276, 166}}
220
- :inspector_frame => 'AXInspector.frame'
217
+ :inspector_frame => {:key => 'AXInspector.frame',
218
+ :value => '{{270, -13}, {276, 166}}',
219
+ :type => 'string'}
221
220
  }
222
221
  end
223
222
 
224
- # the absolute path the the iPhone Simulator Application Support directory
223
+ # the absolute path to the iPhone Simulator Application Support directory
225
224
  # @return [String] absolute path
226
225
  def simulator_app_support_dir
227
226
  File.expand_path('~/Library/Application Support/iPhone Simulator')
228
227
  end
229
228
 
229
+ # the absolute path to the SDK's com.apple.Accessibility.plist file
230
+ # @param [String] sdk_dir base path the SDK directory
231
+ # @return [String] an absolute path
232
+ def plist_path_with_sdk_dir(sdk_dir)
233
+ File.expand_path("#{sdk_dir}/Library/Preferences/com.apple.Accessibility.plist")
234
+ end
235
+
230
236
  # returns a list of absolute paths the existing simulator directories.
231
237
  #
232
238
  # a simulator 'exists' if has an Application Support directory. for
@@ -238,13 +244,63 @@ module Calabash
238
244
  # ~/Library/Application Support/iPhone Simulator/Library/7.1
239
245
  #
240
246
  # @return[Array<String>] a list of absolute paths to simulator directories
241
- def simulator_support_sdk_dirs
247
+ def existing_simulator_support_sdk_dirs
242
248
  sim_app_support_path = simulator_app_support_dir()
243
249
  Dir.glob("#{sim_app_support_path}/*").select { |path|
244
250
  path =~ /(\d)\.(\d)\.?(\d)?(-64)?/
245
251
  }
246
252
  end
247
253
 
254
+ # returns a list of possible SDKs per Xcode version
255
+ #
256
+ # it is not enough to ask for the available sdks because of the new 64-bit
257
+ # variants that started to appear Xcode 5 and the potential for patch level
258
+ # versions.
259
+ #
260
+ # unfortunately, this method will need be maintained per Xcode version.
261
+ #
262
+ # @return [Array<String>] ex. ['6.1', '7.1', '7.0.3', '7.0.3-64']
263
+ def possible_simulator_sdks
264
+ sdk_detector = SimLauncher::SdkDetector.new
265
+ available = sdk_detector.available_sdk_versions
266
+ instruments_version = instruments(:version)
267
+
268
+ # in Xcode 5.1* SDK 7.0 ==> 7.0.3
269
+ if (instruments_version == '5.1' or instruments_version == '5.1.1') and available.include?('7.0')
270
+ available << '7.0.3'
271
+ available << '7.0.3-64'
272
+ end
273
+
274
+ if instruments_version == '5.1.1' and available.include?('7.1')
275
+ available << '7.1'
276
+ available << '7.1-64'
277
+ end
278
+
279
+ gem_compat_xcode_versions = ['5.1', '5.1.1']
280
+ unless gem_compat_xcode_versions.include?(instruments_version)
281
+ msg = ["expected Xcode instruments version to be '5.1' or '5.1.1'",
282
+ "but found version '#{instruments_version}'",
283
+ "Gem needs a manual update for Xcode #{instruments_version}!"].join("\n")
284
+ calabash_warn(msg)
285
+ end
286
+
287
+ # in Xcode 5.1* SDK 7.0 ==> 7.0.3 so we should not include '7.0'
288
+ # if the user's support directory already contains a 7.0 and 7.0-64 dir
289
+ # we will detect it by reading from disk.
290
+ (available - ['7.0']).uniq.sort
291
+ end
292
+
293
+ # return absolute paths to possible simulator support sdk dirs
294
+ #
295
+ # these directories may or may not exist
296
+ # @return [Array<String>] an array of absolute paths
297
+ def possible_simulator_support_sdk_dirs
298
+ base_dir = simulator_app_support_dir
299
+ possible_simulator_sdks.map { |sdk|
300
+ "#{base_dir}/#{sdk}"
301
+ }
302
+ end
303
+
248
304
  end
249
305
  end
250
306
  end