Sha256: 3a6da2b9daf5c2cbd66a41a2fcaa8eb13c1c5ad1d695f3ad2813cb3cb3756e29

Contents?: true

Size: 1.18 KB

Versions: 10

Compression:

Stored size: 1.18 KB

Contents

module Calabash
  module IOS

    # Interactions with your app that are specific to iOS
    module Interactions

      # @!visibility private
      # Sends app to background. Simulates pressing the home button.
      #
      # @note Cannot be more than 60 seconds.
      #
      # @param [Numeric] seconds The number of seconds to keep the app
      #   in the background
      # @raise [ArgumentError] If number of seconds is less than 1 and more
      #   than 60 seconds.
      def _send_current_app_to_background(seconds)
        unless (1..60).member?(seconds)
          raise ArgumentError,
            "Number of seconds: '#{seconds}' must be between 1 and 60"
        end

        javascript = %Q(
          var x = target.deactivateAppForDuration(#{seconds});
          var MAX_RETRY=5, retry_count = 0;
          while (!x && retry_count < MAX_RETRY) {
            x = target.deactivateAppForDuration(#{seconds});
            retry_count += 1
          };
          x
        )
        uia(javascript)
      end

      # @!visibility private
      def _evaluate_javascript_in(query, javascript)
        query(query, calabashStringByEvaluatingJavaScript: javascript)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
calabash-2.0.0.pre10 lib/calabash/ios/interactions.rb
calabash-2.0.0.pre9 lib/calabash/ios/interactions.rb
calabash-2.0.0.prelegacy4 lib/calabash/ios/interactions.rb
calabash-2.0.0.prelegacy3 lib/calabash/ios/interactions.rb
calabash-2.0.0.prelegacy2 lib/calabash/ios/interactions.rb
calabash-2.0.0.prelegacy lib/calabash/ios/interactions.rb
calabash-2.0.0.pre6 lib/calabash/ios/interactions.rb
calabash-2.0.0.pre5 lib/calabash/ios/interactions.rb
calabash-2.0.0.pre4 lib/calabash/ios/interactions.rb
calabash-2.0.0.pre3 lib/calabash/ios/interactions.rb