capybara-screenshot-diff 1.8.3 → 1.9.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -11
- data/capybara-screenshot-diff.gemspec +2 -3
- data/gems.rb +4 -4
- data/lib/capybara/screenshot/diff/area_calculator.rb +56 -0
- data/lib/capybara/screenshot/diff/browser_helpers.rb +5 -5
- data/lib/capybara/screenshot/diff/comparison.rb +6 -0
- data/lib/capybara/screenshot/diff/cucumber.rb +1 -9
- data/lib/capybara/screenshot/diff/difference.rb +8 -4
- data/lib/capybara/screenshot/diff/drivers/base_driver.rb +0 -5
- data/lib/capybara/screenshot/diff/drivers/chunky_png_driver.rb +10 -5
- data/lib/capybara/screenshot/diff/drivers/vips_driver.rb +14 -3
- data/lib/capybara/screenshot/diff/drivers.rb +1 -1
- data/lib/capybara/screenshot/diff/image_compare.rb +80 -114
- data/lib/capybara/screenshot/diff/region.rb +28 -7
- data/lib/capybara/screenshot/diff/reporters/default.rb +117 -0
- data/lib/capybara/screenshot/diff/screenshot_matcher.rb +36 -74
- data/lib/capybara/screenshot/diff/screenshoter.rb +46 -54
- data/lib/capybara/screenshot/diff/stable_screenshoter.rb +65 -63
- data/lib/capybara/screenshot/diff/test_methods.rb +76 -9
- data/lib/capybara/screenshot/diff/{drivers/utils.rb → utils.rb} +0 -7
- data/lib/capybara/screenshot/diff/vcs.rb +25 -23
- data/lib/capybara/screenshot/diff/version.rb +1 -1
- data/lib/capybara/screenshot/diff.rb +1 -111
- data/lib/capybara-screenshot-diff.rb +1 -1
- data/lib/capybara_screenshot_diff/attempts_reporter.rb +49 -0
- data/lib/capybara_screenshot_diff/cucumber.rb +12 -0
- data/lib/capybara_screenshot_diff/dsl.rb +11 -0
- data/lib/capybara_screenshot_diff/minitest.rb +45 -0
- data/lib/capybara_screenshot_diff/rspec.rb +32 -0
- data/lib/capybara_screenshot_diff/snap.rb +55 -0
- data/lib/capybara_screenshot_diff/snap_manager.rb +76 -0
- data/lib/capybara_screenshot_diff.rb +86 -0
- metadata +20 -39
- data/lib/capybara/screenshot/diff/stabilization.rb +0 -0
- data/sig/capybara/screenshot/diff/diff.rbs +0 -28
- data/sig/capybara/screenshot/diff/difference.rbs +0 -33
- data/sig/capybara/screenshot/diff/drivers/base_driver.rbs +0 -63
- data/sig/capybara/screenshot/diff/drivers/browser_helpers.rbs +0 -36
- data/sig/capybara/screenshot/diff/drivers/chunky_png_driver.rbs +0 -89
- data/sig/capybara/screenshot/diff/drivers/utils.rbs +0 -13
- data/sig/capybara/screenshot/diff/drivers/vips_driver.rbs +0 -25
- data/sig/capybara/screenshot/diff/image_compare.rbs +0 -93
- data/sig/capybara/screenshot/diff/os.rbs +0 -11
- data/sig/capybara/screenshot/diff/region.rbs +0 -43
- data/sig/capybara/screenshot/diff/screenshot_matcher.rbs +0 -60
- data/sig/capybara/screenshot/diff/screenshoter.rbs +0 -48
- data/sig/capybara/screenshot/diff/stable_screenshoter.rbs +0 -29
- data/sig/capybara/screenshot/diff/test_methods.rbs +0 -39
- data/sig/capybara/screenshot/diff/vcs.rbs +0 -17
@@ -0,0 +1,86 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "capybara/dsl"
|
4
|
+
require "capybara/screenshot/diff/version"
|
5
|
+
require "capybara/screenshot/diff/utils"
|
6
|
+
require "capybara/screenshot/diff/image_compare"
|
7
|
+
require "capybara_screenshot_diff/snap_manager"
|
8
|
+
require "capybara/screenshot/diff/test_methods"
|
9
|
+
require "capybara/screenshot/diff/screenshoter"
|
10
|
+
require "capybara/screenshot/diff/reporters/default"
|
11
|
+
|
12
|
+
module CapybaraScreenshotDiff
|
13
|
+
class ExpectationNotMet < StandardError; end
|
14
|
+
end
|
15
|
+
|
16
|
+
module Capybara
|
17
|
+
module Screenshot
|
18
|
+
mattr_accessor :add_driver_path
|
19
|
+
mattr_accessor :add_os_path
|
20
|
+
mattr_accessor :blur_active_element
|
21
|
+
mattr_accessor :enabled
|
22
|
+
mattr_accessor :hide_caret
|
23
|
+
mattr_reader(:root) { (defined?(Rails) && defined?(Rails.root) && Rails.root) || Pathname(".").expand_path }
|
24
|
+
mattr_accessor :stability_time_limit
|
25
|
+
mattr_accessor :window_size
|
26
|
+
mattr_accessor(:save_path) { "doc/screenshots" }
|
27
|
+
mattr_accessor(:use_lfs)
|
28
|
+
mattr_accessor(:screenshot_format) { "png" }
|
29
|
+
mattr_accessor(:capybara_screenshot_options) { {} }
|
30
|
+
|
31
|
+
class << self
|
32
|
+
def root=(path)
|
33
|
+
@@root = Pathname(path).expand_path
|
34
|
+
end
|
35
|
+
|
36
|
+
def active?
|
37
|
+
enabled || (enabled.nil? && Diff.enabled)
|
38
|
+
end
|
39
|
+
|
40
|
+
def screenshot_area
|
41
|
+
parts = [Screenshot.save_path]
|
42
|
+
parts << Os.name if Screenshot.add_os_path
|
43
|
+
parts << Capybara.current_driver.to_s if Screenshot.add_driver_path
|
44
|
+
File.join(*parts)
|
45
|
+
end
|
46
|
+
|
47
|
+
def screenshot_area_abs
|
48
|
+
root / screenshot_area
|
49
|
+
end
|
50
|
+
end
|
51
|
+
|
52
|
+
# Module to track screen shot changes
|
53
|
+
module Diff
|
54
|
+
mattr_accessor(:delayed) { true }
|
55
|
+
mattr_accessor :area_size_limit
|
56
|
+
mattr_accessor(:fail_if_new) { false }
|
57
|
+
mattr_accessor(:fail_on_difference) { true }
|
58
|
+
mattr_accessor :color_distance_limit
|
59
|
+
mattr_accessor(:enabled) { true }
|
60
|
+
mattr_accessor :shift_distance_limit
|
61
|
+
mattr_accessor :skip_area
|
62
|
+
mattr_accessor(:driver) { :auto }
|
63
|
+
mattr_accessor :tolerance
|
64
|
+
|
65
|
+
mattr_accessor(:screenshoter) { Screenshoter }
|
66
|
+
mattr_accessor(:manager) { CapybaraScreenshotDiff::SnapManager }
|
67
|
+
|
68
|
+
AVAILABLE_DRIVERS = Utils.detect_available_drivers.freeze
|
69
|
+
|
70
|
+
def self.default_options
|
71
|
+
{
|
72
|
+
area_size_limit: area_size_limit,
|
73
|
+
color_distance_limit: color_distance_limit,
|
74
|
+
driver: driver,
|
75
|
+
screenshot_format: Screenshot.screenshot_format,
|
76
|
+
capybara_screenshot_options: Screenshot.capybara_screenshot_options,
|
77
|
+
shift_distance_limit: shift_distance_limit,
|
78
|
+
skip_area: skip_area,
|
79
|
+
stability_time_limit: Screenshot.stability_time_limit,
|
80
|
+
tolerance: tolerance || ((driver == :vips) ? 0.001 : nil),
|
81
|
+
wait: Capybara.default_max_wait_time
|
82
|
+
}
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: capybara-screenshot-diff
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.9.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Uwe Kubosch
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-11-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -19,7 +19,7 @@ dependencies:
|
|
19
19
|
version: '6.1'
|
20
20
|
- - "<"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '
|
22
|
+
version: '9'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -29,7 +29,7 @@ dependencies:
|
|
29
29
|
version: '6.1'
|
30
30
|
- - "<"
|
31
31
|
- !ruby/object:Gem::Version
|
32
|
-
version: '
|
32
|
+
version: '9'
|
33
33
|
- !ruby/object:Gem::Dependency
|
34
34
|
name: capybara
|
35
35
|
requirement: !ruby/object:Gem::Requirement
|
@@ -50,20 +50,6 @@ dependencies:
|
|
50
50
|
- - "<"
|
51
51
|
- !ruby/object:Gem::Version
|
52
52
|
version: '4'
|
53
|
-
- !ruby/object:Gem::Dependency
|
54
|
-
name: chunky_png
|
55
|
-
requirement: !ruby/object:Gem::Requirement
|
56
|
-
requirements:
|
57
|
-
- - "~>"
|
58
|
-
- !ruby/object:Gem::Version
|
59
|
-
version: '1.3'
|
60
|
-
type: :runtime
|
61
|
-
prerelease: false
|
62
|
-
version_requirements: !ruby/object:Gem::Requirement
|
63
|
-
requirements:
|
64
|
-
- - "~>"
|
65
|
-
- !ruby/object:Gem::Version
|
66
|
-
version: '1.3'
|
67
53
|
description: Save screen shots and track changes with graphical diff
|
68
54
|
email:
|
69
55
|
- uwe@kubosch.no
|
@@ -77,45 +63,40 @@ files:
|
|
77
63
|
- gems.rb
|
78
64
|
- lib/capybara-screenshot-diff.rb
|
79
65
|
- lib/capybara/screenshot/diff.rb
|
66
|
+
- lib/capybara/screenshot/diff/area_calculator.rb
|
80
67
|
- lib/capybara/screenshot/diff/browser_helpers.rb
|
68
|
+
- lib/capybara/screenshot/diff/comparison.rb
|
81
69
|
- lib/capybara/screenshot/diff/cucumber.rb
|
82
70
|
- lib/capybara/screenshot/diff/difference.rb
|
83
71
|
- lib/capybara/screenshot/diff/drivers.rb
|
84
72
|
- lib/capybara/screenshot/diff/drivers/base_driver.rb
|
85
73
|
- lib/capybara/screenshot/diff/drivers/chunky_png_driver.rb
|
86
|
-
- lib/capybara/screenshot/diff/drivers/utils.rb
|
87
74
|
- lib/capybara/screenshot/diff/drivers/vips_driver.rb
|
88
75
|
- lib/capybara/screenshot/diff/image_compare.rb
|
89
76
|
- lib/capybara/screenshot/diff/os.rb
|
90
77
|
- lib/capybara/screenshot/diff/region.rb
|
78
|
+
- lib/capybara/screenshot/diff/reporters/default.rb
|
91
79
|
- lib/capybara/screenshot/diff/screenshot_matcher.rb
|
92
80
|
- lib/capybara/screenshot/diff/screenshoter.rb
|
93
|
-
- lib/capybara/screenshot/diff/stabilization.rb
|
94
81
|
- lib/capybara/screenshot/diff/stable_screenshoter.rb
|
95
82
|
- lib/capybara/screenshot/diff/test_methods.rb
|
83
|
+
- lib/capybara/screenshot/diff/utils.rb
|
96
84
|
- lib/capybara/screenshot/diff/vcs.rb
|
97
85
|
- lib/capybara/screenshot/diff/version.rb
|
98
|
-
-
|
99
|
-
-
|
100
|
-
-
|
101
|
-
-
|
102
|
-
-
|
103
|
-
-
|
104
|
-
-
|
105
|
-
-
|
106
|
-
- sig/capybara/screenshot/diff/os.rbs
|
107
|
-
- sig/capybara/screenshot/diff/region.rbs
|
108
|
-
- sig/capybara/screenshot/diff/screenshot_matcher.rbs
|
109
|
-
- sig/capybara/screenshot/diff/screenshoter.rbs
|
110
|
-
- sig/capybara/screenshot/diff/stable_screenshoter.rbs
|
111
|
-
- sig/capybara/screenshot/diff/test_methods.rbs
|
112
|
-
- sig/capybara/screenshot/diff/vcs.rbs
|
86
|
+
- lib/capybara_screenshot_diff.rb
|
87
|
+
- lib/capybara_screenshot_diff/attempts_reporter.rb
|
88
|
+
- lib/capybara_screenshot_diff/cucumber.rb
|
89
|
+
- lib/capybara_screenshot_diff/dsl.rb
|
90
|
+
- lib/capybara_screenshot_diff/minitest.rb
|
91
|
+
- lib/capybara_screenshot_diff/rspec.rb
|
92
|
+
- lib/capybara_screenshot_diff/snap.rb
|
93
|
+
- lib/capybara_screenshot_diff/snap_manager.rb
|
113
94
|
homepage: https://github.com/donv/capybara-screenshot-diff
|
114
95
|
licenses:
|
115
96
|
- MIT
|
116
97
|
metadata:
|
117
98
|
allowed_push_host: https://rubygems.org/
|
118
|
-
post_install_message:
|
99
|
+
post_install_message:
|
119
100
|
rdoc_options: []
|
120
101
|
require_paths:
|
121
102
|
- lib
|
@@ -130,8 +111,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
130
111
|
- !ruby/object:Gem::Version
|
131
112
|
version: '0'
|
132
113
|
requirements: []
|
133
|
-
rubygems_version: 3.
|
134
|
-
signing_key:
|
114
|
+
rubygems_version: 3.5.22
|
115
|
+
signing_key:
|
135
116
|
specification_version: 4
|
136
117
|
summary: Track your GUI changes with diff assertions
|
137
118
|
test_files: []
|
File without changes
|
@@ -1,28 +0,0 @@
|
|
1
|
-
module Capybara
|
2
|
-
module Screenshot
|
3
|
-
def self.root=: ((String | Pathname) path) -> Pathname
|
4
|
-
|
5
|
-
def self.root: -> Pathname
|
6
|
-
|
7
|
-
def self.active?: () -> boolish
|
8
|
-
|
9
|
-
def self.screenshot_area: () -> String
|
10
|
-
|
11
|
-
def self.screenshot_area_abs: () -> Pathname
|
12
|
-
|
13
|
-
# Module to track screen shot changes
|
14
|
-
module Diff
|
15
|
-
AVAILABLE_DRIVERS: Array[(:vips | :chunky_png)]
|
16
|
-
|
17
|
-
ASSERTION: (top | RuntimeError)
|
18
|
-
|
19
|
-
def self.default_options: () -> ScreenshotMatcher::input_options
|
20
|
-
|
21
|
-
def self.included: (top klass) -> void
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def track_failures: (Array[untyped] screenshots) -> void
|
26
|
-
end
|
27
|
-
end
|
28
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
module Capybara
|
2
|
-
module Screenshot
|
3
|
-
module Diff
|
4
|
-
class Difference
|
5
|
-
attr_reader comparison: ImageCompare::Comparison
|
6
|
-
|
7
|
-
def different?: () -> bool
|
8
|
-
|
9
|
-
def base_image: () -> top
|
10
|
-
|
11
|
-
def options: () -> Drivers::BaseDriver::options_entity
|
12
|
-
|
13
|
-
def tolerance: () -> Numeric?
|
14
|
-
|
15
|
-
def area_size_limit: () -> Numeric?
|
16
|
-
|
17
|
-
def blank?: () -> bool
|
18
|
-
|
19
|
-
def region_area_size: () -> Numeric
|
20
|
-
|
21
|
-
def ratio: () -> Numeric?
|
22
|
-
|
23
|
-
def to_h: () -> Hash[Symbol, untyped]
|
24
|
-
|
25
|
-
def coordinates: () -> Region::raw_region_entity
|
26
|
-
|
27
|
-
def inspect: () -> String
|
28
|
-
|
29
|
-
def tolerable?: () -> bool
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
@@ -1,63 +0,0 @@
|
|
1
|
-
module Capybara
|
2
|
-
module Screenshot
|
3
|
-
module Diff
|
4
|
-
module Drivers
|
5
|
-
class BaseDriver[ImageEntity]
|
6
|
-
|
7
|
-
type images_entity[out T] = [T, T]
|
8
|
-
type dimension_entity = [Numeric, Numeric]
|
9
|
-
|
10
|
-
type options_entity = {
|
11
|
-
area_size_limit?: Numeric?,
|
12
|
-
color_distance_limit?: Numeric?,
|
13
|
-
driver: (:auto | :vips | :chunky_png | VipsDriver | ChunkyPNGDriver)?,
|
14
|
-
dimensions: dimension_entity?,
|
15
|
-
median_filter_window_size: Numeric?,
|
16
|
-
shift_distance_limit?: Numeric?,
|
17
|
-
skip_area?: Array[Region]?,
|
18
|
-
stability_time_limit?: Numeric?,
|
19
|
-
tolerance?: Numeric?,
|
20
|
-
wait?: Numeric?
|
21
|
-
}
|
22
|
-
|
23
|
-
type color = [Integer, Integer, Integer, Integer]
|
24
|
-
|
25
|
-
def find_difference_region: (ImageEntity new_image, ImageEntity old_image, Numeric color_distance_limit, Numeric _shift_distance_limit, Integer _area_size_limit, ?fast_fail: bool) -> Difference
|
26
|
-
|
27
|
-
def inscribed?: (dimension_entity dimensions, ImageEntity i) -> boolish
|
28
|
-
|
29
|
-
def crop: (Region region, ImageEntity i) -> ImageEntity
|
30
|
-
|
31
|
-
def filter_image_with_median: (ImageEntity image, Numeric median_filter_window_size) -> ImageEntity
|
32
|
-
|
33
|
-
def add_black_box: (ImageEntity memo, Region region) -> void
|
34
|
-
|
35
|
-
def difference_level: (ImageEntity diff_mask, ImageEntity old_img, Region _region) -> Float
|
36
|
-
|
37
|
-
def image_area_size: (ImageEntity old_img) -> Integer
|
38
|
-
|
39
|
-
def height_for: (ImageEntity image) -> Integer
|
40
|
-
|
41
|
-
def width_for: (ImageEntity image) -> Integer
|
42
|
-
|
43
|
-
# Vips could not work with the same file. Per each process we require to create new file
|
44
|
-
def save_image_to: (ImageEntity image, String filename) -> void
|
45
|
-
|
46
|
-
def resize_image_to: (ImageEntity image, Integer new_width, Integer new_height) -> ImageEntity
|
47
|
-
|
48
|
-
def load_images: (String old_file_name, String new_file_name) -> images_entity[ImageEntity]
|
49
|
-
|
50
|
-
def from_file: (TestMethods::path_entity filename) -> ImageEntity
|
51
|
-
|
52
|
-
def dimension: (ImageEntity image) -> dimension_entity
|
53
|
-
|
54
|
-
def draw_rectangles: (images_entity[ImageEntity] images, Region region, color rgba, Integer offset) -> void
|
55
|
-
|
56
|
-
def same_pixels?: () -> boolish
|
57
|
-
end
|
58
|
-
|
59
|
-
def self.for: (ScreenshotMatcher::input_options) -> (VipsDriver | ChunkyPNGDriver)
|
60
|
-
end
|
61
|
-
end
|
62
|
-
end
|
63
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
module Capybara
|
2
|
-
class Result
|
3
|
-
def map: () -> Result
|
4
|
-
end
|
5
|
-
module Screenshot
|
6
|
-
module BrowserHelpers
|
7
|
-
def self.current_capybara_driver_class: () -> top
|
8
|
-
|
9
|
-
def self.selenium?: () -> boolish?
|
10
|
-
|
11
|
-
def self.window_size_is_wrong?: () -> boolish
|
12
|
-
|
13
|
-
def self.bounds_for_css: (*String css_selectors) -> Array[Region::raw_region_entity]
|
14
|
-
|
15
|
-
IMAGE_WAIT_SCRIPT: String
|
16
|
-
|
17
|
-
def self.pending_image_to_load: () -> top?
|
18
|
-
|
19
|
-
HIDE_CARET_SCRIPT: String
|
20
|
-
|
21
|
-
def self.hide_caret: () -> void
|
22
|
-
|
23
|
-
FIND_ACTIVE_ELEMENT_SCRIPT: String
|
24
|
-
|
25
|
-
type capybara_element = top
|
26
|
-
|
27
|
-
def self.blur_from_focused_element: () -> capybara_element?
|
28
|
-
|
29
|
-
GET_BOUNDING_CLIENT_RECT_SCRIPT: String
|
30
|
-
|
31
|
-
def self.all_visible_regions_for: (String selector) -> Array[Region::raw_region_entity]
|
32
|
-
|
33
|
-
def self.region_for: (Result element) -> Region::raw_region_entity
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
module ChunkyPNG
|
2
|
-
class Canvas
|
3
|
-
end
|
4
|
-
|
5
|
-
class Image
|
6
|
-
def self.from_blob: (String str) -> Image
|
7
|
-
|
8
|
-
def self.from_file: (String filename) -> Image
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
module Capybara
|
13
|
-
module Screenshot
|
14
|
-
module Diff
|
15
|
-
module Drivers
|
16
|
-
class ChunkyPNGDriver < BaseDriver[ChunkyPNG::Canvas]
|
17
|
-
|
18
|
-
def _load_images: (String old_file, String new_file) -> [ChunkyPNG::Image, ChunkyPNG::Image]
|
19
|
-
|
20
|
-
class DifferenceRegionFinder
|
21
|
-
def find_diff_rectangle: (
|
22
|
-
ChunkyPNG::Image org_img,
|
23
|
-
ChunkyPNG::Image new_img,
|
24
|
-
(Region | Region::raw_region_entity) area_coordinates,
|
25
|
-
cache: ImageCompare::cache_entity
|
26
|
-
) -> Region?
|
27
|
-
|
28
|
-
def find_top: (
|
29
|
-
ChunkyPNG::Image old_img,
|
30
|
-
ChunkyPNG::Image new_img,
|
31
|
-
cache: ImageCompare::cache_entity
|
32
|
-
) -> Region::raw_region_entity?
|
33
|
-
|
34
|
-
def find_left_right_and_top: (
|
35
|
-
ChunkyPNG::Image old_img,
|
36
|
-
ChunkyPNG::Image new_img,
|
37
|
-
(Region | Region::raw_region_entity) region,
|
38
|
-
cache: ImageCompare::cache_entity
|
39
|
-
) -> Region::raw_region_entity
|
40
|
-
|
41
|
-
def find_bottom: (
|
42
|
-
ChunkyPNG::Image old_img,
|
43
|
-
ChunkyPNG::Image new_img,
|
44
|
-
Integer left,
|
45
|
-
Integer right,
|
46
|
-
Integer bottom,
|
47
|
-
cache: ImageCompare::cache_entity
|
48
|
-
) -> Integer
|
49
|
-
|
50
|
-
def same_color?: (
|
51
|
-
ChunkyPNG::Image old_img,
|
52
|
-
ChunkyPNG::Image new_img,
|
53
|
-
Integer x,
|
54
|
-
Integer y,
|
55
|
-
?cache: ImageCompare::cache_entity
|
56
|
-
) -> boolish
|
57
|
-
|
58
|
-
def skipped_region?: (Integer x, Integer y) -> boolish
|
59
|
-
|
60
|
-
def color_distance_at: (
|
61
|
-
ChunkyPNG::Image new_img,
|
62
|
-
ChunkyPNG::Image old_img,
|
63
|
-
Integer x,
|
64
|
-
Integer y,
|
65
|
-
shift_distance_limit: Numeric?
|
66
|
-
) -> Float
|
67
|
-
|
68
|
-
def shift_distance_at: (
|
69
|
-
ChunkyPNG::Image new_img,
|
70
|
-
ChunkyPNG::Image old_img,
|
71
|
-
Integer x,
|
72
|
-
Integer y,
|
73
|
-
color_distance_limit: Numeric?
|
74
|
-
) -> Numeric
|
75
|
-
|
76
|
-
def color_matches: (
|
77
|
-
ChunkyPNG::Image new_img,
|
78
|
-
Integer org_color,
|
79
|
-
Integer x,
|
80
|
-
Integer y,
|
81
|
-
Numeric? color_distance_limit
|
82
|
-
) -> boolish
|
83
|
-
end
|
84
|
-
|
85
|
-
end
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
@@ -1,13 +0,0 @@
|
|
1
|
-
module Capybara
|
2
|
-
module Screenshot
|
3
|
-
module Diff
|
4
|
-
module Utils
|
5
|
-
def self.detect_available_drivers: () -> Array[(:vips | :chunky_png)]
|
6
|
-
|
7
|
-
def self.find_driver_class_for: [T] (Symbol driver) -> T
|
8
|
-
|
9
|
-
def self.detect_test_framework_assert: [T < Exception] () -> T
|
10
|
-
end
|
11
|
-
end
|
12
|
-
end
|
13
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
module ::Vips
|
2
|
-
class Image
|
3
|
-
def self.new_from_file: (String filename) -> Image
|
4
|
-
end
|
5
|
-
end
|
6
|
-
|
7
|
-
module Capybara
|
8
|
-
module Screenshot
|
9
|
-
module Diff
|
10
|
-
module Drivers
|
11
|
-
class VipsDriver < BaseDriver[Vips::Image]
|
12
|
-
class VipsUtil
|
13
|
-
def self.difference_area: (Vips::Image old_image, Vips::Image new_image, ?color_distance: ::Integer) -> Numeric
|
14
|
-
|
15
|
-
def self.difference_area_size_by: (Vips::Image difference_mask) -> Numeric
|
16
|
-
|
17
|
-
def self.difference_mask: (Vips::Image, Vips::Image, ?Numeric? color_distance) -> Vips::Image
|
18
|
-
|
19
|
-
def self.difference_region_by: (Vips::Image diff_mask) -> Region?
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,93 +0,0 @@
|
|
1
|
-
module Capybara
|
2
|
-
module Screenshot
|
3
|
-
module Diff
|
4
|
-
LOADED_DRIVERS: { vips: ImageCompare::driver_entity, chunky_png: ImageCompare::driver_entity }
|
5
|
-
|
6
|
-
# Compare two images_entities and determine if they are equal, different, or within some comparison
|
7
|
-
# range considering color values and difference area size.
|
8
|
-
class ImageCompare
|
9
|
-
TOLERABLE_OPTIONS: [:tolerance, :color_distance_limit, :shift_distance_limit, :area_size_limit]
|
10
|
-
|
11
|
-
class Comparison
|
12
|
-
|
13
|
-
end
|
14
|
-
|
15
|
-
type driver_entity = (Drivers::VipsDriver | Drivers::ChunkyPNGDriver)
|
16
|
-
type image_entity = (ChunkyPNG::Canvas | Vips::Image)
|
17
|
-
type images_entities = [image_entity, image_entity]
|
18
|
-
type cache_entity = (::Hash[Symbol, top] | top)
|
19
|
-
|
20
|
-
@annotated_base_image_path: Pathname
|
21
|
-
@annotated_image_path: Pathname
|
22
|
-
@difference: Difference
|
23
|
-
@error_message: String?
|
24
|
-
|
25
|
-
attr_reader error_message: String?
|
26
|
-
attr_reader annotated_base_image_path: Pathname
|
27
|
-
attr_reader annotated_image_path: Pathname
|
28
|
-
attr_reader driver: driver_entity
|
29
|
-
attr_reader driver_options: Drivers::BaseDriver::options_entity
|
30
|
-
attr_reader annotated_new_file_name: TestMethods::path_entity
|
31
|
-
attr_reader annotated_old_file_name: TestMethods::path_entity
|
32
|
-
attr_reader new_file_name: String
|
33
|
-
attr_reader old_file_name: String
|
34
|
-
attr_reader skip_area: Array[Region]?
|
35
|
-
attr_accessor shift_distance_limit: Numeric?
|
36
|
-
attr_accessor area_size_limit: Numeric?
|
37
|
-
attr_accessor color_distance_limit: Numeric?
|
38
|
-
|
39
|
-
@median_filter_window_size: Numeric?
|
40
|
-
@dimensions: Drivers::BaseDriver::dimension_entity?
|
41
|
-
@tolerance: Numeric?
|
42
|
-
|
43
|
-
def initialize: (TestMethods::path_entity new_file_name, TestMethods::path_entity old_file_name, ?Drivers::BaseDriver::options_entity options) -> void
|
44
|
-
|
45
|
-
# Compare the two image_entity files and return `true` or `false` as quickly as possible.
|
46
|
-
# Return falsely if the old file does not exist or the image_entity dimensions do not match.
|
47
|
-
def quick_equal?: () -> boolish
|
48
|
-
|
49
|
-
# Compare the two images_entities referenced by this object, and return `true` if they are different,
|
50
|
-
# and `false` if they are the same.
|
51
|
-
def different?: () -> bool
|
52
|
-
|
53
|
-
def clean_tmp_files: () -> void
|
54
|
-
|
55
|
-
def save: (image_entity, TestMethods::path_entity) -> void
|
56
|
-
|
57
|
-
def old_file_exists?: () -> boolish
|
58
|
-
|
59
|
-
def reset: () -> void
|
60
|
-
|
61
|
-
NEW_LINE: "\n"
|
62
|
-
|
63
|
-
private
|
64
|
-
|
65
|
-
def _different?: -> String?
|
66
|
-
|
67
|
-
def different: (Difference images) -> String
|
68
|
-
|
69
|
-
def preprocess_images: (images_entities images) -> images_entities
|
70
|
-
|
71
|
-
def preprocess_image: (image_entity image) -> image_entity
|
72
|
-
|
73
|
-
def old_file_size: () -> Integer
|
74
|
-
|
75
|
-
def new_file_size: () -> Integer
|
76
|
-
|
77
|
-
def not_different: () -> nil
|
78
|
-
|
79
|
-
def annotate_and_save_images: (Difference) -> void
|
80
|
-
|
81
|
-
def annotate_and_save_image: (Difference, image_entity, TestMethods::path_entity) -> void
|
82
|
-
|
83
|
-
DIFF_COLOR: [255, 0, 0, 255]
|
84
|
-
|
85
|
-
def annotate_difference: (image_entity, Region) -> void
|
86
|
-
|
87
|
-
SKIP_COLOR: [255, 192, 0, 255]
|
88
|
-
|
89
|
-
def annotate_skip_areas: (image_entity, Array[Region] skip_areas) -> void
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|
93
|
-
end
|
@@ -1,43 +0,0 @@
|
|
1
|
-
class Region
|
2
|
-
type raw_region_entity = [Numeric, Numeric, Numeric, Numeric]
|
3
|
-
|
4
|
-
attr_accessor x: Numeric
|
5
|
-
|
6
|
-
attr_accessor y: Numeric
|
7
|
-
|
8
|
-
attr_accessor width: Numeric
|
9
|
-
|
10
|
-
attr_accessor height: Numeric
|
11
|
-
|
12
|
-
def initialize: (Numeric x, Numeric y, Numeric width, Numeric height) -> void
|
13
|
-
|
14
|
-
def self.from_top_left_corner_coordinates: (Numeric x, Numeric y, Numeric width, Numeric height) -> Region?
|
15
|
-
|
16
|
-
def self.from_edge_coordinates: (Numeric left, Numeric `top`, Numeric right, Numeric bottom) -> Region?
|
17
|
-
|
18
|
-
def to_edge_coordinates: () -> ::Array[Numeric]
|
19
|
-
|
20
|
-
def to_top_left_corner_coordinates: () -> ::Array[Numeric]
|
21
|
-
|
22
|
-
def top: () -> Numeric
|
23
|
-
|
24
|
-
def bottom: () -> Numeric
|
25
|
-
|
26
|
-
def left: () -> Numeric
|
27
|
-
|
28
|
-
def right: () -> Numeric
|
29
|
-
|
30
|
-
def size: () -> Numeric
|
31
|
-
|
32
|
-
def to_a: () -> ::Array[Numeric]
|
33
|
-
|
34
|
-
def find_intersect_with: (Region region) -> Region?
|
35
|
-
|
36
|
-
def intersect?: (Region region) -> boolish
|
37
|
-
|
38
|
-
def move_by: (Numeric right_by, Numeric down_by) -> Region
|
39
|
-
|
40
|
-
def find_relative_intersect: (Region region) -> Region?
|
41
|
-
|
42
|
-
def cover?: (Numeric x, Numeric y) -> boolish
|
43
|
-
end
|