briar 0.0.8 → 0.0.9

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.
@@ -1,64 +1,51 @@
1
-
2
-
3
-
4
1
  module Briar
5
2
  module Keyboard
6
- # these are not ready for prime time# the methods for setting auto correct, spell check, etc. are not ready
3
+ # dismiss the keyboard on iPad
4
+ # send_uia_command command:"uia.keyboard().buttons()['Hide keyboard'].tap()"
5
+
6
+ # these are not ready for prime time
7
+ # the methods for setting auto correct, spell check, etc. are not ready
7
8
  UITextAutocapitalizationTypeNone = 0
8
9
  UITextAutocapitalizationTypeWords = 1
9
10
  UITextAutocapitalizationTypeSentences = 2
10
11
  UITextAutocapitalizationTypeAllCharacters = 3
11
12
 
13
+ UITextAutocorrectionTypeYes = 0
12
14
  UITextAutocorrectionTypeNo = 1
13
- UITextAutocorrectionTypeYes = 2
15
+
14
16
 
15
17
  UITextSpellCheckingTypeNo = 1
16
18
  UITextSpellCheckingTypeYes = 2
17
19
 
18
20
  @text_entered_by_keyboard = ''
19
21
 
20
- def should_see_keyboard (timeout=1.0)
22
+ def should_see_keyboard (timeout=BRIAR_WAIT_TIMEOUT)
21
23
  msg = "waited for '#{timeout}' seconds but did not see keyboard"
22
24
  wait_for(:timeout => timeout,
23
25
  :retry_frequency => 0.2,
24
26
  :post_timeout => 0.1,
25
- :timeout_message => msg ) do
27
+ :timeout_message => msg) do
26
28
  element_exists('keyboardAutomatic')
27
29
  end
28
30
  end
29
31
 
30
- def should_not_see_keyboard (timeout=1.0)
32
+ def should_not_see_keyboard (timeout=BRIAR_WAIT_TIMEOUT)
31
33
  msg = "waited for '#{timeout}' seconds but keyboard did not disappear"
32
34
  wait_for(:timeout => timeout,
33
35
  :retry_frequency => 0.2,
34
36
  :post_timeout => 0.1,
35
- :timeout_message => msg ) do
37
+ :timeout_message => msg) do
36
38
  element_does_not_exist 'keyboardAutomatic'
37
39
  end
38
40
  end
39
41
 
40
42
  def briar_keyboard_enter_text (text)
41
- if device.ios7?
42
- pending('keyboard playback is not available on iOS 7')
43
- end
44
- @text_entered_by_keyboard = keyboard_enter_text text
43
+ keyboard_enter_text text
44
+ # not ideal, but entering text by uia keyboard will never return what
45
+ # was text was actually input to the keyboard
46
+ @text_entered_by_keyboard = text
45
47
  end
46
48
 
47
- def briar_keyboard_set_text (text, view_id, &do_for_each_char)
48
- unless device.ios7?
49
- warn 'this is hack for iOS 7 (playback not available yet) - use briar_keyboard_enter_text'
50
- end
51
-
52
- query_str = "view marked:'#{view_id}'"
53
- accum = ''
54
- text.chars.to_a.each { |char|
55
- accum << char
56
- query(query_str, {setText:accum})
57
- do_for_each_char.call(view_id, accum)
58
- @text_entered_by_keyboard = accum
59
- sleep(0.05)
60
- }
61
- end
62
49
 
63
50
  # is it possible to find what view the keyboard is responding to?
64
51
  def autocapitalization_type ()
@@ -71,11 +58,21 @@ module Briar
71
58
  end
72
59
  end
73
60
 
61
+ def auto_correct_type()
62
+ if !query('textView index:0').empty?
63
+ query('textView index:0', :autocorrectionType).first.to_i
64
+ elsif !query('textField index:0').empty?
65
+ query('textField index:0', :autocorrectionType).first.to_i
66
+ else
67
+ screenshot_and_raise 'could not find a text view or text field'
68
+ end
69
+ end
70
+
74
71
  def set_autocapitalization (type)
75
72
  if !query('textView index:0').empty?
76
- query('textView index:0', [{setAutocapitalizationType:type}])
73
+ query('textView index:0', [{setAutocapitalizationType: type}])
77
74
  elsif !query('textField index:0').empty?
78
- query('textField index:0', [{setAutocapitalizationType:type}])
75
+ query('textField index:0', [{setAutocapitalizationType: type}])
79
76
  else
80
77
  screenshot_and_raise 'could not find a text view or text field'
81
78
  end
@@ -87,9 +84,9 @@ module Briar
87
84
 
88
85
  def set_autocorrect (type)
89
86
  if !query('textView index:0').empty?
90
- query('textView index:0', [{setAutocorrectionType:type}])
87
+ query('textView index:0', [{setAutocorrectionType: type}])
91
88
  elsif !query('textField index:0').empty?
92
- query('textField index:0', [{setAutocorrectionType:type}])
89
+ query('textField index:0', [{setAutocorrectionType: type}])
93
90
  else
94
91
  screenshot_and_raise 'could not find a text view or text field'
95
92
  end
@@ -101,20 +98,23 @@ module Briar
101
98
 
102
99
  def turn_spell_correct_off
103
100
  if !query('textView index:0').empty?
104
- query('textView index:0', [{setSpellCheckingType:UITextSpellCheckingTypeNo}])
101
+ query('textView index:0', [{setSpellCheckingType: UITextSpellCheckingTypeNo}])
105
102
  elsif !query('textField index:0').empty?
106
- query('textField index:0', [{setSpellCheckingType:UITextSpellCheckingTypeNo}])
103
+ query('textField index:0', [{setSpellCheckingType: UITextSpellCheckingTypeNo}])
107
104
  else
108
105
  screenshot_and_raise 'could not find a text view or text field'
109
106
  end
110
107
  end
111
108
 
112
-
113
-
114
- def clear_text(uiquery)
115
- text_fields_modified = map(uiquery, :setText, '')
116
- screenshot_and_raise "could not find text field #{uiquery}" if text_fields_modified.empty?
117
- text_fields_modified
109
+ def briar_clear_text(view_id)
110
+ wait_for_view view_id
111
+ touch("view marked:'#{view_id}'")
112
+ wait_for_button 'Select All'
113
+ step_pause
114
+ touch_button_and_wait_for_view 'Select All', 'Cut'
115
+ step_pause
116
+ touch_button 'Cut'
117
+ step_pause
118
118
  end
119
119
 
120
120
  #def is_capitalize_none (cap_type)
data/lib/briar/label.rb CHANGED
@@ -1,5 +1,3 @@
1
- require "calabash-cucumber"
2
-
3
1
  module Briar
4
2
  module Label
5
3
  def label_exists? (name)
@@ -31,7 +29,7 @@ module Briar
31
29
  end
32
30
  end
33
31
 
34
- def wait_for_label (label_id, timeout=1.0)
32
+ def wait_for_label (label_id, timeout=BRIAR_WAIT_TIMEOUT)
35
33
  msg = "waited for '#{timeout}' seconds but did not see label '#{label_id}'"
36
34
  wait_for(:timeout => timeout,
37
35
  :retry_frequency => 0.2,
@@ -25,8 +25,16 @@ module Briar
25
25
  include Briar::Picker::DateCore
26
26
  include Briar::Picker::DateManipulation
27
27
 
28
- # requires a time or date change. picker does not need to be visible
28
+ def should_see_label_has_time_i_just_entered (label_id)
29
+ should_see_label label_id
30
+ query_str = "label marked:'#{label_id}'"
31
+ actual_text = query(query_str, :text).first
32
+ unless (actual_text.eql? @date_picker_time_12h) or (actual_text.eql? @date_picker_time_24h)
33
+ screenshot_and_raise "expected to see '#{@date_picker_time_12h}' or '#{@date_picker_time_24h}' in '#{label_id}' but found '#{actual_text}'"
34
+ end
35
+ end
29
36
 
37
+ # requires a time or date change. picker does not need to be visible
30
38
  def should_see_row_has_time_i_just_entered (row_id, label_id, table_id=nil)
31
39
  query_str = query_str_for_row row_id, table_id
32
40
  arr = query("#{query_str} descendant label marked:'#{label_id}'", :text)
@@ -115,14 +115,14 @@ module Briar
115
115
  # pickers that use utc (reminders, alerts, etc. do no usually have
116
116
  # min/max dates
117
117
  def ensure_can_change_picker_to_date(target_dt, picker_id=nil)
118
- max_date = picker_maximum_date_time picker_id
118
+ max_date = maximum_date_time_from_picker picker_id
119
119
  if max_date and target_dt > max_date
120
120
  p "target: '#{target_dt}'"
121
121
  p " 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
 
125
- min_date = picker_minimum_date_time picker_id
125
+ min_date = minimum_date_time_from_picker picker_id
126
126
  if min_date and target_dt < min_date
127
127
  p "target: '#{target_dt}'"
128
128
  p " min: '#{min_date}'"
data/lib/briar/table.rb CHANGED
@@ -1,11 +1,10 @@
1
- #require 'calabash-cucumber'
2
-
3
1
  module Briar
2
+ #noinspection ALL
4
3
  module Table
5
4
 
6
5
  def query_str_for_row_content (row_id, table_id = nil)
7
6
  base = query_str_for_row row_id, table_id
8
- "#{base} tableViewCellContentView descendant"
7
+ "#{base} descendant"
9
8
  end
10
9
 
11
10
  def query_str_for_row (row_id, table_id = nil)
@@ -71,12 +70,9 @@ module Briar
71
70
  end
72
71
 
73
72
  def should_see_row (row_id, table_id = nil)
74
- unless row_visible? row_id, table_id
75
- screenshot_and_raise "i do not see a row '#{row_id}'"
76
- end
73
+ wait_for_row(row_id, {:table_id => table_id})
77
74
  end
78
75
 
79
-
80
76
  def should_not_see_row(row_id, table_id=nil)
81
77
  if row_visible? row_id, table_id
82
78
  screenshot_and_raise "i should not have seen row named #{row_id}"
@@ -84,15 +80,15 @@ module Briar
84
80
  end
85
81
 
86
82
  def wait_for_row(row_id, options={:table_id => nil,
87
- :timeout => 1.0})
83
+ :timeout => BRIAR_WAIT_TIMEOUT})
88
84
  table_id = options[:table_id]
89
85
  query_str = query_str_for_row row_id, table_id
90
- timeout = options[:timeout] || 1.0
86
+ timeout = options[:timeout] || BRIAR_WAIT_TIMEOUT
91
87
  msg = "waited for '#{timeout}' seconds but did not see row '#{query_str}' with query '#{query_str}'"
92
88
  wait_for(:timeout => timeout,
93
89
  :retry_frequency => 0.2,
94
90
  :post_timeout => 0.1,
95
- :timeout_message => msg ) do
91
+ :timeout_message => msg) do
96
92
  row_visible? row_id, table_id
97
93
  end
98
94
  end
@@ -118,6 +114,21 @@ module Briar
118
114
  end
119
115
  end
120
116
 
117
+ def should_see_row_with_label_that_has_no_text(row_id, label_id)
118
+ wait_for_row row_id
119
+ qstr = "#{query_str_for_row_content row_id} label marked:'#{label_id}'"
120
+ res = query(qstr, :text)
121
+ if res.empty?
122
+ screenshot_and_raise "expected to see row '#{row_id}' with label '#{label_id}'"
123
+ end
124
+
125
+ text = res.first
126
+ unless text.nil? or text.eql?('')
127
+ screenshot_and_raise "expected to see no text in row '#{row_id}' in label '#{label_id}' but found '#{text}'"
128
+ end
129
+ end
130
+
131
+
121
132
  def should_see_row_with_image (row_id, image_id, table_id = nil)
122
133
  should_see_row row_id, table_id
123
134
  query_str = query_str_for_row_content row_id, table_id
@@ -189,6 +200,7 @@ module Briar
189
200
 
190
201
  def touch_row (row_id, table_id = nil)
191
202
  should_see_row row_id
203
+ step_pause
192
204
  offset = touch_row_offset_hash row_id, table_id
193
205
  query_str = query_str_for_row(row_id, table_id)
194
206
  #puts "touch(\"#{query_str}\", :offset => #{offset})"
@@ -200,7 +212,7 @@ module Briar
200
212
  def touch_row_and_wait_to_see(row_id, view, table_id = nil)
201
213
  should_see_row row_id, table_id
202
214
  touch_row row_id, table_id
203
- wait_for_view view, 2.0
215
+ wait_for_view view, 3.0
204
216
  end
205
217
 
206
218
  def table_exists? (table_name)
@@ -222,9 +234,10 @@ module Briar
222
234
  end
223
235
 
224
236
  def swipe_on_row (dir, row_id, table_id=nil)
225
- if device.ios7?
226
- pending ('swipe is not available on iOS 7')
237
+ if device.ios7? and device.simulator?
238
+ pending('swiping on rows is not available on iOS 7 because of a bug in Xcode 5 simulator')
227
239
  end
240
+ wait_for_row row_id, {:table_id => table_id}
228
241
  query_str = query_str_for_row row_id, table_id
229
242
  swipe(dir, {:query => query_str})
230
243
  step_pause
@@ -239,23 +252,33 @@ module Briar
239
252
  end
240
253
  end
241
254
 
255
+ def query_str_for_confirm_delete_in_row(row_id, table_id=nil)
256
+ mark = device.ios7? ? 'Delete' : 'Confirm Deletion'
257
+ "#{query_str_for_row row_id, table_id} descendant control marked:'#{mark}'"
258
+ end
259
+
242
260
  def should_see_delete_confirmation_in_row(row_id, table_id=nil)
243
- query_str = query_str_for_row row_id, table_id
244
- if query("#{query_str} descendant tableViewCellDeleteConfirmationControl").empty?
245
- screenshot_and_raise "should see a delete confirmation button on row '#{row_id}'"
261
+ query_str = query_str_for_confirm_delete_in_row(row_id, table_id)
262
+ timeout = 5
263
+ msg = "waited for '#{timeout}' seconds but did not see 'Delete' confirmation in row '#{row_id}'"
264
+ wait_for(:timeout => timeout,
265
+ :retry_frequency => 0.2,
266
+ :post_timeout => 0.1,
267
+ :timeout_message => msg) do
268
+ element_exists query_str
246
269
  end
247
270
  end
248
271
 
249
272
  def touch_delete_confirmation(row_id, table_id=nil)
250
- query_str = query_str_for_row row_id, table_id
251
- touch("#{query_str} descendant tableViewCellDeleteConfirmationControl")
273
+ query_str = query_str_for_confirm_delete_in_row(row_id, table_id)
274
+ touch(query_str)
252
275
  step_pause
253
276
  end
254
277
 
255
278
  def edit_mode_delete_button_exists? (row_id, table_id=nil)
256
279
  query_str = query_str_for_row row_id, table_id
257
- #!query("all tableViewCell marked:'#{row_id}' child tableViewCellEditControl").empty?
258
- !query("#{query_str} descendant tableViewCellEditControl").empty?
280
+ # note the extra space on the Delete
281
+ !query("#{query_str} descendant tableViewCellEditControl marked:'Delete '").empty?
259
282
  end
260
283
 
261
284
  def should_see_edit_mode_delete_button (row_id, table_id=nil)
@@ -272,8 +295,6 @@ module Briar
272
295
 
273
296
  def reorder_button_exists? (row_id, table_id=nil)
274
297
  query_str = query_str_for_row row_id, table_id
275
- #!query("tableViewCell marked:'#{row_id}' child tableViewCellReorderControl").empty?
276
- #!query("all tableViewCell marked:'#{row_id}' child tableViewCellReorderControl").empty?
277
298
  !query("#{query_str} descendant tableViewCellReorderControl").empty?
278
299
  end
279
300
 
@@ -299,8 +320,8 @@ module Briar
299
320
 
300
321
  def touch_edit_mode_delete_button (row_id, table_id=nil)
301
322
  should_see_edit_mode_delete_button row_id, table_id
302
- touch("tableViewCell marked:'#{row_id}' child tableViewCellEditControl")
303
- step_pause
323
+ touch("tableViewCell marked:'#{row_id}' descendant tableViewCellEditControl marked:'Delete '")
324
+ # this is a wait function - so no step pause is necessary
304
325
  should_see_delete_confirmation_in_row row_id
305
326
  end
306
327
 
@@ -343,7 +364,9 @@ module Briar
343
364
 
344
365
  def delete_row_with_edit_mode_delete_button (row_id, table_id=nil)
345
366
  touch_edit_mode_delete_button row_id, table_id
367
+ 2.times { step_pause }
346
368
  touch_delete_confirmation row_id, table_id
369
+ 2.times { step_pause }
347
370
  should_not_see_row row_id, table_id
348
371
  end
349
372
 
@@ -355,10 +378,12 @@ module Briar
355
378
  end
356
379
 
357
380
  def swipe_to_delete_row (row_id, table_id = nil)
358
-
381
+ step_pause
359
382
  swipe_on_row 'left', row_id, table_id
383
+ step_pause
360
384
  should_see_delete_confirmation_in_row row_id, table_id
361
385
  touch_delete_confirmation row_id, table_id
386
+ step_pause
362
387
  should_not_see_row row_id, table_id
363
388
  end
364
389
 
@@ -393,5 +418,11 @@ module Briar
393
418
  touch("#{query_str} descendant view marked:'#{header_id}'")
394
419
  step_pause
395
420
  end
421
+
422
+ def touch_button_in_row(button_id, row_id, table_id=nil)
423
+ query_str = query_str_for_table(table_id)
424
+ touch("#{query_str} descendant button marked:'#{button_id}'")
425
+ step_pause
426
+ end
396
427
  end
397
428
  end
@@ -1,4 +1,4 @@
1
- require "calabash-cucumber"
1
+ require 'calabash-cucumber'
2
2
 
3
3
  module Briar
4
4
  module TextField
@@ -22,10 +22,12 @@ module Briar
22
22
 
23
23
  def button_in_text_field_is_clear? (text_field_id)
24
24
  ht = query("textField marked:'#{text_field_id}' child button child imageView", :frame).first
25
- if !ht.nil?
26
- ht["X"] == 0 and ht["Y"] == 0 and ht["Width"] == 19 and ht["Height"] == 19
25
+ return false if ht.nil?
26
+
27
+ if device.ios7?
28
+ ht['X'] == 2.5 and ht['Y'] == 2.5 and ht['Width'] == 14 and ht['Height'] == 14
27
29
  else
28
- false
30
+ ht['X'] == 0 and ht['Y'] == 0 and ht['Width'] == 19 and ht['Height'] == 19
29
31
  end
30
32
  end
31
33
 
@@ -2,19 +2,44 @@ require "calabash-cucumber"
2
2
 
3
3
  module Briar
4
4
  module TextView
5
- def text_view_exists? (name)
6
- !query("textView marked:'#{name}'").empty?
5
+ def text_view_exists? (view_id)
6
+ !query("textView marked:'#{view_id}'").empty?
7
7
  end
8
8
 
9
- def should_see_text_view (name)
10
- unless text_view_exists? name
11
- screenshot_and_raise "i do not see text view with id #{name}"
9
+ def wait_for_text_view(view_id, timeout=BRIAR_WAIT_TIMEOUT)
10
+ msg = "waited for '#{timeout}' seconds but did not see '#{view_id}'"
11
+ wait_for(:timeout => timeout,
12
+ :retry_frequency => 0.2,
13
+ :post_timeout => 0.1,
14
+ :timeout_message => msg) do
15
+ text_view_exists? view_id
12
16
  end
13
17
  end
14
18
 
15
- def should_not_see_text_view (name)
16
- if text_view_exists? name
17
- screenshot_and_raise "i should not see text view with name #{name}"
19
+ def wait_for_text_view_to_disappear(view_id, timeout=BRIAR_WAIT_TIMEOUT)
20
+ msg = "waited for '#{timeout}' seconds for '#{view_id}' to disappear but it is still visible"
21
+ options = {:timeout => timeout,
22
+ :retry_frequency => 0.2,
23
+ :post_timeout => 0.1,
24
+ :timeout_message => msg}
25
+ wait_for(options) do
26
+ not text_view_exists? view_id
27
+ end
28
+ end
29
+
30
+ def should_see_text_view (view_id, timeout=BRIAR_WAIT_TIMEOUT)
31
+ wait_for_text_view(view_id, timeout)
32
+ end
33
+
34
+ def should_not_see_text_view (view_id, timeout=BRIAR_WAIT_TIMEOUT)
35
+ wait_for_text_view_to_disappear(view_id, timeout)
36
+ end
37
+
38
+ def should_see_text_view_with_text(view_id, text)
39
+ should_see_text_view view_id
40
+ actual = query("textView marked:'#{view_id}'", :text).first
41
+ unless @text_entered_by_keyboard.eql?(actual)
42
+ screenshot_and_raise "i expected to see '#{@text_entered_by_keyboard}' in text view '#{view_id}' but found '#{actual}'"
18
43
  end
19
44
  end
20
45
  end