calabash-cucumber 0.9.163.pre11 → 0.9.163

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: a3a488993902bfbb00390bc250e3c1bd67863115
4
- data.tar.gz: 838d8084acb6139715dbf5f8597cd6255f603f8e
3
+ metadata.gz: 8e46355e0ae02bee56543532987c7b907f58398e
4
+ data.tar.gz: 10e5addcfae303f65b9abfbfa65609cd075b1bd8
5
5
  SHA512:
6
- metadata.gz: ca26a0000569e4729514796fa4273178096df47e647d2fcba6688bc429d3a8d1d21d4da144881a3431e38a2b59cf8f5d12ce91bd5e17fbfe2cb7242ed41d39a7
7
- data.tar.gz: 39743981fa30de194e00ef53a538d561a0bba9025102fafc139253c8c64a4e47de539c457febe6481d95113b6420099d8e5747a2126c7e1c38e0a8b2ec70a899
6
+ metadata.gz: 879217db665a6c5b6279abed8e3ae98ddd8e2654ad8b28b67953375401a9ba808f17e53b6e6ff03cf23e89522ec7d4afc5d522e8ab97fe565a2a8a534f824cdb
7
+ data.tar.gz: 98c78b78a519fe5529616faeab0334b936198503f889ba1b1b81942cd5ec971883b4f9a2d202efabcfe08ac6ad539248f8298f0513f23b013250a1d5d6c5e6c7
@@ -239,8 +239,8 @@ def validate_ipa(ipa)
239
239
  end
240
240
 
241
241
  app_dir = Dir.foreach("#{dir}/Payload").find {|d| /\.app$/.match(d)}
242
- app = app_dir.split(".")[0]
243
- res = `otool "#{File.expand_path(dir)}/Payload/#{app_dir}/#{app}" -o 2> /dev/null | grep CalabashServer`
242
+
243
+ res = `otool "#{File.expand_path(dir)}/Payload/#{app_dir}/"* -o 2> /dev/null | grep CalabashServer`
244
244
  msg("Info") do
245
245
  if /CalabashServer/.match(res)
246
246
  puts "Ipa: #{ipa} *contains* calabash.framework"
@@ -26,8 +26,8 @@ Gem::Specification.new do |s|
26
26
  s.add_dependency( "geocoder", "~>1.1.8")
27
27
  s.add_dependency( "httpclient","~> 2.3.3")
28
28
  s.add_dependency( "bundler", "~> 1.1")
29
- s.add_dependency( "run_loop", "~> 0.1.0.pre8" )
29
+ s.add_dependency( "run_loop", "~> 0.1.0" )
30
30
  s.add_dependency( "awesome_print")
31
- s.add_dependency( "xamarin-test-cloud", "~> 0.9.25")
31
+ s.add_dependency( "xamarin-test-cloud", "~> 0.9.27")
32
32
 
33
33
  end
@@ -98,14 +98,14 @@ end
98
98
 
99
99
  Then /^I enter "([^\"]*)" into the "([^\"]*)" field$/ do |text_to_type, field_name|
100
100
  touch("textField marked:'#{field_name}'")
101
- await_keyboard
101
+ wait_for_keyboard()
102
102
  keyboard_enter_text text_to_type
103
103
  sleep(STEP_PAUSE)
104
104
  end
105
105
 
106
106
  Then /^I enter "([^\"]*)" into the "([^\"]*)" (?:text|input) field$/ do |text_to_type, field_name|
107
107
  touch("textField marked:'#{field_name}'")
108
- await_keyboard
108
+ wait_for_keyboard()
109
109
  keyboard_enter_text text_to_type
110
110
  sleep(STEP_PAUSE)
111
111
  end
@@ -117,7 +117,7 @@ end
117
117
 
118
118
  Then /^I use the native keyboard to enter "([^\"]*)" into the "([^\"]*)" (?:text|input) field$/ do |text_to_type, field_name|
119
119
  macro %Q|I touch the "#{field_name}" text field|
120
- await_keyboard()
120
+ wait_for_keyboard()
121
121
  keyboard_enter_text(text_to_type)
122
122
  sleep(STEP_PAUSE)
123
123
  end
@@ -132,7 +132,7 @@ Then /^I enter "([^\"]*)" into (?:input|text) field number (\d+)$/ do |text, ind
132
132
  index = index.to_i
133
133
  screenshot_and_raise "Index should be positive (was: #{index})" if (index<=0)
134
134
  touch("textField index:#{index-1}")
135
- await_keyboard()
135
+ wait_for_keyboard()
136
136
  keyboard_enter_text text
137
137
  sleep(STEP_PAUSE)
138
138
  end
@@ -140,17 +140,14 @@ end
140
140
  Then /^I use the native keyboard to enter "([^\"]*)" into (?:input|text) field number (\d+)$/ do |text_to_type, index|
141
141
  idx = index.to_i
142
142
  macro %Q|I touch text field number #{idx}|
143
- await_keyboard()
143
+ wait_for_keyboard()
144
144
  keyboard_enter_text(text_to_type)
145
145
  sleep(STEP_PAUSE)
146
146
  end
147
147
 
148
148
  When /^I clear "([^\"]*)"$/ do |name|
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
149
+ msg = "When I clear <name>' will be deprecated because it is ambiguous - what should be cleared?"
150
+ _deprecated('0.9.151', msg, :warn)
154
151
  clear_text("textField marked:'#{name}'")
155
152
  end
156
153
 
@@ -4,5 +4,4 @@ require 'calabash-cucumber/keyboard_helpers'
4
4
  require 'calabash-cucumber/wait_helpers'
5
5
  require 'calabash-cucumber/operations'
6
6
  require 'calabash-cucumber/version'
7
- require 'calabash-cucumber/uia'
8
- require 'calabash-cucumber/date_picker.rb'
7
+ require 'calabash-cucumber/date_picker'
@@ -1,10 +1,11 @@
1
1
  require 'httpclient'
2
2
  require 'json'
3
3
  require 'geocoder'
4
+ require 'calabash-cucumber/uia'
5
+ require 'calabash-cucumber/environment_helpers'
4
6
  require 'calabash-cucumber/connection'
5
7
  require 'calabash-cucumber/connection_helpers'
6
8
  require 'calabash-cucumber/launch/simulator_helper'
7
- require 'calabash-cucumber/uia'
8
9
  require 'calabash-cucumber/query_helpers'
9
10
  require 'calabash-cucumber/playback_helpers'
10
11
  require 'calabash-cucumber/failure_helpers'
@@ -15,6 +16,7 @@ require 'calabash-cucumber/map'
15
16
  module Calabash
16
17
  module Cucumber
17
18
  module Core
19
+ include Calabash::Cucumber::EnvironmentHelpers
18
20
  include Calabash::Cucumber::ConnectionHelpers
19
21
  include Calabash::Cucumber::QueryHelpers
20
22
  include Calabash::Cucumber::FailureHelpers
@@ -50,10 +52,10 @@ module Calabash
50
52
  end
51
53
 
52
54
  def query_all(uiquery, *args)
53
- unless ENV['CALABASH_NO_DEPRECATION'] == '1'
54
- puts "query_all is deprecated. Use the new all/visible feature."
55
- puts "see: https://github.com/calabash/calabash-ios/wiki/05-Query-syntax"
56
- end
55
+ msg0 = "use the 'all' or 'visible' query language feature"
56
+ msg1 = 'see: https://github.com/calabash/calabash-ios/wiki/05-Query-syntax'
57
+ msg = "#{msg0}\n#{msg1}"
58
+ _deprecated('0.9.133', msg, :warn)
57
59
  map("all #{uiquery}", :query, *args)
58
60
  end
59
61
 
@@ -84,7 +86,7 @@ module Calabash
84
86
  end
85
87
 
86
88
  def swipe(dir, options={})
87
- unless uia?
89
+ unless uia_available?
88
90
  options = options.merge(:status_bar_orientation => status_bar_orientation)
89
91
  end
90
92
  launcher.actions.swipe(dir.to_sym, options)
@@ -100,8 +102,8 @@ module Calabash
100
102
 
101
103
 
102
104
  def cell_swipe(options={})
103
- if uia?
104
- raise "cell_swipe not supported with instruments, simply use swipe with a query that matches the cell"
105
+ if uia_available?
106
+ raise 'cell_swipe not supported with instruments, simply use swipe with a query that matches the cell'
105
107
  end
106
108
  playback('cell_swipe', options)
107
109
  end
@@ -114,36 +116,36 @@ module Calabash
114
116
 
115
117
  def scroll_to_row(uiquery, number)
116
118
  views_touched=map(uiquery, :scrollToRow, number)
117
- if views_touched.empty? or views_touched.member? "<VOID>"
119
+ if views_touched.empty? or views_touched.member? '<VOID>'
118
120
  screenshot_and_raise "Unable to scroll: '#{uiquery}' to: #{number}"
119
121
  end
120
122
  views_touched
121
123
  end
122
124
 
123
- def scroll_to_cell(options={:query => "tableView",
125
+ def scroll_to_cell(options={:query => 'tableView',
124
126
  :row => 0,
125
127
  :section => 0,
126
128
  :scroll_position => :top,
127
129
  :animate => true})
128
- uiquery = options[:query] || "tableView"
130
+ uiquery = options[:query] || 'tableView'
129
131
  row = options[:row]
130
132
  sec = options[:section]
131
133
  if row.nil? or sec.nil?
132
- raise "You must supply both :row and :section keys to scroll_to_cell"
134
+ raise 'You must supply both :row and :section keys to scroll_to_cell'
133
135
  end
134
136
 
135
137
  args = []
136
138
  if options.has_key?(:scroll_position)
137
139
  args << options[:scroll_position]
138
140
  else
139
- args << "top"
141
+ args << 'top'
140
142
  end
141
143
  if options.has_key?(:animate)
142
144
  args << options[:animate]
143
145
  end
144
146
  views_touched=map(uiquery, :scrollToRow, row.to_i, sec.to_i, *args)
145
147
 
146
- if views_touched.empty? or views_touched.member? "<VOID>"
148
+ if views_touched.empty? or views_touched.member? '<VOID>'
147
149
  screenshot_and_raise "Unable to scroll: '#{uiquery}' to: #{options}"
148
150
  end
149
151
  views_touched
@@ -179,7 +181,7 @@ module Calabash
179
181
  end
180
182
 
181
183
  def set_location(options)
182
- if uia?
184
+ if uia_available?
183
185
  uia_set_location(options)
184
186
  else
185
187
  if options[:place]
@@ -216,14 +218,14 @@ module Calabash
216
218
  end
217
219
 
218
220
  def move_wheel(opts={})
219
- q = opts[:query] || "pickerView"
221
+ q = opts[:query] || 'pickerView'
220
222
  wheel = opts[:wheel] || 0
221
223
  dir = opts[:dir] || :down
222
224
 
223
- raise "Wheel index must be non negative" if wheel < 0
225
+ raise 'Wheel index must be non negative' if wheel < 0
224
226
  raise "Only up and down supported :dir (#{dir})" unless [:up, :down].include?(dir)
225
227
 
226
- if ENV['OS'] == "ios4"
228
+ if ENV['OS'] == 'ios4'
227
229
  playback "wheel_#{dir}", :query => "#{q} pickerTable index:#{wheel}"
228
230
  elsif ios7?
229
231
  raise NotImplementedError
@@ -233,8 +235,8 @@ module Calabash
233
235
 
234
236
  end
235
237
 
236
- def picker(opts={:query => "pickerView", :action => :texts})
237
- raise "Not implemented" unless opts[:action] == :texts
238
+ def picker(opts={:query => 'pickerView', :action => :texts})
239
+ raise 'Not implemented' unless opts[:action] == :texts
238
240
 
239
241
  q = opts[:query]
240
242
 
@@ -269,8 +271,8 @@ module Calabash
269
271
 
270
272
  def backdoor(sel, arg)
271
273
  json = {
272
- :selector => sel,
273
- :arg => arg
274
+ :selector => sel,
275
+ :arg => arg
274
276
  }
275
277
  res = http({:method => :post, :path => 'backdoor'}, json)
276
278
  res = JSON.parse(res)
@@ -310,21 +312,15 @@ module Calabash
310
312
  stop_test_server
311
313
  end
312
314
 
313
- def default_device
314
- l = Calabash::Cucumber::Launcher.launcher_if_used
315
- l && l.device
316
- end
317
-
318
- def uia?
319
- Calabash::Cucumber::Launcher.instruments?
320
- end
321
315
 
322
316
  def console_attach
323
- launcher.attach
317
+ # setting the @calabash_launcher here for backward compatibility
318
+ @calabash_launcher = launcher.attach
324
319
  end
325
320
 
326
321
  def launcher
327
- Calabash::Cucumber::Launcher.launcher
322
+ # setting the @calabash_launcher here for backward compatibility
323
+ @calabash_launcher = Calabash::Cucumber::Launcher.launcher
328
324
  end
329
325
 
330
326
  def query_action_with_options(action, uiquery, options)
@@ -343,12 +339,12 @@ module Calabash
343
339
 
344
340
  def prepare_query_options(uiquery, options)
345
341
  opts = options.dup
346
- if (uiquery.is_a?(Array))
342
+ if uiquery.is_a?(Array)
347
343
  raise 'No elements in array' if uiquery.empty?
348
344
  uiquery = uiquery.first
349
345
  end #this is deliberately not elsif (uiquery.first could be a hash)
350
346
 
351
- if (uiquery.is_a?(Hash))
347
+ if uiquery.is_a?(Hash)
352
348
  opts[:offset] = point_from(uiquery, options)
353
349
  uiquery = nil
354
350
  end
@@ -359,3 +355,4 @@ module Calabash
359
355
  end
360
356
  end
361
357
  end
358
+
@@ -2,10 +2,8 @@ require 'json'
2
2
 
3
3
  module Calabash
4
4
  module Cucumber
5
- # Class device encapsulates information about the device or devices
6
- # we are interacting with during a test.
7
- # Credit: Due to jmoody's briar: https://github.com/jmoody/briar/blob/master/lib/briar/gestalt.rb
8
-
5
+ # Class device encapsulates information about the device or devices we are
6
+ # interacting with during a test.
9
7
  class Device
10
8
 
11
9
  GESTALT_IPHONE = 'iPhone'
@@ -14,12 +12,12 @@ module Calabash
14
12
  GESTALT_SIM_SYS = 'x86_64'
15
13
  GESTALT_IPOD = 'iPod'
16
14
 
17
-
18
15
  attr_reader :endpoint
19
16
  attr_reader :device_family
20
17
  attr_reader :simulator_details, :ios_version
21
18
  attr_reader :system
22
19
  attr_reader :framework_version
20
+ attr_reader :iphone_app_emulated_on_ipad
23
21
 
24
22
  attr_accessor :udid
25
23
 
@@ -31,6 +29,7 @@ module Calabash
31
29
  @simulator_details = version_data['simulator']
32
30
  @ios_version = version_data['iOS_version']
33
31
  @framework_version = version_data['version']
32
+ @iphone_app_emulated_on_ipad = version_data['iphone_app_emulated_on_ipad']
34
33
  end
35
34
 
36
35
  def simulator?
@@ -89,6 +88,10 @@ module Calabash
89
88
  return { :width => 320, :height => 568 } if iphone_5?
90
89
  { :width => 320, :height => 480 }
91
90
  end
91
+
92
+ def iphone_app_emulated_on_ipad?
93
+ iphone_app_emulated_on_ipad
94
+ end
92
95
  end
93
96
  end
94
97
  end
@@ -0,0 +1,205 @@
1
+ require 'calabash-cucumber/device'
2
+ require 'calabash-cucumber/launcher'
3
+
4
+ module Calabash
5
+ module Cucumber
6
+ module EnvironmentHelpers
7
+
8
+
9
+ # returns +true+ if UIAutomation functions are available
10
+ #
11
+ # UIAutomation is only available if the app has been launched with
12
+ # Instruments
13
+ def uia_available?
14
+ Calabash::Cucumber::Launcher.instruments?
15
+ end
16
+
17
+ # returns +true+ if UIAutomation functions are not available
18
+ #
19
+ # UIAutomation is only available if the app has been launched with
20
+ # Instruments
21
+ def uia_not_available?
22
+ not uia_available?
23
+ end
24
+
25
+ # returns +true+ if cucumber is running in the test cloud
26
+ def xamarin_test_cloud?
27
+ ENV['XAMARIN_TEST_CLOUD'] == '1'
28
+ end
29
+
30
+ # returns the default Device
31
+ def default_device
32
+ l = Calabash::Cucumber::Launcher.launcher_if_used
33
+ l && l.device
34
+ end
35
+
36
+ # returns +true+ if the target device is an ipad
37
+ #
38
+ # raises an error if the server cannot be reached
39
+ def ipad?
40
+ _default_device_or_create().ipad?
41
+ end
42
+
43
+ # returns +true+ if the target device is an iphone
44
+ #
45
+ # raises an error if the server cannot be reached
46
+ def iphone?
47
+ _default_device_or_create().iphone?
48
+ end
49
+
50
+ # returns +true+ if the target device is an ipod
51
+ #
52
+ # raises an error if the server cannot be reached
53
+ def ipod?
54
+ _default_device_or_create().ipod?
55
+ end
56
+
57
+ # returns +true+ if the target device is an iphone or ipod
58
+ #
59
+ # raises an error if the server cannot be reached
60
+ def device_family_iphone?
61
+ iphone? or ipod?
62
+ end
63
+
64
+ # returns +true+ if the target device is a simulator (not a physical device)
65
+ #
66
+ # raises an error if the server cannot be reached
67
+ def simulator?
68
+ _default_device_or_create().simulator?
69
+ end
70
+
71
+ # returns +true+ if the target device or simulator is a 4in model
72
+ #
73
+ # raises an error if the server cannot be reached
74
+ def iphone_5?
75
+ _default_device_or_create().iphone_5?
76
+ end
77
+
78
+ # returns +true+ if the target device or simulator is a 4in model
79
+ #
80
+ # raises an error if the server cannot be reached
81
+ def iphone_4in?
82
+ iphone_5?
83
+ end
84
+
85
+ # returns +true+ if the OS major version is 5
86
+ #
87
+ # raises an error if the server cannot be reached
88
+ #
89
+ # WARNING: setting the +OS+ env variable will override the value returned
90
+ # by querying the device
91
+ def ios5?
92
+ _OS_ENV.eql?(_canonical_os_version(:ios5)) || _default_device_or_create().ios5?
93
+ end
94
+
95
+ # returns +true+ if the OS major version is 6
96
+ #
97
+ # raises an error if the server cannot be reached
98
+ #
99
+ # WARNING: setting the +OS+ env variable will override the value returned
100
+ # by querying the device
101
+ def ios6?
102
+ _OS_ENV.eql?(_canonical_os_version(:ios6)) || _default_device_or_create().ios6?
103
+ end
104
+
105
+
106
+ # returns +true+ if the OS major version is 7
107
+ #
108
+ # raises an error if the server cannot be reached
109
+ #
110
+ # WARNING: setting the +OS+ env variable will override the value returned
111
+ # by querying the device
112
+ def ios7?
113
+ _OS_ENV.eql?(_canonical_os_version(:ios7)) || _default_device_or_create().ios7?
114
+ end
115
+
116
+ # returns +true+ if the app is an iphone app emulated on an ipad
117
+ #
118
+ # raises an error if the server cannot be reached
119
+ def iphone_app_emulated_on_ipad?
120
+ _default_device_or_create().iphone_app_emulated_on_ipad?
121
+ end
122
+
123
+ # returns +true+ if the <tt>CALABASH_NO_DEPRECATION</tt> variable is set
124
+ # to +1+
125
+ def no_deprecation_warnings?
126
+ ENV['CALABASH_NO_DEPRECATION'] == '1'
127
+ end
128
+
129
+ # returns +true+ if the <tt>CALABASH_FULL_CONSOLE_OUTPUT</tt> is set to
130
+ # +1+
131
+ def full_console_logging?
132
+ ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1'
133
+ end
134
+
135
+ # returns +true+ if the <tt>DEBUG</tt> is set to +1+
136
+ def debug_logging?
137
+ ENV['DEBUG'] == '1'
138
+ end
139
+
140
+
141
+
142
+ # prints a deprecated message that includes the line number
143
+ # +version+ string indicating when the feature was deprecated
144
+ # +msg+ deprecation message (possibly suggesting alternatives)
145
+ # +type+ <tt>{ :warn | :pending }</tt> - <tt>:pending</tt> will raise a
146
+ # cucumber pending exception
147
+ #
148
+ # if ENV['CALABASH_NO_DEPRECATION'] == '1' then this method is a nop
149
+ def _deprecated(version, msg, type)
150
+ allowed = [:pending, :warn]
151
+ unless allowed.include?(type)
152
+ screenshot_and_raise "type '#{type}' must be on of '#{allowed}'"
153
+ end
154
+
155
+ unless no_deprecation_warnings?
156
+
157
+ stack = Kernel.caller(0, 6)[1..-1].join("\n")
158
+ msg = "deprecated '#{version}' - '#{msg}'\n#{stack}"
159
+
160
+ if type.eql?(:pending)
161
+ pending(msg)
162
+ else
163
+ # todo deprecated function does not output on a new line when called within cucumber
164
+ begin
165
+ warn "\033[34m\nWARN: #{msg}\033[0m"
166
+ rescue
167
+ warn "\nWARN: #{msg}"
168
+ end
169
+ end
170
+ end
171
+ end
172
+
173
+ private
174
+ # returns the device that is currently being tested against
175
+ #
176
+ # returns the +device+ attr of <tt>Calabash::Cucumber::Launcher</tt> if
177
+ # it is defined. otherwise, creates a new <tt>Calabash::Cucumber::Device</tt>
178
+ # by querying the server.
179
+ #
180
+ # raises an error if the server cannot be reached
181
+ def _default_device_or_create
182
+ device = default_device
183
+ if device.nil?
184
+ device = Calabash::Cucumber::Device.new(nil, server_version())
185
+ end
186
+ device
187
+ end
188
+
189
+ # returns the value of the environmental variable +OS+
190
+ def _OS_ENV
191
+ ENV['OS']
192
+ end
193
+
194
+ CANONICAL_IOS_VERSIONS = {:ios5 => 'ios5',
195
+ :ios6 => 'ios6',
196
+ :ios7 => 'ios7'}
197
+
198
+
199
+ # returns the canonical value iOS versions as strings
200
+ def _canonical_os_version(key)
201
+ CANONICAL_IOS_VERSIONS[key]
202
+ end
203
+ end
204
+ end
205
+ end