Sha256: 92ebd07e4c09b6716e3b38e0a7dc6c6b5b3cb30f7632b45428b750d5cc613ad2

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

require 'calabash-cucumber/utils/logging'

module Calabash
  module Cucumber
    module StatusBarHelpers #=> Map

      include Calabash::Cucumber::Logging

      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 rotate_home_button_to :down
        end

        return res unless res.eql?('unknown')
        return res unless force_down
        rotate_home_button_to(:down)
      end

      def status_bar_orientation
        map(nil, :orientation, :status_bar).first
      end

      # returns +true+ if orientation is portrait
      def portrait?
        o = status_bar_orientation
        o.eql?('up') or o.eql?('down')
      end

      # returns +true+ if orientation is landscape
      def landscape?
        o = status_bar_orientation
        o.eql?('right') or o.eql?('left')
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
calabash-cucumber-0.10.0.pre1 lib/calabash-cucumber/status_bar_helpers.rb
calabash-cucumber-0.9.169 lib/calabash-cucumber/status_bar_helpers.rb
calabash-cucumber-0.9.169.pre6 lib/calabash-cucumber/status_bar_helpers.rb
calabash-cucumber-0.9.169.pre5 lib/calabash-cucumber/status_bar_helpers.rb