briar 0.0.7 → 0.0.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/Rakefile +6 -11
- data/bin/briar +58 -0
- data/bin/briar_helpers.rb +28 -2
- data/briar.gemspec +3 -2
- data/features/step_definitions/alerts_and_sheets/action_sheet_steps.rb +10 -4
- data/features/step_definitions/alerts_and_sheets/alert_view_steps.rb +3 -10
- data/features/step_definitions/bars/navbar_steps.rb +1 -9
- data/features/step_definitions/bars/tabbar_steps.rb +2 -4
- data/features/step_definitions/bars/toolbar_steps.rb +2 -11
- data/features/step_definitions/control/button_steps.rb +3 -8
- data/features/step_definitions/control/segmented_control_steps.rb +20 -58
- data/features/step_definitions/email_steps.rb +10 -7
- data/features/step_definitions/keyboard_steps.rb +7 -2
- data/features/step_definitions/picker/date_picker_steps.rb +21 -177
- data/features/step_definitions/table_steps.rb +35 -71
- data/features/step_definitions/text_field_steps.rb +1 -5
- data/features/step_definitions/text_view_steps.rb +2 -2
- data/install-calabash-framework.sh.example +10 -0
- data/lib/briar.rb +31 -5
- data/lib/briar/alerts_and_sheets/action_sheet.rb +99 -0
- data/lib/briar/alerts_and_sheets/alert_view.rb +25 -4
- data/lib/briar/bars/navbar.rb +30 -19
- data/lib/briar/bars/tabbar.rb +7 -4
- data/lib/briar/bars/toolbar.rb +14 -1
- data/lib/briar/briar_core.rb +46 -15
- data/lib/briar/control/button.rb +35 -1
- data/lib/briar/control/segmented_control.rb +69 -8
- data/lib/briar/control/slider.rb +2 -2
- data/lib/briar/cucumber.rb +3 -1
- data/lib/briar/email.rb +19 -13
- data/lib/briar/keyboard.rb +50 -10
- data/lib/briar/label.rb +20 -0
- data/lib/briar/picker/date_picker.rb +88 -584
- data/lib/briar/picker/date_picker_core.rb +293 -0
- data/lib/briar/picker/date_picker_manipulation.rb +255 -0
- data/lib/briar/picker/picker.rb +10 -0
- data/lib/briar/table.rb +261 -93
- data/lib/briar/version.rb +1 -1
- data/spec/spec_helper.rb +0 -2
- metadata +14 -13
- data/lib/briar/gestalt.rb +0 -87
- data/spec/briar/gestalt_spec.rb +0 -66
@@ -0,0 +1,293 @@
|
|
1
|
+
UIDatePickerModeTime = 0
|
2
|
+
UIDatePickerModeDate = 1
|
3
|
+
UIDatePickerModeDateAndTime = 2
|
4
|
+
UIDatePickerModeCountDownTimer = 3
|
5
|
+
|
6
|
+
# most locales and situations prefer _not_ to have leading zeros on hours in 24h
|
7
|
+
# see usage below to find out when and if the zeros are stripped
|
8
|
+
BRIAR_PICKER_24H_TIME_FMT = '%H:%M'
|
9
|
+
BRIAR_PICKER_12H_TIME_FMT = '%l:%M %p'
|
10
|
+
|
11
|
+
BRIAR_TIME_FORMATS = {:h24 => BRIAR_PICKER_24H_TIME_FMT,
|
12
|
+
:h12 => BRIAR_PICKER_12H_TIME_FMT}
|
13
|
+
|
14
|
+
BRIAR_REMOVE_LEADING_ZERO_REGEX = /\A^0/
|
15
|
+
|
16
|
+
# 24h locales - Fri 16 Nov - 24h locales
|
17
|
+
BRIAR_PICKER_24H_BRIEF_DATE_FMT = '%a %e %b'
|
18
|
+
# common format for US Fri Nov 16
|
19
|
+
BRIAR_PICKER_12H_BRIEF_DATE_FMT = '%a %b %e'
|
20
|
+
|
21
|
+
BRIAR_DATE_FORMATS = {:brief_24h => BRIAR_PICKER_24H_BRIEF_DATE_FMT,
|
22
|
+
:brief_12h => BRIAR_PICKER_12H_BRIEF_DATE_FMT}
|
23
|
+
|
24
|
+
|
25
|
+
module Briar
|
26
|
+
module Picker
|
27
|
+
module DateCore
|
28
|
+
|
29
|
+
def query_string_for_picker (picker_id = nil)
|
30
|
+
picker_id.nil? ? 'datePicker' : "datePicker marked:'#{picker_id}'"
|
31
|
+
end
|
32
|
+
|
33
|
+
def should_see_date_picker (picker_id=nil)
|
34
|
+
query_str = query_string_for_picker picker_id
|
35
|
+
if query(query_str).empty?
|
36
|
+
screenshot_and_raise "should see picker with query '#{query_str}'"
|
37
|
+
end
|
38
|
+
query_str
|
39
|
+
end
|
40
|
+
|
41
|
+
def ruby_time_from_picker (options = {:picker_id => nil,
|
42
|
+
:convert_time_to_utc => false})
|
43
|
+
picker_id = picker_id_from_options options
|
44
|
+
|
45
|
+
if picker_is_in_countdown_mode picker_id
|
46
|
+
screenshot_and_raise 'method is not available for pickers that are not in date or date time mode'
|
47
|
+
end
|
48
|
+
query_str = should_see_date_picker picker_id
|
49
|
+
res = query(query_str, :date)
|
50
|
+
if res.empty?
|
51
|
+
screenshot_and_raise "should be able to get date from picker with query '#{query_str}'"
|
52
|
+
end
|
53
|
+
|
54
|
+
rdt = DateTime.parse(res.first)
|
55
|
+
convert = convert_to_utc_from_options options
|
56
|
+
if convert
|
57
|
+
rdt.to_time.utc
|
58
|
+
else
|
59
|
+
rdt.to_time
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
|
64
|
+
# appledoc ==> The property is an NSDate object or nil (the default),
|
65
|
+
# which means no maximum date.
|
66
|
+
def picker_maximum_date_time (picker_id = nil)
|
67
|
+
if picker_is_in_countdown_mode picker_id
|
68
|
+
screenshot_and_raise 'method is not available for pickers that are not in date or date time mode'
|
69
|
+
end
|
70
|
+
|
71
|
+
query_str = should_see_date_picker picker_id
|
72
|
+
res = query(query_str, :maximumDate)
|
73
|
+
if res.empty?
|
74
|
+
screenshot_and_raise "should be able to get max date from picker with query '#{query_str}'"
|
75
|
+
end
|
76
|
+
return nil if res.first.nil?
|
77
|
+
DateTime.parse(res.first)
|
78
|
+
end
|
79
|
+
|
80
|
+
# appledoc ==> The property is an NSDate object or nil (the default),
|
81
|
+
# which means no minimum date.
|
82
|
+
def picker_minimum_date_time (picker_id = nil)
|
83
|
+
if picker_is_in_countdown_mode picker_id
|
84
|
+
screenshot_and_raise 'method is not available for pickers that are not in date or date time mode'
|
85
|
+
end
|
86
|
+
|
87
|
+
query_str = should_see_date_picker picker_id
|
88
|
+
res = query(query_str, :minimumDate)
|
89
|
+
if res.empty?
|
90
|
+
screenshot_and_raise "should be able to get min date from picker with query '#{query_str}'"
|
91
|
+
end
|
92
|
+
return nil if res.first.nil?
|
93
|
+
DateTime.parse(res.first)
|
94
|
+
end
|
95
|
+
|
96
|
+
def picker_mode(picker_id=nil)
|
97
|
+
query_str = should_see_date_picker picker_id
|
98
|
+
res = query(query_str, :datePickerMode)
|
99
|
+
if res.empty?
|
100
|
+
screenshot_and_raise "should be able to get mode from picker with query '#{query_str}'"
|
101
|
+
end
|
102
|
+
res.first
|
103
|
+
end
|
104
|
+
|
105
|
+
def picker_is_in_time_mode(picker_id=nil)
|
106
|
+
picker_mode(picker_id) == UIDatePickerModeTime
|
107
|
+
end
|
108
|
+
|
109
|
+
def picker_is_in_date_mode(picker_id=nil)
|
110
|
+
picker_mode(picker_id) == UIDatePickerModeDate
|
111
|
+
end
|
112
|
+
|
113
|
+
def picker_is_in_date_and_time_mode(picker_id=nil)
|
114
|
+
picker_mode(picker_id) == UIDatePickerModeDateAndTime
|
115
|
+
end
|
116
|
+
|
117
|
+
def picker_is_in_countdown_mode(picker_id=nil)
|
118
|
+
picker_mode(picker_id) == UIDatePickerModeCountDownTimer
|
119
|
+
end
|
120
|
+
|
121
|
+
def picker_id_from_options (options={:picker_id => nil})
|
122
|
+
options == nil ? nil : options[:picker_id]
|
123
|
+
end
|
124
|
+
|
125
|
+
def convert_to_utc_from_options(options={:convert_time_to_utc => false})
|
126
|
+
return false if options.nil?
|
127
|
+
return false if not options.has_key?(:convert_time_to_utc)
|
128
|
+
options[:convert_time_to_utc]
|
129
|
+
end
|
130
|
+
|
131
|
+
# apple docs
|
132
|
+
# You can use this property to set the interval displayed by the minutes wheel
|
133
|
+
# (for example, 15 minutes). The interval value must be evenly divided into 60;
|
134
|
+
# if it is not, the default value is used. The default and minimum values are 1;
|
135
|
+
# the maximum value is 30.
|
136
|
+
def picker_minute_interval(picker_id = nil)
|
137
|
+
screenshot_and_raise 'there is no minute in date mode' if picker_is_in_date_mode
|
138
|
+
query_str = should_see_date_picker picker_id
|
139
|
+
res = query(query_str, :minuteInterval)
|
140
|
+
if res.empty?
|
141
|
+
screenshot_and_raise "should be able to get minute interval from picker with '#{query_str}'"
|
142
|
+
end
|
143
|
+
@picker_minute_interval = res.first
|
144
|
+
end
|
145
|
+
|
146
|
+
# funky little bugger - used to change a picker to the nearest minute
|
147
|
+
# based on the minute interval
|
148
|
+
def time_hash_by_add_minutes_until_at_closest_interval (time_str, interval=picker_minute_interval())
|
149
|
+
screenshot_and_raise "interval '#{interval}' is not on (0, 59) which is not allowed" unless (0..59).member?(interval)
|
150
|
+
time = Time.parse(time_str)
|
151
|
+
# normalize to zero
|
152
|
+
time = time - time.sec
|
153
|
+
minute = time.min
|
154
|
+
count = 0
|
155
|
+
unless (minute % interval) == 0
|
156
|
+
begin
|
157
|
+
minute = (minute > 59) ? 0 : minute + 1
|
158
|
+
count = count + 1
|
159
|
+
end
|
160
|
+
end while ((minute % interval) != 0)
|
161
|
+
time = time + (count * 60)
|
162
|
+
|
163
|
+
{:h12 => time.strftime(BRIAR_PICKER_12H_TIME_FMT).squeeze(' ').strip,
|
164
|
+
:h24 => time.strftime(BRIAR_PICKER_24H_TIME_FMT).squeeze(' ').strip.sub(BRIAR_REMOVE_LEADING_ZERO_REGEX, ''),
|
165
|
+
:time => time}
|
166
|
+
end
|
167
|
+
|
168
|
+
|
169
|
+
# is the picker in 12h or 24h mode
|
170
|
+
def picker_column_for_period(picker_id = nil)
|
171
|
+
if picker_is_in_date_mode picker_id or picker_is_in_countdown_mode picker_id
|
172
|
+
screenshot_and_raise '12h/24h mode is not applicable to this mode'
|
173
|
+
end
|
174
|
+
picker_is_in_time_mode ? 2 : 3
|
175
|
+
end
|
176
|
+
|
177
|
+
# 12h or 24h locale
|
178
|
+
def picker_is_in_12h_locale(picker_id = nil)
|
179
|
+
if picker_is_in_date_mode picker_id or picker_is_in_countdown_mode picker_id
|
180
|
+
screenshot_and_raise '12h/24h mode is not applicable to this mode'
|
181
|
+
end
|
182
|
+
|
183
|
+
column = picker_column_for_period(picker_id=nil)
|
184
|
+
!query("pickerTableView index:#{column}").empty?
|
185
|
+
end
|
186
|
+
|
187
|
+
def picker_is_in_24h_locale(picker_id=nil)
|
188
|
+
if picker_is_in_date_mode picker_id or picker_is_in_countdown_mode picker_id
|
189
|
+
screenshot_and_raise '12h/24h mode is not applicable to this mode'
|
190
|
+
end
|
191
|
+
!picker_is_in_12h_locale picker_id
|
192
|
+
end
|
193
|
+
|
194
|
+
# get the times off the picker in 12h and 24h format
|
195
|
+
def picker_time_str(format_key, options={:picker_id => nil,
|
196
|
+
:convert_time_to_utc => false})
|
197
|
+
picker_id = picker_id_from_options options
|
198
|
+
|
199
|
+
if picker_is_in_date_mode picker_id or picker_is_in_countdown_mode picker_id
|
200
|
+
screenshot_and_raise 'the time is not applicable for this mode'
|
201
|
+
end
|
202
|
+
format = BRIAR_TIME_FORMATS[format_key]
|
203
|
+
unless format
|
204
|
+
screenshot_and_raise "format '#{format_key}' was not one of '#{BRIAR_TIME_FORMATS}'"
|
205
|
+
end
|
206
|
+
|
207
|
+
time = ruby_time_from_picker options
|
208
|
+
time.strftime(format).strip.sub(BRIAR_REMOVE_LEADING_ZERO_REGEX, '')
|
209
|
+
end
|
210
|
+
|
211
|
+
|
212
|
+
def picker_time_strs_hash(options={:picker_id => nil,
|
213
|
+
:convert_time_to_utc => false})
|
214
|
+
picker_id = picker_id_from_options options
|
215
|
+
if picker_is_in_date_mode picker_id or picker_is_in_countdown_mode picker_id
|
216
|
+
screenshot_and_raise 'the time is not applicable for this mode'
|
217
|
+
end
|
218
|
+
|
219
|
+
{:h24 => picker_time_str(:h24, options),
|
220
|
+
:h12 => picker_time_str(:h12, options)}
|
221
|
+
end
|
222
|
+
|
223
|
+
def picker_time_strs_arr(options={:picker_id => nil,
|
224
|
+
:convert_time_to_utc => false})
|
225
|
+
picker_id = picker_id_from_options options
|
226
|
+
if picker_is_in_date_mode picker_id or picker_is_in_countdown_mode picker_id
|
227
|
+
screenshot_and_raise 'the time is not applicable for this mode'
|
228
|
+
end
|
229
|
+
[picker_time_str(:h24, options), picker_time_str(:h12, options)]
|
230
|
+
end
|
231
|
+
|
232
|
+
def picker_brief_date_str(format_key, options={:picker_id => nil,
|
233
|
+
:convert_time_to_utc => false})
|
234
|
+
picker_id = picker_id_from_options options
|
235
|
+
if picker_is_in_countdown_mode picker_id
|
236
|
+
screenshot_and_raise 'date is not applicable for this mode'
|
237
|
+
end
|
238
|
+
format = BRIAR_DATE_FORMATS[format_key]
|
239
|
+
unless format
|
240
|
+
screenshot_and_raise "format '#{format_key}' is not one of '#{BRIAR_DATE_FORMATS.keys}'"
|
241
|
+
end
|
242
|
+
time = ruby_time_from_picker options
|
243
|
+
time.strftime(format).strip.squeeze(' ')
|
244
|
+
end
|
245
|
+
|
246
|
+
def picker_brief_date_strs_hash(options={:picker_id => nil,
|
247
|
+
:convert_time_to_utc => false})
|
248
|
+
picker_id = picker_id_from_options options
|
249
|
+
if picker_is_in_countdown_mode picker_id
|
250
|
+
screenshot_and_raise 'date is not applicable for this mode'
|
251
|
+
end
|
252
|
+
{:brief_24h => picker_brief_date_str(:brief_24h, options),
|
253
|
+
:brief_12h => picker_brief_date_str(:brief_12h, options)}
|
254
|
+
end
|
255
|
+
|
256
|
+
def picker_brief_date_strs_arr(options={:picker_id => nil,
|
257
|
+
:convert_time_to_utc => false})
|
258
|
+
picker_id = picker_id_from_options options
|
259
|
+
if picker_is_in_countdown_mode picker_id
|
260
|
+
screenshot_and_raise 'date is not applicable for this mode'
|
261
|
+
end
|
262
|
+
[picker_brief_date_str(:brief_24h, options), picker_brief_date_str(:brief_12h, options)]
|
263
|
+
end
|
264
|
+
|
265
|
+
|
266
|
+
def now_times_map
|
267
|
+
utc = Time.now.utc
|
268
|
+
now = Time.now
|
269
|
+
|
270
|
+
{:h12 => now.strftime(BRIAR_PICKER_12H_TIME_FMT).squeeze(' ').strip,
|
271
|
+
:h24 => now.strftime(BRIAR_PICKER_24H_TIME_FMT).squeeze(' ').strip.sub(BRIAR_REMOVE_LEADING_ZERO_REGEX, ''),
|
272
|
+
:h12_utc => utc.strftime(BRIAR_PICKER_12H_TIME_FMT).squeeze(' ').strip,
|
273
|
+
:h24_utc => utc.strftime(BRIAR_PICKER_24H_TIME_FMT).squeeze(' ').strip.sub(BRIAR_REMOVE_LEADING_ZERO_REGEX, ''),
|
274
|
+
:utc => utc,
|
275
|
+
:time => now}
|
276
|
+
end
|
277
|
+
|
278
|
+
def now_time_24h_locale
|
279
|
+
now_times_map[:h24]
|
280
|
+
end
|
281
|
+
|
282
|
+
def now_time_12h_locale
|
283
|
+
now_times_map[:h12]
|
284
|
+
end
|
285
|
+
|
286
|
+
def now_times_arr
|
287
|
+
[now_time_24h_locale, now_time_12h_locale]
|
288
|
+
end
|
289
|
+
|
290
|
+
|
291
|
+
end
|
292
|
+
end
|
293
|
+
end
|
@@ -0,0 +1,255 @@
|
|
1
|
+
require 'date'
|
2
|
+
|
3
|
+
=begin
|
4
|
+
|
5
|
+
change_picker_date_time (target_dt, options)
|
6
|
+
|
7
|
+
change_time_on_picker_with_time_str (time_str, options)
|
8
|
+
change_time_on_picker_with_time (time, options)
|
9
|
+
|
10
|
+
change_date_on_picker_with_date_str (date_str, options)
|
11
|
+
change_date_on_picker_with_date (date, options)
|
12
|
+
|
13
|
+
|
14
|
+
options ==>
|
15
|
+
{
|
16
|
+
# calabash returns dates in terms of the local timezone
|
17
|
+
# sometimes you have pickers (like alarms or reminders) that use utc timezone
|
18
|
+
# WARN: only set this if you need times converted to UTC - if you are in UTC
|
19
|
+
# timezone, don't set this
|
20
|
+
:convert_time_to_utc => false,
|
21
|
+
# animat the change
|
22
|
+
:animate => true,
|
23
|
+
# optionally pass the picker id
|
24
|
+
:picker_id => nil,
|
25
|
+
# iterate over the picker's target/action pairs and call them using
|
26
|
+
# performSelector:SEL object:<picker>
|
27
|
+
:notify_targets => true
|
28
|
+
}
|
29
|
+
|
30
|
+
=end
|
31
|
+
|
32
|
+
BRIAR_PICKER_ISO8601_TIME_FMT = '%H:%M'
|
33
|
+
|
34
|
+
# our canonical format for testing if two dates are the same
|
35
|
+
BRIAR_PICKER_ISO8601_BRIEF_DATE_FMT = '%Y-%m-%d'
|
36
|
+
BRIAR_PICKER_ISO8601_BRIEF_DATE_TIME_FMT = '%Y-%m-%d %H:%M'
|
37
|
+
|
38
|
+
# ex. 2012_11_18_16_45
|
39
|
+
BRIAR_PICKER_RUBY_DATE_AND_TIME_FMT_ZONED = '%Y_%m_%d_%H_%M_%z'
|
40
|
+
BRIAR_PICKER_OBJC_DATE_AND_TIME_FMT_ZONED = 'yyyy_MM_dd_HH_mm_Z'
|
41
|
+
BRIAR_PICKER_RUBY_DATE_AND_TIME_FMT = '%Y_%m_%d_%H_%M'
|
42
|
+
BRIAR_PICKER_OBJC_DATE_AND_TIME_FMT = 'yyyy_MM_dd_HH_mm'
|
43
|
+
|
44
|
+
BRIAR_DATE_CONVERSION_FORMATS = {:objc => {:zoned => BRIAR_PICKER_OBJC_DATE_AND_TIME_FMT_ZONED,
|
45
|
+
:default => BRIAR_PICKER_OBJC_DATE_AND_TIME_FMT},
|
46
|
+
:ruby => {:zoned => BRIAR_PICKER_RUBY_DATE_AND_TIME_FMT_ZONED,
|
47
|
+
:default => BRIAR_PICKER_RUBY_DATE_AND_TIME_FMT}}
|
48
|
+
|
49
|
+
module Briar
|
50
|
+
module Picker
|
51
|
+
module DateManipulation
|
52
|
+
include Briar::Picker::DateCore
|
53
|
+
|
54
|
+
def date_format_for_target (target, zoned)
|
55
|
+
res = BRIAR_DATE_CONVERSION_FORMATS[target][zoned]
|
56
|
+
if res.nil?
|
57
|
+
screenshot_and_raise "could not find format for target '#{target}' and zone '#{zoned}'"
|
58
|
+
end
|
59
|
+
res
|
60
|
+
end
|
61
|
+
|
62
|
+
def convert_date_time_to_objc_fmt (date_time, convert=false)
|
63
|
+
format = date_format_for_target(:ruby, convert ? :zoned : :default)
|
64
|
+
date_time.strftime(format).squeeze(' ').strip
|
65
|
+
end
|
66
|
+
|
67
|
+
def args_for_change_date_on_picker(options)
|
68
|
+
args = []
|
69
|
+
if options.has_key?(:notify_targets)
|
70
|
+
args << options[:notify_targets] ? 1 : 0
|
71
|
+
else
|
72
|
+
args << 1
|
73
|
+
end
|
74
|
+
|
75
|
+
if options.has_key?(:animate)
|
76
|
+
args << options[:animate] ? 1 : 0
|
77
|
+
else
|
78
|
+
args << 1
|
79
|
+
end
|
80
|
+
args
|
81
|
+
end
|
82
|
+
|
83
|
+
def target_date_for_change_time_on_picker_with_time_str(time_str, convert, picker_id=nil)
|
84
|
+
if time_str.nil? || time_str.length == 0
|
85
|
+
screenshot_and_raise "time str '#{time_str}' must be non-nil and non-empty"
|
86
|
+
end
|
87
|
+
time = Time.parse(time_str)
|
88
|
+
target_date_for_change_time_on_picker_with_time time, convert, picker_id
|
89
|
+
end
|
90
|
+
|
91
|
+
def target_date_for_change_time_on_picker_with_time(target_time, convert, picker_id=nil)
|
92
|
+
current_time = ruby_time_from_picker picker_id
|
93
|
+
tz_offset = convert ? 0 : (current_time.gmt_offset/3600)/12
|
94
|
+
DateTime.new(current_time.year, current_time.mon, current_time.day,
|
95
|
+
target_time.hour, target_time.min,
|
96
|
+
0, tz_offset)
|
97
|
+
end
|
98
|
+
|
99
|
+
|
100
|
+
def target_date_for_change_date_on_picker_with_date_str(date_str, picker_id=nil)
|
101
|
+
if date_str.nil? || date_str.length == 0
|
102
|
+
screenshot_and_raise "date str '#{date_str}' must be non-nil and non-empty"
|
103
|
+
end
|
104
|
+
date = Date.parse(date_str)
|
105
|
+
target_date_for_change_date_on_picker_with_date date, picker_id
|
106
|
+
end
|
107
|
+
|
108
|
+
def target_date_for_change_date_on_picker_with_date(target_date, picker_id=nil)
|
109
|
+
current_time = ruby_time_from_picker picker_id
|
110
|
+
DateTime.new(target_date.year, target_date.mon, target_date.day,
|
111
|
+
current_time.hour, current_time.min, 0, current_time.offset)
|
112
|
+
end
|
113
|
+
|
114
|
+
|
115
|
+
# pickers that use utc (reminders, alerts, etc. do no usually have
|
116
|
+
# min/max dates
|
117
|
+
def ensure_can_change_picker_to_date(target_dt, picker_id=nil)
|
118
|
+
max_date = picker_maximum_date_time picker_id
|
119
|
+
if max_date and target_dt > max_date
|
120
|
+
p "target: '#{target_dt}'"
|
121
|
+
p " max: '#{max_date}'"
|
122
|
+
screenshot_and_raise "cannot change time to '#{target_dt}' because the picker has a maximum date of '#{max_date}'"
|
123
|
+
end
|
124
|
+
|
125
|
+
min_date = picker_minimum_date_time picker_id
|
126
|
+
if min_date and target_dt < min_date
|
127
|
+
p "target: '#{target_dt}'"
|
128
|
+
p " min: '#{min_date}'"
|
129
|
+
screenshot_and_raise "cannot change time to #{target_dt} because the picker has a minimum date of '#{min_date}'"
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
|
134
|
+
def change_picker_date_time (target_dt, options = {:convert_time_to_utc => false,
|
135
|
+
:animate => true,
|
136
|
+
:picker_id => nil,
|
137
|
+
:notify_targets => true})
|
138
|
+
|
139
|
+
picker_id = picker_id_from_options options
|
140
|
+
unless picker_is_in_time_mode picker_id or picker_is_in_date_and_time_mode picker_id
|
141
|
+
screenshot_and_raise 'picker is not in date time or time mode'
|
142
|
+
end
|
143
|
+
|
144
|
+
should_see_date_picker picker_id
|
145
|
+
|
146
|
+
convert = convert_to_utc_from_options options
|
147
|
+
|
148
|
+
ensure_can_change_picker_to_date target_dt, picker_id
|
149
|
+
|
150
|
+
target_str = convert_date_time_to_objc_fmt target_dt, convert
|
151
|
+
fmt_str = date_format_for_target(:objc, convert ? :zoned : :default)
|
152
|
+
|
153
|
+
args = args_for_change_date_on_picker options
|
154
|
+
query_str = query_string_for_picker picker_id
|
155
|
+
|
156
|
+
views_touched = map(query_str, :changeDatePickerDate, target_str, fmt_str, *args)
|
157
|
+
|
158
|
+
if views_touched.empty? or views_touched.member? '<VOID>'
|
159
|
+
screenshot_and_raise "could not change date on picker to '#{target_dt}' using query '#{query_str}' with options '#{options}'"
|
160
|
+
end
|
161
|
+
|
162
|
+
set_briar_date_picker_variables target_dt, options
|
163
|
+
|
164
|
+
step_pause
|
165
|
+
views_touched
|
166
|
+
end
|
167
|
+
|
168
|
+
def change_time_on_picker_with_time_str (time_str, options = {:convert_time_to_utc => false,
|
169
|
+
:animate => true,
|
170
|
+
:picker_id => nil,
|
171
|
+
:notify_targets => true})
|
172
|
+
convert = convert_to_utc_from_options options
|
173
|
+
picker_id = picker_id_from_options options
|
174
|
+
target_dt = target_date_for_change_time_on_picker_with_time_str time_str, convert, picker_id
|
175
|
+
change_picker_date_time target_dt, options
|
176
|
+
end
|
177
|
+
|
178
|
+
|
179
|
+
def change_time_on_picker_with_time (time, options = {:convert_time_to_utc => false,
|
180
|
+
:animate => true,
|
181
|
+
:picker_id => nil,
|
182
|
+
:notify_targets => true})
|
183
|
+
convert = convert_to_utc_from_options options
|
184
|
+
picker_id = picker_id_from_options options
|
185
|
+
target_dt = target_date_for_change_time_on_picker_with_time time, convert, picker_id
|
186
|
+
change_picker_date_time target_dt, options
|
187
|
+
end
|
188
|
+
|
189
|
+
def change_date_on_picker_with_date_str (date_str, options = {:animate => true,
|
190
|
+
:picker_id => nil,
|
191
|
+
:notify_targets => true})
|
192
|
+
picker_id = picker_id_from_options options
|
193
|
+
target_dt = target_date_for_change_date_on_picker_with_date_str date_str, picker_id
|
194
|
+
change_picker_date_time target_dt, options
|
195
|
+
end
|
196
|
+
|
197
|
+
|
198
|
+
def change_date_on_picker_with_date (date, options = {:animate => true,
|
199
|
+
:picker_id => nil,
|
200
|
+
:notify_targets => true})
|
201
|
+
picker_id = picker_id_from_options options
|
202
|
+
target_dt = target_date_for_change_date_on_picker_with_date date, picker_id
|
203
|
+
change_picker_date_time target_dt, options
|
204
|
+
end
|
205
|
+
|
206
|
+
|
207
|
+
def set_briar_date_picker_variables(target_dt, options={:picker_id => nil,
|
208
|
+
:convert_time_to_utc => false})
|
209
|
+
picker_id = picker_id_from_options options
|
210
|
+
if picker_is_in_date_and_time_mode picker_id or picker_is_in_time_mode picker_id
|
211
|
+
@date_picker_time_12h = picker_time_str :h12, options
|
212
|
+
@date_picker_time_24h = picker_time_str :h24, options
|
213
|
+
@date_picker_time_hash = picker_time_strs_hash options
|
214
|
+
@date_picker_time_arr = picker_time_strs_arr options
|
215
|
+
unless time_strings_are_equivalent @date_picker_time_12h, @date_picker_time_24h
|
216
|
+
screenshot_and_raise "ERROR: changing the picker resulted in two different times: '#{@date_picker_time_hash}'"
|
217
|
+
end
|
218
|
+
end
|
219
|
+
|
220
|
+
@date_picker_brief_date_12h = picker_brief_date_str :brief_12h, options
|
221
|
+
@date_picker_brief_date_24h = picker_brief_date_str :brief_24h, options
|
222
|
+
@date_picker_brief_date_hash = picker_brief_date_strs_hash options
|
223
|
+
@date_picker_brief_date_arr = picker_brief_date_strs_arr options
|
224
|
+
|
225
|
+
unless brief_date_strings_are_equivalent @date_picker_brief_date_12h, @date_picker_brief_date_24h
|
226
|
+
screenshot_and_raise "ERROR: changing the picker resulted in two different dates: '#{@date_picker_brief_date_hash}'"
|
227
|
+
end
|
228
|
+
|
229
|
+
@date_picker_date_time = target_dt
|
230
|
+
end
|
231
|
+
|
232
|
+
|
233
|
+
# utility
|
234
|
+
def time_strings_are_equivalent (a, b)
|
235
|
+
a_iso_str = Time.parse(a).strftime(BRIAR_PICKER_ISO8601_TIME_FMT)
|
236
|
+
b_iso_str = Time.parse(b).strftime(BRIAR_PICKER_ISO8601_TIME_FMT)
|
237
|
+
a_iso_str.eql? b_iso_str
|
238
|
+
end
|
239
|
+
|
240
|
+
|
241
|
+
def brief_date_strings_are_equivalent (a, b)
|
242
|
+
a_iso_str = Date.parse(a).strftime(BRIAR_PICKER_ISO8601_BRIEF_DATE_FMT)
|
243
|
+
b_iso_str = Date.parse(b).strftime(BRIAR_PICKER_ISO8601_BRIEF_DATE_FMT)
|
244
|
+
a_iso_str.eql? b_iso_str
|
245
|
+
end
|
246
|
+
|
247
|
+
|
248
|
+
def brief_date_time_strings_are_equivalent (a, b)
|
249
|
+
a_iso_str = Date.parse(a).strftime(BRIAR_PICKER_ISO8601_BRIEF_DATE_TIME_FMT)
|
250
|
+
b_iso_str = Date.parse(b).strftime(BRIAR_PICKER_ISO8601_BRIEF_DATE_TIME_FMT)
|
251
|
+
a_iso_str.eql? b_iso_str
|
252
|
+
end
|
253
|
+
end
|
254
|
+
end
|
255
|
+
end
|