eyes_core 3.14.0 → 3.14.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (41) hide show
  1. checksums.yaml +4 -4
  2. data/lib/applitools/calabash/calabash_element.rb +62 -0
  3. data/lib/applitools/calabash/calabash_screenshot_provider.rb +81 -0
  4. data/lib/applitools/calabash/environment_detector.rb +23 -0
  5. data/lib/applitools/calabash/eyes.rb +182 -0
  6. data/lib/applitools/calabash/eyes_calabash_android_screenshot.rb +56 -0
  7. data/lib/applitools/calabash/eyes_calabash_ios_screenshot.rb +28 -0
  8. data/lib/applitools/calabash/eyes_calabash_screenshot.rb +78 -0
  9. data/lib/applitools/calabash/eyes_hooks.rb +51 -0
  10. data/lib/applitools/calabash/eyes_settings.rb +43 -0
  11. data/lib/applitools/calabash/full_page_capture_algorithm.rb +24 -0
  12. data/lib/applitools/calabash/full_page_capture_algorithm/android_scroll_view.rb +85 -0
  13. data/lib/applitools/calabash/full_page_capture_algorithm/base.rb +49 -0
  14. data/lib/applitools/calabash/full_page_capture_algorithm/ios_ui_table_view.rb +148 -0
  15. data/lib/applitools/calabash/os_versions.rb +23 -0
  16. data/lib/applitools/calabash/rspec_matchers.rb +22 -0
  17. data/lib/applitools/calabash/steps/android_eyes_session.rb +35 -0
  18. data/lib/applitools/calabash/steps/android_matchers.rb +34 -0
  19. data/lib/applitools/calabash/steps/eyes_session.rb +40 -0
  20. data/lib/applitools/calabash/steps/eyes_settings.rb +57 -0
  21. data/lib/applitools/calabash/steps/ios_eyes_session.rb +13 -0
  22. data/lib/applitools/calabash/steps/ios_matchers.rb +15 -0
  23. data/lib/applitools/calabash/steps/matchers.rb +69 -0
  24. data/lib/applitools/calabash/target.rb +67 -0
  25. data/lib/applitools/calabash/utils.rb +72 -0
  26. data/lib/applitools/calabash_steps.rb +14 -0
  27. data/lib/applitools/chunky_png_patch.rb +1 -0
  28. data/lib/applitools/connectivity/server_connector.rb +5 -4
  29. data/lib/applitools/core/abstract_region.rb +16 -0
  30. data/lib/applitools/core/class_name.rb +7 -0
  31. data/lib/applitools/core/eyes_base.rb +2 -0
  32. data/lib/applitools/core/floating_region.rb +17 -4
  33. data/lib/applitools/core/fluent_interface.rb +8 -0
  34. data/lib/applitools/core/location.rb +7 -0
  35. data/lib/applitools/core/match_window_data.rb +1 -1
  36. data/lib/applitools/core/rectangle_size.rb +8 -2
  37. data/lib/applitools/core/region.rb +9 -1
  38. data/lib/applitools/rspec/target_matcher.rb +23 -0
  39. data/lib/applitools/utils/eyes_selenium_utils.rb +0 -2
  40. data/lib/applitools/version.rb +1 -1
  41. metadata +30 -2
@@ -0,0 +1,14 @@
1
+ Applitools::Calabash.require_environment(
2
+ 'applitools/calabash/steps/matchers',
3
+ Applitools::Calabash::EnvironmentDetector.current_environment
4
+ )
5
+
6
+ Applitools::Calabash.require_environment(
7
+ 'applitools/calabash/steps/eyes_settings',
8
+ Applitools::Calabash::EnvironmentDetector.current_environment
9
+ )
10
+
11
+ Applitools::Calabash.require_environment(
12
+ 'applitools/calabash/steps/eyes_session',
13
+ Applitools::Calabash::EnvironmentDetector.current_environment
14
+ )
@@ -1,4 +1,5 @@
1
1
  require 'oily_png'
2
+ # require 'chunky_png'
2
3
  require_relative 'chunky_png/resampling'
3
4
  require 'eyes_core/eyes_core'
4
5
 
@@ -100,12 +100,13 @@ module Applitools::Connectivity
100
100
  end
101
101
 
102
102
  def start_session(session_start_info)
103
+ request_body = Oj.dump(
104
+ startInfo: Applitools::Utils.camelcase_hash_keys(session_start_info.to_hash)
105
+ )
103
106
  res = post(
104
- endpoint_url, body: Oj.dump(
105
- startInfo: Applitools::Utils.camelcase_hash_keys(session_start_info.to_hash)
106
- )
107
+ endpoint_url, body: request_body
107
108
  )
108
- raise Applitools::EyesError.new("Request failed: #{res.status} #{res.body}") unless res.success?
109
+ raise Applitools::EyesError.new("Request failed: #{res.status} #{res.body} #{request_body}") unless res.success?
109
110
 
110
111
  response = Oj.load(res.body)
111
112
  Applitools::Session.new(response['id'], response['url'], res.status == HTTP_STATUS_CODES[:created])
@@ -0,0 +1,16 @@
1
+ module Applitools
2
+ class AbstractRegion
3
+ class << self
4
+ def ===(other)
5
+ result = true
6
+ result &&= other.respond_to?(:location)
7
+ result &&= other.respond_to?(:size)
8
+ result &&= other.location.respond_to?(:x)
9
+ result &&= other.location.respond_to?(:y)
10
+ result &&= other.size.respond_to?(:width)
11
+ result &&= other.size.respond_to?(:height)
12
+ result
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,7 @@
1
+ module Applitools
2
+ class ClassName < String
3
+ def ===(other)
4
+ self == other.class.name
5
+ end
6
+ end
7
+ end
@@ -608,6 +608,8 @@ module Applitools
608
608
  screenshot = screenshot.sub_screenshot region, region_provider.coordinate_type, false
609
609
  end
610
610
 
611
+ screenshot = yield(screenshot) if block_given?
612
+
611
613
  logger.info 'Compressing screenshot...'
612
614
  compress_result = compress_screenshot64 screenshot, last_screenshot
613
615
  logger.info 'Done! Getting title...'
@@ -32,6 +32,7 @@ module Applitools
32
32
  end
33
33
 
34
34
  attr_accessor :max_top_offset, :max_right_offset, :max_bottom_offset, :max_left_offset
35
+
35
36
  NAMES = [
36
37
  :left, :top, :width, :height, :max_left_offset, :max_top_offset, :max_right_offset, :max_bottom_offset
37
38
  ].freeze
@@ -60,14 +61,26 @@ module Applitools
60
61
  raise(
61
62
  Applitools::EyesIllegalArgument,
62
63
  '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)'
64
+ 'Applitools::FloatingRegion.new(region, floating_bounds)' \
65
+ 'or ' \
66
+ 'Applitools::FloatingRegion.new(left, top, width, height, ' \
67
+ 'bounds_leeft, bounds_top, bounds_right, bounds_bottom)'
67
68
  )
68
69
  end
69
70
  end
70
71
 
72
+ def scale_it!(scale_factor)
73
+ self.left *= scale_factor
74
+ self.top *= scale_factor
75
+ self.width *= scale_factor
76
+ self.height *= scale_factor
77
+ self.max_left_offset *= scale_factor
78
+ self.max_top_offset *= scale_factor
79
+ self.max_right_offset *= scale_factor
80
+ self.max_bottom_offset *= scale_factor
81
+ self
82
+ end
83
+
71
84
  def to_hash
72
85
  {
73
86
  'Top' => top,
@@ -1,6 +1,14 @@
1
1
  require_relative 'match_level_setter'
2
2
  module Applitools::FluentInterface
3
3
  include Applitools::MatchLevelSetter
4
+
5
+ def self.included(base)
6
+ base.define_singleton_method(:===) do |other|
7
+ return name == other if other.is_a? String
8
+ super(other)
9
+ end
10
+ end
11
+
4
12
  def ignore_caret(value = false)
5
13
  options[:ignore_caret] = value ? true : false
6
14
  self
@@ -80,5 +80,12 @@ module Applitools
80
80
  @y -= other.y
81
81
  self
82
82
  end
83
+
84
+ def scale_it!(scale_factor)
85
+ raise Applitools::EyesIllegalArgument, 'scale_factor must be an integer' unless scale_factor.is_a? Integer
86
+ @x *= scale_factor
87
+ @y *= scale_factor
88
+ self
89
+ end
83
90
  end
84
91
  end
@@ -225,7 +225,7 @@ module Applitools
225
225
  def convert_floating_regions_coordinates
226
226
  return unless @need_convert_floating_regions_coordinates
227
227
  self.floating_regions = @floating_regions.map do |r|
228
- r.location = app_output.screenshot.convert_location(
228
+ r.location = app_output.screenshot.convert_region_location(
229
229
  r.location,
230
230
  Applitools::EyesScreenshot::COORDINATE_TYPES[:context_relative],
231
231
  Applitools::EyesScreenshot::COORDINATE_TYPES[:screenshot_as_is]
@@ -15,11 +15,11 @@ module Applitools
15
15
 
16
16
  def from_string(value)
17
17
  width, height = value.split(/x/)
18
- new width, height
18
+ new width.to_i, height.to_i
19
19
  end
20
20
 
21
21
  def from_hash(value)
22
- new value[:width], value[:height]
22
+ new value[:width].to_i, value[:height].to_i
23
23
  end
24
24
 
25
25
  def from_struct(value)
@@ -48,6 +48,12 @@ module Applitools
48
48
  self
49
49
  end
50
50
 
51
+ def scale_it!(scale_factor)
52
+ self.width *= scale_factor
53
+ self.height *= scale_factor
54
+ self
55
+ end
56
+
51
57
  def to_hash
52
58
  to_h
53
59
  end
@@ -41,7 +41,7 @@ module Applitools
41
41
  end
42
42
 
43
43
  def location
44
- Location.new left, top
44
+ Applitools::Location.new left, top
45
45
  end
46
46
 
47
47
  def location=(other_location)
@@ -91,6 +91,14 @@ module Applitools
91
91
  Applitools::Location.for(mid_x.round, mid_y.round)
92
92
  end
93
93
 
94
+ def scale_it!(scale_factor)
95
+ @left = (@left * scale_factor).to_i
96
+ @top = (@top * scale_factor).to_i
97
+ @width = (@width * scale_factor).to_i
98
+ @height = (@height * scale_factor).to_i
99
+ self
100
+ end
101
+
94
102
  def sub_regions(subregion_size, is_fixed_size = false)
95
103
  return self.class.sub_regions_with_fixed_size self, subregion_size if is_fixed_size
96
104
  self.class.sub_regions_with_varying_size self, subregion_size
@@ -0,0 +1,23 @@
1
+ require 'rspec/expectations'
2
+
3
+ RSpec::Matchers.define :match_baseline do |expected, tag|
4
+ match do |actual|
5
+ unless expected.is_a? Applitools::EyesBase
6
+ raise Applitools::EyesIllegalArgument.new(
7
+ "Expected #{expected} to be a Applitools::EyesBase instance, but got #{expected.class.name}."
8
+ )
9
+ end
10
+
11
+ eyes_selenium_target = Applitools::ClassName.new('Applitools::Selenium::Target')
12
+ eyes_images_target = Applitools::ClassName.new('Applitools::Images::Target')
13
+
14
+ case actual
15
+ when eyes_selenium_target, eyes_images_target
16
+ result = expected.check(tag, actual)
17
+ return result if [TrueClass, FalseClass].include?(result.class)
18
+ return result.as_expected? if result.respond_to? :as_expected?
19
+ else
20
+ false
21
+ end
22
+ end
23
+ end
@@ -187,7 +187,6 @@ module Applitools::Utils
187
187
 
188
188
  # @param [Applitools::Selenium::Driver] executor
189
189
  def entire_page_size(executor)
190
- return Applitools::MOCK_ENTIRE_SIZE if defined?(Applitools::MOCK_ENTIRE_SIZE)
191
190
  metrics = page_metrics(executor)
192
191
  max_document_element_height = [metrics[:client_height], metrics[:scroll_height]].max
193
192
  max_body_height = [metrics[:body_client_height], metrics[:body_scroll_height]].max
@@ -199,7 +198,6 @@ module Applitools::Utils
199
198
  end
200
199
 
201
200
  def current_frame_content_entire_size(executor)
202
- return Applitools::MOCK_ENTIRE_SIZE if defined?(Applitools::MOCK_ENTIRE_SIZE)
203
201
  dimensions = executor.execute_script(JS_GET_CONTENT_ENTIRE_SIZE)
204
202
  Applitools::RectangleSize.new(dimensions.first.to_i, dimensions.last.to_i)
205
203
  rescue
@@ -1,3 +1,3 @@
1
1
  module Applitools
2
- VERSION = '3.14.0'.freeze
2
+ VERSION = '3.14.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.14.0
4
+ version: 3.14.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-12-12 00:00:00.000000000 Z
11
+ date: 2017-12-29 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: oily_png
@@ -203,16 +203,43 @@ files:
203
203
  - ext/eyes_core/extconf.rb
204
204
  - ext/eyes_core/eyes_core.c
205
205
  - ext/eyes_core/eyes_core.h
206
+ - lib/applitools/calabash/calabash_element.rb
207
+ - lib/applitools/calabash/calabash_screenshot_provider.rb
208
+ - lib/applitools/calabash/environment_detector.rb
209
+ - lib/applitools/calabash/eyes.rb
210
+ - lib/applitools/calabash/eyes_calabash_android_screenshot.rb
211
+ - lib/applitools/calabash/eyes_calabash_ios_screenshot.rb
212
+ - lib/applitools/calabash/eyes_calabash_screenshot.rb
213
+ - lib/applitools/calabash/eyes_hooks.rb
214
+ - lib/applitools/calabash/eyes_settings.rb
215
+ - lib/applitools/calabash/full_page_capture_algorithm.rb
216
+ - lib/applitools/calabash/full_page_capture_algorithm/android_scroll_view.rb
217
+ - lib/applitools/calabash/full_page_capture_algorithm/base.rb
218
+ - lib/applitools/calabash/full_page_capture_algorithm/ios_ui_table_view.rb
219
+ - lib/applitools/calabash/os_versions.rb
220
+ - lib/applitools/calabash/rspec_matchers.rb
221
+ - lib/applitools/calabash/steps/android_eyes_session.rb
222
+ - lib/applitools/calabash/steps/android_matchers.rb
223
+ - lib/applitools/calabash/steps/eyes_session.rb
224
+ - lib/applitools/calabash/steps/eyes_settings.rb
225
+ - lib/applitools/calabash/steps/ios_eyes_session.rb
226
+ - lib/applitools/calabash/steps/ios_matchers.rb
227
+ - lib/applitools/calabash/steps/matchers.rb
228
+ - lib/applitools/calabash/target.rb
229
+ - lib/applitools/calabash/utils.rb
230
+ - lib/applitools/calabash_steps.rb
206
231
  - lib/applitools/capybara.rb
207
232
  - lib/applitools/chunky_png/resampling.rb
208
233
  - lib/applitools/chunky_png_patch.rb
209
234
  - lib/applitools/connectivity/proxy.rb
210
235
  - lib/applitools/connectivity/server_connector.rb
236
+ - lib/applitools/core/abstract_region.rb
211
237
  - lib/applitools/core/app_environment.rb
212
238
  - lib/applitools/core/app_output.rb
213
239
  - lib/applitools/core/app_output_with_screenshot.rb
214
240
  - lib/applitools/core/argument_guard.rb
215
241
  - lib/applitools/core/batch_info.rb
242
+ - lib/applitools/core/class_name.rb
216
243
  - lib/applitools/core/debug_screenshot_provider.rb
217
244
  - lib/applitools/core/eyes_base.rb
218
245
  - lib/applitools/core/eyes_screenshot.rb
@@ -244,6 +271,7 @@ files:
244
271
  - lib/applitools/extensions.rb
245
272
  - lib/applitools/eyes_logger.rb
246
273
  - lib/applitools/method_tracer.rb
274
+ - lib/applitools/rspec/target_matcher.rb
247
275
  - lib/applitools/sauce.rb
248
276
  - lib/applitools/utils/eyes_selenium_utils.rb
249
277
  - lib/applitools/utils/image_delta_compressor.rb