briar 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. checksums.yaml +15 -0
  2. data/LICENSE.txt +1 -6
  3. data/README.md +8 -0
  4. data/bin/briar +44 -0
  5. data/bin/briar_helpers.rb +14 -0
  6. data/briar.gemspec +15 -12
  7. data/cucumber.yml.example +4 -0
  8. data/features/step_definitions/alerts_and_sheets/alert_view_steps.rb +3 -3
  9. data/features/step_definitions/bars/navbar_steps.rb +8 -8
  10. data/features/step_definitions/bars/tabbar_steps.rb +20 -14
  11. data/features/step_definitions/briar_core_steps.rb +3 -3
  12. data/features/step_definitions/control/button_steps.rb +10 -35
  13. data/features/step_definitions/email_steps.rb +55 -28
  14. data/features/step_definitions/keyboard_steps.rb +15 -2
  15. data/features/step_definitions/picker/date_picker_steps.rb +82 -68
  16. data/features/step_definitions/picker/picker_steps.rb +3 -3
  17. data/features/step_definitions/scroll_view_steps.rb +13 -12
  18. data/features/step_definitions/table_steps.rb +15 -10
  19. data/features/step_definitions/text_field_steps.rb +3 -3
  20. data/features/step_definitions/text_view_steps.rb +1 -7
  21. data/lib/briar.rb +2 -0
  22. data/lib/briar/alerts_and_sheets/alert_view.rb +17 -1
  23. data/lib/briar/bars/navbar.rb +16 -12
  24. data/lib/briar/bars/tabbar.rb +16 -4
  25. data/lib/briar/briar_core.rb +9 -3
  26. data/lib/briar/briar_steps.rb +19 -18
  27. data/lib/briar/control/button.rb +0 -1
  28. data/lib/briar/cucumber.rb +2 -0
  29. data/lib/briar/email.rb +34 -19
  30. data/lib/briar/keyboard.rb +25 -25
  31. data/lib/briar/picker/date_picker.rb +152 -107
  32. data/lib/briar/table.rb +18 -21
  33. data/lib/briar/version.rb +1 -1
  34. data/run-tests.sh +4 -0
  35. metadata +46 -20
@@ -2,8 +2,24 @@ require 'calabash-cucumber'
2
2
 
3
3
  module Briar
4
4
  module Alerts_and_Sheets
5
+ def alert_exists? (alert_id)
6
+ !query("alertView marked:'#{alert_id}'").empty?
7
+ end
8
+
9
+ def should_see_alert (alert_id)
10
+ unless alert_exists? alert_id
11
+ screenshot_and_raise "should see alert view marked '#{alert_id}'"
12
+ end
13
+ end
14
+
15
+ def should_not_see_alert (alert_id)
16
+ if alert_exists? alert_id
17
+ screenshot_and_raise "should not see alert view marked '#{alert_id}'"
18
+ end
19
+ end
20
+
5
21
  def alert_button_exists? (button_id)
6
- query("alertView child button child label", :text).include?(button_id)
22
+ query('alertView child button child label', :text).include?(button_id)
7
23
  end
8
24
 
9
25
  def should_see_alert_button (button_id)
@@ -7,25 +7,25 @@ module Briar
7
7
  end
8
8
 
9
9
  def navbar_has_back_button?
10
- !query("navigationItemButtonView").empty?
10
+ !query('navigationItemButtonView').empty?
11
11
  end
12
12
 
13
13
  def should_see_navbar_back_button
14
14
  unless navbar_has_back_button?
15
- screenshot_and_raise "there is no navigation bar back button"
15
+ screenshot_and_raise 'there is no navigation bar back button'
16
16
  end
17
17
  end
18
18
 
19
19
  def should_not_see_navbar_back_button
20
20
  if navbar_has_back_button?
21
- screenshot_and_raise "i should not see navigation bar back button"
21
+ screenshot_and_raise 'i should not see navigation bar back button'
22
22
  end
23
23
  end
24
24
 
25
25
 
26
26
  # will not work to detect left/right buttons
27
27
  def index_of_navbar_button (name)
28
- titles = query("navigationButton", :accessibilityLabel)
28
+ titles = query('navigationButton', :accessibilityLabel)
29
29
  titles.index(name)
30
30
  end
31
31
 
@@ -44,22 +44,22 @@ module Briar
44
44
  end
45
45
 
46
46
  def date_is_in_navbar (date)
47
- with_leading = date.strftime("%a %b %d")
47
+ with_leading = date.strftime('%a %b %d')
48
48
  without_leading = date.strftime("%a %b #{date.day}")
49
- items = query("navigationItemView", :accessibilityLabel)
49
+ items = query('navigationItemView', :accessibilityLabel)
50
50
  items.include?(with_leading) || items.include?(without_leading)
51
51
  end
52
52
 
53
53
 
54
54
  def go_back_after_waiting
55
55
  wait_for_animation
56
- touch("navigationItemButtonView first")
56
+ touch('navigationItemButtonView first')
57
57
  step_pause
58
58
  end
59
59
 
60
60
  def go_back_and_wait_for_view (view)
61
61
  wait_for_animation
62
- touch_transition("navigationItemButtonView first",
62
+ touch_transition('navigationItemButtonView first',
63
63
  "view marked:'#{view}'",
64
64
  {:timeout=>TOUCH_TRANSITION_TIMEOUT,
65
65
  :retry_frequency=>TOUCH_TRANSITION_RETRY_FREQ})
@@ -73,7 +73,7 @@ module Briar
73
73
  touch("navigationButton index:#{idx}")
74
74
  step_pause
75
75
  else
76
- screenshot_and_raise "could not find navbar item #{name}"
76
+ screenshot_and_raise "could not find navbar item '#{name}'"
77
77
  end
78
78
  end
79
79
 
@@ -88,17 +88,21 @@ module Briar
88
88
  end
89
89
 
90
90
 
91
- def navbar_has_title (title)
91
+ def navbar_has_title? (title)
92
92
  wait_for_animation
93
93
  query('navigationItemView', :accessibilityLabel).include?(title)
94
94
  end
95
95
 
96
- def navbar_should_have_title(title)
97
- unless navbar_has_title title
96
+ def should_see_navbar_with_title(title)
97
+ unless navbar_has_title? title
98
98
  screenshot_and_raise "after waiting, i did not see navbar with title #{title}"
99
99
  end
100
100
  end
101
101
 
102
+
103
+ def navbar_should_have_title(title)
104
+ pending "deprecated 0.0.6 - use should_see_navbar_with_title '#{title}'"
105
+ end
102
106
  end
103
107
  end
104
108
 
@@ -3,12 +3,18 @@ require 'calabash-cucumber'
3
3
  module Briar
4
4
  module Bars
5
5
  def tabbar_visible?
6
- element_exists("tabBar")
6
+ element_exists('tabBar')
7
7
  end
8
8
 
9
9
  def should_see_tabbar
10
10
  unless tabbar_visible?
11
- screenshot_and_raise "i do not see the tabbar"
11
+ screenshot_and_raise 'i should see the tabbar'
12
+ end
13
+ end
14
+
15
+ def should_not_see_tabbar
16
+ if tabbar_visible?
17
+ screenshot_and_raise 'i should not see the tabbar'
12
18
  end
13
19
  end
14
20
 
@@ -29,9 +35,15 @@ module Briar
29
35
  end
30
36
  end
31
37
 
32
- def tabbar_item_is_at_index(name, index)
38
+ def should_see_tab_at_index(name, index)
33
39
  tabs = query('tabBarButton', :accessibilityLabel)
34
- tabs.index(name) == index.to_i
40
+ unless tabs.index(name) == index.to_i
41
+ screenshot_and_raise "should have seen tab named '#{name}' at index '#{index}' but found these: '#{tabs}'"
42
+ end
43
+ end
44
+
45
+ def tabbar_item_is_at_index(name, index)
46
+ pending "deprecated 0.0.6 - use should_see_tab_at_index '#{name}', '#{index}'"
35
47
  end
36
48
  end
37
49
  end
@@ -20,7 +20,13 @@ module Briar
20
20
 
21
21
  def should_see_view (view_id)
22
22
  unless view_exists? view_id
23
- screenshot_and_raise "no view found with id #{view_id}"
23
+ screenshot_and_raise "should see view with id '#{view_id}'"
24
+ end
25
+ end
26
+
27
+ def should_not_see_view (view_id)
28
+ if view_exists? view_id
29
+ screenshot_and_raise "should not see view with id '#{view_id}'"
24
30
  end
25
31
  end
26
32
 
@@ -37,14 +43,14 @@ module Briar
37
43
  def should_not_see_view_after_animation (view_id)
38
44
  wait_for_animation
39
45
  if view_exists? view_id
40
- screenshot_and_raise "did not expect to see view '#{view_id}'"
46
+ screenshot_and_raise "should not see view with id '#{view_id}'"
41
47
  end
42
48
  end
43
49
 
44
50
  def should_see_view_with_text (text)
45
51
  res = view_exists_with_text? text
46
52
  unless res
47
- screenshot_and_raise "No view found with text #{text}"
53
+ screenshot_and_raise "should see view with text '#{text}'"
48
54
  end
49
55
  end
50
56
 
@@ -1,26 +1,27 @@
1
- require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions', "briar_core_steps")
1
+ require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions', 'briar_core_steps')
2
2
 
3
- require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions',"alerts_and_sheets", "action_sheet_steps")
4
- require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions',"alerts_and_sheets", "alert_view_steps")
3
+ require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions', 'alerts_and_sheets', 'action_sheet_steps')
4
+ require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions', 'alerts_and_sheets', 'alert_view_steps')
5
5
 
6
- require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions',"bars", "tabbar_steps")
7
- require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions',"bars", "navbar_steps")
8
- require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions',"bars", "toolbar_steps")
6
+ require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions', 'bars', 'tabbar_steps')
7
+ require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions', 'bars', 'navbar_steps')
8
+ require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions', 'bars', 'toolbar_steps')
9
9
 
10
- require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions',"control", "button_steps")
11
- require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions',"control", "segmented_control_steps")
12
- require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions',"control", "slider_steps")
10
+ require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions', 'control', 'button_steps')
11
+ require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions', 'control', 'segmented_control_steps')
12
+ require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions', 'control', 'slider_steps')
13
13
 
14
14
 
15
- require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions',"picker", "picker_steps")
16
- require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions',"picker", "date_picker_steps")
15
+ require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions', 'picker', 'picker_steps')
16
+ require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions', 'picker', 'date_picker_steps')
17
17
 
18
18
 
19
- require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions',"email_steps")
20
- require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions',"image_view_steps")
21
- require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions',"keyboard_steps")
22
- require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions',"label_steps")
23
- require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions',"scroll_view_steps")
19
+ require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions', 'email_steps')
20
+ require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions', 'image_view_steps')
21
+ require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions', 'keyboard_steps')
22
+ require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions', 'label_steps')
23
+ require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions', 'scroll_view_steps')
24
24
 
25
- require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions',"table_steps")
26
- require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions',"text_field_steps")
25
+ require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions', 'table_steps')
26
+ require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions', 'text_field_steps')
27
+ require File.join(File.dirname(__FILE__), '..', '..','features','step_definitions', 'text_view_steps')
@@ -40,7 +40,6 @@ module Briar
40
40
  touch("button marked:'#{name}'")
41
41
  step_pause
42
42
  end
43
-
44
43
  end
45
44
  end
46
45
  end
@@ -19,6 +19,8 @@ World(Briar::Table)
19
19
  World(Briar::TextField)
20
20
  World(Briar::TextView)
21
21
 
22
+
23
+
22
24
  AfterConfiguration do
23
25
  require 'briar/briar_steps'
24
26
  end
@@ -2,56 +2,71 @@ require 'calabash-cucumber'
2
2
 
3
3
  module Briar
4
4
  module Email
5
- def email_body_first_line_is? (text)
5
+
6
+ def email_body
7
+ query("view:'MFComposeTextContentView'", :text)
8
+ end
9
+
10
+ def email_body_contains? (text)
6
11
  if gestalt.is_ios6?
7
- puts "WARN: cannot test for email body text on iOS 6 - see https://groups.google.com/d/topic/calabash-ios/Ff3XFsjp-B0/discussion"
12
+ puts 'WARN: cannot test for email body text on iOS 6 - see https://groups.google.com/d/topic/calabash-ios/Ff3XFsjp-B0/discussion'
8
13
  else
9
- actual_tokens = query("view:'MFComposeTextContentView'", :text).first.split("\n")
10
- actual_tokens.include?(text)
14
+ !query("view:'MFComposeTextContentView' {text LIKE '*#{text}*'}").empty?
11
15
  end
12
16
  end
13
17
 
18
+ def email_subject
19
+ query("view:'MFComposeSubjectView'", :text).first
20
+ end
21
+
14
22
  def email_subject_is? (text)
15
23
  if gestalt.is_ios6?
16
- puts "WARN: cannot test for email subject text on iOS 6 - see https://groups.google.com/d/topic/calabash-ios/Ff3XFsjp-B0/discussion"
24
+ puts 'WARN: cannot test for email subject text on iOS 6 - see https://groups.google.com/d/topic/calabash-ios/Ff3XFsjp-B0/discussion'
17
25
  else
18
- actual = query("view marked:'subjectField'", :text)
19
- actual.length == 1 && actual.first.eql?(text)
26
+ email_subject.eql? text
20
27
  end
21
28
  end
22
29
 
23
30
  def email_subject_has_text_like? (text)
24
31
  if gestalt.is_ios6?
25
- puts "WARN: cannot test for email subject text on iOS 6 - see https://groups.google.com/d/topic/calabash-ios/Ff3XFsjp-B0/discussion"
32
+ puts 'WARN: cannot test for email subject text on iOS 6 - see https://groups.google.com/d/topic/calabash-ios/Ff3XFsjp-B0/discussion'
26
33
  else
27
- !query("view marked:'subjectField' {text LIKE '*#{text}*'}").empty?
34
+ !query("view:'MFComposeSubjectView' {text LIKE '*#{text}*'}").empty?
28
35
  end
29
36
  end
30
37
 
38
+ def email_to
39
+ query("view:'_MFMailRecipientTextField'", :text).first
40
+ end
41
+
31
42
  def email_to_field_is? (text)
32
43
  if gestalt.is_ios6?
33
44
  puts "WARN: iOS6 detected - cannot test for email 'to' field on iOS simulator or devices"
34
45
  else
35
- actual = query("view marked:'toField'", :text)
36
- actual.length == 1 && actual.first.eql?(text)
46
+ email_to.eql? text
37
47
  end
38
48
  end
39
49
 
40
- def is_ios5_mail_view ()
41
- query("view:'MFMailComposeRecipientView'").count == 3
42
- #access_ids = query("view", :accessibilityIdentifier)
43
- #access_ids.member?("toField") || access_ids.member?("subjectField")
50
+ def email_to_contains? (address)
51
+ addrs = email_to.split(/, ?/)
52
+ addrs.include? address
53
+ end
54
+
55
+ def is_ios5_mail_view
56
+ query("layoutContainerView descendant view:'MFMailComposeView'").count == 1
44
57
  end
45
58
 
46
- def is_ios6_mail_view()
47
- access_ids = query("view", :accessibilityIdentifier)
48
- access_ids.member?("RemoteViewBridge")
59
+ def is_ios6_mail_view
60
+ gestalt.is_ios6?
61
+ # sometimes this is returning false
62
+ # access_ids = query("view", :accessibilityIdentifier)
63
+ # access_ids.member?("RemoteViewBridge")
49
64
  end
50
65
 
51
66
  def should_see_mail_view
52
67
  wait_for_animation
53
68
  unless is_ios5_mail_view || is_ios6_mail_view
54
- screenshot_and_raise "expected to see email view"
69
+ screenshot_and_raise 'expected to see email view'
55
70
  end
56
71
  end
57
72
  end
@@ -1,4 +1,4 @@
1
- require "calabash-cucumber"
1
+ require 'calabash-cucumber'
2
2
 
3
3
  module Briar
4
4
  module Keyboard
@@ -15,37 +15,37 @@ module Briar
15
15
 
16
16
 
17
17
  def should_see_keyboard
18
- res = element_exists("keyboardAutomatic")
18
+ res = element_exists('keyboardAutomatic')
19
19
  unless res
20
- screenshot_and_raise "Expected keyboard to be visible."
20
+ screenshot_and_raise 'Expected keyboard to be visible.'
21
21
  end
22
22
  end
23
23
 
24
24
  def should_not_see_keyboard
25
- res = element_exists("keyboardAutomatic")
25
+ res = element_exists('keyboardAutomatic')
26
26
  if res
27
- screenshot_and_raise "Expected keyboard to not be visible."
27
+ screenshot_and_raise 'Expected keyboard to not be visible.'
28
28
  end
29
29
  end
30
30
 
31
31
  # is it possible to find what view the keyboard is responding to?
32
32
  def autocapitalization_type ()
33
- if !query("textView index:0").empty?
34
- query("textView index:0", :autocapitalizationType).first.to_i
35
- elsif !query("textField index:0").empty?
36
- query("textField index:0", :autocapitalizationType).first.to_i
33
+ if !query('textView index:0').empty?
34
+ query('textView index:0', :autocapitalizationType).first.to_i
35
+ elsif !query('textField index:0').empty?
36
+ query('textField index:0', :autocapitalizationType).first.to_i
37
37
  else
38
- screenshot_and_raise "could not find a text view or text field"
38
+ screenshot_and_raise 'could not find a text view or text field'
39
39
  end
40
40
  end
41
41
 
42
42
  def set_autocapitalization (type)
43
- if !query("textView index:0").empty?
44
- query("textView index:0", [{setAutocapitalizationType:type}])
45
- elsif !query("textField index:0").empty?
46
- query("textField index:0", [{setAutocapitalizationType:type}])
43
+ if !query('textView index:0').empty?
44
+ query('textView index:0', [{setAutocapitalizationType:type}])
45
+ elsif !query('textField index:0').empty?
46
+ query('textField index:0', [{setAutocapitalizationType:type}])
47
47
  else
48
- screenshot_and_raise "could not find a text view or text field"
48
+ screenshot_and_raise 'could not find a text view or text field'
49
49
  end
50
50
  end
51
51
 
@@ -54,12 +54,12 @@ module Briar
54
54
  end
55
55
 
56
56
  def set_autocorrect (type)
57
- if !query("textView index:0").empty?
58
- query("textView index:0", [{setAutocorrectionType:type}])
59
- elsif !query("textField index:0").empty?
60
- query("textField index:0", [{setAutocorrectionType:type}])
57
+ if !query('textView index:0').empty?
58
+ query('textView index:0', [{setAutocorrectionType:type}])
59
+ elsif !query('textField index:0').empty?
60
+ query('textField index:0', [{setAutocorrectionType:type}])
61
61
  else
62
- screenshot_and_raise "could not find a text view or text field"
62
+ screenshot_and_raise 'could not find a text view or text field'
63
63
  end
64
64
  end
65
65
 
@@ -68,12 +68,12 @@ module Briar
68
68
  end
69
69
 
70
70
  def turn_spell_correct_off
71
- if !query("textView index:0").empty?
72
- query("textView index:0", [{setSpellCheckingType:UITextSpellCheckingTypeNo}])
73
- elsif !query("textField index:0").empty?
74
- query("textField index:0", [{setSpellCheckingType:UITextSpellCheckingTypeNo}])
71
+ if !query('textView index:0').empty?
72
+ query('textView index:0', [{setSpellCheckingType:UITextSpellCheckingTypeNo}])
73
+ elsif !query('textField index:0').empty?
74
+ query('textField index:0', [{setSpellCheckingType:UITextSpellCheckingTypeNo}])
75
75
  else
76
- screenshot_and_raise "could not find a text view or text field"
76
+ screenshot_and_raise 'could not find a text view or text field'
77
77
  end
78
78
  end
79
79
 
@@ -1,6 +1,49 @@
1
1
  require 'date'
2
2
  require 'calabash-cucumber'
3
3
 
4
+ # 0.2 is too fast because the picker does not pause at the date long enough for
5
+ # the date to change. 0.3 seems to work, but 0.4 is best i think.
6
+ PICKER_STEP_PAUSE = 0.4.to_f
7
+ PICKER_AM = 'AM'
8
+ PICKER_PM = 'PM'
9
+
10
+ # most locales and situations prefer _not_ to have leading zeros on hours in 24h
11
+ # see usage below to find out when and if the zeros are stripped
12
+ PICKER_24H_TIME_FMT = '%H:%M'
13
+ PICKER_12H_TIME_FMT = '%l:%M %p'
14
+ PICKER_ISO8601_TIME_FMT = '%H:%M'
15
+
16
+ PICKER_REMOVE_LEADING_ZERO_REGEX = /\A^0/
17
+
18
+ # 24h locales - Fri 16 Nov - 24h locales
19
+ PICKER_24H_DATE_FMT = '%a %e %b'
20
+ # common format for US Fri Nov 16
21
+ PICKER_12H_DATE_FMT = '%a %b %e'
22
+
23
+ # our canonical format for testing if two dates are the same
24
+ PICKER_ISO8601_DATE_FMT = '%Y-%m-%d'
25
+ PICKER_ISO8601_DATE_TIME_FMT = '%Y-%m-%d %H:%M'
26
+
27
+ # when we are using the date picker category, this is the format of the string
28
+ # we will send to setDateWithString:animated:
29
+ #
30
+ # ex. 2012_11_18_16_45
31
+ PICKER__RUBY___SET_PICKER_DATE__DATE_AND_TIME_FMT_ZONED = '%Y_%m_%d_%H_%M_%z'
32
+ PICKER__OBJC___SET_PICKER_DATE__DATE_AND_TIME_FMT_ZONED = 'yyyy_MM_dd_HH_mm_Z'
33
+ PICKER__RUBY___SET_PICKER_DATE__DATE_AND_TIME_FMT = '%Y_%m_%d_%H_%M'
34
+ PICKER__OBJC___SET_PICKER_DATE__DATE_AND_TIME_FMT = 'yyyy_MM_dd_HH_mm'
35
+
36
+
37
+ # iOS 5
38
+ PICKER_VIEW_CLASS_IOS5 = 'datePickerView'
39
+ PICKER_VIEW_CLASS_IOS6 = "view:'_UIDatePickerView'"
40
+
41
+ UIDatePickerModeTime = 0
42
+ UIDatePickerModeDate = 1
43
+ UIDatePickerModeDateAndTime = 2
44
+ UIDatePickerModeCountDownTimer = 3
45
+
46
+
4
47
  module Briar
5
48
  module Picker
6
49
  module Date
@@ -102,39 +145,39 @@ to use the automatic mode, include this category in your CALABASH target
102
145
 
103
146
  =end
104
147
 
105
- # 0.2 is too fast because the picker does not pause at the date long enough for
106
- # the date to change. 0.3 seems to work, but 0.4 is best i think.
107
- PICKER_STEP_PAUSE = 0.4.to_f
108
- PICKER_AM = "AM"
109
- PICKER_PM = "PM"
110
-
111
- # most locales and situations prefer _not_ to have leading zeros on hours in 24h
112
- # see usage below to find out when and if the zeros are stripped
113
- PICKER_24H_TIME_FMT = '%H:%M'
114
- PICKER_12H_TIME_FMT = '%l:%M %p'
115
- PICKER_ISO8601_TIME_FMT = '%H:%M'
116
-
117
- PICKER_REMOVE_LEADING_ZERO_REGEX = /\A^0/
118
-
119
- # 24h locales - Fri 16 Nov - 24h locales
120
- PICKER_24H_DATE_FMT = '%a %e %b'
121
- # common format for US Fri Nov 16
122
- PICKER_12H_DATE_FMT = '%a %b %e'
123
-
124
- # our canonical format for testing if two dates are the same
125
- PICKER_ISO8601_DATE_FMT = '%Y-%m-%d'
126
- PICKER_ISO8601_DATE_TIME_FMT = '%Y-%m-%d %H:%M'
127
-
128
- # when we are using the date picker category, this is the format of the string
129
- # we will send to setDateWithString:animated:
148
+ ## 0.2 is too fast because the picker does not pause at the date long enough for
149
+ ## the date to change. 0.3 seems to work, but 0.4 is best i think.
150
+ # PICKER_STEP_PAUSE = 0.4.to_f
151
+ # PICKER_AM = 'AM'
152
+ # PICKER_PM = 'PM'
130
153
  #
131
- # ex. 2012_11_18_16_45
132
- PICKER__RUBY___SET_PICKER_DATE__DATE_AND_TIME_FMT = '%Y_%m_%d_%H_%M_%z'
133
- PICKER__OBJC___SET_PICKER_DATE__DATE_AND_TIME_FMT = 'yyyy_MM_dd_HH_mm_Z'
134
-
135
- # iOS 5
136
- PICKER_VIEW_CLASS_IOS5 = "datePickerView"
137
- PICKER_VIEW_CLASS_IOS6 = "view:'_UIDatePickerView'"
154
+ ## most locales and situations prefer _not_ to have leading zeros on hours in 24h
155
+ ## see usage below to find out when and if the zeros are stripped
156
+ # PICKER_24H_TIME_FMT = '%H:%M'
157
+ # PICKER_12H_TIME_FMT = '%l:%M %p'
158
+ # PICKER_ISO8601_TIME_FMT = '%H:%M'
159
+ #
160
+ # PICKER_REMOVE_LEADING_ZERO_REGEX = /\A^0/
161
+ #
162
+ ## 24h locales - Fri 16 Nov - 24h locales
163
+ # PICKER_24H_DATE_FMT = '%a %e %b'
164
+ ## common format for US Fri Nov 16
165
+ # PICKER_12H_DATE_FMT = '%a %b %e'
166
+ #
167
+ ## our canonical format for testing if two dates are the same
168
+ # PICKER_ISO8601_DATE_FMT = '%Y-%m-%d'
169
+ # PICKER_ISO8601_DATE_TIME_FMT = '%Y-%m-%d %H:%M'
170
+ #
171
+ ## when we are using the date picker category, this is the format of the string
172
+ ## we will send to setDateWithString:animated:
173
+ ##
174
+ ## ex. 2012_11_18_16_45
175
+ # PICKER__RUBY___SET_PICKER_DATE__DATE_AND_TIME_FMT = '%Y_%m_%d_%H_%M_%z'
176
+ # PICKER__OBJC___SET_PICKER_DATE__DATE_AND_TIME_FMT = 'yyyy_MM_dd_HH_mm_Z'
177
+ #
178
+ ## iOS 5
179
+ # PICKER_VIEW_CLASS_IOS5 = 'datePickerView'
180
+ # PICKER_VIEW_CLASS_IOS6 = "view:'_UIDatePickerView'"
138
181
 
139
182
  # testing for existence
140
183
  def should_see_date_picker (picker_id)
@@ -147,24 +190,24 @@ to use the automatic mode, include this category in your CALABASH target
147
190
  # getting dates from the picker
148
191
 
149
192
  def picker_date_time
150
- res = query("datePicker", :date)
151
- screenshot_and_raise "expected to see a date picker" if res.empty?
193
+ res = query('datePicker', :date)
194
+ screenshot_and_raise 'expected to see a date picker' if res.empty?
152
195
  DateTime.parse(res.first)
153
196
  end
154
197
 
155
198
  # appledoc ==> The property is an NSDate object or nil (the default), which
156
199
  # means no maximum date.
157
200
  def picker_maximum_date_time
158
- res = query("datePicker", :maximumDate)
159
- screenshot_and_raise "expected to see a date picker" if res.empty?
201
+ res = query('datePicker', :maximumDate)
202
+ screenshot_and_raise 'expected to see a date picker' if res.empty?
160
203
  res.first != nil ? DateTime.parse(res.first) : nil
161
204
  end
162
205
 
163
206
  # appledoc ==> The property is an NSDate object or nil (the default), which
164
207
  # means no minimum date.
165
208
  def picker_minimum_date_time
166
- res = query("datePicker", :minimumDate)
167
- screenshot_and_raise "expected to see a date picker" if res.empty?
209
+ res = query('datePicker', :minimumDate)
210
+ screenshot_and_raise 'expected to see a date picker' if res.empty?
168
211
  res.first != nil ? DateTime.parse(res.first) : nil
169
212
  end
170
213
 
@@ -173,9 +216,9 @@ to use the automatic mode, include this category in your CALABASH target
173
216
  # checking to see if the picker is visible and has the calabash category
174
217
  # additions
175
218
  def picker_has_calabash_additions
176
- success_value = "1"
177
- res = query("datePicker", [{hasCalabashAdditions:success_value}])
178
- screenshot_and_raise "picker is not visible" if res.empty?
219
+ success_value = '1'
220
+ res = query('datePicker', [{hasCalabashAdditions:success_value}])
221
+ screenshot_and_raise 'picker is not visible' if res.empty?
179
222
  res.first.eql? success_value
180
223
  end
181
224
 
@@ -188,40 +231,43 @@ to use the automatic mode, include this category in your CALABASH target
188
231
  !date_str[-1, 1].scan(/^[a-zA-Z]/).empty?
189
232
  end
190
233
 
191
- def date_str_to_send_to_picker_from_time_str (time_str)
234
+ def date_str_to_send_to_picker_from_time_str (time_str, format=PICKER__RUBY___SET_PICKER_DATE__DATE_AND_TIME_FMT)
192
235
  time_in_24h = date_time_or_time_str_is_in_24h time_str
193
236
  time_fmt = time_in_24h ? PICKER_24H_TIME_FMT : PICKER_12H_TIME_FMT
194
237
  date_fmt = time_in_24h ? PICKER_24H_DATE_FMT : PICKER_12H_DATE_FMT
195
- date_str = picker_date_time.strftime(date_fmt).squeeze(" ").strip
238
+ date_str = picker_date_time.strftime(date_fmt).squeeze(' ').strip
196
239
 
197
240
  date_time_str = "#{date_str} #{time_str}"
198
241
  date_time_fmt = "#{date_fmt} #{time_fmt}"
199
242
 
200
243
  date_time = DateTime.strptime(date_time_str, date_time_fmt)
201
- date_time.strftime(PICKER__RUBY___SET_PICKER_DATE__DATE_AND_TIME_FMT).squeeze(" ").strip
244
+ date_time.strftime(format).squeeze(' ').strip
202
245
  end
203
246
 
204
247
 
205
- def date_str_to_send_to_picker_from_date_str (date_str)
248
+ def date_str_to_send_to_picker_from_date_str (date_str, format=PICKER__RUBY___SET_PICKER_DATE__DATE_AND_TIME_FMT)
206
249
  date_in_24h = date_str_is_in_24h (date_str)
207
250
  time_fmt = date_in_24h ? PICKER_24H_TIME_FMT : PICKER_12H_TIME_FMT
208
251
  date_fmt = date_in_24h ? PICKER_24H_DATE_FMT : PICKER_12H_DATE_FMT
209
- time_str = picker_date_time.strftime(time_fmt).squeeze(" ").strip
252
+ time_str = picker_date_time.strftime(time_fmt).squeeze(' ').strip
210
253
  date_time_str = "#{date_str} #{time_str}"
211
254
  date_time_fmt = "#{date_fmt} #{time_fmt}"
255
+
212
256
  date_time = DateTime.strptime(date_time_str, date_time_fmt)
213
- date_time.strftime(PICKER__RUBY___SET_PICKER_DATE__DATE_AND_TIME_FMT).squeeze(" ").strip
257
+
258
+ date_time.strftime(format).squeeze(' ').strip
214
259
  end
215
260
 
216
261
 
217
- def set_picker_date_with_date_time_str (date_time_str, animated=1)
218
- query("datePicker", [{respondsToSelector:"minuteInterval"}])
262
+ def set_picker_date_with_date_time_str (date_time_str, opts={:animated => 1,
263
+ :objc_format => PICKER__OBJC___SET_PICKER_DATE__DATE_AND_TIME_FMT})
264
+ query('datePicker', [{respondsToSelector: 'minuteInterval'}])
219
265
 
266
+ res = query('datePicker', [{setDateWithString:date_time_str},
267
+ {format:"#{opts[:objc_format]}"},
268
+ {animated:opts[:animated]}])
220
269
 
221
- res = query("datePicker", [{setDateWithString:date_time_str},
222
- {format:"#{PICKER__OBJC___SET_PICKER_DATE__DATE_AND_TIME_FMT}"},
223
- {animated:animated.to_i}])
224
- screenshot_and_raise "could not find a date picker to query" if res.empty?
270
+ screenshot_and_raise 'could not find a date picker to query' if res.empty?
225
271
  if res.first.to_i == 0
226
272
  screenshot_and_raise "could not set the picker date with '#{date_time_str}' and '#{PICKER__RUBY___SET_PICKER_DATE__DATE_AND_TIME_FMT}'"
227
273
  end
@@ -232,17 +278,19 @@ to use the automatic mode, include this category in your CALABASH target
232
278
  # the query does not create a UIControlEventValueChanged event, so we have to
233
279
  # to a touch event
234
280
 
281
+ # not true :(
235
282
  # if the picker is in time mode, then we dont need to worry about min/max
283
+
236
284
  # if the picker is date or date time mode, i think the first column is
237
285
  # always scrollable up _and_ it sends an event even if the date is beyond
238
286
  # the maximum date
239
-
287
+ #
240
288
  #picker_max_date = picker_maximum_date_time
241
289
  #picker_min_date = picker_minimum_date_time
242
290
  #target_date = DateTime.strptime(date_time_str, PICKER__RUBY___SET_PICKER_DATE__DATE_AND_TIME_FMT)
243
-
291
+ #
244
292
  #column_one_index = picker_current_index_for_column 0
245
- #query("pickerTableView index:0", [{selectRow:column_one_index}, {animated:1}, {notify:1}])
293
+ #query('pickerTableView index:0', [{selectRow:column_one_index}, {animated:1}, {notify:1}])
246
294
 
247
295
  picker_scroll_down_on_column 0
248
296
  sleep(PICKER_STEP_PAUSE)
@@ -268,10 +316,10 @@ to use the automatic mode, include this category in your CALABASH target
268
316
  # if it is not, the default value is used. The default and minimum values are 1;
269
317
  # the maximum value is 30.
270
318
  def picker_minute_interval
271
- screenshot_and_raise "there is no minute in date mode" if picker_is_in_date_mode
272
- screenshot_and_raise "nyi" if picker_is_in_countdown_mode
273
- res = query("datePicker", :minuteInterval)
274
- screenshot_and_raise "expected to see a date picker" if res.empty?
319
+ screenshot_and_raise 'there is no minute in date mode' if picker_is_in_date_mode
320
+ screenshot_and_raise 'nyi' if picker_is_in_countdown_mode
321
+ res = query('datePicker', :minuteInterval)
322
+ screenshot_and_raise 'expected to see a date picker' if res.empty?
275
323
  @picker_minute_interval = res.first
276
324
  end
277
325
 
@@ -290,21 +338,18 @@ to use the automatic mode, include this category in your CALABASH target
290
338
  end while ((minute % interval) != 0)
291
339
  time = time + (count * 60)
292
340
 
293
- {:h12 => time.strftime(PICKER_12H_TIME_FMT).squeeze(" ").strip,
294
- :h24 => time.strftime(PICKER_24H_TIME_FMT).squeeze(" ").strip.sub(PICKER_REMOVE_LEADING_ZERO_REGEX,""),
341
+ {:h12 => time.strftime(PICKER_12H_TIME_FMT).squeeze(' ').strip,
342
+ :h24 => time.strftime(PICKER_24H_TIME_FMT).squeeze(' ').strip.sub(PICKER_REMOVE_LEADING_ZERO_REGEX, ''),
295
343
  :time => time}
296
344
  end
297
345
 
298
346
  # picker modes
299
347
 
300
- UIDatePickerModeTime = 0
301
- UIDatePickerModeDate = 1
302
- UIDatePickerModeDateAndTime = 2
303
- UIDatePickerModeCountDownTimer = 3
348
+
304
349
 
305
350
  def picker_mode
306
- res = query("datePicker", :datePickerMode)
307
- screenshot_and_raise "expected to see a date picker" if res.empty?
351
+ res = query('datePicker', :datePickerMode)
352
+ screenshot_and_raise 'expected to see a date picker' if res.empty?
308
353
  res.first
309
354
  end
310
355
 
@@ -327,27 +372,27 @@ to use the automatic mode, include this category in your CALABASH target
327
372
  # columns for different modes
328
373
 
329
374
  def picker_column_for_hour
330
- screenshot_and_raise "there is no hour column in date mode" if picker_is_in_date_mode
331
- screenshot_and_raise "nyi" if picker_is_in_countdown_mode
375
+ screenshot_and_raise 'there is no hour column in date mode' if picker_is_in_date_mode
376
+ screenshot_and_raise 'nyi' if picker_is_in_countdown_mode
332
377
  picker_is_in_time_mode ? 0 : 1
333
378
  end
334
379
 
335
380
  def picker_column_for_minute
336
- screenshot_and_raise "there is no minute column in date mode" if picker_is_in_date_mode
337
- screenshot_and_raise "nyi" if picker_is_in_countdown_mode
381
+ screenshot_and_raise 'there is no minute column in date mode' if picker_is_in_date_mode
382
+ screenshot_and_raise 'nyi' if picker_is_in_countdown_mode
338
383
  picker_is_in_time_mode ? 1 : 2
339
384
  end
340
385
 
341
386
  def picker_column_for_period
342
- screenshot_and_raise "there is no period column in date mode" if picker_is_in_date_mode
343
- screenshot_and_raise "nyi" if picker_is_in_countdown_mode
387
+ screenshot_and_raise 'there is no period column in date mode' if picker_is_in_date_mode
388
+ screenshot_and_raise 'nyi' if picker_is_in_countdown_mode
344
389
  picker_is_in_time_mode ? 2 : 3
345
390
  end
346
391
 
347
392
  # 12h or 24h locale
348
393
 
349
394
  def picker_is_in_12h_locale
350
- screenshot_and_raise "12h/24h mode is not applicable to this mode" if picker_is_in_date_mode or picker_is_in_countdown_mode
395
+ screenshot_and_raise '12h/24h mode is not applicable to this mode' if picker_is_in_date_mode or picker_is_in_countdown_mode
351
396
  column = picker_column_for_period
352
397
  !query("pickerTableView index:#{column}").empty?
353
398
  end
@@ -362,42 +407,42 @@ to use the automatic mode, include this category in your CALABASH target
362
407
  # pt (lisbon) - a.m./p.m.
363
408
  # de - nach/vor
364
409
  def picker_period
365
- screenshot_and_raise "picker is not in 12h mode" if picker_is_in_24h_locale
410
+ screenshot_and_raise 'picker is not in 12h mode' if picker_is_in_24h_locale
366
411
  date = picker_date_time
367
412
  date_str = date.strftime(PICKER_12H_TIME_FMT)
368
- tokens = date_str.split(" ")
413
+ tokens = date_str.split(' ')
369
414
  tokens.last
370
415
  end
371
416
 
372
417
  def picker_period_is_am?
373
- picker_period.eql?("AM")
418
+ picker_period.eql?('AM')
374
419
  end
375
420
 
376
421
  def picker_period_is_pm?
377
- picker_period.eql?("PM")
422
+ picker_period.eql?('PM')
378
423
  end
379
424
 
380
425
  # weekday, month, day, etc
381
426
 
382
427
  def picker_weekday
383
- screenshot_and_raise "weekday is not applicable to this mode" if picker_is_in_time_mode or picker_is_in_countdown_mode
384
- res = query("datePickerWeekMonthDayView", :weekdayLabel, :text)[2]
428
+ screenshot_and_raise 'weekday is not applicable to this mode' if picker_is_in_time_mode or picker_is_in_countdown_mode
429
+ res = query('datePickerWeekMonthDayView', :weekdayLabel, :text)[2]
385
430
  # need to guard against Today showing
386
431
  res == nil ? Date.today.strftime('%a') : res
387
432
  end
388
433
 
389
434
  def picker_month_day
390
- screenshot_and_raise "month/day is not applicable to this mode" if picker_is_in_time_mode or picker_is_in_countdown_mode
391
- res = query("datePickerWeekMonthDayView", :dateLabel, :text)[2]
392
- picker_iso = picker_date_time.strftime(PICKER_ISO8601_DATE_FMT).squeeze(" ").strip
435
+ screenshot_and_raise 'month/day is not applicable to this mode' if picker_is_in_time_mode or picker_is_in_countdown_mode
436
+ res = query('datePickerWeekMonthDayView', :dateLabel, :text)[2]
437
+ picker_iso = picker_date_time.strftime(PICKER_ISO8601_DATE_FMT).squeeze(' ').strip
393
438
  today = Date.today
394
- today_iso = today.strftime(PICKER_ISO8601_DATE_FMT).squeeze(" ").strip
439
+ today_iso = today.strftime(PICKER_ISO8601_DATE_FMT).squeeze(' ').strip
395
440
  fmt = picker_is_in_24h_locale ? '%e %b' : '%b %e'
396
441
  (picker_iso.eql? today_iso) ? today.strftime(fmt) : res
397
442
  end
398
443
 
399
444
  def picker_date_str
400
- "#{picker_weekday} #{picker_month_day}".strip.squeeze(" ")
445
+ "#{picker_weekday} #{picker_month_day}".strip.squeeze(' ')
401
446
  end
402
447
 
403
448
  def picker_weekday_month_day_is (weekday_month_day)
@@ -407,7 +452,7 @@ to use the automatic mode, include this category in your CALABASH target
407
452
  # dealing with time
408
453
 
409
454
  def picker_hour_24h
410
- screenshot_and_raise "hour is not applicable to this mode" if picker_is_in_countdown_mode or picker_is_in_date_mode
455
+ screenshot_and_raise 'hour is not applicable to this mode' if picker_is_in_countdown_mode or picker_is_in_date_mode
411
456
  # query always returns as 24h
412
457
  res_ios5 = query(PICKER_VIEW_CLASS_IOS5, :hour).first
413
458
  res_ios6 = query(PICKER_VIEW_CLASS_IOS6, :hour).first
@@ -416,19 +461,19 @@ to use the automatic mode, include this category in your CALABASH target
416
461
  end
417
462
 
418
463
  def picker_hour_24h_str
419
- screenshot_and_raise "hour is not applicable to this mode" if picker_is_in_countdown_mode or picker_is_in_date_mode
420
- "%02d" % picker_hour_24h
464
+ screenshot_and_raise 'hour is not applicable to this mode' if picker_is_in_countdown_mode or picker_is_in_date_mode
465
+ '%02d' % picker_hour_24h
421
466
  end
422
467
 
423
468
  def picker_hour_12h
424
- screenshot_and_raise "hour is not applicable to this mode" if picker_is_in_countdown_mode or picker_is_in_date_mode
469
+ screenshot_and_raise 'hour is not applicable to this mode' if picker_is_in_countdown_mode or picker_is_in_date_mode
425
470
  hour_24h = picker_hour_24h
426
471
  return 12 if hour_24h == 0
427
472
  hour_24h > 12 ? hour_24h - 12 : hour_24h
428
473
  end
429
474
 
430
475
  def picker_hour_12h_str
431
- screenshot_and_raise "hour is not applicable to this mode" if picker_is_in_countdown_mode or picker_is_in_date_mode
476
+ screenshot_and_raise 'hour is not applicable to this mode' if picker_is_in_countdown_mode or picker_is_in_date_mode
432
477
  "#{picker_hour_12h}"
433
478
  end
434
479
 
@@ -445,7 +490,7 @@ to use the automatic mode, include this category in your CALABASH target
445
490
  end
446
491
 
447
492
  def picker_minute
448
- screenshot_and_raise "hour is not applicable to this mode" if picker_is_in_countdown_mode or picker_is_in_date_mode
493
+ screenshot_and_raise 'hour is not applicable to this mode' if picker_is_in_countdown_mode or picker_is_in_date_mode
449
494
  res_ios5 = query(PICKER_VIEW_CLASS_IOS5, :minute).first
450
495
  res_ios6 = query(PICKER_VIEW_CLASS_IOS6, :minute).first
451
496
  return res_ios5 != nil ? res_ios5 : res_ios6
@@ -453,8 +498,8 @@ to use the automatic mode, include this category in your CALABASH target
453
498
  end
454
499
 
455
500
  def picker_minute_str
456
- screenshot_and_raise "hour is not applicable to this mode" if picker_is_in_countdown_mode or picker_is_in_date_mode
457
- "%02d" % picker_minute
501
+ screenshot_and_raise 'hour is not applicable to this mode' if picker_is_in_countdown_mode or picker_is_in_date_mode
502
+ '%02d' % picker_minute
458
503
  #"%02d" % query("datePickerView", :minute).first
459
504
  end
460
505
 
@@ -463,35 +508,35 @@ to use the automatic mode, include this category in your CALABASH target
463
508
  end
464
509
 
465
510
  def picker_time_24h_str
466
- screenshot_and_raise "the time is not applicable for this mode" if picker_is_in_date_mode or picker_is_in_countdown_mode
467
- "#{picker_hour_24h_str}:#{picker_minute_str}".strip.sub(PICKER_REMOVE_LEADING_ZERO_REGEX, "")
511
+ screenshot_and_raise 'the time is not applicable for this mode' if picker_is_in_date_mode or picker_is_in_countdown_mode
512
+ "#{picker_hour_24h_str}:#{picker_minute_str}".strip.sub(PICKER_REMOVE_LEADING_ZERO_REGEX, '')
468
513
  end
469
514
 
470
515
  def picker_time_12h_str
471
- screenshot_and_raise "the time is not applicable for this mode" if picker_is_in_date_mode or picker_is_in_countdown_mode
516
+ screenshot_and_raise 'the time is not applicable for this mode' if picker_is_in_date_mode or picker_is_in_countdown_mode
472
517
  "#{picker_hour_12h_str}:#{picker_minute_str} #{picker_period}"
473
518
  end
474
519
 
475
520
  def picker_time_str
476
- screenshot_and_raise "the time is not applicable for this mode" if picker_is_in_date_mode or picker_is_in_countdown_mode
521
+ screenshot_and_raise 'the time is not applicable for this mode' if picker_is_in_date_mode or picker_is_in_countdown_mode
477
522
  picker_is_in_24h_locale ? picker_time_24h_str : picker_time_12h_str
478
523
  end
479
524
 
480
525
  def picker_time_for_other_locale
481
526
  time_str = picker_is_in_24h_locale ? picker_time_24h_str : picker_time_12h_str
482
527
  fmt_str = picker_is_in_24h_locale ? PICKER_12H_TIME_FMT : PICKER_24H_TIME_FMT
483
- Time.parse(time_str).strftime(fmt_str).squeeze(" ").strip.sub(PICKER_REMOVE_LEADING_ZERO_REGEX,"")
528
+ Time.parse(time_str).strftime(fmt_str).squeeze(' ').strip.sub(PICKER_REMOVE_LEADING_ZERO_REGEX, '')
484
529
  end
485
530
 
486
531
  # date and time
487
532
 
488
533
  def picker_date_and_time_str_24h
489
- screenshot_and_raise "the time is not applicable for this mode" if picker_is_in_date_mode or picker_is_in_countdown_mode
534
+ screenshot_and_raise 'the time is not applicable for this mode' if picker_is_in_date_mode or picker_is_in_countdown_mode
490
535
  "#{picker_date_str} #{picker_time_24h_str}"
491
536
  end
492
537
 
493
538
  def picker_date_and_time_str_12h
494
- screenshot_and_raise "the time is not applicable for this mode" if picker_is_in_date_mode or picker_is_in_countdown_mode
539
+ screenshot_and_raise 'the time is not applicable for this mode' if picker_is_in_date_mode or picker_is_in_countdown_mode
495
540
  "#{picker_date_str} #{picker_time_12h_str}"
496
541
  end
497
542
 
@@ -507,8 +552,8 @@ to use the automatic mode, include this category in your CALABASH target
507
552
 
508
553
  def now_times_map
509
554
  now = Time.new
510
- {:h12 => now.strftime(PICKER_12H_TIME_FMT).squeeze(" ").strip,
511
- :h24 => now.strftime(PICKER_24H_TIME_FMT).squeeze(" ").strip.sub(PICKER_REMOVE_LEADING_ZERO_REGEX,""),
555
+ {:h12 => now.strftime(PICKER_12H_TIME_FMT).squeeze(' ').strip,
556
+ :h24 => now.strftime(PICKER_24H_TIME_FMT).squeeze(' ').strip.sub(PICKER_REMOVE_LEADING_ZERO_REGEX, ''),
512
557
  :time => now}
513
558
  end
514
559
 
@@ -523,7 +568,7 @@ to use the automatic mode, include this category in your CALABASH target
523
568
  # scrolling picker
524
569
 
525
570
  def picker_scroll_to_hour (target_hour_int_24h_notation)
526
- screenshot_and_raise "nyi" if picker_is_in_countdown_mode
571
+ screenshot_and_raise 'nyi' if picker_is_in_countdown_mode
527
572
  column = picker_column_for_hour
528
573
  limit = 25
529
574
  count = 0
@@ -540,7 +585,7 @@ to use the automatic mode, include this category in your CALABASH target
540
585
  end
541
586
 
542
587
  def picker_scroll_to_minute (target_minute_int)
543
- screenshot_and_raise "nyi" if picker_is_in_countdown_mode
588
+ screenshot_and_raise 'nyi' if picker_is_in_countdown_mode
544
589
  column = picker_column_for_minute
545
590
  limit = 61
546
591
  count = 0
@@ -557,8 +602,8 @@ to use the automatic mode, include this category in your CALABASH target
557
602
  end
558
603
 
559
604
  def picker_scroll_to_period(target_period_str)
560
- screenshot_and_raise "nyi" if picker_is_in_countdown_mode
561
- screenshot_and_raise "period is not applicable to 24h locale" if picker_is_in_24h_locale
605
+ screenshot_and_raise 'nyi' if picker_is_in_countdown_mode
606
+ screenshot_and_raise 'period is not applicable to 24h locale' if picker_is_in_24h_locale
562
607
  column = picker_column_for_period
563
608
  limit = 3
564
609
  count = 0