eyes_core 3.17.16 → 3.17.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/applitools/core/app_output.rb +16 -2
- data/lib/applitools/core/batch_info.rb +5 -3
- data/lib/applitools/core/eyes_base.rb +29 -30
- data/lib/applitools/core/match_window_data.rb +10 -0
- data/lib/applitools/core/match_window_task.rb +20 -26
- data/lib/applitools/core/screenshot.rb +9 -0
- data/lib/applitools/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bec0e3de9fa596430d8a46e5274359fafb24bf610223181263cc74c7da18cc74
|
4
|
+
data.tar.gz: 2949d1c8638ecb578569fd55b69e3eaafdfc81fd7ad05cd35f0f5dc9c17bba7e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d79a7817840dafdd6102d6442a71f63fd5db7885e6de70432d9fd0f43c66805f533e0c439f25330253ca17b87e05c752996ea6001a0a63ecb5b74e690704780a
|
7
|
+
data.tar.gz: 214446f6d9a8e1fafe461970f560a9b65d353578a820ad18fb0dae523752f0dd7f3eab74ca530d2400198f97d9f7f5731f79bbf77e85d4949b051c7940607b5b
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
module Applitools
|
4
4
|
class AppOutput
|
5
|
-
attr_reader :title, :screenshot64, :location
|
5
|
+
attr_reader :title, :screenshot64, :location, :screenshot_url_getter, :dom_url_getter
|
6
6
|
|
7
7
|
attr_accessor :dom_url, :screenshot_url, :visual_viewport
|
8
8
|
|
@@ -10,6 +10,8 @@ module Applitools
|
|
10
10
|
@title = title
|
11
11
|
@screenshot64 = screenshot64
|
12
12
|
@location = Applitools::Location::TOP_LEFT
|
13
|
+
@screenshot_url_getter = nil
|
14
|
+
@dom_url_getter = nil
|
13
15
|
end
|
14
16
|
|
15
17
|
def location=(value)
|
@@ -17,12 +19,24 @@ module Applitools
|
|
17
19
|
@location = value
|
18
20
|
end
|
19
21
|
|
22
|
+
def on_need_screenshot_url(&block)
|
23
|
+
@screenshot_url_getter = block if block_given?
|
24
|
+
end
|
25
|
+
|
26
|
+
def on_need_dom_url(&block)
|
27
|
+
@dom_url_getter = block if block_given?
|
28
|
+
end
|
29
|
+
|
30
|
+
def dom_url
|
31
|
+
@dom_url ||= (@dom_url_getter && @dom_url_getter.call)
|
32
|
+
end
|
33
|
+
|
20
34
|
def to_hash
|
21
35
|
result = {
|
22
36
|
Title: title,
|
23
37
|
Screenshot64: nil,
|
24
38
|
Location: location.to_hash,
|
25
|
-
ScreenshotUrl: screenshot_url
|
39
|
+
ScreenshotUrl: screenshot_url || (screenshot_url_getter && screenshot_url_getter.call)
|
26
40
|
}
|
27
41
|
result[:DomUrl] = dom_url if dom_url
|
28
42
|
result[:visualViewport] = visual_viewport if visual_viewport
|
@@ -6,17 +6,19 @@ require_relative 'helpers'
|
|
6
6
|
module Applitools
|
7
7
|
class BatchInfo
|
8
8
|
extend Helpers
|
9
|
-
attr_accessor :started_at, :id
|
9
|
+
attr_accessor :started_at, :id, :notify_on_completion
|
10
10
|
|
11
11
|
environment_attribute :name, 'APPLITOOLS_BATCH_NAME'
|
12
12
|
environment_attribute :id, 'APPLITOOLS_BATCH_ID'
|
13
13
|
environment_attribute :sequence_name, 'APPLITOOLS_BATCH_SEQUENCE'
|
14
|
-
environment_attribute :
|
14
|
+
environment_attribute :env_notify_on_completion, 'APPLITOOLS_BATCH_NOTIFY'
|
15
|
+
|
15
16
|
|
16
17
|
def initialize(name = nil, started_at = Time.now)
|
17
18
|
self.name = name if name
|
18
19
|
@started_at = started_at
|
19
20
|
self.id = SecureRandom.uuid unless id
|
21
|
+
self.notify_on_completion = 'true'.casecmp(env_notify_on_completion || '') == 0 ? true : false
|
20
22
|
end
|
21
23
|
|
22
24
|
def json_data
|
@@ -25,7 +27,7 @@ module Applitools
|
|
25
27
|
'name' => name,
|
26
28
|
'startedAt' => @started_at.iso8601,
|
27
29
|
'batchSequenceName' => sequence_name,
|
28
|
-
'notifyOnCompletion' =>
|
30
|
+
'notifyOnCompletion' => notify_on_completion
|
29
31
|
}
|
30
32
|
end
|
31
33
|
|
@@ -280,7 +280,6 @@ module Applitools
|
|
280
280
|
self.last_screenshot = result.screenshot
|
281
281
|
end
|
282
282
|
|
283
|
-
self.should_match_window_run_once_on_timeout = true
|
284
283
|
self.failed = true
|
285
284
|
logger.info "Mistmatch! #{tag}" unless running_session.new_session?
|
286
285
|
|
@@ -614,27 +613,7 @@ module Applitools
|
|
614
613
|
end
|
615
614
|
|
616
615
|
def get_app_output_with_screenshot(region_provider, _last_screenshot)
|
617
|
-
dom_url = ''
|
618
616
|
captured_dom_data = dom_data
|
619
|
-
unless captured_dom_data.empty?
|
620
|
-
begin
|
621
|
-
logger.info 'Processing DOM..'
|
622
|
-
dom_url = server_connector.post_dom_json(captured_dom_data, runner.rendering_info(server_connector)) do |json|
|
623
|
-
io = StringIO.new
|
624
|
-
gz = Zlib::GzipWriter.new(io)
|
625
|
-
gz.write(json.encode('UTF-8'))
|
626
|
-
gz.close
|
627
|
-
result = io.string
|
628
|
-
io.close
|
629
|
-
result
|
630
|
-
end
|
631
|
-
logger.info 'Done'
|
632
|
-
logger.info dom_url
|
633
|
-
rescue Applitools::EyesError => e
|
634
|
-
logger.warn e.message
|
635
|
-
dom_url = nil
|
636
|
-
end
|
637
|
-
end
|
638
617
|
logger.info 'Getting screenshot...'
|
639
618
|
screenshot = capture_screenshot
|
640
619
|
logger.info 'Done getting screenshot!'
|
@@ -646,21 +625,41 @@ module Applitools
|
|
646
625
|
|
647
626
|
screenshot = yield(screenshot) if block_given?
|
648
627
|
|
649
|
-
if screenshot
|
650
|
-
self.screenshot_url = server_connector.put_screenshot(
|
651
|
-
runner.rendering_info(server_connector),
|
652
|
-
screenshot
|
653
|
-
)
|
654
|
-
end
|
655
|
-
|
656
628
|
logger.info 'Getting title...'
|
657
629
|
a_title = title
|
658
630
|
logger.info 'Done!'
|
659
631
|
Applitools::AppOutputWithScreenshot.new(
|
660
632
|
Applitools::AppOutput.new(a_title, screenshot).tap do |o|
|
661
633
|
o.location = region.location unless region.empty?
|
662
|
-
o.
|
663
|
-
|
634
|
+
o.on_need_screenshot_url do
|
635
|
+
return unless screenshot
|
636
|
+
server_connector.put_screenshot(
|
637
|
+
runner.rendering_info(server_connector),
|
638
|
+
screenshot
|
639
|
+
)
|
640
|
+
end
|
641
|
+
o.on_need_dom_url do
|
642
|
+
unless captured_dom_data.empty?
|
643
|
+
begin
|
644
|
+
logger.info 'Processing DOM..'
|
645
|
+
dom_url = server_connector.post_dom_json(captured_dom_data, runner.rendering_info(server_connector)) do |json|
|
646
|
+
io = StringIO.new
|
647
|
+
gz = Zlib::GzipWriter.new(io)
|
648
|
+
gz.write(json.encode('UTF-8'))
|
649
|
+
gz.close
|
650
|
+
result = io.string
|
651
|
+
io.close
|
652
|
+
result
|
653
|
+
end
|
654
|
+
logger.info 'Done'
|
655
|
+
logger.info dom_url
|
656
|
+
rescue Applitools::EyesError => e
|
657
|
+
logger.warn e.message
|
658
|
+
dom_url = nil
|
659
|
+
end
|
660
|
+
dom_url
|
661
|
+
end
|
662
|
+
end
|
664
663
|
end,
|
665
664
|
screenshot,
|
666
665
|
allow_empty_screenshot
|
@@ -24,6 +24,7 @@ module Applitools
|
|
24
24
|
'ForceMismatch' => false,
|
25
25
|
'IgnoreMatch' => false,
|
26
26
|
'IgnoreMismatch' => false,
|
27
|
+
'ReplaceLast' => false,
|
27
28
|
'Trim' => {
|
28
29
|
'Enabled' => false
|
29
30
|
},
|
@@ -313,6 +314,15 @@ module Applitools
|
|
313
314
|
current_data['IgnoreMismatch']
|
314
315
|
end
|
315
316
|
|
317
|
+
def replace_last
|
318
|
+
current_data['Options']['ReplaceLast']
|
319
|
+
end
|
320
|
+
|
321
|
+
def replace_last=(value)
|
322
|
+
Applitools::ArgumentGuard.one_of?(value, 'value', [TrueClass, FalseClass])
|
323
|
+
current_data['Options']['ReplaceLast'] = value
|
324
|
+
end
|
325
|
+
|
316
326
|
def tag
|
317
327
|
current_data['Tag']
|
318
328
|
end
|
@@ -48,10 +48,11 @@ module Applitools
|
|
48
48
|
match_window_data.convert_strict_regions_coordinates
|
49
49
|
match_window_data.convert_content_regions_coordinates
|
50
50
|
match_window_data.convert_accessibility_regions_coordinates
|
51
|
+
match_window_data.replace_last = false
|
51
52
|
match_result = perform_match(match_window_data)
|
52
53
|
else
|
53
|
-
passed_ignore_mismatch = match_window_data.ignore_mismatch
|
54
54
|
app_output = app_output_provider.app_output(region_provider, last_screenshot)
|
55
|
+
last_image_digest = app_output.screenshot.image.sha256
|
55
56
|
match_window_data.app_output = app_output
|
56
57
|
match_window_data.convert_ignored_regions_coordinates
|
57
58
|
match_window_data.convert_floating_regions_coordinates
|
@@ -59,44 +60,37 @@ module Applitools
|
|
59
60
|
match_window_data.convert_strict_regions_coordinates
|
60
61
|
match_window_data.convert_content_regions_coordinates
|
61
62
|
match_window_data.convert_accessibility_regions_coordinates
|
62
|
-
match_window_data.
|
63
|
-
start = Time.now
|
63
|
+
match_window_data.replace_last = false
|
64
64
|
match_result = perform_match(match_window_data)
|
65
|
-
retry_time = Time.now - start
|
66
65
|
|
67
66
|
block_retry = if block_given?
|
68
67
|
yield(match_result)
|
69
68
|
else
|
70
69
|
false
|
71
70
|
end
|
71
|
+
start = Time.now
|
72
|
+
retry_time = 0
|
72
73
|
|
73
74
|
while retry_time < retry_timeout && !(block_retry || match_result.as_expected?)
|
74
75
|
sleep MATCH_INTERVAL
|
75
76
|
app_output = app_output_provider.app_output(region_provider, last_screenshot)
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
77
|
+
image_digest = app_output.screenshot.image.sha256
|
78
|
+
if image_digest == last_image_digest
|
79
|
+
logger.info('Got the same screenshot in retry. Not sending to the server.')
|
80
|
+
else
|
81
|
+
match_window_data.app_output = app_output
|
82
|
+
match_window_data.convert_ignored_regions_coordinates
|
83
|
+
match_window_data.convert_floating_regions_coordinates
|
84
|
+
match_window_data.convert_layout_regions_coordinates
|
85
|
+
match_window_data.convert_strict_regions_coordinates
|
86
|
+
match_window_data.convert_content_regions_coordinates
|
87
|
+
match_window_data.convert_accessibility_regions_coordinates
|
88
|
+
match_window_data.replace_last = true
|
89
|
+
match_result = perform_match(match_window_data)
|
90
|
+
end
|
91
|
+
last_image_digest = image_digest
|
85
92
|
retry_time = Time.now - start
|
86
93
|
end
|
87
|
-
|
88
|
-
unless block_retry || match_result.as_expected?
|
89
|
-
app_output = app_output_provider.app_output(region_provider, last_screenshot)
|
90
|
-
match_window_data.app_output = app_output
|
91
|
-
match_window_data.convert_ignored_regions_coordinates
|
92
|
-
match_window_data.convert_floating_regions_coordinates
|
93
|
-
match_window_data.convert_layout_regions_coordinates
|
94
|
-
match_window_data.convert_strict_regions_coordinates
|
95
|
-
match_window_data.convert_content_regions_coordinates
|
96
|
-
match_window_data.convert_accessibility_regions_coordinates
|
97
|
-
match_window_data.ignore_mismatch = passed_ignore_mismatch
|
98
|
-
match_result = perform_match(match_window_data)
|
99
|
-
end
|
100
94
|
end
|
101
95
|
|
102
96
|
logger.info "Completed in #{format('%.2f', Time.now - elapsed_time_start)} seconds"
|
@@ -1,4 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
+
require 'digest'
|
2
3
|
|
3
4
|
module Applitools
|
4
5
|
class Screenshot < Delegator
|
@@ -91,6 +92,10 @@ module Applitools
|
|
91
92
|
def restore
|
92
93
|
::ChunkyPNG::Image.from_datastream @datastream
|
93
94
|
end
|
95
|
+
|
96
|
+
def sha256
|
97
|
+
Digest::SHA2.new(256).hexdigest(@datastream.to_s)
|
98
|
+
end
|
94
99
|
end
|
95
100
|
|
96
101
|
class Image < self
|
@@ -115,6 +120,10 @@ module Applitools
|
|
115
120
|
def __setobj__(obj)
|
116
121
|
@image = obj
|
117
122
|
end
|
123
|
+
|
124
|
+
def sha256
|
125
|
+
Digest::SHA2.new(256).hexdigest(@image.to_datastream.to_s)
|
126
|
+
end
|
118
127
|
end
|
119
128
|
end
|
120
129
|
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.17.
|
4
|
+
version: 3.17.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Applitools Team
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-07-
|
11
|
+
date: 2020-07-29 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: oily_png
|