class Applitools::Calabash::EyesCalabashAndroidScreenshot

Constants

ANDROID_DENSITY
DENSITY_DEFAULT

Public Class Methods

new(*args) click to toggle source
# File lib/applitools/calabash/eyes_calabash_android_screenshot.rb, line 25
def initialize(*args)
  options = if args.last.is_a? Hash
              args.pop
            else
              {}
            end
  super(*args)
  @scale_factor = nil
  self.density = options[:density] if options[:density]
  @scale_factor ||= options[:scale_factor]
  @scale_factor = 1 unless @scale_factor
end

Public Instance Methods

convert_region_location(region, from, to) click to toggle source
# File lib/applitools/calabash/eyes_calabash_android_screenshot.rb, line 38
def convert_region_location(region, from, to)
  case from
  when DRIVER
    case to
    when SCREENSHOT_AS_IS
      region
    else
      raise Applitools::EyesError, "from: #{from}, to: #{to}"
    end
  when CONTEXT_RELATIVE
    case to
    when SCREENSHOT_AS_IS
      region.scale_it!(1.to_f / scale_factor) # !!!!!!
      region
    else
      raise Applitools::EyesError, "from: #{from}, to: #{to}"
    end
  else
    raise Applitools::EyesError, "from: #{from}, to: #{to}"
  end
  region
end
density=(value) click to toggle source
# File lib/applitools/calabash/eyes_calabash_android_screenshot.rb, line 61
def density=(value)
  logger.warn("Trying to set unknown device density - #{value}") unless
      ANDROID_DENSITY.keys.include?(value.to_i)
  @scale_factor = value.to_f / DENSITY_DEFAULT
end