briar 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MmNiZGVhYTAwYTllYWE2NGU1Njg2MmY2NThhN2MyOGE2MTRlMjk0Zg==
4
+ NzIwYTIwOTk1NzRkOGIwYjljZTZiZWM4YTY4YTg3ZjNiNmUxZjNmMA==
5
5
  data.tar.gz: !binary |-
6
- M2U0ZWJkNDBmZjljNzJiZTM3ZmY3ZWVjZTViNGY0NDdhY2VmMmI1YQ==
6
+ YzBjM2M5M2RmMDlmZWQwNDFiYWJhZTk1MWJkNjk5NDU3NjY5ZmE5Zg==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- NThkZDk3YjUxNDI1MGE4NWRiZDdlMWVkZjcwYzcyMGE3NDU1MTY2ZmI4Yzcz
10
- MjM1Njk0NDMzZDY2YmVhYWIwNjdjZTM3MjRlMWFkMzZmM2FlYmZjOTRmMTFi
11
- MTYwYWM4MmE3Y2Q4ZGViMDI4OGYxMTNlZjYwN2ZlMWE4M2MwMTI=
9
+ OTFmOWY1M2JkODY1YmRhMjEzYjBkMWU5N2ZiNzFkNDE3OWM1OGE4NTljM2Zj
10
+ MDQwNzNhYjJiNzMzMDg2YmIxYTE1OGVmMGMwODc3Y2NkZWJkY2UwZjE3ZGM4
11
+ MzQxMGJmZjMyYTUwZjEwNTgzNjYzZDRlMDg1YWJlZDI4YWUzNzE=
12
12
  data.tar.gz: !binary |-
13
- Mjc5MjIyYzQwY2ZkZGMyZjU3NGQyNDIwM2EwZGY2MzMxMmJhZmYzYTAzMDJk
14
- ZWM0NDlmOTg0NmU5NmFlN2ViNjRkYjRiZWNhYzlmOGIwM2FmN2UxMDM5YjRi
15
- Y2E0OGY3ZWRhMDBjYzliZWYxM2Y0YTE1OTQ0MTc2ZjYyYTBiZDM=
13
+ MTBhYjhmYTAyZTQxM2IxMmUwNmUzOTVlMzQ2ZmJjYmY0NjhlMzk4NmNhNjBl
14
+ NjM4M2RlNzc0ZTRhNTgyM2Y4YTIwZGFjODBmYTM1MWFjMzQ0YzNlNjMzOGIw
15
+ MjllNjgxMjExZTM3NDc2ZDEwYTk3ZWZhNDJhN2Y4NTBhOGRkYTY=
@@ -15,13 +15,8 @@ Gem::Specification.new do |gem|
15
15
  gem.license = 'MIT'
16
16
 
17
17
  gem.add_runtime_dependency 'calabash-cucumber'
18
- #gem.add_runtime_dependency 'calabash-cucumber', '0.9.159'
19
18
  gem.add_runtime_dependency 'rake'
20
19
  gem.add_runtime_dependency 'syntax'
21
- gem.add_runtime_dependency 'rspec'
22
-
23
- # rubymine is not picking up development dependencies in the gemspec
24
- #gem.add_development_dependency 'rspec'
25
20
 
26
21
  gem.files = `git ls-files`.split($/)
27
22
  gem.executables = 'briar'
@@ -2,8 +2,8 @@ Then /^I touch the "([^"]*)" button on the action sheet$/ do |button_title|
2
2
  timeout = 1.0
3
3
  msg = "waited for '#{timeout}' seconds but did not see sheet with button '#{button_title}'"
4
4
  options = {:timeout => timeout,
5
- :retry_frequency => 0.2,
6
- :post_timeout => 0.1,
5
+ :retry_frequency => BRIAR_RETRY_FREQ,
6
+ :post_timeout => BRIAR_POST_TIMEOUT,
7
7
  :timeout_message => msg}
8
8
  wait_for(options) do
9
9
  not query('actionSheet').empty?
@@ -27,7 +27,7 @@ When /^I touch the "([^"]*)" tab I should see the "([^"]*)" view$/ do |tab_label
27
27
  end
28
28
 
29
29
  Then /^I should see "([^"]*)" tabs$/ do |list_of_tabs|
30
- tabs = list_of_tabs.split(/,\s?/)
30
+ tabs = tokenize_list(list_of_tabs)
31
31
  index = 0
32
32
  tabs.each do |tab|
33
33
  should_see_tab_at_index tab.strip! || tab, index
@@ -3,45 +3,52 @@ Then /^I should see segmented control "([^"]*)" with titles "([^"]*)"$/ do |cont
3
3
  should_see_control_with_segment_titles control_id, titles
4
4
  end
5
5
 
6
- Then /^I touch segment "([^"]*)" in segmented control "([^"]*)"$/ do |segment_id, control_id|
6
+ Then /^I touch the "([^"]*)" segment in segmented control "([^"]*)"$/ do |segment_id, control_id|
7
7
  touch_segment segment_id, control_id
8
8
  end
9
9
 
10
-
11
10
  Then /^I should see segment "([^"]*)" in segmented control "([^"]*)" (is|is not) selected$/ do |segment_id, control_id, selectedness|
12
11
  should_see_segment_with_selected_state control_id, segment_id, selectedness.eql?('is') ? 1 : 0
13
12
  end
14
13
 
14
+
15
+ ### deprecated - will remove in future versions ####
16
+
15
17
  Then /^I should see the segment I touched (is|is not) selected and the "([^"]*)" should be set correctly$/ do |selectedness, label_id|
16
- @associated_label = label_id
17
- should_see_segment_with_selected_state @control_id, @segment_id, selectedness.eql?('is') ? 1 : 0
18
- # unexpected!
19
- # this is a label outside the control that is set by touching the segment
20
- # not so good because it conflates segment_id and the title of the segment
21
- should_see_label_with_text label_id, @segment_id
18
+ pending('deprecated 0.1.1 - no replacement')
19
+ #@associated_label = label_id
20
+ #should_see_segment_with_selected_state @control_id, @segment_id, selectedness.eql?('is') ? 1 : 0
21
+ ## unexpected!
22
+ ## this is a label outside the control that is set by touching the segment
23
+ ## not so good because it conflates segment_id and the title of the segment
24
+ #should_see_label_with_text label_id, @segment_id
22
25
  end
23
26
 
24
27
  Then /^I touch the segment again$/ do
25
- touch_segment @segment_id, @control_id
28
+ pending('deprecated 0.1.1 - no replacement')
29
+ #touch_segment @segment_id, @control_id
26
30
  end
27
31
 
28
32
  Then /^I should see the segment is not selected and the detail label is cleared$/ do
29
- # ugh - that @associated_label variable needs to be set
30
- macro %Q|I should see segment "#{@segment_id}" in segmented control "#{@control_id}" is not selected|
31
- macro %Q|I should see label "#{@associated_label}" with text ""|
33
+ pending('deprecated 0.1.1 - no replacement')
34
+ ## ugh - that @associated_label variable needs to be set
35
+ #macro %Q|I should see segment "#{@segment_id}" in segmented control "#{@control_id}" is not selected|
36
+ #macro %Q|I should see label "#{@associated_label}" with text ""|
32
37
  end
33
38
 
34
39
  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|
35
- # ugh - that @associated_label variable needs to be set
36
- @associated_label = label_id
37
- @associated_row = row_id
38
- macro %Q|I should see segment "#{@segment_id}" in segmented control "#{@control_id}" #{selectedness} selected|
39
- should_see_row_with_label_with_text @associated_row, @associated_label, "#{@segment_id}"
40
+ pending('deprecated 0.1.1 - no replacement')
41
+ ## ugh - that @associated_label variable needs to be set
42
+ #@associated_label = label_id
43
+ #@associated_row = row_id
44
+ #macro %Q|I should see segment "#{@segment_id}" in segmented control "#{@control_id}" #{selectedness} selected|
45
+ #should_see_row_with_label_with_text @associated_row, @associated_label, "#{@segment_id}"
40
46
  end
41
47
 
42
48
  Then /^I should see the segment is not selected and the label in the row is cleared$/ do
43
- # ugh - difficult to extract to a function because we need the
44
- # @associated_row and @associated_label to be set
45
- macro %Q|I should see segment "#{@segment_id}" in segmented control "#{@control_id}" is not selected|
46
- should_see_row_with_label_with_text @associated_row, @associated_label, ""
49
+ pending('deprecated 0.1.1 - no replacement')
50
+ ## ugh - difficult to extract to a function because we need the
51
+ ## @associated_row and @associated_label to be set
52
+ #macro %Q|I should see segment "#{@segment_id}" in segmented control "#{@control_id}" is not selected|
53
+ #should_see_row_with_label_with_text @associated_row, @associated_label, ""
47
54
  end
@@ -8,7 +8,7 @@ Then /^I should see email view with body that contains "([^"]*)"$/ do |text|
8
8
  if not device.ios5?
9
9
  warn_about_no_ios5_email_view
10
10
  else
11
- wait_for_animation
11
+ 2.times { step_pause }
12
12
  unless email_body_contains? text
13
13
  screenshot_and_raise "expected to see email body containing '#{text} but found '#{email_body}'"
14
14
  end
@@ -16,20 +16,18 @@ Then /^I should see email view with body that contains "([^"]*)"$/ do |text|
16
16
  end
17
17
 
18
18
  Then /^I touch the "([^"]*)" row and wait to see the email view$/ do |row_id|
19
+ if email_not_testable?
20
+ warn_about_no_ios5_email_view
21
+ return
22
+ end
23
+
19
24
  if device_can_send_email
20
- # cannot do the usual - touch_row_and_wait_to_see because sometimes
21
- # we will not see because in iOS 6, email compose views cannot be queried
22
- # by calabash
23
25
  should_see_row row_id
24
- touch("tableViewCell marked:'#{row_id}'")
25
- wait_for_animation
26
- if not device.ios5?
27
- warn_about_no_ios5_email_view
28
- else
29
- should_see_mail_view
30
- end
26
+ briar_scroll_to_row_and_touch row_id
27
+ 2.times { step_pause }
28
+ should_see_mail_view
31
29
  else
32
- pending 'device is not configured for email so a system alert is probably generated, which we cannot touch'
30
+ pending 'device is not configured for email so a system alert is probably generated'
33
31
  end
34
32
  end
35
33
 
@@ -63,7 +61,7 @@ Then /^I should see email view with text like "([^"]*)" in the subject$/ do |tex
63
61
  warn_about_no_ios5_email_view
64
62
  else
65
63
  should_see_mail_view
66
- wait_for_animation
64
+ 2.times { step_pause }
67
65
  unless email_subject_has_text_like? text
68
66
  screenshot_and_raise "expected to see '#{text}' in the email subject but found '#{email_subject}'"
69
67
  end
@@ -71,11 +69,7 @@ Then /^I should see email view with text like "([^"]*)" in the subject$/ do |tex
71
69
  end
72
70
 
73
71
  When /^I cancel email editing I should see the "([^"]*)" view$/ do |view_id|
74
- if not device.ios5?
75
- delete_draft_and_wait_for view_id
76
- else
77
- warn_about_no_ios5_email_view
78
- end
72
+ delete_draft_and_wait_for view_id
79
73
  end
80
74
 
81
75
  Given(/^we are testing on the simulator or a device configured to send emails$/) do
@@ -88,3 +82,10 @@ Given(/^we are testing on the simulator or a device configured to send emails$/)
88
82
  pending 'device is not configured to send email - we cannot proceed with email view testing'
89
83
  end
90
84
  end
85
+
86
+ Given(/^I can test an email view$/) do
87
+ if (not device.ios5?) and (not uia_available?)
88
+ warn_about_no_ios5_email_view
89
+ pending('cannot test email views yet')
90
+ end
91
+ end
@@ -18,15 +18,17 @@ When /^I touch the done button the keyboard disappears$/ do
18
18
  should_not_see_keyboard
19
19
  end
20
20
 
21
+
21
22
  Then /^I touch the delete key$/ do
22
23
  keyboard_enter_char 'Delete'
23
24
  end
24
25
 
25
26
  Then(/^I turn off spell checking and capitalization$/) do
26
- should_see_keyboard
27
- turn_autocapitalization_off
28
- turn_autocorrect_off
29
- turn_spell_correct_off
27
+ pending('deprecated 0.1.1 - not working')
28
+ #should_see_keyboard
29
+ #turn_autocapitalization_off
30
+ #turn_autocorrect_off
31
+ #turn_spell_correct_off
30
32
  end
31
33
 
32
34
  Then /^I am done text editing$/ do
@@ -77,7 +77,7 @@ Then /^I should see "([^"]*)" in row (\d+)$/ do |row_id, row_index|
77
77
  end
78
78
 
79
79
  Then /^I should see the rows in this order "([^"]*)"$/ do |row_ids|
80
- tokens = row_ids.split(',')
80
+ tokens = tokenize_list(row_ids)
81
81
  counter = 0
82
82
  tokens.each do |token|
83
83
  token.strip!
@@ -1,11 +1,19 @@
1
1
  #$:.unshift File.dirname(__FILE__)
2
2
 
3
3
  DEVICE_ENDPOINT = (ENV['DEVICE_ENDPOINT'] || 'http://localhost:37265')
4
+
5
+ # deprecate these #
4
6
  TOUCH_TRANSITION_TIMEOUT = 30.0
5
7
  TOUCH_TRANSITION_RETRY_FREQ = 0.5
8
+ ##################
9
+
6
10
  BRIAR_STEP_PAUSE = (ENV['STEP_PAUSE'] || 0.5).to_f
7
11
  BRIAR_WAIT_TIMEOUT = (ENV['WAIT_TIMEOUT'] || 2.0).to_f
12
+ BRIAR_RETRY_FREQ = (ENV['RETRY_FREQ'] || 0.1).to_f
13
+ BRIAR_POST_TIMEOUT = (ENV['POST_TIMEOUT'] || 0.2).to_f
14
+
8
15
  ANIMATION_PAUSE = (ENV['ANIMATION_PAUSE'] || 0.6).to_f
16
+
9
17
  #noinspection RubyConstantNamingConvention
10
18
  AI = :accessibilityIdentifier
11
19
  #noinspection RubyConstantNamingConvention
@@ -64,9 +72,12 @@ def device ()
64
72
  end
65
73
 
66
74
  def uia_available?
67
- launcher = Calabash::Cucumber::Launcher.launcher
68
- return false if launcher.nil?
69
- launcher.active?
75
+ # proxy for testing if run_loop exists
76
+ if default_device.nil?
77
+ false
78
+ else
79
+ true
80
+ end
70
81
  end
71
82
 
72
83
  #noinspection RubyDefParenthesesInspection
@@ -36,8 +36,8 @@ module Briar
36
36
  def wait_for_sheet (sheet_id, timeout=BRIAR_WAIT_TIMEOUT)
37
37
  msg = "waited for '#{timeout}' seconds but did not see '#{sheet_id}'"
38
38
  wait_for(:timeout => timeout,
39
- :retry_frequency => 0.2,
40
- :post_timeout => 0.1,
39
+ :retry_frequency => BRIAR_RETRY_FREQ,
40
+ :post_timeout => BRIAR_POST_TIMEOUT,
41
41
  :timeout_message => msg ) do
42
42
  sheet_exists? sheet_id
43
43
  end
@@ -46,8 +46,8 @@ module Briar
46
46
  def wait_for_sheet_to_disappear(sheet_id, timeout=BRIAR_WAIT_TIMEOUT)
47
47
  msg = "waited for '#{timeout}' seconds for '#{sheet_id}' to disappear but it is still visible"
48
48
  options = {:timeout => timeout,
49
- :retry_frequency => 0.2,
50
- :post_timeout => 0.1,
49
+ :retry_frequency => BRIAR_RETRY_FREQ,
50
+ :post_timeout => BRIAR_POST_TIMEOUT,
51
51
  :timeout_message => msg}
52
52
  wait_for(options) do
53
53
  not sheet_exists? sheet_id
@@ -49,8 +49,8 @@ module Briar
49
49
  qstr = 'alertView child label'
50
50
  msg = "waited for '#{timeout}' for alert with title '#{title}'"
51
51
  wait_for(:timeout => timeout,
52
- :retry_frequency => 0.2,
53
- :post_timeout => 0.1,
52
+ :retry_frequency => BRIAR_RETRY_FREQ,
53
+ :post_timeout => BRIAR_POST_TIMEOUT,
54
54
  :timeout_message => msg) do
55
55
  query(qstr, :text).include?(title)
56
56
  end
@@ -68,8 +68,8 @@ module Briar
68
68
  qstr = 'alertView child label'
69
69
  msg = "waited for '#{timeout}' for alert with message '#{message}'"
70
70
  wait_for(:timeout => timeout,
71
- :retry_frequency => 0.2,
72
- :post_timeout => 0.1,
71
+ :retry_frequency => BRIAR_RETRY_FREQ,
72
+ :post_timeout => BRIAR_POST_TIMEOUT,
73
73
  :timeout_message => msg) do
74
74
  query(qstr, :text).include?(title)
75
75
  end
@@ -26,8 +26,8 @@ module Briar
26
26
  timeout = BRIAR_WAIT_TIMEOUT * 2.0
27
27
  msg = "waited for '#{timeout}' seconds but did not see navbar back button"
28
28
  wait_for(:timeout => timeout,
29
- :retry_frequency => 0.2,
30
- :post_timeout => 0.1,
29
+ :retry_frequency => BRIAR_RETRY_FREQ,
30
+ :post_timeout => BRIAR_POST_TIMEOUT,
31
31
  :timeout_message => msg) do
32
32
  navbar_has_back_button?
33
33
  end
@@ -52,8 +52,8 @@ module Briar
52
52
  timeout = BRIAR_WAIT_TIMEOUT
53
53
  msg = "waited for '#{timeout}' seconds but did not see '#{name}' in navigation bar"
54
54
  wait_for(:timeout => timeout,
55
- :retry_frequency => 0.2,
56
- :post_timeout => 0.1,
55
+ :retry_frequency => BRIAR_RETRY_FREQ,
56
+ :post_timeout => BRIAR_POST_TIMEOUT,
57
57
  :timeout_message => msg) do
58
58
  element_exists qstr
59
59
  end
@@ -73,8 +73,8 @@ module Briar
73
73
  timeout = 1.0
74
74
  msg = "waited for '#{timeout}' seconds but i still see '#{name}' in navigation bar"
75
75
  wait_for(:timeout => timeout,
76
- :retry_frequency => 0.2,
77
- :post_timeout => 0.1,
76
+ :retry_frequency => BRIAR_RETRY_FREQ,
77
+ :post_timeout => BRIAR_POST_TIMEOUT,
78
78
  :timeout_message => msg) do
79
79
  element_does_not_exist qstr
80
80
  end
@@ -97,7 +97,8 @@ module Briar
97
97
  def go_back_after_waiting
98
98
  sleep(0.2)
99
99
  wait_for(:timeout => 1.0,
100
- :retry_frequency => 0.2) do
100
+ :retry_frequency => BRIAR_RETRY_FREQ,
101
+ :post_timeout => BRIAR_POST_TIMEOUT) do
101
102
  not query('navigationItemButtonView first').empty?
102
103
  end
103
104
  touch('navigationItemButtonView first')
@@ -106,8 +107,8 @@ module Briar
106
107
 
107
108
  def go_back_and_wait_for_view (view)
108
109
  sleep(0.2)
109
- wait_for(:timeout => 1.0,
110
- :retry_frequency => 0.2) do
110
+ wait_for(:timeout => BRIAR_WAIT_TIMEOUT,
111
+ :retry_frequency => BRIAR_RETRY_FREQ) do
111
112
  not query('navigationItemButtonView first').empty?
112
113
  end
113
114
 
@@ -119,8 +120,8 @@ module Briar
119
120
  end
120
121
 
121
122
  def touch_navbar_item(item_name, wait_for_view_id=nil)
122
- wait_for(:timeout => 1.0,
123
- :retry_frequency => 0.4) do
123
+ wait_for(:timeout => BRIAR_WAIT_TIMEOUT,
124
+ :retry_frequency => BRIAR_RETRY_FREQ) do
124
125
  (index_of_navbar_button(item_name) != nil) || button_exists?(item_name)
125
126
  end
126
127
  sleep(0.2)
@@ -154,17 +155,12 @@ module Briar
154
155
  def should_see_navbar_with_title(title, timeout=BRIAR_WAIT_TIMEOUT)
155
156
  msg = "waited for '#{timeout}' seconds but i did not see #{title} in navbar"
156
157
  wait_for(:timeout => timeout,
157
- :retry_frequency => 0.2,
158
- :post_timeout => 0.1,
158
+ :retry_frequency => BRIAR_RETRY_FREQ,
159
+ :post_timeout => BRIAR_POST_TIMEOUT,
159
160
  :timeout_message => msg) do
160
161
  navbar_has_title? title
161
162
  end
162
163
  end
163
-
164
-
165
- def navbar_should_have_title(title)
166
- pending "deprecated 0.0.6 - use should_see_navbar_with_title '#{title}'"
167
- end
168
164
  end
169
165
  end
170
166
 
@@ -25,8 +25,8 @@ module Briar
25
25
 
26
26
  def touch_tabbar_item(name, wait_for_view_id=nil)
27
27
  sleep(0.2)
28
- wait_for(:timeout => 1.0,
29
- :retry_frequency => 0.4) do
28
+ wait_for(:timeout => BRIAR_WAIT_TIMEOUT,
29
+ :retry_frequency => BRIAR_RETRY_FREQ) do
30
30
  index_of_tabbar_item(name) != nil
31
31
  end
32
32
  should_see_tabbar
@@ -49,10 +49,6 @@ module Briar
49
49
  screenshot_and_raise "should have seen tab named '#{name}' at index '#{index}' but found these: '#{tabs}'"
50
50
  end
51
51
  end
52
-
53
- def tabbar_item_is_at_index(name, index)
54
- pending "deprecated 0.0.6 - use should_see_tab_at_index '#{name}', '#{index}'"
55
- end
56
52
  end
57
53
  end
58
54
 
@@ -94,8 +94,8 @@ module Briar
94
94
  def wait_for_view (view_id, timeout=BRIAR_WAIT_TIMEOUT)
95
95
  msg = "waited for '#{timeout}' seconds but did not see '#{view_id}'"
96
96
  wait_for(:timeout => timeout,
97
- :retry_frequency => 0.2,
98
- :post_timeout => 0.1,
97
+ :retry_frequency => BRIAR_RETRY_FREQ,
98
+ :post_timeout => BRIAR_POST_TIMEOUT,
99
99
  :timeout_message => msg) do
100
100
  view_exists? view_id
101
101
  end
@@ -104,8 +104,8 @@ module Briar
104
104
  def wait_for_query(qstr, timeout=BRIAR_WAIT_TIMEOUT)
105
105
  msg = "waited for '#{timeout}' seconds but did not see\n '#{qstr}'"
106
106
  wait_for(:timeout => timeout,
107
- :retry_frequency => 0.2,
108
- :post_timeout => 0.1,
107
+ :retry_frequency => BRIAR_RETRY_FREQ,
108
+ :post_timeout => BRIAR_POST_TIMEOUT,
109
109
  :timeout_message => msg) do
110
110
  !query(qstr).empty?
111
111
  end
@@ -114,8 +114,8 @@ module Briar
114
114
  def wait_for_custom_view (view_class, view_id, timeout=BRIAR_WAIT_TIMEOUT)
115
115
  msg = "waited for '#{timeout}' seconds but did not see '#{view_id}'"
116
116
  wait_for(:timeout => timeout,
117
- :retry_frequency => 0.2,
118
- :post_timeout => 0.1,
117
+ :retry_frequency => BRIAR_RETRY_FREQ,
118
+ :post_timeout => BRIAR_POST_TIMEOUT,
119
119
  :timeout_message => msg) do
120
120
  !query("view:'#{view_class}' marked:'#{view_id}'").empty?
121
121
  end
@@ -137,8 +137,8 @@ module Briar
137
137
  def wait_for_views(views, timeout=BRIAR_WAIT_TIMEOUT)
138
138
  msg = "waited for '#{timeout}' seconds but did not see '#{views}'"
139
139
  options = {:timeout => timeout,
140
- :retry_frequency => 0.2,
141
- :post_timeout => 0.1,
140
+ :retry_frequency => BRIAR_RETRY_FREQ,
141
+ :post_timeout => BRIAR_POST_TIMEOUT,
142
142
  :timeout_message => msg}
143
143
  wait_for(options) do
144
144
  views.all? { |view_id| view_exists?(view_id) }
@@ -148,8 +148,8 @@ module Briar
148
148
  def wait_for_view_to_disappear(view_id, timeout=BRIAR_WAIT_TIMEOUT)
149
149
  msg = "waited for '#{timeout}' seconds for '#{view_id}' to disappear but it is still visible"
150
150
  options = {:timeout => timeout,
151
- :retry_frequency => 0.2,
152
- :post_timeout => 0.1,
151
+ :retry_frequency => BRIAR_RETRY_FREQ,
152
+ :post_timeout => BRIAR_POST_TIMEOUT,
153
153
  :timeout_message => msg}
154
154
  wait_for(options) do
155
155
  not view_exists? view_id
@@ -54,8 +54,8 @@ module Briar
54
54
  def wait_for_button (button_id, timeout=BRIAR_WAIT_TIMEOUT)
55
55
  msg = "waited for '#{timeout}' seconds but did not see button '#{button_id}'"
56
56
  wait_for(:timeout => timeout,
57
- :retry_frequency => 0.2,
58
- :post_timeout => 0.1,
57
+ :retry_frequency => BRIAR_RETRY_FREQ,
58
+ :post_timeout => BRIAR_POST_TIMEOUT,
59
59
  :timeout_message => msg ) do
60
60
  button_exists? button_id
61
61
  end
@@ -64,8 +64,8 @@ module Briar
64
64
  def wait_for_button_with_title (button_id, title, timeout=BRIAR_WAIT_TIMEOUT)
65
65
  msg = "waited for '#{timeout}' seconds but did not see button '#{button_id}' with title '#{title}'"
66
66
  wait_for(:timeout => timeout,
67
- :retry_frequency => 0.2,
68
- :post_timeout => 0.1,
67
+ :retry_frequency => BRIAR_RETRY_FREQ,
68
+ :post_timeout => BRIAR_POST_TIMEOUT,
69
69
  :timeout_message => msg ) do
70
70
  button_exists? button_id
71
71
  end
@@ -16,66 +16,53 @@ module Briar
16
16
  end
17
17
 
18
18
  def index_of_segment_with_name_in_control_with_id(segment_id, control_id)
19
- control_idx = index_of_control_with_id (control_id)
20
- if control_idx
21
- titles = query("segmentedControl index:#{control_idx} child segment child segmentLabel", :text).reverse
22
- titles.index(segment_id)
23
- else
24
- nil
19
+ qstr = "segmentedControl marked:'#{control_id}'"
20
+ num_segs = query(qstr, :numberOfSegments).first.to_i
21
+ idx = 0
22
+ while idx < num_segs
23
+ title = query(qstr, {titleForSegmentAtIndex:idx}).first
24
+ return idx if title.eql?(segment_id)
25
+ idx = idx + 1
25
26
  end
27
+ return nil
26
28
  end
27
29
 
28
30
  def should_see_segment_with_selected_state (control_id, segment_id, selected_state)
29
31
  @segment_id = segment_id
30
32
  @control_id = control_id
31
- control_idx = index_of_control_with_id control_id
32
- if control_idx
33
- segment_idx = index_of_segment_with_name_in_control_with_id(segment_id, control_id)
34
- if segment_idx
35
- selected_arr = query("segmentedControl index:#{control_idx} child segment", :isSelected).reverse
36
- res = selected_arr[segment_idx]
37
- unless res.to_i == selected_state
38
- screenshot_and_raise "found segment named #{segment_id} in #{control_id}, but it was _not_ selected"
39
- end
40
- else
41
- screenshot_and_raise "could not find #{segment_id} in #{control_id}"
42
- end
43
- else
44
- screenshot_and_raise "could not find control named #{control_id}"
33
+ res = query("segmentedControl marked:'#{control_id}' child segment marked:'#{segment_id}'",
34
+ :isSelected)
35
+ if res.empty?
36
+ screenshot_and_raise "expected to see segmented control '#{control_id}' with segment '#{segment_id}'"
37
+ end
38
+
39
+ unless res.first.to_i == selected_state
40
+ screenshot_and_raise "expected to see segment '#{segment_id}' in '#{control_id}' with selection state '#{selected_state}' but found '#{res.to_i}'"
45
41
  end
46
42
  end
47
43
 
48
44
  def touch_segment(segment_id, control_id)
49
45
  @segment_id = segment_id
50
46
  @control_id = control_id
51
- idx = index_of_control_with_id control_id
52
- if idx
53
- touch("segmentedControl index:#{idx} child segment child segmentLabel marked:'#{segment_id}'")
54
- step_pause
55
- else
56
- screenshot_and_raise "could not find segmented control with name #{control_id}"
57
- end
47
+ touch("segmentedControl marked:'#{control_id}' child segment marked:'#{segment_id}'")
48
+ step_pause
58
49
  end
59
50
 
60
51
  def should_see_control_with_segment_titles (control_id, segment_titles)
61
52
  @control_id = control_id
62
53
  should_see_view control_id
63
- tokens = segment_titles.split(',')
54
+ tokens = tokenize_list(segment_titles)
64
55
  tokens.each do |token|
65
56
  token.strip!
66
57
  end
67
- idx = index_of_control_with_id control_id
68
- if idx
69
- actual_titles = query("segmentedControl index:#{idx} child segment child segmentLabel", :text).reverse
70
- counter = 0
71
- tokens.zip(actual_titles).each do |expected, actual|
72
- unless actual.eql? expected
73
- screenshot_and_raise "when inspecting #{control_id} i expected title: #{expected} but found: #{actual} at index #{counter}"
74
- end
75
- counter = counter + 1
58
+ counter = 0
59
+ tokens.each do |expected|
60
+ idx = index_of_segment_with_name_in_control_with_id expected, control_id
61
+ unless idx == counter
62
+ actual = query("segmentedControl marked:'#{control_id}'", {titleForSegmentAtIndex:counter}).first
63
+ screenshot_and_raise "expected to see segment '#{expected}' at index '#{counter}' but found '#{actual}'"
76
64
  end
77
- else
78
- screenshot_and_raise "could not find segmented control with name #{control_id}"
65
+ counter = counter + 1
79
66
  end
80
67
  end
81
68
  end
@@ -61,7 +61,7 @@ module Briar
61
61
  end
62
62
 
63
63
  def email_to_contains? (address)
64
- addrs = email_to.split(/, ?/)
64
+ addrs = tokenize_list(email_to)
65
65
  addrs.include? address
66
66
  end
67
67
 
@@ -81,25 +81,32 @@ module Briar
81
81
  end
82
82
 
83
83
  def is_ios6_mail_view
84
- warn 'WARN: deprected 0.0.9'
84
+ warn 'WARN: deprecated 0.0.9'
85
85
  end
86
86
 
87
- def should_see_mail_view (timeout=BRIAR_WAIT_TIMEOUT)
87
+ def should_see_mail_view (opts = {:timeout => BRIAR_WAIT_TIMEOUT,
88
+ :email_view_mark => 'compose email'})
89
+
90
+ {:timeout => BRIAR_WAIT_TIMEOUT, :email_view_mark => 'compose email'}.merge!(opts)
91
+
92
+
88
93
  if email_not_testable?
89
94
  warn_about_no_ios5_email_view
90
95
  return
91
96
  end
92
97
 
98
+ timeout = opts[:timeout]
93
99
  msg = "waited for '#{timeout}' seconds but did not see email compose view"
94
100
  dev = device()
101
+ email_view_mark = opts[:email_view_mark]
95
102
  wait_for(:timeout => timeout,
96
- :retry_frequency => 0.2,
97
- :post_timeout => 0.1,
103
+ :retry_frequency => BRIAR_RETRY_FREQ,
104
+ :post_timeout => BRIAR_POST_TIMEOUT,
98
105
  :timeout_message => msg) do
99
106
  if dev.ios5?
100
107
  is_ios5_mail_view
101
108
  else
102
- view_exists? 'compose email'
109
+ view_exists? email_view_mark
103
110
  end
104
111
  end
105
112
  end
@@ -144,8 +151,8 @@ module Briar
144
151
  timeout = BRIAR_WAIT_TIMEOUT * 2
145
152
  msg = "waited for '#{timeout}' seconds but did not see cancel button"
146
153
  wait_for(:timeout => timeout,
147
- :retry_frequency => 1.1,
148
- :post_timeout => 0.1,
154
+ :retry_frequency => BRIAR_RETRY_FREQ,
155
+ :post_timeout => BRIAR_POST_TIMEOUT,
149
156
  :timeout_message => msg) do
150
157
  uia_element_exists?(:view, marked: 'Cancel')
151
158
  end
@@ -153,8 +160,8 @@ module Briar
153
160
  uia_tap_mark('Cancel')
154
161
  msg = "waited for '#{timeout}' seconds but did not see dismiss email action sheet"
155
162
  wait_for(:timeout => timeout,
156
- :retry_frequency => 1.1,
157
- :post_timeout => 0.1,
163
+ :retry_frequency => BRIAR_RETRY_FREQ,
164
+ :post_timeout => BRIAR_POST_TIMEOUT,
158
165
  :timeout_message => msg) do
159
166
  uia_element_exists?(:view, marked: 'Delete Draft')
160
167
  end
@@ -3,8 +3,6 @@ module Briar
3
3
  # dismiss the keyboard on iPad
4
4
  # send_uia_command command:"uia.keyboard().buttons()['Hide keyboard'].tap()"
5
5
 
6
- # these are not ready for prime time
7
- # the methods for setting auto correct, spell check, etc. are not ready
8
6
  UITextAutocapitalizationTypeNone = 0
9
7
  UITextAutocapitalizationTypeWords = 1
10
8
  UITextAutocapitalizationTypeSentences = 2
@@ -14,6 +12,7 @@ module Briar
14
12
  UITextAutocorrectionTypeNo = 1
15
13
 
16
14
 
15
+ # might be 0 and 1?
17
16
  UITextSpellCheckingTypeNo = 1
18
17
  UITextSpellCheckingTypeYes = 2
19
18
 
@@ -22,8 +21,8 @@ module Briar
22
21
  def should_see_keyboard (timeout=BRIAR_WAIT_TIMEOUT)
23
22
  msg = "waited for '#{timeout}' seconds but did not see keyboard"
24
23
  wait_for(:timeout => timeout,
25
- :retry_frequency => 0.2,
26
- :post_timeout => 0.1,
24
+ :retry_frequency => BRIAR_RETRY_FREQ,
25
+ :post_timeout => BRIAR_POST_TIMEOUT,
27
26
  :timeout_message => msg) do
28
27
  element_exists('keyboardAutomatic')
29
28
  end
@@ -32,8 +31,8 @@ module Briar
32
31
  def should_not_see_keyboard (timeout=BRIAR_WAIT_TIMEOUT)
33
32
  msg = "waited for '#{timeout}' seconds but keyboard did not disappear"
34
33
  wait_for(:timeout => timeout,
35
- :retry_frequency => 0.2,
36
- :post_timeout => 0.1,
34
+ :retry_frequency => BRIAR_RETRY_FREQ,
35
+ :post_timeout => BRIAR_POST_TIMEOUT,
37
36
  :timeout_message => msg) do
38
37
  element_does_not_exist 'keyboardAutomatic'
39
38
  end
@@ -68,78 +67,68 @@ module Briar
68
67
  end
69
68
  end
70
69
 
70
+
71
+ def briar_clear_text(view_id, timeout=5)
72
+ warn("deprecated 0.1.1 - will remove 'timeout' argument in a future release")
73
+ clear_text("view marked:'#{view_id}'")
74
+
75
+ # i really wanted this to work, but there are too many issues with the
76
+ # touch not bringing up the the Select menu bar - for example sometimes
77
+ # it brings up the typo correction bar.
78
+ #wait_for_view view_id
79
+ #step_pause
80
+ #touch("view marked:'#{view_id}'")
81
+ #wait_for_button 'Select All', timeout
82
+ #step_pause
83
+ #touch_button_and_wait_for_view 'Select All', 'Cut', timeout
84
+ #step_pause
85
+ #touch_button 'Cut'
86
+ #step_pause
87
+ end
88
+
89
+ ### deprecated ###
90
+
71
91
  def set_autocapitalization (type)
72
- if !query('textView index:0').empty?
73
- query('textView index:0', [{setAutocapitalizationType: type}])
74
- elsif !query('textField index:0').empty?
75
- query('textField index:0', [{setAutocapitalizationType: type}])
76
- else
77
- screenshot_and_raise 'could not find a text view or text field'
78
- end
92
+ pending('deprecated 0.1.1 - does not work')
93
+ #if !query('textView index:0').empty?
94
+ # query('textView index:0', [{setAutocapitalizationType: type}])
95
+ #elsif !query('textField index:0').empty?
96
+ # query('textField index:0', [{setAutocapitalizationType: type}])
97
+ #else
98
+ # screenshot_and_raise 'could not find a text view or text field'
99
+ #end
79
100
  end
80
101
 
81
102
  def turn_autocapitalization_off
82
- set_autocapitalization UITextAutocapitalizationTypeNone
103
+ pending('deprecated 0.1.1 - does not work')
104
+ #set_autocapitalization UITextAutocapitalizationTypeNone
83
105
  end
84
106
 
85
107
  def set_autocorrect (type)
86
- if !query('textView index:0').empty?
87
- query('textView index:0', [{setAutocorrectionType: type}])
88
- elsif !query('textField index:0').empty?
89
- query('textField index:0', [{setAutocorrectionType: type}])
90
- else
91
- screenshot_and_raise 'could not find a text view or text field'
92
- end
108
+ pending('deprecated 0.1.1 - does not work')
109
+ #if !query('textView index:0').empty?
110
+ # query('textView index:0', [{setAutocorrectionType: type}])
111
+ #elsif !query('textField index:0').empty?
112
+ # query('textField index:0', [{setAutocorrectionType: type}])
113
+ #else
114
+ # screenshot_and_raise 'could not find a text view or text field'
115
+ #end
93
116
  end
94
117
 
95
118
  def turn_autocorrect_off
96
- set_autocorrect UITextAutocorrectionTypeNo
119
+ pending('deprecated 0.1.1 - does not work')
120
+ # set_autocorrect UITextAutocorrectionTypeNo
97
121
  end
98
122
 
99
123
  def turn_spell_correct_off
100
- if !query('textView index:0').empty?
101
- query('textView index:0', [{setSpellCheckingType: UITextSpellCheckingTypeNo}])
102
- elsif !query('textField index:0').empty?
103
- query('textField index:0', [{setSpellCheckingType: UITextSpellCheckingTypeNo}])
104
- else
105
- screenshot_and_raise 'could not find a text view or text field'
106
- end
107
- end
108
-
109
- def briar_clear_text(view_id, timeout=5)
110
- wait_for_view view_id
111
- step_pause
112
- touch("view marked:'#{view_id}'")
113
- wait_for_button 'Select All', timeout
114
- step_pause
115
- touch_button_and_wait_for_view 'Select All', 'Cut', timeout
116
- step_pause
117
- touch_button 'Cut'
118
- step_pause
124
+ pending('deprecated 0.1.1 - does not work')
125
+ #if !query('textView index:0').empty?
126
+ # query('textView index:0', [{setSpellCheckingType: UITextSpellCheckingTypeNo}])
127
+ #elsif !query('textField index:0').empty?
128
+ # query('textField index:0', [{setSpellCheckingType: UITextSpellCheckingTypeNo}])
129
+ #else
130
+ # screenshot_and_raise 'could not find a text view or text field'
131
+ #end
119
132
  end
120
-
121
- #def is_capitalize_none (cap_type)
122
- # cap_type == UITextAutocapitalizationTypeNone
123
- #end
124
- #
125
- #def is_capitalize_words (cap_type)
126
- # cap_type == UITextAutocapitalizationTypeWords
127
- #end
128
- #
129
- #def is_capitalize_sentences (cap_type)
130
- # cap_type == UITextAutocapitalizationTypeSentences
131
- #end
132
- #
133
- #def is_capitalize_all (cap_type)
134
- # cap_type == UITextAutocapitalizationTypeAllCharacters
135
- #end
136
- #
137
- #def is_autocorrect_on (state)
138
- # state == UITextAutocorrectionTypeYes
139
- #end
140
- #
141
- #def is_autocorrect_off (state)
142
- # state == UITextAutocorrectionTypeNo
143
- #end
144
133
  end
145
134
  end
@@ -32,8 +32,8 @@ module Briar
32
32
  def wait_for_label (label_id, timeout=BRIAR_WAIT_TIMEOUT)
33
33
  msg = "waited for '#{timeout}' seconds but did not see label '#{label_id}'"
34
34
  wait_for(:timeout => timeout,
35
- :retry_frequency => 0.2,
36
- :post_timeout => 0.1,
35
+ :retry_frequency => BRIAR_RETRY_FREQ,
36
+ :post_timeout => BRIAR_POST_TIMEOUT,
37
37
  :timeout_message => msg ) do
38
38
  label_exists? label_id
39
39
  end
@@ -141,7 +141,7 @@ module Briar
141
141
  if convert
142
142
  past = Time.now.gmtime + Time.now.gmtoff - (target_minutes.to_i * 60)
143
143
  else
144
- past = Time.new - (60 * target_minutes.to_i)
144
+ past = Time.now - (60 * target_minutes.to_i)
145
145
  end
146
146
 
147
147
  opts = {:picker_id => picker_id,
@@ -90,7 +90,7 @@ module Briar
90
90
 
91
91
  def target_date_for_change_time_on_picker_with_time(target_time, convert, picker_id=nil)
92
92
  current_time = ruby_time_from_picker picker_id
93
- tz_offset = convert ? 0 : (current_time.gmt_offset/3600)/12
93
+ tz_offset = (convert) ? 0 : Rational((target_time.utc_offset/3600.0)/24.0)
94
94
  DateTime.new(current_time.year, current_time.mon, current_time.day,
95
95
  target_time.hour, target_time.min,
96
96
  0, tz_offset)
@@ -117,8 +117,8 @@ module Briar
117
117
  def ensure_can_change_picker_to_date(target_dt, picker_id=nil)
118
118
  max_date = maximum_date_time_from_picker picker_id
119
119
  if max_date and target_dt > max_date
120
- p "target: '#{target_dt}'"
121
- p " max: '#{max_date}'"
120
+ puts "\ntarget: '#{target_dt}'"
121
+ puts " max: '#{max_date}'"
122
122
  screenshot_and_raise "cannot change time to '#{target_dt}' because the picker has a maximum date of '#{max_date}'"
123
123
  end
124
124
 
@@ -86,8 +86,8 @@ module Briar
86
86
  timeout = options[:timeout] || BRIAR_WAIT_TIMEOUT
87
87
  msg = "waited for '#{timeout}' seconds but did not see row '#{query_str}' with query '#{query_str}'"
88
88
  wait_for(:timeout => timeout,
89
- :retry_frequency => 0.2,
90
- :post_timeout => 0.1,
89
+ :retry_frequency => BRIAR_RETRY_FREQ,
90
+ :post_timeout => BRIAR_POST_TIMEOUT,
91
91
  :timeout_message => msg) do
92
92
  row_visible? row_id, table_id
93
93
  end
@@ -169,19 +169,6 @@ module Briar
169
169
  end
170
170
  end
171
171
 
172
- def scroll_until_i_see_row (dir, row_id, table_id=nil)
173
- warn "deprecated 0.0.8 - use 'scroll_to_row #{row_id}' with optional table view mark"
174
- wait_poll({:until_exists => query_str_for_row(row_id, table_id),
175
- :timeout => 2}) do
176
- scroll('tableView', dir)
177
- end
178
-
179
- unless row_visible?(row_id)
180
- screenshot_and_raise "i scrolled '#{dir}' but did not see '#{row_id}'"
181
- end
182
- end
183
-
184
-
185
172
  def touch_row_offset_hash (row_id, table_id = nil)
186
173
  offset = 0
187
174
  query = query_str_for_row row_id, table_id
@@ -262,8 +249,8 @@ module Briar
262
249
  timeout = 5
263
250
  msg = "waited for '#{timeout}' seconds but did not see 'Delete' confirmation in row '#{row_id}'"
264
251
  wait_for(:timeout => timeout,
265
- :retry_frequency => 0.2,
266
- :post_timeout => 0.1,
252
+ :retry_frequency => BRIAR_RETRY_FREQ,
253
+ :post_timeout => BRIAR_POST_TIMEOUT,
267
254
  :timeout_message => msg) do
268
255
  element_exists query_str
269
256
  end
@@ -9,8 +9,8 @@ module Briar
9
9
  def wait_for_text_view(view_id, timeout=BRIAR_WAIT_TIMEOUT)
10
10
  msg = "waited for '#{timeout}' seconds but did not see '#{view_id}'"
11
11
  wait_for(:timeout => timeout,
12
- :retry_frequency => 0.2,
13
- :post_timeout => 0.1,
12
+ :retry_frequency => BRIAR_RETRY_FREQ,
13
+ :post_timeout => BRIAR_POST_TIMEOUT,
14
14
  :timeout_message => msg) do
15
15
  text_view_exists? view_id
16
16
  end
@@ -19,8 +19,8 @@ module Briar
19
19
  def wait_for_text_view_to_disappear(view_id, timeout=BRIAR_WAIT_TIMEOUT)
20
20
  msg = "waited for '#{timeout}' seconds for '#{view_id}' to disappear but it is still visible"
21
21
  options = {:timeout => timeout,
22
- :retry_frequency => 0.2,
23
- :post_timeout => 0.1,
22
+ :retry_frequency => BRIAR_RETRY_FREQ,
23
+ :post_timeout => BRIAR_POST_TIMEOUT,
24
24
  :timeout_message => msg}
25
25
  wait_for(options) do
26
26
  not text_view_exists? view_id
@@ -1,3 +1,3 @@
1
1
  module Briar
2
- VERSION = '0.1.0'
2
+ VERSION = '0.1.1'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: briar
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joshua Moody
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2013-10-18 00:00:00.000000000 Z
11
+ date: 2013-10-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: calabash-cucumber
@@ -52,20 +52,6 @@ dependencies:
52
52
  - - ! '>='
53
53
  - !ruby/object:Gem::Version
54
54
  version: '0'
55
- - !ruby/object:Gem::Dependency
56
- name: rspec
57
- requirement: !ruby/object:Gem::Requirement
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
61
- version: '0'
62
- type: :runtime
63
- prerelease: false
64
- version_requirements: !ruby/object:Gem::Requirement
65
- requirements:
66
- - - ! '>='
67
- - !ruby/object:Gem::Version
68
- version: '0'
69
55
  description: extends calabash-ios steps
70
56
  email:
71
57
  - joshuajmoody@gmail.com
@@ -155,10 +141,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
155
141
  version: '0'
156
142
  requirements: []
157
143
  rubyforge_project:
158
- rubygems_version: 2.1.9
144
+ rubygems_version: 2.1.10
159
145
  signing_key:
160
146
  specification_version: 4
161
- summary: briar-0.1.0
147
+ summary: briar-0.1.1
162
148
  test_files:
163
149
  - features/step_definitions/alerts_and_sheets/action_sheet_steps.rb
164
150
  - features/step_definitions/alerts_and_sheets/alert_view_steps.rb