Module: Calabash::Cucumber::DatePicker
Overview
A collection of methods for interacting with UIDatePicker
Instance Method Summary collapse
-
#countdown_mode?(picker_id = nil) ⇒ Boolean
Is the date picker in countdown mode?.
-
#date_and_time_mode?(picker_id = nil) ⇒ Boolean
Is the date picker in date and time mode?.
-
#date_mode?(picker_id = nil) ⇒ Boolean
Is the date picker in date mode?.
-
#date_time_from_picker(picker_id = nil) ⇒ DateTime
Returns the date and time from the picker.
-
#maximum_date_time_from_picker(picker_id = nil) ⇒ DateTime
The maximum date for a picker.
-
#minimum_date_time_from_picker(picker_id = nil) ⇒ DateTime
The minimum date for a picker.
-
#picker_set_date_time(target_dt, options = {:animate => true, :picker_id => nil, :notify_targets => true}) ⇒ Object
Sets the date and time on picker.
-
#should_see_date_picker(picker_id = nil) ⇒ Object
Asserts that a date picker is visible.
-
#time_mode?(picker_id = nil) ⇒ Boolean
Is the date picker in time mode?.
Methods included from Core
#await_page, #backdoor, #calabash_exit, #calabash_info, #calabash_warn, #clear_text, #client_version, #console_attach, #deprecated, #device_agent, #dismiss_ipad_keyboard, #double_tap, #flash, #flick, #html, #identifier, #keyboard_enter_char, #keyboard_enter_text, #label, #location_for_place, #page, #pan, #pan_coordinates, #pinch, #query, #rotate, #rotate_home_button_to, #scroll, #scroll_to_cell, #scroll_to_collection_view_item, #scroll_to_collection_view_item_with_mark, #scroll_to_mark, #scroll_to_row, #scroll_to_row_with_mark, #send_app_to_background, #server_log_level, #server_version, #set_location, #set_server_log_level, #set_text, #set_user_pref, #shake, #slider_set_value, #start_test_server_in_background, #swipe, #tap_keyboard_action_key, #tap_keyboard_delete_key, #tap_mark, #tap_point, #touch, #touch_hold, #two_finger_tap, #user_pref
Methods included from KeyboardHelpers
#docked_keyboard_visible?, #keyboard_visible?, #lookup_key_name, #split_keyboard_visible?, #undocked_keyboard_visible?, #wait_for_keyboard, #wait_for_no_keyboard
Methods included from StatusBarHelpers
#device_orientation, #landscape?, #portrait?, #status_bar_details, #status_bar_orientation
Methods included from UIA
#uia, #uia_call, #uia_call_windows, #uia_keyboard_visible?, #uia_names, #uia_orientation, #uia_query, #uia_query_windows, #uia_rotate, #uia_rotate_home_button_to, #uia_set_responder_value, #uia_wait_for_keyboard
Methods included from FailureHelpers
#fail, #screenshot, #screenshot_and_raise, #screenshot_embed
Methods included from QueryHelpers
#escape_backslashes, #escape_newlines, #escape_quotes, #escape_string
Methods included from EnvironmentHelpers
#default_device, #device_family_iphone?, #ios10?, #ios11?, #ios5?, #ios6?, #ios7?, #ios8?, #ios9?, #ios_gte_11?, #ios_version, #ipad?, #ipad_pro?, #iphone?, #iphone_35in?, #iphone_4in?, #iphone_6?, #iphone_6_plus?, #iphone_app_emulated_on_ipad?, #ipod?, #screen_dimensions, #simulator?, #uia_available?, #uia_not_available?, #xamarin_test_cloud?
Instance Method Details
#countdown_mode?(picker_id = nil) ⇒ Boolean
Is the date picker in countdown mode?
115 116 117 |
# File 'lib/calabash-cucumber/date_picker.rb', line 115 def countdown_mode?(picker_id=nil) date_picker_mode(picker_id) == UI_DATE_PICKER_MODE_COUNT_DOWN_TIMER end |
#date_and_time_mode?(picker_id = nil) ⇒ Boolean
Is the date picker in date and time mode?
99 100 101 |
# File 'lib/calabash-cucumber/date_picker.rb', line 99 def date_and_time_mode?(picker_id=nil) date_picker_mode(picker_id) == UI_DATE_PICKER_MODE_DATE_AND_TIME end |
#date_mode?(picker_id = nil) ⇒ Boolean
Is the date picker in date mode?
83 84 85 |
# File 'lib/calabash-cucumber/date_picker.rb', line 83 def date_mode?(picker_id=nil) date_picker_mode(picker_id) == UI_DATE_PICKER_MODE_DATE end |
#date_time_from_picker(picker_id = nil) ⇒ DateTime
Returns the date and time from the picker.
208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/calabash-cucumber/date_picker.rb', line 208 def date_time_from_picker (picker_id=nil) if countdown_mode? picker_id screenshot_and_raise 'method is not available for pickers that are not in date or date time mode' end query_str = query_string_for_picker picker_id res = query(query_str, :date) if res.empty? screenshot_and_raise "should be able to get date from picker with query '#{query_str}'" end DateTime.parse(res.first) end |
#maximum_date_time_from_picker(picker_id = nil) ⇒ DateTime
From the Apple docs: ‘The property is an NSDate object or nil (the default)`.
The maximum date for a picker. If there is no maximum date, this method returns nil.
158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'lib/calabash-cucumber/date_picker.rb', line 158 def maximum_date_time_from_picker (picker_id = nil) if countdown_mode? picker_id screenshot_and_raise 'method is not available for pickers that are not in date or date time mode' end query_str = should_see_date_picker picker_id res = query(query_str, :maximumDate) if res.empty? screenshot_and_raise "should be able to get max date from picker with query '#{query_str}'" end return nil if res.first.nil? DateTime.parse(res.first) end |
#minimum_date_time_from_picker(picker_id = nil) ⇒ DateTime
From the Apple docs: ‘The property is an NSDate object or nil (the default)`.
The minimum date for a picker. If there is no minimum date, this method returns nil.
186 187 188 189 190 191 192 193 194 195 196 197 198 |
# File 'lib/calabash-cucumber/date_picker.rb', line 186 def minimum_date_time_from_picker (picker_id = nil) if countdown_mode? picker_id screenshot_and_raise 'method is not available for pickers that are not in date or date time mode' end query_str = should_see_date_picker picker_id res = query(query_str, :minimumDate) if res.empty? screenshot_and_raise "should be able to get min date from picker with query '#{query_str}'" end return nil if res.first.nil? DateTime.parse(res.first) end |
#picker_set_date_time(target_dt, options = {:animate => true, :picker_id => nil, :notify_targets => true}) ⇒ Object
replace ‘args_for_change_date_on_picker` with hash table `merge`
When ‘:notify_targets => true` this operation iterates through the target/action pairs on the objc `UIDatePicker` instance and calls
Sets the date and time on picker.
‘performSelector:<action> object:<target>`. This has the effect of
generating `UIEvents`.
265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 |
# File 'lib/calabash-cucumber/date_picker.rb', line 265 def picker_set_date_time (target_dt, = {:animate => true, :picker_id => nil, :notify_targets => true}) unless target_dt.is_a?(DateTime) raise "target_dt must be a DateTime but found '#{target_dt.class}'" end picker_id = == nil ? nil : [:picker_id] if time_mode?(picker_id) == UI_DATE_PICKER_MODE_COUNT_DOWN_TIMER pending('picker is in count down mode which is not yet supported') end target_str = target_dt.strftime(RUBY_DATE_AND_TIME_FMT).squeeze(' ').strip fmt_str = OBJC_DATE_AND_TIME_FMT args = args_for_change_date_on_picker query_str = query_string_for_picker picker_id views_touched = Map.map(query_str, :changeDatePickerDate, target_str, fmt_str, *args) msg = "could not change date on picker to '#{target_dt}' using query '#{query_str}' with options '#{}'" Map.assert_map_results(views_touched,msg) views_touched end |
#should_see_date_picker(picker_id = nil) ⇒ Object
Asserts that a date picker is visible.
136 137 138 139 140 141 142 |
# File 'lib/calabash-cucumber/date_picker.rb', line 136 def should_see_date_picker (picker_id=nil) query_str = query_string_for_picker picker_id if query(query_str).empty? screenshot_and_raise "should see picker with query '#{query_str}'" end query_str end |
#time_mode?(picker_id = nil) ⇒ Boolean
Is the date picker in time mode?
67 68 69 |
# File 'lib/calabash-cucumber/date_picker.rb', line 67 def time_mode?(picker_id=nil) date_picker_mode(picker_id) == UI_DATE_PICKER_MODE_TIME end |