eyes_core 6.6.1 → 6.9.6

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.
data/README.md ADDED
@@ -0,0 +1,402 @@
1
+ # Applitools Eyes Core SDK
2
+
3
+ [![Gem Version](https://badge.fury.io/rb/eyes_core.svg)](https://badge.fury.io/rb/eyes_core)
4
+
5
+ The `eyes_core` gem is the foundation of the Applitools Eyes Ruby SDK ecosystem. It provides the core functionality, base classes, and utilities that power all specialized Applitools SDKs for Ruby.
6
+
7
+ ## Table of Contents
8
+
9
+ 1. [Overview](#overview)
10
+ 2. [Installation](#installation)
11
+ 3. [Core Components](#core-components)
12
+ - [EyesBase](#eyesbase)
13
+ - [Configuration](#configuration)
14
+ - [Viewport Size](#viewport-size)
15
+ - [Batch Info](#batch-info)
16
+ - [Region](#region)
17
+ - [Match Settings](#match-settings)
18
+ 4. [Universal SDK Integration](#universal-sdk-integration)
19
+ 5. [Error Handling](#error-handling)
20
+ 6. [Advanced Features](#advanced-features)
21
+ - [Accessibility Testing](#accessibility-testing)
22
+ - [Layout Breakpoints](#layout-breakpoints)
23
+ - [Proxy Configuration](#proxy-configuration)
24
+ 7. [Best Practices](#best-practices)
25
+ 8. [Troubleshooting](#troubleshooting)
26
+ 9. [FAQ](#faq)
27
+
28
+ ## Overview
29
+
30
+ The `eyes_core` gem serves as the foundation for all Applitools Ruby SDKs. While not intended for direct use, it provides essential functionality that enables visual testing across different platforms and frameworks.
31
+
32
+ ### Core Capabilities
33
+
34
+ - **Configuration Management**: Centralized settings for all Eyes operations
35
+ - **Server Communication**: Handles API interactions with Applitools services
36
+ - **Data Structures**: Common models for regions, batches, and test results
37
+ - **Visual Validation Primitives**: Base implementation for visual comparisons
38
+ - **Universal SDK Integration**: Connects to the cross-platform Universal SDK
39
+ - **Utility Functions**: Shared helpers for geometry, image processing, and more
40
+
41
+ ## Installation
42
+
43
+ The `eyes_core` gem is automatically installed as a dependency when you install any of the specific Eyes SDK implementations. You typically don't need to install it directly.
44
+
45
+ ```ruby
46
+ # Installing a specific SDK automatically includes eyes_core
47
+ gem install eyes_selenium
48
+ gem install eyes_images
49
+ gem install eyes_capybara
50
+ gem install eyes_appium
51
+
52
+ # Or add to your Gemfile
53
+ gem 'eyes_selenium' # This will include eyes_core as a dependency
54
+ ```
55
+
56
+ > **Note**: Direct installation of `eyes_core` is only needed if you're building a custom integration or extending the SDK functionality.
57
+
58
+ ## Core Components
59
+
60
+ ### EyesBase
61
+
62
+ The `EyesBase` class is the foundation of all Eyes SDK implementations. It provides the core functionality for:
63
+
64
+ - Opening and closing tests
65
+ - Performing visual validations
66
+ - Managing test configurations
67
+ - Communicating with the Applitools server
68
+
69
+ Key methods include:
70
+
71
+ ```ruby
72
+ # Opening a test
73
+ open_base(options = {})
74
+
75
+ # Core validation method (used by specific implementations)
76
+ check_window_base(region_provider, retry_timeout, match_window_data)
77
+
78
+ # Closing a test and getting results
79
+ close(throw_exception = true, be_silent = false)
80
+
81
+ # Aborting a test
82
+ abort_if_not_closed
83
+ ```
84
+
85
+ ### Configuration
86
+
87
+ The `EyesBaseConfiguration` class manages all test settings. Key configurations include:
88
+
89
+ ```ruby
90
+ # Basic test information
91
+ config.app_name = "My Application"
92
+ config.test_name = "My Test"
93
+ config.viewport_size = Applitools::RectangleSize.new(1024, 768)
94
+
95
+ # Authentication
96
+ config.api_key = "YOUR_API_KEY"
97
+ config.server_url = "https://eyesapi.applitools.com" # Default server
98
+
99
+ # Test organization
100
+ config.batch = Applitools::BatchInfo.new("My Batch")
101
+ config.branch_name = "feature/branch"
102
+ config.parent_branch_name = "master"
103
+
104
+ # Match settings
105
+ config.match_level = Applitools::MatchLevel::STRICT
106
+ config.match_timeout = 5 # seconds
107
+ config.ignore_caret = true
108
+ config.ignore_displacements = false
109
+
110
+ # Advanced features
111
+ config.accessibility_validation = Applitools::AccessibilitySettings.new(
112
+ level: Applitools::AccessibilityLevel::AA,
113
+ guidelines_version: Applitools::AccessibilityGuidelinesVersion::WCAG_2_0
114
+ )
115
+ ```
116
+
117
+ The configuration system supports environment variables:
118
+ - `APPLITOOLS_API_KEY` - Your API key
119
+ - `APPLITOOLS_SERVER_URL` - The Applitools server URL
120
+ - `APPLITOOLS_BRANCH` - Branch name for the test
121
+ - `APPLITOOLS_PARENT_BRANCH` - Parent branch for baseline comparison
122
+ - `APPLITOOLS_BASELINE_BRANCH` - Specific branch to use as baseline
123
+
124
+ ### Viewport Size
125
+
126
+ The viewport size is defined using the `RectangleSize` class:
127
+
128
+ ```ruby
129
+ viewport_size = Applitools::RectangleSize.new(width, height)
130
+ ```
131
+
132
+ This class provides methods for manipulating and comparing sizes:
133
+
134
+ ```ruby
135
+ size.width # Get width
136
+ size.height # Get height
137
+ size.empty? # Check if width or height is zero
138
+ size.to_hash # Convert to a hash: {width: w, height: h}
139
+ ```
140
+
141
+ ### Batch Info
142
+
143
+ The `BatchInfo` class groups test results for easier management:
144
+
145
+ ```ruby
146
+ batch = Applitools::BatchInfo.new("My Batch Name")
147
+ batch.id = "unique-batch-id" # Optional, auto-generated if not provided
148
+ batch.started_at = Time.now # Optional, defaults to now
149
+ ```
150
+
151
+ Batches with the same name and ID are grouped together in the Applitools dashboard.
152
+
153
+ ### Region
154
+
155
+ The `Region` class represents a rectangular area for operations like:
156
+ - Check specific parts of a page
157
+ - Define ignore regions
158
+ - Specify areas for accessibility checks
159
+
160
+ ```ruby
161
+ region = Applitools::Region.new(left, top, width, height)
162
+
163
+ # Operations
164
+ region.contains?(location) # Check if a point is inside the region
165
+ region.intersect(other_region) # Get intersection of two regions
166
+ region.empty? # Check if the region has zero area
167
+ ```
168
+
169
+ ### Match Settings
170
+
171
+ The `ImageMatchSettings` class controls how visual comparisons work:
172
+
173
+ ```ruby
174
+ settings = Applitools::ImageMatchSettings.new
175
+ settings.match_level = Applitools::MatchLevel::STRICT
176
+ settings.ignore_caret = true
177
+ settings.ignore_displacements = false
178
+ ```
179
+
180
+ Match levels include:
181
+ - `NONE` - No comparison (screenshot only)
182
+ - `LAYOUT` - Compare layout structure
183
+ - `CONTENT` - Compare textual content
184
+ - `STRICT` - Compare visually with some tolerance (default)
185
+ - `EXACT` - Pixel-perfect comparison
186
+
187
+ ## Universal SDK Integration
188
+
189
+ The `eyes_core` gem integrates with the cross-language Universal SDK through several components:
190
+
191
+ - `UniversalEyes` - Manages the session lifecycle and visual checks
192
+ - `UniversalClient` - Handles communication with the Universal SDK
193
+ - `UniversalCheckSettings` - Configures check operations
194
+ - `UniversalServerControl` - Manages the Universal SDK process
195
+
196
+ This integration provides:
197
+ - Consistent behavior across language SDKs
198
+ - Improved performance and reliability
199
+ - Access to advanced features
200
+
201
+ ```ruby
202
+ # The UniversalEyes class provides methods like:
203
+ universal_eyes.check(check_settings, image_target)
204
+ universal_eyes.close
205
+ universal_eyes.abort
206
+ ```
207
+
208
+
209
+ ## Error Handling
210
+
211
+ The SDK defines several error classes:
212
+
213
+ - `EyesError` - Base class for all errors
214
+ - `TestFailedError` - Test did not match the baseline
215
+ - `DiffsFoundError` - Differences found during comparison
216
+ - `NewTestError` - First run of a test with no baseline
217
+
218
+ ```ruby
219
+ begin
220
+ # Eyes operations
221
+ eyes.close
222
+ rescue Applitools::NewTestError => e
223
+ puts "New test (no baseline): #{e.message}"
224
+ puts "See results at: #{e.test_results.url}"
225
+ rescue Applitools::DiffsFoundError => e
226
+ puts "Found differences: #{e.message}"
227
+ puts "See results at: #{e.test_results.url}"
228
+ rescue Applitools::TestFailedError => e
229
+ puts "Test failed: #{e.message}"
230
+ rescue Applitools::EyesError => e
231
+ puts "Eyes error: #{e.message}"
232
+ end
233
+ ```
234
+
235
+ ## Advanced Features
236
+
237
+ ### Accessibility Testing
238
+
239
+ The SDK supports automated accessibility testing:
240
+
241
+ ```ruby
242
+ # Configure accessibility testing
243
+ config.accessibility_validation = Applitools::AccessibilitySettings.new(
244
+ level: Applitools::AccessibilityLevel::AA,
245
+ guidelines_version: Applitools::AccessibilityGuidelinesVersion::WCAG_2_1
246
+ )
247
+
248
+ # Add specific regions for accessibility checks
249
+ check_settings.accessibility_region(
250
+ region,
251
+ Applitools::AccessibilityRegionType::REGULAR_TEXT
252
+ )
253
+ ```
254
+
255
+ Accessibility levels:
256
+ - `AA` - WCAG AA standard
257
+ - `AAA` - WCAG AAA standard
258
+
259
+ Guidelines versions:
260
+ - `WCAG_2_0` - Web Content Accessibility Guidelines 2.0
261
+ - `WCAG_2_1` - Web Content Accessibility Guidelines 2.1
262
+
263
+ ### Layout Breakpoints
264
+
265
+ The SDK supports responsive design testing with layout breakpoints:
266
+
267
+ ```ruby
268
+ # Enable automatic breakpoints
269
+ config.layout_breakpoints = true
270
+
271
+ # Specify exact breakpoint widths (in pixels)
272
+ config.layout_breakpoints = [768, 1024, 1440]
273
+
274
+ # Advanced configuration
275
+ config.layout_breakpoints(
276
+ [768, 1024, 1440], # Width breakpoints
277
+ reload: true, # Reload page at each breakpoint
278
+ height_breakpoints: [600, 900] # Height breakpoints
279
+ )
280
+ ```
281
+
282
+ ### Proxy Configuration
283
+
284
+ For environments that require a proxy to access the internet:
285
+
286
+ ```ruby
287
+ # Basic proxy configuration
288
+ config.proxy = Applitools::Connectivity::Proxy.new('http://proxy-address:port')
289
+
290
+ # Proxy with authentication
291
+ config.proxy = Applitools::Connectivity::Proxy.new(
292
+ 'http://proxy-address:port',
293
+ 'username',
294
+ 'password'
295
+ )
296
+
297
+ # Alternative syntax
298
+ config.set_proxy('http://proxy-address:port', 'username', 'password')
299
+ ```
300
+
301
+ ## Best Practices
302
+
303
+ 1. **Configuration Management**
304
+ - Create a base configuration that's shared across tests
305
+ - Override specific settings for individual tests as needed
306
+ - Use environment variables for deployment-specific settings
307
+
308
+ 2. **Batch Organization**
309
+ - Group related tests in the same batch
310
+ - Use descriptive batch names
311
+ - Consider using consistent batch IDs for CI/CD pipelines
312
+
313
+ 3. **Error Handling**
314
+ - Always wrap Eyes operations in try/catch blocks
315
+ - Handle different error types appropriately
316
+ - Decide on a strategy for handling new tests vs. failing tests
317
+
318
+ 4. **Resource Management**
319
+ - Always call `close` or `abort_if_not_closed` to release resources
320
+ - Use `abort_if_not_closed` in ensure blocks to prevent resource leaks
321
+
322
+ 5. **Performance Optimization**
323
+ - Only check what's necessary (specific regions when possible)
324
+ - Use the appropriate match level for each test
325
+ - Leverage batching to improve efficiency
326
+
327
+ ## Troubleshooting
328
+
329
+ ### Common Issues
330
+
331
+ 1. **API Key Errors**
332
+ - Ensure your API key is set correctly
333
+ - Check environment variables are properly configured
334
+ - Verify the API key has permissions for the server you're using
335
+
336
+ 2. **Connection Issues**
337
+ - Check network connectivity to Applitools servers
338
+ - Verify proxy settings if applicable
339
+ - Check server URL if using a private cloud
340
+
341
+ 3. **Match Level Problems**
342
+ - If getting too many false differences, consider using a less strict match level
343
+ - If missing important differences, use a stricter match level
344
+
345
+ 4. **Performance Issues**
346
+ - Large or complex pages may have slower performance
347
+ - Consider checking specific regions instead of full page
348
+ - Optimize match timeout settings
349
+
350
+
351
+ ### Logging
352
+
353
+ The SDK provides built-in logging:
354
+
355
+ ```ruby
356
+ # Set log level
357
+ Applitools::EyesLogger.log_handler = Logger.new(STDOUT)
358
+ Applitools::EyesLogger.log_handler.level = Logger::DEBUG
359
+ ```
360
+
361
+ Log levels:
362
+ - `DEBUG` - Very verbose for troubleshooting
363
+ - `INFO` - Normal operations (default)
364
+ - `WARN` - Potential issues
365
+ - `ERROR` - Operation failures
366
+
367
+ ## FAQ
368
+
369
+ ### Q: Is `eyes_core` meant to be used directly?
370
+ A: No, the `eyes_core` gem provides core functionality for other Eyes SDK implementations like `eyes_selenium` or `eyes_images`. You should use those specific implementations instead.
371
+
372
+ ### Q: How do I set my API key?
373
+ A: You can set your API key in any of these ways:
374
+ - Via environment variable: `ENV['APPLITOOLS_API_KEY']='your_api_key'`
375
+ - In your code: `config.api_key = 'your_api_key'`
376
+ - In your configuration file (if applicable to your test framework)
377
+
378
+ ### Q: How do match levels affect visual testing?
379
+ A: Match levels determine how strictly Eyes compares screenshots:
380
+ - `EXACT`: Pixel-perfect matching (very strict)
381
+ - `STRICT`: Default level, allows small differences
382
+ - `CONTENT`: More lenient, focuses on content matching
383
+ - `LAYOUT`: Most lenient, only checks layout structure
384
+
385
+ ### Q: What's the difference between `close` and `abort_if_not_closed`?
386
+ A: `close` completes the test and reports results to the Applitools dashboard, while `abort_if_not_closed` terminates the test without reporting results. Use `abort_if_not_closed` in exception handling.
387
+
388
+ ### Q: How do I handle tests with no baseline?
389
+ A: When running a test for the first time with no baseline, it will raise a `NewTestError`. You can:
390
+ 1. Catch this error and handle it (e.g., approve it automatically in certain environments)
391
+ 2. Pass `false` to the `throw_exception` parameter of `close` to prevent the exception
392
+ 3. Use `save_new_tests = true` in your configuration (default) to save new tests as baselines
393
+
394
+
395
+ ### Q: Can I use eyes_core with non-web applications?
396
+ A: Yes, through specialized SDKs like `eyes_images` for image comparison or `eyes_appium` for mobile testing, which build on the core functionality provided by `eyes_core`.
397
+
398
+ ## License
399
+
400
+ This SDK is distributed under the Applitools SDK License Agreement. See the [LICENSE](LICENSE) file for more details.
401
+
402
+ **Important:** This SDK may be used solely for your personal, non-commercial purposes. For commercial use, please contact your Applitools representative or visit [applitools.com](https://applitools.com) to obtain a commercial license.
data/eyes_core.gemspec CHANGED
@@ -14,11 +14,13 @@ Gem::Specification.new do |spec|
14
14
  spec.description = "Don't use it directly, take a look at eyes_selenium, eyes_images or eyes_calabash gems instead."
15
15
  spec.summary = 'Core of the Applitools Ruby SDK'
16
16
  spec.homepage = 'https://www.applitools.com'
17
- spec.license = 'Applitools'
17
+ spec.license = 'Proprietary'
18
18
 
19
19
  spec.files = `git ls-files lib/applitools`.split($RS) + [
20
20
  'lib/require_utils.rb',
21
21
  'lib/eyes_core.rb',
22
+ 'LICENSE',
23
+ 'README.md',
22
24
  'CHANGELOG.md',
23
25
  'eyes_core.gemspec',
24
26
  'Rakefile',
@@ -38,13 +40,12 @@ Gem::Specification.new do |spec|
38
40
  spec.add_dependency 'colorize'
39
41
  spec.add_dependency 'websocket'
40
42
  spec.add_dependency 'sorted_set'
41
- spec.add_dependency 'eyes_universal', "= 4.35.1"
43
+ spec.add_dependency 'eyes_universal', "= 4.49.0"
42
44
 
43
45
  spec.add_development_dependency 'bundler'
44
46
  spec.add_development_dependency 'rake'
45
47
  spec.add_development_dependency 'rspec', '>= 3'
46
48
  spec.add_development_dependency 'rubocop', '<= 0.46.0'
47
- spec.add_development_dependency 'webdrivers', '~> 5.0'
48
49
 
49
50
  # Exclude debugging support on Travis CI, due to its incompatibility with jruby and older rubies.
50
51
  unless ENV['TRAVIS']
@@ -7,8 +7,7 @@ module Applitools
7
7
  def initialize(app_output, screenshot, allow_empty_screenshot = false)
8
8
  raise Applitools::EyesIllegalArgument.new 'app_output is not kind of Applitools::AppOutput' unless
9
9
  app_output.is_a? Applitools::AppOutput
10
- raise Applitools::EyesIllegalArgument.new 'screenshot is not kind of Applitools::EyesScreenshot' unless
11
- allow_empty_screenshot || screenshot.is_a?(Applitools::EyesScreenshot)
10
+ # No type checking for screenshot since EyesScreenshot is removed
12
11
  @app_output = app_output
13
12
  @screenshot = screenshot
14
13
  end
@@ -25,4 +24,4 @@ module Applitools
25
24
  app_output.screenshot_url
26
25
  end
27
26
  end
28
- end
27
+ end
@@ -15,7 +15,9 @@ module Applitools
15
15
  case image
16
16
  when Applitools::Screenshot
17
17
  image.save(file_name_to_save(suffix)) if image.area > 0
18
- when Applitools::EyesScreenshot
18
+ # EyesScreenshot class has been removed
19
+ # when responding to :image method, try to save the image
20
+ when -> (img) { img.respond_to?(:image) && img.image.respond_to?(:area) && img.image.respond_to?(:save) }
19
21
  image.image.save(file_name_to_save(suffix)) if image.image.area > 0
20
22
  # when String
21
23
  # ::ChunkyPNG::Image.from_string(image).save(file_name_to_save(suffix))
@@ -6,16 +6,46 @@ module Applitools
6
6
  class DynamicRegion < ::Applitools::Region
7
7
  attr_accessor :region_type
8
8
  def initialize(element, region_type)
9
- super(element.location.x, element.location.y, element.size.width, element.size.height)
9
+ if element.is_a?(::Applitools::Region)
10
+ super(element.left, element.top, element.width, element.height)
11
+ self.padding = element.current_padding if element.current_padding
12
+ else
13
+ super(element.location.x, element.location.y, element.size.width, element.size.height)
14
+ end
10
15
  self.region_type = region_type
11
16
  end
12
17
 
13
18
  def to_hash
19
+ hash = {
20
+ region: {
21
+ x: left,
22
+ y: top,
23
+ width: width,
24
+ height: height
25
+ }
26
+ }
27
+
28
+ # Type should always be an array
14
29
  if region_type
15
- super.merge(type: region_type)
16
- else
17
- super
30
+ hash[:type] = region_type.is_a?(Array) ? region_type : [region_type]
31
+ end
32
+
33
+ if current_padding && !current_padding.zero?
34
+ if padding_top == padding_right && padding_right == padding_bottom && padding_bottom == padding_left
35
+ # If all padding values are the same, use a single number
36
+ hash[:padding] = padding_top
37
+ else
38
+ # Otherwise, use an object with individual values
39
+ hash[:padding] = {
40
+ top: padding_top,
41
+ right: padding_right,
42
+ bottom: padding_bottom,
43
+ left: padding_left
44
+ }
45
+ end
18
46
  end
47
+
48
+ hash
19
49
  end
20
50
 
21
51
  alias json_data to_hash
@@ -38,8 +38,9 @@ module Applitools
38
38
 
39
39
  USE_DEFAULT_TIMEOUT = -1
40
40
 
41
- SCREENSHOT_AS_IS = Applitools::EyesScreenshot::COORDINATE_TYPES[:screenshot_as_is].freeze
42
- CONTEXT_RELATIVE = Applitools::EyesScreenshot::COORDINATE_TYPES[:context_relative].freeze
41
+ # Define these constants directly since EyesScreenshot is removed
42
+ SCREENSHOT_AS_IS = :screenshot_as_is
43
+ CONTEXT_RELATIVE = :context_relative
43
44
 
44
45
  class << self
45
46
  def set_viewport_size(driver, viewport_size)
@@ -677,8 +678,8 @@ module Applitools
677
678
  return
678
679
  end
679
680
 
680
- control = last_screenshot.intersected_region control, EyesScreenshot::COORDINATE_TYPES[:context_relative],
681
- EyesScreenshot::COORDINATE_TYPES[:screenshot_as_is]
681
+ # Use constants defined at class level since EyesScreenshot is removed
682
+ control = last_screenshot.intersected_region control, CONTEXT_RELATIVE, SCREENSHOT_AS_IS
682
683
 
683
684
  if control.empty?
684
685
  logger.info "Ignoring '#{text}' out of bounds"
@@ -207,9 +207,11 @@ module Applitools
207
207
 
208
208
  # layoutBreakpoints?: boolean | number[]
209
209
  def layout_breakpoints=(value)
210
- config_hash[:layout_breakpoints] = { breakpoints: value } if value === true || value === false
211
- config_hash[:layout_breakpoints] = { breakpoints: value } if value.is_a?(Array) && value.all? {|v| v.is_a?(Numeric)}
212
- if value.is_a?(Hash)
210
+ if value === true || value === false
211
+ config_hash[:layout_breakpoints] = { breakpoints: value }
212
+ elsif value.is_a?(Array) && value.all? {|v| v.is_a?(Numeric)}
213
+ config_hash[:layout_breakpoints] = { breakpoints: value }
214
+ elsif value.is_a?(Hash)
213
215
  if value.has_key?(:breakpoints) || value.has_key?('breakpoints')
214
216
  config_hash[:layout_breakpoints] = value
215
217
  else
@@ -217,8 +219,27 @@ module Applitools
217
219
  end
218
220
  end
219
221
  end
220
- def layout_breakpoints
221
- config_hash[:layout_breakpoints]
222
+
223
+ def layout_breakpoints(value = nil, reload: nil, height_breakpoints: nil)
224
+ if value.nil?
225
+ config_hash[:layout_breakpoints]
226
+ else
227
+ if value.is_a?(Hash)
228
+ # If it's already a hash, add our options if not present
229
+ # Need to check both symbol and string keys
230
+ value[:layout_breakpoints][:reload] = value[:reload] || value['reload'] || reload
231
+ value[:layout_breakpoints][:height_breakpoints] = value[:height_breakpoints] || value['height_breakpoints'] || height_breakpoints
232
+ self.layout_breakpoints = value
233
+ else
234
+ # For non-hash values, create a hash with all options
235
+ self.layout_breakpoints = {
236
+ breakpoints: value,
237
+ reload: reload,
238
+ height_breakpoints: height_breakpoints
239
+ }
240
+ end
241
+ self
242
+ end
222
243
  end
223
244
  collect_method :layout_breakpoints
224
245
 
@@ -1,62 +1,14 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ # Empty placeholder for backward compatibility
4
+ # This class has been removed as its functionality is now handled by the Universal SDK
5
+
3
6
  module Applitools
7
+ # Empty placeholder class to maintain backward compatibility
4
8
  class EyesScreenshot
5
- extend Forwardable
6
- extend Applitools::Helpers
7
-
8
- def_delegators 'Applitools::EyesLogger', :logger, :log_handler, :log_handler=
9
- attr_accessor :image, :top_left_location
10
- def_delegators '@image', :width, :height
11
-
12
9
  COORDINATE_TYPES = {
13
- context_as_is: 'CONTEXT_AS_IS',
14
- screenshot_as_is: 'SCREENSHOT_AS_IS',
15
- context_relative: 'CONTEXT_RELATIVE'
10
+ context_relative: :context_relative,
11
+ screenshot_as_is: :screenshot_as_is
16
12
  }.freeze
17
-
18
- def initialize(screenshot)
19
- Applitools::ArgumentGuard.is_a? screenshot, 'screenshot', Applitools::Screenshot
20
- self.image = screenshot
21
- end
22
-
23
- abstract_method :sub_screenshot, false
24
- abstract_method :convert_location, false
25
- abstract_method :location_in_screenshot, false
26
- abstract_method :intersected_region, false
27
-
28
- def sub_screenshots(regions, coordinate_type)
29
- Applitools::ArgumentGuard.is_a? regions, 'regions', Enumerable
30
- regions.map do |region|
31
- sub_screenshot(region, coordinate_type, false, true)
32
- end
33
- end
34
-
35
- def convert_region_location(region, from, to)
36
- Applitools::ArgumentGuard.not_nil region, 'region'
37
- Applitools::ArgumentGuard.is_a? region, 'region', Applitools::Region
38
- if region.empty?
39
- return region.dup.tap do |r|
40
- r.left = 0
41
- r.top = 0
42
- r.width = 0
43
- r.height = 0
44
- end
45
- end
46
- Applitools::ArgumentGuard.not_nil from, 'from'
47
- Applitools::ArgumentGuard.not_nil to, 'to'
48
-
49
- updated_location = convert_location(region.location, from, to)
50
- region.dup.tap do |r|
51
- r.left = updated_location.x
52
- r.top = updated_location.y
53
- end
54
- end
55
-
56
- private
57
-
58
- def image_region
59
- Applitools::Region.new(0, 0, image.width, image.height)
60
- end
61
13
  end
62
- end
14
+ end
@@ -94,20 +94,22 @@ module Applitools
94
94
  end
95
95
 
96
96
  def ==(other)
97
- min_diff_intensity == other.min_diff_intensity &&
98
- min_diff_width == other.min_diff_width &&
99
- min_diff_height == other.min_diff_height &&
100
- match_threshold == other.match_threshold
97
+ return false unless other.is_a?(self.class)
98
+ self.min_diff_intensity == other.min_diff_intensity &&
99
+ self.min_diff_width == other.min_diff_width &&
100
+ self.min_diff_height == other.min_diff_height &&
101
+ self.match_threshold == other.match_threshold
101
102
  end
102
103
 
103
104
  def to_hash
104
105
  {
105
- minDiffIntensity: min_diff_intensity,
106
- minDiffWidth: min_diff_width,
107
- minDiffHeight: min_diff_height,
108
- matchThreshold: match_threshold
106
+ minDiffIntensity: self.min_diff_intensity,
107
+ minDiffWidth: self.min_diff_width,
108
+ minDiffHeight: self.min_diff_height,
109
+ matchThreshold: self.match_threshold
109
110
  }
110
111
  end
112
+
111
113
  end
112
114
 
113
115
  # export type MatchSettings<TRegion> = {