Module: Briar::Control::Segmented_Control
- Defined in:
- lib/briar/control/segmented_control.rb
Instance Method Summary collapse
- #index_of_control_with_id(control_id) ⇒ Object
- #index_of_segment_with_name_in_control_with_id(segment_id, control_id) ⇒ Object
- #query_str_for_control(control_id = nil) ⇒ Object
- #should_see_control_with_segment_titles(control_id, segment_titles) ⇒ Object
- #should_see_segment_with_selected_state(control_id, segment_id, selected_state) ⇒ Object
- #touch_segment(segment_id, control_id) ⇒ Object
Instance Method Details
#index_of_control_with_id(control_id) ⇒ Object
15 16 17 18 |
# File 'lib/briar/control/segmented_control.rb', line 15 def index_of_control_with_id (control_id) controls = query('segmentedControl', AI) controls.index(control_id) end |
#index_of_segment_with_name_in_control_with_id(segment_id, control_id) ⇒ Object
20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/briar/control/segmented_control.rb', line 20 def index_of_segment_with_name_in_control_with_id(segment_id, control_id) qstr = "segmentedControl marked:'#{control_id}'" num_segs = query(qstr, :numberOfSegments).first.to_i idx = 0 while idx < num_segs title = query(qstr, {:titleForSegmentAtIndex => idx}).first return idx if title.eql?(segment_id) idx = idx + 1 end return nil end |
#query_str_for_control(control_id = nil) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/briar/control/segmented_control.rb', line 7 def query_str_for_control (control_id=nil) if control_id.nil? 'segmentedControl' else "segmentedControl marked:'#{control_id}'" end end |
#should_see_control_with_segment_titles(control_id, segment_titles) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/briar/control/segmented_control.rb', line 55 def should_see_control_with_segment_titles (control_id, segment_titles) @control_id = control_id should_see_view control_id tokens = tokenize_list(segment_titles) tokens.each do |token| token.strip! end counter = 0 tokens.each do |expected| idx = index_of_segment_with_name_in_control_with_id expected, control_id unless idx == counter actual = query("segmentedControl marked:'#{control_id}'", {:titleForSegmentAtIndex => counter}).first screenshot_and_raise "expected to see segment '#{expected}' at index '#{counter}' but found '#{actual}'" end counter = counter + 1 end end |
#should_see_segment_with_selected_state(control_id, segment_id, selected_state) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/briar/control/segmented_control.rb', line 32 def should_see_segment_with_selected_state (control_id, segment_id, selected_state) @segment_id = segment_id @control_id = control_id qstr = "segmentedControl marked:'#{control_id}' child segment marked:'#{segment_id}'" res = query(qstr, :isSelected) if res.empty? screenshot_and_raise "expected to see segmented control '#{control_id}' with segment '#{segment_id}'" end actual_state = res.first unless actual_state == selected_state screenshot_and_raise "expected to see segment '#{segment_id}' in '#{control_id}' with selection state '#{selected_state}' but found '#{actual_state}'" end end |
#touch_segment(segment_id, control_id) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/briar/control/segmented_control.rb', line 48 def touch_segment(segment_id, control_id) @segment_id = segment_id @control_id = control_id touch("segmentedControl marked:'#{control_id}' child segment marked:'#{segment_id}'") step_pause end |