Class: Applitools::Calabash::AndroidScreenshotProvider

Inherits:
CalabashScreenshotProvider show all
Includes:
Singleton
Defined in:
lib/applitools/calabash/calabash_screenshot_provider.rb

Constant Summary

Constants inherited from CalabashScreenshotProvider

CalabashScreenshotProvider::WAIT_BEFORE_SCREENSHOT

Instance Attribute Summary

Attributes inherited from CalabashScreenshotProvider

#context, #debug_screenshot_provider, #density

Instance Method Summary collapse

Methods inherited from CalabashScreenshotProvider

#initialize, #using_context, #with_debug_screenshot_provider, #with_density

Constructor Details

This class inherits a constructor from Applitools::Calabash::CalabashScreenshotProvider

Instance Method Details

#capture_screenshot(options = {}) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# File 'lib/applitools/calabash/calabash_screenshot_provider.rb', line 44

def capture_screenshot(options = {})
  sleep WAIT_BEFORE_SCREENSHOT
  result = nil
  Applitools::Calabash::Utils.using_screenshot(context) do |screenshot_path|
    screenshot = ::ChunkyPNG::Image.from_file(screenshot_path)
    save_debug_screenshot(screenshot, ['original', options[:debug_suffix]])
    viewport_size = Applitools::Calabash::EyesSettings.instance.viewport_size
    screenshot.crop!(0, 0, viewport_size[:width], viewport_size[:height])
    save_debug_screenshot(screenshot, ['cropped', options[:debug_suffix]])
    result = Applitools::Calabash::EyesCalabashAndroidScreenshot.new(
      Applitools::Screenshot.from_image(
        screenshot
      ),
      density: density
    )
  end
  result
end