eyes_core 3.4.1 → 3.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/applitools/connectivity/server_connector.rb +1 -1
- data/lib/applitools/core/eyes_base.rb +13 -11
- data/lib/applitools/core/match_window_task.rb +47 -8
- data/lib/applitools/images/eyes.rb +47 -0
- data/lib/applitools/images/target.rb +87 -0
- data/lib/applitools/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 22dadbeb5bb6802f3b1832c21c781a3c215ea4c3
|
4
|
+
data.tar.gz: f15fb3396c09a95a91b75a7ae3f742777cff67a3
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 110a411d8e8a363d1daec3f68c940c92aadf99c7ee19989e1caf3172972343a5f1b178976fab6bd9af850adc4078781913e91d4d49426e0dba0088e45fd15283
|
7
|
+
data.tar.gz: beb2a60ad9973a932702b01625e9536ae0fbb58564a04150f5f4ee7c255b0c9c288462fdf6e83c6bd700797c4e1942105f0ecabe41ff7f5941a748a91307a750
|
@@ -49,7 +49,7 @@ module Applitools::Connectivity
|
|
49
49
|
# Notice that this does not include the screenshot.
|
50
50
|
json_data = Oj.dump(Applitools::Utils.camelcase_hash_keys(data.to_hash)).force_encoding('BINARY')
|
51
51
|
body = [json_data.length].pack('L>') + json_data + data.screenshot
|
52
|
-
#Applitools::EyesLogger.debug json_data
|
52
|
+
# Applitools::EyesLogger.debug json_data
|
53
53
|
Applitools::EyesLogger.debug 'Sending match data...'
|
54
54
|
res = post(URI.join(endpoint_url, session.id.to_s), content_type: 'application/octet-stream', body: body)
|
55
55
|
raise Applitools::EyesError.new("Request failed: #{res.status} #{res.headers}") unless res.success?
|
@@ -2,6 +2,15 @@ require 'applitools/core/helpers'
|
|
2
2
|
require 'applitools/core/eyes_screenshot'
|
3
3
|
|
4
4
|
module Applitools
|
5
|
+
MATCH_LEVEL = {
|
6
|
+
none: 'None',
|
7
|
+
layout: 'Layout',
|
8
|
+
layout2: 'Layout2',
|
9
|
+
content: 'Content',
|
10
|
+
strict: 'Strict',
|
11
|
+
exact: 'Exact'
|
12
|
+
}.freeze
|
13
|
+
|
5
14
|
class EyesBase
|
6
15
|
extend Forwardable
|
7
16
|
extend Applitools::Helpers
|
@@ -12,15 +21,6 @@ module Applitools
|
|
12
21
|
SCREENSHOT_AS_IS = Applitools::EyesScreenshot::COORDINATE_TYPES[:screenshot_as_is].freeze
|
13
22
|
CONTEXT_RELATIVE = Applitools::EyesScreenshot::COORDINATE_TYPES[:context_relative].freeze
|
14
23
|
|
15
|
-
MATCH_LEVEL = {
|
16
|
-
none: 'None',
|
17
|
-
layout: 'Layout',
|
18
|
-
layout2: 'Layout2',
|
19
|
-
content: 'Content',
|
20
|
-
strict: 'Strict',
|
21
|
-
exact: 'Exact'
|
22
|
-
}.freeze
|
23
|
-
|
24
24
|
def_delegators 'Applitools::EyesLogger', :logger, :log_handler, :log_handler=
|
25
25
|
def_delegators 'Applitools::Connectivity::ServerConnector', :api_key, :api_key=, :server_url, :server_url=,
|
26
26
|
:set_proxy, :proxy, :proxy=
|
@@ -64,7 +64,7 @@ module Applitools
|
|
64
64
|
end
|
65
65
|
end
|
66
66
|
|
67
|
-
@default_match_settings = { match_level: MATCH_LEVEL[:strict], exact: nil }
|
67
|
+
@default_match_settings = { match_level: Applitools::MATCH_LEVEL[:strict], exact: nil }
|
68
68
|
end
|
69
69
|
|
70
70
|
def batch
|
@@ -209,7 +209,9 @@ module Applitools
|
|
209
209
|
ignore_mismatch: ignore_mismatch,
|
210
210
|
retry_timeout: retry_timeout,
|
211
211
|
ignore: options[:ignore],
|
212
|
-
trim: options[:trim]
|
212
|
+
trim: options[:trim],
|
213
|
+
match_level: options[:match_level],
|
214
|
+
exact: options[:exact]
|
213
215
|
)
|
214
216
|
logger.info 'match_window done!'
|
215
217
|
|
@@ -8,7 +8,7 @@ module Applitools
|
|
8
8
|
|
9
9
|
class << self
|
10
10
|
def convert_coordinates(regions, screenshot)
|
11
|
-
regions.map
|
11
|
+
regions.map do |r|
|
12
12
|
screenshot.convert_region_location(
|
13
13
|
Applitools::Region.from_location_size(r.location, r.size),
|
14
14
|
Applitools::EyesScreenshot::COORDINATE_TYPES[:context_relative],
|
@@ -45,6 +45,8 @@ module Applitools
|
|
45
45
|
retry_timeout = options[:retry_timeout]
|
46
46
|
ignore = options[:ignore] || []
|
47
47
|
trim = options[:trim] || false
|
48
|
+
match_level = options[:match_level]
|
49
|
+
exact = options[:exact]
|
48
50
|
|
49
51
|
retry_timeout = default_retry_timeout if retry_timeout < 0
|
50
52
|
|
@@ -54,25 +56,59 @@ module Applitools
|
|
54
56
|
if retry_timeout.zero? || should_match_window_run_once_on_timeout
|
55
57
|
sleep retry_timeout if should_match_window_run_once_on_timeout
|
56
58
|
app_output = app_output_provider.app_output region_provider, last_screenshot
|
57
|
-
match_result = perform_match
|
58
|
-
|
59
|
+
match_result = perform_match(
|
60
|
+
user_inputs: user_inputs,
|
61
|
+
app_output: app_output,
|
62
|
+
tag: tag,
|
63
|
+
ignore_mismatch: ignore_mismatch,
|
64
|
+
ignore: self.class.convert_coordinates(ignore, app_output.screenshot),
|
65
|
+
trim: trim,
|
66
|
+
match_level: match_level,
|
67
|
+
exact: exact
|
68
|
+
)
|
59
69
|
else
|
60
70
|
app_output = app_output_provider.app_output region_provider, last_screenshot
|
61
71
|
start = Time.now
|
62
|
-
match_result = perform_match
|
72
|
+
match_result = perform_match(
|
73
|
+
user_inputs: user_inputs,
|
74
|
+
app_output: app_output,
|
75
|
+
tag: tag,
|
76
|
+
ignore_mismatch: true,
|
77
|
+
ignore: self.class.convert_coordinates(ignore, app_output.screenshot),
|
78
|
+
trim: trim,
|
79
|
+
match_level: match_level,
|
80
|
+
exact: exact
|
81
|
+
)
|
63
82
|
retry_time = Time.now - start
|
64
83
|
|
65
84
|
while retry_time < retry_timeout && !match_result.as_expected?
|
66
85
|
sleep MATCH_INTERVAL
|
67
86
|
app_output = app_output_provider.app_output region_provider, last_screenshot
|
68
|
-
match_result = perform_match
|
87
|
+
match_result = perform_match(
|
88
|
+
user_inputs: user_inputs,
|
89
|
+
app_output: app_output,
|
90
|
+
tag: tag,
|
91
|
+
ignore_mismatch: true,
|
92
|
+
ignore: self.class.convert_coordinates(ignore, app_output.screenshot),
|
93
|
+
trim: trim,
|
94
|
+
match_level: match_level,
|
95
|
+
exact: exact
|
96
|
+
)
|
69
97
|
retry_time = Time.now - start
|
70
98
|
end
|
71
99
|
|
72
100
|
unless match_result.as_expected?
|
73
101
|
app_output = app_output_provider.app_output region_provider, last_screenshot
|
74
|
-
match_result = perform_match
|
75
|
-
|
102
|
+
match_result = perform_match(
|
103
|
+
user_inputs: user_inputs,
|
104
|
+
app_output: app_output,
|
105
|
+
tag: tag,
|
106
|
+
ignore_mismatch: ignore_mismatch,
|
107
|
+
ignore: self.class.convert_coordinates(ignore, app_output.screenshot),
|
108
|
+
trim: trim,
|
109
|
+
match_level: match_level,
|
110
|
+
exact: exact
|
111
|
+
)
|
76
112
|
end
|
77
113
|
end
|
78
114
|
|
@@ -95,7 +131,10 @@ module Applitools
|
|
95
131
|
tag: tag, user_inputs: user_inputs.to_hash, ignore_mismatch: ignore_mismatch, ignore_match: false,
|
96
132
|
force_mistmatch: false, force_match: false,
|
97
133
|
image_match_settings: {
|
98
|
-
|
134
|
+
matchLevel: options[:match_level],
|
135
|
+
ignore: options[:ignore],
|
136
|
+
ignoreCaret: options[:ignore_caret].nil? ? true : options[:ignore_caret],
|
137
|
+
exact: options[:exact]
|
99
138
|
},
|
100
139
|
trim: {
|
101
140
|
enabled: options[:trim]
|
@@ -58,6 +58,53 @@ module Applitools::Images
|
|
58
58
|
abort_if_not_closed
|
59
59
|
end
|
60
60
|
|
61
|
+
def check(name, target)
|
62
|
+
Applitools::ArgumentGuard.not_nil(name, 'name')
|
63
|
+
region_provider = get_region_provider(target)
|
64
|
+
|
65
|
+
image = target.image
|
66
|
+
self.viewport_size = Applitools::RectangleSize.new image.width, image.height if viewport_size.nil?
|
67
|
+
self.screenshot = EyesImagesScreenshot.new image
|
68
|
+
|
69
|
+
mr = check_window_base(
|
70
|
+
region_provider, name, false,
|
71
|
+
target.options[:timeout] || Applitools::EyesBase::USE_DEFAULT_TIMEOUT,
|
72
|
+
ignore: target.ignored_regions,
|
73
|
+
trim: target.options[:trim],
|
74
|
+
match_level: default_match_settings[:match_level],
|
75
|
+
exact: default_match_settings[:exact]
|
76
|
+
)
|
77
|
+
mr.as_expected?
|
78
|
+
end
|
79
|
+
|
80
|
+
def get_region_provider(target)
|
81
|
+
if (region_to_check = target.region_to_check).nil?
|
82
|
+
Object.new.tap do |prov|
|
83
|
+
prov.instance_eval do
|
84
|
+
define_singleton_method :region do
|
85
|
+
Applitools::Region::EMPTY
|
86
|
+
end
|
87
|
+
|
88
|
+
define_singleton_method :coordinate_type do
|
89
|
+
nil
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
else
|
94
|
+
Object.new.tap do |prov|
|
95
|
+
prov.instance_eval do
|
96
|
+
define_singleton_method :region do
|
97
|
+
region_to_check
|
98
|
+
end
|
99
|
+
|
100
|
+
define_singleton_method :coordinate_type do
|
101
|
+
Applitools::EyesScreenshot::COORDINATE_TYPES[:context_relative]
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
61
108
|
# Matches the input image with the next expected image. Takes a hash as an argument. Returns +boolean+
|
62
109
|
# as result of matching.
|
63
110
|
# @param [Hash] options
|
@@ -0,0 +1,87 @@
|
|
1
|
+
module Applitools::Images
|
2
|
+
class Target
|
3
|
+
class << self
|
4
|
+
def path(path)
|
5
|
+
raise Applitools::EyesIllegalArgument unless File.exist?(path)
|
6
|
+
new Applitools::Screenshot.from_image(ChunkyPNG::Image.from_file(path))
|
7
|
+
end
|
8
|
+
|
9
|
+
def blob(blob_image)
|
10
|
+
Applitools::ArgumentGuard.not_nil blob_image, 'blob_image'
|
11
|
+
Applitools::ArgumentGuard.is_a? blob_image, 'blob_image', String
|
12
|
+
new Applitools::Screenshot.from_datastream(blob_image)
|
13
|
+
end
|
14
|
+
|
15
|
+
def image(image)
|
16
|
+
Applitools::ArgumentGuard.not_nil image, 'image'
|
17
|
+
Applitools::ArgumentGuard.is_a? image, 'image', ChunkyPNG::Image
|
18
|
+
new Applitools::Screenshot.from_image(image)
|
19
|
+
end
|
20
|
+
|
21
|
+
def screenshot(screenshot)
|
22
|
+
Applitools::ArgumentGuard.not_nil screenshot, 'screenshot'
|
23
|
+
Applitools::ArgumentGuard.is_a? screenshot, 'screenshot', Applitools::Screenshot
|
24
|
+
new screenshot
|
25
|
+
end
|
26
|
+
|
27
|
+
def any(screenshot)
|
28
|
+
case screenshot
|
29
|
+
when Applitools::Screenshot
|
30
|
+
screenshot(screenshot)
|
31
|
+
when ChunkyPNG::Image
|
32
|
+
image(screenshot)
|
33
|
+
when String
|
34
|
+
begin
|
35
|
+
blob(screenshot)
|
36
|
+
rescue ChunkyPNG::SignatureMismatch
|
37
|
+
path(screenshot)
|
38
|
+
end
|
39
|
+
else
|
40
|
+
raise Applitools::EyesIllegalArgument.new "Passed screenshot is not image type (#{screenshot.class})"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
attr_accessor :image, :options, :ignored_regions, :region_to_check
|
46
|
+
|
47
|
+
def initialize(image)
|
48
|
+
Applitools::ArgumentGuard.not_nil(image, 'image')
|
49
|
+
Applitools::ArgumentGuard.is_a? image, 'image', Applitools::Screenshot
|
50
|
+
self.image = image
|
51
|
+
self.ignored_regions = []
|
52
|
+
self.options = {
|
53
|
+
trim: false
|
54
|
+
}
|
55
|
+
end
|
56
|
+
|
57
|
+
def ignore(region = nil)
|
58
|
+
if region
|
59
|
+
Applitools::ArgumentGuard.is_a? region, 'region', Applitools::Region
|
60
|
+
ignored_regions << region
|
61
|
+
else
|
62
|
+
self.ignored_regions = []
|
63
|
+
end
|
64
|
+
self
|
65
|
+
end
|
66
|
+
|
67
|
+
def region(region = nil)
|
68
|
+
if region
|
69
|
+
Applitools::ArgumentGuard.is_a? region, 'region', Applitools::Region
|
70
|
+
self.region_to_check = region
|
71
|
+
else
|
72
|
+
self.region_to_check = nil
|
73
|
+
end
|
74
|
+
self
|
75
|
+
end
|
76
|
+
|
77
|
+
def trim(value = true)
|
78
|
+
options[:trim] = value ? true : false
|
79
|
+
self
|
80
|
+
end
|
81
|
+
|
82
|
+
def timeout(value = nil)
|
83
|
+
options[:timeout] = value ? value : nil
|
84
|
+
self
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
data/lib/applitools/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: eyes_core
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.
|
4
|
+
version: 3.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Applitools Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-04-
|
11
|
+
date: 2017-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oily_png
|
@@ -237,6 +237,7 @@ files:
|
|
237
237
|
- lib/applitools/eyes_logger.rb
|
238
238
|
- lib/applitools/images/eyes.rb
|
239
239
|
- lib/applitools/images/eyes_images_screenshot.rb
|
240
|
+
- lib/applitools/images/target.rb
|
240
241
|
- lib/applitools/method_tracer.rb
|
241
242
|
- lib/applitools/sauce.rb
|
242
243
|
- lib/applitools/utils/eyes_selenium_utils.rb
|