eyes_core 4.6.3 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +504 -0
  3. data/Rakefile +35 -0
  4. data/eyes_core.gemspec +60 -0
  5. data/lib/applitools/core/batch_info.rb +2 -0
  6. data/lib/applitools/core/classic_runner.rb +1 -3
  7. data/lib/applitools/core/eyes_base.rb +110 -22
  8. data/lib/applitools/core/eyes_base_configuration.rb +9 -1
  9. data/lib/applitools/core/eyes_runner.rb +3 -2
  10. data/lib/applitools/core/test_result_summary.rb +7 -7
  11. data/lib/applitools/core/test_results.rb +19 -3
  12. data/lib/applitools/core/universal_eyes_checks.rb +2 -1
  13. data/lib/applitools/core/universal_eyes_open.rb +5 -1
  14. data/lib/applitools/eyes_core/version.rb +10 -0
  15. data/lib/applitools/universal_sdk/universal_client.rb +26 -10
  16. data/lib/applitools/universal_sdk/universal_eyes.rb +5 -0
  17. data/lib/applitools/universal_sdk/universal_eyes_config.rb +10 -9
  18. data/lib/applitools/universal_sdk/universal_eyes_manager.rb +1 -1
  19. data/lib/eyes_core.rb +1 -3
  20. metadata +14 -58
  21. data/ext/eyes_core/extconf.rb +0 -5
  22. data/ext/eyes_core/eyes_core.c +0 -252
  23. data/ext/eyes_core/eyes_core.h +0 -28
  24. data/lib/applitools/appium/android_region_provider.rb +0 -32
  25. data/lib/applitools/appium/android_screenshot.rb +0 -21
  26. data/lib/applitools/appium/driver.rb +0 -12
  27. data/lib/applitools/appium/eyes.rb +0 -189
  28. data/lib/applitools/appium/ios_region_provider.rb +0 -25
  29. data/lib/applitools/appium/ios_screenshot.rb +0 -10
  30. data/lib/applitools/appium/region_provider.rb +0 -51
  31. data/lib/applitools/appium/screenshot.rb +0 -30
  32. data/lib/applitools/appium/target.rb +0 -240
  33. data/lib/applitools/appium/utils.rb +0 -64
  34. data/lib/applitools/calabash/calabash_element.rb +0 -64
  35. data/lib/applitools/calabash/calabash_screenshot_provider.rb +0 -83
  36. data/lib/applitools/calabash/environment_detector.rb +0 -25
  37. data/lib/applitools/calabash/eyes.rb +0 -194
  38. data/lib/applitools/calabash/eyes_calabash_android_screenshot.rb +0 -68
  39. data/lib/applitools/calabash/eyes_calabash_ios_screenshot.rb +0 -30
  40. data/lib/applitools/calabash/eyes_calabash_screenshot.rb +0 -80
  41. data/lib/applitools/calabash/eyes_hooks.rb +0 -51
  42. data/lib/applitools/calabash/eyes_settings.rb +0 -45
  43. data/lib/applitools/calabash/full_page_capture_algorithm/android_scroll_view.rb +0 -95
  44. data/lib/applitools/calabash/full_page_capture_algorithm/base.rb +0 -51
  45. data/lib/applitools/calabash/full_page_capture_algorithm/ios_ui_table_view.rb +0 -150
  46. data/lib/applitools/calabash/full_page_capture_algorithm.rb +0 -26
  47. data/lib/applitools/calabash/os_versions.rb +0 -25
  48. data/lib/applitools/calabash/rspec_matchers.rb +0 -25
  49. data/lib/applitools/calabash/steps/android_eyes_session.rb +0 -37
  50. data/lib/applitools/calabash/steps/android_matchers.rb +0 -36
  51. data/lib/applitools/calabash/steps/eyes_session.rb +0 -42
  52. data/lib/applitools/calabash/steps/eyes_settings.rb +0 -59
  53. data/lib/applitools/calabash/steps/ios_eyes_session.rb +0 -15
  54. data/lib/applitools/calabash/steps/ios_matchers.rb +0 -17
  55. data/lib/applitools/calabash/steps/matchers.rb +0 -71
  56. data/lib/applitools/calabash/target.rb +0 -69
  57. data/lib/applitools/calabash/utils.rb +0 -74
  58. data/lib/applitools/calabash_steps.rb +0 -16
  59. data/lib/applitools/capybara/capybara_settings.rb +0 -25
  60. data/lib/applitools/capybara/driver.rb +0 -39
  61. data/lib/applitools/rspec/target_matcher.rb +0 -25
  62. data/lib/applitools/universal_sdk/executable_finder.rb +0 -57
  63. data/lib/applitools/universal_sdk/universal_server_control.rb +0 -79
  64. data/lib/applitools/version.rb +0 -8
  65. data/lib/eyes_consts.rb +0 -4
  66. data/lib/eyes_rspec.rb +0 -4
@@ -1,150 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative 'base'
4
-
5
- module Applitools
6
- module Calabash
7
- module FullPageCaptureAlgorithm
8
- class IosUITableView < Base
9
- NSSIZE = /^.*: {(?<width>\d+), (?<height>\d+)}$/
10
- NEXT_REQUEST_DELAY = 0.5
11
- CROP_SHADOW_BOUNDS = 5
12
-
13
- def initialize(*args)
14
- super
15
- @entire_content = nil
16
- @stitched_image = nil
17
- @original_position = nil
18
- @entire_size = nil
19
- @eyes_window = nil
20
- end
21
-
22
- def get_stitched_region(scroll_to_top = true)
23
- create_entire_image
24
- store_original_position
25
- scroll_left_top if scroll_to_top
26
-
27
- scroll_it! do |position, cut_vertical, cut_horizontal|
28
- current_region = cutted_eyes_window(cut_vertical ? :top : :none)
29
- current_region = cutted_eyes_window(cut_horizontal ? :left : :none, current_region)
30
-
31
- current_position = updated_position(cut_vertical ? :top : :none, position.dup)
32
- current_position = updated_position(cut_horizontal ? :left : :none, current_position)
33
-
34
- put_it_on_canvas!(
35
- screenshot_provider.capture_screenshot.sub_screenshot(
36
- current_region,
37
- Applitools::Calabash::EyesCalabashScreenshot::DRIVER,
38
- false,
39
- false
40
- ).image.image,
41
- current_position.scale_it!(screenshot_provider.density)
42
- )
43
- end
44
-
45
- Applitools::Calabash::EyesCalabashIosScreenshot.new(
46
- Applitools::Screenshot.from_image(stitched_image),
47
- scale_factor: screenshot_provider.density
48
- )
49
- end
50
-
51
- def cutted_eyes_window(side, region = eyes_window)
52
- case side
53
- when :top
54
- Applitools::Region.new(
55
- region.left,
56
- region.top + CROP_SHADOW_BOUNDS,
57
- region.width,
58
- region.height - CROP_SHADOW_BOUNDS
59
- )
60
- when :left
61
- Applitools::Region.new(
62
- region.left + CROP_SHADOW_BOUNDS,
63
- region.top,
64
- region.width - CROP_SHADOW_BOUNDS,
65
- region.height
66
- )
67
- else
68
- region.dup
69
- end
70
- end
71
-
72
- def updated_position(side, position)
73
- case side
74
- when :top
75
- position.offset Applitools::Location.new(0, CROP_SHADOW_BOUNDS)
76
- when :left
77
- position.offset Applitools::Location.new(CROP_SHADOW_BOUNDS, 0)
78
- else
79
- position
80
- end
81
- end
82
-
83
- def scrollable_element
84
- Applitools::Calabash::Utils.get_ios_element(context, element.element_query, 0)
85
- end
86
-
87
- def entire_size
88
- @entire_size ||= query_entire_size
89
- end
90
-
91
- def query_entire_size
92
- result = NSSIZE.match(Applitools::Calabash::Utils.request_element(context, element, :contentSize).first)
93
- Applitools::RectangleSize.new(
94
- result[:width].to_i, result[:height].to_i
95
- ).scale_it!(screenshot_provider.density)
96
- end
97
-
98
- def query_current_position
99
- result = Applitools::Calabash::Utils.request_element(context, element, :contentOffset).first
100
- Applitools::Location.new(
101
- result['X'].to_i,
102
- result['Y'].to_i
103
- )
104
- end
105
-
106
- def store_original_position
107
- current_scrollable_element = Applitools::Calabash::Utils.request_element(context, element, :contentSize).first
108
- @original_position = Applitools::Location.new(
109
- current_scrollable_element['X'],
110
- current_scrollable_element['Y']
111
- )
112
- end
113
-
114
- def restore_original_position; end
115
-
116
- def scroll_it!
117
- scroll_in_one_dimension(:down) do |pos, is_first_vertical|
118
- scroll_in_one_dimension(:right, pos) do |position, is_first_horizontal|
119
- yield(position, !is_first_vertical, !is_first_horizontal) if block_given?
120
- end
121
- end
122
- end
123
-
124
- def scroll_in_one_dimension(direction, position = nil)
125
- previous_position = position || query_current_position
126
- is_first = true
127
- loop do
128
- yield(previous_position, is_first) if block_given?
129
- is_first = false if is_first
130
- context.scroll(element.element_query, direction)
131
- sleep NEXT_REQUEST_DELAY
132
- new_position = query_current_position
133
- return if previous_position == new_position
134
- previous_position = new_position
135
- end
136
- end
137
-
138
- def scroll_left_top
139
- scroll_in_one_dimension(:up) do |position, _is_first, _direction|
140
- scroll_in_one_dimension(:left, position)
141
- end
142
- end
143
-
144
- def eyes_window
145
- @eyes_window ||= Applitools::Region.from_location_size(element.location, element.size)
146
- end
147
- end
148
- end
149
- end
150
- end
@@ -1,26 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Applitools::Calabash.require_dir 'calabash/full_page_capture_algorithm'
4
-
5
- module Applitools
6
- module Calabash
7
- module FullPageCaptureAlgorithm
8
- ANDROID_ALGORITHMS = {
9
- 'android.widget.ScrollView' => Applitools::Calabash::FullPageCaptureAlgorithm::AndroidScrollView
10
- }.freeze
11
- IOS_ALGORITHMS = {
12
- 'UITableView' => Applitools::Calabash::FullPageCaptureAlgorithm::IosUITableView
13
- }.freeze
14
- class << self
15
- def get_algorithm_class(env, klass)
16
- case env
17
- when :ios
18
- IOS_ALGORITHMS[klass]
19
- when :android
20
- ANDROID_ALGORITHMS[klass]
21
- end
22
- end
23
- end
24
- end
25
- end
26
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Applitools
4
- module Calabash
5
- module OsVersions
6
- module Android
7
- extend self
8
- API_TO_NAME = {
9
- 4 => 'Android 1',
10
- 10 => 'Android 2',
11
- 13 => 'Android 3',
12
- 20 => 'Android 4',
13
- 22 => 'Android 5',
14
- 23 => 'Android 6',
15
- 25 => 'Android 7',
16
- 27 => 'Android 8'
17
- }.freeze
18
-
19
- def os_version(api_level)
20
- API_TO_NAME[API_TO_NAME.keys.select { |v| api_level.to_i >= v }.last] || 'Android'
21
- end
22
- end
23
- end
24
- end
25
- end
@@ -1,25 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rspec/expectations'
4
-
5
- RSpec::Matchers.define :match_baseline do |expected|
6
- match do |actual|
7
- eyes = Applitools::Calabash::EyesSettings.instance.eyes
8
- result = eyes.check(expected, actual)
9
- eyes.new_session? || result.as_expected?
10
- end
11
-
12
- failure_message do |_actual|
13
- "expected #{expected} to match a baseline"
14
- end
15
- end
16
-
17
- RSpec::Matchers.define :be_success do
18
- match do |actual|
19
- actual.as_expected? == true
20
- end
21
-
22
- failure_message do |actual|
23
- "Expected eyes session to be successful, but mismatches occur. \n#{actual}"
24
- end
25
- end
@@ -1,37 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Then(/^set OS$/) do
4
- sdk_version = begin
5
- perform_action('android_sdk_version')
6
- rescue HTTPClient::KeepAliveDisconnected
7
- reinstall_apps
8
- start_test_server_in_background
9
- perform_action('android_sdk_version')
10
- end
11
- if sdk_version['success']
12
- Applitools::Calabash::EyesSettings.instance.eyes.host_os = Applitools::Calabash::OsVersions::Android.os_version(
13
- sdk_version['message']
14
- )
15
- end
16
- end
17
-
18
- Then(/^set device pixel ratio$/) do
19
- display_info = `#{default_device.adb_command} shell dumpsys display`
20
- # size_match = /deviceWidth=(?<width>\d+), deviceHeight=(?<height>\d+)/.match(display_info)
21
- density_match = /DisplayDeviceInfo.*density (?<density>\d+)/.match(display_info)
22
- Applitools::Calabash::EyesSettings.instance.eyes.device_pixel_ratio = density_match[:density].to_i
23
- end
24
-
25
- Then(/^set device physical size$/) do
26
- result = /mDefaultViewport=.*deviceWidth=(?<width>\d+).*deviceHeight=(?<height>\d+).*\n/.match(
27
- `#{default_device.adb_command} shell dumpsys display |grep mDefaultViewport`
28
- )
29
- step %(eyes viewport size is "#{result[:width].to_i}x#{result[:height].to_i}")
30
- end
31
-
32
- Then(/^set device size$/) do
33
- result = /^.*app=(?<width>\d+)x(?<height>\d+)/.match(
34
- `#{default_device.adb_command} shell dumpsys window displays |grep cur | tr -d ' '`
35
- )
36
- step %(eyes viewport size is "#{result[:width].to_i}x#{result[:height].to_i}")
37
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Then(/^ignore status bar$/) do
4
- raise Applitools::EyesError, '@target is not set' unless @target
5
- step %(query element "view id:'statusBarBackground'")
6
- @target.ignore @current_element if @current_element
7
- end
8
-
9
- Then(/^remove status bar$/) do
10
- raise Applitools::EyesError, '@target is not set' unless @target
11
- step %(query element "view id:'statusBarBackground'")
12
- if @current_element
13
- viewport_size = Applitools::RectangleSize.from_any_argument(
14
- Applitools::Calabash::EyesSettings.instance.viewport_size
15
- )
16
- region_location = Applitools::Location.new(0, @current_element.size.height)
17
- @target.region(Applitools::Region.from_location_size(region_location, viewport_size))
18
- end
19
- end
20
-
21
- Then(/^the whole screen should match a baseline/) do
22
- step %(create target)
23
- step %(remove status bar)
24
- step %(target should match a baseline)
25
- end
26
-
27
- Then(/^query element "([^"]*)" and take (\d+)$/) do |query, index|
28
- @current_element = nil
29
- @current_element = Applitools::Calabash::Utils.get_android_element(self, query, index)
30
- end
31
-
32
- Then(/^check for scrollable$/) do
33
- unless query('ScrollView').empty?
34
- @present_scrollable = Applitools::Calabash::Utils.get_android_element(self, 'ScrollView', 0)
35
- end
36
- end
@@ -1,42 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Then(/^create eyes$/) do
4
- eyes_settings = Applitools::Calabash::EyesSettings.instance
5
- eyes_settings.eyes ||= Applitools::Calabash::Eyes.new.tap do |eyes|
6
- eyes.api_key = eyes_settings.applitools_api_key
7
- log_file_path = File.join(eyes_settings.log_prefix, eyes_settings.log_file)
8
- eyes.log_handler = Logger.new(File.new(log_file_path, 'w+'))
9
- end
10
-
11
- unless eyes_settings.eyes.open?
12
- step %(set batch "#{@before_hook_scenario.feature.name}")
13
- step %(set OS)
14
- step %(set device pixel ratio)
15
- step %(set device size)
16
- end
17
- end
18
-
19
- Then(/^open eyes$/) do
20
- eyes_settings = Applitools::Calabash::EyesSettings.instance
21
- eyes_settings.eyes.open eyes_settings.options_for_open unless eyes_settings.eyes.open?
22
- end
23
-
24
- When(/^I close eyes session$/) do
25
- @test_result = Applitools::Calabash::EyesSettings.instance.eyes.close(false)
26
- end
27
-
28
- Then(/^test result should be positive$/) do
29
- raise Applitools::EyesError, 'Test result are not present!' unless @test_result
30
- expect(@test_result).to be_success
31
- end
32
-
33
- Then(/^applitools link should be reported$/) do
34
- puts @test_result
35
- end
36
-
37
- Then(/^terminate eyes session$/) do
38
- step %(I close eyes session)
39
- step %(test result should be positive)
40
- step %(applitools link should be reported)
41
- @test_results = nil
42
- end
@@ -1,59 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Given(/^eyes application name is "([^"]*)"$/) do |name|
4
- Applitools::Calabash::EyesSettings.instance.app_name = name
5
- end
6
-
7
- Given(/^eyes test name is "([^"]*)"$/) do |name|
8
- Applitools::Calabash::EyesSettings.instance.test_name = name
9
- end
10
-
11
- Given(/^eyes viewport size is "([^"]*)"$/) do |size|
12
- Applitools::Calabash::EyesSettings.instance.viewport_size = Applitools::RectangleSize.from_any_argument(size)
13
- end
14
-
15
- Given(/^eyes API key "([^"]*)"$/) do |key|
16
- Applitools::Calabash::EyesSettings.instance.applitools_api_key = key
17
- end
18
-
19
- Given(/^eyes tag is "([^"]*)"$/) do |tag|
20
- @tag = tag
21
- end
22
-
23
- Given(/^set batch "([^"]*)"/) do |name|
24
- @current_batch ||= Applitools::Calabash::EyesSettings.instance.eyes.batch.tap do |batch|
25
- batch.name = name
26
- end
27
-
28
- Applitools::Calabash::EyesSettings.instance.eyes.batch = @current_batch
29
- end
30
-
31
- Given(/^calabash screenshot dir is "([^"]*)"$/) do |path|
32
- Applitools::Calabash::EyesSettings.instance.screenshot_dir = path
33
- end
34
-
35
- Given(/^calabash temp dir is "([^"]*)"$/) do |path|
36
- Applitools::Calabash::EyesSettings.instance.tmp_dir = path
37
- end
38
-
39
- Given(/^calabash log path is "([^"]*)"$/) do |path|
40
- Applitools::Calabash::EyesSettings.instance.log_dir = path
41
- end
42
-
43
- Given(/^eyes logfile is "([^"]*)"$/) do |logfile_path|
44
- Applitools::Calabash::EyesSettings.instance.log_file = logfile_path
45
- end
46
-
47
- Given(/^clear directories$/) do
48
- Applitools::Calabash::Utils.clear_directories(Applitools::Calabash::EyesSettings.instance)
49
- end
50
-
51
- Given(/^create directories$/) do
52
- Applitools::Calabash::Utils.create_directories(Applitools::Calabash::EyesSettings.instance)
53
- end
54
-
55
- Given(/^set it up$/) do
56
- step %(clear directories)
57
- step %(create directories)
58
- Applitools::Calabash::EyesSettings.instance.needs_setting_up = false
59
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Then(/^set OS$/) do
4
- Applitools::Calabash::EyesSettings.instance.eyes.host_os = "iOS #{default_device.ios_major_version}"
5
- end
6
-
7
- Then(/^set device pixel ratio$/) do
8
- dimensions = default_device.screen_dimensions
9
- Applitools::Calabash::EyesSettings.instance.eyes.device_pixel_ratio = dimensions[:scale] #:native_scale?
10
- end
11
-
12
- Then(/^set device size$/) do
13
- dimensions = default_device.screen_dimensions
14
- step %(eyes viewport size is "#{dimensions[:width].to_i}x#{dimensions[:height].to_i}")
15
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Then(/^the whole screen should match a baseline/) do
4
- step %(create target)
5
- step %(target should match a baseline)
6
- end
7
-
8
- Then(/^query element "([^"]*)" and take (\d+)$/) do |query, index|
9
- @current_element = nil
10
- @current_element = Applitools::Calabash::Utils.get_ios_element(self, query, index)
11
- end
12
-
13
- Then(/^check for scrollable$/) do
14
- unless query('UIScrollView').empty?
15
- @present_scrollable = Applitools::Calabash::Utils.get_ios_element(self, 'UIScrollView', 0)
16
- end
17
- end
@@ -1,71 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Then(/^create target$/) do
4
- @target = nil
5
- @target = Applitools::Calabash::Target.new
6
- end
7
-
8
- Then(/^target should match a baseline$/) do
9
- raise Applitools::EyesError, '@target is not set' unless @target
10
- @tag ||= ''
11
- expect(@target).to match_baseline(@tag)
12
- end
13
-
14
- Then(/^the element "([^"]*)" should match a baseline$/) do |query|
15
- step %(create target)
16
- step %(query element "#{query}")
17
- @target.region(@current_element) if @current_element
18
- step %(target should match a baseline)
19
- end
20
-
21
- Then(/^the entire element "([^"]*)" should match a baseline$/) do |query|
22
- step %(create target)
23
- step %(query element "#{query}")
24
- @target.region(@current_element).fully if @current_element
25
- step %(target should match a baseline)
26
- end
27
-
28
- Then(/^query element "([^"]*)"$/) do |query|
29
- step %(query element "#{query}" and take 0)
30
- end
31
-
32
- Then(/^I check viewport window$/) do
33
- step %(the whole screen should match a baseline)
34
- end
35
-
36
- Then(/^I check viewport window with description "([^"]*)"$/) do |description|
37
- step %(eyes tag is "#{description}")
38
- step %(I check viewport window)
39
- end
40
-
41
- Then(/^I check window$/) do
42
- step %(check for scrollable)
43
- if @present_scrollable
44
- step %(the entire element "#{@present_scrollable.element_query}" should match a baseline)
45
- else
46
- step %(I check viewport window)
47
- end
48
- end
49
-
50
- Then(/^I check window with description "([^"]*)"$/) do |description|
51
- step %(eyes tag is "#{description}")
52
- step %(I check window)
53
- end
54
-
55
- Then(/^I check viewport element "([^"]*)"$/) do |selector|
56
- step %(the element "#{selector}" should match a baseline)
57
- end
58
-
59
- Then(/^I check viewport element "([^"]*)" with description "([^"]*)"$/) do |selector, description|
60
- step %(eyes tag is "#{description}")
61
- step %(I check viewport element "#{selector}")
62
- end
63
-
64
- Then(/^I check element "([^"]*)"$/) do |selector|
65
- step %(the entire element "#{selector}" should match a baseline)
66
- end
67
-
68
- Then(/^I check element "([^"]*)" with description "([^"]*)"$/) do |selector, description|
69
- step %(eyes tag is "#{description}")
70
- step %(I check element "#{selector}")
71
- end
@@ -1,69 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Applitools
4
- module Calabash
5
- class Target
6
- include Applitools::FluentInterface
7
-
8
- attr_accessor :options, :ignored_regions, :region_to_check, :floating_regions
9
-
10
- def initialize
11
- self.ignored_regions = []
12
- self.floating_regions = []
13
- self.options = {
14
- trim: false
15
- }
16
- end
17
-
18
- def fully
19
- options[:stitch_content] = true
20
- self
21
- end
22
-
23
- def ignore(region = nil)
24
- if region
25
- Applitools::ArgumentGuard.is_a? region, 'region', Applitools::Calabash::CalabashElement
26
- ignored_regions << region.region
27
- else
28
- self.ignored_regions = []
29
- end
30
- self
31
- end
32
-
33
- def region(region = nil)
34
- if region
35
- case region
36
- when Applitools::Calabash::CalabashElement, Applitools::Region
37
- self.region_to_check = region
38
- else
39
- self.region_to_check = nil
40
- raise(
41
- Applitools::EyesIllegalArgument,
42
- 'Expected region to be instance of Applitools::Calabash::CalabashElement or Applitools::Region'
43
- )
44
- end
45
- else
46
- self.region_to_check = nil
47
- end
48
- self
49
- end
50
-
51
- # def floating(*args)
52
- # value = case args.first
53
- # when Applitools::FloatingRegion
54
- # proc { args.first.scale_it!(scale_factor) }
55
- # when Applitools::Region
56
- # proc do
57
- # region = args.shift
58
- # region.scale_it!(scale_factor)
59
- # Applitools::FloatingRegion.new region.left, region.top, region.width, region.height, *args
60
- # end
61
- # else
62
- # self.floating_regions = []
63
- # end
64
- # floating_regions << value
65
- # self
66
- # end
67
- end
68
- end
69
- end
@@ -1,74 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module Applitools
4
- module Calabash
5
- module Utils
6
- extend self
7
-
8
- def create_directories(eyes_settings)
9
- FileUtils.mkpath(
10
- File.join(Dir.getwd, eyes_settings.tmp_dir, eyes_settings.screenshot_dir)
11
- )
12
- FileUtils.mkpath(
13
- File.join(Dir.getwd, eyes_settings.log_dir)
14
- )
15
- end
16
-
17
- def clear_directories(eyes_settings)
18
- tmp_dir = File.join Dir.getwd, eyes_settings.tmp_dir
19
- log_dir = File.join Dir.getwd, eyes_settings.log_dir
20
-
21
- FileUtils.remove_dir(tmp_dir) if File.exist?(tmp_dir)
22
- FileUtils.remove_dir(log_dir) if File.exist?(log_dir)
23
- end
24
-
25
- def using_screenshot(context)
26
- return unless block_given?
27
- screenshot_options = Applitools::Calabash::EyesSettings.instance.screenshot_names.next
28
- yield context.screenshot(screenshot_options)
29
- end
30
-
31
- def region_from_element(element)
32
- region = Applitools::Region.new(
33
- element['rect']['x'],
34
- element['rect']['y'],
35
- element['rect']['width'],
36
- element['rect']['height']
37
- )
38
- return region if Applitools::Calabash::EnvironmentDetector.android?
39
- region.scale_it!(Applitools::Calabash::EyesSettings.instance.eyes.density)
40
- end
41
-
42
- def request_element(context, element, method)
43
- Applitools::ArgumentGuard.is_a?(element, 'element', Applitools::Calabash::CalabashElement)
44
- context.query(element.element_query, method)
45
- end
46
-
47
- def grub_android_class_name(context, element)
48
- request_element(context, element, :class)
49
- end
50
-
51
- def grub_ios_class_name(context, element)
52
- request_element(context, element, :className)
53
- end
54
-
55
- def get_android_element(context, query, index)
56
- element_query = if (id = context.query(query, :getId)[index.to_i]) && id > 0
57
- "* id:#{id}"
58
- else
59
- query + " index:#{index.to_i}"
60
- end
61
- element = context.query(element_query).first
62
- Applitools::Calabash::CalabashElement.new(element, element_query)
63
- end
64
-
65
- def get_ios_element(context, query, index)
66
- hash = context.query(query, :hash)[index.to_i]
67
- return unless hash
68
- element_query = "* hash:#{hash}"
69
- element = context.query(element_query).first
70
- Applitools::Calabash::CalabashElement.new(element, element_query)
71
- end
72
- end
73
- end
74
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Applitools::Calabash.require_environment(
4
- 'applitools/calabash/steps/matchers',
5
- Applitools::Calabash::EnvironmentDetector.current_environment
6
- )
7
-
8
- Applitools::Calabash.require_environment(
9
- 'applitools/calabash/steps/eyes_settings',
10
- Applitools::Calabash::EnvironmentDetector.current_environment
11
- )
12
-
13
- Applitools::Calabash.require_environment(
14
- 'applitools/calabash/steps/eyes_session',
15
- Applitools::Calabash::EnvironmentDetector.current_environment
16
- )