eyes_core 3.8.0 → 3.9.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.
- checksums.yaml +4 -4
- data/lib/applitools/connectivity/server_connector.rb +13 -3
- data/lib/applitools/core/eyes_base.rb +1 -1
- data/lib/applitools/core/floating_region.rb +35 -0
- data/lib/applitools/core/match_single_check_data.rb +4 -0
- data/lib/applitools/core/match_window_data.rb +54 -1
- data/lib/applitools/core/match_window_task.rb +4 -0
- data/lib/applitools/images/target.rb +18 -1
- 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: 3cd56839e5721775879c8103fe725889fd804eb6
|
4
|
+
data.tar.gz: 1a22c8653ccf48d6021b5d6416e2de18d55c98ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 024443174ee13d25181fbdd8f92fdc2daced4cbbf43394b189d7f22921c867d1e64e700f179c79d433072b5f390b065ecc3f37b2d992d8692b574066aa6cc109
|
7
|
+
data.tar.gz: ab4d97600d218dbd6f0920ae3230638c2c4b25898dd074176b548b86e76ac1bad15d16c3bef49309ba38f1052cca930c12b69a58e9c082c809b9ee13d05cd7e7
|
@@ -66,14 +66,19 @@ module Applitools::Connectivity
|
|
66
66
|
RETRY_STEP_FACTOR = 1.5
|
67
67
|
RETRY_MAX_DELAY = 5
|
68
68
|
|
69
|
-
def
|
69
|
+
def match_single_window_data(data)
|
70
70
|
# Notice that this does not include the screenshot.
|
71
71
|
json_data = Oj.dump(data.to_hash).force_encoding('BINARY')
|
72
72
|
body = [json_data.length].pack('L>') + json_data + data.screenshot
|
73
73
|
# Applitools::EyesLogger.debug json_data
|
74
74
|
begin
|
75
75
|
Applitools::EyesLogger.debug 'Sending match data...'
|
76
|
-
res = long_post(
|
76
|
+
res = long_post(
|
77
|
+
@single_check_endpoint_url,
|
78
|
+
content_type: 'application/octet-stream',
|
79
|
+
body: body,
|
80
|
+
query: { agent_id: data.agent_id }
|
81
|
+
)
|
77
82
|
rescue Errno::EWOULDBLOCK, Faraday::ConnectionFailed
|
78
83
|
@delays ||= request_delay(RETRY_DELAY, RETRY_STEP_FACTOR, RETRY_MAX_DELAY)
|
79
84
|
begin
|
@@ -81,11 +86,16 @@ module Applitools::Connectivity
|
|
81
86
|
rescue StopIteration
|
82
87
|
raise Applitools::UnknownNetworkStackError.new('Unknown network stack error')
|
83
88
|
end
|
84
|
-
res =
|
89
|
+
res = match_single_window_data(data)
|
85
90
|
ensure
|
86
91
|
@delays = nil
|
87
92
|
end
|
88
93
|
raise Applitools::EyesError.new("Request failed: #{res.status} #{res.headers} #{res.body}") unless res.success?
|
94
|
+
res
|
95
|
+
end
|
96
|
+
|
97
|
+
def match_single_window(data)
|
98
|
+
res = match_single_window_data(data)
|
89
99
|
Applitools::TestResults.new Oj.load(res.body)
|
90
100
|
end
|
91
101
|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require_relative 'region'
|
2
|
+
module Applitools
|
3
|
+
class FloatingRegion < Region
|
4
|
+
class << self
|
5
|
+
def for_element(element, max_left_offset, max_top_offset, max_right_offset, max_bottom_offset)
|
6
|
+
Applitools::ArgumentGuard.is_a? element, 'element', Applitools::Selenium::Element
|
7
|
+
new element.location.x, element.location.y, element.size.width, element.size.height, max_left_offset,
|
8
|
+
max_top_offset, max_right_offset, max_bottom_offset
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
attr_accessor :max_top_offset, :max_right_offset, :max_bottom_offset, :max_left_offset
|
13
|
+
|
14
|
+
def initialize(left, top, width, height, max_left_offset, max_top_offset, max_right_offset, max_bottom_offset)
|
15
|
+
super(left, top, width, height)
|
16
|
+
self.max_left_offset = max_left_offset
|
17
|
+
self.max_top_offset = max_top_offset
|
18
|
+
self.max_right_offset = max_right_offset
|
19
|
+
self.max_bottom_offset = max_bottom_offset
|
20
|
+
end
|
21
|
+
|
22
|
+
def to_hash
|
23
|
+
{
|
24
|
+
'Top' => top,
|
25
|
+
'Left' => left,
|
26
|
+
'Width' => width,
|
27
|
+
'Height' => height,
|
28
|
+
'MaxUpOffset' => max_top_offset,
|
29
|
+
'MaxLeftOffset' => max_left_offset,
|
30
|
+
'MaxRightOffset' => max_right_offset,
|
31
|
+
'MaxDownOffset' => max_bottom_offset
|
32
|
+
}
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -22,6 +22,7 @@ module Applitools
|
|
22
22
|
'SplitBottomHeight' => 0,
|
23
23
|
'IgnoreCaret' => false,
|
24
24
|
'Ignore' => [],
|
25
|
+
'Floating' => [],
|
25
26
|
'Exact' => {
|
26
27
|
'MinDiffIntensity' => 0,
|
27
28
|
'MinDiffWidth' => 0,
|
@@ -65,7 +66,9 @@ module Applitools
|
|
65
66
|
def initialize
|
66
67
|
@app_output = nil
|
67
68
|
@ignored_regions = []
|
69
|
+
@floating_regions = []
|
68
70
|
@need_convert_ignored_regions_coordinates = false
|
71
|
+
@need_convert_floating_regions_coordinates = false
|
69
72
|
end
|
70
73
|
|
71
74
|
def screenshot
|
@@ -97,6 +100,13 @@ module Applitools
|
|
97
100
|
end
|
98
101
|
end
|
99
102
|
|
103
|
+
def floating_regions=(value)
|
104
|
+
Applitools::ArgumentGuard.is_a? value, 'value', Array
|
105
|
+
value.each do |r|
|
106
|
+
current_data['Options']['ImageMatchSettings']['Floating'] << r.to_hash
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
100
110
|
def app_output=(value)
|
101
111
|
Applitools::ArgumentGuard.is_a? value, 'value', Applitools::AppOutputWithScreenshot
|
102
112
|
@app_output = value
|
@@ -116,7 +126,7 @@ module Applitools
|
|
116
126
|
|
117
127
|
def read_target(target, driver)
|
118
128
|
# options
|
119
|
-
|
129
|
+
target_options_to_read.each do |field|
|
120
130
|
send("#{field}=", target.options[field.to_sym])
|
121
131
|
end
|
122
132
|
# ignored regions
|
@@ -131,8 +141,28 @@ module Applitools
|
|
131
141
|
@need_convert_ignored_regions_coordinates = true
|
132
142
|
end
|
133
143
|
end
|
144
|
+
# floating regions
|
145
|
+
target.floating_regions.each do |r|
|
146
|
+
case r
|
147
|
+
when Proc
|
148
|
+
region = r.call(driver)
|
149
|
+
raise Applitools::EyesError.new "Wrong floating region: #{region.class}" unless
|
150
|
+
region.is_a? Applitools::FloatingRegion
|
151
|
+
@floating_regions << region
|
152
|
+
@need_convert_floating_regions_coordinates = true
|
153
|
+
when Applitools::FloatingRegion
|
154
|
+
@floating_regions << r
|
155
|
+
@need_convert_floating_regions_coordinates = true
|
156
|
+
end
|
157
|
+
end
|
134
158
|
end
|
135
159
|
|
160
|
+
def target_options_to_read
|
161
|
+
%w(trim ignore_caret)
|
162
|
+
end
|
163
|
+
|
164
|
+
private :target_options_to_read
|
165
|
+
|
136
166
|
def ignore_mismatch
|
137
167
|
current_data['IgnoreMismatch']
|
138
168
|
end
|
@@ -145,6 +175,10 @@ module Applitools
|
|
145
175
|
current_data['Options']['Trim']['Enabled'] = value ? true : false
|
146
176
|
end
|
147
177
|
|
178
|
+
def ignore_caret=(value)
|
179
|
+
current_data['Options']['ImageMatchSettings']['IgnoreCaret'] = value
|
180
|
+
end
|
181
|
+
|
148
182
|
def convert_ignored_regions_coordinates
|
149
183
|
return unless @need_convert_ignored_regions_coordinates
|
150
184
|
self.ignored_regions = @ignored_regions.map do |r|
|
@@ -153,12 +187,31 @@ module Applitools
|
|
153
187
|
@need_convert_ignored_regions_coordinates = false
|
154
188
|
end
|
155
189
|
|
190
|
+
def convert_floating_regions_coordinates
|
191
|
+
return unless @need_convert_floating_regions_coordinates
|
192
|
+
self.floating_regions = @floating_regions.map do |r|
|
193
|
+
r.location = app_output.screenshot.convert_location(
|
194
|
+
r.location,
|
195
|
+
Applitools::EyesScreenshot::COORDINATE_TYPES[:context_relative],
|
196
|
+
Applitools::EyesScreenshot::COORDINATE_TYPES[:screenshot_as_is]
|
197
|
+
)
|
198
|
+
r.to_hash
|
199
|
+
end
|
200
|
+
@need_convert_floating_regions_coordinates = false
|
201
|
+
end
|
202
|
+
|
156
203
|
def to_hash
|
157
204
|
if @need_convert_ignored_regions_coordinates
|
158
205
|
raise Applitools::EyesError.new(
|
159
206
|
'You should convert coordinates for ignored_regions!'
|
160
207
|
)
|
161
208
|
end
|
209
|
+
|
210
|
+
if @need_convert_floating_regions_coordinates
|
211
|
+
raise Applitools::EyesError.new(
|
212
|
+
'You should convert coordinates for floating_regions!'
|
213
|
+
)
|
214
|
+
end
|
162
215
|
current_data.dup
|
163
216
|
end
|
164
217
|
|
@@ -41,12 +41,14 @@ module Applitools
|
|
41
41
|
app_output = app_output_provider.app_output(region_provider, last_screenshot)
|
42
42
|
match_window_data.app_output = app_output
|
43
43
|
match_window_data.convert_ignored_regions_coordinates
|
44
|
+
match_window_data.convert_floating_regions_coordinates
|
44
45
|
match_result = perform_match(match_window_data)
|
45
46
|
else
|
46
47
|
passed_ignore_mismatch = match_window_data.ignore_mismatch
|
47
48
|
app_output = app_output_provider.app_output(region_provider, last_screenshot)
|
48
49
|
match_window_data.app_output = app_output
|
49
50
|
match_window_data.convert_ignored_regions_coordinates
|
51
|
+
match_window_data.convert_floating_regions_coordinates
|
50
52
|
match_window_data.ignore_mismatch = true
|
51
53
|
start = Time.now
|
52
54
|
match_result = perform_match(match_window_data)
|
@@ -63,6 +65,7 @@ module Applitools
|
|
63
65
|
app_output = app_output_provider.app_output(region_provider, last_screenshot)
|
64
66
|
match_window_data.app_output = app_output
|
65
67
|
match_window_data.convert_ignored_regions_coordinates
|
68
|
+
match_window_data.convert_floating_regions_coordinates
|
66
69
|
match_window_data.ignore_mismatch = true
|
67
70
|
match_result = perform_match(match_window_data)
|
68
71
|
retry_time = Time.now - start
|
@@ -72,6 +75,7 @@ module Applitools
|
|
72
75
|
app_output = app_output_provider.app_output(region_provider, last_screenshot)
|
73
76
|
match_window_data.app_output = app_output
|
74
77
|
match_window_data.convert_ignored_regions_coordinates
|
78
|
+
match_window_data.convert_floating_regions_coordinates
|
75
79
|
match_window_data.ignore_mismatch = passed_ignore_mismatch
|
76
80
|
match_result = perform_match(match_window_data)
|
77
81
|
end
|
@@ -42,13 +42,14 @@ module Applitools::Images
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
attr_accessor :image, :options, :ignored_regions, :region_to_check
|
45
|
+
attr_accessor :image, :options, :ignored_regions, :region_to_check, :floating_regions
|
46
46
|
|
47
47
|
def initialize(image)
|
48
48
|
Applitools::ArgumentGuard.not_nil(image, 'image')
|
49
49
|
Applitools::ArgumentGuard.is_a? image, 'image', Applitools::Screenshot
|
50
50
|
self.image = image
|
51
51
|
self.ignored_regions = []
|
52
|
+
self.floating_regions = []
|
52
53
|
self.options = {
|
53
54
|
trim: false
|
54
55
|
}
|
@@ -64,6 +65,22 @@ module Applitools::Images
|
|
64
65
|
self
|
65
66
|
end
|
66
67
|
|
68
|
+
def floating(*args)
|
69
|
+
value = case args.first
|
70
|
+
when Applitools::FloatingRegion
|
71
|
+
proc { args.first }
|
72
|
+
when Applitools::Region
|
73
|
+
proc do
|
74
|
+
region = args.shift
|
75
|
+
Applitools::FloatingRegion.new region.left, region.top, region.width, region.height, *args
|
76
|
+
end
|
77
|
+
else
|
78
|
+
self.floating_regions = []
|
79
|
+
end
|
80
|
+
floating_regions << value
|
81
|
+
self
|
82
|
+
end
|
83
|
+
|
67
84
|
def region(region = nil)
|
68
85
|
if region
|
69
86
|
Applitools::ArgumentGuard.is_a? region, 'region', Applitools::Region
|
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.9.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-05-
|
11
|
+
date: 2017-05-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oily_png
|
@@ -217,6 +217,7 @@ files:
|
|
217
217
|
- lib/applitools/core/eyes_screenshot.rb
|
218
218
|
- lib/applitools/core/fixed_cut_provider.rb
|
219
219
|
- lib/applitools/core/fixed_scale_provider.rb
|
220
|
+
- lib/applitools/core/floating_region.rb
|
220
221
|
- lib/applitools/core/hash_extension.rb
|
221
222
|
- lib/applitools/core/helpers.rb
|
222
223
|
- lib/applitools/core/location.rb
|