eyes_core 3.10.2 → 3.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b5809ea0c1a4fce9a7233b53c2f93b811cd45e24
4
- data.tar.gz: 7297d6577eb1d687fe9fd08954a9accbbd7273b1
3
+ metadata.gz: e4ecf0b330e7ed9c413a7c4e22ea2e2f39324d1c
4
+ data.tar.gz: c5792bf7600f5046341ef35f5c4387cbd99806d5
5
5
  SHA512:
6
- metadata.gz: 224885021816ed5b60ba60c5e07a9469c3e991f1fb10a789935fce33b7119d2605202ea751b23da8bf3291f088e82b0ce71e461736610854b2a7ed03fb53f48a
7
- data.tar.gz: 7257faf0af15b39d3d90a0708ee001f2f7aa55ffa9b4134745633af0b342bb56898316494b03da7547278431bcb5c4a6061ced8456475485de093d8ec0445d0a
6
+ metadata.gz: d4980e04b7a5d40183a5a632f36fae69458eef23826ea0bfc91d818bdf8c2bead8d3d5c9cc5930e349fd75229a71fbb6c74056d0af56dc09000c7b94f68bbf9f
7
+ data.tar.gz: 80510420088d04c8f482bd68e0701ead2033fc74d37c32a4be257b86a4d81c180260a90ed11448c96465e7c8e490cc29fd502ab7e0133ffe7ce0fdf0d9532320
@@ -93,17 +93,20 @@ module Applitools
93
93
  # @return [Target] Applitools::Selenium::Target or Applitools::Images::target
94
94
 
95
95
  def default_match_level(value, exact_options = {})
96
- @match_level, self.exact = match_level_with_exact(value, exact_options)
96
+ result = match_level_with_exact(value, exact_options)
97
+ default_match_settings[:match_level] = result.first
98
+ self.match_level = result.first
99
+ default_match_settings[:exact] = result.last
100
+ self.exact = result.last
101
+ result
97
102
  end
98
103
 
99
- # rubocop:disable LineLength
100
104
  # Sets default match settings
101
105
  # @param [Hash] value
102
106
  # @option value [Symbol] match_level
103
107
  # @option value [Hash] exact exact values. Available keys are 'MinDiffIntensity', 'MinDiffWidth', 'MinDiffHeight', 'MatchThreshold'
104
108
  # @option value [Fixnum] scale
105
109
  # @option value [Fixnum] remainder
106
- # rubocop:enable LineLength
107
110
 
108
111
  def default_match_settings=(value)
109
112
  Applitools::ArgumentGuard.is_a? value, 'value', Hash
@@ -2,30 +2,70 @@ require_relative 'region'
2
2
  module Applitools
3
3
  class FloatingRegion < Region
4
4
  class << self
5
- def any(element, max_left_offset, max_top_offset, max_right_offset, max_bottom_offset)
5
+ def any(element, *args)
6
6
  case element
7
- when Applitools::Selenium::Element, ::Selenium::WebDriver::Element, Applitools::Region
8
- for_element(element, max_left_offset, max_top_offset, max_right_offset, max_bottom_offset)
7
+ when Applitools::Region
8
+ for_element(element, *args)
9
+ when ::Selenium::WebDriver::Element
10
+ for_element(Applitools::Region.from_location_size(element.location, element.size), *args)
11
+ when Applitools::Selenium::Element
12
+ for_element(element.bounds, *args)
9
13
  else
10
14
  raise Applitools::EyesIllegalArgument.new "Unsupported element - #{element.class}"
11
15
  end
12
16
  end
13
17
 
14
- def for_element(element, max_left_offset, max_top_offset, max_right_offset, max_bottom_offset)
15
- new element.location.x, element.location.y, element.size.width, element.size.height, max_left_offset,
16
- max_top_offset, max_right_offset, max_bottom_offset
18
+ def for_element(element, *args)
19
+ case args.count
20
+ when 1
21
+ new element, args.first
22
+ when 4
23
+ new element, FloatingBounds.new(*args)
24
+ else
25
+ raise(
26
+ Applitools::EyesIllegalArgument,
27
+ 'Applitools::FloatingRegion.for_element has been called with illegal argument'
28
+ )
29
+ end
17
30
  end
18
31
  private :for_element
19
32
  end
20
33
 
21
34
  attr_accessor :max_top_offset, :max_right_offset, :max_bottom_offset, :max_left_offset
35
+ NAMES = [
36
+ :left, :top, :width, :height, :max_left_offset, :max_top_offset, :max_right_offset, :max_bottom_offset
37
+ ].freeze
22
38
 
23
- def initialize(left, top, width, height, max_left_offset, max_top_offset, max_right_offset, max_bottom_offset)
24
- super(left, top, width, height)
25
- self.max_left_offset = max_left_offset
26
- self.max_top_offset = max_top_offset
27
- self.max_right_offset = max_right_offset
28
- self.max_bottom_offset = max_bottom_offset
39
+ def initialize(*args)
40
+ case args.size
41
+ when 2
42
+ region = args.first
43
+ bounds = args.last
44
+ super(region.left, region.top, region.width, region.height)
45
+ self.max_left_offset = bounds.max_left_offset
46
+ self.max_top_offset = bounds.max_top_offset
47
+ self.max_right_offset = bounds.max_right_offset
48
+ self.max_bottom_offset = bounds.max_bottom_offset
49
+ when 8
50
+ args.each_with_index do |a, i|
51
+ Applitools::ArgumentGuard.is_a? a, NAMES[i], Integer
52
+ Applitools::ArgumentGuard.greater_than_or_equal_to_zero(a, NAMES[i])
53
+ end
54
+ super(*args[0..3])
55
+ self.max_left_offset = args[4]
56
+ self.max_top_offset = args[5]
57
+ self.max_right_offset = args[6]
58
+ self.max_bottom_offset = args[7]
59
+ else
60
+ raise(
61
+ Applitools::EyesIllegalArgument,
62
+ 'Expected Applitools::FloatingRegion.new to be called as ' \
63
+ 'Applitools::FloatingRegion.new(region, floating_bounds)' \
64
+ 'or ' \
65
+ 'Applitools::FloatingRegion.new(left, top, width, height, ' \
66
+ 'bounds_leeft, bounds_top, bounds_right, bounds_bottom)'
67
+ )
68
+ end
29
69
  end
30
70
 
31
71
  def to_hash
@@ -34,11 +74,31 @@ module Applitools
34
74
  'Left' => left,
35
75
  'Width' => width,
36
76
  'Height' => height,
37
- 'MaxUpOffset' => max_top_offset,
38
- 'MaxLeftOffset' => max_left_offset,
39
- 'MaxRightOffset' => max_right_offset,
40
- 'MaxDownOffset' => max_bottom_offset
77
+ 'MaxUpOffset' => max_top_offset + padding_top,
78
+ 'MaxLeftOffset' => max_left_offset + padding_left,
79
+ 'MaxRightOffset' => max_right_offset + padding_right,
80
+ 'MaxDownOffset' => max_bottom_offset + padding_bottom
41
81
  }
42
82
  end
43
83
  end
84
+
85
+ class FloatingBounds
86
+ attr_accessor :max_left_offset, :max_top_offset, :max_right_offset, :max_bottom_offset
87
+ def initialize(max_left_offset, max_top_offset, max_right_offset, max_bottom_offset)
88
+ Applitools::ArgumentGuard.is_a?(max_left_offset, 'max_left_offset', Integer)
89
+ Applitools::ArgumentGuard.is_a?(max_top_offset, 'max_top_offset', Integer)
90
+ Applitools::ArgumentGuard.is_a?(max_right_offset, 'max_right_offset', Integer)
91
+ Applitools::ArgumentGuard.is_a?(max_bottom_offset, 'max_bottom_offset', Integer)
92
+
93
+ Applitools::ArgumentGuard.greater_than_or_equal_to_zero(max_left_offset, 'max_left_offset')
94
+ Applitools::ArgumentGuard.greater_than_or_equal_to_zero(max_top_offset, 'max_top_offset')
95
+ Applitools::ArgumentGuard.greater_than_or_equal_to_zero(max_right_offset, 'max_right_offset')
96
+ Applitools::ArgumentGuard.greater_than_or_equal_to_zero(max_bottom_offset, 'max_bottom_offset')
97
+
98
+ self.max_left_offset = max_left_offset
99
+ self.max_top_offset = max_top_offset
100
+ self.max_right_offset = max_right_offset
101
+ self.max_bottom_offset = max_bottom_offset
102
+ end
103
+ end
44
104
  end
@@ -3,7 +3,7 @@ module Applitools
3
3
  class << self
4
4
  def convert_coordinates(region, screenshot)
5
5
  screenshot.convert_region_location(
6
- Applitools::Region.from_location_size(region.location, region.size),
6
+ region.with_padding,
7
7
  Applitools::EyesScreenshot::COORDINATE_TYPES[:context_relative],
8
8
  Applitools::EyesScreenshot::COORDINATE_TYPES[:screenshot_as_is]
9
9
  ).to_hash
@@ -166,8 +166,7 @@ module Applitools
166
166
  target.ignored_regions.each do |r|
167
167
  case r
168
168
  when Proc
169
- region = r.call(driver)
170
- @ignored_regions << Applitools::Region.from_location_size(region.location, region.size)
169
+ @ignored_regions << r.call(driver)
171
170
  @need_convert_ignored_regions_coordinates = true
172
171
  when Applitools::Region
173
172
  @ignored_regions << r
@@ -0,0 +1,24 @@
1
+ module Applitools
2
+ class PaddingBounds
3
+ attr_accessor :padding_left, :padding_top, :padding_right, :padding_bottom
4
+ def initialize(padding_left, padding_top, padding_right, padding_bottom)
5
+ Applitools::ArgumentGuard.is_a?(padding_left, 'padding_left', Integer)
6
+ Applitools::ArgumentGuard.is_a?(padding_top, 'padding_top', Integer)
7
+ Applitools::ArgumentGuard.is_a?(padding_right, 'padding_right', Integer)
8
+ Applitools::ArgumentGuard.is_a?(padding_bottom, 'padding_bottom', Integer)
9
+
10
+ Applitools::ArgumentGuard.greater_than_or_equal_to_zero(padding_left, 'padding_left')
11
+ Applitools::ArgumentGuard.greater_than_or_equal_to_zero(padding_top, 'padding_top')
12
+ Applitools::ArgumentGuard.greater_than_or_equal_to_zero(padding_right, 'padding_right')
13
+ Applitools::ArgumentGuard.greater_than_or_equal_to_zero(padding_bottom, 'padding_bottom')
14
+
15
+ self.padding_left = padding_left
16
+ self.padding_top = padding_top
17
+ self.padding_right = padding_right
18
+ self.padding_bottom = padding_bottom
19
+ end
20
+
21
+ ZERO_PADDING = PaddingBounds.new(0, 0, 0, 0).freeze
22
+ PIXEL_PADDING = PaddingBounds.new(1, 1, 1, 1).freeze
23
+ end
24
+ end
@@ -1,6 +1,11 @@
1
+ require_relative 'padding_bounds'
1
2
  module Applitools
2
3
  class Region
4
+ extend Forwardable
3
5
  attr_accessor :left, :top, :width, :height
6
+
7
+ def_delegators :@padding, :padding_left, :padding_top, :padding_right, :padding_bottom
8
+
4
9
  alias x left
5
10
  alias y top
6
11
 
@@ -15,6 +20,7 @@ module Applitools
15
20
  @top = top.round
16
21
  @width = width.round
17
22
  @height = height.round
23
+ @padding = Applitools::PaddingBounds::ZERO_PADDING
18
24
  end
19
25
 
20
26
  EMPTY = Region.new(0, 0, 0, 0)
@@ -106,6 +112,23 @@ module Applitools
106
112
  width == region.width && height == region.height
107
113
  end
108
114
 
115
+ # Sets padding for a current region. If called without any argument, all paddings will be set to 0
116
+ # @param padding[Applitools::PaddingBounds] represents paddings to be set for a region
117
+ # @return [Applitools::Region]
118
+ def padding(padding = nil)
119
+ padding = Applitools::PaddingBounds::ZERO_PADDING unless padding
120
+ Applitools::ArgumentGuard.is_a?(padding, 'padding', Applitools::PaddingBounds)
121
+ @padding = padding
122
+ self
123
+ end
124
+
125
+ def with_padding
126
+ Applitools::Region.from_location_size(
127
+ Applitools::Location.new(left - padding_left, top - padding_top),
128
+ Applitools::RectangleSize.new(width + padding_left + padding_right, height + padding_top + padding_bottom)
129
+ )
130
+ end
131
+
109
132
  class << self
110
133
  def sub_regions_with_fixed_size(container_region, sub_region)
111
134
  Applitools::ArgumentGuard.not_nil container_region, 'container_region'
@@ -1,3 +1,3 @@
1
1
  module Applitools
2
- VERSION = '3.10.2'.freeze
2
+ VERSION = '3.11.0'.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.10.2
4
+ version: 3.11.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-07-10 00:00:00.000000000 Z
11
+ date: 2017-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oily_png
@@ -230,6 +230,7 @@ files:
230
230
  - lib/applitools/core/match_window_data.rb
231
231
  - lib/applitools/core/match_window_task.rb
232
232
  - lib/applitools/core/mouse_trigger.rb
233
+ - lib/applitools/core/padding_bounds.rb
233
234
  - lib/applitools/core/rectangle_size.rb
234
235
  - lib/applitools/core/region.rb
235
236
  - lib/applitools/core/region_provider.rb