calabash-cucumber 0.10.0.pre1 → 0.10.0.pre2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (184) hide show
  1. checksums.yaml +4 -4
  2. data/features/step_definitions/calabash_steps.rb +1 -1
  3. data/lib/calabash-cucumber/actions/instruments_actions.rb +15 -4
  4. data/lib/calabash-cucumber/actions/playback_actions.rb +12 -3
  5. data/lib/calabash-cucumber/connection.rb +3 -0
  6. data/lib/calabash-cucumber/connection_helpers.rb +4 -0
  7. data/lib/calabash-cucumber/core.rb +637 -83
  8. data/lib/calabash-cucumber/date_picker.rb +148 -29
  9. data/lib/calabash-cucumber/device.rb +160 -3
  10. data/lib/calabash-cucumber/environment_helpers.rb +91 -46
  11. data/lib/calabash-cucumber/failure_helpers.rb +40 -0
  12. data/lib/calabash-cucumber/http_helpers.rb +9 -2
  13. data/lib/calabash-cucumber/ibase.rb +136 -17
  14. data/lib/calabash-cucumber/ios7_operations.rb +13 -9
  15. data/lib/calabash-cucumber/ipad_1x_2x.rb +103 -48
  16. data/lib/calabash-cucumber/keyboard_helpers.rb +253 -144
  17. data/lib/calabash-cucumber/keychain_helpers.rb +46 -32
  18. data/lib/calabash-cucumber/launch/simulator_helper.rb +13 -12
  19. data/lib/calabash-cucumber/launch/simulator_launcher.rb +111 -78
  20. data/lib/calabash-cucumber/launcher.rb +265 -25
  21. data/lib/calabash-cucumber/map.rb +24 -22
  22. data/lib/calabash-cucumber/operations.rb +4 -160
  23. data/lib/calabash-cucumber/playback_helpers.rb +26 -0
  24. data/lib/calabash-cucumber/query_helpers.rb +12 -0
  25. data/lib/calabash-cucumber/rotation_helpers.rb +64 -8
  26. data/lib/calabash-cucumber/status_bar_helpers.rb +40 -3
  27. data/lib/calabash-cucumber/tests_helpers.rb +43 -14
  28. data/lib/calabash-cucumber/uia.rb +93 -9
  29. data/lib/calabash-cucumber/utils/logging.rb +30 -16
  30. data/lib/calabash-cucumber/utils/plist_buddy.rb +18 -19
  31. data/lib/calabash-cucumber/utils/simulator_accessibility.rb +41 -30
  32. data/lib/calabash-cucumber/utils/xctools.rb +31 -21
  33. data/lib/calabash-cucumber/version.rb +98 -2
  34. data/lib/calabash-cucumber/wait_helpers.rb +257 -77
  35. data/staticlib/calabash.framework.zip +0 -0
  36. metadata +64 -231
  37. data/.gitignore +0 -17
  38. data/CHANGES.txt +0 -1
  39. data/Gemfile +0 -4
  40. data/Rakefile +0 -72
  41. data/calabash-cucumber.gemspec +0 -36
  42. data/epl-v10.html +0 -261
  43. data/lib/calabash-cucumber/resources/cell_swipe_ios4_ipad.base64 +0 -51
  44. data/lib/calabash-cucumber/resources/cell_swipe_ios4_iphone.base64 +0 -51
  45. data/lib/calabash-cucumber/resources/cell_swipe_ios5_ipad.base64 +0 -74
  46. data/lib/calabash-cucumber/resources/cell_swipe_ios5_iphone.base64 +0 -74
  47. data/lib/calabash-cucumber/resources/double_tap_ios5_ipad.base64 +0 -15
  48. data/lib/calabash-cucumber/resources/double_tap_ios5_iphone.base64 +0 -15
  49. data/lib/calabash-cucumber/resources/double_tap_ios6_ipad.base64 +0 -22
  50. data/lib/calabash-cucumber/resources/double_tap_ios6_iphone.base64 +0 -22
  51. data/lib/calabash-cucumber/resources/pan_ios5_ipad.base64 +0 -199
  52. data/lib/calabash-cucumber/resources/pan_ios5_iphone.base64 +0 -199
  53. data/lib/calabash-cucumber/resources/pan_ios6_ipad.base64 +0 -206
  54. data/lib/calabash-cucumber/resources/pan_ios6_iphone.base64 +0 -206
  55. data/lib/calabash-cucumber/resources/pinch_in_ios4_ipad.base64 +0 -104
  56. data/lib/calabash-cucumber/resources/pinch_in_ios4_iphone.base64 +0 -104
  57. data/lib/calabash-cucumber/resources/pinch_in_ios5_ipad.base64 +0 -144
  58. data/lib/calabash-cucumber/resources/pinch_in_ios5_iphone.base64 +0 -144
  59. data/lib/calabash-cucumber/resources/pinch_in_ios6_ipad.base64 +0 -70
  60. data/lib/calabash-cucumber/resources/pinch_in_ios6_iphone.base64 +0 -70
  61. data/lib/calabash-cucumber/resources/pinch_out_ios5_ipad.base64 +0 -207
  62. data/lib/calabash-cucumber/resources/pinch_out_ios5_iphone.base64 +0 -207
  63. data/lib/calabash-cucumber/resources/pinch_out_ios6_ipad.base64 +0 -96
  64. data/lib/calabash-cucumber/resources/pinch_out_ios6_iphone.base64 +0 -96
  65. data/lib/calabash-cucumber/resources/rotate_left_home_down_ios4_ipad.base64 +0 -2
  66. data/lib/calabash-cucumber/resources/rotate_left_home_down_ios4_iphone.base64 +0 -2
  67. data/lib/calabash-cucumber/resources/rotate_left_home_down_ios5_ipad.base64 +0 -2
  68. data/lib/calabash-cucumber/resources/rotate_left_home_down_ios5_iphone.base64 +0 -2
  69. data/lib/calabash-cucumber/resources/rotate_left_home_left_ios4_ipad.base64 +0 -2
  70. data/lib/calabash-cucumber/resources/rotate_left_home_left_ios4_iphone.base64 +0 -2
  71. data/lib/calabash-cucumber/resources/rotate_left_home_left_ios5_ipad.base64 +0 -2
  72. data/lib/calabash-cucumber/resources/rotate_left_home_left_ios5_iphone.base64 +0 -2
  73. data/lib/calabash-cucumber/resources/rotate_left_home_right_ios4_ipad.base64 +0 -2
  74. data/lib/calabash-cucumber/resources/rotate_left_home_right_ios4_iphone.base64 +0 -2
  75. data/lib/calabash-cucumber/resources/rotate_left_home_right_ios5_ipad.base64 +0 -2
  76. data/lib/calabash-cucumber/resources/rotate_left_home_right_ios5_iphone.base64 +0 -2
  77. data/lib/calabash-cucumber/resources/rotate_left_home_up_ios4_ipad.base64 +0 -2
  78. data/lib/calabash-cucumber/resources/rotate_left_home_up_ios4_iphone.base64 +0 -2
  79. data/lib/calabash-cucumber/resources/rotate_left_home_up_ios5_ipad.base64 +0 -2
  80. data/lib/calabash-cucumber/resources/rotate_left_home_up_ios5_iphone.base64 +0 -2
  81. data/lib/calabash-cucumber/resources/rotate_right_home_down_ios4_ipad.base64 +0 -2
  82. data/lib/calabash-cucumber/resources/rotate_right_home_down_ios4_iphone.base64 +0 -2
  83. data/lib/calabash-cucumber/resources/rotate_right_home_down_ios5_ipad.base64 +0 -2
  84. data/lib/calabash-cucumber/resources/rotate_right_home_down_ios5_iphone.base64 +0 -2
  85. data/lib/calabash-cucumber/resources/rotate_right_home_left_ios4_ipad.base64 +0 -2
  86. data/lib/calabash-cucumber/resources/rotate_right_home_left_ios4_iphone.base64 +0 -2
  87. data/lib/calabash-cucumber/resources/rotate_right_home_left_ios5_ipad.base64 +0 -2
  88. data/lib/calabash-cucumber/resources/rotate_right_home_left_ios5_iphone.base64 +0 -2
  89. data/lib/calabash-cucumber/resources/rotate_right_home_right_ios4_ipad.base64 +0 -2
  90. data/lib/calabash-cucumber/resources/rotate_right_home_right_ios4_iphone.base64 +0 -2
  91. data/lib/calabash-cucumber/resources/rotate_right_home_right_ios5_ipad.base64 +0 -2
  92. data/lib/calabash-cucumber/resources/rotate_right_home_right_ios5_iphone.base64 +0 -2
  93. data/lib/calabash-cucumber/resources/rotate_right_home_up_ios4_ipad.base64 +0 -2
  94. data/lib/calabash-cucumber/resources/rotate_right_home_up_ios4_iphone.base64 +0 -2
  95. data/lib/calabash-cucumber/resources/rotate_right_home_up_ios5_ipad.base64 +0 -2
  96. data/lib/calabash-cucumber/resources/rotate_right_home_up_ios5_iphone.base64 +0 -2
  97. data/lib/calabash-cucumber/resources/swipe_down_ios5_ipad.base64 +0 -18
  98. data/lib/calabash-cucumber/resources/swipe_down_ios5_iphone.base64 +0 -31
  99. data/lib/calabash-cucumber/resources/swipe_down_ios6_ipad.base64 +0 -25
  100. data/lib/calabash-cucumber/resources/swipe_down_ios6_iphone.base64 +0 -25
  101. data/lib/calabash-cucumber/resources/swipe_left_hard_ios4_ipad.base64 +0 -15
  102. data/lib/calabash-cucumber/resources/swipe_left_hard_ios4_iphone.base64 +0 -15
  103. data/lib/calabash-cucumber/resources/swipe_left_ios4_ipad.base64 +0 -18
  104. data/lib/calabash-cucumber/resources/swipe_left_ios4_iphone.base64 +0 -18
  105. data/lib/calabash-cucumber/resources/swipe_left_ios5_ipad.base64 +0 -17
  106. data/lib/calabash-cucumber/resources/swipe_left_ios5_iphone.base64 +0 -34
  107. data/lib/calabash-cucumber/resources/swipe_left_ios6_ipad.base64 +0 -28
  108. data/lib/calabash-cucumber/resources/swipe_left_ios6_iphone.base64 +0 -28
  109. data/lib/calabash-cucumber/resources/swipe_right_hard_ios4_ipad.base64 +0 -17
  110. data/lib/calabash-cucumber/resources/swipe_right_hard_ios4_iphone.base64 +0 -17
  111. data/lib/calabash-cucumber/resources/swipe_right_ios4_ipad.base64 +0 -13
  112. data/lib/calabash-cucumber/resources/swipe_right_ios4_iphone.base64 +0 -13
  113. data/lib/calabash-cucumber/resources/swipe_right_ios5_ipad.base64 +0 -17
  114. data/lib/calabash-cucumber/resources/swipe_right_ios5_iphone.base64 +0 -17
  115. data/lib/calabash-cucumber/resources/swipe_right_ios6_ipad.base64 +0 -25
  116. data/lib/calabash-cucumber/resources/swipe_right_ios6_iphone.base64 +0 -25
  117. data/lib/calabash-cucumber/resources/swipe_up_ios5_ipad.base64 +0 -34
  118. data/lib/calabash-cucumber/resources/swipe_up_ios5_iphone.base64 +0 -28
  119. data/lib/calabash-cucumber/resources/swipe_up_ios6_ipad.base64 +0 -25
  120. data/lib/calabash-cucumber/resources/swipe_up_ios6_iphone.base64 +0 -25
  121. data/lib/calabash-cucumber/resources/touch_done_ios4_ipad.base64 +0 -7
  122. data/lib/calabash-cucumber/resources/touch_done_ios4_iphone.base64 +0 -9
  123. data/lib/calabash-cucumber/resources/touch_done_ios5_ipad.base64 +0 -7
  124. data/lib/calabash-cucumber/resources/touch_done_ios5_iphone.base64 +0 -9
  125. data/lib/calabash-cucumber/resources/touch_hold_ios5_ipad.base64 +0 -9
  126. data/lib/calabash-cucumber/resources/touch_hold_ios5_iphone.base64 +0 -9
  127. data/lib/calabash-cucumber/resources/touch_hold_ios6_ipad.base64 +0 -9
  128. data/lib/calabash-cucumber/resources/touch_hold_ios6_iphone.base64 +0 -9
  129. data/lib/calabash-cucumber/resources/touch_ios4_ipad.base64 +0 -9
  130. data/lib/calabash-cucumber/resources/touch_ios4_iphone.base64 +0 -9
  131. data/lib/calabash-cucumber/resources/touch_ios5_ipad.base64 +0 -9
  132. data/lib/calabash-cucumber/resources/touch_ios5_iphone.base64 +0 -9
  133. data/lib/calabash-cucumber/resources/touch_ios7_ipad.base64 +0 -9
  134. data/lib/calabash-cucumber/resources/touch_ios7_iphone.base64 +0 -9
  135. data/lib/calabash-cucumber/resources/wheel_down_ios4_ipad.base64 +0 -159
  136. data/lib/calabash-cucumber/resources/wheel_down_ios4_iphone.base64 +0 -159
  137. data/lib/calabash-cucumber/resources/wheel_down_ios5_ipad.base64 +0 -156
  138. data/lib/calabash-cucumber/resources/wheel_down_ios5_iphone.base64 +0 -156
  139. data/lib/calabash-cucumber/resources/wheel_up_ios4_ipad.base64 +0 -166
  140. data/lib/calabash-cucumber/resources/wheel_up_ios4_iphone.base64 +0 -166
  141. data/lib/calabash-cucumber/resources/wheel_up_ios5_ipad.base64 +0 -156
  142. data/lib/calabash-cucumber/resources/wheel_up_ios5_iphone.base64 +0 -156
  143. data/scripts/EmptyAppHack.app/Default-568h@2x.png +0 -0
  144. data/scripts/EmptyAppHack.app/Default.png +0 -0
  145. data/scripts/EmptyAppHack.app/Default@2x.png +0 -0
  146. data/scripts/EmptyAppHack.app/EmptyAppHack +0 -0
  147. data/scripts/EmptyAppHack.app/Info.plist +0 -0
  148. data/scripts/EmptyAppHack.app/PkgInfo +0 -1
  149. data/scripts/EmptyAppHack.app/en.lproj/InfoPlist.strings +0 -0
  150. data/scripts/com.example.plist +0 -0
  151. data/scripts/data/.GlobalPreferences.plist +0 -0
  152. data/scripts/reset_simulator.scpt +0 -0
  153. data/spec/bin/calabash_ios_sim_spec.rb +0 -24
  154. data/spec/launcher_spec.rb +0 -166
  155. data/spec/logging_spec.rb +0 -38
  156. data/spec/plist_buddy_spec.rb +0 -99
  157. data/spec/resources/enable-accessibility/6.1/.gitkeep +0 -0
  158. data/spec/resources/enable-accessibility/7.0.3-64/.gitkeep +0 -0
  159. data/spec/resources/enable-accessibility/7.0.3/.gitkeep +0 -0
  160. data/spec/resources/enable-accessibility/7.1-64/.gitkeep +0 -0
  161. data/spec/resources/enable-accessibility/7.1/.gitkeep +0 -0
  162. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/Default-568h@2x.png +0 -0
  163. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/Info.plist +0 -0
  164. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/LPSimpleExample-cal +0 -0
  165. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/PkgInfo +0 -1
  166. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/InfoPlist.strings +0 -0
  167. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFirstViewController.nib +0 -0
  168. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFirstViewController~ipad.nib +0 -0
  169. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFourthViewController.nib +0 -0
  170. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPFourthViewController~ipad.nib +0 -0
  171. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPSecondViewController.nib +0 -0
  172. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPSecondViewController~ipad.nib +0 -0
  173. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPThirdViewController.nib +0 -0
  174. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/en.lproj/LPThirdViewController~ipad.nib +0 -0
  175. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/first.png +0 -0
  176. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/first@2x.png +0 -0
  177. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/second.png +0 -0
  178. data/spec/resources/enable-accessibility/LPSimpleExample-cal.app/second@2x.png +0 -0
  179. data/spec/resources/plist_buddy/com.example.plist +0 -0
  180. data/spec/resources/plist_buddy/com.testing.plist +0 -18
  181. data/spec/simulator_accessibility_spec.rb +0 -206
  182. data/spec/spec_helper.rb +0 -31
  183. data/spec/version_spec.rb +0 -13
  184. data/spec/xctools_spec.rb +0 -58
@@ -2,20 +2,22 @@ require 'json'
2
2
 
3
3
  module Calabash
4
4
  module Cucumber
5
- module Map #=> Connection
6
5
 
7
- # returns an array of views matched by the +query+ or the result of
8
- # performing the Objective-C sequence defined by the +method_name+ and
9
- # +method_args+ on all the views matched by the +query+
6
+ # @!visibility private
7
+ module Map
8
+
9
+ # returns an array of views matched by the `query` or the result of
10
+ # performing the Objective-C sequence defined by the `method_name` and
11
+ # `method_args` on all the views matched by the `query`
10
12
  #
11
13
  # the query language is documented here: https://github.com/calabash/calabash-ios/wiki
12
14
  #
13
15
  # returns a JSON representation of each view that is matched
14
16
  #
15
- # when the +method_name+ is a calabash operation, returns an array that
16
- # contains the result of calling the objc selector +description+ on each
17
- # matched view. these are examples of calabash operations: +:flash+,
18
- # +:scrollToRowWithMark+, +:changeDatePickerDate+.
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`.
19
21
  def map(query, method_name, *method_args)
20
22
  #todo calabash operations should return 'views touched' in JSON format
21
23
  raw_map(query, method_name, *method_args)['results']
@@ -24,26 +26,26 @@ module Calabash
24
26
  # returns a JSON object the represents the result of performing an http
25
27
  # query against the calabash server.
26
28
  #
27
- # gem users should _not_ call this method directly; call +map+ instead.
29
+ # gem users should _not_ call this method directly; call `map` instead.
28
30
  #
29
- # raises an error and takes a screenshot if the value of the +outcome+ key
31
+ # raises an error and takes a screenshot if the value of the `outcome` key
30
32
  # is _not_ 'SUCCESS'
31
33
  #
32
34
  # the JSON object contains the following keys:
33
35
  #
34
- # +outcome+ => indicates the success or failure of the query
36
+ # `outcome` => indicates the success or failure of the query
35
37
  #
36
- # +status_bar_orientation+ => the orientation of the status bar
38
+ # `status_bar_orientation` => the orientation of the status bar
37
39
  #
38
- # +results+ => views matched by the +query+ or the result of
40
+ # `results` => views matched by the `query` or the result of
39
41
  # performing the Objective-C selector sequence defined by
40
- # the +method_name+ with arguments defined in
41
- # +method_args+ on all views matched by the +query+
42
+ # the `method_name` with arguments defined in
43
+ # `method_args` on all views matched by the `query`
42
44
  #
43
45
  # the query language is documented here: https://github.com/calabash/calabash-ios/wiki
44
46
  #
45
- # here are some examples that clarify how the +method_name+ and +method_args+
46
- # influence the value of the +results+ key
47
+ # here are some examples that clarify how the `method_name` and `method_args`
48
+ # influence the value of the `results` key
47
49
  #
48
50
  # simple examples:
49
51
  #
@@ -76,20 +78,20 @@ module Calabash
76
78
  res
77
79
  end
78
80
 
79
- # asserts the result of a calabash +map+ call and raises an error with
80
- # +msg+ if no valid results are found.
81
+ # asserts the result of a calabash `map` call and raises an error with
82
+ # `msg` if no valid results are found.
81
83
  #
82
84
  # casual gem users should never need to call this method; this is a
83
85
  # convenience method for gem maintainers.
84
86
  #
85
- # raises an error if +map_results+:
87
+ # raises an error if `map_results`:
86
88
  #
87
89
  # is an empty list #=> []
88
90
  # contains a '<VOID>' string #=> [ "<VOID>" ]
89
91
  # contains '*****' string #=> [ "*****" ]
90
92
  # contains a single nil #=> [ nil ]
91
93
  #
92
- # when evaluating whether a +map+ call is successful it is important to
94
+ # when evaluating whether a `map` call is successful it is important to
93
95
  # note that sometimes a <tt>[ nil ]</tt> or <tt>[nil, <val>, nil]</tt> is
94
96
  # a valid result.
95
97
  #
@@ -110,7 +112,7 @@ module Calabash
110
112
  #
111
113
  # here a <tt>[ nil ]</tt> should be considered invalid because the
112
114
  # the operation could not be performed because there is not row that
113
- # matches +mark+
115
+ # matches `mark`
114
116
  def assert_map_results(map_results, msg)
115
117
  compact = map_results.compact
116
118
  if compact.empty? or compact.member? '<VOID>' or compact.member? '*****'
@@ -5,7 +5,7 @@ require 'calabash-cucumber/keychain_helpers'
5
5
  require 'calabash-cucumber/wait_helpers'
6
6
  require 'calabash-cucumber/launcher'
7
7
  require 'net/http'
8
- require 'test/unit'
8
+ require 'test/unit/assertions'
9
9
  require 'json'
10
10
  require 'set'
11
11
  require 'calabash-cucumber/version'
@@ -13,17 +13,13 @@ require 'calabash-cucumber/date_picker'
13
13
  require 'calabash-cucumber/ipad_1x_2x'
14
14
  require 'calabash-cucumber/utils/logging'
15
15
 
16
- if not Object.const_defined?(:CALABASH_COUNT)
17
- #compatability with IRB
18
- CALABASH_COUNT = {:step_index => 0, :step_line => "irb"}
19
- end
20
-
21
-
22
16
  module Calabash
23
17
  module Cucumber
18
+
19
+ # A module for wrapping the public APIs of this gem.
24
20
  module Operations
25
21
 
26
- include Minitest::Assertions
22
+ include Test::Unit::Assertions
27
23
  include Calabash::Cucumber::Logging
28
24
  include Calabash::Cucumber::Core
29
25
  include Calabash::Cucumber::TestsHelpers
@@ -33,158 +29,6 @@ module Calabash
33
29
  include Calabash::Cucumber::DatePicker
34
30
  include Calabash::Cucumber::IPad
35
31
 
36
- def page(clz,*args)
37
- clz.new(self,*args)
38
- end
39
-
40
- def await_page(clz,*args)
41
- clz.new(self,*args).await
42
- end
43
-
44
- def home_direction
45
- status_bar_orientation.to_sym
46
- end
47
-
48
- def assert_home_direction(expected)
49
- unless expected.to_sym == home_direction
50
- screenshot_and_raise "Expected home button to have direction #{expected} but had #{home_direction}"
51
- end
52
- end
53
-
54
- def label(uiquery)
55
- query(uiquery, :accessibilityLabel)
56
- end
57
-
58
- def identifier(uiquery)
59
- query(uiquery, :accessibilityIdentifier)
60
- end
61
-
62
- def simple_touch(label, *args)
63
- touch("view marked:'#{label}'", *args)
64
- end
65
-
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)
77
- simple_touch(label, *args)
78
- end
79
-
80
- def html(q)
81
- query(q).map { |e| e['html'] }
82
- end
83
-
84
- # sets the text value of the views matched by +uiquery+ to +txt+
85
- #
86
- # @deprecated since 0.9.145
87
- #
88
- # we have stopped testing this method. you have been warned.
89
- #
90
- # * to enter text using the native keyboard use 'keyboard_enter_text'
91
- # * to delete text use 'keyboard_enter_text('Delete')"
92
- # * to clear a text field or text view:
93
- # - RECOMMENDED: use queries and touches to replicate what the user would do
94
- # - for text fields, implement a clear text button and touch it
95
- # - for text views, use touches to reveal text editing popup
96
- # see https://github.com/calabash/calabash-ios/issues/151
97
- # - use 'clear_text'
98
- # https://github.com/calabash/calabash-ios/wiki/03.5-Calabash-iOS-Ruby-API
99
- #
100
- # raises an error if the +uiquery+ finds no matching queries or finds
101
- # a view that does not respond to the objc selector 'setText'
102
- def set_text(uiquery, txt)
103
- msgs = ["'set_text' is deprecated and its behavior is now unpredictable",
104
- "* to enter text using the native keyboard use 'keyboard_enter_text'",
105
- "* to delete text use 'keyboard_enter_text('Delete')",
106
- '* to clear a text field or text view:',
107
- ' - RECOMMENDED: use queries and touches to replicate what the user would do',
108
- ' * for text fields, implement a clear text button and touch it',
109
- ' * for text views, use touches to reveal text editing popup',
110
- ' see https://github.com/calabash/calabash-ios/issues/151',
111
- " - use 'clear_text'",
112
- 'https://github.com/calabash/calabash-ios/wiki/03.5-Calabash-iOS-Ruby-API']
113
- msg = msgs.join("\n")
114
- _deprecated('0.9.145', msg, :warn)
115
-
116
- text_fields_modified = map(uiquery, :setText, txt)
117
-
118
- msg = "query '#{uiquery}' returned no matching views that respond to 'setText'"
119
- assert_map_results(text_fields_modified, msg)
120
- text_fields_modified
121
- end
122
-
123
- # sets the text value of the views matched by +uiquery+ to <tt>''</tt>
124
- # (the empty string)
125
- #
126
- # using this sparingly and with caution
127
- #
128
- #
129
- # it is recommended that you instead do some combination of the following
130
- #
131
- # * use queries and touches to replicate with the user would
132
- # - for text fields, implement a clear text button and touch it
133
- # - for text views, use touches to reveal text editing popup
134
- # see https://github.com/calabash/calabash-ios/issues/151
135
- #
136
- # https://github.com/calabash/calabash-ios/wiki/03.5-Calabash-iOS-Ruby-API
137
- #
138
- # raises an error if the +uiquery+ finds no matching queries or finds
139
- # a _single_ view that does not respond to the objc selector 'setText'
140
- #
141
- # IMPORTANT
142
- # calling:
143
- #
144
- # > clear_text("view")
145
- #
146
- # will clear the text on _all_ visible views that respond to 'setText'
147
- def clear_text(uiquery)
148
- views_modified = map(uiquery, :setText, '')
149
- msg = "query '#{uiquery}' returned no matching views that respond to 'setText'"
150
- assert_map_results(views_modified, msg)
151
- views_modified
152
- end
153
-
154
-
155
- def set_user_pref(key, val)
156
- res = http({:method => :post, :path => 'userprefs'},
157
- {:key=> key, :value => val})
158
- res = JSON.parse(res)
159
- if res['outcome'] != 'SUCCESS'
160
- screenshot_and_raise "set_user_pref #{key} = #{val} failed because: #{res['reason']}\n#{res['details']}"
161
- end
162
-
163
- res['results']
164
- end
165
-
166
- def user_pref(key)
167
- res = http({:method => :get, :raw => true, :path => 'userprefs'},
168
- {:key=> key})
169
- res = JSON.parse(res)
170
- if res['outcome'] != 'SUCCESS'
171
- screenshot_and_raise "get user_pref #{key} failed because: #{res['reason']}\n#{res['details']}"
172
- end
173
-
174
- res['results'].first
175
- end
176
-
177
- #def screencast_begin
178
- # http({:method=>:post, :path=>'screencast'}, {:action => :start})
179
- #end
180
- #
181
- #def screencast_end(file_name)
182
- # res = http({:method=>:post, :path=>'screencast'}, {:action => :stop})
183
- # File.open(file_name,'wb') do |f|
184
- # f.write res
185
- # end
186
- # file_name
187
- #end
188
32
  end
189
33
  end
190
34
  end
@@ -3,12 +3,25 @@ require 'calabash-cucumber/device'
3
3
 
4
4
  module Calabash
5
5
  module Cucumber
6
+
7
+ # This module provides methods for interaction with UIAutomation's
8
+ # record-and-playback features.
9
+ #
10
+ # @note
11
+ # In iOS 7, the record-and-playback feature was dropped from UIAutomation.
12
+ # As such, using the record-and-playback API is not recommended.
13
+ #
14
+ # @note
15
+ # We expect that this module will be deprecated once iOS 6 testing is no
16
+ # longer supported.
6
17
  module PlaybackHelpers
7
18
 
8
19
  include Calabash::Cucumber::Logging
9
20
 
21
+ # @!visibility private
10
22
  DATA_PATH = File.expand_path(File.dirname(__FILE__))
11
23
 
24
+ # @!visibility private
12
25
  def recording_name_for(recording_name, os, device)
13
26
  #noinspection RubyControlFlowConversionInspection
14
27
  if !recording_name.end_with? '.base64'
@@ -18,6 +31,7 @@ module Calabash
18
31
  end
19
32
  end
20
33
 
34
+ # @!visibility private
21
35
  def load_recording(recording, rec_dir)
22
36
  directories = playback_file_directories(rec_dir)
23
37
  directories.each { |dir|
@@ -29,6 +43,7 @@ module Calabash
29
43
  nil
30
44
  end
31
45
 
46
+ # @!visibility private
32
47
  def playback_file_directories (rec_dir)
33
48
  # rec_dir is either ENV['PLAYBACK_DIR'] or ./features/playback
34
49
  [File.expand_path(rec_dir),
@@ -38,6 +53,7 @@ module Calabash
38
53
  "#{DATA_PATH}/resources/"].uniq
39
54
  end
40
55
 
56
+ # @!visibility private
41
57
  def load_playback_data(recording_name, options={})
42
58
  device = options['DEVICE'] || ENV['DEVICE'] || 'iphone'
43
59
 
@@ -79,6 +95,7 @@ EOF
79
95
  data
80
96
  end
81
97
 
98
+ # @!visibility private
82
99
  def find_compatible_recording (recording_name, os, rec_dir, device, candidates)
83
100
  recording = recording_name_for(recording_name, os, device)
84
101
  data = load_recording(recording, rec_dir)
@@ -99,6 +116,9 @@ EOF
99
116
  data
100
117
  end
101
118
 
119
+ # Plays back a recording.
120
+ # @param [String] recording the filename of the recording
121
+ # @param [Hash] options can control the behavior of the recording
102
122
  def playback(recording, options={})
103
123
  data = load_playback_data(recording)
104
124
 
@@ -119,6 +139,9 @@ EOF
119
139
  res['results']
120
140
  end
121
141
 
142
+ # Plays back a recording but interpolates it first.
143
+ # @param [String] recording the filename of the recording
144
+ # @param [Hash] options can control the behavior of the recording
122
145
  def interpolate(recording, options={})
123
146
  data = load_playback_data(recording)
124
147
 
@@ -138,10 +161,13 @@ EOF
138
161
  res['results']
139
162
  end
140
163
 
164
+ # Begins a recording.
141
165
  def record_begin
142
166
  http({:method => :post, :path => 'record'}, {:action => :start})
143
167
  end
144
168
 
169
+ # Ends a recording and saves it.
170
+ # @param [String] file_name where to save the recording.
145
171
  def record_end(file_name)
146
172
  res = http({:method => :post, :path => 'record'}, {:action => :stop})
147
173
  File.open('_recording.plist', 'wb') do |f|
@@ -1,11 +1,23 @@
1
1
  module Calabash
2
2
  module Cucumber
3
+
4
+ # A module of methods that can help you construct queries.
3
5
  module QueryHelpers
4
6
 
7
+ # call this method to properly escape single quotes in Calabash queries
8
+ # Calabash iOS has some annoying rules for text containing single quotes.
9
+ # This helper frees you from manual escaping.
10
+ # @example
11
+ # quoted = escape_quotes("Karl's child")
12
+ # # => "Karl\\'s child"
13
+ # @param {String} str string to escape
14
+ # @return {String} escaped version of `str`
5
15
  def escape_quotes(str)
6
16
  str.gsub("'", "\\\\'")
7
17
  end
8
18
 
19
+ # converts a query result or off-set hash to a point hash
20
+ # @!visibility private
9
21
  def point_from(query_result, options={})
10
22
  offset_x = 0
11
23
  offset_y = 0
@@ -2,23 +2,57 @@ require 'calabash-cucumber/utils/logging'
2
2
 
3
3
  module Calabash
4
4
  module Cucumber
5
- module RotationHelpers #=> Connection, StatusBarHelpers
5
+
6
+ # Provides methods for rotating a device in a direction or to a particular
7
+ # orientation.
8
+ module RotationHelpers
6
9
 
7
10
  include Calabash::Cucumber::Logging
8
11
 
12
+ # @!visibility private
9
13
  def rotation_candidates
10
14
  %w(rotate_left_home_down rotate_left_home_left rotate_left_home_right rotate_left_home_up
11
15
  rotate_right_home_down rotate_right_home_left rotate_right_home_right rotate_right_home_up)
12
16
  end
13
17
 
14
- # orientations refer to home button position
15
- # down ==> bottom
16
- # up ==> top
17
- # left ==> landscape with left home button AKA: _right_ landscape*
18
- # right ==> landscape with right home button AKA: _left_ landscape*
18
+ # Rotates the home button position to the position indicated by `dir`.
19
+ #
20
+ # @example portrait
21
+ # rotate_home_button_to :down
22
+ #
23
+ # @example upside down
24
+ # rotate_home_button_to :up
25
+ #
26
+ # @example landscape with left home button AKA: _right_ landscape
27
+ # rotate_home_button_to :left
28
+ #
29
+ # @example landscape with right home button AKA: _left_ landscape
30
+ # rotate_home_button_to :right
31
+ #
32
+ # @note Refer to Apple's documentation for clarification about left vs.
33
+ # right landscape orientations.
34
+ #
35
+ # @note For legacy support the `dir` argument can be a String or Symbol.
36
+ # Please update your code to pass a Symbol.
37
+ #
38
+ # @note For legacy support `:top` and `top` are synonyms for `:up`.
39
+ # Please update your code to pass `:up`.
40
+ #
41
+ # @note For legacy support `:bottom` and `bottom` are synonyms for `:down`.
42
+ # Please update your code to pass `:down`.
43
+ #
44
+ # @note This method generates verbose messages when full console logging
45
+ # is enabled. See {Calabash::Cucumber::Logging#full_console_logging?}.
19
46
  #
20
- # * see apple documentation for clarification about where the home button
21
- # is in left and right landscape orientations
47
+ # @param [Symbol] dir The position of the home button after the rotation.
48
+ # Can be one of `{:down | :left | :right | :up }`.
49
+ #
50
+ # @return [Symbol] The orientation of the button when all rotations have
51
+ # been completed. If there is problem rotating, this method will return
52
+ # `:down` regardless of the actual home button position.
53
+ #
54
+ # @todo When running under UIAutomation, we should use that API to rotate
55
+ # instead of relying on playbacks.
22
56
  def rotate_home_button_to(dir)
23
57
  dir_sym = dir.to_sym
24
58
  if dir_sym.eql?(:top)
@@ -75,6 +109,28 @@ module Calabash
75
109
  :down
76
110
  end
77
111
 
112
+ # Rotates the device in the direction indicated by `dir`.
113
+ #
114
+ # @example rotate left
115
+ # rotate :left
116
+ #
117
+ # @example rotate right
118
+ # rotate :right
119
+ #
120
+ # @example rotate down
121
+ # rotate :down
122
+ #
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 }`.
131
+ #
132
+ # @todo When running under UIAutomation, we should use that API to rotate
133
+ # instead of relying on playbacks.
78
134
  def rotate(dir)
79
135
  dir = dir.to_sym
80
136
  current_orientation = status_bar_orientation().to_sym