Module: Calabash::Cucumber::StatusBarHelpers
Overview
Contains methods for interacting with the status bar.
Instance Method Summary collapse
-
#device_orientation(force_down = false) ⇒ Symbol
Returns the device orientation as reported by ‘[[UIDevice currentDevice] orientation]`.
-
#landscape? ⇒ Boolean
Is the device in the landscape orientation?.
-
#portrait? ⇒ Boolean
Is the device in the portrait orientation?.
-
#status_bar_orientation ⇒ String
Returns the home button position relative to the status bar.
Methods included from Logging
#calabash_info, #calabash_warn
Instance Method Details
#device_orientation(force_down = false) ⇒ Symbol
This method is not used internally by the gem. It is provided as an alternative to ‘status_bar_orientation`. We recommend that you use `status_bar_orientation` whenever possible.
Devices that are lying on a flat surface will report their orientation as ‘face up’ or ‘face down’. In order to translate gestures based on orientation, Calabash must have left, right, up, or down orientation. To that end, if a device is lying flat, this method will ***force*** a down orientation. This will happen regardless of the value of the ‘force_down` optional argument.
Returns the device orientation as reported by ‘[[UIDevice currentDevice] orientation]`.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/calabash-cucumber/status_bar_helpers.rb', line 31 def device_orientation(force_down=false) res = map(nil, :orientation, :device).first if ['face up', 'face down'].include?(res) if full_console_logging? if force_down puts "WARN found orientation '#{res}' - will rotate to force orientation to 'down'" end end return res unless force_down return :down end return res unless res.eql?('unknown') return res unless force_down (:down) end |
#landscape? ⇒ Boolean
Is the device in the landscape orientation?
76 77 78 79 |
# File 'lib/calabash-cucumber/status_bar_helpers.rb', line 76 def landscape? o = o.eql?('right') or o.eql?('left') end |
#portrait? ⇒ Boolean
Is the device in the portrait orientation?
67 68 69 70 |
# File 'lib/calabash-cucumber/status_bar_helpers.rb', line 67 def portrait? o = o.eql?('up') or o.eql?('down') end |
#status_bar_orientation ⇒ String
You should always prefer to use this method over ‘device_orientation`.
This method works even if a status bar is not visible.
Returns the home button position relative to the status bar.
59 60 61 |
# File 'lib/calabash-cucumber/status_bar_helpers.rb', line 59 def map(nil, :orientation, :status_bar).first end |