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,6 +2,8 @@ require 'date'
2
2
 
3
3
  module Calabash
4
4
  module Cucumber
5
+
6
+ # A collection of methods for interacting with UIDatePicker
5
7
  module DatePicker
6
8
  include Calabash::Cucumber::Core
7
9
 
@@ -9,15 +11,38 @@ module Calabash
9
11
  # we convert DateTime object to a string
10
12
  # and pass the format that objc can use
11
13
  # to convert the string into NSDate
14
+
15
+ # @!visibility private
12
16
  RUBY_DATE_AND_TIME_FMT = '%Y_%m_%d_%H_%M'
17
+
18
+ # @!visibility private
13
19
  OBJC_DATE_AND_TIME_FMT = 'yyyy_MM_dd_HH_mm'
14
20
 
15
21
  # picker modes
22
+
23
+ # @!visibility private
16
24
  UI_DATE_PICKER_MODE_TIME = 0
25
+ # @!visibility private
17
26
  UI_DATE_PICKER_MODE_DATE = 1
27
+ # @!visibility private
18
28
  UI_DATE_PICKER_MODE_DATE_AND_TIME = 2
29
+ # @!visibility private
19
30
  UI_DATE_PICKER_MODE_COUNT_DOWN_TIMER = 3
20
31
 
32
+ # @!visibility private
33
+ # Returns the picker mode of the UIDatePicker.
34
+ #
35
+ # @see #time_mode?
36
+ # @see #date_mode?
37
+ # @see #date_and_time_mode?
38
+ # @see #countdown_mode?
39
+ #
40
+ # @param [String] picker_id The accessibility label or id of the picker
41
+ # you are looking for. If nil, then the first UIDatePicker that is
42
+ # found will be queried.
43
+ # @return [String] Returns the picker mode which will be one of
44
+ # `{'0', '1', '2', '3'}`
45
+ # @raise [RuntimeError] if no picker can be found
21
46
  def date_picker_mode(picker_id=nil)
22
47
  query_str = should_see_date_picker picker_id
23
48
  res = query(query_str, :datePickerMode)
@@ -27,28 +52,87 @@ module Calabash
27
52
  res.first
28
53
  end
29
54
 
55
+ # Is the date picker in time mode?
56
+ #
57
+ # @see #time_mode?
58
+ # @see #date_mode?
59
+ # @see #date_and_time_mode?
60
+ # @see #countdown_mode?
61
+ #
62
+ # @param [String] picker_id The accessibility label or id of the picker
63
+ # you are looking for. If nil, then the first UIDatePicker that is
64
+ # found will be queried.
65
+ # @return [Boolean] true if the picker is in time mode
66
+ # @raise [RuntimeError] if no picker can be found
30
67
  def time_mode?(picker_id=nil)
31
68
  date_picker_mode(picker_id) == UI_DATE_PICKER_MODE_TIME
32
69
  end
33
70
 
71
+ # Is the date picker in date mode?
72
+ #
73
+ # @see #time_mode?
74
+ # @see #date_mode?
75
+ # @see #date_and_time_mode?
76
+ # @see #countdown_mode?
77
+ #
78
+ # @param [String] picker_id The accessibility label or id of the picker
79
+ # you are looking for. If nil, then the first UIDatePicker that is
80
+ # found will be queried.
81
+ # @return [Boolean] true if the picker is in date mode
82
+ # @raise [RuntimeError] if no picker can be found
34
83
  def date_mode?(picker_id=nil)
35
84
  date_picker_mode(picker_id) == UI_DATE_PICKER_MODE_DATE
36
85
  end
37
86
 
87
+ # Is the date picker in date and time mode?
88
+ #
89
+ # @see #time_mode?
90
+ # @see #date_mode?
91
+ # @see #date_and_time_mode?
92
+ # @see #countdown_mode?
93
+ #
94
+ # @param [String] picker_id The accessibility label or id of the picker
95
+ # you are looking for. If nil, then the first UIDatePicker that is
96
+ # found will be queried.
97
+ # @return [Boolean] true if the picker is in date and time mode
98
+ # @raise [RuntimeError] if no picker can be found
38
99
  def date_and_time_mode?(picker_id=nil)
39
100
  date_picker_mode(picker_id) == UI_DATE_PICKER_MODE_DATE_AND_TIME
40
101
  end
41
102
 
103
+ # Is the date picker in countdown mode?
104
+ #
105
+ # @see #time_mode?
106
+ # @see #date_mode?
107
+ # @see #date_and_time_mode?
108
+ # @see #countdown_mode?
109
+ #
110
+ # @param [String] picker_id The accessibility label or id of the picker
111
+ # you are looking for. If nil, then the first UIDatePicker that is
112
+ # found will be queried.
113
+ # @return [Boolean] true if the picker is in countdown mode
114
+ # @raise [RuntimeError] if no picker can be found
42
115
  def countdown_mode?(picker_id=nil)
43
116
  date_picker_mode(picker_id) == UI_DATE_PICKER_MODE_COUNT_DOWN_TIMER
44
117
  end
45
118
 
46
- # ensuring picker is visible
47
-
119
+ # @!visibility private
120
+ # Returns a query string for a date picker.
121
+ #
122
+ # @param [String] picker_id The accessibility label or id of the picker
123
+ # you are looking for. If nil, a query that looks for any UIDatePicker
124
+ # will be constructed.
125
+ # @return [String] a query-ready string for finding a UIDatePicker
48
126
  def query_string_for_picker (picker_id = nil)
49
127
  picker_id.nil? ? 'datePicker' : "datePicker marked:'#{picker_id}'"
50
128
  end
51
129
 
130
+ # Asserts that a date picker is visible.
131
+ #
132
+ # @param [String] picker_id The accessibility label or id of the picker
133
+ # you are looking for. If nil, any visible date picker will satisfy the
134
+ # assertion.
135
+ # @raise [RuntimeError] if a matching date picker is not visible
52
136
  def should_see_date_picker (picker_id=nil)
53
137
  query_str = query_string_for_picker picker_id
54
138
  if query(query_str).empty?
@@ -57,10 +141,20 @@ module Calabash
57
141
  query_str
58
142
  end
59
143
 
60
-
61
- # minimum and maximum dates
62
- # appledoc ==> The property is an NSDate object or nil (the default),
63
- # which means no maximum date.
144
+ # The maximum date for a picker. If there is no maximum date, this
145
+ # method returns nil.
146
+ #
147
+ # @note
148
+ # From the Apple docs:
149
+ # `The property is an NSDate object or nil (the default)`.
150
+ #
151
+ # @param [String] picker_id The accessibility label or id of the picker
152
+ # you are looking for. If nil, then the first UIDatePicker that is
153
+ # found will be queried.
154
+ # @return [DateTime] the maximum date on the picker or nil if no maximum
155
+ # exists
156
+ # @raise [RuntimeError] if the picker is in countdown mode
157
+ # @raise [RuntimeError] if the picker cannot be found
64
158
  def maximum_date_time_from_picker (picker_id = nil)
65
159
  if countdown_mode? picker_id
66
160
  screenshot_and_raise 'method is not available for pickers that are not in date or date time mode'
@@ -75,8 +169,20 @@ module Calabash
75
169
  DateTime.parse(res.first)
76
170
  end
77
171
 
78
- # appledoc ==> The property is an NSDate object or nil (the default),
79
- # which means no minimum date.
172
+ # The minimum date for a picker. If there is no minimum date, this
173
+ # method returns nil.
174
+ #
175
+ # @note
176
+ # From the Apple docs:
177
+ # `The property is an NSDate object or nil (the default)`.
178
+ #
179
+ # @param [String] picker_id The accessibility label or id of the picker
180
+ # you are looking for. If nil, then the first UIDatePicker that is
181
+ # found will be queried.
182
+ # @return [DateTime] the minimum date on the picker or nil if no minimum
183
+ # exists
184
+ # @raise [RuntimeError] if the picker is in countdown mode
185
+ # @raise [RuntimeError] if the picker cannot be found
80
186
  def minimum_date_time_from_picker (picker_id = nil)
81
187
  if countdown_mode? picker_id
82
188
  screenshot_and_raise 'method is not available for pickers that are not in date or date time mode'
@@ -91,7 +197,14 @@ module Calabash
91
197
  DateTime.parse(res.first)
92
198
  end
93
199
 
94
- # date time from picker
200
+ # Returns the date and time from the picker.
201
+ #
202
+ # @param [String] picker_id The accessibility label or id of the picker
203
+ # you are looking for. If nil, then the first UIDatePicker that is
204
+ # found will be queried.
205
+ # @return [DateTime] the date on the picker
206
+ # @raise [RuntimeError] if the picker is in countdown mode
207
+ # @raise [RuntimeError] if the picker cannot be found
95
208
  def date_time_from_picker (picker_id=nil)
96
209
  if countdown_mode? picker_id
97
210
  screenshot_and_raise 'method is not available for pickers that are not in date or date time mode'
@@ -104,8 +217,9 @@ module Calabash
104
217
  DateTime.parse(res.first)
105
218
  end
106
219
 
107
-
108
- # changing picker date time
220
+ # @!visibility private
221
+ # @todo replace with a `merge` inside the calling function
222
+ # -1 @jmoody for ruby noob-ness
109
223
  def args_for_change_date_on_picker(options)
110
224
  args = []
111
225
  if options.has_key?(:notify_targets)
@@ -122,27 +236,32 @@ module Calabash
122
236
  args
123
237
  end
124
238
 
125
-
126
- # sets the date and time on picker identified by <tt>options[:picker_id]</tt>
127
- # using the DateTime +target_dt+
128
- #
129
- # valid options are:
239
+ # Sets the date and time on picker.
130
240
  #
131
- # :animate - animate the change - default is +true+
132
- # :picker_id - the id (or mark) of the date picker - default is +nil+ which
133
- # will target the first visible date picker
134
- # :notify_targets - notify all objc targets that the date picker has changed
135
- # default is +true+
241
+ # @note
242
+ # When `:notify_targets => true` this operation iterates through the
243
+ # target/action pairs on the objc `UIDatePicker` instance and calls
244
+ # `performSelector:<action> object:<target>`. This has the effect of
245
+ # generating `UIEvents`.
136
246
  #
137
- # when <tt>:notify_targets = true</tt> this operation iterates through the
138
- # target/action pairs on the objc +UIDatePicker+ instance and calls
139
- # <tt>performSelector:<action> object:<target></tt> to simulate a +UIEvent+
247
+ # @param [DateTime] target_dt the date and time you want to change to
248
+ # @param [Hash] options controls the behavior of this method
249
+ # @option options [Boolean] :animate (true) animate the date change
250
+ # @option options [String] :picker_id (nil) The accessibility id or label
251
+ # of the date picker you are looking for. If nil, the first UIDatePicker
252
+ # that is found will have the date and time applied.
253
+ # @option options [Boolean] :notify_target (true) If true, all the date
254
+ # picker's target/action pairs will be called. This is necessary to
255
+ # generate UIEvents. If false, no UIEvents will be generated and it is
256
+ # likely that your UI will not update correctly.
140
257
  #
141
- # raises an error if
142
- # * no UIDatePicker can be found
143
- # * the target date is greater than the picker's maximum date
144
- # * the target date is less than the picker's minimum date
145
- # * the target date is not a DateTime object
258
+ # @raise [RuntimeError] if no date picker can be found
259
+ # @raise [RuntimeError] if the target date is greater than the picker's
260
+ # maximum date
261
+ # @raise [RuntimeError] if the target date is less than the picker's
262
+ # minimum date
263
+ # @raise [RuntimeError] if the target date is not a DateTime instance
264
+ # @todo replace `args_for_change_date_on_picker` with hash table `merge`
146
265
  def picker_set_date_time (target_dt, options = {:animate => true,
147
266
  :picker_id => nil,
148
267
  :notify_targets => true})
@@ -3,28 +3,128 @@ require 'calabash-cucumber/utils/logging'
3
3
 
4
4
  module Calabash
5
5
  module Cucumber
6
- # Class device encapsulates information about the device or devices we are
7
- # interacting with during a test.
6
+
7
+ # Device encapsulates information about the device or simulator that the
8
+ # app is running on. It also includes the following information about the
9
+ # app that is running on the current device.
10
+ #
11
+ # * The version of the embedded Calabash server.
12
+ # * Whether or not the app is an iPhone-only app that is being emulated on
13
+ # an iPad.
8
14
  class Device
9
15
 
10
16
  include Calabash::Cucumber::Logging
11
17
 
18
+ # @!visibility private
12
19
  GESTALT_IPHONE = 'iPhone'
20
+
21
+ # @!visibility private
13
22
  GESTALT_IPAD = 'iPad'
23
+
24
+ # @!visibility private
14
25
  GESTALT_IPHONE5 = '4-inch'
26
+
27
+ # @!visibility private
15
28
  GESTALT_SIM_SYS = 'x86_64'
29
+
30
+ # @!visibility private
16
31
  GESTALT_IPOD = 'iPod'
17
32
 
33
+ # @!attribute [r] endpoint
34
+ # The http address of this device.
35
+ # @example
36
+ # http://192.168.0.2:37265
37
+ # @return [String] an ip address with port number.
18
38
  attr_reader :endpoint
39
+
40
+ # The device family of this device.
41
+ #
42
+ # @note Also know as the form factor.
43
+ #
44
+ # @example
45
+ # # will be one of
46
+ # iPhone
47
+ # iPod
48
+ # iPad
49
+ #
50
+ # @!attribute [r] device_family
51
+ # @return [String] the device family
19
52
  attr_reader :device_family
20
- attr_reader :simulator_details, :ios_version
53
+
54
+ # @!visibility private
55
+ # @attribute [r] simulator_details
56
+ # @return [String] Additional details about the simulator. If this device
57
+ # is a physical device, returns nil.
58
+ attr_reader :simulator_details
59
+
60
+ # The `major.minor.[.patch]` version of iOS that is running on this device.
61
+ #
62
+ # @example
63
+ # 7.1
64
+ # 6.1.2
65
+ # 5.1.1
66
+ #
67
+ # @attribute [r] ios_version
68
+ # @return [String] the version of the iOS that is running on this device
69
+ attr_reader :ios_version
70
+
71
+ # The hardware architecture of this device. Also known as the chip set.
72
+ #
73
+ # @example
74
+ # # simulator
75
+ # i386
76
+ # x86_64
77
+ #
78
+ # @example
79
+ # # examples from physical devices
80
+ # armv6
81
+ # armv7s
82
+ # arm64
83
+ #
84
+ # @attribute [r] system
85
+ # @return [String] the hardware architecture of this device.
86
+ # this device.
21
87
  attr_reader :system
88
+
89
+ # The version of the embedded Calabash server that is running in the
90
+ # app under test on this device.
91
+ #
92
+ # @example
93
+ # 0.9.168
94
+ # 0.10.0.pre1
95
+ #
96
+ # @attribute [r] server_version
97
+ # @return [String] the major.minor.patch[.pre\d] version of the embedded
98
+ # Calabash server
22
99
  attr_reader :server_version
100
+
101
+ # Indicates whether or not the app under test on this device is an
102
+ # iPhone-only app that is being emulated on an iPad.
103
+ #
104
+ # @note If the `1x` or `2x` button is visible, then the app is being
105
+ # emulated.
106
+ #
107
+ # @attribute [r] iphone_app_emulated_on_ipad
108
+ # @return [Boolean] `true` if the app under test is emulated
23
109
  attr_reader :iphone_app_emulated_on_ipad
110
+
111
+ # Indicates whether or not this device has a 4in screen.
112
+ # @attribute [r] iphone_4in
113
+ # @return [Boolean] `true` if this device has a 4in screen.
24
114
  attr_reader :iphone_4in
25
115
 
116
+ # @deprecated 0.10.0 no replacement
117
+ # @!attribute [rw] udid
118
+ # @return [String] The udid of this device.
26
119
  attr_accessor :udid
27
120
 
121
+ # Creates a new instance of Device.
122
+ #
123
+ # @see Calabash::Cucumber::Core#server_version
124
+ #
125
+ # @param [String] endpoint the http address of this device
126
+ # @param [Hash] version_data the output of the `server_version` function
127
+ # @return [Device] a new Device instance
28
128
  def initialize (endpoint, version_data)
29
129
  simulator_device = version_data['simulator_device']
30
130
  @endpoint = endpoint
@@ -37,35 +137,53 @@ module Calabash
37
137
  @iphone_4in = version_data['4inch']
38
138
  end
39
139
 
140
+ # Is this device a simulator or physical device?
141
+ # @return [Boolean] true if this device is a simulator
40
142
  def simulator?
41
143
  system.eql?(GESTALT_SIM_SYS)
42
144
  end
43
145
 
146
+ # Is this device a device or simulator?
147
+ # @return [Boolean] true if this device is a physical device
44
148
  def device?
45
149
  not simulator?
46
150
  end
47
151
 
152
+ # Is this device an iPhone?
153
+ # @return [Boolean] true if this device is an iphone
48
154
  def iphone?
49
155
  device_family.eql? GESTALT_IPHONE
50
156
  end
51
157
 
158
+ # Is this device an iPod?
159
+ # @return [Boolean] true if this device is an ipod
52
160
  def ipod?
53
161
  device_family.eql? GESTALT_IPOD
54
162
  end
55
163
 
164
+ # Is this device an iPad?
165
+ # @return [Boolean] true if this device is an ipad
56
166
  def ipad?
57
167
  device_family.eql? GESTALT_IPAD
58
168
  end
59
169
 
170
+ # Is this device a 4in iPhone?
171
+ # @return [Boolean] true if this device is a 4in iphone
60
172
  def iphone_4in?
61
173
  @iphone_4in
62
174
  end
63
175
 
176
+ # @deprecated 0.9.168 replaced with iphone_4in?
177
+ # @see #iphone_4in?
178
+ # Is this device an iPhone 5?
179
+ # @note Deprecated because the iPhone 5S reports as an iPhone6,*.
180
+ # @return [Boolean] true if this device is an iPhone 5
64
181
  def iphone_5?
65
182
  _deprecated('0.9.168', "use 'iphone_4in?' instead", :warn)
66
183
  iphone_4in?
67
184
  end
68
185
 
186
+ # @!visibility private
69
187
  def version_hash (version_str)
70
188
  tokens = version_str.split(/[,.]/)
71
189
  {:major_version => tokens[0],
@@ -73,37 +191,76 @@ module Calabash
73
191
  :bug_version => tokens[2]}
74
192
  end
75
193
 
194
+ # The major iOS version of this device.
195
+ # @return [String] the major version of the OS
76
196
  def ios_major_version
77
197
  version_hash(ios_version)[:major_version]
78
198
  end
79
199
 
200
+ # Is this device running iOS 7?
201
+ # @return [Boolean] true if the major version of the OS is 7
80
202
  def ios7?
81
203
  ios_major_version.eql?('7')
82
204
  end
83
205
 
206
+ # Is this device running iOS 6?
207
+ # @return [Boolean] true if the major version of the OS is 6
84
208
  def ios6?
85
209
  ios_major_version.eql?('6')
86
210
  end
87
211
 
212
+ # Is this device running iOS 5?
213
+ # @return [Boolean] true if the major version of the OS is 5
88
214
  def ios5?
89
215
  ios_major_version.eql?('5')
90
216
  end
91
217
 
218
+ # The screen size of the device.
219
+ #
220
+ # @note These values are not dynamically computed; they are constants.
221
+ #
222
+ # @note These values are for portrait or upside orientations
223
+ #
224
+ # @return [Hash] representation of the screen size as a hash with keys
225
+ # `:width` and `:height`
92
226
  def screen_size
93
227
  return { :width => 768, :height => 1024 } if ipad?
94
228
  return { :width => 320, :height => 568 } if iphone_4in?
95
229
  { :width => 320, :height => 480 }
96
230
  end
97
231
 
232
+ # Is the app that is running an iPhone-only app emulated on an iPad?
233
+ #
234
+ # @note If the app is running in emulation mode, there will be a 1x or 2x
235
+ # scale button visible on the iPad.
236
+ #
237
+ # @return [Boolean] true if the app running on this devices is an
238
+ # iPhone-only app emulated on an iPad
98
239
  def iphone_app_emulated_on_ipad?
99
240
  iphone_app_emulated_on_ipad
100
241
  end
101
242
 
243
+ # The version of the embedded Calabash server running in the app under
244
+ # test on this device.
245
+ # @deprecated 0.9.169 replaced with `server_version`
246
+ # @see #server_version
247
+ # @return [String] the version of the embedded Calabash server
102
248
  def framework_version
103
249
  _deprecated('0.9.169', "use 'server_version', instead", :warn)
104
250
  @server_version
105
251
  end
106
252
 
253
+ # @deprecated 0.10.0 no replacement
254
+ def udid
255
+ _deprecated('0.10.0', 'no replacement', :warn)
256
+ @udid
257
+ end
258
+
259
+ # @deprecated 0.10.0 no replacement
260
+ def udid=(value)
261
+ _deprecated('0.10.0', 'no replacement', :warn)
262
+ @udid = value
263
+ end
107
264
  end
108
265
  end
109
266
  end