briar 0.0.4
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.
- checksums.yaml +15 -0
- data/.gitignore +29 -0
- data/Gemfile +4 -0
- data/LICENSE.txt +36 -0
- data/README.md +25 -0
- data/Rakefile +12 -0
- data/briar.gemspec +26 -0
- data/dotirbc_briar_additions +31 -0
- data/features/step_definitions/alerts_and_sheets/action_sheet_steps.rb +8 -0
- data/features/step_definitions/alerts_and_sheets/alert_view_steps.rb +25 -0
- data/features/step_definitions/bars/navbar_steps.rb +95 -0
- data/features/step_definitions/bars/tabbar_steps.rb +32 -0
- data/features/step_definitions/bars/toolbar_steps.rb +17 -0
- data/features/step_definitions/briar_core_steps.rb +9 -0
- data/features/step_definitions/control/button_steps.rb +57 -0
- data/features/step_definitions/control/segmented_control_steps.rb +85 -0
- data/features/step_definitions/control/slider_steps.rb +9 -0
- data/features/step_definitions/email_steps.rb +59 -0
- data/features/step_definitions/image_view_steps.rb +9 -0
- data/features/step_definitions/keyboard_steps.rb +21 -0
- data/features/step_definitions/label_steps.rb +21 -0
- data/features/step_definitions/picker/date_picker_steps.rb +216 -0
- data/features/step_definitions/picker/picker_steps.rb +58 -0
- data/features/step_definitions/scroll_view_steps.rb +20 -0
- data/features/step_definitions/table_steps.rb +186 -0
- data/features/step_definitions/text_field_steps.rb +37 -0
- data/features/step_definitions/text_view_steps.rb +44 -0
- data/features/support/env.rb +0 -0
- data/features/support/hooks.rb +0 -0
- data/features/support/launch.rb +0 -0
- data/lib/briar.rb +72 -0
- data/lib/briar/alerts_and_sheets/alert_view.rb +16 -0
- data/lib/briar/bars/navbar.rb +104 -0
- data/lib/briar/bars/tabbar.rb +38 -0
- data/lib/briar/bars/toolbar.rb +36 -0
- data/lib/briar/briar_core.rb +56 -0
- data/lib/briar/briar_steps.rb +26 -0
- data/lib/briar/control/button.rb +47 -0
- data/lib/briar/control/segmented_control.rb +22 -0
- data/lib/briar/control/slider.rb +34 -0
- data/lib/briar/cucumber.rb +49 -0
- data/lib/briar/email.rb +58 -0
- data/lib/briar/gestalt.rb +80 -0
- data/lib/briar/image_view.rb +27 -0
- data/lib/briar/keyboard.rb +104 -0
- data/lib/briar/label.rb +34 -0
- data/lib/briar/picker/date_picker.rb +598 -0
- data/lib/briar/picker/picker.rb +32 -0
- data/lib/briar/picker/picker_shared.rb +34 -0
- data/lib/briar/scroll_view.rb +10 -0
- data/lib/briar/table.rb +237 -0
- data/lib/briar/text_field.rb +57 -0
- data/lib/briar/text_view.rb +21 -0
- data/lib/briar/version.rb +3 -0
- data/spec/briar/gestalt_spec.rb +62 -0
- data/spec/spec_helper.rb +17 -0
- metadata +164 -0
@@ -0,0 +1,85 @@
|
|
1
|
+
#include Briar::Control::Segmented_Control
|
2
|
+
|
3
|
+
Then /^I should see segmented control "([^"]*)" with titles "([^"]*)"$/ do |control_name, titles|
|
4
|
+
@control_name = control_name
|
5
|
+
should_see_view control_name
|
6
|
+
tokens = titles.split(",")
|
7
|
+
tokens.each do |token|
|
8
|
+
token.strip!
|
9
|
+
end
|
10
|
+
idx = index_of_control_with_name control_name
|
11
|
+
if idx
|
12
|
+
actual_titles = query("segmentedControl index:#{idx} child segment child segmentLabel", :text).reverse
|
13
|
+
counter = 0
|
14
|
+
tokens.zip(actual_titles).each do |expected, actual|
|
15
|
+
unless actual.eql? expected
|
16
|
+
screenshot_and_raise "when inspecting #{control_name} i expected title: #{expected} but found: #{actual} at index #{counter}"
|
17
|
+
end
|
18
|
+
counter = counter + 1
|
19
|
+
end
|
20
|
+
else
|
21
|
+
screenshot_and_raise "could not find segmented control with name #{control_name}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
Then /^I touch segment "([^"]*)" in segmented control "([^"]*)"$/ do |segment_name, control_name|
|
26
|
+
@segment_name = segment_name
|
27
|
+
@control_name = control_name
|
28
|
+
idx = index_of_control_with_name control_name
|
29
|
+
if idx
|
30
|
+
touch("segmentedControl index:#{idx} child segment child segmentLabel marked:'#{segment_name}'")
|
31
|
+
wait_for_animation
|
32
|
+
else
|
33
|
+
screenshot_and_raise "could not find segmented control with name #{control_name}"
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
|
38
|
+
Then /^I should see segment "([^"]*)" in segmented control "([^"]*)" (is|is not) selected$/ do |segment_name, control_name, selectedness|
|
39
|
+
@segment_name = segment_name
|
40
|
+
@control_name = control_name
|
41
|
+
control_idx = index_of_control_with_name control_name
|
42
|
+
if control_idx
|
43
|
+
segment_idx = index_of_segment_with_name_in_control_with_name(segment_name, control_name)
|
44
|
+
if segment_idx
|
45
|
+
selected_arr = query("segmentedControl index:#{control_idx} child segment", :isSelected).reverse
|
46
|
+
res = selected_arr[segment_idx]
|
47
|
+
target = selectedness.eql?("is") ? 1 : 0
|
48
|
+
unless res.to_i == target
|
49
|
+
screenshot_and_raise "found segment named #{segment_name} in #{control_name}, but it was _not_ selected"
|
50
|
+
end
|
51
|
+
else
|
52
|
+
screenshot_and_raise "could not find #{segment_name} in #{control_name}"
|
53
|
+
end
|
54
|
+
else
|
55
|
+
screenshot_and_raise "could not find control named #{control_name}"
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
Then /^I should see the segment I touched (is|is not) selected and the "([^"]*)" should be set correctly$/ do |selectedness, label_id|
|
60
|
+
@associated_label = label_id
|
61
|
+
wait_for_animation
|
62
|
+
macro %Q|I should see segment "#{@segment_name}" in segmented control "#{@control_name}" #{selectedness} selected|
|
63
|
+
macro %Q|I should see label "#{label_id}" with text "#{@segment_name}"|
|
64
|
+
end
|
65
|
+
|
66
|
+
Then /^I touch the segment again$/ do
|
67
|
+
macro %Q|I touch segment "#{@segment_name}" in segmented control "#{@control_name}"|
|
68
|
+
end
|
69
|
+
|
70
|
+
Then /^I should see the segment is not selected and the detail label is cleared$/ do
|
71
|
+
macro %Q|I should see segment "#{@segment_name}" in segmented control "#{@control_name}" is not selected|
|
72
|
+
macro %Q|I should see label "#{@associated_label}" with text ""|
|
73
|
+
end
|
74
|
+
|
75
|
+
Then /^I should see the segment I touched (is|is not) selected and the "([^"]*)" in the "([^"]*)" row should be set correctly$/ do |selectedness, label_id, row_id|
|
76
|
+
@associated_label = label_id
|
77
|
+
@associated_row = row_id
|
78
|
+
macro %Q|I should see segment "#{@segment_name}" in segmented control "#{@control_name}" #{selectedness} selected|
|
79
|
+
should_see_row_with_label_with_text @associated_row, @associated_label, "#{@segment_name}"
|
80
|
+
end
|
81
|
+
|
82
|
+
Then /^I should see the segment is not selected and the label in the row is cleared$/ do
|
83
|
+
macro %Q|I should see segment "#{@segment_name}" in segmented control "#{@control_name}" is not selected|
|
84
|
+
should_see_row_with_label_with_text @associated_row, @associated_label, ""
|
85
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
#include Briar::Email
|
2
|
+
#include Briar::Core
|
3
|
+
|
4
|
+
Then /^I should see email body that contains "([^"]*)"$/ do |text|
|
5
|
+
wait_for_animation
|
6
|
+
unless email_body_first_line_is? text
|
7
|
+
screenshot_and_raise "i did not see an email body (MFComposeTextContentView) containing '#{text}'"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
Then /^I touch the "([^"]*)" row and wait to see the email view$/ do |row_id|
|
12
|
+
should_see_row row_id
|
13
|
+
touch("tableViewCell marked:'#{row_id}'")
|
14
|
+
wait_for_animation
|
15
|
+
should_see_mail_view
|
16
|
+
end
|
17
|
+
|
18
|
+
Then /^I should see email view with "([^"]*)" in the subject$/ do |text|
|
19
|
+
wait_for_animation
|
20
|
+
should_see_mail_view
|
21
|
+
unless email_subject_is? text
|
22
|
+
screenshot_and_raise "expected to see '#{text}' in 'subjectField' but found '#{actual.first}'"
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
Then /^I should see email view with to field set to "([^"]*)"$/ do |text|
|
27
|
+
should_see_mail_view
|
28
|
+
wait_for_animation
|
29
|
+
|
30
|
+
unless email_to_field_is? text
|
31
|
+
screenshot_and_raise "expected to see '#{text}' in 'subjectField' but found '#{actual.first}'"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
Then /^I should see email view with text like "([^"]*)" in the subject$/ do |text|
|
36
|
+
should_see_mail_view
|
37
|
+
wait_for_animation
|
38
|
+
|
39
|
+
unless email_subject_has_text_like? text
|
40
|
+
actual = query("view marked:'subjectField'", :text)
|
41
|
+
screenshot_and_raise "expected to see '#{text}' in 'subjectField' but found '#{actual.first}'"
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
When /^I cancel email editing I should see the "([^"]*)" view$/ do |view_id|
|
46
|
+
should_see_mail_view
|
47
|
+
wait_for_animation
|
48
|
+
|
49
|
+
if gestalt.is_ios6?
|
50
|
+
puts "WARN: iOS6 detected - navbar cancel button is not visible on iOS 6"
|
51
|
+
else
|
52
|
+
touch_navbar_item "Cancel"
|
53
|
+
wait_for_animation
|
54
|
+
touch_transition("button marked:'Delete Draft'",
|
55
|
+
"view marked:'#{view_id}'",
|
56
|
+
{:timeout=>TOUCH_TRANSITION_TIMEOUT,
|
57
|
+
:retry_frequency=>TOUCH_TRANSsITION_RETRY_FREQ})
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#include Briar::Keyboard
|
2
|
+
|
3
|
+
Then /^I should see the keyboard$/ do
|
4
|
+
should_see_keyboard
|
5
|
+
end
|
6
|
+
|
7
|
+
Then /^I should not see the keyboard$/ do
|
8
|
+
should_not_see_keyboard
|
9
|
+
end
|
10
|
+
|
11
|
+
|
12
|
+
Then /^I use the keyboard to enter "([^"]*)"$/ do |text|
|
13
|
+
wait_for_animation
|
14
|
+
should_see_keyboard
|
15
|
+
@text_entered_by_keyboard = keyboard_enter_text text
|
16
|
+
end
|
17
|
+
|
18
|
+
When /^I touch the done button the keyboard disappears$/ do
|
19
|
+
done
|
20
|
+
should_not_see_keyboard
|
21
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
#include Briar::Label
|
2
|
+
|
3
|
+
Then /^I should (see|not see) "([^"]*)" in label "([^"]*)"$/ do |visibility, text, name|
|
4
|
+
if visibility.eql? "see"
|
5
|
+
should_see_label_with_text(name, text)
|
6
|
+
else
|
7
|
+
should_not_see_label_with_text(name, text)
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
Then /^I should (see|not see) label "([^"]*)" with text "([^"]*)"$/ do |visibility, name, text|
|
12
|
+
if visibility.eql? "see"
|
13
|
+
should_see_label_with_text(name, text)
|
14
|
+
else
|
15
|
+
should_not_see_label_with_text(name, text)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
Then /^I should see an "([^"]*)" label$/ do |label_id|
|
20
|
+
should_see_label label_id
|
21
|
+
end
|
@@ -0,0 +1,216 @@
|
|
1
|
+
#include Briar::Picker::Date
|
2
|
+
|
3
|
+
# steps
|
4
|
+
|
5
|
+
Then /^I change the time on the picker to "([^"]*)"$/ do |target_time|
|
6
|
+
screenshot_and_raise "picker is not in date time or time mode" unless picker_is_in_time_mode or picker_is_in_date_and_time_mode
|
7
|
+
if picker_has_calabash_additions
|
8
|
+
date_str_to_send = date_str_to_send_to_picker_from_time_str target_time
|
9
|
+
set_picker_date_with_date_time_str (date_str_to_send)
|
10
|
+
else
|
11
|
+
tokens = target_time.split(/[: ]/)
|
12
|
+
screenshot_and_raise "could not parse '#{target_time}' into a valid time" if tokens.count > 3 or tokens.count < 1
|
13
|
+
time_in_24h_locale = tokens.count == 2
|
14
|
+
hour_token = tokens[0].to_i
|
15
|
+
period_token = tokens[2]
|
16
|
+
if time_in_24h_locale
|
17
|
+
screenshot_and_raise "'#{hour_token}' is not on (0, 23)" unless (0..23).member?(hour_token)
|
18
|
+
period_token = hour_token > 11 ? PICKER_PM : PICKER_AM
|
19
|
+
else
|
20
|
+
screenshot_and_raise "'#{hour_token}' is not on (1, 12)" unless (0..12).member?(hour_token)
|
21
|
+
am_pm_token = tokens[2]
|
22
|
+
screenshot_and_raise "'#{am_pm_token}' is not a recognized period (AM or PM)" unless (am_pm_token.eql? PICKER_AM or am_pm_token.eql? PICKER_PM)
|
23
|
+
hour_token = 0 if hour_token == 12 and am_pm_token.eql? PICKER_AM
|
24
|
+
hour_token = hour_token + 12 if hour_token < 12 and am_pm_token.eql? PICKER_PM
|
25
|
+
end
|
26
|
+
|
27
|
+
minute_token = tokens[1].to_i
|
28
|
+
screenshot_and_raise "'#{minute_token}'is not on (0, 59)" unless (0..59).member?(minute_token)
|
29
|
+
|
30
|
+
# rollback the date by 1 to avoid maxi date problems
|
31
|
+
# decided this was not a good idea because sometimes the rollback step below
|
32
|
+
# would not fire
|
33
|
+
# picker_scroll_down_on_column 0 if picker_is_in_date_and_time_mode
|
34
|
+
|
35
|
+
picker_scroll_to_hour hour_token
|
36
|
+
picker_scroll_to_minute minute_token
|
37
|
+
|
38
|
+
picker_scroll_to_period period_token if picker_is_in_12h_locale
|
39
|
+
|
40
|
+
# rollback the change we made above
|
41
|
+
# decided this was not a good idea
|
42
|
+
# sometimes this does not fire so you can end up with inconsistent dates
|
43
|
+
# see the test below
|
44
|
+
# picker_scroll_up_on_column 0 if picker_is_in_date_and_time_mode
|
45
|
+
end
|
46
|
+
|
47
|
+
@date_picker_time_12h = picker_is_in_12h_locale ? picker_time_12h_str : picker_time_for_other_locale
|
48
|
+
@date_picker_time_24h = picker_is_in_24h_locale ? picker_time_24h_str : picker_time_for_other_locale
|
49
|
+
|
50
|
+
# this test catches problems (it is how i caught the scroll down/scroll up
|
51
|
+
# described in the comment block above)
|
52
|
+
unless time_strings_are_equivalent(@date_picker_time_12h, @date_picker_time_24h)
|
53
|
+
screenshot_and_raise "ERROR: changing the picker resulted in two different times: 12H => '#{@date_picker_time_12h}' 24H => '#{@date_picker_time_24h}'"
|
54
|
+
end
|
55
|
+
|
56
|
+
if picker_is_in_date_and_time_mode
|
57
|
+
@date_picker_date_time_12h = picker_is_in_12h_locale ? picker_date_and_time_str_12h : picker_date_and_time_str_for_other_locale
|
58
|
+
@date_picker_date_time_24h = picker_is_in_24h_locale ? picker_date_and_time_str_24h : picker_date_and_time_str_for_other_locale
|
59
|
+
# this test catches problems (it is how i caught the scroll down/scroll up
|
60
|
+
# described in the comment block above)
|
61
|
+
unless date_time_strings_are_equivalent(@date_picker_date_time_12h, @date_picker_date_time_24h)
|
62
|
+
screenshot_and_raise "ERROR: changing the picker resulted in two different dates: 12H => '#{@date_picker_date_time_12h}' 24H => '#{@date_picker_date_time_24h}'"
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
unless target_time.eql? @date_picker_time_12h or target_time.eql? @date_picker_time_24h
|
67
|
+
screenshot_and_raise "tried to change the time to '#{target_time}' but found '#{@date_picker_time_12h}' or '#{@date_picker_time_24h}'"
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
Then /^I change the date on the picker to "([^"]*)"$/ do |target_date|
|
72
|
+
if picker_has_calabash_additions
|
73
|
+
date_str_to_send = date_str_to_send_to_picker_from_date_str target_date
|
74
|
+
set_picker_date_with_date_time_str (date_str_to_send)
|
75
|
+
else
|
76
|
+
unless picker_weekday_month_day_is(target_date)
|
77
|
+
# figure out which way to turn the picker
|
78
|
+
# target = Date.parse(target_date)
|
79
|
+
dir = (Date.parse(target_date) < Date.today) ? "down" : "up"
|
80
|
+
limit = 60
|
81
|
+
count = 0
|
82
|
+
begin
|
83
|
+
dir.eql?("down") ? picker_scroll_down_on_column(0) : picker_scroll_up_on_column(0)
|
84
|
+
sleep(PICKER_STEP_PAUSE)
|
85
|
+
count = count + 1
|
86
|
+
end while ((not picker_weekday_month_day_is(target_date)) and count < limit)
|
87
|
+
end
|
88
|
+
unless picker_weekday_month_day_is(target_date)
|
89
|
+
screenshot_and_raise "scrolled '#{limit}' and could not change date to #{target_date}"
|
90
|
+
end
|
91
|
+
|
92
|
+
@date_picker_date_time_12h = picker_is_in_12h_locale ? picker_date_and_time_str_12h : picker_date_and_time_str_for_other_locale
|
93
|
+
@date_picker_date_time_24h = picker_is_in_24h_locale ? picker_date_and_time_str_24h : picker_date_and_time_str_for_other_locale
|
94
|
+
if picker_is_in_date_and_time_mode
|
95
|
+
@date_picker_time_12h = picker_is_in_12h_locale ? picker_time_12h_str : picker_time_for_other_locale
|
96
|
+
@date_picker_time_24h = picker_is_in_24h_locale ? picker_time_24h_str : picker_time_for_other_locale
|
97
|
+
unless time_strings_are_equivalent(@date_picker_time_12h, @date_picker_time_24h)
|
98
|
+
screenshot_and_raise "ERROR: changing the picker resulted in two different times: 12H => '#{@date_picker_time_12h}' 24H => '#{@date_picker_time_24h}'"
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
|
105
|
+
Then /^I change the picker date to "([^"]*)" and the time to "([^"]*)"$/ do |target_date, target_time|
|
106
|
+
macro %Q|I change the date on the picker to "#{target_date}"|
|
107
|
+
macro %Q|I change the time on the picker to "#{target_time}"|
|
108
|
+
end
|
109
|
+
|
110
|
+
Then /^I change the picker to (\d+) days? ago$/ do |days_ago|
|
111
|
+
today = Date.today
|
112
|
+
days_ago = today -= days_ago.to_i
|
113
|
+
fmt = picker_is_in_24h_locale ? PICKER_24H_DATE_FMT : PICKER_12H_DATE_FMT
|
114
|
+
target_date = days_ago.strftime(fmt).squeeze(" ").strip
|
115
|
+
macro %Q|I change the date on the picker to "#{target_date}"|
|
116
|
+
end
|
117
|
+
|
118
|
+
|
119
|
+
Then /^I change the picker to (\d+) days? ago at "([^"]*)"$/ do |days_ago, target_time|
|
120
|
+
today = Date.today
|
121
|
+
days_ago = today -= days_ago.to_i
|
122
|
+
fmt = picker_is_in_24h_locale ? PICKER_24H_DATE_FMT : PICKER_12H_DATE_FMT
|
123
|
+
target_date = days_ago.strftime(fmt).squeeze(" ").strip
|
124
|
+
macro %Q|I change the picker date to "#{target_date}" and the time to "#{target_time}"|
|
125
|
+
end
|
126
|
+
|
127
|
+
# requires that the picker is visible
|
128
|
+
Then /^the text in the "([^"]*)" label should match picker date and time$/ do |label_id|
|
129
|
+
text = query("view marked:'#{label_id}'", :text).first
|
130
|
+
screenshot_and_raise "could not find label with id '#{label_id}'"
|
131
|
+
date_time_24h = picker_is_in_24h_locale ? picker_date_and_time_str_24h : picker_date_and_time_str_for_other_locale
|
132
|
+
date_time_12h = picker_is_in_12h_locale ? picker_date_and_time_str_12h : picker_date_and_time_str_for_other_locale
|
133
|
+
unless (text.eql? date_time_12h) or (text.eql? date_time_24h)
|
134
|
+
screenshot_and_raise "expected '#{text}' to match '#{date_time_12h}' or '#{date_time_24h}'"
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
Then /^I change the picker date time to "([^"]*)"$/ do |target_time|
|
139
|
+
date_str = picker_date_str
|
140
|
+
macro %Q|I change the picker date to "#{date_str}" and the time to "#{target_time}"|
|
141
|
+
end
|
142
|
+
|
143
|
+
Then /^I should see that the date picker is in time mode$/ do
|
144
|
+
res = query("datePicker", :datePickerMode).first
|
145
|
+
unless res
|
146
|
+
screenshot_and_raise "expected to a date picker"
|
147
|
+
end
|
148
|
+
unless res == UIDatePickerModeTime
|
149
|
+
screenshot_and_raise "expected to see picker with time mode but found mode '#{res}'"
|
150
|
+
end
|
151
|
+
end
|
152
|
+
|
153
|
+
# requires picker is visible
|
154
|
+
Then /^I should see that the time on the picker is now$/ do
|
155
|
+
time_hash = time_hash_by_add_minutes_until_at_closest_interval (now_time_12h_locale)
|
156
|
+
at_interval_12h = time_hash[:h12]
|
157
|
+
at_interval_24h = time_hash[:h24]
|
158
|
+
picker_time = picker_time_str
|
159
|
+
unless picker_time.eql? at_interval_12h or picker_time.eql? at_interval_24h
|
160
|
+
screenshot_and_raise "expected to picker time to be '#{at_interval_12h}' or '#{at_interval_24h}' but found '#{picker_time}'"
|
161
|
+
end
|
162
|
+
end
|
163
|
+
|
164
|
+
# requires a time or date change. picker does not need to be visible
|
165
|
+
Then /^I should see that the "([^"]*)" row has the time I just entered in the "([^"]*)" label$/ do |row_id, label_id|
|
166
|
+
arr = query("tableViewCell marked:'#{row_id}' isHidden:0 descendant label marked:'#{label_id}'", :text)
|
167
|
+
screenshot_and_raise "could not find '#{label_id}' in the '#{row_id}' row" if arr.empty?
|
168
|
+
actual_text = arr.first
|
169
|
+
unless (actual_text.eql? @date_picker_time_12h) or (actual_text.eql? @date_picker_time_24h)
|
170
|
+
screenshot_and_raise "expected to see '#{@date_picker_time_12h}' or '#{@date_picker_time_24h}' in '#{label_id}' but found '#{actual_text}'"
|
171
|
+
end
|
172
|
+
end
|
173
|
+
|
174
|
+
# does not require a time or date change. picker needs to be visible
|
175
|
+
Then /^I should see that the "([^"]*)" row has the same time as the picker in the "([^"]*)" label$/ do |row_id, label_id|
|
176
|
+
arr = query("tableViewCell marked:'#{row_id}' isHidden:0 descendant label marked:'#{label_id}'", :text)
|
177
|
+
screenshot_and_raise "could not find '#{label_id}' in the '#{row_id}'" if arr.empty?
|
178
|
+
time_str_12h = picker_is_in_12h_locale ? picker_time_12h_str : picker_time_for_other_locale
|
179
|
+
time_str_24h = picker_is_in_24h_locale ? picker_time_24h_str : picker_time_for_other_locale
|
180
|
+
actual_text = arr.first
|
181
|
+
unless (actual_text.eql? time_str_12h) or (actual_text.eql? time_str_24h)
|
182
|
+
screenshot_and_raise "expected to see '#{time_str_12h}' or '#{time_str_24h}' in '#{label_id}' but found '#{actual_text}'"
|
183
|
+
end
|
184
|
+
end
|
185
|
+
|
186
|
+
# requires a time or date change. picker does not need to be visible
|
187
|
+
Then /^I should see that the "([^"]*)" row has the date and time I just entered in the "([^"]*)" label$/ do |row_id, label_id|
|
188
|
+
arr = query("tableViewCell marked:'#{row_id}' isHidden:0 descendant label marked:'#{label_id}'", :text)
|
189
|
+
screenshot_and_raise "could not find '#{label_id}' in the '#{row_id}' row" if arr.empty?
|
190
|
+
actual_text = arr.first
|
191
|
+
unless (actual_text.eql? @date_picker_date_time_12h) or (actual_text.eql? @date_picker_date_time_24h)
|
192
|
+
screenshot_and_raise "expected to see '#{@date_picker_date_time_12h}' or '#{@date_picker_date_time_24h}' in '#{label_id}' but found '#{actual_text}'"
|
193
|
+
end
|
194
|
+
end
|
195
|
+
|
196
|
+
Then /^I change the minute interval on the picker to (1|5|10|30) minutes?$/ do |target_interval|
|
197
|
+
res = query("datePicker", [{setMinuteInterval:target_interval.to_i}])
|
198
|
+
screenshot_and_raise "did not find a date picker - could not set the minute interval" if res.empty?
|
199
|
+
sleep(PICKER_STEP_PAUSE * 5)
|
200
|
+
@picker_minute_interval = target_interval.to_i
|
201
|
+
end
|
202
|
+
|
203
|
+
Then /^I change the time on the picker to (\d+) minutes? from now$/ do |target_minute|
|
204
|
+
future = Time.new + (60 * target_minute.to_i)
|
205
|
+
time_str = future.strftime(PICKER_12H_TIME_FMT).squeeze(" ").strip
|
206
|
+
macro %Q|I change the time on the picker to "#{time_str}"|
|
207
|
+
sleep(PICKER_STEP_PAUSE)
|
208
|
+
end
|
209
|
+
|
210
|
+
Then /^I change the time on the picker to (\d+) minutes? before now$/ do |target_minute|
|
211
|
+
past = Time.new - (60 * target_minute.to_i)
|
212
|
+
time_str = past.strftime(PICKER_12H_TIME_FMT).squeeze(" ").strip
|
213
|
+
macro %Q|I change the time on the picker to "#{time_str}"|
|
214
|
+
sleep(PICKER_STEP_PAUSE)
|
215
|
+
end
|
216
|
+
|
@@ -0,0 +1,58 @@
|
|
1
|
+
#include Briar::Picker
|
2
|
+
|
3
|
+
# may only work on circular pickers - does _not_ work on non-circular pickers
|
4
|
+
# because the visible titles do _not_ follow the selected index
|
5
|
+
Then /^I should see picker "([^"]*)" with row "([^"]*)" selected$/ do |picker_name, row_named|
|
6
|
+
should_see_picker picker_name
|
7
|
+
selected_title = selected_title_for_column 0
|
8
|
+
unless selected_title.eql?(row_named)
|
9
|
+
screenshot_and_raise "found picker named #{picker_name} but #{row_named} was not selected - found #{selected_title}"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
Then /^I scroll (up|down) on picker "([^"]*)"$/ do |dir, picker_name|
|
14
|
+
should_see_picker picker_name
|
15
|
+
if dir.eql? "down"
|
16
|
+
picker_scroll_down_on_column 0
|
17
|
+
else
|
18
|
+
picker_scroll_up_on_column 0
|
19
|
+
end
|
20
|
+
step_pause
|
21
|
+
end
|
22
|
+
|
23
|
+
Then /^I scroll (up|down) on picker "([^"]*)" to row (\d+)$/ do |dir, picker, row|
|
24
|
+
should_see_picker picker
|
25
|
+
target_row = row.to_i
|
26
|
+
unless picker_current_index_for_column_is(0, target_row)
|
27
|
+
count = 0
|
28
|
+
begin
|
29
|
+
if dir.eql? "down"
|
30
|
+
picker_scroll_down_on_column 0
|
31
|
+
else
|
32
|
+
picker_scroll_up_on_column 0
|
33
|
+
end
|
34
|
+
count = count + 1
|
35
|
+
step_pause
|
36
|
+
end while ((not picker_current_index_for_column_is(0, target_row)) and count < 20)
|
37
|
+
end
|
38
|
+
|
39
|
+
unless picker_current_index_for_column_is(0, target_row)
|
40
|
+
screenshot_and_raise "scrolled #{dir} on picker 20 times but never found row #{row}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
Then /^I should see picker "([^"]*)" has selected row (\d+)$/ do |picker, row|
|
45
|
+
should_see_picker picker
|
46
|
+
unless picker_current_index_for_column_is(0, row.to_i)
|
47
|
+
screenshot_and_raise "expected picker #{picker} to have #{row} selected but found #{picker_current_index_for_column 0}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
Then /^I should (see|not see) picker "([^"]*)"$/ do |visibility, picker|
|
52
|
+
target = visibility.eql? "see"
|
53
|
+
if target
|
54
|
+
should_see_picker picker
|
55
|
+
else
|
56
|
+
should_not_see_picker picker
|
57
|
+
end
|
58
|
+
end
|