Module: Calabash::Cucumber::DatePicker
Constant Summary collapse
- RUBY_DATE_AND_TIME_FMT =
equivalent formats for ruby and objc we convert DateTime object to a string and pass the format that objc can use to convert the string into NSDate
'%Y_%m_%d_%H_%M'
- OBJC_DATE_AND_TIME_FMT =
'yyyy_MM_dd_HH_mm'
- UI_DATE_PICKER_MODE_TIME =
picker modes
0
- UI_DATE_PICKER_MODE_DATE =
1
- UI_DATE_PICKER_MODE_DATE_AND_TIME =
2
- UI_DATE_PICKER_MODE_COUNT_DOWN_TIMER =
3
Constants included from PlaybackHelpers
Instance Method Summary collapse
-
#args_for_change_date_on_picker(options) ⇒ Object
changing picker date time.
- #countdown_mode?(picker_id = nil) ⇒ Boolean
- #date_and_time_mode?(picker_id = nil) ⇒ Boolean
- #date_mode?(picker_id = nil) ⇒ Boolean
- #date_picker_mode(picker_id = nil) ⇒ Object
-
#date_time_from_picker(picker_id = nil) ⇒ Object
date time from picker.
-
#maximum_date_time_from_picker(picker_id = nil) ⇒ Object
minimum and maximum dates appledoc ==> The property is an NSDate object or nil (the default), which means no maximum date.
-
#minimum_date_time_from_picker(picker_id = nil) ⇒ Object
appledoc ==> The property is an NSDate object or nil (the default), which means no minimum date.
-
#picker_set_date_time(target_dt, options = {:animate => true, :picker_id => nil, :notify_targets => true}) ⇒ Object
expects a DateTime object notify_targets = true iterates through the target/action pairs and calls performSelector:<action> object:<target> to simulate a UIEvent.
-
#query_string_for_picker(picker_id = nil) ⇒ Object
ensuring picker is visible.
- #should_see_date_picker(picker_id = nil) ⇒ Object
- #time_mode?(picker_id = nil) ⇒ Boolean
Methods included from Core
#backdoor, #calabash_exit, #cell_swipe, #client_version, #console_attach, #double_tap, #extract_query_and_options, #flash, #flick, #launcher, #location_for_place, #locations_for_place, #macro, #move_wheel, #pan, #picker, #pinch, #prepare_query_options, #query, #query_action_with_options, #query_all, #scroll, #scroll_to_cell, #scroll_to_row, #scroll_to_row_with_mark, #send_app_to_background, #server_version, #set_location, #shutdown_test_server, #start_test_server_in_background, #stop_test_server, #swipe, #touch, #touch_hold, #two_finger_tap
Methods included from PlaybackHelpers
#find_compatible_recording, #interpolate, #load_playback_data, #load_recording, #playback, #playback_file_directories, #record_begin, #record_end, #recording_name_for
Methods included from RotationHelpers
#rotate, #rotate_home_button_to, #rotation_candidates
Methods included from StatusBarHelpers
#device_orientation, #landscape?, #portrait?, #status_bar_orientation
Methods included from UIA
#escape_uia_string, #send_uia_command, #uia, #uia_call, #uia_call_method, #uia_double_tap, #uia_double_tap_mark, #uia_double_tap_offset, #uia_element_does_not_exist?, #uia_element_exists?, #uia_enter, #uia_flick_offset, #uia_handle_command, #uia_names, #uia_pan, #uia_pan_offset, #uia_pinch, #uia_pinch_offset, #uia_query, #uia_query_el, #uia_query_windows, #uia_screenshot, #uia_scroll_to, #uia_send_app_to_background, #uia_serialize_argument, #uia_serialize_arguments, #uia_serialize_command, #uia_set_location, #uia_swipe, #uia_swipe_offset, #uia_tap, #uia_tap_mark, #uia_tap_offset, #uia_touch_hold, #uia_touch_hold_offset, #uia_two_finger_tap, #uia_two_finger_tap_offset, #uia_type_string
Methods included from Map
Methods included from FailureHelpers
#fail, #screenshot, #screenshot_and_raise, #screenshot_embed
Methods included from QueryHelpers
Methods included from ConnectionHelpers
Methods included from EnvironmentHelpers
#_deprecated, #debug_logging?, #default_device, #device_family_iphone?, #full_console_logging?, #ios5?, #ios6?, #ios7?, #ipad?, #iphone?, #iphone_4in?, #iphone_5?, #iphone_app_emulated_on_ipad?, #ipod?, #no_deprecation_warnings?, #simulator?, #uia_available?, #uia_not_available?, #xamarin_test_cloud?
Instance Method Details
#args_for_change_date_on_picker(options) ⇒ Object
changing picker date time
109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# File 'lib/calabash-cucumber/date_picker.rb', line 109 def args_for_change_date_on_picker() args = [] if .has_key?(:notify_targets) args << [:notify_targets] ? 1 : 0 else args << 1 end if .has_key?(:animate) args << [:animate] ? 1 : 0 else args << 1 end args end |
#countdown_mode?(picker_id = nil) ⇒ Boolean
42 43 44 |
# File 'lib/calabash-cucumber/date_picker.rb', line 42 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
38 39 40 |
# File 'lib/calabash-cucumber/date_picker.rb', line 38 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
34 35 36 |
# File 'lib/calabash-cucumber/date_picker.rb', line 34 def date_mode?(picker_id=nil) date_picker_mode(picker_id) == UI_DATE_PICKER_MODE_DATE end |
#date_picker_mode(picker_id = nil) ⇒ Object
21 22 23 24 25 26 27 28 |
# File 'lib/calabash-cucumber/date_picker.rb', line 21 def date_picker_mode(picker_id=nil) query_str = should_see_date_picker picker_id res = query(query_str, :datePickerMode) if res.empty? screenshot_and_raise "should be able to get mode from picker with query '#{query_str}'" end res.first end |
#date_time_from_picker(picker_id = nil) ⇒ Object
date time from picker
95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/calabash-cucumber/date_picker.rb', line 95 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) ⇒ Object
minimum and maximum dates appledoc ==> The property is an NSDate object or nil (the default), which means no maximum date.
64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/calabash-cucumber/date_picker.rb', line 64 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) ⇒ Object
appledoc ==> The property is an NSDate object or nil (the default), which means no minimum date.
80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'lib/calabash-cucumber/date_picker.rb', line 80 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
expects a DateTime object notify_targets = true iterates through the target/action pairs and calls performSelector:<action> object:<target> to simulate a UIEvent
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'lib/calabash-cucumber/date_picker.rb', line 128 def picker_set_date_time (target_dt, = {:animate => true, :picker_id => nil, :notify_targets => true}) 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(query_str, :changeDatePickerDate, target_str, fmt_str, *args) if views_touched.empty? or views_touched.member? '<VOID>' screenshot_and_raise "could not change date on picker to '#{target_dt}' using query '#{query_str}' with options '#{}'" end views_touched end |
#query_string_for_picker(picker_id = nil) ⇒ Object
ensuring picker is visible
48 49 50 |
# File 'lib/calabash-cucumber/date_picker.rb', line 48 def query_string_for_picker (picker_id = nil) picker_id.nil? ? 'datePicker' : "datePicker marked:'#{picker_id}'" end |
#should_see_date_picker(picker_id = nil) ⇒ Object
52 53 54 55 56 57 58 |
# File 'lib/calabash-cucumber/date_picker.rb', line 52 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
30 31 32 |
# File 'lib/calabash-cucumber/date_picker.rb', line 30 def time_mode?(picker_id=nil) date_picker_mode(picker_id) == UI_DATE_PICKER_MODE_TIME end |