briar 0.1.2 → 0.1.3.b1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/briar.gemspec +12 -12
  3. data/features/step_definitions/alerts_and_sheets/action_sheet_steps.rb +2 -2
  4. data/features/step_definitions/bars/tabbar_steps.rb +0 -12
  5. data/features/step_definitions/control/segmented_control_steps.rb +5 -5
  6. data/features/step_definitions/email_steps.rb +0 -6
  7. data/features/step_definitions/keyboard_steps.rb +2 -3
  8. data/features/step_definitions/picker/date_picker_steps.rb +0 -7
  9. data/features/step_definitions/scroll_view_steps.rb +0 -7
  10. data/features/step_definitions/table_steps.rb +1 -12
  11. data/lib/briar.rb +41 -10
  12. data/lib/briar/alerts_and_sheets/action_sheet.rb +6 -5
  13. data/lib/briar/alerts_and_sheets/alert_view.rb +13 -11
  14. data/lib/briar/bars/navbar.rb +12 -12
  15. data/lib/briar/bars/tabbar.rb +1 -1
  16. data/lib/briar/bars/toolbar.rb +13 -11
  17. data/lib/briar/briar_core.rb +22 -20
  18. data/lib/briar/briar_uia.rb +18 -5
  19. data/lib/briar/control/button.rb +7 -6
  20. data/lib/briar/control/segmented_control.rb +4 -2
  21. data/lib/briar/control/slider.rb +5 -4
  22. data/lib/briar/cucumber.rb +1 -0
  23. data/lib/briar/email.rb +47 -11
  24. data/lib/briar/image_view.rb +4 -4
  25. data/lib/briar/{keyboard.rb → keyboard/keyboard.rb} +17 -12
  26. data/lib/briar/keyboard/uia_keyboard.rb +172 -0
  27. data/lib/briar/label.rb +5 -3
  28. data/lib/briar/picker/date_picker.rb +1 -0
  29. data/lib/briar/picker/date_picker_core.rb +4 -4
  30. data/lib/briar/picker/date_picker_manipulation.rb +1 -0
  31. data/lib/briar/scroll_view.rb +1 -1
  32. data/lib/briar/table.rb +49 -21
  33. data/lib/briar/text_field.rb +5 -0
  34. data/lib/briar/text_view.rb +8 -9
  35. data/lib/briar/version.rb +1 -1
  36. metadata +7 -6
@@ -0,0 +1,172 @@
1
+ require 'calabash-cucumber'
2
+
3
+ module Briar
4
+ module UIAKeyboard
5
+ # use the apple localization codes
6
+ BRIAR_LANGUAGE_KEYS = {
7
+ :en => 'space',
8
+ :de => 'Leerzeichen',
9
+ # could not decide what the language code should be (alt was ja-JP)
10
+ :ja => '空白'
11
+ }
12
+
13
+ # work in progress
14
+ # the number of buttons on the keyboard will be
15
+ # 3 <== there is no international button
16
+ # 4 <== there is an international button
17
+ def keyboard_has_international? (opts={})
18
+ default_opts = {:await_keyboard => false}
19
+ opts = default_opts.merge(opts)
20
+ await_keyboard if opts[:await_keyboard]
21
+ res = uia('UIATarget.localTarget().frontMostApp().keyboard().buttons().length')
22
+ button_count = res['value']
23
+ button_count == 4
24
+ end
25
+
26
+ def touch_international_key(opts={})
27
+ default_opts = {:await_keyboard => false,
28
+ :step_pause => 0.4}
29
+ opts = default_opts.merge(opts)
30
+
31
+ await_keyboard if opts[:await_keyboard]
32
+
33
+ unless keyboard_has_international?
34
+ screenshot_and_raise 'could not find an international key on the keyboard'
35
+ end
36
+
37
+ # the international button will be at index 1
38
+ # 3 <== return key
39
+ # 2 <== Dictation key
40
+ # 1 <== International key
41
+ # 0 <== shift key
42
+ res = uia('UIATarget.localTarget().frontMostApp().keyboard().buttons()[1].tap()')
43
+ # sleep for a moment and let the keyboard settle into the new language
44
+ sleep(opts[:step_pause])
45
+ res
46
+ end
47
+
48
+
49
+ # work in progress
50
+ # when looking at elements() the space bar will be at the penultimate index
51
+ # when looking at keys() the space bar index seems to float around
52
+ def spacebar_label (opts={})
53
+ default_opts = {:await_keyboard => false}
54
+ opts = default_opts.merge(opts)
55
+ await_keyboard if opts[:await_keyboard]
56
+ elm_count = uia('UIATarget.localTarget().frontMostApp().keyboard().elements().length')['value']
57
+ spacebar_idx = elm_count - 2
58
+ res = uia("UIATarget.localTarget().frontMostApp().keyboard().elements()[#{spacebar_idx}].label()")
59
+ res['value']
60
+ end
61
+
62
+ def spacebar_has_label?(label, opts={})
63
+ default_opts = {:await_keyboard => false}
64
+ opts = default_opts.merge(opts)
65
+ await_keyboard if opts[:await_keyboard]
66
+ spacebar_label.eql?(label)
67
+ end
68
+
69
+ def english_keyboard? (opts={})
70
+ default_opts = {:await_keyboard => false}
71
+ opts = default_opts.merge(opts)
72
+ await_keyboard if opts[:await_keyboard]
73
+ spacebar_has_label? BRIAR_LANGUAGE_KEYS[:en]
74
+ end
75
+
76
+ def german_keyboard? (opts={})
77
+ default_opts = {:await_keyboard => false}
78
+ opts = default_opts.merge(opts)
79
+ await_keyboard if opts[:await_keyboard]
80
+ spacebar_has_label? BRIAR_LANGUAGE_KEYS[:de]
81
+ end
82
+
83
+ def romaji_keyboard? (opts={})
84
+ default_opts = {:await_keyboard => false}
85
+ opts = default_opts.merge(opts)
86
+ await_keyboard if opts[:await_keyboard]
87
+ spacebar_has_label? BRIAR_LANGUAGE_KEYS[:ja]
88
+ end
89
+
90
+ def touch_international_until_language(language_key, opts={})
91
+ default_opts = {:await_keyboard => false}
92
+ opts = default_opts.merge(opts)
93
+ await_keyboard if opts[:await_keyboard]
94
+
95
+ unless keyboard_has_international?
96
+ screenshot_and_raise 'keyboard does not have an international key'
97
+ end
98
+
99
+ target = BRIAR_LANGUAGE_KEYS[language_key]
100
+ if target.nil?
101
+ screenshot_and_raise "unknown language key '#{language_key}'"
102
+ end
103
+
104
+ stop_at = spacebar_label
105
+ return if target.eql?(stop_at)
106
+
107
+ touch_international_key
108
+
109
+ current = spacebar_label
110
+ loop do
111
+ break if current.eql?(target)
112
+ touch_international_key
113
+ current = spacebar_label
114
+ if current.eql?(stop_at)
115
+ screenshot_and_raise "could not find keyboard using key '#{language_key}' and space bar label '#{target}'"
116
+ end
117
+ end
118
+ end
119
+
120
+ def is_numeric_keyboard?(opts={})
121
+ default_opts = {:await_keyboard => false}
122
+ opts = default_opts.merge(opts)
123
+ await_keyboard if opts[:await_keyboard]
124
+ res = uia('UIATarget.localTarget().frontMostApp().keyboard().keys().length')['value']
125
+ res == 12
126
+ end
127
+
128
+ def briar_keyboard_send_numeric_backspace(opts={})
129
+ default_opts = {:await_keyboard => false}
130
+ opts = default_opts.merge(opts)
131
+ await_keyboard if opts[:await_keyboard]
132
+ if ios7?
133
+ uia('UIATarget.localTarget().frontMostApp().keyboard().buttons()[0].tap()')
134
+ else
135
+ keyboard_enter_char 'Delete'
136
+ end
137
+ end
138
+
139
+ def briar_keyboard_send_backspace(opts={})
140
+ default_opts = {:await_keyboard => false}
141
+ opts = default_opts.merge(opts)
142
+ await_keyboard if opts[:await_keyboard]
143
+ if is_numeric_keyboard?
144
+ briar_keyboard_send_numeric_backspace
145
+ else
146
+ briar_keyboard_send_backspace
147
+ end
148
+ end
149
+
150
+ def uia_keyboard_visible?
151
+ res = uia('UIATarget.localTarget().frontMostApp().keyboard()')['value']
152
+ not res.eql?(':nil')
153
+ end
154
+
155
+ def uia_await_keyboard(opts={})
156
+ default_opts = {:timeout => BRIAR_WAIT_TIMEOUT,
157
+ :retry_frequency => BRIAR_WAIT_RETRY_FREQ,
158
+ :post_timeout => BRIAR_WAIT_STEP_PAUSE}
159
+ opts = default_opts.merge(opts)
160
+ unless opts[:timeout_message]
161
+ msg = "waited for '#{opts[:timeout]}' for keyboard"
162
+ opts[:timeout_message] = msg
163
+ end
164
+
165
+ wait_for(opts) do
166
+ uia_keyboard_visible?
167
+ end
168
+
169
+ end
170
+
171
+ end
172
+ end
@@ -1,3 +1,5 @@
1
+ require 'calabash-cucumber'
2
+
1
3
  module Briar
2
4
  module Label
3
5
  def label_exists? (name)
@@ -32,9 +34,9 @@ module Briar
32
34
  def wait_for_label (label_id, timeout=BRIAR_WAIT_TIMEOUT)
33
35
  msg = "waited for '#{timeout}' seconds but did not see label '#{label_id}'"
34
36
  wait_for(:timeout => timeout,
35
- :retry_frequency => BRIAR_RETRY_FREQ,
36
- :post_timeout => BRIAR_POST_TIMEOUT,
37
- :timeout_message => msg ) do
37
+ :retry_frequency => BRIAR_WAIT_RETRY_FREQ,
38
+ :post_timeout => BRIAR_WAIT_STEP_PAUSE,
39
+ :timeout_message => msg) do
38
40
  label_exists? label_id
39
41
  end
40
42
  end
@@ -1,3 +1,4 @@
1
+ require 'calabash-cucumber'
1
2
  =begin
2
3
 
3
4
  examples
@@ -1,3 +1,5 @@
1
+ require 'calabash-cucumber'
2
+
1
3
  UIDatePickerModeTime = 0
2
4
  UIDatePickerModeDate = 1
3
5
  UIDatePickerModeDateAndTime = 2
@@ -32,9 +34,7 @@ module Briar
32
34
 
33
35
  def should_see_date_picker (picker_id=nil)
34
36
  query_str = query_string_for_picker picker_id
35
- if query(query_str).empty?
36
- screenshot_and_raise "should see picker with query '#{query_str}'"
37
- end
37
+ wait_for_query query_str
38
38
  query_str
39
39
  end
40
40
 
@@ -145,7 +145,7 @@ module Briar
145
145
 
146
146
  # funky little bugger - used to change a picker to the nearest minute
147
147
  # based on the minute interval
148
- def time_hash_by_add_minutes_until_at_closest_interval (time_str, interval=picker_minute_interval())
148
+ def time_hash_by_add_minutes_until_at_closest_interval (time_str, interval=picker_minute_interval)
149
149
  screenshot_and_raise "interval '#{interval}' is not on (0, 59) which is not allowed" unless (0..59).member?(interval)
150
150
  time = Time.parse(time_str)
151
151
  # normalize to zero
@@ -1,3 +1,4 @@
1
+ require 'calabash-cucumber'
1
2
  require 'date'
2
3
 
3
4
  =begin
@@ -1,4 +1,4 @@
1
- require "calabash-cucumber"
1
+ require 'calabash-cucumber'
2
2
 
3
3
  module Briar
4
4
  module ScrollView
@@ -1,3 +1,5 @@
1
+ require 'calabash-cucumber'
2
+
1
3
  module Briar
2
4
  #noinspection ALL
3
5
  module Table
@@ -32,11 +34,6 @@ module Briar
32
34
  res.first.eql? success_value
33
35
  end
34
36
 
35
- #noinspection RubyUnusedLocalVariable
36
- def row_exists? (row_id, table_id = nil)
37
- pending "deprecated 0.0.8 - use 'row_visible?' instead"
38
- end
39
-
40
37
  def row_visible? (row_id, table_id = nil)
41
38
  query_str = query_str_for_row row_id, table_id
42
39
  !query(query_str, AI).empty?
@@ -86,8 +83,8 @@ module Briar
86
83
  timeout = options[:timeout] || BRIAR_WAIT_TIMEOUT
87
84
  msg = "waited for '#{timeout}' seconds but did not see row '#{query_str}' with query '#{query_str}'"
88
85
  wait_for(:timeout => timeout,
89
- :retry_frequency => BRIAR_RETRY_FREQ,
90
- :post_timeout => BRIAR_POST_TIMEOUT,
86
+ :retry_frequency => BRIAR_WAIT_RETRY_FREQ,
87
+ :post_timeout => BRIAR_WAIT_STEP_PAUSE,
91
88
  :timeout_message => msg) do
92
89
  row_visible? row_id, table_id
93
90
  end
@@ -160,12 +157,25 @@ module Briar
160
157
  step_pause
161
158
  end
162
159
 
163
- def briar_scroll_to_row_and_touch (row_id, wait_for_view=nil)
164
- briar_scroll_to_row(row_id)
165
- if wait_for_view.nil?
160
+ def briar_scroll_to_row_and_touch (row_id, opts={})
161
+ if (not opts.is_a?(Hash)) and (not opts.nil?)
162
+ warn "WARN: deprecated 0.1.3 - you should no longer pass a view_id '#{opts}' as an arg, pass opts hash instead"
163
+ opts = {:wait_for_id => opts}
164
+ end
165
+
166
+ default_opts = {:wait_for_id => nil,
167
+ :table_id => nil,
168
+ :timeout => BRIAR_WAIT_TIMEOUT}
169
+ opts = default_opts.merge(opts)
170
+ table_id = opts[:table_id]
171
+ wait_for_id = opts[:wait_for_id]
172
+ timeout = opts[:timeout]
173
+ briar_scroll_to_row(row_id, table_id)
174
+ if wait_for_id.nil?
166
175
  touch_row row_id
167
176
  else
168
- touch_row_and_wait_to_see row_id, wait_for_view
177
+ touch_row_and_wait_to_see row_id, wait_for_id, {:timeout => timeout,
178
+ :table_id => table_id}
169
179
  end
170
180
  end
171
181
 
@@ -196,10 +206,20 @@ module Briar
196
206
  end
197
207
 
198
208
 
199
- def touch_row_and_wait_to_see(row_id, view, table_id = nil)
200
- should_see_row row_id, table_id
201
- touch_row row_id, table_id
202
- wait_for_view view, 3.0
209
+ def touch_row_and_wait_to_see(row_id, view, opts={})
210
+ if (not opts.is_a?(Hash)) and (not opts.nil?)
211
+ deprecated('0.1.3',
212
+ "you should no longer pass a table_id '#{opts}' as an arg, pass opts hash instead",
213
+ :warn)
214
+ opts = {:table_id => opts}
215
+ end
216
+
217
+ default_opts = {:table_id => nil,
218
+ :timeout => BRIAR_WAIT_TIMEOUT}
219
+ opts = default_opts.merge(opts)
220
+ should_see_row row_id, opts[:table_id]
221
+ touch_row row_id, opts[:table_id]
222
+ wait_for_view view, opts[:timeout]
203
223
  end
204
224
 
205
225
  def table_exists? (table_name)
@@ -245,12 +265,16 @@ module Briar
245
265
  end
246
266
 
247
267
  def should_see_delete_confirmation_in_row(row_id, table_id=nil)
268
+ if ios7?
269
+ pending 'cannot detect delete confirmation in iOS 7'
270
+ end
271
+
248
272
  query_str = query_str_for_confirm_delete_in_row(row_id, table_id)
249
273
  timeout = 5
250
274
  msg = "waited for '#{timeout}' seconds but did not see 'Delete' confirmation in row '#{row_id}'"
251
275
  wait_for(:timeout => timeout,
252
- :retry_frequency => BRIAR_RETRY_FREQ,
253
- :post_timeout => BRIAR_POST_TIMEOUT,
276
+ :retry_frequency => BRIAR_WAIT_RETRY_FREQ,
277
+ :post_timeout => BRIAR_WAIT_STEP_PAUSE,
254
278
  :timeout_message => msg) do
255
279
  element_exists query_str
256
280
  end
@@ -315,7 +339,9 @@ module Briar
315
339
  def should_see_switch_in_row_with_state (switch_id, row_id, state, opts={})
316
340
 
317
341
  if (not opts.is_a?(Hash)) and (not opts.nil?)
318
- warn "WARN: deprecated 0.1.1 - you should no longer pass a table_id '#{table_id}' at an arg, pass opts hash instead"
342
+ deprecated('0.1.1',
343
+ "you should no longer pass a table_id '#{opts}' as an arg, pass opts hash instead",
344
+ :warn)
319
345
  opts = {:table_id => opts}
320
346
  end
321
347
 
@@ -381,9 +407,11 @@ module Briar
381
407
  end
382
408
 
383
409
  def touch_switch_in_row (switch_id, row_id, opts={})
384
- if (not opts.is_a?(Hash)) and (not table_id.nil?)
385
- warn "WARN: deprecated 0.1.1 - passing a table_id '#{table_id}' has been deprecated pass a hash instead"
386
- opts = {:table_id => table_id}
410
+ if (not opts.is_a?(Hash)) and (not opts.nil?)
411
+ deprecated('0.1.1',
412
+ "you should no longer pass a table_id '#{opts}' pass a hash instead",
413
+ :warn)
414
+ opts = {:table_id => opts}
387
415
  end
388
416
 
389
417
  default_opts = {:table_id => nil,
@@ -31,6 +31,11 @@ module Briar
31
31
  end
32
32
  end
33
33
 
34
+ def clear_text_field_with_button(text_field_id)
35
+ should_see_clear_button_in_text_field text_field_id
36
+ touch("textField marked:'#{text_field_id}' child button")
37
+ end
38
+
34
39
  def should_see_clear_button_in_text_field (text_field_id)
35
40
  unless button_in_text_field_is_clear? text_field_id
36
41
  screenshot_and_raise "expected to see clear button in text field #{text_field_id}"
@@ -1,5 +1,4 @@
1
- require "calabash-cucumber"
2
-
1
+ require 'calabash-cucumber'
3
2
  module Briar
4
3
  module TextView
5
4
  def text_view_exists? (view_id)
@@ -9,8 +8,8 @@ module Briar
9
8
  def wait_for_text_view(view_id, timeout=BRIAR_WAIT_TIMEOUT)
10
9
  msg = "waited for '#{timeout}' seconds but did not see '#{view_id}'"
11
10
  wait_for(:timeout => timeout,
12
- :retry_frequency => BRIAR_RETRY_FREQ,
13
- :post_timeout => BRIAR_POST_TIMEOUT,
11
+ :retry_frequency => BRIAR_WAIT_RETRY_FREQ,
12
+ :post_timeout => BRIAR_WAIT_STEP_PAUSE,
14
13
  :timeout_message => msg) do
15
14
  text_view_exists? view_id
16
15
  end
@@ -19,8 +18,8 @@ module Briar
19
18
  def wait_for_text_view_to_disappear(view_id, timeout=BRIAR_WAIT_TIMEOUT)
20
19
  msg = "waited for '#{timeout}' seconds for '#{view_id}' to disappear but it is still visible"
21
20
  options = {:timeout => timeout,
22
- :retry_frequency => BRIAR_RETRY_FREQ,
23
- :post_timeout => BRIAR_POST_TIMEOUT,
21
+ :retry_frequency => BRIAR_WAIT_RETRY_FREQ,
22
+ :post_timeout => BRIAR_WAIT_STEP_PAUSE,
24
23
  :timeout_message => msg}
25
24
  wait_for(options) do
26
25
  not text_view_exists? view_id
@@ -35,11 +34,11 @@ module Briar
35
34
  wait_for_text_view_to_disappear(view_id, timeout)
36
35
  end
37
36
 
38
- def should_see_text_view_with_text(view_id, text)
37
+ def should_see_text_view_with_text(view_id, text=@text_entered_by_keyboard)
39
38
  should_see_text_view view_id
40
39
  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}'"
40
+ unless text.eql?(actual)
41
+ screenshot_and_raise "i expected to see '#{text}' in text view '#{view_id}' but found '#{actual}'"
43
42
  end
44
43
  end
45
44
  end
@@ -1,3 +1,3 @@
1
1
  module Briar
2
- VERSION = '0.1.2'
2
+ VERSION = '0.1.3.b1'
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.2
4
+ version: 0.1.3.b1
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-04 00:00:00.000000000 Z
11
+ date: 2013-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: calabash-cucumber
@@ -108,7 +108,8 @@ files:
108
108
  - lib/briar/cucumber.rb
109
109
  - lib/briar/email.rb
110
110
  - lib/briar/image_view.rb
111
- - lib/briar/keyboard.rb
111
+ - lib/briar/keyboard/keyboard.rb
112
+ - lib/briar/keyboard/uia_keyboard.rb
112
113
  - lib/briar/label.rb
113
114
  - lib/briar/picker/date_picker.rb
114
115
  - lib/briar/picker/date_picker_core.rb
@@ -137,15 +138,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
137
138
  version: '0'
138
139
  required_rubygems_version: !ruby/object:Gem::Requirement
139
140
  requirements:
140
- - - '>='
141
+ - - '>'
141
142
  - !ruby/object:Gem::Version
142
- version: '0'
143
+ version: 1.3.1
143
144
  requirements: []
144
145
  rubyforge_project:
145
146
  rubygems_version: 2.1.11
146
147
  signing_key:
147
148
  specification_version: 4
148
- summary: briar-0.1.2
149
+ summary: briar-0.1.3.b1
149
150
  test_files:
150
151
  - features/step_definitions/alerts_and_sheets/action_sheet_steps.rb
151
152
  - features/step_definitions/alerts_and_sheets/alert_view_steps.rb