eyes_core 5.0.0 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) 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/eyes_base.rb +106 -18
  7. data/lib/applitools/core/eyes_base_configuration.rb +9 -3
  8. data/lib/applitools/core/eyes_runner.rb +3 -2
  9. data/lib/applitools/core/test_results.rb +6 -1
  10. data/lib/applitools/core/universal_eyes_checks.rb +2 -1
  11. data/lib/applitools/core/universal_eyes_open.rb +2 -1
  12. data/lib/applitools/eyes_core/version.rb +10 -0
  13. data/lib/applitools/universal_sdk/universal_client.rb +26 -10
  14. data/lib/applitools/universal_sdk/universal_eyes_config.rb +10 -9
  15. data/lib/eyes_core.rb +1 -3
  16. metadata +14 -58
  17. data/ext/eyes_core/extconf.rb +0 -5
  18. data/ext/eyes_core/eyes_core.c +0 -252
  19. data/ext/eyes_core/eyes_core.h +0 -28
  20. data/lib/applitools/appium/android_region_provider.rb +0 -32
  21. data/lib/applitools/appium/android_screenshot.rb +0 -21
  22. data/lib/applitools/appium/driver.rb +0 -12
  23. data/lib/applitools/appium/eyes.rb +0 -189
  24. data/lib/applitools/appium/ios_region_provider.rb +0 -25
  25. data/lib/applitools/appium/ios_screenshot.rb +0 -10
  26. data/lib/applitools/appium/region_provider.rb +0 -51
  27. data/lib/applitools/appium/screenshot.rb +0 -30
  28. data/lib/applitools/appium/target.rb +0 -240
  29. data/lib/applitools/appium/utils.rb +0 -64
  30. data/lib/applitools/calabash/calabash_element.rb +0 -64
  31. data/lib/applitools/calabash/calabash_screenshot_provider.rb +0 -83
  32. data/lib/applitools/calabash/environment_detector.rb +0 -25
  33. data/lib/applitools/calabash/eyes.rb +0 -194
  34. data/lib/applitools/calabash/eyes_calabash_android_screenshot.rb +0 -68
  35. data/lib/applitools/calabash/eyes_calabash_ios_screenshot.rb +0 -30
  36. data/lib/applitools/calabash/eyes_calabash_screenshot.rb +0 -80
  37. data/lib/applitools/calabash/eyes_hooks.rb +0 -51
  38. data/lib/applitools/calabash/eyes_settings.rb +0 -45
  39. data/lib/applitools/calabash/full_page_capture_algorithm/android_scroll_view.rb +0 -95
  40. data/lib/applitools/calabash/full_page_capture_algorithm/base.rb +0 -51
  41. data/lib/applitools/calabash/full_page_capture_algorithm/ios_ui_table_view.rb +0 -150
  42. data/lib/applitools/calabash/full_page_capture_algorithm.rb +0 -26
  43. data/lib/applitools/calabash/os_versions.rb +0 -25
  44. data/lib/applitools/calabash/rspec_matchers.rb +0 -25
  45. data/lib/applitools/calabash/steps/android_eyes_session.rb +0 -37
  46. data/lib/applitools/calabash/steps/android_matchers.rb +0 -36
  47. data/lib/applitools/calabash/steps/eyes_session.rb +0 -42
  48. data/lib/applitools/calabash/steps/eyes_settings.rb +0 -59
  49. data/lib/applitools/calabash/steps/ios_eyes_session.rb +0 -15
  50. data/lib/applitools/calabash/steps/ios_matchers.rb +0 -17
  51. data/lib/applitools/calabash/steps/matchers.rb +0 -71
  52. data/lib/applitools/calabash/target.rb +0 -69
  53. data/lib/applitools/calabash/utils.rb +0 -74
  54. data/lib/applitools/calabash_steps.rb +0 -16
  55. data/lib/applitools/capybara/capybara_settings.rb +0 -25
  56. data/lib/applitools/capybara/driver.rb +0 -39
  57. data/lib/applitools/rspec/target_matcher.rb +0 -25
  58. data/lib/applitools/universal_sdk/executable_finder.rb +0 -57
  59. data/lib/applitools/universal_sdk/universal_server_control.rb +0 -79
  60. data/lib/applitools/version.rb +0 -8
  61. data/lib/eyes_consts.rb +0 -4
  62. data/lib/eyes_rspec.rb +0 -4
@@ -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
@@ -1,150 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'base'
4
-
5
- module Applitools
6
- module Calabash
7
- module FullPageCaptureAlgorithm
8
- class IosUITableView < Base
9
- NSSIZE = /^.*: {(?<width>\d+), (?<height>\d+)}$/
10
- NEXT_REQUEST_DELAY = 0.5
11
- CROP_SHADOW_BOUNDS = 5
12
-
13
- def initialize(*args)
14
- super
15
- @entire_content = nil
16
- @stitched_image = nil
17
- @original_position = nil
18
- @entire_size = nil
19
- @eyes_window = nil
20
- end
21
-
22
- def get_stitched_region(scroll_to_top = true)
23
- create_entire_image
24
- store_original_position
25
- scroll_left_top if scroll_to_top
26
-
27
- scroll_it! do |position, cut_vertical, cut_horizontal|
28
- current_region = cutted_eyes_window(cut_vertical ? :top : :none)
29
- current_region = cutted_eyes_window(cut_horizontal ? :left : :none, current_region)
30
-
31
- current_position = updated_position(cut_vertical ? :top : :none, position.dup)
32
- current_position = updated_position(cut_horizontal ? :left : :none, current_position)
33
-
34
- put_it_on_canvas!(
35
- screenshot_provider.capture_screenshot.sub_screenshot(
36
- current_region,
37
- Applitools::Calabash::EyesCalabashScreenshot::DRIVER,
38
- false,
39
- false
40
- ).image.image,
41
- current_position.scale_it!(screenshot_provider.density)
42
- )
43
- end
44
-
45
- Applitools::Calabash::EyesCalabashIosScreenshot.new(
46
- Applitools::Screenshot.from_image(stitched_image),
47
- scale_factor: screenshot_provider.density
48
- )
49
- end
50
-
51
- def cutted_eyes_window(side, region = eyes_window)
52
- case side
53
- when :top
54
- Applitools::Region.new(
55
- region.left,
56
- region.top + CROP_SHADOW_BOUNDS,
57
- region.width,
58
- region.height - CROP_SHADOW_BOUNDS
59
- )
60
- when :left
61
- Applitools::Region.new(
62
- region.left + CROP_SHADOW_BOUNDS,
63
- region.top,
64
- region.width - CROP_SHADOW_BOUNDS,
65
- region.height
66
- )
67
- else
68
- region.dup
69
- end
70
- end
71
-
72
- def updated_position(side, position)
73
- case side
74
- when :top
75
- position.offset Applitools::Location.new(0, CROP_SHADOW_BOUNDS)
76
- when :left
77
- position.offset Applitools::Location.new(CROP_SHADOW_BOUNDS, 0)
78
- else
79
- position
80
- end
81
- end
82
-
83
- def scrollable_element
84
- Applitools::Calabash::Utils.get_ios_element(context, element.element_query, 0)
85
- end
86
-
87
- def entire_size
88
- @entire_size ||= query_entire_size
89
- end
90
-
91
- def query_entire_size
92
- result = NSSIZE.match(Applitools::Calabash::Utils.request_element(context, element, :contentSize).first)
93
- Applitools::RectangleSize.new(
94
- result[:width].to_i, result[:height].to_i
95
- ).scale_it!(screenshot_provider.density)
96
- end
97
-
98
- def query_current_position
99
- result = Applitools::Calabash::Utils.request_element(context, element, :contentOffset).first
100
- Applitools::Location.new(
101
- result['X'].to_i,
102
- result['Y'].to_i
103
- )
104
- end
105
-
106
- def store_original_position
107
- current_scrollable_element = Applitools::Calabash::Utils.request_element(context, element, :contentSize).first
108
- @original_position = Applitools::Location.new(
109
- current_scrollable_element['X'],
110
- current_scrollable_element['Y']
111
- )
112
- end
113
-
114
- def restore_original_position; end
115
-
116
- def scroll_it!
117
- scroll_in_one_dimension(:down) do |pos, is_first_vertical|
118
- scroll_in_one_dimension(:right, pos) do |position, is_first_horizontal|
119
- yield(position, !is_first_vertical, !is_first_horizontal) if block_given?
120
- end
121
- end
122
- end
123
-
124
- def scroll_in_one_dimension(direction, position = nil)
125
- previous_position = position || query_current_position
126
- is_first = true
127
- loop do
128
- yield(previous_position, is_first) if block_given?
129
- is_first = false if is_first
130
- context.scroll(element.element_query, direction)
131
- sleep NEXT_REQUEST_DELAY
132
- new_position = query_current_position
133
- return if previous_position == new_position
134
- previous_position = new_position
135
- end
136
- end
137
-
138
- def scroll_left_top
139
- scroll_in_one_dimension(:up) do |position, _is_first, _direction|
140
- scroll_in_one_dimension(:left, position)
141
- end
142
- end
143
-
144
- def eyes_window
145
- @eyes_window ||= Applitools::Region.from_location_size(element.location, element.size)
146
- end
147
- end
148
- end
149
- end
150
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Applitools::Calabash.require_dir 'calabash/full_page_capture_algorithm'
4
-
5
- module Applitools
6
- module Calabash
7
- module FullPageCaptureAlgorithm
8
- ANDROID_ALGORITHMS = {
9
- 'android.widget.ScrollView' => Applitools::Calabash::FullPageCaptureAlgorithm::AndroidScrollView
10
- }.freeze
11
- IOS_ALGORITHMS = {
12
- 'UITableView' => Applitools::Calabash::FullPageCaptureAlgorithm::IosUITableView
13
- }.freeze
14
- class << self
15
- def get_algorithm_class(env, klass)
16
- case env
17
- when :ios
18
- IOS_ALGORITHMS[klass]
19
- when :android
20
- ANDROID_ALGORITHMS[klass]
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Applitools
4
- module Calabash
5
- module OsVersions
6
- module Android
7
- extend self
8
- API_TO_NAME = {
9
- 4 => 'Android 1',
10
- 10 => 'Android 2',
11
- 13 => 'Android 3',
12
- 20 => 'Android 4',
13
- 22 => 'Android 5',
14
- 23 => 'Android 6',
15
- 25 => 'Android 7',
16
- 27 => 'Android 8'
17
- }.freeze
18
-
19
- def os_version(api_level)
20
- API_TO_NAME[API_TO_NAME.keys.select { |v| api_level.to_i >= v }.last] || 'Android'
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rspec/expectations'
4
-
5
- RSpec::Matchers.define :match_baseline do |expected|
6
- match do |actual|
7
- eyes = Applitools::Calabash::EyesSettings.instance.eyes
8
- result = eyes.check(expected, actual)
9
- eyes.new_session? || result.as_expected?
10
- end
11
-
12
- failure_message do |_actual|
13
- "expected #{expected} to match a baseline"
14
- end
15
- end
16
-
17
- RSpec::Matchers.define :be_success do
18
- match do |actual|
19
- actual.as_expected? == true
20
- end
21
-
22
- failure_message do |actual|
23
- "Expected eyes session to be successful, but mismatches occur. \n#{actual}"
24
- end
25
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Then(/^set OS$/) do
4
- sdk_version = begin
5
- perform_action('android_sdk_version')
6
- rescue HTTPClient::KeepAliveDisconnected
7
- reinstall_apps
8
- start_test_server_in_background
9
- perform_action('android_sdk_version')
10
- end
11
- if sdk_version['success']
12
- Applitools::Calabash::EyesSettings.instance.eyes.host_os = Applitools::Calabash::OsVersions::Android.os_version(
13
- sdk_version['message']
14
- )
15
- end
16
- end
17
-
18
- Then(/^set device pixel ratio$/) do
19
- display_info = `#{default_device.adb_command} shell dumpsys display`
20
- # size_match = /deviceWidth=(?<width>\d+), deviceHeight=(?<height>\d+)/.match(display_info)
21
- density_match = /DisplayDeviceInfo.*density (?<density>\d+)/.match(display_info)
22
- Applitools::Calabash::EyesSettings.instance.eyes.device_pixel_ratio = density_match[:density].to_i
23
- end
24
-
25
- Then(/^set device physical size$/) do
26
- result = /mDefaultViewport=.*deviceWidth=(?<width>\d+).*deviceHeight=(?<height>\d+).*\n/.match(
27
- `#{default_device.adb_command} shell dumpsys display |grep mDefaultViewport`
28
- )
29
- step %(eyes viewport size is "#{result[:width].to_i}x#{result[:height].to_i}")
30
- end
31
-
32
- Then(/^set device size$/) do
33
- result = /^.*app=(?<width>\d+)x(?<height>\d+)/.match(
34
- `#{default_device.adb_command} shell dumpsys window displays |grep cur | tr -d ' '`
35
- )
36
- step %(eyes viewport size is "#{result[:width].to_i}x#{result[:height].to_i}")
37
- end