calabash-cucumber 0.14.3 → 0.15.0

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: 3e2dcaa1398aadb061fce6ced92b4b390665c467
4
- data.tar.gz: 9d51395fc82748addee27a52ba0ca18a911f40d5
3
+ metadata.gz: 1162678765d96a589e12bdf06d092d2f0eba972a
4
+ data.tar.gz: 4c68a868778d5fac3f875a2c709c1329e4330791
5
5
  SHA512:
6
- metadata.gz: 45dd5313852539ff2a58c7d280626ff186050348a3363c9db74126094a42c773cccd1a81eb98bc0d22a7850ae5b63d6b393e34babd4bb8259f27fd7c21d43b54
7
- data.tar.gz: f9e63acb09345a0972e74c0e319e22964f292e0349a62076e481546a04981ed199e4a2f55c9425e37fcf86db42013a77f44163b6094eb42dcd1e9e6b1ffcff2b
6
+ metadata.gz: da411ca25785cad3d76cbc52745708a9af974d1aed3d9d855e0231afb6d21486ec71a9ff9f980bf25c2bdad61742d244695c9f799e763f42f12328c3f82a8335
7
+ data.tar.gz: 0cca1e98616a717243bb4727e64ce41a2befaecc9f6fc6b54f5421723ff696c53435b42e986daa43a72bb55387f177058233119af367b80989d43cb62ac55c56
Binary file
@@ -5,7 +5,7 @@
5
5
  # When running calabash-ios tests at #
6
6
  # www.xamarin.com/test-cloud #
7
7
  # the methods invoked by #
8
- # CalabashLauncher are overriden. #
8
+ # CalabashLauncher are overridden. #
9
9
  # It will automatically ensure #
10
10
  # running on device, installing apps #
11
11
  # etc. #
@@ -336,12 +336,27 @@ module Calabash
336
336
  # @option options {Hash} :offset (nil) optional offset to touch point. Offset supports an `:x` and `:y` key
337
337
  # and causes the touch to be offset with `(x,y)` relative to the center (`center + (offset[:x], offset[:y])`).
338
338
  # @option options {String} :query (nil) if specified, the swipe will be made relative to this query.
339
+ # @option options [Symbol] :force (nil) Indicates the force of the swipe.
340
+ # Valid values are :strong, :normal, :light.
341
+ #
339
342
  # @return {Array<Hash>,String} array containing the serialized version of the touched view if `options[:query]` is given.
340
343
  def swipe(dir, options={})
344
+ merged_options = options.dup
345
+
346
+ # I don't understand why the :status_bar_orientation value is being overwritten
341
347
  unless uia_available?
342
- options = options.merge(:status_bar_orientation => status_bar_orientation)
348
+ merged_options[:status_bar_orientation] = status_bar_orientation
349
+ end
350
+
351
+ force = merged_options[:force]
352
+ if force
353
+ unless [:light, :strong, :normal].include?(force)
354
+ raise ArgumentError,
355
+ "Expected :force option '#{force}' to be :light, :strong, or :normal"
356
+ end
343
357
  end
344
- launcher.actions.swipe(dir.to_sym, options)
358
+
359
+ launcher.actions.swipe(dir.to_sym, merged_options)
345
360
  end
346
361
 
347
362
 
@@ -393,9 +408,17 @@ module Calabash
393
408
  # @note this is implemented by calling the Obj-C `setContentOffset:animated:` method and can do things users cant.
394
409
  #
395
410
  # @param {String} uiquery query describing view scroll (should be UIScrollView or a web view).
411
+ # @param [Symbol] direction The direction to scroll. Valid directions are:
412
+ # :up, :down, :left, and :right
396
413
  def scroll(uiquery, direction)
397
- views_touched=map(uiquery, :scroll, direction)
398
- msg = "could not find view to scroll: '#{uiquery}', args: #{direction}"
414
+ allowed_directions = [:up, :down, :left, :right]
415
+ dir_symbol = direction.to_sym
416
+ unless allowed_directions.include?(dir_symbol)
417
+ raise ArgumentError, "Expected '#{direction} to be one of #{allowed_directions}"
418
+ end
419
+
420
+ views_touched=map(uiquery, :scroll, dir_symbol)
421
+ msg = "could not find view to scroll: '#{uiquery}', args: #{dir_symbol}"
399
422
  assert_map_results(views_touched, msg)
400
423
  views_touched
401
424
  end
@@ -790,18 +813,33 @@ module Calabash
790
813
  # backdoor("calabashBackdoor:", '')
791
814
  # @example
792
815
  # backdoor("calabashBackdoor:", {example:'param'})
793
- # @param {String} sel the selector to perform on the app delegate
794
- # @param {Object} arg the argument to pass to the selector
816
+ # @param {String} selector the selector to perform on the app delegate
817
+ # @param {Object} argument the argument to pass to the selector
795
818
  # @return {Object} the result of performing the selector with the argument (serialized)
796
- def backdoor(sel, arg)
819
+ def backdoor(selector, argument)
820
+
821
+ unless selector.end_with?(':')
822
+ messages =
823
+ [
824
+ "Selector '#{selector}' is missing a trailing ':'",
825
+ 'Valid backdoor selectors must take one argument.',
826
+ "Before 0.15.0, the server will append a trailing ':'.",
827
+ ' After 0.15.0, this behavior is scheduled to change.',
828
+ '',
829
+ 'http://developer.xamarin.com/guides/testcloud/calabash/working-with/backdoors/#backdoor_in_iOS',
830
+ ''
831
+ ]
832
+ _deprecated('0.15.0', messages.join("\n"), :warn)
833
+ end
834
+
797
835
  json = {
798
- :selector => sel,
799
- :arg => arg
836
+ :selector => selector,
837
+ :arg => argument
800
838
  }
801
839
  res = http({:method => :post, :path => 'backdoor'}, json)
802
840
  res = JSON.parse(res)
803
841
  if res['outcome'] != 'SUCCESS'
804
- screenshot_and_raise "backdoor #{json} failed because: #{res['reason']}\n#{res['details']}"
842
+ screenshot_and_raise "backdoor #{json} failed because:\n\n#{res['reason']}\n#{res['details']}"
805
843
  end
806
844
  res['result']
807
845
  end
@@ -49,6 +49,9 @@ module Calabash
49
49
  :emulated_2x => '1X'}
50
50
  }
51
51
 
52
+ # accessibility key = fullscreen.zoom => 2x => Switch to full screen mode
53
+ # accessibility key = normal.zoom => 1x => Switch to normal mode
54
+
52
55
  # @!visibility private
53
56
  # @!attribute [r] scale
54
57
  # The current 1X or 2X scale represented as a Symbol.
@@ -242,4 +245,4 @@ module Calabash
242
245
 
243
246
  end
244
247
  end
245
- end
248
+ end
@@ -898,6 +898,24 @@ module Calabash
898
898
  end
899
899
  end
900
900
 
901
+ # Waits for a keyboard to appear and returns the localized name of the
902
+ # `key_code` signifier
903
+ #
904
+ # @param [String] key_code Maps to a specific name in some localization
905
+ def lookup_key_name(key_code)
906
+ wait_for_keyboard
907
+ begin
908
+ response_json = JSON.parse(http(:path => 'keyboard-language'))
909
+ rescue JSON::ParserError
910
+ raise RuntimeError, "Could not parse output of keyboard-language route. Did the app crash?"
911
+ end
912
+ if response_json['outcome'] != 'SUCCESS'
913
+ screenshot_and_raise "failed to retrieve the keyboard localization"
914
+ end
915
+ localized_lang = response_json['results']['input_mode']
916
+ RunLoop::L10N.new.lookup_localization_name(key_code, localized_lang)
917
+ end
918
+
901
919
  # @!visibility private
902
920
  # Returns the the text in the first responder.
903
921
  #
@@ -55,6 +55,7 @@ class Calabash::Cucumber::Launcher
55
55
  attr_accessor :actions
56
56
  attr_accessor :launch_args
57
57
  attr_accessor :simulator_launcher
58
+ attr_reader :xcode
58
59
 
59
60
  # @!visibility private
60
61
  # Generated when calabash cannot launch the app.
@@ -76,6 +77,10 @@ class Calabash::Cucumber::Launcher
76
77
  class CalabashLauncherTimeoutErr < Timeout::Error
77
78
  end
78
79
 
80
+ def xcode
81
+ @xcode ||= RunLoop::Xcode.new
82
+ end
83
+
79
84
  # @!visibility private
80
85
  def initialize
81
86
  @simulator_launcher = Calabash::Cucumber::SimulatorLauncher.new
@@ -274,7 +279,7 @@ class Calabash::Cucumber::Launcher
274
279
 
275
280
  sim_control = opts.fetch(:sim_control, RunLoop::SimControl.new)
276
281
  if sim_control.xcode_version_gte_6?
277
- default_sim = RunLoop::Core.default_simulator(sim_control.xctools)
282
+ default_sim = RunLoop::Core.default_simulator(xcode)
278
283
  name_or_udid = merged_opts[:udid] || ENV['DEVICE_TARGET'] || default_sim
279
284
 
280
285
  target_simulator = nil
@@ -487,7 +492,7 @@ class Calabash::Cucumber::Launcher
487
492
  return :instruments if major && major >= 7 # Only instruments supported for iOS7+
488
493
  return :sim_launcher if major # and then we have <= 6
489
494
 
490
- if RunLoop::XCTools.new.xcode_version_gte_51?
495
+ if RunLoop::Xcode.new.version_gte_51?
491
496
  return use_sim_launcher_env? ? :sim_launcher : :instruments
492
497
  end
493
498
 
@@ -535,11 +540,11 @@ class Calabash::Cucumber::Launcher
535
540
 
536
541
  # RunLoop::Core.run_with_options can reuse the SimControl instance. Many
537
542
  # of the Xcode tool calls, like instruments -s templates, take a long time
538
- # to execute. The SimControl instance has XCTool attribute which caches
539
- # the results of many of these time-consuming calls so they only need to
540
- # be called 1 time per launch.
543
+ # to execute.
541
544
  # @todo Use SimControl in Launcher in place of methods like simulator_target?
542
545
  args[:sim_control] = RunLoop::SimControl.new
546
+ args[:instruments] = RunLoop::Instruments.new
547
+ args[:xcode] = xcode
543
548
 
544
549
  if args[:app]
545
550
  if !File.exist?(args[:app])
@@ -624,7 +629,7 @@ class Calabash::Cucumber::Launcher
624
629
  if run_with_instruments?(args)
625
630
  # Patch for bug in Xcode 6 GM + iOS 8 device testing.
626
631
  # http://openradar.appspot.com/radar?id=5891145586442240
627
- uia_strategy = default_uia_strategy(args, args[:sim_control])
632
+ uia_strategy = default_uia_strategy(args, args[:sim_control], args[:instruments])
628
633
  args[:uia_strategy] ||= uia_strategy
629
634
  calabash_info "Using uia strategy: '#{args[:uia_strategy]}'" if debug_logging?
630
635
 
@@ -656,14 +661,18 @@ class Calabash::Cucumber::Launcher
656
661
  #
657
662
  # rdar://18296714
658
663
  # http://openradar.appspot.com/radar?id=5891145586442240
659
- def default_uia_strategy(launch_args, sim_control)
664
+ #
665
+ # @param [Hash] launch_args The launch arguments.
666
+ # @param [RunLoop::SimControl] sim_control Used to find simulators.
667
+ # @param [RunLoop::Instruments] instruments Used to find physical devices.
668
+ def default_uia_strategy(launch_args, sim_control, instruments)
660
669
  # Preferences strategy works on Xcode iOS Simulators.
661
670
  if RunLoop::Core.simulator_target?(launch_args, sim_control)
662
671
  :preferences
663
672
  else
664
673
  target_udid = launch_args[:device_target]
665
674
  target_device = nil
666
- devices_connected = sim_control.xctools.instruments(:devices)
675
+ devices_connected = instruments.physical_devices
667
676
  devices_connected.each do |device|
668
677
  if device.udid == target_udid
669
678
  target_device = device
@@ -787,6 +796,11 @@ class Calabash::Cucumber::Launcher
787
796
  begin
788
797
  connected = (ping_app == '200')
789
798
  break if connected
799
+ rescue StandardError => e
800
+ if full_console_logging?
801
+ puts "Could not connect. #{e.message}"
802
+ puts "Will retry ..."
803
+ end
790
804
  ensure
791
805
  sleep 1 unless connected
792
806
  end
@@ -6,32 +6,60 @@ module Calabash
6
6
  # @!visibility private
7
7
  module Map
8
8
 
9
- # returns an array of views matched by the `query` or the result of
9
+ # Returns an array of views matched by the `query` or the result of
10
10
  # performing the Objective-C sequence defined by the `method_name` and
11
- # `method_args` on all the views matched by the `query`
11
+ # `method_args` on all the views matched by the `query`.
12
12
  #
13
- # the query language is documented here: https://github.com/calabash/calabash-ios/wiki
13
+ # This is not a method that users should be calling directly.
14
14
  #
15
- # returns a JSON representation of each view that is matched
15
+ # The `method_name` is typically mapped to an LPOperation on the server.
16
+ # Some examples of LPOperations are:
16
17
  #
17
- # when the `method_name` is a calabash operation, returns an array that
18
- # contains the result of calling the objc selector `description` on each
19
- # matched view. these are examples of calabash operations: `:flash`,
20
- # `:scrollToRowWithMark`, `:changeDatePickerDate`.
18
+ # * :flash
19
+ # * :scrollToRowWithMark
20
+ # * :changeDatePickerDate
21
+ #
22
+ # If `method_name` maps to no LPOperation, then it is treated a selector
23
+ # and is performed on any view that matches `query`.
24
+ #
25
+ # @examples
26
+ #
27
+ # # Calls 'text' on any visible UITextField, because :text is not a defined operation.
28
+ # > map("textField", :text)
29
+ # => [ "old text" ]
30
+ #
31
+ # # Does not call 'setText:', because :setText is a defined operation.
32
+ # > map("textField", :setText, 'new text')
33
+ # => [ <UITextField ... > ]
34
+ #
35
+ # # Calls 'setText:', because 'setText:' is not a defined operation.
36
+ # > map("textField", 'setText:', 'newer text')
37
+ # => [ "<VOID>" ]
38
+ #
39
+ # # Will return [] because :unknownSelector is not defined on UITextField.
40
+ # > map("textField", :unknownSelector)
41
+ # => []
42
+ #
43
+ # # Will return [] because 'setAlpha' requires 1 argument and none was provided.
44
+ # # An error will be logged by the server in the device logs.
45
+ # > map("textField", 'setAlpha:')
46
+ # => []
47
+ #
48
+ #
49
+ # Well behaved LPOperations should return the view as JSON objects.
50
+ #
51
+ # @todo Calabash LPOperations should return 'views touched' in JSON format
21
52
  def map(query, method_name, *method_args)
22
- #todo calabash operations should return 'views touched' in JSON format
23
53
  raw_map(query, method_name, *method_args)['results']
24
54
  end
25
55
 
26
- # returns a JSON object the represents the result of performing an http
56
+ # Returns a JSON object the represents the result of performing an http
27
57
  # query against the calabash server.
28
58
  #
29
- # gem users should _not_ call this method directly; call `map` instead.
30
- #
31
- # raises an error and takes a screenshot if the value of the `outcome` key
59
+ # Raises an error and takes a screenshot if the value of the `outcome` key
32
60
  # is _not_ 'SUCCESS'
33
61
  #
34
- # the JSON object contains the following keys:
62
+ # The JSON object contains the following keys:
35
63
  #
36
64
  # `outcome` => indicates the success or failure of the query
37
65
  #
@@ -42,27 +70,7 @@ module Calabash
42
70
  # the `method_name` with arguments defined in
43
71
  # `method_args` on all views matched by the `query`
44
72
  #
45
- # the query language is documented here: https://github.com/calabash/calabash-ios/wiki
46
- #
47
- # here are some examples that clarify how the `method_name` and `method_args`
48
- # influence the value of the `results` key
49
- #
50
- # simple examples:
51
- #
52
- # raw_map('label')['result'] #=> [ all visible UILabels ]
53
- # raw_map('label', :text) #=> [ the 'text' of all visible UILabels ]
54
- #
55
- # example of calling a selector with arguments:
56
- #
57
- # <tt>raw_map("tableView marked:'cheeses'", {'numberOfRowsInSection' => 0})) =></tt>
58
- # <tt>[ the number of rows in the first section of the 'cheeses' table ]</tt>
59
- #
60
- # example of calling a selector on view to return an object and then calling
61
- # another selector on the returned object:
62
- #
63
- # <tt>raw_map("pickerView marked:'cheeses'", :delegate, [{pickerView:nil},{titleForRow:1},{forComponent:0}]) =></tt>
64
- # objc call: <tt>[[pickerView delegate] pickerView:nil titleForRow:1 forComponent:0] =></tt>
65
- # <tt>['French']</tt>
73
+ # @see Calabash::Cucumber::Map#map for examples.
66
74
  def raw_map(query, method_name, *method_args)
67
75
  operation_map = {
68
76
  :method_name => method_name,
@@ -87,7 +87,6 @@ module Calabash
87
87
  puts "try to rotate to '#{dir_sym}' using '#{candidate}'"
88
88
  end
89
89
  playback(candidate)
90
- # need a longer sleep for cloud testing
91
90
  sleep(0.4)
92
91
  recalibrate_after_rotation()
93
92
 
@@ -117,17 +116,10 @@ module Calabash
117
116
  # @example rotate right
118
117
  # rotate :right
119
118
  #
120
- # @example rotate down
121
- # rotate :down
119
+ # @param [Symbol] dir The direction to rotate. Can be :left or :right.
122
120
  #
123
- # @example rotate up
124
- # rotate :up
125
- #
126
- # @note For legacy support the `dir` argument can be a String or Symbol.
127
- # Please update your code to pass a Symbol.
128
- #
129
- # @param [Symbol] dir The position of the home button after the rotation.
130
- # Can be one of `{:down | :left | :right | :up }`.
121
+ # @return [Symbol] The position of the home button relative to the status
122
+ # bar after the rotation. Can be one of `{:down | :left | :right | :up }`.
131
123
  def rotate(dir)
132
124
  dir = dir.to_sym
133
125
  current_orientation = status_bar_orientation().to_sym
@@ -173,4 +165,4 @@ module Calabash
173
165
 
174
166
  end
175
167
  end
176
- end
168
+ end
@@ -92,7 +92,7 @@ module Calabash
92
92
  stack = Kernel.caller(0, 6)[1..-1].join("\n")
93
93
  end
94
94
 
95
- msg = "deprecated '#{version}' - '#{msg}'\n#{stack}"
95
+ msg = "deprecated '#{version}' - #{msg}\n#{stack}"
96
96
 
97
97
  if type.eql?(:pending)
98
98
  pending(msg)
@@ -3,10 +3,10 @@ module Calabash
3
3
 
4
4
  # @!visibility public
5
5
  # The Calabash iOS gem version.
6
- VERSION = '0.14.3'
6
+ VERSION = '0.15.0'
7
7
 
8
8
  # @!visibility public
9
9
  # The minimum required version of the Calabash embedded server.
10
- MIN_SERVER_VERSION = '0.14.3'
10
+ MIN_SERVER_VERSION = '0.15.0'
11
11
  end
12
12
  end
Binary file
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.14.3
4
+ version: 0.15.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karl Krukow
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-21 00:00:00.000000000 Z
11
+ date: 2015-09-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 0.0.1
33
+ version: 0.0.2
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 0.0.1
40
+ version: 0.0.2
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: edn
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -146,7 +146,7 @@ dependencies:
146
146
  requirements:
147
147
  - - ">="
148
148
  - !ruby/object:Gem::Version
149
- version: 1.3.3
149
+ version: 1.5.0
150
150
  - - "<"
151
151
  - !ruby/object:Gem::Version
152
152
  version: '2.0'
@@ -156,7 +156,7 @@ dependencies:
156
156
  requirements:
157
157
  - - ">="
158
158
  - !ruby/object:Gem::Version
159
- version: 1.3.3
159
+ version: 1.5.0
160
160
  - - "<"
161
161
  - !ruby/object:Gem::Version
162
162
  version: '2.0'
@@ -236,14 +236,14 @@ dependencies:
236
236
  requirements:
237
237
  - - ">="
238
238
  - !ruby/object:Gem::Version
239
- version: '0'
239
+ version: 1.1.0
240
240
  type: :development
241
241
  prerelease: false
242
242
  version_requirements: !ruby/object:Gem::Requirement
243
243
  requirements:
244
244
  - - ">="
245
245
  - !ruby/object:Gem::Version
246
- version: '0'
246
+ version: 1.1.0
247
247
  - !ruby/object:Gem::Dependency
248
248
  name: rake
249
249
  requirement: !ruby/object:Gem::Requirement
@@ -551,7 +551,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
551
551
  version: '0'
552
552
  requirements: []
553
553
  rubyforge_project:
554
- rubygems_version: 2.4.5
554
+ rubygems_version: 2.4.8
555
555
  signing_key:
556
556
  specification_version: 4
557
557
  summary: Client for calabash-ios-server for automated functional testing on iOS