eyes_core 4.6.3 → 6.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +504 -0
  3. data/Rakefile +35 -0
  4. data/eyes_core.gemspec +60 -0
  5. data/lib/applitools/core/batch_info.rb +2 -0
  6. data/lib/applitools/core/classic_runner.rb +1 -3
  7. data/lib/applitools/core/eyes_base.rb +110 -22
  8. data/lib/applitools/core/eyes_base_configuration.rb +9 -1
  9. data/lib/applitools/core/eyes_runner.rb +3 -2
  10. data/lib/applitools/core/test_result_summary.rb +7 -7
  11. data/lib/applitools/core/test_results.rb +19 -3
  12. data/lib/applitools/core/universal_eyes_checks.rb +2 -1
  13. data/lib/applitools/core/universal_eyes_open.rb +5 -1
  14. data/lib/applitools/eyes_core/version.rb +10 -0
  15. data/lib/applitools/universal_sdk/universal_client.rb +26 -10
  16. data/lib/applitools/universal_sdk/universal_eyes.rb +5 -0
  17. data/lib/applitools/universal_sdk/universal_eyes_config.rb +10 -9
  18. data/lib/applitools/universal_sdk/universal_eyes_manager.rb +1 -1
  19. data/lib/eyes_core.rb +1 -3
  20. metadata +14 -58
  21. data/ext/eyes_core/extconf.rb +0 -5
  22. data/ext/eyes_core/eyes_core.c +0 -252
  23. data/ext/eyes_core/eyes_core.h +0 -28
  24. data/lib/applitools/appium/android_region_provider.rb +0 -32
  25. data/lib/applitools/appium/android_screenshot.rb +0 -21
  26. data/lib/applitools/appium/driver.rb +0 -12
  27. data/lib/applitools/appium/eyes.rb +0 -189
  28. data/lib/applitools/appium/ios_region_provider.rb +0 -25
  29. data/lib/applitools/appium/ios_screenshot.rb +0 -10
  30. data/lib/applitools/appium/region_provider.rb +0 -51
  31. data/lib/applitools/appium/screenshot.rb +0 -30
  32. data/lib/applitools/appium/target.rb +0 -240
  33. data/lib/applitools/appium/utils.rb +0 -64
  34. data/lib/applitools/calabash/calabash_element.rb +0 -64
  35. data/lib/applitools/calabash/calabash_screenshot_provider.rb +0 -83
  36. data/lib/applitools/calabash/environment_detector.rb +0 -25
  37. data/lib/applitools/calabash/eyes.rb +0 -194
  38. data/lib/applitools/calabash/eyes_calabash_android_screenshot.rb +0 -68
  39. data/lib/applitools/calabash/eyes_calabash_ios_screenshot.rb +0 -30
  40. data/lib/applitools/calabash/eyes_calabash_screenshot.rb +0 -80
  41. data/lib/applitools/calabash/eyes_hooks.rb +0 -51
  42. data/lib/applitools/calabash/eyes_settings.rb +0 -45
  43. data/lib/applitools/calabash/full_page_capture_algorithm/android_scroll_view.rb +0 -95
  44. data/lib/applitools/calabash/full_page_capture_algorithm/base.rb +0 -51
  45. data/lib/applitools/calabash/full_page_capture_algorithm/ios_ui_table_view.rb +0 -150
  46. data/lib/applitools/calabash/full_page_capture_algorithm.rb +0 -26
  47. data/lib/applitools/calabash/os_versions.rb +0 -25
  48. data/lib/applitools/calabash/rspec_matchers.rb +0 -25
  49. data/lib/applitools/calabash/steps/android_eyes_session.rb +0 -37
  50. data/lib/applitools/calabash/steps/android_matchers.rb +0 -36
  51. data/lib/applitools/calabash/steps/eyes_session.rb +0 -42
  52. data/lib/applitools/calabash/steps/eyes_settings.rb +0 -59
  53. data/lib/applitools/calabash/steps/ios_eyes_session.rb +0 -15
  54. data/lib/applitools/calabash/steps/ios_matchers.rb +0 -17
  55. data/lib/applitools/calabash/steps/matchers.rb +0 -71
  56. data/lib/applitools/calabash/target.rb +0 -69
  57. data/lib/applitools/calabash/utils.rb +0 -74
  58. data/lib/applitools/calabash_steps.rb +0 -16
  59. data/lib/applitools/capybara/capybara_settings.rb +0 -25
  60. data/lib/applitools/capybara/driver.rb +0 -39
  61. data/lib/applitools/rspec/target_matcher.rb +0 -25
  62. data/lib/applitools/universal_sdk/executable_finder.rb +0 -57
  63. data/lib/applitools/universal_sdk/universal_server_control.rb +0 -79
  64. data/lib/applitools/version.rb +0 -8
  65. data/lib/eyes_consts.rb +0 -4
  66. data/lib/eyes_rspec.rb +0 -4
@@ -1,194 +0,0 @@
1
- # frozen_string_literal: false
2
-
3
- module Applitools
4
- module Calabash
5
- class Eyes < Applitools::EyesBase
6
- attr_accessor :device_pixel_ratio, :full_page_capture_algorithm, :base_agent_id, :title,
7
- :debug_screenshots, :debug_screenshot_provider, :tag_for_debug
8
- attr_reader :context
9
-
10
- def initialize(server_url = Applitools::Connectivity::ServerConnector::DEFAULT_SERVER_URL)
11
- super
12
- self.runner = Applitools::ClassicRunner.new
13
- self.base_agent_id = "eyes.calabash.ruby/#{Applitools::VERSION}".freeze
14
- self.debug_screenshots = false
15
- self.debug_screenshot_provider = Applitools::DebugScreenshotProvider.new
16
- .tag_access { tag_for_debug }
17
- .debug_flag_access { debug_screenshots }
18
- end
19
-
20
- def open(options = {})
21
- Applitools::ArgumentGuard.hash options, 'open(options)', [:app_name, :test_name]
22
- open_base options
23
- end
24
-
25
- def check(*args)
26
- args.compact!
27
- case (first_arg = args.shift)
28
- when String
29
- name = first_arg
30
- target = args.shift
31
- when Applitools::Selenium::Target
32
- target = first_arg
33
- when Hash
34
- target = first_arg[:target]
35
- name = first_arg[:name] || first_arg[:tag]
36
- end
37
-
38
- self.tag_for_debug = get_tag_for_debug(name)
39
- check_it(name, target, Applitools::MatchWindowData.new(default_match_settings))
40
- end
41
-
42
- def inferred_environment
43
- return @inferred_environment unless @inferred_environment.nil?
44
- return unless device_pixel_ratio
45
- "device pixel ratio: #{device_pixel_ratio}"
46
- end
47
-
48
- def add_context(value)
49
- @context = value
50
- end
51
-
52
- def remove_context
53
- @context = nil
54
- end
55
-
56
- def capture_screenshot
57
- return screenshot_provider.capture_screenshot(debug_suffix: tag_for_debug) unless full_page_capture_algorithm
58
- full_page_capture_algorithm.get_stitched_region
59
- end
60
-
61
- def screenshot_provider
62
- env = Applitools::Calabash::EnvironmentDetector.current_environment
63
- case env
64
- when :android
65
- Applitools::Calabash::AndroidScreenshotProvider.instance.with_density(device_pixel_ratio)
66
- .using_context(context)
67
- .with_debug_screenshot_provider(debug_screenshot_provider)
68
- when :ios
69
- Applitools::Calabash::IosScreenshotProvider.instance.with_density(device_pixel_ratio)
70
- .using_context(context)
71
- .with_debug_screenshot_provider(debug_screenshot_provider)
72
- end
73
- end
74
-
75
- def check_it(name, target, match_window_data)
76
- Applitools::ArgumentGuard.not_nil(name, 'name')
77
-
78
- logger.info 'Full element requested' if target.options[:stitch_content]
79
-
80
- self.full_page_capture_algorithm = target.options[:stitch_content] &&
81
- get_full_page_capture_algorithm(target.region_to_check)
82
-
83
- region_provider = if full_page_capture_algorithm
84
- entire_screenshot_region
85
- else
86
- get_region_provider(target)
87
- end
88
-
89
- match_window_data.tag = name
90
- match_window_data.read_target(target, nil)
91
-
92
- self.viewport_size = Applitools::Calabash::EyesSettings.instance.viewport_size if viewport_size.nil?
93
-
94
- if match_window_data.is_a? Applitools::MatchSingleCheckData
95
- return check_single_base(
96
- region_provider,
97
- target.options[:timeout] || Applitools::EyesBase::USE_DEFAULT_TIMEOUT,
98
- match_window_data
99
- )
100
- end
101
-
102
- check_window_base(
103
- region_provider,
104
- target.options[:timeout] || Applitools::EyesBase::USE_DEFAULT_TIMEOUT,
105
- match_window_data
106
- )
107
- end
108
-
109
- def get_region_provider(target)
110
- if (region_to_check = target.region_to_check).nil?
111
- entire_screenshot_region
112
- else
113
- region_for_element(region_to_check)
114
- end
115
- end
116
-
117
- def get_app_output_with_screenshot(*args)
118
- result = super(*args, &:scale_it!)
119
- self.screenshot_url = nil
120
- result
121
- end
122
-
123
- def entire_screenshot_region
124
- Object.new.tap do |prov|
125
- prov.instance_eval do
126
- define_singleton_method :region do
127
- Applitools::Region::EMPTY
128
- end
129
-
130
- define_singleton_method :coordinate_type do
131
- nil
132
- end
133
- end
134
- end
135
- end
136
-
137
- def region_for_element(region_to_check)
138
- Object.new.tap do |prov|
139
- prov.instance_eval do
140
- define_singleton_method :region do
141
- case region_to_check
142
- when Applitools::Calabash::CalabashElement
143
- region_to_check.region
144
- when Applitools::Region
145
- region_to_check
146
- else
147
- raise Applitools::EyesError, "Incompatible region type: #{region_to_check.class}"
148
- end
149
- # region_to_check.respond_to?(:region) ? region_to_check.region : region_to_check
150
- end
151
- define_singleton_method :coordinate_type do
152
- Applitools::Calabash::EyesCalabashScreenshot::DRIVER
153
- end
154
- end
155
- end
156
- end
157
-
158
- def vp_size
159
- viewport_size
160
- end
161
-
162
- def vp_size=(value, skip_check_if_open = false)
163
- unless skip_check_if_open || open?
164
- raise Applitools::EyesNotOpenException.new 'set_viewport_size: Eyes not open!'
165
- end
166
- Applitools::ArgumentGuard.not_nil 'value', value
167
- @viewport_size = Applitools::RectangleSize.for value
168
- end
169
-
170
- alias get_viewport_size vp_size
171
- alias set_viewport_size vp_size=
172
-
173
- def get_full_page_capture_algorithm(element)
174
- logger.info "Trying to get full page capture algorithm for element #{element}..."
175
- environment = Applitools::Calabash::EnvironmentDetector.current_environment
176
- element_class = Applitools::Calabash::Utils.send("grub_#{environment}_class_name", context, element).first
177
- logger.info "Trying to get FullPageCaptureAlgorithm for #{element_class}..."
178
- algo = Applitools::Calabash::FullPageCaptureAlgorithm.get_algorithm_class(environment, element_class)
179
- if algo
180
- logger.info "Using #{algo}"
181
- algo = algo.new(screenshot_provider, element, debug_screenshot_provider: debug_screenshot_provider)
182
- else
183
- logger.info "FullPageCaptureAlgorithm for #{element_class} not found. Continue with :check_region instead"
184
- end
185
- algo
186
- end
187
-
188
- def get_tag_for_debug(name)
189
- return "#{app_name} #{test_name}" if name.empty?
190
- "#{app_name} #{test_name} - #{name}"
191
- end
192
- end
193
- end
194
- end
@@ -1,68 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'eyes_calabash_screenshot'
4
- module Applitools
5
- module Calabash
6
- class EyesCalabashAndroidScreenshot < ::Applitools::Calabash::EyesCalabashScreenshot
7
- extend Forwardable
8
- def_delegators 'Applitools::EyesLogger', :logger
9
-
10
- ANDROID_DENSITY = {
11
- 120 => 0.75,
12
- 160 => 1,
13
- 213 => 1.33,
14
- 240 => 1.5,
15
- 320 => 2,
16
- 480 => 3,
17
- 560 => 3.5,
18
- 640 => 4
19
- }.freeze
20
-
21
- DENSITY_DEFAULT = 160
22
-
23
- class UnknownDeviceDensity < ::Applitools::EyesError; end
24
-
25
- def initialize(*args)
26
- options = if args.last.is_a? Hash
27
- args.pop
28
- else
29
- {}
30
- end
31
- super(*args)
32
- @scale_factor = nil
33
- self.density = options[:density] if options[:density]
34
- @scale_factor ||= options[:scale_factor]
35
- @scale_factor = 1 unless @scale_factor
36
- end
37
-
38
- def convert_region_location(region, from, to)
39
- case from
40
- when DRIVER
41
- case to
42
- when SCREENSHOT_AS_IS
43
- region
44
- else
45
- raise Applitools::EyesError, "from: #{from}, to: #{to}"
46
- end
47
- when CONTEXT_RELATIVE
48
- case to
49
- when SCREENSHOT_AS_IS
50
- region.scale_it!(1.to_f / scale_factor) # !!!!!!
51
- region
52
- else
53
- raise Applitools::EyesError, "from: #{from}, to: #{to}"
54
- end
55
- else
56
- raise Applitools::EyesError, "from: #{from}, to: #{to}"
57
- end
58
- region
59
- end
60
-
61
- def density=(value)
62
- logger.warn("Trying to set unknown device density - #{value}") unless
63
- ANDROID_DENSITY.keys.include?(value.to_i)
64
- @scale_factor = value.to_f / DENSITY_DEFAULT
65
- end
66
- end
67
- end
68
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'eyes_calabash_screenshot'
4
- module Applitools
5
- module Calabash
6
- class EyesCalabashIosScreenshot < Applitools::Calabash::EyesCalabashScreenshot
7
- def convert_region_location(region, from, to)
8
- case from
9
- when DRIVER
10
- case to
11
- when SCREENSHOT_AS_IS
12
- region.scale_it!(scale_factor)
13
- else
14
- raise Applitools::EyesError, "from: #{from}, to: #{to}"
15
- end
16
- when CONTEXT_RELATIVE
17
- case to
18
- when SCREENSHOT_AS_IS
19
- region
20
- else
21
- raise Applitools::EyesError, "from: #{from}, to: #{to}"
22
- end
23
- else
24
- raise Applitools::EyesError, "from: #{from}, to: #{to}"
25
- end
26
- region
27
- end
28
- end
29
- end
30
- end
@@ -1,80 +0,0 @@
1
- # frozen_string_literal: false
2
-
3
- module Applitools
4
- module Calabash
5
- class EyesCalabashScreenshot < Applitools::EyesScreenshot
6
- SCREENSHOT_AS_IS = Applitools::EyesScreenshot::COORDINATE_TYPES[:screenshot_as_is].freeze
7
- CONTEXT_RELATIVE = Applitools::EyesScreenshot::COORDINATE_TYPES[:context_relative].freeze
8
- DRIVER = 'DRIVER'.freeze
9
-
10
- attr_reader :scale_factor
11
-
12
- def initialize(image, options = {})
13
- super image
14
- @scale_factor = options[:scale_factor] || 1
15
- # return if (location = options[:location]).nil?
16
- # Applitools::ArgumentGuard.is_a? location, 'options[:location]', Applitools::Location
17
- # @bounds = Applitools::Region.new location.x, location.y, image.width, image.height
18
- end
19
-
20
- def sub_screenshot(region, coordinates_type, throw_if_clipped = false, force_nil_if_clipped = false)
21
- Applitools::ArgumentGuard.not_nil region, 'region'
22
- Applitools::ArgumentGuard.not_nil coordinates_type, 'coordinates_type'
23
-
24
- sub_screen_region = intersected_region region, coordinates_type, SCREENSHOT_AS_IS
25
-
26
- if sub_screen_region.empty? || (throw_if_clipped && !region.size_equals?(sub_screen_region))
27
- return nil if force_nil_if_clipped
28
- raise Applitools::OutOfBoundsException, "Region #{sub_screen_region} (#{coordinates_type}) is out of " \
29
- " screenshot bounds #{bounds}"
30
- end
31
-
32
- sub_screenshot_image = Applitools::Screenshot.from_any_image(
33
- image.crop(
34
- sub_screen_region.left, sub_screen_region.top, sub_screen_region.width, sub_screen_region.height
35
- ).to_datastream.to_blob
36
- )
37
-
38
- self.class.new sub_screenshot_image, scale_factor: scale_factor
39
- end
40
-
41
- def location_in_screenshot(_location, _coordinates_type)
42
- raise(
43
- Applitools::EyesError,
44
- 'Call to :convert_location is prohibited for Applitools::Calabash::EyesCalabashScreenshot'
45
- )
46
- end
47
-
48
- def intersected_region(region, from, to = CONTEXT_RELATIVE)
49
- Applitools::ArgumentGuard.not_nil region, 'region'
50
- Applitools::ArgumentGuard.not_nil from, 'coordinates Type (from)'
51
- return Applitools::Region.new(0, 0, 0, 0) if region.empty?
52
- intersected_region = convert_region_location region, from, to
53
- intersected_region.intersect bounds
54
- intersected_region
55
- end
56
-
57
- def convert_location(_location, _from, _to)
58
- raise(
59
- Applitools::EyesError,
60
- 'Call to :convert_location is prohibited for Applitools::Calabash::EyesCalabashScreenshot'
61
- )
62
- end
63
-
64
- abstract_method :convert_region_location, false
65
-
66
- def scale_it!
67
- width = (image.width.to_f / scale_factor).to_i
68
- height = (image.height.to_f / scale_factor).to_i
69
- image.resample_bicubic!(width, height)
70
- self
71
- end
72
-
73
- private
74
-
75
- def bounds
76
- @bounds ||= Applitools::Region.new(0, 0, image.width, image.height)
77
- end
78
- end
79
- end
80
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- if respond_to?(:Before)
4
- Before('@eyes') do |scenario|
5
- get_scenario_tags(scenario)
6
- before_feature(scenario) if scenario.feature.children.first == scenario.source.last
7
- end
8
-
9
- Before('@eyes') do |scenario|
10
- Applitools::Calabash::EyesSettings.instance.eyes.add_context(self)
11
- step %(eyes test name is "#{@eyes_current_tags[:test_name] || scenario.name}")
12
- step %(open eyes)
13
- end
14
- end
15
-
16
- if respond_to?(:After)
17
- After('@eyes') do |scenario|
18
- after_feature(scenario) if scenario.feature.children.last == scenario.source.last
19
- end
20
-
21
- After('@eyes') do |_scenario|
22
- eyes = Applitools::Calabash::EyesSettings.instance.eyes
23
- Applitools::Calabash::EyesSettings.instance.eyes.remove_context if eyes && eyes.open?
24
- step %(terminate eyes session) if eyes && eyes.running_session?
25
- end
26
- end
27
-
28
- def before_feature(scenario)
29
- @before_hook_scenario = scenario
30
- eyes_settings = Applitools::Calabash::EyesSettings.instance
31
-
32
- step %(eyes API key "#{@eyes_current_tags[:api_key] || ENV['APPLITOOLS_API_KEY']}") unless
33
- eyes_settings.applitools_api_key
34
-
35
- step %(eyes application name is "#{@eyes_current_tags[:app_name] || scenario.feature.name}")
36
-
37
- step %(set it up) if eyes_settings.needs_setting_up
38
-
39
- step %(create eyes)
40
- end
41
-
42
- def after_feature(_scenario) end
43
-
44
- def get_scenario_tags(scenario)
45
- @eyes_current_tags = {}
46
- eyes_tag_name_regexp = /@eyes_(?<tag_name>[a-z,A-Z, \_]+) \"(?<value>.*)\"/
47
- scenario.tags.each do |t|
48
- match_data = t.name.match eyes_tag_name_regexp
49
- @eyes_current_tags[match_data[:tag_name].to_sym] = match_data[:value] if match_data
50
- end
51
- end
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'singleton'
4
- require 'securerandom'
5
- module Applitools
6
- module Calabash
7
- class EyesSettings
8
- attr_accessor :eyes, :applitools_api_key, :app_name, :test_name, :viewport_size
9
- attr_accessor :tmp_dir, :screenshot_dir, :log_dir, :log_file
10
- attr_accessor :needs_setting_up
11
-
12
- include Singleton
13
-
14
- def initialize
15
- @tmp_dir = 'tmp'
16
- @screenshot_dir = 'screenshots'
17
- @log_dir = 'logs'
18
- @log_file = 'applitools.log'
19
- @needs_setting_up = true
20
- end
21
-
22
- def options_for_open
23
- result = { app_name: app_name, test_name: test_name }
24
- return result unless viewport_size
25
- result.merge!(viewport_size: viewport_size)
26
- end
27
-
28
- def screenshot_prefix
29
- File.join(Dir.getwd, tmp_dir, screenshot_dir, '')
30
- end
31
-
32
- def log_prefix
33
- File.join(Dir.getwd, log_dir)
34
- end
35
-
36
- def screenshot_names
37
- @names ||= Enumerator.new do |y|
38
- loop do
39
- y << { prefix: screenshot_prefix, name: "#{SecureRandom.uuid}.png" }
40
- end
41
- end
42
- end
43
- end
44
- end
45
- end
@@ -1,95 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'base'
4
- module Applitools
5
- module Calabash
6
- module FullPageCaptureAlgorithm
7
- module CalabashAndroidScreenshot
8
- def calabash_android_screenshot(screenshot, density)
9
- Applitools::Calabash::EyesCalabashAndroidScreenshot.new(
10
- screenshot, density: density
11
- )
12
- end
13
- end
14
- class AndroidScrollView < Base
15
- include CalabashAndroidScreenshot
16
- def initialize(*args)
17
- super
18
- @entire_content = nil
19
- @stitched_image = nil
20
- @original_position = nil
21
- end
22
-
23
- def get_stitched_region(scroll_to_top = true)
24
- create_entire_image
25
- store_original_position
26
- scroll_top if scroll_to_top
27
-
28
- scroll_it! do |scrollable_element|
29
- put_it_on_canvas!(
30
- screenshot_provider.capture_screenshot.sub_screenshot(
31
- eyes_window,
32
- Applitools::Calabash::EyesCalabashScreenshot::DRIVER,
33
- false,
34
- false
35
- ).image.image,
36
- element.location.offset_negative(scrollable_element.location)
37
- )
38
- end
39
-
40
- restore_original_position
41
-
42
- calabash_android_screenshot(
43
- Applitools::Screenshot.from_image(stitched_image),
44
- screenshot_provider.density
45
- )
46
- end
47
-
48
- private
49
-
50
- def scrollable_element
51
- child_query = "#{element.element_query} child * index:0"
52
- Applitools::Calabash::Utils.get_android_element(context, child_query, 0)
53
- end
54
-
55
- def scroll_top
56
- logger.info 'Scrolling up...'
57
- context.query(element.element_query, scrollTo: [0, 0])
58
- logger.info 'Done!'
59
- end
60
-
61
- def store_original_position
62
- current_scrollable_element = scrollable_element
63
- @original_position = Applitools::Location.new(current_scrollable_element.left, current_scrollable_element.top)
64
- end
65
-
66
- def restore_original_position
67
- return unless @original_position
68
- offset = @original_position.offset_negative(scrollable_element.location)
69
- context.query(element.element_query, scrollBy: [-offset.x, -offset.y])
70
- @original_position = nil
71
- end
72
-
73
- def scroll_it!
74
- scroll_vertical = true
75
- loop do
76
- scrollable = scrollable_element if scroll_vertical
77
- vertical_offset = element.location.offset_negative(scrollable.location).top
78
- scroll_vertical = false if vertical_offset + 1 >= scrollable.height - element.height
79
- yield(scrollable) if block_given?
80
- context.query(element.element_query, scrollBy: [0, element.height]) if scroll_vertical
81
- return unless scroll_vertical
82
- end
83
- end
84
-
85
- def entire_size
86
- entire_content.size
87
- end
88
-
89
- def eyes_window
90
- @eyes_window ||= Applitools::Region.from_location_size(element.location, element.size)
91
- end
92
- end
93
- end
94
- end
95
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Applitools
4
- module Calabash
5
- module FullPageCaptureAlgorithm
6
- class Base
7
- extend Applitools::Helpers
8
- extend Forwardable
9
- def_delegators 'Applitools::EyesLogger', :logger, :log_handler, :log_handler=
10
-
11
- attr_reader :context, :element, :screenshot_provider, :stitched_image, :debug_screenshot_provider
12
-
13
- DEFAULT_SLEEP_INTERVAL = 1
14
-
15
- def initialize(screenshot_provider, element, options = {})
16
- Applitools::ArgumentGuard.is_a?(element, 'element', Applitools::Calabash::CalabashElement)
17
- @screenshot_provider = screenshot_provider
18
- @element = element
19
- @context = screenshot_provider.context
20
- return unless options[:debug_screenshot_provider]
21
- Applitools::ArgumentGuard.is_a?(
22
- options[:debug_screenshot_provider],
23
- 'options[:debug_screenshot_provider]',
24
- Applitools::DebugScreenshotProvider
25
- )
26
- @debug_screenshot_provider = options[:debug_screenshot_provider]
27
- end
28
-
29
- private
30
-
31
- def create_entire_image
32
- current_entire_size = entire_size
33
- # @stitched_image = ::ChunkyPNG::Image.new(current_entire_size.width, current_entire_size.height)
34
- end
35
-
36
- def entire_content
37
- @entire_content ||= scrollable_element
38
- end
39
-
40
- abstract_method(:entire_size, true)
41
- abstract_method(:scrollable_element, true)
42
- abstract_method(:eyes_window, true)
43
-
44
- def put_it_on_canvas!(image, offset)
45
- debug_screenshot_provider.save(image, "#{offset.x} x #{offset.y}") if debug_screenshot_provider
46
- stitched_image.replace!(image, offset.x, offset.y)
47
- end
48
- end
49
- end
50
- end
51
- end