Class: Applitools::MatchWindowData
- Inherits:
-
Object
- Object
- Applitools::MatchWindowData
- Defined in:
- lib/applitools/core/match_window_data.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#app_output ⇒ Object
Returns the value of attribute app_output.
-
#ignore_mismatch ⇒ Object
Returns the value of attribute ignore_mismatch.
-
#options ⇒ Object
Returns the value of attribute options.
-
#tag ⇒ Object
Returns the value of attribute tag.
-
#user_inputs ⇒ Object
Returns the value of attribute user_inputs.
Class Method Summary collapse
- .convert_coordinates(region, screenshot) ⇒ Object
- .default_data ⇒ Object
- .valid_input(_i) ⇒ Object
- .valid_region(_r) ⇒ Object
Instance Method Summary collapse
- #convert_floating_regions_coordinates ⇒ Object
- #convert_ignored_regions_coordinates ⇒ Object
- #exact ⇒ Object
- #exact=(value) ⇒ Object
- #floating_regions=(value) ⇒ Object
- #ignore_caret=(value) ⇒ Object
- #ignored_regions=(value) ⇒ Object
-
#initialize ⇒ MatchWindowData
constructor
A new instance of MatchWindowData.
- #match_level ⇒ Object
- #match_level=(value) ⇒ Object
- #read_target(target, driver) ⇒ Object
- #remainder ⇒ Object
- #remainder=(value) ⇒ Object
- #scale ⇒ Object
- #scale=(value) ⇒ Object
- #screenshot ⇒ Object
- #to_hash ⇒ Object
- #to_s ⇒ Object
- #trim=(value) ⇒ Object
Constructor Details
#initialize ⇒ MatchWindowData
Returns a new instance of MatchWindowData.
68 69 70 71 72 73 74 |
# File 'lib/applitools/core/match_window_data.rb', line 68 def initialize @app_output = nil @ignored_regions = [] @floating_regions = [] @need_convert_ignored_regions_coordinates = false @need_convert_floating_regions_coordinates = false end |
Instance Attribute Details
#app_output ⇒ Object
Returns the value of attribute app_output.
66 67 68 |
# File 'lib/applitools/core/match_window_data.rb', line 66 def app_output @app_output end |
#ignore_mismatch ⇒ Object
Returns the value of attribute ignore_mismatch.
66 67 68 |
# File 'lib/applitools/core/match_window_data.rb', line 66 def ignore_mismatch @ignore_mismatch end |
#options ⇒ Object
Returns the value of attribute options.
66 67 68 |
# File 'lib/applitools/core/match_window_data.rb', line 66 def @options end |
#tag ⇒ Object
Returns the value of attribute tag.
66 67 68 |
# File 'lib/applitools/core/match_window_data.rb', line 66 def tag @tag end |
#user_inputs ⇒ Object
Returns the value of attribute user_inputs.
66 67 68 |
# File 'lib/applitools/core/match_window_data.rb', line 66 def user_inputs @user_inputs end |
Class Method Details
.convert_coordinates(region, screenshot) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/applitools/core/match_window_data.rb', line 4 def convert_coordinates(region, screenshot) screenshot.convert_region_location( region.with_padding, Applitools::EyesScreenshot::COORDINATE_TYPES[:context_relative], Applitools::EyesScreenshot::COORDINATE_TYPES[:screenshot_as_is] ).to_hash end |
.default_data ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/applitools/core/match_window_data.rb', line 12 def default_data { 'IgnoreMismatch' => false, 'MismatchWait' => 0, 'Options' => { 'Name' => nil, 'UserInputs' => [], 'ImageMatchSettings' => { 'MatchLevel' => 'Strict', 'SplitTopHeight' => 0, 'SplitBottomHeight' => 0, 'IgnoreCaret' => false, 'Ignore' => [], 'Floating' => [], 'Exact' => { 'MinDiffIntensity' => 0, 'MinDiffWidth' => 0, 'MinDiffHeight' => 0, 'MatchThreshold' => 0 }, 'scale' => 0, 'remainder' => 0 }, 'IgnoreExpectedOutputSettings' => false, 'ForceMatch' => false, 'ForceMismatch' => false, 'IgnoreMatch' => false, 'IgnoreMismatch' => false, 'Trim' => { 'Enabled' => false } }, 'Id' => nil, 'UserInputs' => [], 'AppOutput' => { 'Screenshot64' => nil, 'ScreenshotUrl' => nil, 'Title' => nil, 'IsPrimary' => false, 'Elapsed' => 0 }, 'Tag' => nil } end |
.valid_input(_i) ⇒ Object
61 62 63 |
# File 'lib/applitools/core/match_window_data.rb', line 61 def valid_input(_i) true end |
.valid_region(_r) ⇒ Object
57 58 59 |
# File 'lib/applitools/core/match_window_data.rb', line 57 def valid_region(_r) true end |
Instance Method Details
#convert_floating_regions_coordinates ⇒ Object
225 226 227 228 229 230 231 232 233 234 235 236 |
# File 'lib/applitools/core/match_window_data.rb', line 225 def convert_floating_regions_coordinates return unless @need_convert_floating_regions_coordinates self.floating_regions = @floating_regions.map do |r| r.location = app_output.screenshot.convert_location( r.location, Applitools::EyesScreenshot::COORDINATE_TYPES[:context_relative], Applitools::EyesScreenshot::COORDINATE_TYPES[:screenshot_as_is] ) r.to_hash end @need_convert_floating_regions_coordinates = false end |
#convert_ignored_regions_coordinates ⇒ Object
217 218 219 220 221 222 223 |
# File 'lib/applitools/core/match_window_data.rb', line 217 def convert_ignored_regions_coordinates return unless @need_convert_ignored_regions_coordinates self.ignored_regions = @ignored_regions.map do |r| self.class.convert_coordinates(r, app_output.screenshot) end @need_convert_ignored_regions_coordinates = false end |
#exact ⇒ Object
144 145 146 |
# File 'lib/applitools/core/match_window_data.rb', line 144 def exact current_data['Options']['ImageMatchSettings']['Exact'] end |
#exact=(value) ⇒ Object
148 149 150 151 152 153 154 155 156 |
# File 'lib/applitools/core/match_window_data.rb', line 148 def exact=(value) raise Applitools::EyesError.new('You should pass a hash as a value!') unless value.nil? || value.is_a?(Hash) return current_data['Options']['ImageMatchSettings']['Exact'] = nil if value.nil? current_value = exact || {} %w(MinDiffIntensity MinDiffWidth MinDiffHeight MatchThreshold).each do |k| current_value[k] = value[k] end current_data['Options']['ImageMatchSettings']['Exact'] = current_value end |
#floating_regions=(value) ⇒ Object
104 105 106 107 108 109 |
# File 'lib/applitools/core/match_window_data.rb', line 104 def floating_regions=(value) Applitools::ArgumentGuard.is_a? value, 'value', Array value.each do |r| current_data['Options']['ImageMatchSettings']['Floating'] << r.to_hash end end |
#ignore_caret=(value) ⇒ Object
213 214 215 |
# File 'lib/applitools/core/match_window_data.rb', line 213 def ignore_caret=(value) current_data['Options']['ImageMatchSettings']['IgnoreCaret'] = value end |
#ignored_regions=(value) ⇒ Object
97 98 99 100 101 102 |
# File 'lib/applitools/core/match_window_data.rb', line 97 def ignored_regions=(value) Applitools::ArgumentGuard.is_a? value, 'value', Array value.each do |r| current_data['Options']['ImageMatchSettings']['Ignore'] << r.to_hash if self.class.valid_region(r) end end |
#match_level ⇒ Object
124 125 126 |
# File 'lib/applitools/core/match_window_data.rb', line 124 def match_level current_data['Options']['ImageMatchSettings']['MatchLevel'] end |
#match_level=(value) ⇒ Object
120 121 122 |
# File 'lib/applitools/core/match_window_data.rb', line 120 def match_level=(value) current_data['Options']['ImageMatchSettings']['MatchLevel'] = value end |
#read_target(target, driver) ⇒ Object
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 |
# File 'lib/applitools/core/match_window_data.rb', line 158 def read_target(target, driver) # options .each do |field| a_value = target.[field.to_sym] send("#{field}=", a_value) unless a_value.nil? end # ignored regions if target.respond_to? :ignored_regions target.ignored_regions.each do |r| case r when Proc @ignored_regions << r.call(driver) @need_convert_ignored_regions_coordinates = true when Applitools::Region @ignored_regions << r @need_convert_ignored_regions_coordinates = true end end end # floating regions return unless target.respond_to? :floating_regions target.floating_regions.each do |r| case r when Proc region = r.call(driver) raise Applitools::EyesError.new "Wrong floating region: #{region.class}" unless region.is_a? Applitools::FloatingRegion @floating_regions << region @need_convert_floating_regions_coordinates = true when Applitools::FloatingRegion @floating_regions << r @need_convert_floating_regions_coordinates = true end end end |
#remainder ⇒ Object
140 141 142 |
# File 'lib/applitools/core/match_window_data.rb', line 140 def remainder current_data['Options']['ImageMatchSettings']['remainder'] end |
#remainder=(value) ⇒ Object
136 137 138 |
# File 'lib/applitools/core/match_window_data.rb', line 136 def remainder=(value) current_data['Options']['ImageMatchSettings']['remainder'] = value end |
#scale ⇒ Object
132 133 134 |
# File 'lib/applitools/core/match_window_data.rb', line 132 def scale current_data['Options']['ImageMatchSettings']['scale'] end |
#scale=(value) ⇒ Object
128 129 130 |
# File 'lib/applitools/core/match_window_data.rb', line 128 def scale=(value) current_data['Options']['ImageMatchSettings']['scale'] = value end |
#screenshot ⇒ Object
76 77 78 |
# File 'lib/applitools/core/match_window_data.rb', line 76 def screenshot app_output.screenshot.image.to_blob end |
#to_hash ⇒ Object
238 239 240 241 242 243 244 245 246 247 248 249 250 251 |
# File 'lib/applitools/core/match_window_data.rb', line 238 def to_hash if @need_convert_ignored_regions_coordinates raise Applitools::EyesError.new( 'You should convert coordinates for ignored_regions!' ) end if @need_convert_floating_regions_coordinates raise Applitools::EyesError.new( 'You should convert coordinates for floating_regions!' ) end current_data.dup end |
#to_s ⇒ Object
253 254 255 |
# File 'lib/applitools/core/match_window_data.rb', line 253 def to_s to_hash end |
#trim=(value) ⇒ Object
209 210 211 |
# File 'lib/applitools/core/match_window_data.rb', line 209 def trim=(value) current_data['Options']['Trim']['Enabled'] = value ? true : false end |