briar 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (57) hide show
  1. checksums.yaml +15 -0
  2. data/.gitignore +29 -0
  3. data/Gemfile +4 -0
  4. data/LICENSE.txt +36 -0
  5. data/README.md +25 -0
  6. data/Rakefile +12 -0
  7. data/briar.gemspec +26 -0
  8. data/dotirbc_briar_additions +31 -0
  9. data/features/step_definitions/alerts_and_sheets/action_sheet_steps.rb +8 -0
  10. data/features/step_definitions/alerts_and_sheets/alert_view_steps.rb +25 -0
  11. data/features/step_definitions/bars/navbar_steps.rb +95 -0
  12. data/features/step_definitions/bars/tabbar_steps.rb +32 -0
  13. data/features/step_definitions/bars/toolbar_steps.rb +17 -0
  14. data/features/step_definitions/briar_core_steps.rb +9 -0
  15. data/features/step_definitions/control/button_steps.rb +57 -0
  16. data/features/step_definitions/control/segmented_control_steps.rb +85 -0
  17. data/features/step_definitions/control/slider_steps.rb +9 -0
  18. data/features/step_definitions/email_steps.rb +59 -0
  19. data/features/step_definitions/image_view_steps.rb +9 -0
  20. data/features/step_definitions/keyboard_steps.rb +21 -0
  21. data/features/step_definitions/label_steps.rb +21 -0
  22. data/features/step_definitions/picker/date_picker_steps.rb +216 -0
  23. data/features/step_definitions/picker/picker_steps.rb +58 -0
  24. data/features/step_definitions/scroll_view_steps.rb +20 -0
  25. data/features/step_definitions/table_steps.rb +186 -0
  26. data/features/step_definitions/text_field_steps.rb +37 -0
  27. data/features/step_definitions/text_view_steps.rb +44 -0
  28. data/features/support/env.rb +0 -0
  29. data/features/support/hooks.rb +0 -0
  30. data/features/support/launch.rb +0 -0
  31. data/lib/briar.rb +72 -0
  32. data/lib/briar/alerts_and_sheets/alert_view.rb +16 -0
  33. data/lib/briar/bars/navbar.rb +104 -0
  34. data/lib/briar/bars/tabbar.rb +38 -0
  35. data/lib/briar/bars/toolbar.rb +36 -0
  36. data/lib/briar/briar_core.rb +56 -0
  37. data/lib/briar/briar_steps.rb +26 -0
  38. data/lib/briar/control/button.rb +47 -0
  39. data/lib/briar/control/segmented_control.rb +22 -0
  40. data/lib/briar/control/slider.rb +34 -0
  41. data/lib/briar/cucumber.rb +49 -0
  42. data/lib/briar/email.rb +58 -0
  43. data/lib/briar/gestalt.rb +80 -0
  44. data/lib/briar/image_view.rb +27 -0
  45. data/lib/briar/keyboard.rb +104 -0
  46. data/lib/briar/label.rb +34 -0
  47. data/lib/briar/picker/date_picker.rb +598 -0
  48. data/lib/briar/picker/picker.rb +32 -0
  49. data/lib/briar/picker/picker_shared.rb +34 -0
  50. data/lib/briar/scroll_view.rb +10 -0
  51. data/lib/briar/table.rb +237 -0
  52. data/lib/briar/text_field.rb +57 -0
  53. data/lib/briar/text_view.rb +21 -0
  54. data/lib/briar/version.rb +3 -0
  55. data/spec/briar/gestalt_spec.rb +62 -0
  56. data/spec/spec_helper.rb +17 -0
  57. metadata +164 -0
@@ -0,0 +1,32 @@
1
+ require 'calabash-cucumber'
2
+
3
+ module Briar
4
+ module Picker
5
+ include Briar::Picker_Shared
6
+ def should_see_picker (picker_name)
7
+ picker_exists = !query("pickerView marked:'#{picker_name}").empty?
8
+ unless picker_exists
9
+ screenshot_and_raise "could not find picker named #{picker_name}"
10
+ end
11
+ end
12
+
13
+ def should_not_see_picker (picker_name)
14
+ picker_exists = !query("pickerView marked:'#{picker_name}").empty?
15
+ if picker_exists
16
+ screenshot_and_raise "expected to _not_ see #{picker}"
17
+ end
18
+ end
19
+
20
+ def visible_titles (column)
21
+ query("pickerTableView index:#{column} child pickerTableViewWrapperCell", :wrappedView, :text).reverse
22
+ end
23
+
24
+ # may only work on circular pickers - does _not_ work on non-circular pickers
25
+ # because the visible titles do _not_ follow the selected index
26
+ def selected_title_for_column (column)
27
+ selected_idx = picker_current_index_for_column column
28
+ titles = visible_titles column
29
+ titles[selected_idx]
30
+ end
31
+ end
32
+ end
@@ -0,0 +1,34 @@
1
+ require 'calabash-cucumber'
2
+
3
+ module Briar
4
+ module Picker_Shared
5
+ def picker_current_index_for_column (column)
6
+ arr = query("pickerTableView", :selectionBarRow)
7
+ arr[column]
8
+ end
9
+ # methods common to generic and date pickers
10
+ def picker_current_index_for_column_is(column, val)
11
+ picker_current_index_for_column(column) == val
12
+ end
13
+
14
+ def previous_index_for_column (column)
15
+ picker_current_index_for_column(column) - 1
16
+ end
17
+
18
+ def picker_next_index_for_column (column)
19
+ picker_current_index_for_column(column) + 1
20
+ end
21
+
22
+ def picker_scroll_down_on_column(column)
23
+ new_row = previous_index_for_column column
24
+ #scroll_to_row("pickerTableView index:#{column}", new_row)
25
+ query("pickerTableView index:'#{column}'", [{selectRow:new_row}, {animated:1}, {notify:1}])
26
+ end
27
+
28
+ def picker_scroll_up_on_column(column)
29
+ new_row = picker_next_index_for_column column
30
+ query("pickerTableView index:'#{column}'", [{selectRow:new_row}, {animated:1}, {notify:1}])
31
+ end
32
+ end
33
+ end
34
+
@@ -0,0 +1,10 @@
1
+ require "calabash-cucumber"
2
+
3
+ module Briar
4
+ module ScrollView
5
+ def exists? (expected_mark)
6
+ (element_exists("view marked:'#{expected_mark}'") or
7
+ element_exists("view text:'#{expected_mark}'"))
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,237 @@
1
+ require "calabash-cucumber"
2
+
3
+ module Briar
4
+ module Table
5
+ def query_str_row_in_table (row_id, table_id = nil)
6
+ table_id == nil ?
7
+ "tableViewCell marked:'#{row_id}'" :
8
+ "tableView marked:'#{table_id}' child tableViewCell marked:'#{row_id}'"
9
+ end
10
+
11
+ def query_str_rows_in_table (table_id = nil)
12
+ table_id == nil ?
13
+ "tableViewCell" :
14
+ "tableView marked:'#{table_id}' child tableViewCell"
15
+ end
16
+
17
+ def query_str_table (table_id = nil)
18
+ table_id == nil ?
19
+ "tableView" :
20
+ "tableView marked:'#{table_id}'"
21
+ end
22
+
23
+ def row_exists? (row_id, table_id = nil)
24
+ query_str = query_str_row_in_table row_id, table_id
25
+ exists = !query(query_str, :accessibilityIdentifier).empty?
26
+ # if row cannot be found just return false
27
+ return false unless exists
28
+
29
+ all_rows = query(query_str_rows_in_table(table_id), :accessibilityIdentifier)
30
+ index = all_rows.index(row_id)
31
+
32
+ # problems only happen if we are dealing with the first or last index
33
+ return exists if index != 0 and index != (all_rows.length - 1)
34
+
35
+ if index == 0 or index == (all_rows.length - 1)
36
+ # collect information about the table, row, and content offset
37
+ content_offset_y = query("tableView", :contentOffset).first["Y"]
38
+ frame = query(query_str).first["frame"]
39
+ cell_h = frame["height"].to_f
40
+ cell_y = frame["y"].to_f
41
+ table_h = query(query_str_table(table_id)).first["frame"]["height"]
42
+
43
+ # if the row is the first row and there has been no scrolling, just return true
44
+ return true if index == 0 and content_offset_y == 0
45
+ # if the row is the first row and more than half of it is visible
46
+ return (content_offset_y + cell_y + (cell_h/2.0))/content_offset_y >= 2.0 if index == 0
47
+ # if the row is the last row and more than half of it is visible
48
+ return (table_h - (cell_y - content_offset_y))/(cell_h/2.0) >= 1.0 if index == (all_rows.length - 1)
49
+ end
50
+ end
51
+
52
+ def should_see_row (row_id, table_id = nil)
53
+ unless row_exists? row_id, table_id
54
+ screenshot_and_raise "i do not see a row named #{row_id}"
55
+ end
56
+ end
57
+
58
+
59
+ def should_not_see_row(row_id)
60
+ if row_exists? row_id
61
+ screenshot_and_raise "i should not have seen row named #{row_id}"
62
+ end
63
+ end
64
+
65
+ def query_str_for_label_and_text_exists (row_id, label_id, text, table_id = nil)
66
+ table_id == nil ?
67
+ "tableViewCell marked:'#{row_id}' isHidden:0 descendant label marked:'#{label_id}'" :
68
+ "tableView marked:'#{table_id}' child tableViewCell marked:'#{row_id}' isHidden:0 descendant label marked:'#{label_id}'"
69
+
70
+ end
71
+
72
+ def row_with_label_and_text_exists? (row_id, label_id, text, table_id = nil)
73
+ should_see_row row_id
74
+ #arr = query("tableViewCell marked:'#{row_id}' isHidden:0 descendant label marked:'#{label_id}'", :text)
75
+ arr = query(query_str_for_label_and_text_exists(row_id, label_id, table_id), :text)
76
+ ## iOS 4 and 5
77
+
78
+ (arr.length == 1) and (arr.first.eql? text)
79
+ ## iOS 6
80
+ #if arr.length > 1
81
+ #
82
+ # pending "iOS 6 can have duplicate subviews"
83
+ # arr.member?(text)
84
+ end
85
+
86
+
87
+
88
+ def should_see_row_with_label_with_text (row_id, label_id, text)
89
+ should_see_row row_id
90
+ unless row_with_label_and_text_exists? row_id, label_id, text
91
+ actual = query("tableViewCell marked:'#{row_id}' child tableViewCellContentView child label marked:'#{label_id}'", :text).first
92
+ screenshot_and_raise "expected to see row '#{row_id}' with label '#{label_id}' that has text '#{text}', but found '#{actual}'"
93
+ end
94
+ end
95
+
96
+ def should_see_row_with_image (row_id, image_id, table_id = nil)
97
+ should_see_row row_id, table_id
98
+ query_base = query_str_row_in_table row_id, table_id
99
+ query_str = "#{query_base} child tableViewCellContentView child imageView marked:'#{image_id}'"
100
+ if query(query_str).empty?
101
+ if table_id == nil
102
+ screenshot_and_raise "expected to see row '#{row_id}' with image view '#{image_id}'"
103
+ else
104
+ screenshot_and_raise "expected to see row '#{row_id}' with image view '#{image_id}' in table '#{table_id}'"
105
+ end
106
+ end
107
+ end
108
+
109
+
110
+ def scroll_until_i_see_row (dir, row_id, limit)
111
+ unless row_exists? row_id
112
+ count = 0
113
+ begin
114
+ scroll("scrollView index:0", dir)
115
+ step_pause
116
+ count = count + 1
117
+ end while ((not row_exists?(row_id)) and count < limit.to_i)
118
+ end
119
+ unless row_exists?(row_id)
120
+ screenshot_and_raise "i scrolled '#{dir}' '#{limit}' times but did not see '#{row_id}'"
121
+ end
122
+ end
123
+
124
+
125
+ def touch_row_offset_hash (row_id, table_id = nil)
126
+ offset = 0
127
+ query = query_str_row_in_table row_id, table_id
128
+ if tabbar_visible?
129
+ #puts "tabbar visible"
130
+ cells = query(query_str_rows_in_table, :accessibilityIdentifier)
131
+ #puts "cells = #{cells} is #{row_id} last? ==> #{cells.last.eql?(row_id)}"
132
+ if cells.last.eql?(row_id)
133
+ row_h = query(query, :frame).first["Height"].to_i
134
+ offset = -1 * (row_h/3)
135
+ #puts "offset = #{offset}"
136
+ end
137
+ end
138
+ {:x => 0, :y => offset}
139
+ end
140
+
141
+ def touch_row (row_id, table_id = nil)
142
+ should_see_row row_id
143
+ offset = touch_row_offset_hash row_id, table_id
144
+ query_str = query_str_row_in_table(row_id, table_id)
145
+ #puts "touch(\"#{query_str}\", :offset => #{offset})"
146
+ touch(query_str, :offset => offset)
147
+ step_pause
148
+ end
149
+
150
+
151
+ def touch_row_and_wait_to_see(row_id, view, table_id = nil)
152
+ should_see_row row_id
153
+ touch_row row_id, table_id
154
+ wait_for_transition("view marked:'#{view}'",
155
+ {:timeout=>TOUCH_TRANSITION_TIMEOUT,
156
+ :retry_frequency=>TOUCH_TRANSITION_RETRY_FREQ})
157
+ end
158
+
159
+ def table_exists? (table_name)
160
+ !query("tableView marked:'#{table_name}'", :accessibilityIdentifier).empty?
161
+ end
162
+
163
+ def should_see_table (table_name)
164
+ res = table_exists? table_name
165
+ unless res
166
+ screenshot_and_raise "could not find table with access id #{table_name}"
167
+ end
168
+ end
169
+
170
+ def should_not_see_table (table_name)
171
+ res = table_exists? table_name
172
+ if res
173
+ screenshot_and_raise "expected not to find table with access id #{table_name}"
174
+ end
175
+ end
176
+
177
+ def swipe_on_row (dir, row_name)
178
+ swipe(dir, {:query => "tableViewCell marked:'#{row_name}'"})
179
+ step_pause
180
+ @row_that_was_swiped = row_name
181
+ end
182
+
183
+ def should_not_see_delete_confirmation_in_row(row_name)
184
+ unless query("tableViewCell marked:'#{row_name}' child tableViewCellDeleteConfirmationControl").empty?
185
+ screenshot_and_raise "should see a delete confirmation button on row #{row_name}"
186
+ end
187
+ end
188
+
189
+
190
+ def should_see_delete_confirmation_in_row(row_name)
191
+ if query("tableViewCell marked:'#{row_name}' child tableViewCellDeleteConfirmationControl").empty?
192
+ screenshot_and_raise "should see a delete confirmation button on row '#{row_name}'"
193
+ end
194
+ end
195
+
196
+ def touch_delete_confirmation(row_name)
197
+ touch("tableViewCell marked:'#{row_name}' child tableViewCellDeleteConfirmationControl")
198
+ step_pause
199
+ end
200
+
201
+ def edit_mode_delete_button_exists? (row_name)
202
+ #!query("tableViewCell marked:'#{row_name}' child tableViewCellEditControl").empty?
203
+ !query_all("tableViewCell marked:'#{row_name}' child tableViewCellEditControl").empty?
204
+ end
205
+
206
+ def should_see_edit_mode_delete_button (row_name)
207
+ unless edit_mode_delete_button_exists? row_name
208
+ screenshot_and_raise "should see a edit mode delete button on row #{row_name}"
209
+ end
210
+ end
211
+
212
+ def should_not_see_edit_mode_delete_button (row_name)
213
+ if edit_mode_delete_button_exists? row_name
214
+ screenshot_and_raise "i should not see an edit mode delete button on row #{row_name}"
215
+ end
216
+ end
217
+
218
+ def reorder_button_exists? (row_name)
219
+ #TableViewCellReorderControl
220
+ #!query("tableViewCell marked:'#{row_name}' child tableViewCellReorderControl").empty?
221
+ !query_all("tableViewCell marked:'#{row_name}' child tableViewCellReorderControl").empty?
222
+ end
223
+
224
+ def should_see_reorder_button (row_name)
225
+ unless reorder_button_exists? row_name
226
+ screenshot_and_raise "i should be able to see reorder button on row #{row_name}"
227
+ end
228
+ end
229
+
230
+ def should_not_see_reorder_button (row_name)
231
+ if reorder_button_exists? row_name
232
+ screenshot_and_raise "i should not see reorder button on row #{row_name}"
233
+ end
234
+ end
235
+
236
+ end
237
+ end
@@ -0,0 +1,57 @@
1
+ require "calabash-cucumber"
2
+
3
+ module Briar
4
+ module TextField
5
+ def text_field_exists? (name)
6
+ !query("textField marked:'#{name}'").empty?
7
+ end
8
+
9
+ def should_see_text_field (name)
10
+ res = text_field_exists? name
11
+ unless res
12
+ screenshot_and_raise "could not find text field with name #{name}"
13
+ end
14
+ end
15
+
16
+ def should_not_see_text_field (name)
17
+ res = text_field_exists? name
18
+ if res
19
+ screenshot_and_raise "i should not see text field with name #{name}"
20
+ end
21
+ end
22
+
23
+ def button_in_text_field_is_clear? (text_field_id)
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
27
+ else
28
+ false
29
+ end
30
+ end
31
+
32
+ def should_see_clear_button_in_text_field (text_field_id)
33
+ unless button_in_text_field_is_clear? text_field_id
34
+ screenshot_and_raise "expected to see clear button in text field #{text_field_id}"
35
+ end
36
+ end
37
+
38
+ def should_not_see_clear_button_in_text_field (text_field_id)
39
+ if button_in_text_field_is_clear? text_field_id
40
+ screenshot_and_raise "did NOT expected to see clear button in text field #{text_field_id}"
41
+ end
42
+ end
43
+
44
+ def text_field_exists_with_text?(text_field, text)
45
+ actual = query("textField marked:'#{text_field}'", :text).first
46
+ actual.eql? text
47
+ end
48
+
49
+ def should_see_text_field_with_text (text_field, text)
50
+ unless text_field_exists_with_text? text_field, text
51
+ actual = query("textField marked:'#{text_field}'", :text).first
52
+ screenshot_and_raise "i expected to see text field named '#{text_field}' with text '#{text}' but found '#{actual}'"
53
+ end
54
+ end
55
+
56
+ end
57
+ end
@@ -0,0 +1,21 @@
1
+ require "calabash-cucumber"
2
+
3
+ module Briar
4
+ module TextView
5
+ def text_view_exists? (name)
6
+ !query("textView marked:'#{name}'").empty?
7
+ end
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}"
12
+ end
13
+ end
14
+
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}"
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,3 @@
1
+ module Briar
2
+ VERSION = "0.0.4"
3
+ end
@@ -0,0 +1,62 @@
1
+ require_relative './../spec_helper'
2
+ require_relative './../../lib/briar/gestalt'
3
+
4
+ module Briar
5
+ SIM__IPHONE_5__IOS_6_JSON = "{\"outcome\":\"SUCCESS\",\"app_name\":\"Rise Up CAL\",\"simulator_device\":\"iPhone\",\"iOS_version\":\"6.0\",\"app_version\":\"1.0\",\"system\":\"x86_64\", \"app_id\":\"org.recoverywarrriors.RiseUp-cal\",\"version\":\"0.9.126\", \"simulator\":\"iPhone Simulator 358.4, iPhone OS 6.0 (iPhone (Retina 4-inch)\/10A403)\"}"
6
+ DEVICE__IPHONE_4__IOS_6_JSON = "{\"outcome\":\"SUCCESS\",\"app_name\":\"Rise Up CAL\",\"iOS_version\":\"6.0.1\",\"app_version\":\"1.0\",\"system\":\"iPhone4,1\",\"app_id\":\"org.recoverywarrriors.RiseUp-cal\",\"version\":\"0.9.125\"}"
7
+ DEVICE__IPHONE_5__IOS_6_JSON = "{\"outcome\":\"SUCCESS\",\"app_name\":\"Rise Up CAL\",\"iOS_version\":\"6.0.1\",\"app_version\":\"1.0\",\"system\":\"iPhone5,0\",\"app_id\":\"org.recoverywarrriors.RiseUp-cal\",\"version\":\"0.9.125\"}"
8
+ DEVICE__IPAD1__IOS_5_JSON = "{\"outcome\":\"SUCCESS\",\"app_name\":\"Rise Up CAL\",\"iOS_version\":\"5.1.1\",\"app_version\":\"1.0\",\"system\":\"iPad1,1\",\"app_id\":\"org.recoverywarrriors.RiseUp-cal\",\"version\":\"0.9.125\"}"
9
+
10
+ describe "Gestalt" do
11
+ before(:each) do
12
+ @sim_iphone_5_ios6 = Gestalt.new(SIM__IPHONE_5__IOS_6_JSON)
13
+ @device_iphone4_ios6 = Gestalt.new(DEVICE__IPHONE_4__IOS_6_JSON)
14
+ @device_iphone5_ios6 = Gestalt.new(DEVICE__IPHONE_5__IOS_6_JSON)
15
+ @device_ipad1_ios5 = Gestalt.new(DEVICE__IPAD1__IOS_5_JSON)
16
+ end
17
+
18
+ it "should be able to determine ios major version" do
19
+ @sim_iphone_5_ios6.is_ios6?.should == true
20
+ @sim_iphone_5_ios6.is_ios5?.should == false
21
+
22
+ @device_iphone4_ios6.is_ios6?.should == true
23
+ @device_iphone4_ios6.is_ios5?.should == false
24
+
25
+ @device_ipad1_ios5.is_ios6?.should == false
26
+ @device_ipad1_ios5.is_ios5?.should == true
27
+ end
28
+
29
+
30
+ it "should be able to determine if running on device or simulator" do
31
+ @sim_iphone_5_ios6.is_simulator?.should == true
32
+ @sim_iphone_5_ios6.is_device?.should == false
33
+
34
+ @device_iphone4_ios6.is_simulator?.should == false
35
+ @device_iphone4_ios6.is_device?.should == true
36
+
37
+ @device_ipad1_ios5.is_simulator?.should == false
38
+ @device_ipad1_ios5.is_device?.should == true
39
+
40
+ end
41
+
42
+
43
+ it "should be able to determine the device family" do
44
+ @sim_iphone_5_ios6.is_iphone?.should == true
45
+ @sim_iphone_5_ios6.is_ipad?.should == false
46
+
47
+ @device_iphone4_ios6.is_iphone?.should == true
48
+ @device_iphone4_ios6.is_ipad?.should == false
49
+
50
+ @device_ipad1_ios5.is_iphone?.should == false
51
+ @device_ipad1_ios5.is_ipad?.should == true
52
+
53
+ end
54
+
55
+ it "should be able to determine the if the runtime is on iphone 5" do
56
+ @sim_iphone_5_ios6.is_iphone_5?.should == true
57
+ @device_iphone4_ios6.is_iphone_5?.should == false
58
+ @device_iphone5_ios6.is_iphone_5?.should == true
59
+ @device_ipad1_ios5.is_iphone_5?.should == false
60
+ end
61
+ end
62
+ end