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,25 +0,0 @@
1
- # frozen_string_literal: true
2
- #
3
- require_relative 'region_provider'
4
- module Applitools
5
- module Appium
6
- class IosRegionProvider < ::Applitools::Appium::RegionProvider
7
- private
8
-
9
- def convert_element_coordinates
10
- Applitools::Region.from_location_size(eye_region.location, eye_region.size).
11
- scale_it!(scale_factor)
12
- end
13
-
14
- def convert_viewport_rect_coordinates
15
- region = viewport_rect
16
- Applitools::Region.new(
17
- region['left'],
18
- region['top'],
19
- region['width'],
20
- region['height']
21
- )
22
- end
23
- end
24
- end
25
- end
@@ -1,10 +0,0 @@
1
- require_relative './screenshot.rb'
2
- module Applitools
3
- module Appium
4
- class IosScreenshot < Applitools::Appium::Screenshot
5
- def convert_location(location, _from, _to)
6
- location.offset_negative(Applitools::Location.new(0, status_bar_height))
7
- end
8
- end
9
- end
10
- end
@@ -1,51 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Applitools
4
- module Appium
5
- class RegionProvider
6
- attr_accessor :driver, :eye_region, :region_to_check
7
-
8
- def initialize(driver, eye_region)
9
- self.driver = driver
10
- self.eye_region = eye_region
11
- self.region_to_check = Applitools::Region::EMPTY
12
- convert_region_coordinates
13
- end
14
-
15
- def region
16
- region_to_check
17
- end
18
-
19
- def coordinate_type
20
- nil
21
- end
22
-
23
- private
24
-
25
- def viewport_rect
26
- Applitools::Appium::Utils.viewport_rect(driver)
27
- end
28
-
29
- def convert_region_coordinates
30
- self.region_to_check = case eye_region
31
- when ::Selenium::WebDriver::Element, Applitools::Selenium::Element
32
- convert_element_coordinates
33
- else
34
- convert_viewport_rect_coordinates
35
- end
36
- end
37
-
38
- def convert_element_coordinates
39
- raise Applitools::AbstractMethodCalled.new(:convert_region_coordinates, 'Applitools::Appium::RegionProvider')
40
- end
41
-
42
- def convert_viewport_rect_coordinates
43
- raise Applitools::AbstractMethodCalled.new(:convert_viewport_rect_coordinates, 'Applitools::Appium::RegionProvider')
44
- end
45
-
46
- def scale_factor
47
- Applitools::Appium::Utils.device_pixel_ratio(driver)
48
- end
49
- end
50
- end
51
- end
@@ -1,30 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Applitools
4
- module Appium
5
- class Screenshot < Applitools::EyesScreenshot
6
-
7
- attr_reader :status_bar_height, :device_pixel_ratio
8
-
9
- def initialize(*args)
10
- options = Applitools::Utils.extract_options!(args)
11
- @status_bar_height = options[:status_bar_height] || 0
12
- @device_pixel_ratio = options[:device_pixel_ratio] || 1
13
- super
14
- end
15
-
16
- def sub_screenshot(region, _coordinate_type, _throw_if_clipped = false, _force_nil_if_clipped = false)
17
- self.class.new(
18
- Applitools::Screenshot.from_image(
19
- image.crop(region.x, region.y, region.width, region.height)
20
- )
21
- )
22
- end
23
-
24
- def convert_location(location, _from, _to)
25
- raise 'Applitools::Appium::Screenshot is an abstract class.' \
26
- ' You should implement :convert_location method in a descendant class.'
27
- end
28
- end
29
- end
30
- end
@@ -1,240 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Applitools
4
- module Appium
5
- class Target < Applitools::Selenium::Target
6
-
7
- def ignore(*args)
8
- if args.empty?
9
- reset_ignore
10
- else
11
- value = convert_to_universal(args)
12
- value = { type: args[0], selector: args[1] } if value.nil?
13
- # value = value[:selector] if value.is_a?(Hash) && (value[:type].to_s === 'id') && !is_a?(Applitools::Appium::Target)
14
- ignored_regions << value
15
- end
16
- self
17
- end
18
-
19
- def region(*args)
20
- value = convert_to_universal(args)
21
- value = { type: args[0], selector: args[1] } if value.nil?
22
- # value = value[:selector] if value.is_a?(Hash) && (value[:type].to_s === 'id') && !is_a?(Applitools::Appium::Target)
23
- self.region_to_check = value
24
- self.coordinate_type = Applitools::EyesScreenshot::COORDINATE_TYPES[:context_relative]
25
- options[:timeout] = nil
26
- reset_ignore
27
- reset_floating
28
- self
29
- end
30
-
31
- def webview(value = true)
32
- options[:webview] = value.is_a?(String) ? value : !!value
33
- # options[:stitch_content] = false if options[:stitch_content].nil?
34
- self
35
- end
36
-
37
- # class Target
38
- # include Applitools::FluentInterface
39
- # attr_accessor :region_to_check, :options, :ignored_regions, :floating_regions, :layout_regions, :content_regions, :strict_regions, :accessibility_regions
40
- #
41
- # class << self
42
- # def window
43
- # new
44
- # end
45
- #
46
- # def region(*args)
47
- # new.region(*args)
48
- # end
49
- # end
50
- #
51
- # def initialize
52
- # self.region_to_check = proc { Applitools::Region::EMPTY }
53
- # self.ignored_regions = []
54
- # self.floating_regions = []
55
- # self.layout_regions = []
56
- # self.content_regions = []
57
- # self.strict_regions = []
58
- # self.accessibility_regions = []
59
- # self.options = {}
60
- # end
61
- #
62
- # def region(*args)
63
- # self.region_to_check = case args.first
64
- # when ::Selenium::WebDriver::Element
65
- # proc { args.first }
66
- # else
67
- # proc do |driver|
68
- # driver.find_element(*args)
69
- # end
70
- # end
71
- # self
72
- # end
73
- #
74
- # def ignore(*args)
75
- # requested_padding = if args.last.is_a? Applitools::PaddingBounds
76
- # args.pop
77
- # else
78
- # Applitools::PaddingBounds::ZERO_PADDING
79
- # end
80
- # ignored_regions << case (first_argument = args.first)
81
- # when ::Selenium::WebDriver::Element
82
- # proc do
83
- # Applitools::Region
84
- # .from_location_size(first_argument.location, first_argument.size)
85
- # .padding(requested_padding)
86
- # end
87
- # when Applitools::Region
88
- # result = first_argument.padding(requested_padding)
89
- # if Applitools::Appium::Utils.ios?(Applitools::Appium::Driver::AppiumLib)
90
- # def result.converted?
91
- # true
92
- # end
93
- # end
94
- # result
95
- # else
96
- # proc do |driver|
97
- # element = driver.find_element(*args)
98
- # Applitools::Region
99
- # .from_location_size(element.location, element.size)
100
- # .padding(requested_padding)
101
- # end
102
- # end
103
- # self
104
- # end
105
- #
106
- # def floating(*args)
107
- # value = case args.first
108
- # when Applitools::FloatingRegion
109
- # args.first
110
- # when Applitools::Region
111
- # result = Applitools::FloatingRegion.any(*args)
112
- # if Applitools::Appium::Utils.ios?(Applitools::Appium::Driver::AppiumLib)
113
- # def result.converted?
114
- # true
115
- # end
116
- # end
117
- # result
118
- # when ::Selenium::WebDriver::Element
119
- # args_dup = args.dup
120
- # Applitools::FloatingRegion.any(*args_dup)
121
- # else
122
- # proc do |driver|
123
- # args_dup = args.dup
124
- # region = driver.find_element(args_dup.shift, args_dup.shift)
125
- # Applitools::FloatingRegion.any(
126
- # region, *args_dup
127
- # )
128
- # end
129
- # end
130
- # floating_regions << value
131
- # self
132
- # end
133
- #
134
- # def layout
135
- # return match_level(Applitools::MatchLevel::LAYOUT) if args.empty?
136
- # region = process_region(*args)
137
- # layout_regions << region
138
- # self
139
- #
140
- # end
141
- #
142
- # def content(*args)
143
- # return match_level(Applitools::MatchLevel::CONTENT) if args.empty?
144
- # region = process_region(*args)
145
- # content_regions << region
146
- # self
147
- # end
148
- #
149
- # def strict(*args)
150
- # return match_level(Applitools::MatchLevel::STRICT) if args.empty?
151
- # region = process_region(*args)
152
- # strict_regions << region
153
- # self
154
- # end
155
- #
156
- # def exact(*args)
157
- # match_level(Applitools::MatchLevel::EXACT, *args)
158
- # end
159
- #
160
- # def accessibility(*args)
161
- # options = Applitools::Utils.extract_options! args
162
- # unless options[:type]
163
- # raise Applitools::EyesError,
164
- # 'You should call Target.accessibility(region, type: type). The region_type option is required'
165
- # end
166
- # unless Applitools::AccessibilityRegionType.enum_values.include?(options[:type])
167
- # raise Applitools::EyesIllegalArgument,
168
- # "The region type should be one of [#{Applitools::AccessibilityRegionType.enum_values.join(', ')}]"
169
- # end
170
- #
171
- # accessibility_regions << case args.first
172
- # when ::Selenium::WebDriver::Element
173
- # element = args.first
174
- # Applitools::AccessibilityRegion.new(
175
- # element,
176
- # options[:type]
177
- # )
178
- # when Applitools::Region
179
- # result = Applitools::AccessibilityRegion.new(
180
- # args.first, options[:type]
181
- # )
182
- # if Applitools::Appium::Utils.ios?(Applitools::Appium::Driver::AppiumLib)
183
- # def result.converted?
184
- # true
185
- # end
186
- # end
187
- # result
188
- # when String
189
- # proc do |driver|
190
- # element = driver.find_element(name_or_id: args.first)
191
- # Applitools::AccessibilityRegion.new(
192
- # element,
193
- # options[:type]
194
- # )
195
- # end
196
- # else
197
- # proc do |driver|
198
- # elements = driver.find_elements(*args)
199
- # elements.map do |e|
200
- # Applitools::AccessibilityRegion.new(
201
- # e,
202
- # options[:type]
203
- # )
204
- # end
205
- # end
206
- # end
207
- # self
208
- # end
209
- #
210
- # def finalize
211
- # self
212
- # end
213
- #
214
- # private
215
- #
216
- # def process_region(*args)
217
- # r = args.first
218
- # case r
219
- # when ::Selenium::WebDriver::Element
220
- # proc do |driver|
221
- # Applitools::Region.from_location_size(r.location, r.size)
222
- # end
223
- # when Applitools::Region
224
- # if Applitools::Appium::Utils.ios?(Applitools::Appium::Driver::AppiumLib)
225
- # def r.converted?
226
- # true
227
- # end
228
- # end
229
- # r
230
- # else
231
- # proc do |driver|
232
- # element = driver.find_element(*args)
233
- # Applitools::Region.from_location_size(element.location, element.size)
234
- # end
235
- # end
236
- # end
237
- #
238
- end
239
- end
240
- end
@@ -1,64 +0,0 @@
1
- # frozen_string_literal: false
2
-
3
- module Applitools::Appium
4
- module Utils
5
- include Applitools::Utils::EyesSeleniumUtils
6
- extend self
7
-
8
- # true if test is running on mobile device
9
- def mobile_device?(driver)
10
- defined?(Appium::Driver) &&
11
- defined?(Applitools::Appium::Driver::AppiumLib) &&
12
- Applitools::Appium::Driver::AppiumLib
13
- end
14
-
15
- # true if test is running on Android device
16
- def android?(driver)
17
- driver.respond_to?(:device_is_android?) && driver.device_is_android?
18
- end
19
-
20
- # true if test is running on iOS device
21
- def ios?(driver)
22
- driver.respond_to?(:device_is_ios?) && driver.device_is_ios?
23
- end
24
-
25
- # @param [Applitools::Selenium::Driver] driver
26
- def platform_version(driver)
27
- driver.respond_to?(:platform_version) && driver.platform_version
28
- end
29
-
30
- # @param [Applitools::Selenium::Driver] executor
31
- def device_pixel_ratio(executor)
32
- session_info = session_capabilities(executor)
33
- return session_info['pixelRatio'].to_f if session_info['pixelRatio']
34
- 1
35
- end
36
-
37
- def status_bar_height(executor)
38
- session_info = session_capabilities(executor)
39
- return session_info['statBarHeight'].to_i if session_info['statBarHeight']
40
- 0
41
- end
42
-
43
- def viewport_rect(executor)
44
- session_info = session_capabilities(executor)
45
- return session_info['viewportRect'] if session_info['viewportRect']
46
- {
47
- 'left' => 0,
48
- 'top' => 0,
49
- 'width' => 0,
50
- 'height' => 0
51
- }
52
- end
53
-
54
- def session_capabilities(executor)
55
- executor.session_capabilities if executor.respond_to? :session_capabilities
56
- end
57
-
58
- def current_scroll_position(driver)
59
- super
60
- rescue
61
- Applitools::Location::TOP_LEFT
62
- end
63
- end
64
- end
@@ -1,64 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Applitools
4
- module Calabash
5
- class CalabashElement
6
- extend Forwardable
7
- attr_reader :original_element, :element_query
8
- def_delegators :@original_element, :[], :keys, :values
9
-
10
- def initialize(element, element_query)
11
- raise Applitools::EyesIllegalArgument, "Invalid element passed! (#{element})" unless valid_element?(element)
12
- @original_element = element
13
- @element_query = element_query
14
- end
15
-
16
- def left
17
- self['rect']['x']
18
- end
19
-
20
- alias x left
21
-
22
- def top
23
- self['rect']['y']
24
- end
25
-
26
- alias y top
27
-
28
- def width
29
- self['rect']['width']
30
- end
31
-
32
- def height
33
- self['rect']['height']
34
- end
35
-
36
- def location
37
- Applitools::Location.from_struct(self)
38
- end
39
-
40
- def size
41
- Applitools::RectangleSize.from_struct(self)
42
- end
43
-
44
- def region
45
- Applitools::Region.from_location_size(location, size)
46
- end
47
-
48
- def to_s
49
- @original_element
50
- end
51
-
52
- private
53
-
54
- def valid_element?(element)
55
- result = true
56
- result &&= element.is_a?(Hash)
57
- result &&= element.key?('rect')
58
- result &&= (rect = element['rect']).is_a?(Hash)
59
- result &&= (%w(height width y x center_x center_y) - rect.keys).empty?
60
- result
61
- end
62
- end
63
- end
64
- end
@@ -1,83 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Applitools
4
- module Calabash
5
- class CalabashScreenshotProvider
6
- WAIT_BEFORE_SCREENSHOT = 1
7
- attr_reader :density, :context, :debug_screenshot_provider
8
-
9
- def initialize(_options = {})
10
- @density = 1
11
- end
12
-
13
- def with_density(value)
14
- @density = value
15
- self
16
- end
17
-
18
- def using_context(value)
19
- @context = value
20
- self
21
- end
22
-
23
- def with_debug_screenshot_provider(value)
24
- Applitools::ArgumentGuard.is_a?(
25
- value,
26
- 'debug_screenshot_provider',
27
- Applitools::DebugScreenshotProvider
28
- )
29
- @debug_screenshot_provider = value
30
- self
31
- end
32
-
33
- private
34
-
35
- def save_debug_screenshot(screenshot, suffix)
36
- suffix = suffix.join('_') if suffix.respond_to? :join
37
- debug_screenshot_provider.save(screenshot, suffix || '') if debug_screenshot_provider
38
- end
39
- end
40
-
41
- class AndroidScreenshotProvider < CalabashScreenshotProvider
42
- include Singleton
43
-
44
- def capture_screenshot(options = {})
45
- sleep WAIT_BEFORE_SCREENSHOT
46
- result = nil
47
- # Applitools::Calabash::Utils.using_screenshot(context) do |screenshot_path|
48
- # screenshot = ::ChunkyPNG::Image.from_file(screenshot_path)
49
- # save_debug_screenshot(screenshot, ['original', options[:debug_suffix]])
50
- # viewport_size = Applitools::Calabash::EyesSettings.instance.viewport_size
51
- # screenshot.crop!(0, 0, viewport_size[:width], viewport_size[:height])
52
- # save_debug_screenshot(screenshot, ['cropped', options[:debug_suffix]])
53
- # result = Applitools::Calabash::EyesCalabashAndroidScreenshot.new(
54
- # Applitools::Screenshot.from_image(
55
- # screenshot
56
- # ),
57
- # density: density
58
- # )
59
- # end
60
- result
61
- end
62
- end
63
-
64
- class IosScreenshotProvider < CalabashScreenshotProvider
65
- include Singleton
66
- def capture_screenshot(options = {})
67
- sleep WAIT_BEFORE_SCREENSHOT
68
- result = nil
69
- # Applitools::Calabash::Utils.using_screenshot(context) do |screenshot_path|
70
- # screenshot = ::ChunkyPNG::Image.from_file(screenshot_path)
71
- # save_debug_screenshot(screenshot, options[:debug_suffix])
72
- # result = Applitools::Calabash::EyesCalabashIosScreenshot.new(
73
- # Applitools::Screenshot.from_image(
74
- # screenshot
75
- # ),
76
- # scale_factor: density
77
- # )
78
- # end
79
- result
80
- end
81
- end
82
- end
83
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Applitools
4
- module Calabash
5
- module EnvironmentDetector
6
- extend self
7
-
8
- def android?
9
- return true if defined?(::Calabash::Android) == 'constant'
10
- false
11
- end
12
-
13
- def ios?
14
- return true if defined?(::Calabash::Cucumber) == 'constant'
15
- false
16
- end
17
-
18
- def current_environment
19
- return :android if android?
20
- return :ios if ios?
21
- raise Applitools::EyesError, 'No calabash environment found!'
22
- end
23
- end
24
- end
25
- end