eyes_images 3.4.1 → 3.5.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: abb2e3351e146bd8321821b3b32a59ca4e49d63f
4
- data.tar.gz: ad5e66defc1e9d5e74ee875831965647dbd14e13
3
+ metadata.gz: 1a7d6f4ca9140ef1a2925d5bad227147eb829ac9
4
+ data.tar.gz: 4983154b46e863c5a5389e8b9d5ecbe7f9e6dcdd
5
5
  SHA512:
6
- metadata.gz: baf2257d1a1e27e1eb854e90886300f1fbda4a9ad4ffa20db9da16fe2ecaa443bfaea86a6aa9940e0c6d1314b72933f54885979b34af5eddde008c70a85b035b
7
- data.tar.gz: 18e38081472754d2b1e02a78d8eefe6136bccb0440a978900a73082a7936d9ee7e14210aec05aeabf224ec64c6143e68a25b4e89ed06422245d55e80085eb46b
6
+ metadata.gz: 266dc300cd6da2fb2a6c94580f0c302963eb4f8257bfd537343da8f92c01d2c1167060838122b227d8eee43d23054971f327369a1d8316a708aba0b2bd4df6c2
7
+ data.tar.gz: fa8df920b199b56358a7ea13da9025c9fb171275e6a445829951e3594a3266dbf6350fb41c150fd1b8288993a57fc24717f4e27e785b12c7ec46c7937947028e
@@ -58,6 +58,53 @@ module Applitools::Images
58
58
  abort_if_not_closed
59
59
  end
60
60
 
61
+ def check(name, target)
62
+ Applitools::ArgumentGuard.not_nil(name, 'name')
63
+ region_provider = get_region_provider(target)
64
+
65
+ image = target.image
66
+ self.viewport_size = Applitools::RectangleSize.new image.width, image.height if viewport_size.nil?
67
+ self.screenshot = EyesImagesScreenshot.new image
68
+
69
+ mr = check_window_base(
70
+ region_provider, name, false,
71
+ target.options[:timeout] || Applitools::EyesBase::USE_DEFAULT_TIMEOUT,
72
+ ignore: target.ignored_regions,
73
+ trim: target.options[:trim],
74
+ match_level: default_match_settings[:match_level],
75
+ exact: default_match_settings[:exact]
76
+ )
77
+ mr.as_expected?
78
+ end
79
+
80
+ def get_region_provider(target)
81
+ if (region_to_check = target.region_to_check).nil?
82
+ Object.new.tap do |prov|
83
+ prov.instance_eval do
84
+ define_singleton_method :region do
85
+ Applitools::Region::EMPTY
86
+ end
87
+
88
+ define_singleton_method :coordinate_type do
89
+ nil
90
+ end
91
+ end
92
+ end
93
+ else
94
+ Object.new.tap do |prov|
95
+ prov.instance_eval do
96
+ define_singleton_method :region do
97
+ region_to_check
98
+ end
99
+
100
+ define_singleton_method :coordinate_type do
101
+ Applitools::EyesScreenshot::COORDINATE_TYPES[:context_relative]
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
107
+
61
108
  # Matches the input image with the next expected image. Takes a hash as an argument. Returns +boolean+
62
109
  # as result of matching.
63
110
  # @param [Hash] options
@@ -0,0 +1,87 @@
1
+ module Applitools::Images
2
+ class Target
3
+ class << self
4
+ def path(path)
5
+ raise Applitools::EyesIllegalArgument unless File.exist?(path)
6
+ new Applitools::Screenshot.from_image(ChunkyPNG::Image.from_file(path))
7
+ end
8
+
9
+ def blob(blob_image)
10
+ Applitools::ArgumentGuard.not_nil blob_image, 'blob_image'
11
+ Applitools::ArgumentGuard.is_a? blob_image, 'blob_image', String
12
+ new Applitools::Screenshot.from_datastream(blob_image)
13
+ end
14
+
15
+ def image(image)
16
+ Applitools::ArgumentGuard.not_nil image, 'image'
17
+ Applitools::ArgumentGuard.is_a? image, 'image', ChunkyPNG::Image
18
+ new Applitools::Screenshot.from_image(image)
19
+ end
20
+
21
+ def screenshot(screenshot)
22
+ Applitools::ArgumentGuard.not_nil screenshot, 'screenshot'
23
+ Applitools::ArgumentGuard.is_a? screenshot, 'screenshot', Applitools::Screenshot
24
+ new screenshot
25
+ end
26
+
27
+ def any(screenshot)
28
+ case screenshot
29
+ when Applitools::Screenshot
30
+ screenshot(screenshot)
31
+ when ChunkyPNG::Image
32
+ image(screenshot)
33
+ when String
34
+ begin
35
+ blob(screenshot)
36
+ rescue ChunkyPNG::SignatureMismatch
37
+ path(screenshot)
38
+ end
39
+ else
40
+ raise Applitools::EyesIllegalArgument.new "Passed screenshot is not image type (#{screenshot.class})"
41
+ end
42
+ end
43
+ end
44
+
45
+ attr_accessor :image, :options, :ignored_regions, :region_to_check
46
+
47
+ def initialize(image)
48
+ Applitools::ArgumentGuard.not_nil(image, 'image')
49
+ Applitools::ArgumentGuard.is_a? image, 'image', Applitools::Screenshot
50
+ self.image = image
51
+ self.ignored_regions = []
52
+ self.options = {
53
+ trim: false
54
+ }
55
+ end
56
+
57
+ def ignore(region = nil)
58
+ if region
59
+ Applitools::ArgumentGuard.is_a? region, 'region', Applitools::Region
60
+ ignored_regions << region
61
+ else
62
+ self.ignored_regions = []
63
+ end
64
+ self
65
+ end
66
+
67
+ def region(region = nil)
68
+ if region
69
+ Applitools::ArgumentGuard.is_a? region, 'region', Applitools::Region
70
+ self.region_to_check = region
71
+ else
72
+ self.region_to_check = nil
73
+ end
74
+ self
75
+ end
76
+
77
+ def trim(value = true)
78
+ options[:trim] = value ? true : false
79
+ self
80
+ end
81
+
82
+ def timeout(value = nil)
83
+ options[:timeout] = value ? value : nil
84
+ self
85
+ end
86
+ end
87
+ end
@@ -1,3 +1,3 @@
1
1
  module Applitools
2
- VERSION = '3.4.1'.freeze
2
+ VERSION = '3.5.0'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: eyes_images
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.4.1
4
+ version: 3.5.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-04-25 00:00:00.000000000 Z
11
+ date: 2017-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: eyes_core
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: 3.4.1
19
+ version: 3.5.0
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 3.4.1
26
+ version: 3.5.0
27
27
  description: Applitools Ruby Images SDK
28
28
  email:
29
29
  - team@applitools.com
@@ -33,6 +33,7 @@ extra_rdoc_files: []
33
33
  files:
34
34
  - lib/applitools/images/eyes.rb
35
35
  - lib/applitools/images/eyes_images_screenshot.rb
36
+ - lib/applitools/images/target.rb
36
37
  - lib/applitools/version.rb
37
38
  - lib/eyes_images.rb
38
39
  homepage: https://www.applitools.com