eyes_core 3.6.5 → 3.6.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 1ce8c72d9ec9b74d08d2043166edd0fef0c4b0d8
4
- data.tar.gz: 2af38568fe334e350dd825bee647885c86d2a161
3
+ metadata.gz: d0af160a9d4c23132f0157a2f7c1f9c3e6ee5a70
4
+ data.tar.gz: b784261c4ab25b34cb427b86a5c5ed516c34db5b
5
5
  SHA512:
6
- metadata.gz: d5d333ccc6d22588c916b6da27fb204ce7206df52fe0480207d1a54e91637a3edfcfc6bfc40e962fb1bf277ca5a0aa771de646089f8e997b67159cb5216758d7
7
- data.tar.gz: b6d7879dd36ccfa121a7b7bdf4a0ae4db298063ca580e588da69657495fcb0fd36dd19e916d2e0c987b3077b9a6236dd37c430a6b4ac2ca93266049c6fdf51f9
6
+ metadata.gz: 3f071a1df3b3d861ab0d898f83c1d894efdb6a47e33c28b85424472f958bd6bc18b06cd226941fa93d70fa36dd7574533c8716b5f1903f1494b39ed2882f427d
7
+ data.tar.gz: 39f1310318b3ac8c2c8aae040c8f4ce12fd606944849580d7f1a566840e50fa71636ecb6c667dbefc1bdec37ac4fe573457ef2d004f467f3f36df08fb6ef4bc9
@@ -5,12 +5,9 @@ Oj.default_options = { :mode => :compat }
5
5
  require 'uri'
6
6
 
7
7
  module Applitools::Connectivity
8
- module ServerConnector
9
- extend self
10
-
8
+ class ServerConnector
11
9
  DEFAULT_SERVER_URL = 'https://eyessdk.applitools.com'.freeze
12
10
 
13
-
14
11
  SSL_CERT = File.join(File.dirname(File.expand_path(__FILE__)), '../../../certs/cacert.pem').to_s.freeze
15
12
  DEFAULT_TIMEOUT = 300
16
13
 
@@ -26,6 +23,10 @@ module Applitools::Connectivity
26
23
  attr_reader :endpoint_url
27
24
  attr_reader :proxy
28
25
 
26
+ def initialize(url = nil)
27
+ self.server_url = url
28
+ end
29
+
29
30
  def server_url=(url)
30
31
  @server_url = url.nil? ? DEFAULT_SERVER_URL : url
31
32
  unless @server_url.is_a? String
@@ -53,7 +54,7 @@ module Applitools::Connectivity
53
54
  json_data = Oj.dump(Applitools::Utils.camelcase_hash_keys(data.to_hash)).force_encoding('BINARY')
54
55
  body = [json_data.length].pack('L>') + json_data + data.screenshot
55
56
  Applitools::EyesLogger.debug 'Sending match data...'
56
- #Applitools::EyesLogger.debug json_data
57
+ # Applitools::EyesLogger.debug json_data
57
58
  res = post(URI.join(endpoint_url, session.id.to_s), content_type: 'application/octet-stream', body: body)
58
59
  raise Applitools::EyesError.new("Request failed: #{res.status} #{res.headers}") unless res.success?
59
60
  Applitools::MatchResult.new Oj.load(res.body)
@@ -139,7 +140,5 @@ module Applitools::Connectivity
139
140
  delay = [MAX_LONG_REQUEST_DELAY, (delay * LONG_REQUEST_DELAY_MULTIPLICATIVE_INCREASE_FACTOR).round].min
140
141
  end
141
142
  end
142
-
143
- include Applitools::MethodTracer
144
143
  end
145
144
  end
@@ -1,7 +1,8 @@
1
1
  require 'securerandom'
2
+
2
3
  module Applitools
3
4
  class BatchInfo
4
- attr_accessor :name, :sterted_at, :id
5
+ attr_accessor :name, :started_at, :id
5
6
  def initialize(name = nil, started_at = Time.now)
6
7
  @name = name
7
8
  @started_at = started_at
@@ -22,7 +22,7 @@ module Applitools
22
22
  CONTEXT_RELATIVE = Applitools::EyesScreenshot::COORDINATE_TYPES[:context_relative].freeze
23
23
 
24
24
  def_delegators 'Applitools::EyesLogger', :logger, :log_handler, :log_handler=
25
- def_delegators 'Applitools::Connectivity::ServerConnector', :api_key, :api_key=, :server_url, :server_url=,
25
+ def_delegators '@server_connector', :api_key, :api_key=, :server_url, :server_url=,
26
26
  :set_proxy, :proxy, :proxy=
27
27
 
28
28
  # @!attribute [rw] verbose_results
@@ -42,7 +42,7 @@ module Applitools
42
42
  abstract_method :get_viewport_size, true
43
43
 
44
44
  def initialize(server_url = nil)
45
- Applitools::Connectivity::ServerConnector.server_url = server_url
45
+ self.server_connector = Applitools::Connectivity::ServerConnector.new(server_url)
46
46
  self.disabled = false
47
47
  @viewport_size = nil
48
48
  self.match_timeout = DEFAULT_MATCH_TIMEOUT
@@ -124,7 +124,7 @@ module Applitools
124
124
  end
125
125
 
126
126
  logger.info 'Aborting server session...'
127
- Applitools::Connectivity::ServerConnector.stop_session(running_session, true, false)
127
+ server_connector.stop_session(running_session, true, false)
128
128
  logger.info '---Test aborted'
129
129
 
130
130
  rescue Applitools::EyesError => e
@@ -184,7 +184,10 @@ module Applitools
184
184
  raise Applitools::EyesError.new 'Eyes not open' unless open?
185
185
  Applitools::ArgumentGuard.not_nil region_provider, 'region_provider'
186
186
 
187
- logger.info "check_window_base(#{region_provider}, #{match_window_data.tag}, #{match_window_data.ignore_mismatch}, #{retry_timeout})"
187
+ logger.info(
188
+ "check_window_base(#{region_provider}, #{match_window_data.tag}, #{match_window_data.ignore_mismatch}," \
189
+ " #{retry_timeout})"
190
+ )
188
191
 
189
192
  tag = '' if tag.nil?
190
193
 
@@ -196,16 +199,18 @@ module Applitools
196
199
  logger,
197
200
  running_session,
198
201
  match_timeout,
199
- app_output_provider
202
+ app_output_provider,
203
+ server_connector
200
204
  )
201
205
  end
202
206
 
203
207
  logger.info 'Calling match_window...'
204
- result = @match_window_task.match_window(match_window_data,
208
+ result = @match_window_task.match_window(
209
+ match_window_data,
205
210
  last_screenshot: last_screenshot,
206
211
  region_provider: region_provider,
207
212
  should_match_window_run_once_on_timeout: should_match_window_run_once_on_timeout,
208
- retry_timeout: retry_timeout,
213
+ retry_timeout: retry_timeout
209
214
  )
210
215
  logger.info 'match_window done!'
211
216
 
@@ -232,7 +237,6 @@ module Applitools
232
237
  result
233
238
  end
234
239
 
235
-
236
240
  def check_single_base(region_provider, retry_timeout, match_window_data)
237
241
  if disabled?
238
242
  logger.info "#{__method__} Ignored"
@@ -244,7 +248,10 @@ module Applitools
244
248
  raise Applitools::EyesError.new 'Eyes not open' unless open?
245
249
  Applitools::ArgumentGuard.not_nil region_provider, 'region_provider'
246
250
 
247
- logger.info "check_single_base(#{region_provider}, #{match_window_data.tag}, #{match_window_data.ignore_mismatch}, #{retry_timeout})"
251
+ logger.info(
252
+ "check_single_base(#{region_provider}, #{match_window_data.tag}, #{match_window_data.ignore_mismatch}," \
253
+ " #{retry_timeout})"
254
+ )
248
255
 
249
256
  tag = '' if tag.nil?
250
257
 
@@ -258,17 +265,19 @@ module Applitools
258
265
  match_window_data.update_baseline_if_new = save_new_tests
259
266
  match_window_data.update_baseline_if_different = save_failed_tests
260
267
  match_window_task = Applitools::MatchSingleTask.new(
261
- logger,
262
- match_timeout,
263
- app_output_provider
268
+ logger,
269
+ match_timeout,
270
+ app_output_provider,
271
+ server_connector
264
272
  )
265
273
 
266
274
  logger.info 'Calling match_window...'
267
- result = match_window_task.match_window(match_window_data,
268
- last_screenshot: last_screenshot,
269
- region_provider: region_provider,
270
- should_match_window_run_once_on_timeout: should_match_window_run_once_on_timeout,
271
- retry_timeout: retry_timeout,
275
+ result = match_window_task.match_window(
276
+ match_window_data,
277
+ last_screenshot: last_screenshot,
278
+ region_provider: region_provider,
279
+ should_match_window_run_once_on_timeout: should_match_window_run_once_on_timeout,
280
+ retry_timeout: retry_timeout
272
281
  ) do |match_results|
273
282
  results = match_results.original_results
274
283
  not_aborted = !results['isAborted']
@@ -336,7 +345,7 @@ module Applitools
336
345
 
337
346
  logger.info "Automatically save test? #{save}"
338
347
 
339
- results = Applitools::Connectivity::ServerConnector.stop_session running_session, false, save
348
+ results = server_connector.stop_session running_session, false, save
340
349
 
341
350
  results.is_new = is_new_session
342
351
  results.url = session_results_url
@@ -370,7 +379,8 @@ module Applitools
370
379
  private
371
380
 
372
381
  attr_accessor :running_session, :last_screenshot, :current_app_name, :test_name, :session_type,
373
- :scale_provider, :session_start_info, :should_match_window_run_once_on_timeout, :app_output_provider, :failed
382
+ :scale_provider, :session_start_info, :should_match_window_run_once_on_timeout, :app_output_provider,
383
+ :failed, :server_connector
374
384
 
375
385
  attr_reader :user_inputs
376
386
 
@@ -489,7 +499,7 @@ module Applitools
489
499
  branch_name: branch_name, parent_branch_name: parent_branch_name
490
500
 
491
501
  logger.info 'Starting server session...'
492
- self.running_session = Applitools::Connectivity::ServerConnector.start_session session_start_info
502
+ self.running_session = server_connector.start_session session_start_info
493
503
 
494
504
  logger.info "Server session ID is #{running_session.id}"
495
505
  test_info = "'#{test_name}' of '#{app_name}' #{app_env}"
@@ -21,6 +21,13 @@ module Applitools
21
21
  abstract_method :location_in_screenshot, false
22
22
  abstract_method :intersected_region, false
23
23
 
24
+ def sub_screenshots(regions, coordinate_type)
25
+ Applitools::ArgumentGuard.is_a? regions, 'regions', Enumerable
26
+ regions.map do |region|
27
+ sub_screenshot(region, coordinate_type, false, true)
28
+ end
29
+ end
30
+
24
31
  def convert_region_location(region, from, to)
25
32
  Applitools::ArgumentGuard.not_nil region, 'region'
26
33
  Applitools::ArgumentGuard.is_a? region, 'region', Applitools::Region
@@ -4,59 +4,59 @@ module Applitools
4
4
  class << self
5
5
  def default_data
6
6
  {
7
- 'startInfo' => {
8
- 'agentId' => nil,
9
- 'appIdOrName' => nil,
10
- 'verId' => nil,
11
- 'scenarioIdOrName' => nil,
12
- 'batchInfo' => {},
13
- 'envName' => nil,
14
- 'environment' => {},
15
- 'defaultMatchSettings' => nil,
16
- 'branchName' => nil,
17
- 'parentBranchName' => nil
18
- },
19
- 'IgnoreMismatch' => false,
20
- 'MismatchWait' => 0,
21
- 'Options' => {
22
- 'Name' => nil,
23
- 'UserInputs' => [],
24
- 'ImageMatchSettings' => {
25
- 'MatchLevel' => 'None',
26
- 'SplitTopHeight' => 0,
27
- 'SplitBottomHeight' => 0,
28
- 'IgnoreCaret' => false,
29
- 'Ignore' => [],
30
- 'Exact' => {
31
- 'MinDiffIntensity' => 0,
32
- 'MinDiffWidth' => 0,
33
- 'MinDiffHeight' => 0,
34
- 'MatchThreshold' => 0
35
- }
36
- },
37
- 'IgnoreExpectedOutputSettings' => false,
38
- 'ForceMatch' => false,
39
- 'ForceMismatch' => false,
40
- 'IgnoreMatch' => false,
41
- 'IgnoreMismatch' => false,
42
- 'Trim' => {
43
- 'Enabled' => false,
44
- 'ForegroundIntensity' => 0,
45
- 'MinEdgeLength' => 0
46
- }
47
- },
48
- 'Id' => nil,
7
+ 'startInfo' => {
8
+ 'agentId' => nil,
9
+ 'appIdOrName' => nil,
10
+ 'verId' => nil,
11
+ 'scenarioIdOrName' => nil,
12
+ 'batchInfo' => {},
13
+ 'envName' => nil,
14
+ 'environment' => {},
15
+ 'defaultMatchSettings' => nil,
16
+ 'branchName' => nil,
17
+ 'parentBranchName' => nil
18
+ },
19
+ 'IgnoreMismatch' => false,
20
+ 'MismatchWait' => 0,
21
+ 'Options' => {
22
+ 'Name' => nil,
49
23
  'UserInputs' => [],
50
- 'AppOutput' => {
51
- 'Screenshot64' => nil,
52
- 'ScreenshotUrl' => nil,
53
- 'Title' => nil,
54
- 'IsPrimary' => false,
55
- 'Elapsed' => 0
24
+ 'ImageMatchSettings' => {
25
+ 'MatchLevel' => 'None',
26
+ 'SplitTopHeight' => 0,
27
+ 'SplitBottomHeight' => 0,
28
+ 'IgnoreCaret' => false,
29
+ 'Ignore' => [],
30
+ 'Exact' => {
31
+ 'MinDiffIntensity' => 0,
32
+ 'MinDiffWidth' => 0,
33
+ 'MinDiffHeight' => 0,
34
+ 'MatchThreshold' => 0
35
+ }
56
36
  },
57
- 'Tag' => nil,
58
- 'updateBaselineIfDifferent' => false,
59
- 'updateBaselineIfNew' => false
37
+ 'IgnoreExpectedOutputSettings' => false,
38
+ 'ForceMatch' => false,
39
+ 'ForceMismatch' => false,
40
+ 'IgnoreMatch' => false,
41
+ 'IgnoreMismatch' => false,
42
+ 'Trim' => {
43
+ 'Enabled' => false,
44
+ 'ForegroundIntensity' => 0,
45
+ 'MinEdgeLength' => 0
46
+ }
47
+ },
48
+ 'Id' => nil,
49
+ 'UserInputs' => [],
50
+ 'AppOutput' => {
51
+ 'Screenshot64' => nil,
52
+ 'ScreenshotUrl' => nil,
53
+ 'Title' => nil,
54
+ 'IsPrimary' => false,
55
+ 'Elapsed' => 0
56
+ },
57
+ 'Tag' => nil,
58
+ 'updateBaselineIfDifferent' => false,
59
+ 'updateBaselineIfNew' => false
60
60
  }
61
61
  end
62
62
  end
@@ -2,15 +2,15 @@ require 'base64'
2
2
  require_relative 'match_window_task'
3
3
  module Applitools
4
4
  class MatchSingleTask < MatchWindowTask
5
- def initialize(logger, retry_timeout, app_output_provider)
6
- super(logger, 'nil', retry_timeout, app_output_provider)
5
+ def initialize(logger, retry_timeout, app_output_provider, server_connector)
6
+ super(logger, 'nil', retry_timeout, app_output_provider, server_connector)
7
7
  end
8
8
 
9
9
  private
10
10
 
11
11
  def perform_match(match_window_data)
12
12
  Applitools::ArgumentGuard.is_a? match_window_data, 'match_window_data', Applitools::MatchSingleCheckData
13
- Applitools::Connectivity::ServerConnector.match_single_window match_window_data
13
+ server_connector.match_single_window match_window_data
14
14
  end
15
15
  end
16
16
  end
@@ -35,7 +35,7 @@ module Applitools
35
35
  'IgnoreMatch' => false,
36
36
  'IgnoreMismatch' => false,
37
37
  'Trim' => {
38
- 'Enabled' => false,
38
+ 'Enabled' => false
39
39
  }
40
40
  },
41
41
  'Id' => nil,
@@ -51,11 +51,11 @@ module Applitools
51
51
  }
52
52
  end
53
53
 
54
- def valid_region(r)
54
+ def valid_region(_r)
55
55
  true
56
56
  end
57
57
 
58
- def valid_input(i)
58
+ def valid_input(_i)
59
59
  true
60
60
  end
61
61
  end
@@ -111,36 +111,32 @@ module Applitools
111
111
  end
112
112
 
113
113
  def read_target(target, driver)
114
- #options
114
+ # options
115
115
  %w(trim).each do |field|
116
116
  send("#{field}=", target.options[field.to_sym])
117
117
  end
118
- #ignored regions
118
+ # ignored regions
119
119
  target.ignored_regions.each do |r|
120
120
  case r
121
- when Proc
122
- region = r.call(driver)
123
- @ignored_regions << Applitools::Region.from_location_size(region.location, region.size)
124
- @need_convert_ignored_regions_coordinates = true
125
- when Applitools::Region
126
- @ignored_regions << r
127
- @need_convert_ignored_regions_coordinates = true
121
+ when Proc
122
+ region = r.call(driver)
123
+ @ignored_regions << Applitools::Region.from_location_size(region.location, region.size)
124
+ @need_convert_ignored_regions_coordinates = true
125
+ when Applitools::Region
126
+ @ignored_regions << r
127
+ @need_convert_ignored_regions_coordinates = true
128
128
  end
129
129
  end
130
130
  end
131
131
 
132
132
  def ignore_mismatch
133
- current_data['IgnoreMismatch']
133
+ current_data['IgnoreMismatch']
134
134
  end
135
135
 
136
136
  def tag
137
137
  current_data['Tag']
138
138
  end
139
139
 
140
- def screenshot
141
- app_output.screenshot.image.to_blob
142
- end
143
-
144
140
  def trim=(value)
145
141
  current_data['Options']['Trim']['Enabled'] = value ? true : false
146
142
  end
@@ -154,7 +150,9 @@ module Applitools
154
150
  end
155
151
 
156
152
  def to_hash
157
- raise Applitools::EyesError.new 'You should convert coordinates for ignored_regions!' if @need_convert_ignored_regions_coordinates
153
+ raise Applitools::EyesError.new(
154
+ 'You should convert coordinates for ignored_regions!'
155
+ ) if @need_convert_ignored_regions_coordinates
158
156
  current_data.dup
159
157
  end
160
158
 
@@ -6,12 +6,14 @@ module Applitools
6
6
 
7
7
  attr_reader :logger, :running_session, :default_retry_timeout, :app_output_provider
8
8
 
9
- def initialize(logger, running_session, retry_timeout, app_output_provider)
9
+ def initialize(logger, running_session, retry_timeout, app_output_provider, server_connector)
10
+ Applitools::ArgumentGuard.is_a? server_connector, 'server_connector', Applitools::Connectivity::ServerConnector
10
11
  @logger = logger
11
12
  @running_session = running_session
12
13
  # @driver = driver
13
14
  @default_retry_timeout = retry_timeout
14
15
  @app_output_provider = app_output_provider
16
+ self.server_connector = server_connector
15
17
 
16
18
  ArgumentGuard.not_nil logger, 'logger'
17
19
  ArgumentGuard.not_nil running_session, 'running_session'
@@ -50,11 +52,11 @@ module Applitools
50
52
  match_result = perform_match(match_window_data)
51
53
  retry_time = Time.now - start
52
54
 
53
- if block_given?
54
- block_retry = yield(match_result)
55
- else
56
- block_retry = false
57
- end
55
+ block_retry = if block_given?
56
+ yield(match_result)
57
+ else
58
+ false
59
+ end
58
60
 
59
61
  while retry_time < retry_timeout && !(block_retry || match_result.as_expected?)
60
62
  sleep MATCH_INTERVAL
@@ -83,9 +85,11 @@ module Applitools
83
85
 
84
86
  private
85
87
 
88
+ attr_accessor :server_connector
89
+
86
90
  def perform_match(match_window_data)
87
91
  Applitools::ArgumentGuard.is_a? match_window_data, 'match_window_data', Applitools::MatchWindowData
88
- Applitools::Connectivity::ServerConnector.match_window running_session, match_window_data
92
+ server_connector.match_window running_session, match_window_data
89
93
  end
90
94
  end
91
95
  end
@@ -14,7 +14,7 @@ module Applitools::EyesLogger
14
14
  def self.add_thread_id_to_log_handler!(log_handler)
15
15
  original_formatter = Logger::Formatter.new
16
16
  log_handler.formatter = proc do |severity, datetime, progname, msg|
17
- updated_progname = "#{progname.to_s} (#{Thread.current.object_id.to_s})"
17
+ updated_progname = "#{progname} (#{Thread.current.object_id})"
18
18
  original_formatter.call(severity, datetime, updated_progname, msg.dump)
19
19
  end
20
20
  end
@@ -97,9 +97,9 @@ module Applitools::Images
97
97
  self.screenshot = EyesImagesScreenshot.new image
98
98
 
99
99
  mr = check_single_base(
100
- region_provider,
101
- target.options[:timeout] || Applitools::EyesBase::USE_DEFAULT_TIMEOUT,
102
- match_window_data
100
+ region_provider,
101
+ target.options[:timeout] || Applitools::EyesBase::USE_DEFAULT_TIMEOUT,
102
+ match_window_data
103
103
  )
104
104
  mr
105
105
  end
@@ -73,13 +73,14 @@ module Applitools::Images
73
73
  convert_location location, CONTEXT_RELATIVE, SCREENSHOT_AS_IS
74
74
  end
75
75
 
76
- def sub_screenshot(region, coordinates_type, throw_if_clipped)
76
+ def sub_screenshot(region, coordinates_type, throw_if_clipped = false, force_nil_if_clipped = false)
77
77
  Applitools::ArgumentGuard.not_nil region, 'region'
78
78
  Applitools::ArgumentGuard.not_nil coordinates_type, 'coordinates_type'
79
79
 
80
80
  sub_screen_region = intersected_region region, coordinates_type, SCREENSHOT_AS_IS
81
81
 
82
82
  if sub_screen_region.empty? || (throw_if_clipped && !region.size_equals?(sub_screen_region))
83
+ return nil if force_nil_if_clipped
83
84
  Applitools::OutOfBoundsException.new "Region #{sub_screen_region} (#{coordinates_type}) is out of " \
84
85
  " screenshot bounds #{bounds}"
85
86
  end
@@ -1,3 +1,3 @@
1
1
  module Applitools
2
- VERSION = '3.6.5'.freeze
2
+ VERSION = '3.6.6'.freeze
3
3
  end
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.6.5
4
+ version: 3.6.6
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-09 00:00:00.000000000 Z
11
+ date: 2017-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oily_png
@@ -270,7 +270,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
270
270
  version: '0'
271
271
  requirements: []
272
272
  rubyforge_project:
273
- rubygems_version: 2.6.8
273
+ rubygems_version: 2.5.1
274
274
  signing_key:
275
275
  specification_version: 4
276
276
  summary: Applitools Ruby SDK