Class: Applitools::Calabash::EyesCalabashAndroidScreenshot

Inherits:
EyesCalabashScreenshot show all
Defined in:
lib/applitools/calabash/eyes_calabash_android_screenshot.rb

Constant Summary collapse

ANDROID_DENSITY =
{
  120 => 0.75,
  160 => 1,
  213 => 1.33,
  240 => 1.5,
  320 => 2,
  480 => 3
}.freeze

Constants inherited from EyesCalabashScreenshot

Applitools::Calabash::EyesCalabashScreenshot::CONTEXT_RELATIVE, Applitools::Calabash::EyesCalabashScreenshot::DRIVER, Applitools::Calabash::EyesCalabashScreenshot::SCREENSHOT_AS_IS

Constants inherited from EyesScreenshot

EyesScreenshot::COORDINATE_TYPES

Instance Attribute Summary

Attributes inherited from EyesCalabashScreenshot

#scale_factor

Attributes inherited from EyesScreenshot

#image

Instance Method Summary collapse

Methods inherited from EyesCalabashScreenshot

#convert_location, #intersected_region, #location_in_screenshot, #scale_it!, #sub_screenshot

Methods inherited from EyesScreenshot

#sub_screenshots

Methods included from Helpers

#abstract_attr_accessor, #abstract_method

Constructor Details

#initialize(*args) ⇒ EyesCalabashAndroidScreenshot

Returns a new instance of EyesCalabashAndroidScreenshot.



14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/applitools/calabash/eyes_calabash_android_screenshot.rb', line 14

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

Instance Method Details

#convert_region_location(region, from, to) ⇒ Object



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# File 'lib/applitools/calabash/eyes_calabash_android_screenshot.rb', line 27

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) ⇒ Object

Raises:

  • (Applitools::EyesIllegalArgument)


50
51
52
53
# File 'lib/applitools/calabash/eyes_calabash_android_screenshot.rb', line 50

def density=(value)
  raise Applitools::EyesIllegalArgument, "Unknown density = #{value}" unless ANDROID_DENSITY[value.to_i]
  @scale_factor = ANDROID_DENSITY[value.to_i]
end