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_ignored_regions_coordinates ⇒ 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
- #screenshot ⇒ Object
- #to_hash ⇒ Object
- #to_s ⇒ Object
- #trim=(value) ⇒ Object
Constructor Details
#initialize ⇒ MatchWindowData
Returns a new instance of MatchWindowData.
65 66 67 68 69 |
# File 'lib/applitools/core/match_window_data.rb', line 65 def initialize @app_output = nil @ignored_regions = [] @need_convert_ignored_regions_coordinates = false end |
Instance Attribute Details
#app_output ⇒ Object
Returns the value of attribute app_output.
63 64 65 |
# File 'lib/applitools/core/match_window_data.rb', line 63 def app_output @app_output end |
#ignore_mismatch ⇒ Object
Returns the value of attribute ignore_mismatch.
63 64 65 |
# File 'lib/applitools/core/match_window_data.rb', line 63 def ignore_mismatch @ignore_mismatch end |
#options ⇒ Object
Returns the value of attribute options.
63 64 65 |
# File 'lib/applitools/core/match_window_data.rb', line 63 def end |
#tag ⇒ Object
Returns the value of attribute tag.
63 64 65 |
# File 'lib/applitools/core/match_window_data.rb', line 63 def tag @tag end |
#user_inputs ⇒ Object
Returns the value of attribute user_inputs.
63 64 65 |
# File 'lib/applitools/core/match_window_data.rb', line 63 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( Applitools::Region.from_location_size(region.location, region.size), 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 |
# File 'lib/applitools/core/match_window_data.rb', line 12 def default_data { 'IgnoreMismatch' => false, 'MismatchWait' => 0, 'Options' => { 'Name' => nil, 'UserInputs' => [], 'ImageMatchSettings' => { 'MatchLevel' => 'None', 'SplitTopHeight' => 0, 'SplitBottomHeight' => 0, 'IgnoreCaret' => false, 'Ignore' => [], 'Exact' => { 'MinDiffIntensity' => 0, 'MinDiffWidth' => 0, 'MinDiffHeight' => 0, 'MatchThreshold' => 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
58 59 60 |
# File 'lib/applitools/core/match_window_data.rb', line 58 def valid_input(_i) true end |
.valid_region(_r) ⇒ Object
54 55 56 |
# File 'lib/applitools/core/match_window_data.rb', line 54 def valid_region(_r) true end |
Instance Method Details
#convert_ignored_regions_coordinates ⇒ Object
148 149 150 151 152 153 154 |
# File 'lib/applitools/core/match_window_data.rb', line 148 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 |
#ignored_regions=(value) ⇒ Object
93 94 95 96 97 98 |
# File 'lib/applitools/core/match_window_data.rb', line 93 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
113 114 115 |
# File 'lib/applitools/core/match_window_data.rb', line 113 def match_level current_data['Options']['ImageMatchSettings']['MatchLevel'] end |
#match_level=(value) ⇒ Object
109 110 111 |
# File 'lib/applitools/core/match_window_data.rb', line 109 def match_level=(value) current_data['Options']['ImageMatchSettings']['MatchLevel'] = value end |
#read_target(target, driver) ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/applitools/core/match_window_data.rb', line 117 def read_target(target, driver) # options %w(trim).each do |field| send("#{field}=", target.[field.to_sym]) end # ignored regions target.ignored_regions.each do |r| case r when Proc region = r.call(driver) @ignored_regions << Applitools::Region.from_location_size(region.location, region.size) @need_convert_ignored_regions_coordinates = true when Applitools::Region @ignored_regions << r @need_convert_ignored_regions_coordinates = true end end end |
#screenshot ⇒ Object
71 72 73 |
# File 'lib/applitools/core/match_window_data.rb', line 71 def screenshot app_output.screenshot.image.to_blob end |
#to_hash ⇒ Object
156 157 158 159 160 161 |
# File 'lib/applitools/core/match_window_data.rb', line 156 def to_hash raise Applitools::EyesError.new( 'You should convert coordinates for ignored_regions!' ) if @need_convert_ignored_regions_coordinates current_data.dup end |
#to_s ⇒ Object
163 164 165 |
# File 'lib/applitools/core/match_window_data.rb', line 163 def to_s to_hash end |
#trim=(value) ⇒ Object
144 145 146 |
# File 'lib/applitools/core/match_window_data.rb', line 144 def trim=(value) current_data['Options']['Trim']['Enabled'] = value ? true : false end |