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
@@ -4,22 +4,19 @@ require 'calabash-cucumber/actions/instruments_actions'
4
4
  require 'calabash-cucumber/actions/playback_actions'
5
5
  require 'calabash-cucumber/environment_helpers'
6
6
 
7
- # todo deprecate the Calabash::Cucumber::IOS7Operations
8
-
9
- # WARNING: this entire module is deprecated
10
- # references functions that do not exist
11
- # should be removed
12
7
  module Calabash
13
8
  module Cucumber
9
+
10
+ # @deprecated The methods in this module have all been deprecated.
11
+ #
12
+ # All the methods have abstracted to actions/instruments_actions.rb.
14
13
  module IOS7Operations
15
14
  include Calabash::Cucumber::UIA
16
15
  include Calabash::Cucumber::EnvironmentHelpers
17
16
 
17
+ # todo deprecate the Calabash::Cucumber::IOS7Operations
18
18
 
19
- # <b>DEPRECATED</b>
20
- #
21
- # abstracted into <tt>actions/instruments_actions.rb</tt> - actions that
22
- # can be performed under instruments
19
+ # @!visibility private
23
20
  def touch_ios7(options)
24
21
  ui_query = options[:query]
25
22
  offset = options[:offset]
@@ -32,6 +29,7 @@ module Calabash
32
29
  end
33
30
  end
34
31
 
32
+ # @!visibility private
35
33
  def swipe_ios7(options)
36
34
  ui_query = options[:query]
37
35
  offset = options[:offset]
@@ -45,6 +43,7 @@ module Calabash
45
43
  end
46
44
  end
47
45
 
46
+ # @!visibility private
48
47
  def pinch_ios7(in_or_out, options)
49
48
  ui_query = options[:query]
50
49
  offset = options[:offset]
@@ -59,6 +58,7 @@ module Calabash
59
58
  end
60
59
  end
61
60
 
61
+ # @!visibility private
62
62
  def pan_ios7(from, to, options={})
63
63
  from_result = find_and_normalize_or_raise from
64
64
  to_result = find_and_normalize_or_raise to
@@ -68,6 +68,7 @@ module Calabash
68
68
  [to_result]
69
69
  end
70
70
 
71
+ # @!visibility private
71
72
  def double_tap_ios7(options)
72
73
  ui_query = options[:query]
73
74
  offset = options[:offset]
@@ -81,6 +82,7 @@ module Calabash
81
82
  end
82
83
  end
83
84
 
85
+ # @!visibility private
84
86
  def two_finger_tap_ios7(options)
85
87
  ui_query = options[:query]
86
88
  offset = options[:offset]
@@ -94,6 +96,7 @@ module Calabash
94
96
  end
95
97
  end
96
98
 
99
+ # @!visibility private
97
100
  def flick_ios7(options, delta)
98
101
  ui_query = options[:query]
99
102
  offset = options[:offset]
@@ -107,6 +110,7 @@ module Calabash
107
110
  end
108
111
  end
109
112
 
113
+ # @!visibility private
110
114
  def touch_hold_ios7(options)
111
115
  ui_query = options[:query]
112
116
  offset = options[:offset]
@@ -6,31 +6,75 @@ require 'calabash-cucumber/uia'
6
6
 
7
7
  module Calabash
8
8
  module Cucumber
9
+ # Contains methods for interacting with the iPad.
9
10
  module IPad
10
11
 
12
+ # @!visibility private
13
+ # Provides methods to interact with the 1x and 2x buttons that appear
14
+ # when an iPhone-only app is emulated on an iPad. Calabash cannot
15
+ # interact with these apps in 2x mode because the touch coordinates
16
+ # cannot be reliably translated from normal iPhone dimensions to the
17
+ # emulated dimensions.
18
+ #
19
+ # On iOS < 7, an app _remembered_ its last 1x/2x scale so when it
20
+ # reopened the previous scale would be the same as when it closed. This
21
+ # meant you could manually set the scale once to 1x and never have to
22
+ # interact with the scale button again.
23
+ #
24
+ # On iOS > 7, the default behavior is that all emulated apps open at 2x
25
+ # regardless of their previous scale.
26
+ #
27
+ # @note In order to use this class, you must allow Calabash to launch
28
+ # your app with instruments.
11
29
  class Emulation
30
+
12
31
  include Calabash::Cucumber::FailureHelpers
13
32
  include Calabash::Cucumber::HTTPHelpers
14
33
  include Calabash::Cucumber::QueryHelpers
15
34
  include Calabash::Cucumber::UIA
16
35
 
17
- # NOTE to maintainers - when adding a localization, please notice that
36
+ # @!visibility private
37
+ #
38
+ # Maintainers: when adding a localization, please notice that
18
39
  # the keys and values are semantically reversed.
19
40
  #
20
41
  # you should read the hash as:
21
42
  #
22
- # :emulated_1x #=> what button is showing when the app is emulated at 2X?
23
- # :emulated_2x #=> what button is showing when the app is emulated at 1X?
43
+ # ```
44
+ # :emulated_1x <= what button is showing when the app is emulated at 2X?
45
+ # :emulated_2x <= what button is showing when the app is emulated at 1X?
46
+ # ```
24
47
  IPAD_1X_2X_BUTTON_LABELS = {
25
48
  :en => {:emulated_1x => '2X',
26
49
  :emulated_2x => '1X'}
27
50
  }
28
51
 
52
+ # @!visibility private
53
+ # @!attribute [r] scale
54
+ # The current 1X or 2X scale represented as a Symbol.
55
+ #
56
+ # @return [Symbol] Returns this emulation's scale. Will be one of
57
+ # `{:emulated_1x | :emulated_2x}`.
29
58
  attr_reader :scale
59
+
60
+ # @!visibility private
61
+ # @!attribute [r] lang_code
62
+ # The Apple compatible language code for determining the accessibility
63
+ # label of the 1X and 2X buttons.
64
+ #
65
+ # @return [Symbol] Returns the language code of this emulation.
30
66
  attr_reader :lang_code
31
67
 
68
+ # @!visibility private
69
+ # A private instance variable for storing this emulation's 1X/2X button
70
+ # names. The value will be set at runtime based on the language code
71
+ # that is passed the initializer.
32
72
  @button_names_hash = nil
33
73
 
74
+ # @!visibility private
75
+ # Creates a new Emulation.
76
+ # @param [Symbol] lang_code an Apple compatible language code
77
+ # @return [Emulation] Returns an emulation that is ready for action!
34
78
  def initialize (lang_code=:en)
35
79
  @button_names_hash = IPAD_1X_2X_BUTTON_LABELS[lang_code]
36
80
  if @button_names_hash.nil?
@@ -41,6 +85,7 @@ module Calabash
41
85
  @scale = _internal_ipad_emulation_scale
42
86
  end
43
87
 
88
+ # @!visibility private
44
89
  def tap_ipad_scale_button
45
90
  key = @scale
46
91
  name = @button_names_hash[key]
@@ -54,6 +99,7 @@ module Calabash
54
99
  end
55
100
 
56
101
  private
102
+ # @!visibility private
57
103
  def _internal_ipad_emulation_scale
58
104
  hash = @button_names_hash
59
105
  val = nil
@@ -81,36 +127,40 @@ module Calabash
81
127
 
82
128
  end
83
129
 
84
- # ensures that iPhone apps emulated on an iPad are displayed at +scale+.
130
+ # Ensures that iPhone apps emulated on an iPad are displayed at scale.
85
131
  #
86
- # starting in iOS 7, iPhone apps emulated on the iPad always launch at 2x.
87
- # calabash cannot currently interact with such apps in 2x mode (trust us,
88
- # we've tried).
132
+ # @note It is recommended that clients call this `ensure_ipad_emulation_1x`
133
+ # instead of this method.
89
134
  #
90
- # +scale+ must be one of { +:emulated_1x+ | +:emulated_2x+ }
135
+ # @note If this is not an iPhone app emulated on an iPad, then calling
136
+ # this method has no effect.
91
137
  #
92
- # is it is recommended that clients call this convenience method:
138
+ # @note In order to use this method, you must allow Calabash to launch
139
+ # your app with instruments.
93
140
  #
94
- # +ensure_ipad_emulation_1x+ #=> ensures the app is displayed in 1x mode
141
+ # Starting in iOS 7, iPhone apps emulated on the iPad always launch at 2x.
142
+ # calabash cannot currently interact with such apps in 2x mode (trust us,
143
+ # we've tried).
95
144
  #
96
- # takes these optional arguments
145
+ # @see #ensure_ipad_emulation_1x
97
146
  #
98
- # :lang_code #=> a language code for matching the name of the 'scale' button
99
- # :wait_after_touch #=> how long to wait after the 'scale' button is touched
147
+ # @param [Symbol] scale the desired scale - must be `:emulated_1x` or
148
+ # `:emulated_2x`
100
149
  #
101
- # the default values are:
150
+ # @param [Hash] opts optional arguments to control the interaction with
151
+ # the 1X/2X buttons
102
152
  #
103
- # :lang_code => :en
104
- # :wait_after_touch => 0.4
153
+ # @option opts [Symbol] :lang_code (:en) an Apple compatible
154
+ # language code
155
+ # @option opts [Symbol] :wait_after_touch (0.4) how long to
156
+ # wait _after_ the scale button is touched
105
157
  #
106
- # +IMPORTANT+ if this is not an iphone app emulated on a ipad, then calling
107
- # this function has no effect.
158
+ # @return [void]
108
159
  #
109
- # raises an exception if:
110
- # * the app was +not+ launched with Instruments i.e. there is no <tt>run_loop</tt>
111
- # * an invalid +scale+ is passed
112
- # * an unknown language code is passed
113
- # * the 'scale' button cannot be touched
160
+ # @raise [RuntimeError] If the app was not launched with instruments.
161
+ # @raise [RuntimeError] If an invalid `scale` is passed.
162
+ # @raise [RuntimeError] If an unknown language code is passed.
163
+ # @raise [RuntimeError] If the scale button cannot be touched.
114
164
  def ensure_ipad_emulation_scale(scale, opts={})
115
165
  return unless iphone_app_emulated_on_ipad?
116
166
 
@@ -139,44 +189,49 @@ module Calabash
139
189
 
140
190
  end
141
191
 
142
- # ensures that iPhone apps emulated on an iPad are displayed at +1X+.
192
+ # Ensures that iPhone apps emulated on an iPad are displayed at `1X`.
143
193
  #
144
- # here is an example of how to use this function in your +Before+ launch
145
- # hooks:
194
+ # @note If this is not an iPhone app emulated on an iPad, then calling
195
+ # this method has no effect.
146
196
  #
147
- # Before do |scenario|
148
- # @calabash_launcher = Calabash::Cucumber::Launcher.new
149
- # unless @calabash_launcher.calabash_no_launch?
150
- # @calabash_launcher.relaunch
151
- # @calabash_launcher.calabash_notify(self)
152
- # # ensure emulated apps are at 1x
153
- # ensure_ipad_emulation_1x
154
- # end
155
- # # do other stuff to prepare the test environment
156
- # end
197
+ # @note In order to use this method, you must allow Calabash to launch
198
+ # your app with instruments.
157
199
  #
158
- # takes these optional arguments
200
+ # Starting in iOS 7, iPhone apps emulated on the iPad always launch at 2x.
201
+ # calabash cannot currently interact with such apps in 2x mode (trust us,
202
+ # we've tried).
159
203
  #
160
- # :lang_code #=> a language code for matching the name of the 'scale' button
161
- # :wait_after_touch #=> how long to wait after the 'scale' button is touched
204
+ # @example Here is an example of how to use this function in your `Before` launch hooks.
205
+ # Before do |scenario|
206
+ # @calabash_launcher = Calabash::Cucumber::Launcher.new
207
+ # unless @calabash_launcher.calabash_no_launch?
208
+ # @calabash_launcher.relaunch
209
+ # @calabash_launcher.calabash_notify(self)
210
+ # # ensure emulated apps are at 1x
211
+ # ensure_ipad_emulation_1x
212
+ # end
213
+ # # do other stuff to prepare the test environment
214
+ # end
162
215
  #
163
- # the default values are:
216
+ # @param [Hash] opts optional arguments to control the interaction with
217
+ # the 1X/2X buttons
164
218
  #
165
- # :lang_code => :en
166
- # :wait_after_touch => 0.4
219
+ # @option opts [Symbol] :lang_code (:en) an Apple compatible
220
+ # language code
221
+ # @option opts [Symbol] :wait_after_touch (0.4) how long to
222
+ # wait _after_ the scale button is touched
167
223
  #
168
- # +IMPORTANT+ if this is not an iphone app emulated on a ipad, then calling
169
- # this function has no effect.
224
+ # @return [void]
170
225
  #
171
- # raises an exception if:
172
- # * the app was +not+ launched with Instruments i.e. there is no <tt>run_loop</tt>
173
- # * an unknown language code is passed
174
- # * the 'scale' button cannot be touched
226
+ # @raise [RuntimeError] If the app was not launched with instruments.
227
+ # @raise [RuntimeError] If an unknown language code is passed.
228
+ # @raise [RuntimeError] If the scale button cannot be touched.
175
229
  def ensure_ipad_emulation_1x(opts={})
176
230
  ensure_ipad_emulation_scale(:emulated_1x, opts)
177
231
  end
178
232
 
179
233
  private
234
+ # @!visibility private
180
235
  # ensures iPhone apps running on an iPad are emulated at 2X
181
236
  #
182
237
  # you should never need to call this function - calabash cannot interact
@@ -6,11 +6,45 @@ require 'calabash-cucumber/utils/logging'
6
6
 
7
7
  module Calabash
8
8
  module Cucumber
9
+ # Collection of methods for interacting with the keyboard.
10
+ #
11
+ # There are two environmental variables you can use to control the speed of
12
+ # typing. We've gone to great lengths to provide the fastest keyboard
13
+ # entry possible.
14
+ #
15
+ # If you are having trouble with skipped or are receiving JSON octet
16
+ # errors when typing, you might be able to resolve the problems by slowing
17
+ # down the rate of typing.
18
+ #
19
+ # Example: Use keyboard_enter_char + :wait_after_char.
20
+ #
21
+ # ```
22
+ # str.each_char do |char|
23
+ # # defaults to 0.05 seconds
24
+ # keyboard_enter_char(char, `{wait_after_char:0.5}`)
25
+ # end
26
+ # ```
27
+ #
28
+ # Example: Use keyboard_enter_char + POST_ENTER_KEYBOARD
29
+ #
30
+ # ```
31
+ # $ POST_ENTER_KEYBOARD=0.1 bundle exec cucumber
32
+ # str.each_char do |char|
33
+ # # defaults to 0.05 seconds
34
+ # keyboard_enter_char(char)
35
+ # end
36
+ # ```
37
+ #
38
+ # @note
39
+ # We have an exhaustive set of keyboard related test.s The API is reasonably
40
+ # stable. We are fighting against known bugs in Apple's UIAutomation. You
41
+ # should only need to fall back to the examples below in unusual situations.
9
42
  module KeyboardHelpers
10
43
 
11
44
  include Calabash::Cucumber::TestsHelpers
12
45
  include Calabash::Cucumber::Logging
13
46
 
47
+ # @!visibility private
14
48
  KEYPLANE_NAMES = {
15
49
  :small_letters => 'small-letters',
16
50
  :capital_letters => 'capital-letters',
@@ -19,7 +53,8 @@ module Calabash
19
53
  :numbers_and_punctuation_alternate => 'numbers-and-punctuation-alternate'
20
54
  }
21
55
 
22
-
56
+ # @!visibility private
57
+ # noinspection RubyStringKeysInHashInspection
23
58
  UIA_SUPPORTED_CHARS = {
24
59
  'Delete' => '\b',
25
60
  'Return' => '\n'
@@ -32,17 +67,19 @@ module Calabash
32
67
  #'More' => nil,
33
68
  }
34
69
 
35
-
36
- # returns a query string for detecting a keyboard
70
+ # @!visibility private
71
+ # Returns a query string for detecting a keyboard.
37
72
  def _qstr_for_keyboard
38
73
  "view:'UIKBKeyplaneView'"
39
74
  end
40
75
 
41
- # returns +true+ if a +docked+ keyboard is visible.
76
+ # Returns true if a docked keyboard is visible.
77
+ #
78
+ # A docked keyboard is pinned to the bottom of the view.
42
79
  #
43
- # a +docked+ keyboard is pinned to the bottom of the view.
80
+ # Keyboards on the iPhone and iPod are docked.
44
81
  #
45
- # keyboards on the iPhone and iPod are +docked+.
82
+ # @return [Boolean] if a keyboard is visible and docked.
46
83
  def docked_keyboard_visible?
47
84
  res = query(_qstr_for_keyboard).first
48
85
  return false if res.nil?
@@ -67,12 +104,12 @@ module Calabash
67
104
 
68
105
  end
69
106
 
70
- # returns +true+ if an +undocked+ keyboard is visible.
107
+ # Returns true if an undocked keyboard is visible.
71
108
  #
72
- # a +undocked+ keyboard is floats in the middle of the view
109
+ # A undocked keyboard is floats in the middle of the view.
73
110
  #
74
- # returns +false+ if the device is not an iPad; all keyboards on the
75
- # iPhone and iPod are +docked+
111
+ # @return [Boolean] Returns false if the device is not an iPad; all
112
+ # keyboards on the iPhone and iPod are docked.
76
113
  def undocked_keyboard_visible?
77
114
  return false if device_family_iphone?
78
115
 
@@ -82,28 +119,39 @@ module Calabash
82
119
  not docked_keyboard_visible?
83
120
  end
84
121
 
85
- # returns +true+ if a +split+ keyboard is visible.
122
+ # Returns true if a split keyboard is visible.
86
123
  #
87
- # a +split+ keyboard is floats in the middle of the view and is split to
124
+ # A split keyboard is floats in the middle of the view and is split to
88
125
  # allow faster thumb typing
89
126
  #
90
- # returns +false+ if the device is not an iPad; all keyboards on the
91
- # iPhone and iPod are +docked+
127
+ # @return [Boolean] Returns false if the device is not an iPad; all
128
+ # keyboards on the Phone and iPod are docked and not split.
92
129
  def split_keyboard_visible?
93
130
  return false if device_family_iphone?
94
131
  query("view:'UIKBKeyView'").count > 0 and
95
132
  element_does_not_exist(_qstr_for_keyboard)
96
133
  end
97
134
 
98
- # returns true if there is a visible keyboard
135
+ # Returns true if there is a visible keyboard.
136
+ #
137
+ # @return [Boolean] Returns true if there is a visible keyboard.
99
138
  def keyboard_visible?
100
139
  docked_keyboard_visible? or undocked_keyboard_visible? or split_keyboard_visible?
101
140
  end
102
141
 
103
- # waits for a keyboard to appear and once it does appear waits for 0.3
104
- # seconds
142
+ # Waits for a keyboard to appear and once it does appear waits for
143
+ # `:post_timeout` seconds.
144
+ #
145
+ # @see Calabash::Cucumber::WaitHelpers#wait_for for other options this
146
+ # method can handle.
105
147
  #
106
- # raises an error if no keyboard appears
148
+ # @param [Hash] opts controls the `wait_for` behavior
149
+ # @option opts [String] :timeout_message ('keyboard did not appear')
150
+ # Controls the message that appears in the exception.
151
+ # @option opts [Number] :post_timeout (0.3) Controls how long to wait
152
+ # _after_ the keyboard has appeared.
153
+ #
154
+ # @raise [Calabash::Cucumber::WaitHelpers::WaitError] if no keyboard appears
107
155
  def wait_for_keyboard(opts={})
108
156
  default_opts = {:timeout_message => 'keyboard did not appear',
109
157
  :post_timeout => 0.3}
@@ -113,37 +161,47 @@ module Calabash
113
161
  end
114
162
  end
115
163
 
116
- # <b>DEPRECATED:</b> Use <tt>wait_for_keyboard</tt> instead.
164
+ # @deprecated 0.9.163 replaced with `wait_for_keyboard`
165
+ # @see #wait_for_keyboard
117
166
  def await_keyboard
118
167
  _deprecated('0.9.163', "use 'wait_for_keyboard' instead", :warn)
119
168
  wait_for_keyboard
120
169
  end
121
170
 
171
+ # @!visibility private
122
172
  # returns an array of possible ipad keyboard modes
123
173
  def _ipad_keyboard_modes
124
174
  [:docked, :undocked, :split]
125
175
  end
126
176
 
127
- # returns the keyboard +mode+
177
+ # Returns the keyboard mode.
178
+ #
179
+ # @example How to use in a wait_* function.
180
+ # wait_for do
181
+ # ipad_keyboard_mode({:raise_on_no_visible_keyboard => false}) == :split
182
+ # end
128
183
  #
184
+ # ```
129
185
  # keyboard is pinned to bottom of the view #=> :docked
130
186
  # keyboard is floating in the middle of the view #=> :undocked
131
187
  # keyboard is floating and split #=> :split
132
- # no keyboard and :raise_on_no_visible_keyboard == +false+ #=> :unknown
188
+ # no keyboard and :raise_on_no_visible_keyboard == false #=> :unknown
189
+ # ```
133
190
  #
134
- # raises an error if the device is not an iPad
191
+ # @raise [RuntimeError] if the device under test is not an iPad.
135
192
  #
136
- # raises an error if the <tt>:raise_on_no_visible_keyboard</tt> is +true+
137
- # (default) and no keyboard is visible
138
- #
139
- # set <tt>:raise_on_no_visible_keyboard</tt> to +false+ to use in +wait+
140
- # functions
193
+ # @raise [RuntimeError] if `:raise_on_no_visible_keyboard` is truthy and
194
+ # no keyboard is visible.
195
+ # @param [Hash] opts controls the runtime behavior.
196
+ # @option opts [Boolean] :raise_on_no_visible_keyboard (true) set to false
197
+ # if you don't want to raise an error.
198
+ # @return [Symbol] Returns one of `{:docked | :undocked | :split | :unknown}`
141
199
  def ipad_keyboard_mode(opts = {})
142
200
  raise 'the keyboard mode does not exist on the iphone or ipod' if device_family_iphone?
143
201
 
144
202
  default_opts = {:raise_on_no_visible_keyboard => true}
145
- opts = default_opts.merge(opts)
146
- if opts[:raise_on_no_visible_keyboard]
203
+ merged_opts = default_opts.merge(opts)
204
+ if merged_opts[:raise_on_no_visible_keyboard]
147
205
  screenshot_and_raise 'there is no visible keyboard' unless keyboard_visible?
148
206
  return :docked if docked_keyboard_visible?
149
207
  return :undocked if undocked_keyboard_visible?
@@ -156,15 +214,18 @@ module Calabash
156
214
  end
157
215
  end
158
216
 
159
- # ensures that there is a keyboard to enter text
217
+ # @!visibility private
218
+ # Ensures that there is a keyboard to enter text.
160
219
  #
161
- # IMPORTANT will always raise an error when the keyboard is split and
162
- # there is no <tt>run_loop</tt> i.e. +UIAutomation+ is not available
220
+ # @note
221
+ # *IMPORTANT* will always raise an error when the keyboard is split and
222
+ # there is no `run_loop`; i.e. UIAutomation is not available.
163
223
  #
164
- # the default options are
165
- # :screenshot +true+ raise with a screenshot
166
- # :skip +false+ skip any checking (a nop) - used when iterating over
167
- # keyplanes for keys
224
+ # @param [Hash] opts controls screenshot-ing and error raising conditions
225
+ # @option opts [Boolean] :screenshot (true) raise with a screenshot if
226
+ # a keyboard cannot be ensured
227
+ # @option opts [Boolean] :skip (false) skip any checking (a nop) - used
228
+ # when iterating over keyplanes for keys
168
229
  def _ensure_can_enter_text(opts={})
169
230
  default_opts = {:screenshot => true,
170
231
  :skip => false}
@@ -191,23 +252,37 @@ module Calabash
191
252
  end
192
253
  end
193
254
 
194
- # use keyboard to enter +chr+
255
+ # Use keyboard to enter a character.
195
256
  #
196
- # IMPORTANT: use the <tt>POST_ENTER_KEYBOARD</tt> environmental variable
197
- # to slow down the typing; adds a wait after each character is touched.
198
- # this can fix problems where the typing is too fast and characters are
199
- # skipped.
257
+ # @note
258
+ # IMPORTANT: Use the `POST_ENTER_KEYBOARD` environmental variable
259
+ # to slow down the typing; adds a wait after each character is touched.
260
+ # this can fix problems where the typing is too fast and characters are
261
+ # skipped.
200
262
  #
201
- # there are several special 'characters', some of which do not appear on all
202
- # keyboards:
203
- # * 'Delete'
204
- # * 'Return'
263
+ # @note
264
+ # There are several special 'characters', some of which do not appear on
265
+ # all keyboards; e.g. `Delete`, `Return`.
205
266
  #
206
- # raises error if there is no visible keyboard or the keyboard is not
207
- # supported
267
+ # @note
268
+ # Since 0.9.163, this method accepts a Hash as the second parameter. The
269
+ # previous second parameter was a Boolean that controlled whether or not
270
+ # to screenshot on errors.
208
271
  #
209
- # use the +should_screenshot+ to control whether or not to raise an error
210
- # if +chr+ is not found
272
+ # @see #keyboard_enter_text
273
+ #
274
+ # @note
275
+ # You should prefer to call `keyboard_enter_text`.
276
+ #
277
+ # @raise [RuntimeError] if there is no visible keyboard
278
+ # @raise [RuntimeError] if the keyboard (layout) is not supported
279
+ #
280
+ # @param [String] chr the character to type
281
+ # @param [Hash] opts options to control the behavior of the method
282
+ # @option opts [Boolean] :should_screenshot (true) whether or not to
283
+ # screenshot on errors
284
+ # @option opts [Float] :wait_after_char ('POST_ENTER_KEYBOARD' or 0.05)
285
+ # how long to wait after a character is typed.
211
286
  def keyboard_enter_char(chr, opts={})
212
287
  unless opts.is_a?(Hash)
213
288
  msg = "you should no longer pass a boolean as the second arg; pass {:should_screenshot => '#{opts}'} hash instead"
@@ -248,6 +323,7 @@ module Calabash
248
323
  uia_type_string(code, '')
249
324
  end
250
325
  end
326
+ # noinspection RubyStringKeysInHashInspection
251
327
  res = {'results' => []}
252
328
  else
253
329
  res = http({:method => :post, :path => 'keyboard'},
@@ -274,9 +350,10 @@ module Calabash
274
350
  res['results']
275
351
  end
276
352
 
277
- # uses the keyboard to enter +text+
353
+ # Uses the keyboard to enter text.
278
354
  #
279
- # raises an error if the text cannot be entered
355
+ # @param [String] text the text to type.
356
+ # @raise [RuntimeError] if the text cannot be typed.
280
357
  def keyboard_enter_text(text)
281
358
  _ensure_can_enter_text
282
359
  if uia_available?
@@ -294,17 +371,21 @@ module Calabash
294
371
  end
295
372
  end
296
373
 
297
- # touches the keyboard +action+ key
374
+ # Touches the keyboard action key.
375
+ #
376
+ # The action key depends on the keyboard. Some examples include:
298
377
  #
299
- # the +action+ key depends on the keyboard. some examples include:
300
378
  # * Return
301
379
  # * Next
302
380
  # * Go
303
381
  # * Join
304
382
  # * Search
305
383
  #
306
- # not all keyboards have an +action+ key
307
- # raises an error if the key cannot be entered
384
+ # @note
385
+ # Not all keyboards have an action key. For example, numeric keyboards
386
+ # do not have an action key.
387
+ #
388
+ # @raise [RuntimeError] if the text cannot be typed.
308
389
  def tap_keyboard_action_key
309
390
  if uia_available?
310
391
  uia_type_string '\n', '', false
@@ -313,24 +394,30 @@ module Calabash
313
394
  end
314
395
  end
315
396
 
316
- # touches the keyboard +action+ key
397
+ # @deprecated 0.10.0 replaced with `tap_keyboard_action_key`
398
+ # @see #tap_keyboard_action_key
399
+ #
400
+ # Touches the keyboard action key.
317
401
  #
318
- # the +action+ key depends on the keyboard.
402
+ # The action key depends on the keyboard. Some examples include:
319
403
  #
320
- # some examples include:
321
404
  # * Return
322
405
  # * Next
323
406
  # * Go
324
407
  # * Join
325
408
  # * Search
326
409
  #
327
- # not all keyboards have an +action+ key
328
- # raises an error if the key cannot be entered
410
+ # @note
411
+ # Not all keyboards have an action key. For example, numeric keyboards
412
+ # do not have an action key.
413
+ #
414
+ # @raise [RuntimeError] if the text cannot be typed.
329
415
  def done
330
416
  tap_keyboard_action_key
331
417
  end
332
418
 
333
- # returns the current keyplane
419
+ # @!visibility private
420
+ # Returns the current keyplane.
334
421
  def _current_keyplane
335
422
  kp_arr = _do_keyplane(
336
423
  lambda { query("view:'UIKBKeyplaneView'", 'keyplane', 'componentName') },
@@ -338,15 +425,20 @@ module Calabash
338
425
  kp_arr.first.downcase
339
426
  end
340
427
 
341
- # searches the available keyplanes for +chr+ and if it is found, types it
428
+ # @!visibility private
429
+ # Searches the available keyplanes for chr and if it is found, types it.
430
+ #
431
+ # This is a recursive function.
342
432
  #
343
- # this is a recursive function
433
+ # @note
434
+ # Use the `KEYPLANE_SEARCH_STEP_PAUSE` variable to control how quickly
435
+ # the next keyplane is searched. Increase this value if you encounter
436
+ # problems with missed keystrokes.
344
437
  #
345
- # IMPORTANT: use the <tt>KEYPLANE_SEARCH_STEP_PAUSE</tt> variable to
346
- # control how quickly the next keyplane is searched. increase this value
347
- # if you encounter problems with missed keystrokes.
438
+ # @note
439
+ # When running under instruments, this method is not called.
348
440
  #
349
- # raises an error if the +chr+ cannot be found
441
+ # @raise [RuntimeError] if the char cannot be found
350
442
  def _search_keyplanes_and_enter_char(chr, visited=Set.new)
351
443
  cur_kp = _current_keyplane
352
444
  begin
@@ -387,9 +479,10 @@ module Calabash
387
479
  end
388
480
  end
389
481
 
390
- # process a keyplane
482
+ # @!visibility private
483
+ # Process a keyplane.
391
484
  #
392
- # raises an error if there is not visible keyplane
485
+ # @raise [RuntimeError] if there is no visible keyplane
393
486
  def _do_keyplane(kbtree_proc, keyplane_proc)
394
487
  desc = query("view:'UIKBKeyplaneView'", 'keyplane')
395
488
  fail('No keyplane (UIKBKeyplaneView keyplane)') if desc.empty?
@@ -404,16 +497,19 @@ module Calabash
404
497
  end
405
498
  end
406
499
 
407
- # returns a query string for finding the iPad 'Hide keyboard' button
500
+ # @!visibility private
501
+ # Returns a query string for finding the iPad 'Hide keyboard' button.
408
502
  def _query_uia_hide_keyboard_button
409
503
  "uia.keyboard().buttons()['Hide keyboard']"
410
504
  end
411
505
 
412
- # dismisses a iPad keyboard by touching the 'Hide keyboard' button and waits
413
- # for the keyboard to disappear
506
+ # Dismisses a iPad keyboard by touching the 'Hide keyboard' button and waits
507
+ # for the keyboard to disappear.
414
508
  #
415
- # raises an error if the device is not an iPad. the dismiss keyboard
416
- # key does not exist on the iPhone or iPod
509
+ # @note
510
+ # the dismiss keyboard key does not exist on the iPhone or iPod
511
+ #
512
+ # @raise [RuntimeError] if the device is not an iPad
417
513
  def dismiss_ipad_keyboard
418
514
  screenshot_and_raise 'cannot dismiss keyboard on iphone' if device_family_iphone?
419
515
 
@@ -429,13 +525,16 @@ module Calabash
429
525
  end
430
526
  end
431
527
 
432
- # returns the activation point of the iPad keyboard +mode+ key.
528
+ # @!visibility private
529
+ # Returns the activation point of the iPad keyboard mode key.
433
530
  #
434
- # the +mode+ key is also known as the <tt>Hide keyboard</tt> key.
531
+ # The mode key is also known as the 'Hide keyboard' key.
435
532
  #
436
- # raises an error when
437
- # * the device is not an iPad
438
- # * the app was not launched with instruments i.e. there is no <tt>run_loop</tt>
533
+ # @note
534
+ # This is only available when running under instruments.
535
+ #
536
+ # @raise [RuntimeError] when the device is not an iPad
537
+ # @raise [RuntimeError] the app was not launched with instruments
439
538
  def _point_for_ipad_keyboard_mode_key
440
539
  raise 'the keyboard mode does not exist on the on the iphone' if device_family_iphone?
441
540
  raise 'cannot detect keyboard mode key without launching with instruments' unless uia_available?
@@ -445,26 +544,24 @@ module Calabash
445
544
 
446
545
  # this did not work.
447
546
  #size = res['value']['size']
448
- #{:x => (origin['x'] + (size['width']/2)), :y => (origin['y'] + (size['height']/2))}
547
+ #{:x => (origin['x'] (size['width']/2)), :y => (origin['y'] (size['height']/2))}
449
548
  end
450
549
 
451
-
452
- # returns a query string for touching one of the options that appears when
453
- # the iPad +mode+ key is touched and held.
550
+ # @!visibility private
551
+ # Returns a query string for touching one of the options that appears when
552
+ # the iPad mode key is touched and held.
454
553
  #
455
- # the +mode+ key is also know as the <tt>Hide keyboard</tt> key.
554
+ # The mode key is also know as the 'Hide keyboard' key.
456
555
  #
457
- # valid arguments are:
458
- # top_or_bottom :top | :bottom
459
- # mode :docked | :undocked | :skipped
556
+ # @note
557
+ # This is only available when running outside of instruments.
460
558
  #
461
- # use <tt>_point_for_keyboard_mode_key</tt> if there is a <tt>run_loop</tt>
462
- # available
559
+ # @param [Symbol] top_or_bottom can be one of `{:top | :bottom}`
560
+ # @param [Symbol] mode `{:docked | :undocked | :skipped}`
463
561
  #
464
- # raises an error when
465
- # * the device is not an iPad
466
- # * the app was launched with Instruments i.e. there is a <tt>run_loop</tt>
467
- # * it is passed invalid arguments
562
+ # @raise [RuntimeError] the device is not an iPad
563
+ # @raise [RuntimeError] the app was not launched with instruments
564
+ # @raise [RuntimeError] the method is passed invalid arguments
468
565
  def _query_for_touch_for_keyboard_mode_option(top_or_bottom, mode)
469
566
  raise 'the keyboard mode does not exist on the iphone' if device_family_iphone?
470
567
 
@@ -492,12 +589,15 @@ module Calabash
492
589
  "label marked:'#{mark}'"
493
590
  end
494
591
 
495
- # returns a query for touching the iPad keyboard +mode+ key.
592
+ # @!visibility private
593
+ # Returns a query for touching the iPad keyboard mode key.
496
594
  #
497
- # the +mode+ key is also know as the <tt>Hide keyboard</tt> key.
595
+ # The mode key is also know as the 'Hide keyboard' key.
498
596
  #
499
- # use <tt>_point_for_keyboard_mode_key</tt> if there is a <tt>run_loop</tt>
500
- # available
597
+ # @note
598
+ # This is only available when running outside of instruments. Use
599
+ # ` _point_for_ipad_keyboard_mode_key` when the app is _not_ launched
600
+ # with instruments.
501
601
  #
502
602
  # raises an error when
503
603
  # * the device is not an iPad
@@ -512,12 +612,13 @@ module Calabash
512
612
  "#{qstr} index:#{idx}"
513
613
  end
514
614
 
515
- # touches the bottom option on the popup dialog that is presented when the
516
- # the iPad keyboard +mode+ key is touched and held.
615
+ # @!visibility private
616
+ # Touches the bottom option on the popup dialog that is presented when the
617
+ # the iPad keyboard `mode` key is touched and held.
517
618
  #
518
- # the +mode+ key is also know as the <tt>Hide keyboard</tt> key.
619
+ # The `mode` key is also know as the 'Hide keyboard' key.
519
620
  #
520
- # the +mode+ key allows the user to undock, dock, or split the keyboard.
621
+ # The `mode` key allows the user to undock, dock, or split the keyboard.
521
622
  def _touch_bottom_keyboard_mode_row
522
623
  mode = ipad_keyboard_mode
523
624
  if uia_available?
@@ -534,12 +635,12 @@ module Calabash
534
635
  2.times { sleep(0.5) }
535
636
  end
536
637
 
537
- # touches the top option on the popup dialog that is presented when the
538
- # the iPad keyboard +mode+ key is touched and held.
638
+ # Touches the top option on the popup dialog that is presented when the
639
+ # the iPad keyboard mode key is touched and held.
539
640
  #
540
- # the +mode+ key is also know as the <tt>Hide keyboard</tt> key.
641
+ # The `mode` key is also know as the 'Hide keyboard' key.
541
642
  #
542
- # the +mode+ key allows the user to undock, dock, or split the keyboard.
643
+ # The `mode` key allows the user to undock, dock, or split the keyboard.
543
644
  def _touch_top_keyboard_mode_row
544
645
  mode = ipad_keyboard_mode
545
646
  if uia_available?
@@ -558,16 +659,15 @@ module Calabash
558
659
  2.times { sleep(0.5) }
559
660
  end
560
661
 
561
- # ensures that the iPad keyboard is +docked+
662
+ # Ensures that the iPad keyboard is docked.
562
663
  #
563
- # +docked+ means the keyboard is pinned to bottom of the view
664
+ # Docked means the keyboard is pinned to bottom of the view.
564
665
  #
565
- # if the device is not an iPad, this is behaves like a call to
566
- # <tt>wait_for_keyboard</tt>
666
+ # If the device is not an iPad, this is behaves like a call to
667
+ # `wait_for_keyboard`.
567
668
  #
568
- # raises an error when
569
- # * there is no visible keyboard or
570
- # * the +docked+ keyboard cannot be achieved
669
+ # @raise [RuntimeError] if there is no visible keyboard
670
+ # @raise [RuntimeError] a docked keyboard was not achieved
571
671
  def ensure_docked_keyboard
572
672
  wait_for_keyboard
573
673
 
@@ -597,16 +697,18 @@ module Calabash
597
697
  end
598
698
 
599
699
 
600
- # ensures that the iPad keyboard is +undocked+
700
+ # Ensures that the iPad keyboard is undocked.
601
701
  #
602
- # +undocked+ means the keyboard is floating in the middle of the view
702
+ # Undocked means the keyboard is floating in the middle of the view.
603
703
  #
604
- # if the device is not an iPad, this is behaves like a call to
605
- # <tt>wait_for_keyboard</tt>
704
+ # If the device is not an iPad, this is behaves like a call to
705
+ # `wait_for_keyboard`.
606
706
  #
607
- # raises an error when
608
- # * there is no visible keyboard or
609
- # * the an +undocked+ keyboard cannot be achieved
707
+ # If the device is not an iPad, this is behaves like a call to
708
+ # `wait_for_keyboard`.
709
+ #
710
+ # @raise [RuntimeError] if there is no visible keyboard
711
+ # @raise [RuntimeError] an undocked keyboard was not achieved
610
712
  def ensure_undocked_keyboard
611
713
  wait_for_keyboard()
612
714
 
@@ -641,17 +743,19 @@ module Calabash
641
743
  end
642
744
 
643
745
 
644
- # ensures that the iPad keyboard is +split+
746
+ # Ensures that the iPad keyboard is split.
645
747
  #
646
- # +split+ means the keyboard is floating in the middle of the view and is
748
+ # Split means the keyboard is floating in the middle of the view and is
647
749
  # split into two sections to enable faster thumb typing.
648
750
  #
649
- # if the device is not an iPad, this is behaves like a call to
650
- # <tt>wait_for_keyboard</tt>
751
+ # If the device is not an iPad, this is behaves like a call to
752
+ # `wait_for_keyboard`.
651
753
  #
652
- # raises an error when
653
- # * there is no visible keyboard or
654
- # * the an +undocked+ keyboard cannot be achieved
754
+ # If the device is not an iPad, this is behaves like a call to
755
+ # `wait_for_keyboard`.
756
+ #
757
+ # @raise [RuntimeError] if there is no visible keyboard
758
+ # @raise [RuntimeError] a split keyboard was not achieved
655
759
  def ensure_split_keyboard
656
760
  wait_for_keyboard
657
761
 
@@ -672,6 +776,7 @@ module Calabash
672
776
  _wait_for_keyboard_in_mode(:split)
673
777
  end
674
778
 
779
+ # @!visibility private
675
780
  def _wait_for_keyboard_in_mode(mode, opts={})
676
781
  default_opts = {:post_timeout => 1.0}
677
782
  opts = default_opts.merge(opts)
@@ -695,13 +800,16 @@ module Calabash
695
800
  end
696
801
  end
697
802
 
698
- # used for detecting keyboards that are not normally visible to calabash
699
- # e.g. the keyboard on +'z'+
803
+ # Used for detecting keyboards that are not normally visible to calabash;
804
+ # e.g. the keyboard on the `MFMailComposeViewController`
700
805
  #
701
- # IMPORTANT this should only be used when the app does not respond to
702
- # <tt>keyboard_visible?</tt>
806
+ # @note
807
+ # IMPORTANT this should only be used when the app does not respond to
808
+ # `keyboard_visible?`.
703
809
  #
704
- # raises an error if the there is no <tt>run_loop</tt>
810
+ # @see #keyboard_visible?
811
+ #
812
+ # @raise [RuntimeError] if the app was not launched with instruments
705
813
  def uia_keyboard_visible?
706
814
  unless uia_available?
707
815
  screenshot_and_raise 'only available if there is a run_loop i.e. the app was launched with Instruments'
@@ -710,13 +818,16 @@ module Calabash
710
818
  not res.eql?(':nil')
711
819
  end
712
820
 
713
- # waits for a keyboard that is not normally visible to calabash
714
- # e.g. the keyboard on +MFMailComposeViewController+
821
+ # Waits for a keyboard that is not normally visible to calabash;
822
+ # e.g. the keyboard on `MFMailComposeViewController`.
823
+ #
824
+ # @note
825
+ # IMPORTANT this should only be used when the app does not respond to
826
+ # `keyboard_visible?`.
715
827
  #
716
- # IMPORTANT this should only be used when the app does not respond to
717
- # <tt>keyboard_visible?</tt>
828
+ # @see #keyboard_visible?
718
829
  #
719
- # raises an error if the there is no <tt>run_loop</tt>
830
+ # @raise [RuntimeError] if the app was not launched with instruments
720
831
  def uia_wait_for_keyboard(opts={})
721
832
  unless uia_available?
722
833
  screenshot_and_raise 'only available if there is a run_loop i.e. the app was launched with Instruments'
@@ -735,18 +846,16 @@ module Calabash
735
846
  end
736
847
  end
737
848
 
738
-
739
- private
740
-
741
- # returns the the text in the first responder
849
+ # @!visibility private
850
+ # Returns the the text in the first responder.
742
851
  #
743
- # the first responder will be the +UITextField+ or +UITextView+ instance
852
+ # The first responder will be the UITextField or UITextView instance
744
853
  # that is associated with the visible keyboard.
745
854
  #
746
- # returns +empty string+ if no +textField+ or +textView+ elements are found to be
855
+ # Teturns empty string if no textField or textView elements are found to be
747
856
  # the first responder.
748
857
  #
749
- # raises an exception if there is no visible keyboard
858
+ # @raise [RuntimeError] if there is no visible keyboard
750
859
  def _text_from_first_responder
751
860
  raise 'there must be a visible keyboard' unless keyboard_visible?
752
861
 
@@ -755,7 +864,7 @@ module Calabash
755
864
  return res.first unless res.empty?
756
865
  end
757
866
  #noinspection RubyUnnecessaryReturnStatement
758
- return ""
867
+ return ''
759
868
  end
760
869
 
761
870
  end