eyes_core 3.14.5 → 3.14.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/applitools/appium/driver.rb +11 -0
- data/lib/applitools/appium/eyes.rb +109 -6
- data/lib/applitools/appium/initialize_1.9.rb +0 -4
- data/lib/applitools/appium/initialize_2.0.rb +0 -4
- data/lib/applitools/appium/region_provider.rb +26 -0
- data/lib/applitools/appium/screenshot.rb +15 -0
- data/lib/applitools/appium/target.rb +42 -0
- data/lib/applitools/appium/utils.rb +12 -16
- data/lib/applitools/core/argument_guard.rb +6 -0
- data/lib/applitools/utils/eyes_selenium_utils.rb +1 -1
- data/lib/applitools/version.rb +1 -1
- metadata +6 -2
    
        checksums.yaml
    CHANGED
    
    | @@ -1,7 +1,7 @@ | |
| 1 1 | 
             
            ---
         | 
| 2 2 | 
             
            SHA256:
         | 
| 3 | 
            -
              metadata.gz:  | 
| 4 | 
            -
              data.tar.gz:  | 
| 3 | 
            +
              metadata.gz: 76b1b9533c6ab0e561eb14fa9b80aedfae91846720fd7559b504f097517b37d3
         | 
| 4 | 
            +
              data.tar.gz: 355309c1236932eb25b426464de828db42bd609a093271817b0ad1860d97d2d0
         | 
| 5 5 | 
             
            SHA512:
         | 
| 6 | 
            -
              metadata.gz:  | 
| 7 | 
            -
              data.tar.gz:  | 
| 6 | 
            +
              metadata.gz: af2aea48847d239d1f4c832b8168e821b1d1aa87841dd2ec9eb647f9f43e3c837a52f9a740dc11bdd765c1ff6eb342e146a55a1c4ebf16bdd71cfbf7308e7fa6
         | 
| 7 | 
            +
              data.tar.gz: e90c28eef3e5b7f9cf8f5efa72eeb3dc6279675b893dd1a4858d3854f145a173e6c0bbd97f297e5b86cf4f85eee37c83c8d335ae34b62479aa1570f50b33a182
         | 
| @@ -0,0 +1,11 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Applitools::Appium
         | 
| 4 | 
            +
              class Driver < Applitools::Selenium::Driver
         | 
| 5 | 
            +
                attr_accessor :appium_driver
         | 
| 6 | 
            +
                def initialize(eyes, options)
         | 
| 7 | 
            +
                  self.appium_driver = options.delete(:appium_driver)
         | 
| 8 | 
            +
                  super(eyes, options)
         | 
| 9 | 
            +
                end
         | 
| 10 | 
            +
              end
         | 
| 11 | 
            +
            end
         | 
| @@ -1,12 +1,115 @@ | |
| 1 1 | 
             
            # frozen_string_literal: false
         | 
| 2 2 |  | 
| 3 | 
            -
             | 
| 4 | 
            -
               | 
| 5 | 
            -
                 | 
| 6 | 
            -
             | 
| 7 | 
            -
             | 
| 3 | 
            +
            class Applitools::Appium::Eyes < Applitools::Selenium::Eyes
         | 
| 4 | 
            +
              def perform_driver_settings_for_appium_driver
         | 
| 5 | 
            +
                self.region_visibility_strategy = Applitools::Selenium::NopRegionVisibilityStrategy.new
         | 
| 6 | 
            +
                self.force_driver_resolution_as_viewport_size = true
         | 
| 7 | 
            +
              end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
              def initialize(*args)
         | 
| 10 | 
            +
                super
         | 
| 11 | 
            +
                self.dont_get_title = true
         | 
| 12 | 
            +
              end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
              private :perform_driver_settings_for_appium_driver
         | 
| 15 | 
            +
             | 
| 16 | 
            +
              def check(name, target)
         | 
| 17 | 
            +
                logger.info "check(#{name}) is called"
         | 
| 18 | 
            +
                self.tag_for_debug = name
         | 
| 19 | 
            +
                Applitools::ArgumentGuard.one_of? target, 'target', [Applitools::Selenium::Target, Applitools::Appium::Target]
         | 
| 20 | 
            +
             | 
| 21 | 
            +
                return check_native(name, target) if native_app?
         | 
| 22 | 
            +
                super
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
              attr_accessor :eyes_element_to_check, :region_provider
         | 
| 26 | 
            +
              private :eyes_element_to_check, :eyes_element_to_check=, :region_provider, :region_provider=
         | 
| 27 | 
            +
             | 
| 28 | 
            +
              def check_native(name, target)
         | 
| 29 | 
            +
                logger.info "check_native(#{name}) is called"
         | 
| 30 | 
            +
                update_scaling_params
         | 
| 31 | 
            +
                target_to_check = target.finalize
         | 
| 32 | 
            +
                match_data = Applitools::MatchWindowData.new
         | 
| 33 | 
            +
                match_data.tag = name
         | 
| 34 | 
            +
                timeout = target_to_check.options[:timeout] || USE_DEFAULT_MATCH_TIMEOUT
         | 
| 35 | 
            +
             | 
| 36 | 
            +
                eyes_element = target_to_check.region_to_check.call(driver)
         | 
| 37 | 
            +
                self.eyes_element_to_check = eyes_element
         | 
| 38 | 
            +
                region_provider = Applitools::Appium::RegionProvider.new(driver, eyes_element)
         | 
| 39 | 
            +
                match_data.read_target(target_to_check, driver)
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                check_window_base(
         | 
| 42 | 
            +
                  region_provider, timeout, match_data
         | 
| 43 | 
            +
                )
         | 
| 44 | 
            +
              end
         | 
| 45 | 
            +
             | 
| 46 | 
            +
              def native_app?
         | 
| 47 | 
            +
                return true if driver.current_context == 'NATIVE_APP'
         | 
| 48 | 
            +
                false
         | 
| 49 | 
            +
              end
         | 
| 50 | 
            +
             | 
| 51 | 
            +
              def capture_screenshot
         | 
| 52 | 
            +
                logger.info 'Getting screenshot (capture_screenshot() has been invoked)'
         | 
| 53 | 
            +
                case eyes_element_to_check
         | 
| 54 | 
            +
                when Applitools::Region
         | 
| 55 | 
            +
                  viewport_screenshot
         | 
| 56 | 
            +
                when Selenium::WebDriver::Element, Applitools::Selenium::Element
         | 
| 57 | 
            +
                  element_screenshot
         | 
| 8 58 | 
             
                end
         | 
| 59 | 
            +
              end
         | 
| 60 | 
            +
             | 
| 61 | 
            +
              def get_app_output_with_screenshot(*args)
         | 
| 62 | 
            +
                super do |screenshot|
         | 
| 63 | 
            +
                  if scale_provider
         | 
| 64 | 
            +
                    scaled_image = scale_provider.scale_image(screenshot.image)
         | 
| 65 | 
            +
                    self.screenshot = Applitools::Appium::Screenshot.new(
         | 
| 66 | 
            +
                      Applitools::Screenshot.from_image(
         | 
| 67 | 
            +
                        case scaled_image
         | 
| 68 | 
            +
                        when ChunkyPNG::Image
         | 
| 69 | 
            +
                          scaled_image
         | 
| 70 | 
            +
                        when Applitools::Screenshot::Datastream
         | 
| 71 | 
            +
                          scaled_image.image
         | 
| 72 | 
            +
                        else
         | 
| 73 | 
            +
                          raise Applitools::EyesError.new('Unknown image format after scale!')
         | 
| 74 | 
            +
                        end
         | 
| 75 | 
            +
                      )
         | 
| 76 | 
            +
                    )
         | 
| 77 | 
            +
                  end
         | 
| 78 | 
            +
                end
         | 
| 79 | 
            +
              end
         | 
| 80 | 
            +
             | 
| 81 | 
            +
              def dom_data
         | 
| 82 | 
            +
                {}
         | 
| 83 | 
            +
              end
         | 
| 84 | 
            +
             | 
| 85 | 
            +
              def check_window(tag = nil, match_timeout = USE_DEFAULT_MATCH_TIMEOUT)
         | 
| 86 | 
            +
                target = Applitools::Appium::Target.window.tap do |t|
         | 
| 87 | 
            +
                  t.timeout(match_timeout)
         | 
| 88 | 
            +
                end
         | 
| 89 | 
            +
                check(tag, target)
         | 
| 90 | 
            +
              end
         | 
| 91 | 
            +
             | 
| 92 | 
            +
              def check_region(*args)
         | 
| 93 | 
            +
                options = { timeout: USE_DEFAULT_MATCH_TIMEOUT, tag: nil }.merge! Applitools::Utils.extract_options!(args)
         | 
| 94 | 
            +
                target = Applitools::Appium::Target.new.region(*args).timeout(options[:match_timeout])
         | 
| 95 | 
            +
                check(options[:tag], target)
         | 
| 96 | 
            +
              end
         | 
| 97 | 
            +
             | 
| 98 | 
            +
              private
         | 
| 99 | 
            +
             | 
| 100 | 
            +
              def viewport_screenshot
         | 
| 101 | 
            +
                logger.info 'Viewport screenshot requested...'
         | 
| 102 | 
            +
                self.screenshot = Applitools::Appium::Screenshot.new(
         | 
| 103 | 
            +
                  Applitools::Screenshot.from_datastream(driver.screenshot_as(:png))
         | 
| 104 | 
            +
                )
         | 
| 105 | 
            +
              end
         | 
| 9 106 |  | 
| 10 | 
            -
             | 
| 107 | 
            +
              def element_screenshot
         | 
| 108 | 
            +
                logger.info 'Element screenshot requested...'
         | 
| 109 | 
            +
                self.screenshot = Applitools::Appium::Screenshot.new(
         | 
| 110 | 
            +
                  Applitools::Screenshot.from_datastream(
         | 
| 111 | 
            +
                    driver.element_screenshot_as(eyes_element_to_check, :png)
         | 
| 112 | 
            +
                  )
         | 
| 113 | 
            +
                )
         | 
| 11 114 | 
             
              end
         | 
| 12 115 | 
             
            end
         | 
| @@ -0,0 +1,26 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Applitools
         | 
| 4 | 
            +
              module Appium
         | 
| 5 | 
            +
                class RegionProvider
         | 
| 6 | 
            +
                  attr_accessor :driver, :eye_region, :coordinate_type
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  def initialize(driver, eye_region)
         | 
| 9 | 
            +
                    self.driver = driver
         | 
| 10 | 
            +
                    self.eye_region = eye_region
         | 
| 11 | 
            +
                  end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  def region
         | 
| 14 | 
            +
                    return Applitools::Region::EMPTY if
         | 
| 15 | 
            +
                        [::Selenium::WebDriver::Element, Applitools::Selenium::Element].include? eye_region.class
         | 
| 16 | 
            +
                    region = driver.session_capabilities['viewportRect']
         | 
| 17 | 
            +
                    Applitools::Region.new(
         | 
| 18 | 
            +
                      region['left'],
         | 
| 19 | 
            +
                      region['top'],
         | 
| 20 | 
            +
                      region['width'],
         | 
| 21 | 
            +
                      region['height']
         | 
| 22 | 
            +
                    )
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
                end
         | 
| 25 | 
            +
              end
         | 
| 26 | 
            +
            end
         | 
| @@ -0,0 +1,15 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Applitools
         | 
| 4 | 
            +
              module Appium
         | 
| 5 | 
            +
                class Screenshot < Applitools::EyesScreenshot
         | 
| 6 | 
            +
                  def sub_screenshot(region, _coordinate_type, _throw_if_clipped = false, _force_nil_if_clipped = false)
         | 
| 7 | 
            +
                    self.class.new(
         | 
| 8 | 
            +
                      Applitools::Screenshot.from_image(
         | 
| 9 | 
            +
                        image.crop(region.x, region.y, region.width, region.height)
         | 
| 10 | 
            +
                      )
         | 
| 11 | 
            +
                    )
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
                end
         | 
| 14 | 
            +
              end
         | 
| 15 | 
            +
            end
         | 
| @@ -0,0 +1,42 @@ | |
| 1 | 
            +
            # frozen_string_literal: true
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            module Applitools
         | 
| 4 | 
            +
              module Appium
         | 
| 5 | 
            +
                class Target
         | 
| 6 | 
            +
                  include Applitools::FluentInterface
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                  attr_accessor :region_to_check, :options
         | 
| 9 | 
            +
             | 
| 10 | 
            +
                  class << self
         | 
| 11 | 
            +
                    def window
         | 
| 12 | 
            +
                      new
         | 
| 13 | 
            +
                    end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                    def region(*args)
         | 
| 16 | 
            +
                      new.region(*args)
         | 
| 17 | 
            +
                    end
         | 
| 18 | 
            +
                  end
         | 
| 19 | 
            +
             | 
| 20 | 
            +
                  def initialize
         | 
| 21 | 
            +
                    self.region_to_check = proc { Applitools::Region::EMPTY }
         | 
| 22 | 
            +
                    self.options = {}
         | 
| 23 | 
            +
                  end
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                  def region(*args)
         | 
| 26 | 
            +
                    self.region_to_check = case args.first
         | 
| 27 | 
            +
                                           when ::Selenium::WebDriver::Element
         | 
| 28 | 
            +
                                             proc { args.first }
         | 
| 29 | 
            +
                                           else
         | 
| 30 | 
            +
                                             proc do |driver|
         | 
| 31 | 
            +
                                               driver.find_element(*args)
         | 
| 32 | 
            +
                                             end
         | 
| 33 | 
            +
                                           end
         | 
| 34 | 
            +
                    self
         | 
| 35 | 
            +
                  end
         | 
| 36 | 
            +
             | 
| 37 | 
            +
                  def finalize
         | 
| 38 | 
            +
                    self
         | 
| 39 | 
            +
                  end
         | 
| 40 | 
            +
                end
         | 
| 41 | 
            +
              end
         | 
| 42 | 
            +
            end
         | 
| @@ -3,19 +3,18 @@ | |
| 3 3 | 
             
            module Applitools::Appium
         | 
| 4 4 | 
             
              module Utils
         | 
| 5 5 | 
             
                # true if test is running on mobile device
         | 
| 6 | 
            -
                def mobile_device?
         | 
| 7 | 
            -
                   | 
| 8 | 
            -
                  return $driver if $driver && $driver.is_a?(Appium::Driver)
         | 
| 6 | 
            +
                def mobile_device?(driver)
         | 
| 7 | 
            +
                  defined?(Appium::Driver) && driver.respond_to?(:appium_driver) && driver.appium_driver
         | 
| 9 8 | 
             
                end
         | 
| 10 9 |  | 
| 11 10 | 
             
                # true if test is running on Android device
         | 
| 12 11 | 
             
                def android?(driver)
         | 
| 13 | 
            -
                  driver.respond_to?(: | 
| 12 | 
            +
                  driver.respond_to?(:device_is_android?) && driver.device_is_android?
         | 
| 14 13 | 
             
                end
         | 
| 15 14 |  | 
| 16 15 | 
             
                # true if test is running on iOS device
         | 
| 17 16 | 
             
                def ios?(driver)
         | 
| 18 | 
            -
                  driver.respond_to?(: | 
| 17 | 
            +
                  driver.respond_to?(:device_is_ios?) && driver.device_is_ios?
         | 
| 19 18 | 
             
                end
         | 
| 20 19 |  | 
| 21 20 | 
             
                # @param [Applitools::Selenium::Driver] driver
         | 
| @@ -23,17 +22,14 @@ module Applitools::Appium | |
| 23 22 | 
             
                  driver.respond_to?(:caps) && driver.caps[:platformVersion]
         | 
| 24 23 | 
             
                end
         | 
| 25 24 |  | 
| 26 | 
            -
                #  | 
| 27 | 
            -
                 | 
| 28 | 
            -
             | 
| 29 | 
            -
             | 
| 30 | 
            -
             | 
| 31 | 
            -
             | 
| 32 | 
            -
             | 
| 33 | 
            -
                 | 
| 34 | 
            -
                #   end
         | 
| 35 | 
            -
                #   result
         | 
| 36 | 
            -
                # end
         | 
| 25 | 
            +
                # @param [Applitools::Selenium::Driver] executor
         | 
| 26 | 
            +
                def device_pixel_ratio(executor)
         | 
| 27 | 
            +
                  if executor.respond_to? :session_capabilities
         | 
| 28 | 
            +
                    session_info = executor.session_capabilities
         | 
| 29 | 
            +
                    return session_info['pixelRatio'].to_f if session_info['pixelRatio']
         | 
| 30 | 
            +
                  end
         | 
| 31 | 
            +
                  Applitools::Selenium::Eyes::UNKNOWN_DEVICE_PIXEL_RATIO
         | 
| 32 | 
            +
                end
         | 
| 37 33 |  | 
| 38 34 | 
             
                def current_scroll_position(driver)
         | 
| 39 35 | 
             
                  super
         | 
| @@ -34,6 +34,12 @@ module Applitools | |
| 34 34 | 
             
                    " instance of #{klass}, but got #{param.class.name} instead"
         | 
| 35 35 | 
             
                end
         | 
| 36 36 |  | 
| 37 | 
            +
                def one_of?(param, param_name, klasses)
         | 
| 38 | 
            +
                  return true if klasses.detect { |a| param.is_a? a }
         | 
| 39 | 
            +
                  raise Applitools::EyesIllegalArgument.new "Expected #{param_name} to be" \
         | 
| 40 | 
            +
                    " instance of one of this classes: [#{klass}], but got #{param.class.name} instead"
         | 
| 41 | 
            +
                end
         | 
| 42 | 
            +
             | 
| 37 43 | 
             
                def raise_argument_error(error)
         | 
| 38 44 | 
             
                  raise Applitools::EyesIllegalArgument.new error
         | 
| 39 45 | 
             
                end
         | 
    
        data/lib/applitools/version.rb
    CHANGED
    
    
    
        metadata
    CHANGED
    
    | @@ -1,14 +1,14 @@ | |
| 1 1 | 
             
            --- !ruby/object:Gem::Specification
         | 
| 2 2 | 
             
            name: eyes_core
         | 
| 3 3 | 
             
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            -
              version: 3.14. | 
| 4 | 
            +
              version: 3.14.6
         | 
| 5 5 | 
             
            platform: ruby
         | 
| 6 6 | 
             
            authors:
         | 
| 7 7 | 
             
            - Applitools Team
         | 
| 8 8 | 
             
            autorequire: 
         | 
| 9 9 | 
             
            bindir: bin
         | 
| 10 10 | 
             
            cert_chain: []
         | 
| 11 | 
            -
            date: 2019-02- | 
| 11 | 
            +
            date: 2019-02-28 00:00:00.000000000 Z
         | 
| 12 12 | 
             
            dependencies:
         | 
| 13 13 | 
             
            - !ruby/object:Gem::Dependency
         | 
| 14 14 | 
             
              name: oily_png
         | 
| @@ -134,9 +134,13 @@ files: | |
| 134 134 | 
             
            - ext/eyes_core/extconf.rb
         | 
| 135 135 | 
             
            - ext/eyes_core/eyes_core.c
         | 
| 136 136 | 
             
            - ext/eyes_core/eyes_core.h
         | 
| 137 | 
            +
            - lib/applitools/appium/driver.rb
         | 
| 137 138 | 
             
            - lib/applitools/appium/eyes.rb
         | 
| 138 139 | 
             
            - lib/applitools/appium/initialize_1.9.rb
         | 
| 139 140 | 
             
            - lib/applitools/appium/initialize_2.0.rb
         | 
| 141 | 
            +
            - lib/applitools/appium/region_provider.rb
         | 
| 142 | 
            +
            - lib/applitools/appium/screenshot.rb
         | 
| 143 | 
            +
            - lib/applitools/appium/target.rb
         | 
| 140 144 | 
             
            - lib/applitools/appium/utils.rb
         | 
| 141 145 | 
             
            - lib/applitools/calabash/calabash_element.rb
         | 
| 142 146 | 
             
            - lib/applitools/calabash/calabash_screenshot_provider.rb
         |