eyes_core 5.0.0 → 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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +504 -0
- data/Rakefile +35 -0
- data/eyes_core.gemspec +60 -0
- data/lib/applitools/core/batch_info.rb +2 -0
- data/lib/applitools/core/eyes_base.rb +106 -18
- data/lib/applitools/core/eyes_base_configuration.rb +9 -3
- data/lib/applitools/core/eyes_runner.rb +3 -2
- data/lib/applitools/core/test_results.rb +6 -1
- data/lib/applitools/core/universal_eyes_checks.rb +2 -1
- data/lib/applitools/core/universal_eyes_open.rb +2 -1
- data/lib/applitools/eyes_core/version.rb +10 -0
- data/lib/applitools/universal_sdk/universal_client.rb +26 -10
- data/lib/applitools/universal_sdk/universal_eyes_config.rb +10 -9
- data/lib/eyes_core.rb +1 -3
- metadata +14 -58
- data/ext/eyes_core/extconf.rb +0 -5
- data/ext/eyes_core/eyes_core.c +0 -252
- data/ext/eyes_core/eyes_core.h +0 -28
- data/lib/applitools/appium/android_region_provider.rb +0 -32
- data/lib/applitools/appium/android_screenshot.rb +0 -21
- data/lib/applitools/appium/driver.rb +0 -12
- data/lib/applitools/appium/eyes.rb +0 -189
- data/lib/applitools/appium/ios_region_provider.rb +0 -25
- data/lib/applitools/appium/ios_screenshot.rb +0 -10
- data/lib/applitools/appium/region_provider.rb +0 -51
- data/lib/applitools/appium/screenshot.rb +0 -30
- data/lib/applitools/appium/target.rb +0 -240
- data/lib/applitools/appium/utils.rb +0 -64
- data/lib/applitools/calabash/calabash_element.rb +0 -64
- data/lib/applitools/calabash/calabash_screenshot_provider.rb +0 -83
- data/lib/applitools/calabash/environment_detector.rb +0 -25
- data/lib/applitools/calabash/eyes.rb +0 -194
- data/lib/applitools/calabash/eyes_calabash_android_screenshot.rb +0 -68
- data/lib/applitools/calabash/eyes_calabash_ios_screenshot.rb +0 -30
- data/lib/applitools/calabash/eyes_calabash_screenshot.rb +0 -80
- data/lib/applitools/calabash/eyes_hooks.rb +0 -51
- data/lib/applitools/calabash/eyes_settings.rb +0 -45
- data/lib/applitools/calabash/full_page_capture_algorithm/android_scroll_view.rb +0 -95
- data/lib/applitools/calabash/full_page_capture_algorithm/base.rb +0 -51
- data/lib/applitools/calabash/full_page_capture_algorithm/ios_ui_table_view.rb +0 -150
- data/lib/applitools/calabash/full_page_capture_algorithm.rb +0 -26
- data/lib/applitools/calabash/os_versions.rb +0 -25
- data/lib/applitools/calabash/rspec_matchers.rb +0 -25
- data/lib/applitools/calabash/steps/android_eyes_session.rb +0 -37
- data/lib/applitools/calabash/steps/android_matchers.rb +0 -36
- data/lib/applitools/calabash/steps/eyes_session.rb +0 -42
- data/lib/applitools/calabash/steps/eyes_settings.rb +0 -59
- data/lib/applitools/calabash/steps/ios_eyes_session.rb +0 -15
- data/lib/applitools/calabash/steps/ios_matchers.rb +0 -17
- data/lib/applitools/calabash/steps/matchers.rb +0 -71
- data/lib/applitools/calabash/target.rb +0 -69
- data/lib/applitools/calabash/utils.rb +0 -74
- data/lib/applitools/calabash_steps.rb +0 -16
- data/lib/applitools/capybara/capybara_settings.rb +0 -25
- data/lib/applitools/capybara/driver.rb +0 -39
- data/lib/applitools/rspec/target_matcher.rb +0 -25
- data/lib/applitools/universal_sdk/executable_finder.rb +0 -57
- data/lib/applitools/universal_sdk/universal_server_control.rb +0 -79
- data/lib/applitools/version.rb +0 -8
- data/lib/eyes_consts.rb +0 -4
- data/lib/eyes_rspec.rb +0 -4
data/ext/eyes_core/eyes_core.c
DELETED
@@ -1,252 +0,0 @@
|
|
1
|
-
#include "eyes_core.h"
|
2
|
-
|
3
|
-
void Init_eyes_core() {
|
4
|
-
VALUE Applitools = rb_define_module("Applitools");
|
5
|
-
VALUE Resampling = rb_define_module_under(Applitools, "ResamplingFast");
|
6
|
-
rb_define_method(Resampling, "resampling_first_step", c_resampling_first_step, 2);
|
7
|
-
};
|
8
|
-
|
9
|
-
VALUE c_resampling_first_step(VALUE self, VALUE dst_dimension_x, VALUE dst_dimension_y) {
|
10
|
-
PIXEL *source, *destination;
|
11
|
-
unsigned long int source_width, source_height, c_dst_dimension_x, c_dst_dimension_y, w_m, h_m;
|
12
|
-
VALUE result_array;
|
13
|
-
|
14
|
-
source_width = NUM2UINT(rb_funcall(self, rb_intern("width"), 0));
|
15
|
-
source_height = NUM2UINT(rb_funcall(self, rb_intern("height"), 0));
|
16
|
-
|
17
|
-
c_dst_dimension_x = NUM2UINT(dst_dimension_x);
|
18
|
-
c_dst_dimension_y = NUM2UINT(dst_dimension_y);
|
19
|
-
|
20
|
-
w_m = source_width / c_dst_dimension_x;
|
21
|
-
h_m = source_height / c_dst_dimension_y;
|
22
|
-
|
23
|
-
if (w_m == 0) {
|
24
|
-
w_m = 1;
|
25
|
-
};
|
26
|
-
|
27
|
-
if (h_m == 0) {
|
28
|
-
h_m = 1;
|
29
|
-
};
|
30
|
-
|
31
|
-
source = get_c_array(self);
|
32
|
-
|
33
|
-
destination = get_bicubic_points(source, source_width, source_height, c_dst_dimension_x * w_m, c_dst_dimension_y * h_m);
|
34
|
-
|
35
|
-
if (w_m * h_m > 1) {
|
36
|
-
source = destination;
|
37
|
-
destination = c_scale_points(source, c_dst_dimension_x, c_dst_dimension_y, w_m, h_m);
|
38
|
-
}
|
39
|
-
|
40
|
-
result_array = get_ruby_array(self, destination, c_dst_dimension_x * c_dst_dimension_y);
|
41
|
-
free(destination);
|
42
|
-
return result_array;
|
43
|
-
};
|
44
|
-
|
45
|
-
VALUE get_ruby_array(VALUE self, PIXEL *pixels, unsigned long int pixels_size) {
|
46
|
-
VALUE result_array;
|
47
|
-
unsigned long int i;
|
48
|
-
result_array = rb_ary_new2(pixels_size);
|
49
|
-
for (i=0; i<pixels_size; i++) {
|
50
|
-
rb_ary_store(result_array, i, UINT2NUM(pixels[i]));
|
51
|
-
};
|
52
|
-
return result_array;
|
53
|
-
}
|
54
|
-
|
55
|
-
PIXEL* get_c_array(VALUE self) {
|
56
|
-
unsigned long int w,h,i;
|
57
|
-
PIXEL* ary;
|
58
|
-
VALUE pixels;
|
59
|
-
|
60
|
-
pixels = rb_funcall(self, rb_intern("pixels"), 0);
|
61
|
-
w = NUM2UINT(rb_funcall(self, rb_intern("width"), 0));
|
62
|
-
h = NUM2UINT(rb_funcall(self, rb_intern("height"), 0));
|
63
|
-
ary = (PIXEL*)malloc( w*h*sizeof(PIXEL));
|
64
|
-
|
65
|
-
for(i=0; i<w*h; i++) {
|
66
|
-
ary[i] = NUM2UINT(rb_ary_entry(pixels, i));
|
67
|
-
}
|
68
|
-
|
69
|
-
return ary;
|
70
|
-
}
|
71
|
-
|
72
|
-
PIXEL raw_interpolate_cubic(double t, PIXEL p0, PIXEL p1, PIXEL p2, PIXEL p3) {
|
73
|
-
BYTE new_r, new_g, new_b, new_a;
|
74
|
-
|
75
|
-
new_r = interpolate_char(t, R_BYTE(p0), R_BYTE(p1), R_BYTE(p2), R_BYTE(p3));
|
76
|
-
new_g = interpolate_char(t, G_BYTE(p0), G_BYTE(p1), G_BYTE(p2), G_BYTE(p3));
|
77
|
-
new_b = interpolate_char(t, B_BYTE(p0), B_BYTE(p1), B_BYTE(p2), B_BYTE(p3));
|
78
|
-
new_a = interpolate_char(t, A_BYTE(p0), A_BYTE(p1), A_BYTE(p2), A_BYTE(p3));
|
79
|
-
|
80
|
-
return BUILD_PIXEL(new_r, new_g, new_b, new_a);
|
81
|
-
}
|
82
|
-
|
83
|
-
BYTE interpolate_char(double t, BYTE c0, BYTE c1, BYTE c2, BYTE c3) {
|
84
|
-
double a, b, c, d, res;
|
85
|
-
a = - 0.5 * c0 + 1.5 * c1 - 1.5 * c2 + 0.5 * c3;
|
86
|
-
b = c0 - 2.5 * c1 + 2 * c2 - 0.5 * c3;
|
87
|
-
c = 0.5 * c2 - 0.5 * c0;
|
88
|
-
d = c1;
|
89
|
-
res = a * t * t * t + b * t * t + c * t + d + 0.5;
|
90
|
-
if(res < 0) {
|
91
|
-
res = 0;
|
92
|
-
} else if(res > 255) {
|
93
|
-
res = 255;
|
94
|
-
};
|
95
|
-
return (BYTE)(res);
|
96
|
-
};
|
97
|
-
|
98
|
-
PIXEL raw_merge_pixels(PIXEL* merge_pixels, unsigned long int size) {
|
99
|
-
unsigned long int i, real_colors, acum_r, acum_g, acum_b, acum_a;
|
100
|
-
BYTE new_r, new_g, new_b, new_a;
|
101
|
-
PIXEL pix;
|
102
|
-
|
103
|
-
acum_r = 0;
|
104
|
-
acum_g = 0;
|
105
|
-
acum_b = 0;
|
106
|
-
acum_a = 0;
|
107
|
-
|
108
|
-
new_r = 0;
|
109
|
-
new_g = 0;
|
110
|
-
new_b = 0;
|
111
|
-
new_a = 0;
|
112
|
-
|
113
|
-
real_colors = 0;
|
114
|
-
|
115
|
-
for(i=0; i < size; i++) {
|
116
|
-
pix = merge_pixels[i];
|
117
|
-
if(A_BYTE(pix) != 0) {
|
118
|
-
acum_r += R_BYTE(pix);
|
119
|
-
acum_g += G_BYTE(pix);
|
120
|
-
acum_b += B_BYTE(pix);
|
121
|
-
acum_a += A_BYTE(pix);
|
122
|
-
real_colors += 1;
|
123
|
-
};
|
124
|
-
};
|
125
|
-
|
126
|
-
if(real_colors > 0) {
|
127
|
-
new_r = (BYTE)(acum_r/real_colors);
|
128
|
-
new_g = (BYTE)(acum_g/real_colors);
|
129
|
-
new_b = (BYTE)(acum_b/real_colors);
|
130
|
-
};
|
131
|
-
new_a = (BYTE)(acum_a/size);
|
132
|
-
return BUILD_PIXEL(new_r, new_g, new_b, new_a);
|
133
|
-
};
|
134
|
-
|
135
|
-
void setup_steps_residues(unsigned long int *steps, double *residues,
|
136
|
-
unsigned long int src_dimension, unsigned long int dst_dimension) {
|
137
|
-
unsigned long int i;
|
138
|
-
double step = (double) (src_dimension - 1) / (dst_dimension - 1);
|
139
|
-
for(i = 0; i < dst_dimension - 1; i++) {
|
140
|
-
steps[i] = (unsigned long int) i*step;
|
141
|
-
residues[i] = i*step - steps[i];
|
142
|
-
};
|
143
|
-
|
144
|
-
steps[dst_dimension - 1] = src_dimension - 2;
|
145
|
-
residues[dst_dimension - 1] = 1;
|
146
|
-
};
|
147
|
-
|
148
|
-
PIXEL get_line_pixel(PIXEL* source, unsigned long int line, long int pixel,
|
149
|
-
unsigned long int src_dimension_x) {
|
150
|
-
if(pixel >= 0 && pixel < (long int)src_dimension_x) {
|
151
|
-
return source[line * src_dimension_x + pixel];
|
152
|
-
} else {
|
153
|
-
return 0;
|
154
|
-
};
|
155
|
-
};
|
156
|
-
|
157
|
-
PIXEL get_column_pixel(PIXEL* source,
|
158
|
-
unsigned long int column, long int pixel,
|
159
|
-
unsigned long int src_dimension_y, unsigned long int src_dimension_x) {
|
160
|
-
|
161
|
-
if(pixel >=0 && pixel < (long int)src_dimension_y) {
|
162
|
-
return source[src_dimension_x * pixel + column];
|
163
|
-
} else {
|
164
|
-
return 0;
|
165
|
-
};
|
166
|
-
};
|
167
|
-
|
168
|
-
PIXEL* get_bicubic_points(PIXEL* source_array,
|
169
|
-
unsigned long int src_dimension_x, unsigned long int src_dimension_y,
|
170
|
-
unsigned long int dst_dimension_x, unsigned long int dst_dimension_y) {
|
171
|
-
PIXEL* dest, *source;
|
172
|
-
unsigned long int index_y, index, y, x;
|
173
|
-
unsigned long int* steps;
|
174
|
-
double* residues;
|
175
|
-
|
176
|
-
steps = (unsigned long int*) malloc(dst_dimension_x * sizeof(unsigned long int));
|
177
|
-
residues = (double*) malloc(dst_dimension_x * sizeof(double));
|
178
|
-
setup_steps_residues(steps, residues, src_dimension_x, dst_dimension_x);
|
179
|
-
|
180
|
-
source = source_array;
|
181
|
-
dest = (PIXEL*)malloc( src_dimension_y*dst_dimension_x*sizeof(PIXEL) );
|
182
|
-
|
183
|
-
for (y=0; y < src_dimension_y; y++) {
|
184
|
-
index_y = dst_dimension_x * y;
|
185
|
-
for (x=0; x < dst_dimension_x; x++) {
|
186
|
-
index = index_y + x;
|
187
|
-
dest[index] = raw_interpolate_cubic(residues[x],
|
188
|
-
get_line_pixel(source, y, steps[x] - 1, src_dimension_x),
|
189
|
-
get_line_pixel(source, y, steps[x], src_dimension_x),
|
190
|
-
get_line_pixel(source, y, steps[x] + 1, src_dimension_x),
|
191
|
-
get_line_pixel(source, y, steps[x] + 2, src_dimension_x)
|
192
|
-
);
|
193
|
-
};
|
194
|
-
};
|
195
|
-
|
196
|
-
steps = realloc(steps, dst_dimension_y * sizeof(unsigned long int));
|
197
|
-
residues = realloc(residues, dst_dimension_y * sizeof(double));
|
198
|
-
setup_steps_residues(steps, residues, src_dimension_y, dst_dimension_y);
|
199
|
-
|
200
|
-
free(source);
|
201
|
-
source = dest;
|
202
|
-
dest = (PIXEL*)malloc( dst_dimension_x * dst_dimension_y * sizeof(PIXEL));
|
203
|
-
|
204
|
-
for (y=0; y < dst_dimension_x; y++) {
|
205
|
-
for (x=0; x < dst_dimension_y; x++) {
|
206
|
-
index = dst_dimension_x * x + y;
|
207
|
-
dest[index] = raw_interpolate_cubic(residues[x],
|
208
|
-
get_column_pixel(source, y, steps[x] - 1, src_dimension_y, dst_dimension_x),
|
209
|
-
get_column_pixel(source, y, steps[x], src_dimension_y, dst_dimension_x),
|
210
|
-
get_column_pixel(source, y, steps[x] + 1, src_dimension_y, dst_dimension_x),
|
211
|
-
get_column_pixel(source, y, steps[x] + 2, src_dimension_y, dst_dimension_x)
|
212
|
-
);
|
213
|
-
};
|
214
|
-
};
|
215
|
-
|
216
|
-
free(source);
|
217
|
-
free(steps);
|
218
|
-
free(residues);
|
219
|
-
|
220
|
-
return dest;
|
221
|
-
};
|
222
|
-
|
223
|
-
PIXEL* c_scale_points(PIXEL* source, unsigned long int dst_width, unsigned long int dst_height,
|
224
|
-
unsigned long int w_m, unsigned long int h_m) {
|
225
|
-
|
226
|
-
unsigned long int y_pos, x_pos, index, i, j, x, y, buffer_size, buffer_index;
|
227
|
-
PIXEL* pixels_to_merge;
|
228
|
-
PIXEL* result;
|
229
|
-
|
230
|
-
pixels_to_merge = malloc(w_m*h_m*sizeof(PIXEL));
|
231
|
-
result = malloc(dst_width * dst_height * sizeof(PIXEL));
|
232
|
-
|
233
|
-
buffer_size = h_m * w_m;
|
234
|
-
|
235
|
-
for (i = 0; i < dst_height; i++) {
|
236
|
-
for (j = 0; j < dst_width; j++) {
|
237
|
-
buffer_index = 0;
|
238
|
-
for (y = 0; y < h_m; y++) {
|
239
|
-
y_pos = i * h_m + y;
|
240
|
-
for (x = 0; x < w_m; x++) {
|
241
|
-
x_pos = j * w_m + x;
|
242
|
-
pixels_to_merge[buffer_index++] = source[dst_width * w_m * y_pos + x_pos];
|
243
|
-
};
|
244
|
-
};
|
245
|
-
index = i * dst_width + j;
|
246
|
-
result[index] = raw_merge_pixels(pixels_to_merge, buffer_size);
|
247
|
-
|
248
|
-
};
|
249
|
-
};
|
250
|
-
free(source);
|
251
|
-
return result;
|
252
|
-
};
|
data/ext/eyes_core/eyes_core.h
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
#ifndef APPLITOOLS_RESAMPLING_EXT
|
2
|
-
#define APPLITOOLS_RESAMPLING_EXT
|
3
|
-
#include "ruby.h"
|
4
|
-
|
5
|
-
typedef uint32_t PIXEL; // Pixels use 32 bits unsigned integers
|
6
|
-
typedef unsigned char BYTE; // Bytes use 8 bits unsigned integers
|
7
|
-
|
8
|
-
#define R_BYTE(pixel) ((BYTE) (((pixel) & (PIXEL) 0xff000000) >> 24))
|
9
|
-
#define G_BYTE(pixel) ((BYTE) (((pixel) & (PIXEL) 0x00ff0000) >> 16))
|
10
|
-
#define B_BYTE(pixel) ((BYTE) (((pixel) & (PIXEL) 0x0000ff00) >> 8))
|
11
|
-
#define A_BYTE(pixel) ((BYTE) (((pixel) & (PIXEL) 0x000000ff)))
|
12
|
-
|
13
|
-
#define BUILD_PIXEL(r, g, b, a) (((PIXEL) (r) << 24) + ((PIXEL) (g) << 16) + ((PIXEL) (b) << 8) + (PIXEL) (a))
|
14
|
-
#define INT8_MULTIPLY(a, b) (((((a) * (b) + 0x80) >> 8) + ((a) * (b) + 0x80)) >> 8)
|
15
|
-
|
16
|
-
BYTE interpolate_char(double, BYTE, BYTE, BYTE, BYTE);
|
17
|
-
|
18
|
-
PIXEL* get_bicubic_points(PIXEL*, unsigned long int, unsigned long int, unsigned long int, unsigned long int);
|
19
|
-
|
20
|
-
PIXEL* get_c_array(VALUE);
|
21
|
-
VALUE c_resampling_first_step(VALUE, VALUE, VALUE);
|
22
|
-
VALUE get_ruby_array(VALUE, PIXEL*, unsigned long int);
|
23
|
-
PIXEL get_line_pixel(PIXEL*, unsigned long int, long int, unsigned long int);
|
24
|
-
PIXEL get_column_pixel(PIXEL*, unsigned long int, long int, unsigned long int, unsigned long int);
|
25
|
-
PIXEL raw_merge_pixels(PIXEL*, unsigned long int);
|
26
|
-
PIXEL* c_scale_points(PIXEL*, unsigned long int, unsigned long int, unsigned long int, unsigned long int);
|
27
|
-
|
28
|
-
#endif
|
@@ -1,32 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require_relative 'region_provider'
|
4
|
-
module Applitools
|
5
|
-
module Appium
|
6
|
-
class AndroidRegionProvider < ::Applitools::Appium::RegionProvider
|
7
|
-
private
|
8
|
-
|
9
|
-
def convert_element_coordinates
|
10
|
-
Applitools::Region.from_location_size(eye_region.location, eye_region.size)
|
11
|
-
end
|
12
|
-
|
13
|
-
def convert_viewport_rect_coordinates
|
14
|
-
region = viewport_rect
|
15
|
-
|
16
|
-
session_info = Applitools::Appium::Utils.session_capabilities(driver)
|
17
|
-
if session_info['deviceScreenSize']
|
18
|
-
device_height = session_info['deviceScreenSize'].split('x').last.to_i
|
19
|
-
system_bars_height = driver.get_system_bars.map {|_,v| v['height'] }.sum
|
20
|
-
region['height'] = device_height - system_bars_height
|
21
|
-
end
|
22
|
-
|
23
|
-
Applitools::Region.new(
|
24
|
-
region['left'],
|
25
|
-
region['top'],
|
26
|
-
region['width'],
|
27
|
-
region['height']
|
28
|
-
)
|
29
|
-
end
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require_relative './screenshot.rb'
|
2
|
-
module Applitools
|
3
|
-
module Appium
|
4
|
-
class AndroidScreenshot < Applitools::Appium::Screenshot
|
5
|
-
def convert_region_location(region, from, to)
|
6
|
-
# converted_size = region.size.dup.scale_it!(1 / device_pixel_ratio)
|
7
|
-
# converted_location = region.location.dup.offset_negative(Applitools::Location.new(0, status_bar_height)).scale_it!(1 / device_pixel_ratio)
|
8
|
-
# Applitools::Region.from_location_size(converted_location, converted_size)
|
9
|
-
Applitools::Region.from_location_size(
|
10
|
-
convert_location(region.location, nil, nil),
|
11
|
-
region.size
|
12
|
-
).scale_it!(1.to_f / device_pixel_ratio)
|
13
|
-
end
|
14
|
-
|
15
|
-
def convert_location(location, _from, _to)
|
16
|
-
location.offset_negative(Applitools::Location.new(0, status_bar_height))
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
@@ -1,189 +0,0 @@
|
|
1
|
-
# frozen_string_literal: false
|
2
|
-
|
3
|
-
class Applitools::Appium::Eyes < Applitools::Selenium::SeleniumEyes
|
4
|
-
attr_accessor :status_bar_height
|
5
|
-
|
6
|
-
def perform_driver_settings_for_appium_driver
|
7
|
-
self.region_visibility_strategy = Applitools::Selenium::NopRegionVisibilityStrategy.new
|
8
|
-
self.force_driver_resolution_as_viewport_size = true
|
9
|
-
end
|
10
|
-
|
11
|
-
def initialize(*args)
|
12
|
-
super
|
13
|
-
self.dont_get_title = true
|
14
|
-
self.runner = Applitools::ClassicRunner.new unless runner
|
15
|
-
self.base_agent_id = "eyes.appium.ruby/#{Applitools::VERSION}".freeze
|
16
|
-
self.status_bar_height = 0
|
17
|
-
self.utils = Applitools::Appium::Utils
|
18
|
-
end
|
19
|
-
|
20
|
-
private :perform_driver_settings_for_appium_driver
|
21
|
-
|
22
|
-
def check(*args)
|
23
|
-
args.compact!
|
24
|
-
case (first_arg = args.shift)
|
25
|
-
when String
|
26
|
-
name = first_arg
|
27
|
-
target = args.shift
|
28
|
-
when Applitools::Selenium::Target
|
29
|
-
target = first_arg
|
30
|
-
when Hash
|
31
|
-
target = first_arg[:target]
|
32
|
-
name = first_arg[:name] || first_arg[:tag]
|
33
|
-
end
|
34
|
-
|
35
|
-
logger.info "check(#{name}) is called"
|
36
|
-
self.tag_for_debug = name
|
37
|
-
Applitools::ArgumentGuard.one_of? target, 'target', [Applitools::Selenium::Target, Applitools::Appium::Target]
|
38
|
-
|
39
|
-
# target.fully(false) if target.options[:stitch_content].nil?
|
40
|
-
|
41
|
-
return universal_check(name, target)
|
42
|
-
return check_native(name, target) if native_app?
|
43
|
-
super
|
44
|
-
end
|
45
|
-
|
46
|
-
attr_accessor :eyes_element_to_check, :region_provider
|
47
|
-
private :eyes_element_to_check, :eyes_element_to_check=, :region_provider, :region_provider=
|
48
|
-
|
49
|
-
def check_native(name, target)
|
50
|
-
logger.info "check_native(#{name}) is called"
|
51
|
-
update_scaling_params
|
52
|
-
target_to_check = target.finalize
|
53
|
-
match_data = Applitools::MatchWindowData.new(default_match_settings)
|
54
|
-
match_data.tag = name
|
55
|
-
timeout = target_to_check.options[:timeout] || USE_DEFAULT_MATCH_TIMEOUT
|
56
|
-
|
57
|
-
eyes_element = target_to_check.region_to_check.call(driver)
|
58
|
-
self.eyes_element_to_check = eyes_element
|
59
|
-
region_provider = region_provider_class.new(driver, eyes_element)
|
60
|
-
match_data.read_target(target_to_check, driver)
|
61
|
-
|
62
|
-
check_window_base(
|
63
|
-
region_provider, timeout, match_data
|
64
|
-
)
|
65
|
-
end
|
66
|
-
|
67
|
-
def native_app?
|
68
|
-
return true if driver.current_context == 'NATIVE_APP'
|
69
|
-
false
|
70
|
-
end
|
71
|
-
|
72
|
-
def capture_screenshot
|
73
|
-
logger.info 'Getting screenshot (capture_screenshot() has been invoked)'
|
74
|
-
case eyes_element_to_check
|
75
|
-
when Applitools::Region
|
76
|
-
viewport_screenshot
|
77
|
-
when Selenium::WebDriver::Element, Applitools::Selenium::Element
|
78
|
-
element_screenshot
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
def get_app_output_with_screenshot(*args)
|
83
|
-
result = super do |screenshot|
|
84
|
-
if scale_provider
|
85
|
-
scaled_image = scale_provider.scale_image(screenshot.image)
|
86
|
-
self.screenshot = screenshot_class.new(
|
87
|
-
Applitools::Screenshot.from_image(
|
88
|
-
case scaled_image
|
89
|
-
# when ChunkyPNG::Image
|
90
|
-
# scaled_image
|
91
|
-
when Applitools::Screenshot::Datastream
|
92
|
-
scaled_image.image
|
93
|
-
else
|
94
|
-
raise Applitools::EyesError.new('Unknown image format after scale!')
|
95
|
-
end
|
96
|
-
),
|
97
|
-
status_bar_height: self.utils.status_bar_height(driver),
|
98
|
-
device_pixel_ratio: self.utils.device_pixel_ratio(driver)
|
99
|
-
)
|
100
|
-
end
|
101
|
-
end
|
102
|
-
self.screenshot_url = nil
|
103
|
-
result
|
104
|
-
end
|
105
|
-
|
106
|
-
def dom_data
|
107
|
-
{}
|
108
|
-
end
|
109
|
-
|
110
|
-
def check_window(tag = nil, match_timeout = USE_DEFAULT_MATCH_TIMEOUT)
|
111
|
-
target = Applitools::Appium::Target.window.tap do |t|
|
112
|
-
t.timeout(match_timeout)
|
113
|
-
end
|
114
|
-
check(tag, target)
|
115
|
-
end
|
116
|
-
|
117
|
-
def check_region(*args)
|
118
|
-
options = { timeout: USE_DEFAULT_MATCH_TIMEOUT, tag: nil }.merge! Applitools::Utils.extract_options!(args)
|
119
|
-
target = Applitools::Appium::Target.new.region(*args).timeout(options[:match_timeout])
|
120
|
-
check(options[:tag], target)
|
121
|
-
end
|
122
|
-
|
123
|
-
def set_mobile_capabilities(nmg_caps, nml_api_key, eyes_server_url, proxy_settings)
|
124
|
-
new_caps = {}
|
125
|
-
|
126
|
-
if nml_api_key.nil? || nml_api_key.empty?
|
127
|
-
nml_api_key = ENV['APPLITOOLS_API_KEY']
|
128
|
-
if nml_api_key.nil? || nml_api_key.empty?
|
129
|
-
raise Applitools::EyesError.new('No API key was given, or is an empty string.')
|
130
|
-
end
|
131
|
-
end
|
132
|
-
new_caps[:NML_API_KEY] = nml_api_key
|
133
|
-
|
134
|
-
if eyes_server_url.nil? || eyes_server_url.empty?
|
135
|
-
eyes_server_url = ENV['APPLITOOLS_SERVER_URL']
|
136
|
-
end
|
137
|
-
new_caps[:NML_SERVER_URL] = eyes_server_url if eyes_server_url
|
138
|
-
|
139
|
-
if proxy_settings.nil? || proxy_settings.empty?
|
140
|
-
proxy_settings = ENV['APPLITOOLS_HTTP_PROXY']
|
141
|
-
end
|
142
|
-
new_caps[:NML_PROXY_URL] = proxy_settings if proxy_settings
|
143
|
-
|
144
|
-
nmg_caps[:optionalIntentArguments] = "--es APPLITOOLS '" + new_caps.to_json + "'"
|
145
|
-
nmg_caps[:processArguments] = {
|
146
|
-
args: [],
|
147
|
-
env: new_caps.merge(DYLD_INSERT_LIBRARIES: "@executable_path/Frameworks/UFG_lib.xcframework/ios-arm64/UFG_lib.framework/UFG_lib:@executable_path/Frameworks/UFG_lib.xcframework/ios-arm64_x86_64-simulator/UFG_lib.framework/UFG_lib")
|
148
|
-
}
|
149
|
-
end
|
150
|
-
|
151
|
-
alias set_nmg_capabilities set_mobile_capabilities
|
152
|
-
|
153
|
-
def use_system_screenshot(value = true)
|
154
|
-
self.screenshot_mode = !value ? 'applitools-lib' : 'default'
|
155
|
-
self
|
156
|
-
end
|
157
|
-
|
158
|
-
private
|
159
|
-
|
160
|
-
def viewport_screenshot
|
161
|
-
logger.info 'Viewport screenshot requested...'
|
162
|
-
obtain_viewport_screenshot
|
163
|
-
end
|
164
|
-
|
165
|
-
def element_screenshot
|
166
|
-
logger.info 'Element screenshot requested...'
|
167
|
-
obtain_viewport_screenshot
|
168
|
-
end
|
169
|
-
|
170
|
-
def obtain_viewport_screenshot
|
171
|
-
self.screenshot = screenshot_class.new(
|
172
|
-
Applitools::Screenshot.from_datastream(driver.screenshot_as(:png)),
|
173
|
-
status_bar_height: self.utils.status_bar_height(driver),
|
174
|
-
device_pixel_ratio: self.utils.device_pixel_ratio(driver)
|
175
|
-
)
|
176
|
-
end
|
177
|
-
|
178
|
-
def screenshot_class
|
179
|
-
return Applitools::Appium::IosScreenshot if self.utils.ios?(Applitools::Appium::Driver::AppiumLib)
|
180
|
-
return Applitools::Appium::AndroidScreenshot if self.utils.android?(Applitools::Appium::Driver::AppiumLib)
|
181
|
-
raise Applitools::EyesError, 'Unknown device type'
|
182
|
-
end
|
183
|
-
|
184
|
-
def region_provider_class
|
185
|
-
return Applitools::Appium::IosRegionProvider if self.utils.ios?(Applitools::Appium::Driver::AppiumLib)
|
186
|
-
return Applitools::Appium::AndroidRegionProvider if self.utils.android?(Applitools::Appium::Driver::AppiumLib)
|
187
|
-
raise Applitools::EyesError, 'Unknown device type'
|
188
|
-
end
|
189
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
#
|
3
|
-
require_relative 'region_provider'
|
4
|
-
module Applitools
|
5
|
-
module Appium
|
6
|
-
class IosRegionProvider < ::Applitools::Appium::RegionProvider
|
7
|
-
private
|
8
|
-
|
9
|
-
def convert_element_coordinates
|
10
|
-
Applitools::Region.from_location_size(eye_region.location, eye_region.size).
|
11
|
-
scale_it!(scale_factor)
|
12
|
-
end
|
13
|
-
|
14
|
-
def convert_viewport_rect_coordinates
|
15
|
-
region = viewport_rect
|
16
|
-
Applitools::Region.new(
|
17
|
-
region['left'],
|
18
|
-
region['top'],
|
19
|
-
region['width'],
|
20
|
-
region['height']
|
21
|
-
)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
@@ -1,10 +0,0 @@
|
|
1
|
-
require_relative './screenshot.rb'
|
2
|
-
module Applitools
|
3
|
-
module Appium
|
4
|
-
class IosScreenshot < Applitools::Appium::Screenshot
|
5
|
-
def convert_location(location, _from, _to)
|
6
|
-
location.offset_negative(Applitools::Location.new(0, status_bar_height))
|
7
|
-
end
|
8
|
-
end
|
9
|
-
end
|
10
|
-
end
|
@@ -1,51 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Applitools
|
4
|
-
module Appium
|
5
|
-
class RegionProvider
|
6
|
-
attr_accessor :driver, :eye_region, :region_to_check
|
7
|
-
|
8
|
-
def initialize(driver, eye_region)
|
9
|
-
self.driver = driver
|
10
|
-
self.eye_region = eye_region
|
11
|
-
self.region_to_check = Applitools::Region::EMPTY
|
12
|
-
convert_region_coordinates
|
13
|
-
end
|
14
|
-
|
15
|
-
def region
|
16
|
-
region_to_check
|
17
|
-
end
|
18
|
-
|
19
|
-
def coordinate_type
|
20
|
-
nil
|
21
|
-
end
|
22
|
-
|
23
|
-
private
|
24
|
-
|
25
|
-
def viewport_rect
|
26
|
-
Applitools::Appium::Utils.viewport_rect(driver)
|
27
|
-
end
|
28
|
-
|
29
|
-
def convert_region_coordinates
|
30
|
-
self.region_to_check = case eye_region
|
31
|
-
when ::Selenium::WebDriver::Element, Applitools::Selenium::Element
|
32
|
-
convert_element_coordinates
|
33
|
-
else
|
34
|
-
convert_viewport_rect_coordinates
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
def convert_element_coordinates
|
39
|
-
raise Applitools::AbstractMethodCalled.new(:convert_region_coordinates, 'Applitools::Appium::RegionProvider')
|
40
|
-
end
|
41
|
-
|
42
|
-
def convert_viewport_rect_coordinates
|
43
|
-
raise Applitools::AbstractMethodCalled.new(:convert_viewport_rect_coordinates, 'Applitools::Appium::RegionProvider')
|
44
|
-
end
|
45
|
-
|
46
|
-
def scale_factor
|
47
|
-
Applitools::Appium::Utils.device_pixel_ratio(driver)
|
48
|
-
end
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
module Applitools
|
4
|
-
module Appium
|
5
|
-
class Screenshot < Applitools::EyesScreenshot
|
6
|
-
|
7
|
-
attr_reader :status_bar_height, :device_pixel_ratio
|
8
|
-
|
9
|
-
def initialize(*args)
|
10
|
-
options = Applitools::Utils.extract_options!(args)
|
11
|
-
@status_bar_height = options[:status_bar_height] || 0
|
12
|
-
@device_pixel_ratio = options[:device_pixel_ratio] || 1
|
13
|
-
super
|
14
|
-
end
|
15
|
-
|
16
|
-
def sub_screenshot(region, _coordinate_type, _throw_if_clipped = false, _force_nil_if_clipped = false)
|
17
|
-
self.class.new(
|
18
|
-
Applitools::Screenshot.from_image(
|
19
|
-
image.crop(region.x, region.y, region.width, region.height)
|
20
|
-
)
|
21
|
-
)
|
22
|
-
end
|
23
|
-
|
24
|
-
def convert_location(location, _from, _to)
|
25
|
-
raise 'Applitools::Appium::Screenshot is an abstract class.' \
|
26
|
-
' You should implement :convert_location method in a descendant class.'
|
27
|
-
end
|
28
|
-
end
|
29
|
-
end
|
30
|
-
end
|