Module: Calabash::Cucumber::StatusBarHelpers
- Included in:
- Core
- Defined in:
- lib/calabash-cucumber/status_bar_helpers.rb
Overview
Contains methods for interacting with the status bar.
Instance Method Summary collapse
-
#device_orientation ⇒ 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_details ⇒ Object
Returns details about the status bar like the frame, its visibility, and orientation.
-
#status_bar_orientation ⇒ String
Returns the home button position relative to the status bar.
Instance Method Details
#device_orientation ⇒ 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’.
Returns the device orientation as reported by ‘[[UIDevice currentDevice] orientation]`.
27 28 29 |
# File 'lib/calabash-cucumber/status_bar_helpers.rb', line 27 def device_orientation Map.map(nil, :orientation, :device).first end |
#landscape? ⇒ Boolean
Is the device in the landscape orientation?
98 99 100 101 |
# File 'lib/calabash-cucumber/status_bar_helpers.rb', line 98 def landscape? o = o.eql?('right') or o.eql?('left') end |
#portrait? ⇒ Boolean
Is the device in the portrait orientation?
89 90 91 92 |
# File 'lib/calabash-cucumber/status_bar_helpers.rb', line 89 def portrait? o = o.eql?('up') or o.eql?('down') end |
#status_bar_details ⇒ Object
Returns details about the status bar like the frame, its visibility, and orientation.
Requires calabash server 0.20.0.
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 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/calabash-cucumber/status_bar_helpers.rb', line 48 def result = http({:method => :get, :raw => true, :path => "statusBar"}) if result == "" RunLoop::log_debug("status_bar_details is only available in Calabash iOS >= 0.20.0") RunLoop::log_debug("Using default status bar details based on orientation.") if portrait? { "frame" => { "y" => 0, "height" => 20, "width" => 375, "x" => 0 }, "hidden" => false, "orientation" => , "warning" => "These are default values. Update the server to 0.20.0" } else { "frame" => { "y" => 0, "height" => 10, "width" => 375, "x" => 0 }, "hidden" => false, "orientation" => , "warning" => "These are default values. Update the server to 0.20.0" } end else hash = JSON.parse(result) hash["results"] end 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.
40 41 42 |
# File 'lib/calabash-cucumber/status_bar_helpers.rb', line 40 def Map.map(nil, :orientation, :status_bar).first end |