eyes_core 3.0.8 → 3.1.1

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: 734dda49eb71281c85770bc8e075346b303417f8
4
- data.tar.gz: '08dfc01e914c3c9d42958d018dba34a8a3305060'
3
+ metadata.gz: a6bfdf93e062d2d12f52900e4e161d86064443a4
4
+ data.tar.gz: 49420a387dc5327c6cd31a5f814e4e1e29f90948
5
5
  SHA512:
6
- metadata.gz: 3365239f1bf1f1843936585a9c25bc7c2804d5ee72ff3928e32e242d0cff34447af492545298a1c13f0e819668016eb4ea5730cec7b6dd1a5f46575e8c6c9195
7
- data.tar.gz: 5292266eaf979ff3caad6b05cb937fa64e9eb25f0e67378625f26ca4450da4460563615c5601564468ddfff0c5767f98602b6dd827293bc418448e0bfa8de1e5
6
+ metadata.gz: 4a3d745e90548ce9c1d9d73471a369e6c2d3eda0fa4dbabf2bfe50159180e3081248f707f15db8d3f488bf80a6a51920e3ed605ea6138b2e39cdc345e18d10f4
7
+ data.tar.gz: 47fdcf476ad6fa1894e70a303b5c8793c6207688e8b9749f9058818761d3277a92ea907f129430f7ac5edbed74bcd62002753ce586caf33a4ce6b844ec45f8eb
@@ -124,7 +124,7 @@ VALUE raw_merge_pixels(VALUE merge_pixels[], unsigned int size) {
124
124
  }
125
125
 
126
126
  VALUE c_bicubic_points(VALUE self, VALUE src_dimension, VALUE dst_dimension, VALUE direction) {
127
- unsigned long y_bounds, pixels_size, c_src_dimension, c_dst_dimension, index, index_y;
127
+ unsigned long y_bounds, pixels_size, c_src_dimension, c_dst_dimension, index, index_y, i, y, x;
128
128
  double step;
129
129
  VALUE result_array;
130
130
 
@@ -146,16 +146,16 @@ VALUE c_bicubic_points(VALUE self, VALUE src_dimension, VALUE dst_dimension, VAL
146
146
  pixels_size = y_bounds * c_dst_dimension;
147
147
  result_array = rb_ary_new2(pixels_size);
148
148
 
149
- for (unsigned long i=0; i < c_dst_dimension; i++) {
149
+ for (i = 0; i < c_dst_dimension; i++) {
150
150
  steps[i] = (unsigned long)i*step;
151
151
  residues[i] = i*step - steps[i];
152
152
  };
153
153
 
154
- for (unsigned long y=0; y < y_bounds; y++) {
154
+ for (y = 0; y < y_bounds; y++) {
155
155
  line_bounds = rb_funcall(self, rb_intern("line_with_bounds"), 3, UINT2NUM(y), src_dimension, direction);
156
156
 
157
157
  index_y = c_dst_dimension * y;
158
- for (unsigned long x=0; x < c_dst_dimension; x++) {
158
+ for (x = 0; x < c_dst_dimension; x++) {
159
159
  if (RTEST(direction)) {
160
160
  index = y_bounds * x + y;
161
161
  } else {
@@ -174,8 +174,8 @@ VALUE c_bicubic_points(VALUE self, VALUE src_dimension, VALUE dst_dimension, VAL
174
174
  }
175
175
 
176
176
  VALUE scale_points2(VALUE self, VALUE dst_width, VALUE dst_height, VALUE w_m, VALUE h_m) {
177
- unsigned long c_dst_height, c_dst_width, y_pos, x_pos, index;
178
- unsigned int c_w_m, c_h_m, buffer_index, buffer_size;
177
+ unsigned long c_dst_height, c_dst_width, y_pos, x_pos, index, i, j;
178
+ unsigned int c_w_m, c_h_m, buffer_index, buffer_size, x, y;
179
179
  VALUE pixels_to_merge [NUM2UINT(w_m) * NUM2UINT(h_m)];
180
180
  VALUE result;
181
181
 
@@ -188,12 +188,12 @@ VALUE scale_points2(VALUE self, VALUE dst_width, VALUE dst_height, VALUE w_m, VA
188
188
  result = rb_ary_new2(c_dst_width * c_dst_height);
189
189
  buffer_size = c_h_m * c_w_m;
190
190
 
191
- for (unsigned long i = 0; i < c_dst_height; i++) {
192
- for (unsigned long j = 0; j < c_dst_width; j++) {
191
+ for (i = 0; i < c_dst_height; i++) {
192
+ for (j = 0; j < c_dst_width; j++) {
193
193
  buffer_index = 0;
194
- for (unsigned int y = 0; y < c_h_m; y++) {
194
+ for (y = 0; y < c_h_m; y++) {
195
195
  y_pos = i * c_h_m + y;
196
- for (unsigned int x = 0; x < c_w_m; x++) {
196
+ for (x = 0; x < c_w_m; x++) {
197
197
  x_pos = j * c_w_m + x;
198
198
  pixels_to_merge[buffer_index++] = rb_funcall(self, rb_intern("get_pixel"), 2, UINT2NUM(x_pos), UINT2NUM(y_pos));
199
199
  }
@@ -1,3 +1,15 @@
1
+ module Applitools
2
+ class Enumerator < ::Enumerator
3
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0')
4
+ attr_reader :size
5
+ def initialize(*args)
6
+ @size = args[0] if args.size == 1
7
+ super()
8
+ end
9
+ end
10
+ end
11
+ end
12
+
1
13
  module Applitools::ChunkyPNG
2
14
  module Resampling
3
15
  def resample_bicubic!(dst_width, dst_height)
@@ -15,7 +27,7 @@ module Applitools::ChunkyPNG
15
27
 
16
28
  return self unless w_m * h_m > 1
17
29
 
18
- pixels = scale_points2(dst_width, dst_height, w_m, h_m);
30
+ pixels = scale_points2(dst_width, dst_height, w_m, h_m)
19
31
  replace_canvas!(dst_width, dst_height, pixels)
20
32
  end
21
33
 
@@ -34,8 +46,8 @@ module Applitools::ChunkyPNG
34
46
  def line_with_bounds(y, src_dimension, direction)
35
47
  line = (direction ? column(y) : row(y))
36
48
  [imaginable_point(line[0], line[1])] + line + [
37
- imaginable_point(line[src_dimension - 2], line[src_dimension - 3]),
38
- imaginable_point(line[src_dimension - 1], line[src_dimension - 2])
49
+ imaginable_point(line[src_dimension - 2], line[src_dimension - 3]),
50
+ imaginable_point(line[src_dimension - 1], line[src_dimension - 2])
39
51
  ]
40
52
  end
41
53
 
@@ -31,5 +31,9 @@ module Applitools
31
31
  raise Applitools::EyesIllegalArgument.new "Expected #{param_name} to be" \
32
32
  " instance of #{klass}"
33
33
  end
34
+
35
+ def raise_argument_error(error)
36
+ raise Applitools::EyesIllegalArgument.new error
37
+ end
34
38
  end
35
39
  end
@@ -62,7 +62,7 @@ module Applitools
62
62
  end
63
63
  end
64
64
 
65
- self.default_match_settings = MATCH_LEVEL[:exact]
65
+ @default_match_settings = { match_level: MATCH_LEVEL[:strict], exact: nil }
66
66
  end
67
67
 
68
68
  def full_agent_id
@@ -73,6 +73,14 @@ module Applitools
73
73
  end
74
74
  end
75
75
 
76
+ def match_level=(level)
77
+ @default_match_settings[:match_level] = level
78
+ end
79
+
80
+ def match_level
81
+ @default_match_settings[:match_level]
82
+ end
83
+
76
84
  def disabled=(value)
77
85
  @disabled = Applitools::Utils.boolean_value value
78
86
  end
@@ -283,8 +291,7 @@ module Applitools
283
291
  private
284
292
 
285
293
  attr_accessor :running_session, :last_screenshot, :current_app_name, :test_name, :session_type,
286
- :scale_provider, :default_match_settings, :session_start_info,
287
- :should_match_window_run_once_on_timeout, :app_output_provider
294
+ :scale_provider, :session_start_info, :should_match_window_run_once_on_timeout, :app_output_provider
288
295
 
289
296
  attr_reader :user_inputs
290
297
 
@@ -405,7 +412,6 @@ module Applitools
405
412
  scenario_id_or_name: test_name, batch_info: test_batch,
406
413
  env_name: baseline_name, environment: app_env,
407
414
  default_match_settings: default_match_settings,
408
- match_level: default_match_settings,
409
415
  branch_name: branch_name, parent_branch_name: parent_branch_name
410
416
 
411
417
  logger.info 'Starting server session...'
@@ -0,0 +1,11 @@
1
+ module Applitools::HashExtension
2
+ if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.0.0')
3
+ def struct_define_to_h_method
4
+ define_singleton_method :to_h do
5
+ result = {}
6
+ each_pair { |k, v| result[k] = v }
7
+ result
8
+ end
9
+ end
10
+ end
11
+ end
@@ -1,5 +1,7 @@
1
+ require_relative 'hash_extension'
1
2
  module Applitools
2
3
  RectangleSize = Struct.new(:width, :height) do
4
+ include Applitools::HashExtension
3
5
  class << self
4
6
  def from_any_argument(value)
5
7
  return from_string(value) if value.is_a? String
@@ -25,6 +27,11 @@ module Applitools
25
27
  end
26
28
  end
27
29
 
30
+ def initialize(*args)
31
+ super
32
+ struct_define_to_h_method if respond_to? :struct_define_to_h_method
33
+ end
34
+
28
35
  def to_s
29
36
  "#{width}x#{height}"
30
37
  end
@@ -41,6 +48,8 @@ module Applitools
41
48
  self
42
49
  end
43
50
 
44
- alias_method :to_hash, :to_h
51
+ def to_hash
52
+ to_h
53
+ end
45
54
  end
46
55
  end
@@ -1,42 +1,32 @@
1
1
  module Applitools
2
2
  class Screenshot < Delegator
3
- extend Forwardable
4
- def_delegators :header, :width, :height
5
-
6
3
  class << self
7
4
  def from_region(region)
8
- new ::ChunkyPNG::Image.new(region.width, region.height).to_blob
5
+ self::Image.new(::ChunkyPNG::Image.new(region.width, region.height))
9
6
  end
10
- end
11
7
 
12
- def initialize(image)
13
- @datastream = ::ChunkyPNG::Datastream.from_string image
14
- end
8
+ def from_datastream(datastream)
9
+ self::Datastream.new(datastream)
10
+ end
15
11
 
16
- def update!(image)
17
- Applitools::ArgumentGuard.not_nil(image, 'image')
18
- Applitools::ArgumentGuard.is_a?(image, 'image', ::ChunkyPNG::Image)
19
- @datastream = image.to_datastream
20
- self
21
- end
12
+ def from_image(image)
13
+ Image.new(image)
14
+ end
22
15
 
23
- def to_blob
24
- @datastream.to_blob
16
+ def from_any_image(image)
17
+ return from_region(image) if image.is_a? Applitools::Region
18
+ return from_image(image) if image.is_a? ::ChunkyPNG::Image
19
+ return image if image.is_a?(Image) | image.is_a?(Datastream)
20
+ from_datastream(image)
21
+ end
25
22
  end
26
23
 
27
- def __getobj__
28
- restore
24
+ def initialize(_image)
25
+ raise Applitools::EyesError.new 'Applitools::Screenshot is an abstract class!'
29
26
  end
30
27
 
31
- alias image __getobj__
32
-
33
- def header
34
- @datastream.header_chunk
35
- end
36
-
37
- def __setobj__(obj)
38
- @datastream = obj.to_datastream
39
- self
28
+ def __getobj__
29
+ nil
40
30
  end
41
31
 
42
32
  def method_missing(method, *args, &block)
@@ -51,8 +41,74 @@ module Applitools
51
41
  super
52
42
  end
53
43
 
54
- def restore
55
- ::ChunkyPNG::Image.from_datastream @datastream
44
+ class Datastream < self
45
+ extend Forwardable
46
+ def_delegators :header, :width, :height
47
+ attr_reader :datastream
48
+
49
+ def initialize(image)
50
+ Applitools::ArgumentGuard.not_nil(image, 'image')
51
+ unless image.is_a?(String)
52
+ Applitools::ArgumentGuard.raise_argument_error(
53
+ "Expected image to be Datastream or String, but got #{image.class}"
54
+ )
55
+ end
56
+ @datastream = ::ChunkyPNG::Datastream.from_string image
57
+ end
58
+
59
+ def update!(image)
60
+ Applitools::ArgumentGuard.not_nil(image, 'image')
61
+ Applitools::ArgumentGuard.is_a?(image, 'image', ::ChunkyPNG::Image)
62
+ @datastream = image.to_datastream
63
+ self
64
+ end
65
+
66
+ def to_blob
67
+ @datastream.to_blob
68
+ end
69
+
70
+ def header
71
+ @datastream.header_chunk
72
+ end
73
+
74
+ def __getobj__
75
+ restore
76
+ end
77
+
78
+ alias image __getobj__
79
+
80
+ def __setobj__(obj)
81
+ @datastream = obj.to_datastream
82
+ self
83
+ end
84
+
85
+ def restore
86
+ ::ChunkyPNG::Image.from_datastream @datastream
87
+ end
88
+ end
89
+
90
+ class Image < self
91
+ attr_reader :image
92
+
93
+ def initialize(image)
94
+ Applitools::ArgumentGuard.not_nil(image, 'image')
95
+ Applitools::ArgumentGuard.is_a?(image, 'image', ::ChunkyPNG::Image)
96
+ @image = image
97
+ end
98
+
99
+ def update!(image)
100
+ Applitools::ArgumentGuard.not_nil(image, 'image')
101
+ Applitools::ArgumentGuard.is_a?(image, 'image', ::ChunkyPNG::Image)
102
+ @image = image
103
+ end
104
+
105
+ def __getobj__
106
+ @image
107
+ end
108
+
109
+ def __setobj__(obj)
110
+ @image = obj
111
+ end
56
112
  end
57
113
  end
58
114
  end
@@ -10,7 +10,7 @@ module Applitools
10
10
  @batch_info = options[:batch_info]
11
11
  @env_name = options[:env_name]
12
12
  @environment = options[:environment]
13
- @match_level = options[:match_level]
13
+ @default_match_settings = options[:default_match_settings]
14
14
  @branch_name = options[:branch_name]
15
15
  @parent_branch_name = options[:parent_branch_name]
16
16
  end
@@ -24,7 +24,7 @@ module Applitools
24
24
  batch_info: @batch_info.to_hash,
25
25
  env_name: @env_name,
26
26
  environment: @environment.to_hash,
27
- match_level: @match_level,
27
+ default_match_settings: @default_match_settings,
28
28
  branch_name: @branch_name,
29
29
  parent_branch_name: @parent_branch_name
30
30
  }
@@ -32,7 +32,7 @@ module Applitools
32
32
  def ==(other)
33
33
  if other.is_a? self.class
34
34
  result = true
35
- %i(is_new url steps matches mismatches missing).each do |field|
35
+ %w(is_new url steps matches mismatches missing).each do |field|
36
36
  result &&= send(field) == other.send(field)
37
37
  end
38
38
  return result if result
@@ -186,15 +186,17 @@ module Applitools::Images
186
186
  alias set_viewport_size vp_size=
187
187
 
188
188
  def get_image_from_options(options)
189
- if options[:image].nil? || !options[:image].is_a?(Applitools::Screenshot)
190
- if !options[:image_path].nil? && !options[:image_path].empty?
191
- image = Applitools::Screenshot.new ChunkyPNG::Datastream.from_file(options[:image_path]).to_s
192
- elsif !options[:image_bytes].nil? && !options[:image_bytes].empty?
193
- image = Applitools::Screenshot.new options[:image_bytes]
194
- end
195
- else
196
- image = options[:image]
197
- end
189
+ image = if options[:image].nil? || !options[:image].is_a?(Applitools::Screenshot)
190
+ if options[:image].is_a? ChunkyPNG::Image
191
+ Applitools::Screenshot.from_image options[:image]
192
+ elsif !options[:image_path].nil? && !options[:image_path].empty?
193
+ Applitools::Screenshot.from_datastream ChunkyPNG::Datastream.from_file(options[:image_path]).to_s
194
+ elsif !options[:image_bytes].nil? && !options[:image_bytes].empty?
195
+ Applitools::Screenshot.from_datastream options[:image_bytes]
196
+ end
197
+ else
198
+ options[:image]
199
+ end
198
200
 
199
201
  Applitools::ArgumentGuard.not_nil image, 'options[:image] can\'t be nil!'
200
202
 
@@ -84,8 +84,11 @@ module Applitools::Images
84
84
  " screenshot bounds #{bounds}"
85
85
  end
86
86
 
87
- sub_screenshot_image = Applitools::Screenshot.new image.crop(sub_screen_region.left, sub_screen_region.top,
88
- sub_screen_region.width, sub_screen_region.height).to_datastream.to_blob
87
+ sub_screenshot_image = Applitools::Screenshot.from_any_image(
88
+ image.crop(
89
+ sub_screen_region.left, sub_screen_region.top, sub_screen_region.width, sub_screen_region.height
90
+ ).to_datastream.to_blob
91
+ )
89
92
 
90
93
  relative_sub_screenshot_region = convert_region_location(sub_screen_region, SCREENSHOT_AS_IS, CONTEXT_RELATIVE)
91
94
 
@@ -1,3 +1,3 @@
1
1
  module Applitools
2
- VERSION = '3.0.8'.freeze
2
+ VERSION = '3.1.1'.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.0.8
4
+ version: 3.1.1
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-03-31 00:00:00.000000000 Z
11
+ date: 2017-04-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oily_png
@@ -217,6 +217,7 @@ files:
217
217
  - lib/applitools/core/eyes_screenshot.rb
218
218
  - lib/applitools/core/fixed_cut_provider.rb
219
219
  - lib/applitools/core/fixed_scale_provider.rb
220
+ - lib/applitools/core/hash_extension.rb
220
221
  - lib/applitools/core/helpers.rb
221
222
  - lib/applitools/core/location.rb
222
223
  - lib/applitools/core/match_result.rb