class Applitools::Calabash::FullPageCaptureAlgorithm::AndroidScrollView
Public Class Methods
new(*args)
click to toggle source
Calls superclass method
# File lib/applitools/calabash/full_page_capture_algorithm/android_scroll_view.rb, line 16 def initialize(*args) super @entire_content = nil @stitched_image = nil @original_position = nil end
Public Instance Methods
get_stitched_region(scroll_to_top = true)
click to toggle source
# File lib/applitools/calabash/full_page_capture_algorithm/android_scroll_view.rb, line 23 def get_stitched_region(scroll_to_top = true) create_entire_image store_original_position scroll_top if scroll_to_top scroll_it! do |scrollable_element| put_it_on_canvas!( screenshot_provider.capture_screenshot.sub_screenshot( eyes_window, Applitools::Calabash::EyesCalabashScreenshot::DRIVER, false, false ).image.image, element.location.offset_negative(scrollable_element.location) ) end restore_original_position calabash_android_screenshot( Applitools::Screenshot.from_image(stitched_image), screenshot_provider.density ) end
Private Instance Methods
entire_size()
click to toggle source
# File lib/applitools/calabash/full_page_capture_algorithm/android_scroll_view.rb, line 85 def entire_size entire_content.size end
eyes_window()
click to toggle source
# File lib/applitools/calabash/full_page_capture_algorithm/android_scroll_view.rb, line 89 def eyes_window @eyes_window ||= Applitools::Region.from_location_size(element.location, element.size) end
restore_original_position()
click to toggle source
# File lib/applitools/calabash/full_page_capture_algorithm/android_scroll_view.rb, line 66 def restore_original_position return unless @original_position offset = @original_position.offset_negative(scrollable_element.location) context.query(element.element_query, scrollBy: [-offset.x, -offset.y]) @original_position = nil end
scroll_it!() { |scrollable| ... }
click to toggle source
# File lib/applitools/calabash/full_page_capture_algorithm/android_scroll_view.rb, line 73 def scroll_it! scroll_vertical = true loop do scrollable = scrollable_element if scroll_vertical vertical_offset = element.location.offset_negative(scrollable.location).top scroll_vertical = false if vertical_offset + 1 >= scrollable.height - element.height yield(scrollable) if block_given? context.query(element.element_query, scrollBy: [0, element.height]) if scroll_vertical return unless scroll_vertical end end
scroll_top()
click to toggle source
# File lib/applitools/calabash/full_page_capture_algorithm/android_scroll_view.rb, line 55 def scroll_top logger.info 'Scrolling up...' context.query(element.element_query, scrollTo: [0, 0]) logger.info 'Done!' end
scrollable_element()
click to toggle source
# File lib/applitools/calabash/full_page_capture_algorithm/android_scroll_view.rb, line 50 def scrollable_element child_query = "#{element.element_query} child * index:0" Applitools::Calabash::Utils.get_android_element(context, child_query, 0) end
store_original_position()
click to toggle source
# File lib/applitools/calabash/full_page_capture_algorithm/android_scroll_view.rb, line 61 def store_original_position current_scrollable_element = scrollable_element @original_position = Applitools::Location.new(current_scrollable_element.left, current_scrollable_element.top) end