Module: Calabash::Cucumber::RotationHelpers
- Included in:
- Core
- Defined in:
- lib/calabash-cucumber/rotation_helpers.rb
Overview
> Connection, StatusBarHelpers
Instance Method Summary collapse
- #rotate(dir) ⇒ Object
-
#rotate_home_button_to(dir) ⇒ Object
orientations refer to home button position down ==> bottom up ==> top left ==> landscape with left home button AKA: right landscape* right ==> landscape with right home button AKA: left landscape*.
- #rotation_candidates ⇒ Object
Instance Method Details
#rotate(dir) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/calabash-cucumber/rotation_helpers.rb', line 74 def rotate(dir) dir = dir.to_sym current_orientation = ().to_sym rotate_cmd = nil case dir when :left then if current_orientation == :down rotate_cmd = 'left_home_down' elsif current_orientation == :right rotate_cmd = 'left_home_right' elsif current_orientation == :left rotate_cmd = 'left_home_left' elsif current_orientation == :up rotate_cmd = 'left_home_up' end when :right then if current_orientation == :down rotate_cmd = 'right_home_down' elsif current_orientation == :left rotate_cmd = 'right_home_left' elsif current_orientation == :right rotate_cmd = 'right_home_right' elsif current_orientation == :up rotate_cmd = 'right_home_up' end end if rotate_cmd.nil? if ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1' puts "Could not rotate device in direction '#{dir}' with orientation '#{current_orientation} - will do nothing" end else playback("rotate_#{rotate_cmd}") end end |
#rotate_home_button_to(dir) ⇒ Object
orientations refer to home button position
down ==> bottom
up ==> top
left ==> landscape with left home button AKA: _right_ landscape*
right ==> landscape with right home button AKA: left landscape*
-
see apple documentation for clarification about where the home button is in left and right landscape orientations
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/calabash-cucumber/rotation_helpers.rb', line 18 def (dir) dir_sym = dir.to_sym if dir_sym.eql?(:top) if ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1' warn "converting '#{dir}' to ':up' - please adjust your code" end dir_sym = :up end if dir_sym.eql?(:bottom) if ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1' warn "converting '#{dir}' to ':down' - please adjust your code" end dir_sym = :down end directions = [:down, :up, :left, :right] unless directions.include?(dir_sym) screenshot_and_raise "expected one of '#{directions}' as an arg to 'rotate_home_button_to but found '#{dir}'" end res = () if res.nil? screenshot_and_raise "expected 'status_bar_orientation' to return a non-nil value" else res = res.to_sym end return res if res.eql? dir_sym rotation_candidates.each { |candidate| if ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1' puts "try to rotate to '#{dir_sym}' using '#{candidate}'" end playback(candidate) # need a longer sleep for cloud testing sleep(0.4) res = if res.nil? screenshot_and_raise "expected 'status_bar_orientation' to return a non-nil value" else res = res.to_sym end return if res.eql? dir_sym } if ENV['CALABASH_FULL_CONSOLE_OUTPUT'] == '1' warn "Could not rotate home button to '#{dir}'." warn 'Is rotation enabled for this controller?' warn "Will return 'down'" end :down end |
#rotation_candidates ⇒ Object
5 6 7 8 |
# File 'lib/calabash-cucumber/rotation_helpers.rb', line 5 def rotation_candidates %w(rotate_left_home_down rotate_left_home_left rotate_left_home_right rotate_left_home_up rotate_right_home_down rotate_right_home_left rotate_right_home_right rotate_right_home_up) end |