briar 0.1.3.b4 → 0.1.3.b5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ba56773bf8fafac50e0a6cda6bd3937469a00c58
4
- data.tar.gz: 35b2ab49686b4449d22980b88978738e9f25a924
3
+ metadata.gz: 20943d437cd107ef7346f8b3f087202b566464cf
4
+ data.tar.gz: ed60404c7bda025024d86bbf0cbfdf87799593ec
5
5
  SHA512:
6
- metadata.gz: 3d98468461361d5a17a3b5aeef32c91aa4b28dc4011ef21155d37d261cfc10eb667f0849703ab51734d9b336b33d4374c87563943b6001f58076b5eb3cb3bac0
7
- data.tar.gz: 063c9190bcb096fe7b7b52d7fee8e5c6371fadc22195e4d1ceb6c3a2e3b7e526540b84f3e6b3dac1305e7af64d7e254d71c883fb7a3d2b1245f47649e1253cab
6
+ metadata.gz: b2838a7535afdd499736697c1e77e40901c6be432a5110a547ec9b1d705c949856dd9981f2e3e60e201b5b96a9d440048444026f780f6e357a2db287041f7637
7
+ data.tar.gz: 3aedf37a8e73a8449607da32c1c73ea9a37eb5c35bb171c510f58409ba9427ab1ddc3cf849a482abc633602550e32139312557908bed04e48deff14001f2cb1b
data/.gitignore CHANGED
@@ -17,6 +17,8 @@ test/tmp
17
17
  test/version_tmp
18
18
  tmp
19
19
 
20
+ .ruby-version
21
+
20
22
  # JetBrains
21
23
  .idea
22
24
 
@@ -15,7 +15,7 @@ end
15
15
  ### deprecated - will remove in future versions ####
16
16
 
17
17
  Then /^I should see the segment I touched (is|is not) selected and the "([^"]*)" should be set correctly$/ do |selectedness, label_id|
18
- deprecated('0.1.1', 'no replacement', :pending)
18
+ _deprecated('0.1.1', 'no replacement', :pending)
19
19
  #@associated_label = label_id
20
20
  #should_see_segment_with_selected_state @control_id, @segment_id, selectedness.eql?('is') ? 1 : 0
21
21
  ## unexpected!
@@ -25,19 +25,19 @@ Then /^I should see the segment I touched (is|is not) selected and the "([^"]*)"
25
25
  end
26
26
 
27
27
  Then /^I touch the segment again$/ do
28
- deprecated('0.1.1', 'no replacement', :pending)
28
+ _deprecated('0.1.1', 'no replacement', :pending)
29
29
  #touch_segment @segment_id, @control_id
30
30
  end
31
31
 
32
32
  Then /^I should see the segment is not selected and the detail label is cleared$/ do
33
- deprecated('0.1.1', 'no replacement', :pending)
33
+ _deprecated('0.1.1', 'no replacement', :pending)
34
34
  ## ugh - that @associated_label variable needs to be set
35
35
  #macro %Q|I should see segment "#{@segment_id}" in segmented control "#{@control_id}" is not selected|
36
36
  #macro %Q|I should see label "#{@associated_label}" with text ""|
37
37
  end
38
38
 
39
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|
40
- deprecated('0.1.1', 'no replacement', :pending)
40
+ _deprecated('0.1.1', 'no replacement', :pending)
41
41
  ## ugh - that @associated_label variable needs to be set
42
42
  #@associated_label = label_id
43
43
  #@associated_row = row_id
@@ -46,7 +46,7 @@ Then /^I should see the segment I touched (is|is not) selected and the "([^"]*)"
46
46
  end
47
47
 
48
48
  Then /^I should see the segment is not selected and the label in the row is cleared$/ do
49
- deprecated('0.1.1', 'no replacement', :pending)
49
+ _deprecated('0.1.1', 'no replacement', :pending)
50
50
  ## ugh - difficult to extract to a function because we need the
51
51
  ## @associated_row and @associated_label to be set
52
52
  #macro %Q|I should see segment "#{@segment_id}" in segmented control "#{@control_id}" is not selected|
@@ -1,5 +1,5 @@
1
1
  Then /^I should see email view with body that contains "([^"]*)"$/ do |text|
2
- if not device.ios5?
2
+ if not ios5?
3
3
  warn_about_no_ios5_email_view
4
4
  else
5
5
  2.times { step_pause }
@@ -26,7 +26,7 @@ Then /^I touch the "([^"]*)" row and wait to see the email view$/ do |row_id|
26
26
  end
27
27
 
28
28
  Then /^I should see email view with "([^"]*)" in the subject$/ do |text|
29
- if not device.ios5?
29
+ if not ios5?
30
30
  warn_about_no_ios5_email_view
31
31
  else
32
32
  wait_for_animation
@@ -38,7 +38,7 @@ Then /^I should see email view with "([^"]*)" in the subject$/ do |text|
38
38
  end
39
39
 
40
40
  Then /^I should see email view with recipients? "([^"]*)"$/ do |comma_sep_addrs|
41
- if not device.ios5?
41
+ if not ios5?
42
42
  warn_about_no_ios5_email_view
43
43
  else
44
44
  should_see_recipients comma_sep_addrs
@@ -51,7 +51,7 @@ Then /^I should see email view with to field set to "([^"]*)"$/ do |text|
51
51
  end
52
52
 
53
53
  Then /^I should see email view with text like "([^"]*)" in the subject$/ do |text|
54
- if not device.ios5?
54
+ if not ios5?
55
55
  warn_about_no_ios5_email_view
56
56
  else
57
57
  should_see_mail_view
@@ -78,7 +78,7 @@ Given(/^we are testing on the simulator or a device configured to send emails$/)
78
78
  end
79
79
 
80
80
  Given(/^I can test an email view$/) do
81
- if (not device.ios5?) and (not uia_available?)
81
+ if (not ios5?) and (not uia_available?)
82
82
  warn_about_no_ios5_email_view
83
83
  pending('cannot test email views yet')
84
84
  end
@@ -17,13 +17,12 @@ When /^I touch the done button the keyboard disappears$/ do
17
17
  should_not_see_keyboard
18
18
  end
19
19
 
20
-
21
20
  Then /^I touch the delete key$/ do
22
- keyboard_send_backspace
21
+ keyboard_enter_char 'Delete'
23
22
  end
24
23
 
25
24
  Then(/^I turn off spell checking and capitalization$/) do
26
- deprecated('0.1.1', 'not working', :pending)
25
+ _deprecated('0.1.1', 'not working', :pending)
27
26
  #should_see_keyboard
28
27
  #turn_autocapitalization_off
29
28
  #turn_autocorrect_off
@@ -1,3 +1,4 @@
1
+ require 'benchmark'
1
2
 
2
3
  Then /^I change the time on the picker to "([^"]*)"$/ do |target_time|
3
4
  change_time_on_picker_with_time_str target_time
@@ -85,7 +85,7 @@ Then /^I should see that the text I just entered is in the "([^"]*)" row "([^"]*
85
85
  end
86
86
 
87
87
  Then /^I move the "([^"]*)" row (up|down) (\d+) times? using the reorder edit control$/ do |row_id, dir, n|
88
- if device.ios7?
88
+ if ios7?
89
89
  pending 'reordering on iOS 7 (more specifically playback) is not supported'
90
90
  end
91
91
 
@@ -128,7 +128,7 @@ Then /^I should see a detail disclosure chevron in the "([^"]*)" row$/ do |row_i
128
128
  end
129
129
 
130
130
  Then /^I touch the "([^"]*)" switch in the "([^"]*)" row$/ do |switch_id, row_id|
131
- deprecated('0.1.1', 'write a custom step', :warn)
131
+ _deprecated('0.1.1', 'write a custom step', :warn)
132
132
  touch_switch_in_row switch_id, row_id
133
133
  end
134
134
 
@@ -13,6 +13,7 @@ BRIAR_POST_TIMEOUT=0.5
13
13
  ##################
14
14
 
15
15
  BRIAR_STEP_PAUSE = (ENV['STEP_PAUSE'] || 0.5).to_f
16
+
16
17
  # we need an insanely long time out because of some changes in 0.9.163
17
18
  # the waits succeed after a short amount of time (visually < 1 sec),
18
19
  # but fail if the wait time out is too short (4s)
@@ -72,38 +73,39 @@ require 'briar/text_field'
72
73
  require 'briar/text_view'
73
74
 
74
75
 
76
+ # <b>DEPRECATED</b> since 0.9.163
77
+ #
78
+ # replaced with:
79
+ # * calabash function <tt>default_device</tt>
80
+ # * methods in <tt>calabash-cucumber/environment_helpers.rb</tt>
81
+ # * briar function <tt>default_device_or_create</tt>
75
82
  def device
76
- deprecated('0.1.3', "use the calabash function 'default_device' instead", :warn)
77
- @device = default_device()
78
- end
79
-
80
- def xamarin_test_cloud?
81
- ENV['XAMARIN_TEST_CLOUD'] == '1'
82
- end
83
-
83
+ msg = "use the calabash function 'default_device', one of the methods in calabash-cucumber/environment_helpers.rb', or briar's 'default_device_or_create'"
84
+ _deprecated('0.9.163', msg, :warn)
85
+ default_device_or_create()
84
86
 
85
- # todo deprecated function does not output on a new line when called within cucumber
86
- def deprecated(version, msg, type)
87
- allowed = [:pending, :warn]
88
- unless allowed.include?(type)
89
- screenshot_and_raise "type '#{type}' must be on of '#{allowed}'"
87
+ d = default_device()
88
+ if d.nil?
89
+ d = Calabash::Cucumber::Device.new(nil, server_version())
90
90
  end
91
+ d
92
+ end
91
93
 
92
- info = Kernel.caller.first
93
-
94
- msg = "deprecated '#{version}' - '#{msg}'\n#{info}"
95
-
96
- if type.eql?(:pending)
97
- pending(msg)
98
- else
99
- warn "\nWARN: #{msg}"
94
+ # returns the device that is currently being tested against
95
+ #
96
+ # returns the +device+ attr of <tt>Calabash::Cucumber::Launcher</tt> if
97
+ # it is defined. otherwise, creates a new <tt>Calabash::Cucumber::Device</tt>
98
+ # by querying the server.
99
+ #
100
+ # raises an error if the server cannot be reached
101
+ def default_device_or_create
102
+ device = default_device()
103
+ if device.nil?
104
+ device = Calabash::Cucumber::Device.new(nil, server_version())
100
105
  end
106
+ device
101
107
  end
102
108
 
103
109
 
104
110
 
105
111
 
106
-
107
-
108
-
109
-
@@ -8,7 +8,7 @@ module Briar
8
8
  # touch("view:'_UIModalItemAlertContentView' descendant view:'_UIModalItemTableViewCell' marked:'OK'")
9
9
 
10
10
  def alert_exists? (alert_id=nil)
11
- if device.ios7?
11
+ if uia_available?
12
12
  res = send_uia_command command: 'uia.alert() != null'
13
13
  res['value']
14
14
  else
@@ -41,26 +41,26 @@ module Briar
41
41
  end
42
42
 
43
43
  def should_see_alert_with_title (title, timeout=BRIAR_WAIT_TIMEOUT)
44
- if device.ios7?
44
+ if ios7?
45
45
  warn 'WARN: cannot distinguish between alert titles and messages'
46
46
  should_see_alert
47
- if uia_query(:view, marked: "#{title}").empty?
48
- screenshot_and_raise "expected to see alert with title '#{title}'"
47
+ msg = "waited for '#{timeout}' but did not see an alert"
48
+ opts = wait_opts(msg, timeout)
49
+ wait_for(opts) do
50
+ not uia_query(:view, marked: "#{title}").empty?
49
51
  end
50
52
  else
51
53
  qstr = 'alertView child label'
52
54
  msg = "waited for '#{timeout}' for alert with title '#{title}'"
53
- wait_for(:timeout => timeout,
54
- :retry_frequency => BRIAR_WAIT_RETRY_FREQ,
55
- :post_timeout => BRIAR_WAIT_STEP_PAUSE,
56
- :timeout_message => msg) do
55
+ opts = wait_opts(msg, timeout)
56
+ wait_for(opts) do
57
57
  query(qstr, :text).include?(title)
58
58
  end
59
59
  end
60
60
  end
61
61
 
62
62
  def should_see_alert_with_message (message, timeout=BRIAR_WAIT_TIMEOUT)
63
- if device.ios7?
63
+ if ios7?
64
64
  warn 'WARN: cannot distinguish between alert titles and messages'
65
65
  should_see_alert
66
66
  if uia_query(:view, marked: "#{message}").empty?
@@ -79,7 +79,7 @@ module Briar
79
79
  end
80
80
 
81
81
  def alert_button_exists? (button_id)
82
- if device.ios7?
82
+ if uia_available?
83
83
  should_see_alert
84
84
  not uia_query(:view, marked: "#{button_id}").empty?
85
85
  else
@@ -95,7 +95,7 @@ module Briar
95
95
 
96
96
  def dismiss_alert_with_button (button_label)
97
97
  touch_alert_button(button_label)
98
- if device.ios7?
98
+ if uia_available?
99
99
  wait_for_view_to_disappear button_label
100
100
  else
101
101
  wait_for_view_to_disappear 'alertView'
@@ -105,7 +105,7 @@ module Briar
105
105
 
106
106
  def touch_alert_button(button_title)
107
107
  should_see_alert
108
- if device.ios7?
108
+ if ios7?
109
109
  touch("view marked:'#{button_title}'")
110
110
  else
111
111
  touch("alertView child button marked:'#{button_title}'")
@@ -104,7 +104,7 @@ module Briar
104
104
  :toolbar_id => nil}
105
105
  opts = default_opts.merge(opts)
106
106
  else
107
- deprecated('0.1.2',
107
+ _deprecated('0.1.2',
108
108
  "second argument should be a hash - found '#{opts}'",
109
109
  :warn)
110
110
  opts = {:wait_for_view => opts[:wait_for_view],
@@ -50,7 +50,7 @@ module Briar
50
50
  screenshot_and_raise "should see view with id '#{view_id}'"
51
51
  end
52
52
 
53
- actual_ht = {x: res['rect']['center_x'].to_f, y: res['rect']['center_y'].to_f}
53
+ actual_ht = {:x => res['rect']['center_x'].to_f, :y => res['rect']['center_y'].to_f}
54
54
 
55
55
  unless actual_ht == center_ht
56
56
  screenshot_and_raise "#{view_id} has center '#{actual_ht}' but should have center '#{center_ht}'"
@@ -4,7 +4,7 @@ module Briar
4
4
  module Email
5
5
 
6
6
  def email_testable?
7
- return true if device.ios5?
7
+ return true if ios5?
8
8
  uia_available?
9
9
  end
10
10
 
@@ -21,7 +21,7 @@ module Briar
21
21
  end
22
22
 
23
23
  def email_body_contains? (text)
24
- if device.ios5?
24
+ if ios5?
25
25
  !query("view:'MFComposeTextContentView' {text LIKE '*#{text}*'}").empty?
26
26
  else
27
27
  warn 'WARN: iOS > 5 detected - cannot test for email body text'
@@ -33,7 +33,7 @@ module Briar
33
33
  end
34
34
 
35
35
  def email_subject_is? (text)
36
- if device.ios5?
36
+ if ios5?
37
37
  email_subject.eql? text
38
38
  else
39
39
  warn 'WARN: iOS > 5 detected - cannot test for email subject text'
@@ -41,7 +41,7 @@ module Briar
41
41
  end
42
42
 
43
43
  def email_subject_has_text_like? (text)
44
- if device.ios5?
44
+ if ios5?
45
45
  !query("view:'MFComposeSubjectView' {text LIKE '*#{text}*'}").empty?
46
46
  else
47
47
  warn 'WARN: iOS > 5 detected - cannot test for email subject text'
@@ -53,7 +53,7 @@ module Briar
53
53
  end
54
54
 
55
55
  def email_to_field_is? (text)
56
- if device.ios5?
56
+ if ios5?
57
57
  email_to.eql? text
58
58
  else
59
59
  warn 'WARN: iOS > 5 detected - cannot test for email to field'
@@ -94,13 +94,13 @@ module Briar
94
94
  timeout = opts[:timeout]
95
95
  msg = "waited for '#{timeout}' seconds but did not see email compose view"
96
96
  #noinspection RubyParenthesesAfterMethodCallInspection
97
- dev = device()
97
+
98
98
  email_view_mark = opts[:email_view_mark]
99
99
  wait_for(:timeout => timeout,
100
100
  :retry_frequency => BRIAR_WAIT_RETRY_FREQ,
101
101
  :post_timeout => BRIAR_WAIT_STEP_PAUSE,
102
102
  :timeout_message => msg) do
103
- if dev.ios5?
103
+ if ios5?
104
104
  is_ios5_mail_view
105
105
  else
106
106
  view_exists? email_view_mark
@@ -110,7 +110,7 @@ module Briar
110
110
 
111
111
  #noinspection RubyResolve
112
112
  def device_can_send_email
113
- return true if device.simulator?
113
+ return true if simulator?
114
114
  if defined? backdoor_device_configured_for_mail?
115
115
  backdoor_device_configured_for_mail?
116
116
  else
@@ -120,7 +120,6 @@ module Briar
120
120
 
121
121
  def delete_draft_and_wait_for (view_id, opts={})
122
122
 
123
-
124
123
  if email_not_testable?
125
124
  warn_about_no_ios5_email_view
126
125
  return
@@ -133,10 +132,7 @@ module Briar
133
132
  # does a wait for iOS > 5 + uia available
134
133
  should_see_mail_view opts
135
134
 
136
- #noinspection RubyParenthesesAfterMethodCallInspection
137
- device = device()
138
-
139
- if device.ios5?
135
+ if ios5?
140
136
  touch_navbar_item_and_wait_for_view 'Cancel', 'Delete Draft'
141
137
  step_pause
142
138
  touch_sheet_button_and_wait_for_view 'Delete Draft', view_id
@@ -147,12 +143,11 @@ module Briar
147
143
  pending "iOS > 5 detected AND orientation '#{sbo}' - there is a bug in UIAutomation that prohibits touching the cancel button"
148
144
  end
149
145
 
150
- # might also occur on devices, but i don't know
151
- if sbo.eql?(:up) and device.ipad? and device.simulator?
152
- pending "iOS > 5 detected AND orientation '#{sbo}' AND simulator - there is a bug in UIAutomation prohibits touching the cancel button"
146
+ if sbo.eql?(:up) and ipad?
147
+ pending "iOS > 5 detected AND orientation '#{sbo}' AND ipad - there is a bug in UIAutomation prohibits touching the cancel button"
153
148
  end
154
149
 
155
- timeout = BRIAR_WAIT_TIMEOUT * 2
150
+ timeout = BRIAR_WAIT_TIMEOUT
156
151
  msg = "waited for '#{timeout}' seconds but did not see cancel button"
157
152
  wait_for(:timeout => timeout,
158
153
  :retry_frequency => BRIAR_WAIT_RETRY_FREQ,
@@ -178,7 +173,7 @@ module Briar
178
173
  end
179
174
 
180
175
  def uia_touch_email_to (opts={})
181
- default_opts = {:await_keyboard => true}
176
+ default_opts = {:wait_for_keyboard => true}
182
177
  opts = default_opts.merge(opts)
183
178
 
184
179
  if uia_not_available?
@@ -190,11 +185,11 @@ module Briar
190
185
  point = {:x => rect['x'] + (2 * rect['width']),
191
186
  :y => rect['y']}
192
187
  uia_touch_with_options(point)
193
- uia_await_keyboard if opts[:await_keyboard]
188
+ uia_wait_for_keyboard if opts[:wait_for_keyboard]
194
189
  end
195
190
 
196
191
  def uia_set_email_to(addresses, opts={})
197
- default_opts = {:await_keyboard => true}
192
+ default_opts = {:wait_for_keyboard => true}
198
193
  opts = default_opts.merge(opts)
199
194
  uia_touch_email_to opts
200
195
  addresses.each do |addr|
@@ -209,7 +204,7 @@ module Briar
209
204
  end
210
205
 
211
206
  def uia_send_email_to(addresses, opts={})
212
- default_opts = {:await_keyboard => true}
207
+ default_opts = {:wait_for_keyboard => true}
213
208
  opts = default_opts.merge(opts)
214
209
  uia_set_email_to addresses, opts
215
210
  uia_touch_send_email
@@ -72,7 +72,7 @@ module Briar
72
72
 
73
73
  #noinspection RubyUnusedLocalVariable
74
74
  def briar_clear_text(view_id, timeout=5)
75
- deprecated('0.1.1', "will remove 'timeout' argument in a future release", :warn)
75
+ _deprecated('0.1.1', "will remove 'timeout' argument in a future release", :warn)
76
76
  clear_text("view marked:'#{view_id}'")
77
77
 
78
78
  # i really wanted this to work, but there are too many issues with the
@@ -93,7 +93,7 @@ module Briar
93
93
 
94
94
  #noinspection RubyUnusedLocalVariable
95
95
  def set_autocapitalization (type)
96
- deprecated('0.1.1', 'does not work', :pending)
96
+ _deprecated('0.1.1', 'does not work', :pending)
97
97
  #if !query('textView index:0').empty?
98
98
  # query('textView index:0', [{setAutocapitalizationType: type}])
99
99
  #elsif !query('textField index:0').empty?
@@ -104,13 +104,13 @@ module Briar
104
104
  end
105
105
 
106
106
  def turn_autocapitalization_off
107
- deprecated('0.1.1', 'does not work', :pending)
107
+ _deprecated('0.1.1', 'does not work', :pending)
108
108
  #set_autocapitalization UITextAutocapitalizationTypeNone
109
109
  end
110
110
 
111
111
  #noinspection RubyUnusedLocalVariable
112
112
  def set_autocorrect (type)
113
- deprecated('0.1.1', 'does not work', :pending)
113
+ _deprecated('0.1.1', 'does not work', :pending)
114
114
  #if !query('textView index:0').empty?
115
115
  # query('textView index:0', [{setAutocorrectionType: type}])
116
116
  #elsif !query('textField index:0').empty?
@@ -121,12 +121,12 @@ module Briar
121
121
  end
122
122
 
123
123
  def turn_autocorrect_off
124
- deprecated('0.1.1', 'does not work', :pending)
124
+ _deprecated('0.1.1', 'does not work', :pending)
125
125
  # set_autocorrect UITextAutocorrectionTypeNo
126
126
  end
127
127
 
128
128
  def turn_spell_correct_off
129
- deprecated('0.1.1', 'does not work', :pending)
129
+ _deprecated('0.1.1', 'does not work', :pending)
130
130
  #if !query('textView index:0').empty?
131
131
  # query('textView index:0', [{setSpellCheckingType: UITextSpellCheckingTypeNo}])
132
132
  #elsif !query('textField index:0').empty?
@@ -18,20 +18,20 @@ module Briar
18
18
  # 3 <== there is no international button
19
19
  # 4 <== there is an international button
20
20
  def keyboard_has_international? (opts={})
21
- default_opts = {:await_keyboard => false}
21
+ default_opts = {:wait_for_keyboard => false}
22
22
  opts = default_opts.merge(opts)
23
- await_keyboard if opts[:await_keyboard]
23
+ wait_for_keyboard if opts[:wait_for_keyboard]
24
24
  res = uia('UIATarget.localTarget().frontMostApp().keyboard().buttons().length')
25
25
  button_count = res['value']
26
26
  button_count == 4
27
27
  end
28
28
 
29
29
  def touch_international_key(opts={})
30
- default_opts = {:await_keyboard => false,
30
+ default_opts = {:wait_for_keyboard => false,
31
31
  :step_pause => 0.4}
32
32
  opts = default_opts.merge(opts)
33
33
 
34
- await_keyboard if opts[:await_keyboard]
34
+ wait_for_keyboard if opts[:wait_for_keyboard]
35
35
 
36
36
  unless keyboard_has_international?
37
37
  screenshot_and_raise 'could not find an international key on the keyboard'
@@ -53,9 +53,9 @@ module Briar
53
53
  # when looking at elements() the space bar will be at the penultimate index
54
54
  # when looking at keys() the space bar index seems to float around
55
55
  def spacebar_label (opts={})
56
- default_opts = {:await_keyboard => false}
56
+ default_opts = {:wait_for_keyboard => false}
57
57
  opts = default_opts.merge(opts)
58
- await_keyboard if opts[:await_keyboard]
58
+ wait_for_keyboard if opts[:wait_for_keyboard]
59
59
  elm_count = uia('UIATarget.localTarget().frontMostApp().keyboard().elements().length')['value']
60
60
  spacebar_idx = elm_count - 2
61
61
  res = uia("UIATarget.localTarget().frontMostApp().keyboard().elements()[#{spacebar_idx}].label()")
@@ -63,37 +63,37 @@ module Briar
63
63
  end
64
64
 
65
65
  def spacebar_has_label?(label, opts={})
66
- default_opts = {:await_keyboard => false}
66
+ default_opts = {:wait_for_keyboard => false}
67
67
  opts = default_opts.merge(opts)
68
- await_keyboard if opts[:await_keyboard]
68
+ wait_for_keyboard if opts[:wait_for_keyboard]
69
69
  spacebar_label.eql?(label)
70
70
  end
71
71
 
72
72
  def english_keyboard? (opts={})
73
- default_opts = {:await_keyboard => false}
73
+ default_opts = {:wait_for_keyboard => false}
74
74
  opts = default_opts.merge(opts)
75
- await_keyboard if opts[:await_keyboard]
75
+ wait_for_keyboard if opts[:wait_for_keyboard]
76
76
  spacebar_has_label? BRIAR_LANGUAGE_KEYS[:en]
77
77
  end
78
78
 
79
79
  def german_keyboard? (opts={})
80
- default_opts = {:await_keyboard => false}
80
+ default_opts = {:wait_for_keyboard => false}
81
81
  opts = default_opts.merge(opts)
82
- await_keyboard if opts[:await_keyboard]
82
+ wait_for_keyboard if opts[:wait_for_keyboard]
83
83
  spacebar_has_label? BRIAR_LANGUAGE_KEYS[:de]
84
84
  end
85
85
 
86
86
  def romaji_keyboard? (opts={})
87
- default_opts = {:await_keyboard => false}
87
+ default_opts = {:wait_for_keyboard => false}
88
88
  opts = default_opts.merge(opts)
89
- await_keyboard if opts[:await_keyboard]
89
+ wait_for_keyboard if opts[:wait_for_keyboard]
90
90
  spacebar_has_label? BRIAR_LANGUAGE_KEYS[:ja]
91
91
  end
92
92
 
93
93
  def touch_international_until_language(language_key, opts={})
94
- default_opts = {:await_keyboard => false}
94
+ default_opts = {:wait_for_keyboard => false}
95
95
  opts = default_opts.merge(opts)
96
- await_keyboard if opts[:await_keyboard]
96
+ wait_for_keyboard if opts[:wait_for_keyboard]
97
97
 
98
98
  unless keyboard_has_international?
99
99
  screenshot_and_raise 'keyboard does not have an international key'
@@ -5,18 +5,21 @@ module Briar
5
5
  module Numeric
6
6
 
7
7
  def is_numeric_keyboard?(opts={})
8
- default_opts = {:await_keyboard => false}
8
+ if uia_not_available?
9
+ pending('this feature is nyi')
10
+ end
11
+ default_opts = {:wait_for_keyboard => false}
9
12
  opts = default_opts.merge(opts)
10
- await_keyboard if opts[:await_keyboard]
13
+ wait_for_keyboard if opts[:wait_for_keyboard]
11
14
  res = uia('UIATarget.localTarget().frontMostApp().keyboard().keys().length')['value']
12
15
  res == 12
13
16
  end
14
17
 
15
18
  def keyboard_send_numeric_backspace(opts={})
16
- default_opts = {:await_keyboard => false}
19
+ default_opts = {:wait_for_keyboard => false}
17
20
  opts = default_opts.merge(opts)
18
- await_keyboard if opts[:await_keyboard]
19
- if ios7?
21
+ wait_for_keyboard if opts[:wait_for_keyboard]
22
+ if uia_available?
20
23
  uia('UIATarget.localTarget().frontMostApp().keyboard().buttons()[0].tap()')
21
24
  else
22
25
  keyboard_enter_char 'Delete'
@@ -24,15 +27,16 @@ module Briar
24
27
  end
25
28
 
26
29
  def keyboard_send_backspace(opts={})
27
- default_opts = {:await_keyboard => false}
30
+ default_opts = {:wait_for_keyboard => false}
28
31
  opts = default_opts.merge(opts)
29
- await_keyboard if opts[:await_keyboard]
32
+ wait_for_keyboard if opts[:wait_for_keyboard]
30
33
  if is_numeric_keyboard?
31
34
  keyboard_send_numeric_backspace
32
35
  else
33
- keyboard_send_backspace
36
+ keyboard_enter_char 'Delete'
34
37
  end
35
38
  end
36
39
  end
37
40
  end
38
- end
41
+ end
42
+
@@ -23,7 +23,7 @@ BRIAR_PICKER_12H_BRIEF_DATE_FMT = '%a %b %e'
23
23
  BRIAR_DATE_FORMATS = {:brief_24h => BRIAR_PICKER_24H_BRIEF_DATE_FMT,
24
24
  :brief_12h => BRIAR_PICKER_12H_BRIEF_DATE_FMT}
25
25
 
26
-
26
+ # todo briar picker should be a class - 1 instance per picker
27
27
  module Briar
28
28
  module Picker
29
29
  module DateCore
@@ -38,14 +38,37 @@ module Briar
38
38
  query_str
39
39
  end
40
40
 
41
- def ruby_time_from_picker (options = {:picker_id => nil,
42
- :convert_time_to_utc => false})
43
- picker_id = picker_id_from_options options
41
+ def ruby_time_from_picker (options = {})
42
+ if not options.is_a?(Hash) or options == nil
43
+ if options == nil
44
+ msg = "'picker_id' argument has been replaced with options hash; pass '{:picker_id => nil}' instead"
45
+ options = {:picker_id => nil}
46
+ else
47
+ msg = "'picker_id' argument has been replaced with options hash; pass '{:picker_id => #{options}}' instead"
48
+ options = {:picker_id => options}
49
+ end
50
+ _deprecated('0.1.3', msg, :warn)
51
+ end
52
+
53
+ default_options = {:picker_id => nil,
54
+ :convert_time_to_utc => false,
55
+ :assert_mode => true,
56
+ :assert_picker => true}
57
+ options = default_options.merge(options)
44
58
 
45
- if picker_is_in_countdown_mode picker_id
46
- screenshot_and_raise 'method is not available for pickers that are not in date or date time mode'
59
+ picker_id = options[:picker_id]
60
+
61
+ if options[:assert_mode]
62
+ if picker_is_in_countdown_mode picker_id
63
+ screenshot_and_raise 'method is not available for pickers that are not in date or date time mode'
64
+ end
47
65
  end
48
- query_str = should_see_date_picker picker_id
66
+
67
+ if options[:assert_picker]
68
+ should_see_date_picker picker_id
69
+ end
70
+
71
+ query_str = query_string_for_picker(picker_id)
49
72
  res = query(query_str, :date)
50
73
  if res.empty?
51
74
  screenshot_and_raise "should be able to get date from picker with query '#{query_str}'"
@@ -192,72 +215,125 @@ module Briar
192
215
  end
193
216
 
194
217
  # get the times off the picker in 12h and 24h format
195
- def picker_time_str(format_key, options={:picker_id => nil,
196
- :convert_time_to_utc => false})
197
- picker_id = picker_id_from_options options
198
-
199
- if picker_is_in_date_mode picker_id or picker_is_in_countdown_mode picker_id
200
- screenshot_and_raise 'the time is not applicable for this mode'
218
+ def picker_time_str(format_key, options={})
219
+ default_options = {:picker_id => nil,
220
+ :convert_time_to_utc => false,
221
+ :time_on_picker => nil,
222
+ :assert_mode => true}
223
+ options = default_options.merge(options)
224
+
225
+ picker_id = options[:picker_id]
226
+
227
+ if options[:assert_mode]
228
+ if picker_is_in_date_mode picker_id or picker_is_in_countdown_mode picker_id
229
+ screenshot_and_raise 'the time is not applicable for this mode'
230
+ end
201
231
  end
232
+
202
233
  format = BRIAR_TIME_FORMATS[format_key]
203
234
  unless format
204
235
  screenshot_and_raise "format '#{format_key}' was not one of '#{BRIAR_TIME_FORMATS}'"
205
236
  end
206
237
 
207
- time = ruby_time_from_picker options
238
+ time = options[:time_on_picker] || ruby_time_from_picker(options)
208
239
  time.strftime(format).strip.sub(BRIAR_REMOVE_LEADING_ZERO_REGEX, '')
209
240
  end
210
241
 
211
242
 
212
- def picker_time_strs_hash(options={:picker_id => nil,
213
- :convert_time_to_utc => false})
214
- picker_id = picker_id_from_options options
215
- if picker_is_in_date_mode picker_id or picker_is_in_countdown_mode picker_id
216
- screenshot_and_raise 'the time is not applicable for this mode'
243
+ def picker_time_strs_hash(options={})
244
+ default_options = {:picker_id => nil,
245
+ :convert_time_to_utc => false,
246
+ :time_on_picker => nil,
247
+ :assert_mode => true}
248
+ options = default_options.merge(options)
249
+ picker_id = options[:picker_id]
250
+
251
+ if options[:assert_mode]
252
+ if picker_is_in_date_mode picker_id or picker_is_in_countdown_mode picker_id
253
+ screenshot_and_raise 'the time is not applicable for this mode'
254
+ end
217
255
  end
218
256
 
219
257
  {:h24 => picker_time_str(:h24, options),
220
258
  :h12 => picker_time_str(:h12, options)}
221
259
  end
222
260
 
223
- def picker_time_strs_arr(options={:picker_id => nil,
224
- :convert_time_to_utc => false})
225
- picker_id = picker_id_from_options options
226
- if picker_is_in_date_mode picker_id or picker_is_in_countdown_mode picker_id
227
- screenshot_and_raise 'the time is not applicable for this mode'
261
+ def picker_time_strs_arr(options={})
262
+
263
+ default_options = {:picker_id => nil,
264
+ :convert_time_to_utc => false,
265
+ :time_on_picker => nil,
266
+ :assert_mode => true}
267
+ options = default_options.merge(options)
268
+
269
+ picker_id = options[:picker_id]
270
+
271
+ if options[:assert_mode]
272
+ if picker_is_in_date_mode picker_id or picker_is_in_countdown_mode picker_id
273
+ screenshot_and_raise 'the time is not applicable for this mode'
274
+ end
228
275
  end
229
276
  [picker_time_str(:h24, options), picker_time_str(:h12, options)]
230
277
  end
231
278
 
232
- def picker_brief_date_str(format_key, options={:picker_id => nil,
233
- :convert_time_to_utc => false})
234
- picker_id = picker_id_from_options options
235
- if picker_is_in_countdown_mode picker_id
236
- screenshot_and_raise 'date is not applicable for this mode'
279
+ def picker_brief_date_str(format_key, options={})
280
+
281
+ default_options = {:picker_id => nil,
282
+ :convert_time_to_utc => false,
283
+ :time_on_picker => nil,
284
+ :assert_mode => true}
285
+ options = default_options.merge(options)
286
+
287
+ picker_id = options[:picker_id]
288
+
289
+ if options[:assert_mode]
290
+ if picker_is_in_countdown_mode picker_id
291
+ screenshot_and_raise 'date is not applicable for this mode'
292
+ end
237
293
  end
294
+
238
295
  format = BRIAR_DATE_FORMATS[format_key]
239
296
  unless format
240
297
  screenshot_and_raise "format '#{format_key}' is not one of '#{BRIAR_DATE_FORMATS.keys}'"
241
298
  end
242
- time = ruby_time_from_picker options
299
+
300
+ time = options[:time_on_picker] || ruby_time_from_picker(options)
243
301
  time.strftime(format).strip.squeeze(' ')
244
302
  end
245
303
 
246
- def picker_brief_date_strs_hash(options={:picker_id => nil,
247
- :convert_time_to_utc => false})
248
- picker_id = picker_id_from_options options
249
- if picker_is_in_countdown_mode picker_id
250
- screenshot_and_raise 'date is not applicable for this mode'
304
+ def picker_brief_date_strs_hash(options={})
305
+
306
+ default_options = {:picker_id => nil,
307
+ :convert_time_to_utc => false,
308
+ :time_on_picker => nil,
309
+ :assert_mode => true}
310
+ options = default_options.merge(options)
311
+
312
+ picker_id = options[:picker_id]
313
+
314
+ if options[:assert_mode]
315
+ if picker_is_in_countdown_mode picker_id
316
+ screenshot_and_raise 'date is not applicable for this mode'
317
+ end
251
318
  end
252
319
  {:brief_24h => picker_brief_date_str(:brief_24h, options),
253
320
  :brief_12h => picker_brief_date_str(:brief_12h, options)}
254
321
  end
255
322
 
256
- def picker_brief_date_strs_arr(options={:picker_id => nil,
257
- :convert_time_to_utc => false})
258
- picker_id = picker_id_from_options options
259
- if picker_is_in_countdown_mode picker_id
260
- screenshot_and_raise 'date is not applicable for this mode'
323
+ def picker_brief_date_strs_arr(options={})
324
+
325
+ default_options = {:picker_id => nil,
326
+ :convert_time_to_utc => false,
327
+ :time_on_picker => nil,
328
+ :assert_mode => true}
329
+ options = default_options.merge(options)
330
+
331
+ picker_id = options[:picker_id]
332
+
333
+ if options[:assert_mode]
334
+ if picker_is_in_countdown_mode picker_id
335
+ screenshot_and_raise 'date is not applicable for this mode'
336
+ end
261
337
  end
262
338
  [picker_brief_date_str(:brief_24h, options), picker_brief_date_str(:brief_12h, options)]
263
339
  end
@@ -1,5 +1,6 @@
1
1
  require 'calabash-cucumber'
2
2
  require 'date'
3
+ require 'benchmark'
3
4
 
4
5
  =begin
5
6
 
@@ -19,7 +20,7 @@ options ==>
19
20
  # WARN: only set this if you need times converted to UTC - if you are in UTC
20
21
  # timezone, don't set this
21
22
  :convert_time_to_utc => false,
22
- # animat the change
23
+ # animate the change
23
24
  :animate => true,
24
25
  # optionally pass the picker id
25
26
  :picker_id => nil,
@@ -89,7 +90,7 @@ module Briar
89
90
  end
90
91
 
91
92
  def target_date_for_change_time_on_picker_with_time(target_time, convert, picker_id=nil)
92
- current_time = ruby_time_from_picker picker_id
93
+ current_time = ruby_time_from_picker({:picker_id => picker_id})
93
94
  tz_offset = (convert) ? 0 : Rational((target_time.utc_offset/3600.0)/24.0)
94
95
  DateTime.new(current_time.year, current_time.mon, current_time.day,
95
96
  target_time.hour, target_time.min,
@@ -136,23 +137,32 @@ module Briar
136
137
  :picker_id => nil,
137
138
  :notify_targets => true})
138
139
 
140
+
139
141
  picker_id = picker_id_from_options options
140
142
  unless picker_is_in_time_mode picker_id or picker_is_in_date_and_time_mode picker_id
141
143
  screenshot_and_raise 'picker is not in date time or time mode'
142
144
  end
143
145
 
146
+
144
147
  should_see_date_picker picker_id
145
148
 
149
+
146
150
  convert = convert_to_utc_from_options options
147
151
 
152
+
148
153
  ensure_can_change_picker_to_date target_dt, picker_id
149
154
 
155
+
150
156
  target_str = convert_date_time_to_objc_fmt target_dt, convert
151
157
  fmt_str = date_format_for_target(:objc, convert ? :zoned : :default)
152
158
 
159
+
153
160
  args = args_for_change_date_on_picker options
161
+
162
+
154
163
  query_str = query_string_for_picker picker_id
155
164
 
165
+
156
166
  views_touched = map(query_str, :changeDatePickerDate, target_str, fmt_str, *args)
157
167
 
158
168
  if views_touched.empty? or views_touched.member? '<VOID>'
@@ -169,9 +179,12 @@ module Briar
169
179
  :animate => true,
170
180
  :picker_id => nil,
171
181
  :notify_targets => true})
182
+
172
183
  convert = convert_to_utc_from_options options
173
184
  picker_id = picker_id_from_options options
185
+
174
186
  target_dt = target_date_for_change_time_on_picker_with_time_str time_str, convert, picker_id
187
+
175
188
  change_picker_date_time target_dt, options
176
189
  end
177
190
 
@@ -204,10 +217,22 @@ module Briar
204
217
  end
205
218
 
206
219
 
207
- def set_briar_date_picker_variables(target_dt, options={:picker_id => nil,
208
- :convert_time_to_utc => false})
209
- picker_id = picker_id_from_options options
210
- if picker_is_in_date_and_time_mode picker_id or picker_is_in_time_mode picker_id
220
+ def set_briar_date_picker_variables(target_dt, options={})
221
+ default_options = {:picker_id => nil,
222
+ :convert_time_to_utc => false,
223
+ :assert_mode => false}
224
+ options = default_options.merge(options)
225
+
226
+ options[:assert_picker] = false
227
+ ruby_picker_time = ruby_time_from_picker options
228
+
229
+ options[:time_on_picker] = ruby_picker_time
230
+
231
+
232
+ picker_mode = picker_mode(options[:picker_id])
233
+
234
+ if picker_mode == UIDatePickerModeDateAndTime or
235
+ picker_mode == UIDatePickerModeTime
211
236
  @date_picker_time_12h = picker_time_str :h12, options
212
237
  @date_picker_time_24h = picker_time_str :h24, options
213
238
  @date_picker_time_hash = picker_time_strs_hash options
@@ -208,7 +208,7 @@ module Briar
208
208
 
209
209
  def touch_row_and_wait_to_see(row_id, view, opts={})
210
210
  if (not opts.is_a?(Hash)) and (not opts.nil?)
211
- deprecated('0.1.3',
211
+ _deprecated('0.1.3',
212
212
  "you should no longer pass a table_id '#{opts}' as an arg, pass opts hash instead",
213
213
  :warn)
214
214
  opts = {:table_id => opts}
@@ -241,7 +241,7 @@ module Briar
241
241
  end
242
242
 
243
243
  def swipe_on_row (dir, row_id, table_id=nil)
244
- if device.ios7? and device.simulator?
244
+ if ios7? and simulator?
245
245
  pending('swiping on rows is not available on iOS 7 because of a bug in Xcode 5 simulator')
246
246
  end
247
247
  wait_for_row row_id, {:table_id => table_id}
@@ -260,11 +260,11 @@ module Briar
260
260
  end
261
261
 
262
262
  def query_str_for_confirm_delete_in_row(row_id, table_id=nil)
263
- if device.ios5?
263
+ if ios5?
264
264
  # it is not either of those...
265
265
  pending 'cannot detect the confirm delete button (yet) in iOS 5'
266
266
  end
267
- mark = device.ios7? ? 'Delete' : 'Confirm Deletion'
267
+ mark = ios7? ? 'Delete' : 'Confirm Deletion'
268
268
  "#{query_str_for_row row_id, table_id} descendant control marked:'#{mark}'"
269
269
  end
270
270
 
@@ -343,7 +343,7 @@ module Briar
343
343
  def should_see_switch_in_row_with_state (switch_id, row_id, state, opts={})
344
344
 
345
345
  if (not opts.is_a?(Hash)) and (not opts.nil?)
346
- deprecated('0.1.1',
346
+ _deprecated('0.1.1',
347
347
  "you should no longer pass a table_id '#{opts}' as an arg, pass opts hash instead",
348
348
  :warn)
349
349
  opts = {:table_id => opts}
@@ -412,7 +412,7 @@ module Briar
412
412
 
413
413
  def touch_switch_in_row (switch_id, row_id, opts={})
414
414
  if (not opts.is_a?(Hash)) and (not opts.nil?)
415
- deprecated('0.1.1',
415
+ _deprecated('0.1.1',
416
416
  "you should no longer pass a table_id '#{opts}' pass a hash instead",
417
417
  :warn)
418
418
  opts = {:table_id => opts}
@@ -24,7 +24,7 @@ module Briar
24
24
  ht = query("textField marked:'#{text_field_id}' child button child imageView", :frame).first
25
25
  return false if ht.nil?
26
26
 
27
- if device.ios7?
27
+ if ios7?
28
28
  ht['X'] == 2.5 and ht['Y'] == 2.5 and ht['Width'] == 14 and ht['Height'] == 14
29
29
  else
30
30
  ht['X'] == 0 and ht['Y'] == 0 and ht['Width'] == 19 and ht['Height'] == 19
@@ -16,7 +16,7 @@ module Briar
16
16
  def current_device
17
17
  if device_internal.nil?
18
18
  #noinspection RubyParenthesesAfterMethodCallInspection
19
- @device_internal = device()
19
+ @device_internal = default_device_or_create()
20
20
  end
21
21
  @device_internal
22
22
  end
@@ -1,3 +1,3 @@
1
1
  module Briar
2
- VERSION = '0.1.3.b4'
2
+ VERSION = '0.1.3.b5'
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.3.b4
4
+ version: 0.1.3.b5
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-12-22 00:00:00.000000000 Z
11
+ date: 2014-01-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: calabash-cucumber
@@ -145,10 +145,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
145
  version: 1.3.1
146
146
  requirements: []
147
147
  rubyforge_project:
148
- rubygems_version: 2.1.11
148
+ rubygems_version: 2.2.1
149
149
  signing_key:
150
150
  specification_version: 4
151
- summary: briar-0.1.3.b4
151
+ summary: briar-0.1.3.b5
152
152
  test_files:
153
153
  - features/step_definitions/alerts_and_sheets/action_sheet_steps.rb
154
154
  - features/step_definitions/alerts_and_sheets/alert_view_steps.rb