@applitools/screenshoter 3.2.6 → 3.3.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.
- package/.bongo/dry-run/package-lock.json +53 -10
- package/.bongo/dry-run/package.json +5 -0
- package/.bongo/dry-run.tgz +0 -0
- package/CHANGELOG.md +18 -0
- package/index.js +2 -1
- package/logs/screenshot_2021_12_16_19_06_06_332Z_full_app_failed_1639681566332.png +0 -0
- package/logs/screenshot_2021_12_16_19_15_59_935Z_full_app_failed_1639682159935.png +0 -0
- package/logs/screenshot_2021_12_16_19_33_20_679Z_full_app_failed_1639683200679.png +0 -0
- package/logs/screenshot_2021_12_16_19_37_22_120Z_ios_viewport_failed.png +0 -0
- package/logs/screenshot_2021_12_16_19_38_09_461Z_ios_full_page_failed.png +0 -0
- package/logs/screenshot_2021_12_16_19_59_45_182Z_ios_viewport_failed.png +0 -0
- package/package.json +11 -7
- package/src/find-image-pattern.js +10 -38
- package/src/image.js +107 -64
- package/src/take-screenshot.js +136 -160
- package/src/take-simple-screenshot.js +25 -0
- package/src/take-stitched-screenshot.js +34 -40
- package/src/take-viewport-screenshot.js +179 -16
- package/test/e2e/android.spec.js +77 -13
- package/test/e2e/external.spec.js +155 -0
- package/test/e2e/ios.spec.js +64 -11
- package/test/e2e/web-ios.spec.js +19 -6
- package/test/e2e/web.spec.js +33 -21
- package/test/fixtures/android/app-fully-non-scrollable.png +0 -0
- package/test/fixtures/android/app-fully-recycler.png +0 -0
- package/test/fixtures/android/app-fully-scroll-statusbar.png +0 -0
- package/test/fixtures/android/app-fully-scroll.png +0 -0
- package/test/fixtures/android/app-statusbar.png +0 -0
- package/test/fixtures/android/region.png +0 -0
- package/test/fixtures/android/x-app-fully-collapsing.png +0 -0
- package/test/fixtures/android/x-app-fully-recycler.png +0 -0
- package/test/fixtures/android/x-element-fully.png +0 -0
- package/test/fixtures/external/agl.png +0 -0
- package/test/fixtures/image/{house.combined-higher-wider.png → house.framed-higher-wider.png} +0 -0
- package/test/fixtures/image/{house.combined-higher.png → house.framed-higher.png} +0 -0
- package/test/fixtures/image/house.framed-shorter-thinner.png +0 -0
- package/test/fixtures/image/{house.combined-wider.png → house.framed-wider.png} +0 -0
- package/test/fixtures/ios/app-fully-collapsing.png +0 -0
- package/test/fixtures/ios/app-fully-collection.png +0 -0
- package/test/fixtures/ios/app-fully-overlapped-statusbar.png +0 -0
- package/test/fixtures/ios/app-fully-overlapped.png +0 -0
- package/test/fixtures/ios/app-fully-scroll-statusbar.png +0 -0
- package/test/fixtures/ios/app-fully-scroll.png +0 -0
- package/test/fixtures/ios/app-fully-superview.png +0 -0
- package/test/fixtures/ios/app-fully-table.png +0 -0
- package/test/fixtures/ios/app-statusbar.png +0 -0
- package/test/fixtures/ios/app.png +0 -0
- package/test/fixtures/ios/element-fully.png +0 -0
- package/test/fixtures/ios/element.png +0 -0
- package/test/fixtures/ios/region.png +0 -0
- package/test/fixtures/pattern/iPad_5th_landscape.png +0 -0
- package/test/fixtures/pattern/iPad_5th_portrait.png +0 -0
- package/test/fixtures/pattern/iPad_9th_landscape.png +0 -0
- package/test/fixtures/pattern/iPad_9th_portrait.png +0 -0
- package/test/fixtures/pattern/iPhone_11_landscape.png +0 -0
- package/test/fixtures/pattern/iPhone_11_portrait.png +0 -0
- package/test/fixtures/pattern/iPhone_13_landscape.png +0 -0
- package/test/fixtures/pattern/iPhone_13_portrait.png +0 -0
- package/test/fixtures/pattern/iPhone_SE_landscape.png +0 -0
- package/test/fixtures/pattern/iPhone_SE_portrait.png +0 -0
- package/test/fixtures/pattern/iPhone_XS_portrait_noviewport.png +0 -0
- package/test/fixtures/web/frame-fully.png +0 -0
- package/test/fixtures/web/frame.png +0 -0
- package/test/fixtures/web/inner-element-fully.png +0 -0
- package/test/fixtures/web/inner-element.png +0 -0
- package/test/fixtures/web/inner-region-fully.png +0 -0
- package/test/fixtures/web/inner-region.png +0 -0
- package/test/fixtures/web/page-fully.png +0 -0
- package/test/fixtures/web/page.png +0 -0
- package/test/fixtures/web/region-fully.png +0 -0
- package/test/fixtures/web/region.png +0 -0
- package/test/fixtures/web-ios/page-fully.png +0 -0
- package/test/fixtures/web-ios/page.png +0 -0
- package/test/it/find-pattern.spec.js +16 -11
- package/test/it/image.spec.js +42 -15
- package/logs/screenshot_2021_10_11_13_22_59_543Z_viewport_failed_1633958579543.png +0 -0
- package/logs/screenshot_2021_10_11_13_28_41_375Z_viewport_failed_1633958921375.png +0 -0
- package/logs/screenshot_2021_10_11_13_36_46_414Z_viewport_failed_1633959406414.png +0 -0
- package/logs/screenshot_2021_10_11_13_54_21_340Z_viewport_failed_1633960461340.png +0 -0
- package/logs/screenshot_2021_10_11_14_32_39_581Z_full_app_failed_1633962759581.png +0 -0
- package/src/calculate-screenshot-regions.js +0 -31
- package/src/screenshoter.js +0 -158
- package/test/fixtures/pattern/iPad_Air_portrait.png +0 -0
- package/test/fixtures/pattern/iPhone_5S_landscape.png +0 -0
- package/test/fixtures/pattern/iPhone_XR_perfecto_landscape.png +0 -0
- package/test/fixtures/pattern/iPhone_XS_Max_perfecto_landscape.png +0 -0
- package/test/fixtures/pattern/iPhone_XS_landscape.png +0 -0
- package/test/fixtures/pattern/iPhone_XS_portrait.png +0 -0
- package/test/fixtures/pattern/iPhone_X_perfecto_portrait.png +0 -0
- package/test/util/spec-driver.js +0 -288
package/test/e2e/web-ios.spec.js
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
1
|
const assert = require('assert')
|
|
2
2
|
const pixelmatch = require('pixelmatch')
|
|
3
3
|
const {Driver} = require('@applitools/driver')
|
|
4
|
-
const spec = require('
|
|
5
|
-
const
|
|
4
|
+
const spec = require('@applitools/spec-driver-webdriverio')
|
|
5
|
+
const takeScreenshot = require('../../index')
|
|
6
6
|
const makeImage = require('../../src/image')
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const env = {
|
|
9
|
+
url: 'https://ondemand.saucelabs.com/wd/hub',
|
|
10
|
+
capabilities: {
|
|
11
|
+
name: 'iOS Web Screenshoter Test',
|
|
12
|
+
deviceName: 'iPhone 11 Pro Simulator',
|
|
13
|
+
browserName: 'safari',
|
|
14
|
+
platformName: 'iOS',
|
|
15
|
+
platformVersion: '14.5',
|
|
16
|
+
appiumVersion: '1.20.1',
|
|
17
|
+
automationName: 'XCUITest',
|
|
18
|
+
username: process.env.SAUCE_USERNAME,
|
|
19
|
+
accessKey: process.env.SAUCE_ACCESS_KEY,
|
|
20
|
+
},
|
|
21
|
+
}
|
|
9
22
|
|
|
10
23
|
describe('screenshoter web ios', () => {
|
|
11
24
|
const logger = {log: () => {}, warn: () => {}, error: () => {}, verbose: () => {}}
|
|
12
25
|
let driver, browser, destroyBrowser
|
|
13
26
|
|
|
14
27
|
before(async () => {
|
|
15
|
-
;[browser, destroyBrowser] = await spec.build(
|
|
28
|
+
;[browser, destroyBrowser] = await spec.build(env)
|
|
16
29
|
})
|
|
17
30
|
|
|
18
31
|
after(async () => {
|
|
@@ -34,7 +47,7 @@ describe('screenshoter web ios', () => {
|
|
|
34
47
|
})
|
|
35
48
|
|
|
36
49
|
async function viewport(options) {
|
|
37
|
-
const screenshot = await
|
|
50
|
+
const screenshot = await takeScreenshot({logger, driver, ...options})
|
|
38
51
|
try {
|
|
39
52
|
const actual = await screenshot.image.toObject()
|
|
40
53
|
const expected = await makeImage('./test/fixtures/web-ios/page.png').toObject()
|
|
@@ -46,7 +59,7 @@ describe('screenshoter web ios', () => {
|
|
|
46
59
|
}
|
|
47
60
|
|
|
48
61
|
async function fullPage(options) {
|
|
49
|
-
const screenshot = await
|
|
62
|
+
const screenshot = await takeScreenshot({logger, driver, fully: true, ...options})
|
|
50
63
|
try {
|
|
51
64
|
const actual = await screenshot.image.toObject()
|
|
52
65
|
const expected = await makeImage('./test/fixtures/web-ios/page-fully.png').toObject()
|
package/test/e2e/web.spec.js
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
const assert = require('assert')
|
|
2
2
|
const pixelmatch = require('pixelmatch')
|
|
3
3
|
const {Driver} = require('@applitools/driver')
|
|
4
|
-
const spec = require('
|
|
5
|
-
const
|
|
4
|
+
const spec = require('@applitools/spec-driver-webdriverio')
|
|
5
|
+
const takeScreenshot = require('../../index')
|
|
6
6
|
const makeImage = require('../../src/image')
|
|
7
7
|
|
|
8
|
+
const env = {
|
|
9
|
+
url: 'http://localhost:4444/wd/hub',
|
|
10
|
+
capabilities: {
|
|
11
|
+
browserName: 'chrome',
|
|
12
|
+
},
|
|
13
|
+
}
|
|
14
|
+
|
|
8
15
|
// TODO add overflowed regions tests
|
|
9
16
|
|
|
10
17
|
describe('screenshoter web', () => {
|
|
@@ -12,7 +19,7 @@ describe('screenshoter web', () => {
|
|
|
12
19
|
let driver, browser, destroyBrowser
|
|
13
20
|
|
|
14
21
|
before(async () => {
|
|
15
|
-
;[browser, destroyBrowser] = await spec.build(
|
|
22
|
+
;[browser, destroyBrowser] = await spec.build(env)
|
|
16
23
|
})
|
|
17
24
|
|
|
18
25
|
after(async () => {
|
|
@@ -37,10 +44,10 @@ describe('screenshoter web', () => {
|
|
|
37
44
|
})
|
|
38
45
|
|
|
39
46
|
it('take frame screenshot with "scroll" scrolling', () => {
|
|
40
|
-
frame({scrollingMode: 'scroll'})
|
|
47
|
+
return frame({scrollingMode: 'scroll'})
|
|
41
48
|
})
|
|
42
49
|
it('take frame screenshot with "css" scrolling', () => {
|
|
43
|
-
frame({scrollingMode: 'css'})
|
|
50
|
+
return frame({scrollingMode: 'css'})
|
|
44
51
|
})
|
|
45
52
|
|
|
46
53
|
it('take full frame screenshot with "scroll" scrolling', () => {
|
|
@@ -51,10 +58,10 @@ describe('screenshoter web', () => {
|
|
|
51
58
|
})
|
|
52
59
|
|
|
53
60
|
it('take region screenshot with "scroll" scrolling', () => {
|
|
54
|
-
region({scrollingMode: 'scroll'})
|
|
61
|
+
return region({scrollingMode: 'scroll'})
|
|
55
62
|
})
|
|
56
63
|
it('take region screenshot with "css" scrolling', () => {
|
|
57
|
-
region({scrollingMode: 'css'})
|
|
64
|
+
return region({scrollingMode: 'css'})
|
|
58
65
|
})
|
|
59
66
|
|
|
60
67
|
it('take full region screenshot with "scroll" scrolling', () => {
|
|
@@ -121,7 +128,7 @@ describe('screenshoter web', () => {
|
|
|
121
128
|
})
|
|
122
129
|
|
|
123
130
|
async function viewport(options) {
|
|
124
|
-
const screenshot = await
|
|
131
|
+
const screenshot = await takeScreenshot({logger, driver, ...options})
|
|
125
132
|
try {
|
|
126
133
|
const actual = await screenshot.image.toObject()
|
|
127
134
|
const expected = await makeImage('./test/fixtures/web/page.png').toObject()
|
|
@@ -132,7 +139,7 @@ describe('screenshoter web', () => {
|
|
|
132
139
|
}
|
|
133
140
|
}
|
|
134
141
|
async function fullPage(options) {
|
|
135
|
-
const screenshot = await
|
|
142
|
+
const screenshot = await takeScreenshot({logger, driver, fully: true, ...options})
|
|
136
143
|
try {
|
|
137
144
|
const actual = await screenshot.image.toObject()
|
|
138
145
|
const expected = await makeImage('./test/fixtures/web/page-fully.png').toObject()
|
|
@@ -143,7 +150,12 @@ describe('screenshoter web', () => {
|
|
|
143
150
|
}
|
|
144
151
|
}
|
|
145
152
|
async function frame(options) {
|
|
146
|
-
const screenshot = await
|
|
153
|
+
const screenshot = await takeScreenshot({
|
|
154
|
+
logger,
|
|
155
|
+
driver,
|
|
156
|
+
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
157
|
+
...options,
|
|
158
|
+
})
|
|
147
159
|
try {
|
|
148
160
|
const actual = await screenshot.image.toObject()
|
|
149
161
|
const expected = await makeImage('./test/fixtures/web/frame.png').toObject()
|
|
@@ -154,7 +166,7 @@ describe('screenshoter web', () => {
|
|
|
154
166
|
}
|
|
155
167
|
}
|
|
156
168
|
async function fullFrame(options) {
|
|
157
|
-
const screenshot = await
|
|
169
|
+
const screenshot = await takeScreenshot({
|
|
158
170
|
logger,
|
|
159
171
|
driver,
|
|
160
172
|
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
@@ -172,7 +184,7 @@ describe('screenshoter web', () => {
|
|
|
172
184
|
}
|
|
173
185
|
async function region(options) {
|
|
174
186
|
const region = {x: 30, y: 500, height: 100, width: 200}
|
|
175
|
-
const screenshot = await
|
|
187
|
+
const screenshot = await takeScreenshot({logger, driver, region, ...options})
|
|
176
188
|
try {
|
|
177
189
|
const actual = await screenshot.image.toObject()
|
|
178
190
|
const expected = await makeImage('./test/fixtures/web/region.png').toObject()
|
|
@@ -184,7 +196,7 @@ describe('screenshoter web', () => {
|
|
|
184
196
|
}
|
|
185
197
|
async function fullRegion(options) {
|
|
186
198
|
const region = {x: 30, y: 500, height: 700, width: 200}
|
|
187
|
-
const screenshot = await
|
|
199
|
+
const screenshot = await takeScreenshot({logger, driver, region, fully: true, ...options})
|
|
188
200
|
try {
|
|
189
201
|
const actual = await screenshot.image.toObject()
|
|
190
202
|
const expected = await makeImage('./test/fixtures/web/region-fully.png').toObject()
|
|
@@ -195,7 +207,7 @@ describe('screenshoter web', () => {
|
|
|
195
207
|
}
|
|
196
208
|
}
|
|
197
209
|
async function element(options) {
|
|
198
|
-
const screenshot = await
|
|
210
|
+
const screenshot = await takeScreenshot({logger, driver, region: '#overflowing-div-image', ...options})
|
|
199
211
|
try {
|
|
200
212
|
const actual = await screenshot.image.toObject()
|
|
201
213
|
const expected = await makeImage('./test/fixtures/web/element.png').toObject()
|
|
@@ -206,7 +218,7 @@ describe('screenshoter web', () => {
|
|
|
206
218
|
}
|
|
207
219
|
}
|
|
208
220
|
async function fullElement(options) {
|
|
209
|
-
const screenshot = await
|
|
221
|
+
const screenshot = await takeScreenshot({logger, driver, region: '#overflowing-div-image', fully: true, ...options})
|
|
210
222
|
try {
|
|
211
223
|
const actual = await screenshot.image.toObject()
|
|
212
224
|
const expected = await makeImage('./test/fixtures/web/element-fully.png').toObject()
|
|
@@ -217,7 +229,7 @@ describe('screenshoter web', () => {
|
|
|
217
229
|
}
|
|
218
230
|
}
|
|
219
231
|
async function regionInFrame(options) {
|
|
220
|
-
const screenshot = await
|
|
232
|
+
const screenshot = await takeScreenshot({
|
|
221
233
|
logger,
|
|
222
234
|
driver,
|
|
223
235
|
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
@@ -234,7 +246,7 @@ describe('screenshoter web', () => {
|
|
|
234
246
|
}
|
|
235
247
|
}
|
|
236
248
|
async function fullRegionInFrame(options) {
|
|
237
|
-
const screenshot = await
|
|
249
|
+
const screenshot = await takeScreenshot({
|
|
238
250
|
logger,
|
|
239
251
|
driver,
|
|
240
252
|
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
@@ -252,7 +264,7 @@ describe('screenshoter web', () => {
|
|
|
252
264
|
}
|
|
253
265
|
}
|
|
254
266
|
async function elementInFrame(options) {
|
|
255
|
-
const screenshot = await
|
|
267
|
+
const screenshot = await takeScreenshot({
|
|
256
268
|
logger,
|
|
257
269
|
driver,
|
|
258
270
|
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
@@ -269,7 +281,7 @@ describe('screenshoter web', () => {
|
|
|
269
281
|
}
|
|
270
282
|
}
|
|
271
283
|
async function fullElementInFrame(options) {
|
|
272
|
-
const screenshot = await
|
|
284
|
+
const screenshot = await takeScreenshot({
|
|
273
285
|
logger,
|
|
274
286
|
driver,
|
|
275
287
|
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
@@ -287,7 +299,7 @@ describe('screenshoter web', () => {
|
|
|
287
299
|
}
|
|
288
300
|
}
|
|
289
301
|
async function frameInFrame(options) {
|
|
290
|
-
const screenshot = await
|
|
302
|
+
const screenshot = await takeScreenshot({
|
|
291
303
|
logger,
|
|
292
304
|
driver,
|
|
293
305
|
frames: [{reference: 'iframe[name="frame1"]'}, {reference: 'iframe[name="frame1-1"]'}],
|
|
@@ -303,7 +315,7 @@ describe('screenshoter web', () => {
|
|
|
303
315
|
}
|
|
304
316
|
}
|
|
305
317
|
async function fullFrameInFrame(options) {
|
|
306
|
-
const screenshot = await
|
|
318
|
+
const screenshot = await takeScreenshot({
|
|
307
319
|
logger,
|
|
308
320
|
driver,
|
|
309
321
|
frames: [{reference: 'iframe[name="frame1"]'}, {reference: 'iframe[name="frame1-1"]'}],
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/test/fixtures/image/{house.combined-higher-wider.png → house.framed-higher-wider.png}
RENAMED
|
File without changes
|
|
File without changes
|
|
Binary file
|
|
File without changes
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -4,23 +4,28 @@ const findPattern = require('../../src/find-image-pattern')
|
|
|
4
4
|
|
|
5
5
|
describe('pattern', () => {
|
|
6
6
|
const fixtures = [
|
|
7
|
-
{name: '
|
|
8
|
-
{name: '
|
|
9
|
-
{name: '
|
|
10
|
-
{name: '
|
|
11
|
-
{name: '
|
|
12
|
-
{name: '
|
|
13
|
-
{name: '
|
|
7
|
+
{name: 'iPhone_SE_portrait', position: {x: 0, y: 140}, offset: 0, pixelRatio: 2},
|
|
8
|
+
{name: 'iPhone_SE_landscape', position: {x: 0, y: 100}, offset: 0, pixelRatio: 2},
|
|
9
|
+
{name: 'iPhone_11_portrait', position: {x: 0, y: 282}, offset: 0, pixelRatio: 3},
|
|
10
|
+
{name: 'iPhone_11_landscape', position: {x: 132, y: 150}, offset: 0, pixelRatio: 3},
|
|
11
|
+
{name: 'iPhone_13_portrait', position: {x: 0, y: 141}, offset: 0, pixelRatio: 3},
|
|
12
|
+
{name: 'iPhone_13_landscape', position: {x: 141, y: 144}, offset: 0, pixelRatio: 3},
|
|
13
|
+
{name: 'iPad_5th_portrait', position: {x: 0, y: 140}, offset: 0, pixelRatio: 2},
|
|
14
|
+
{name: 'iPad_5th_landscape', position: {x: 0, y: 140}, offset: 0, pixelRatio: 2},
|
|
15
|
+
{name: 'iPad_9th_portrait', position: {x: 0, y: 136}, offset: 0, pixelRatio: 2},
|
|
16
|
+
{name: 'iPad_9th_landscape', position: {x: 641, y: 137}, offset: 1, pixelRatio: 2},
|
|
17
|
+
{name: 'iPhone_XS_portrait_noviewport', position: {x: 0, y: 282}, offset: 0, pixelRatio: 3},
|
|
14
18
|
{name: 'iPhone_XS_portrait_nomarker', position: null, pixelRatio: 3},
|
|
15
19
|
]
|
|
16
20
|
|
|
17
|
-
fixtures.forEach(({name, position, pixelRatio}) => {
|
|
21
|
+
fixtures.forEach(({name, position, offset, pixelRatio}) => {
|
|
18
22
|
it(name, async () => {
|
|
19
23
|
const image = await makeImage(`./test/fixtures/pattern/${name}.png`)
|
|
20
24
|
const result = findPattern(await image.toObject(), {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
25
|
+
pixelRatio,
|
|
26
|
+
mask: [1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 1, 0, 1, 0, 0, 1, 1, 1],
|
|
27
|
+
offset,
|
|
28
|
+
size: 1,
|
|
24
29
|
})
|
|
25
30
|
assert.deepStrictEqual(result, position)
|
|
26
31
|
})
|
package/test/it/image.spec.js
CHANGED
|
@@ -78,42 +78,69 @@ describe('image', () => {
|
|
|
78
78
|
assert.strictEqual(actual.height, 50000)
|
|
79
79
|
})
|
|
80
80
|
|
|
81
|
-
it('should
|
|
81
|
+
it('should frame image in a higher and wider region', async () => {
|
|
82
82
|
const image = makeImage('./test/fixtures/image/house.png')
|
|
83
83
|
const srcImage = makeImage({
|
|
84
84
|
width: 200,
|
|
85
85
|
height: 200,
|
|
86
86
|
data: Buffer.alloc(200 * 200 * 4, Buffer.from([0xff, 0, 0, 0xff])),
|
|
87
87
|
})
|
|
88
|
-
const combinedImage = await srcImage.
|
|
88
|
+
const combinedImage = await srcImage.frame(image, image, {x: 200, y: 200, width: 100, height: 100})
|
|
89
89
|
const actual = await combinedImage.toObject()
|
|
90
|
-
const expected = await makeImage('./test/fixtures/image/house.
|
|
90
|
+
const expected = await makeImage('./test/fixtures/image/house.framed-higher-wider.png').toObject()
|
|
91
91
|
assert.ok(pixelmatch(actual.data, expected.data, null, expected.width, expected.height) === 0)
|
|
92
92
|
})
|
|
93
93
|
|
|
94
|
-
it('should
|
|
94
|
+
it('should frame image in a higher region', async () => {
|
|
95
95
|
const image = await makeImage('./test/fixtures/image/house.png')
|
|
96
96
|
const srcImage = makeImage({
|
|
97
97
|
width: 200,
|
|
98
98
|
height: 200,
|
|
99
99
|
data: Buffer.alloc(200 * 200 * 4, Buffer.from([0, 0xff, 0, 0xff])),
|
|
100
100
|
})
|
|
101
|
-
const combinedImage = await srcImage.
|
|
101
|
+
const combinedImage = await srcImage.frame(image, image, {x: 200, y: 200, width: 200, height: 100})
|
|
102
102
|
const actual = await combinedImage.toObject()
|
|
103
|
-
const expected = await makeImage('./test/fixtures/image/house.
|
|
103
|
+
const expected = await makeImage('./test/fixtures/image/house.framed-higher.png').toObject()
|
|
104
104
|
assert.ok(pixelmatch(actual.data, expected.data, null, expected.width, expected.height) === 0)
|
|
105
105
|
})
|
|
106
106
|
|
|
107
|
-
it('should
|
|
107
|
+
it('should frame image in a wider region', async () => {
|
|
108
108
|
const image = await makeImage('./test/fixtures/image/house.png')
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
height: 200
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
109
|
+
const data = Buffer.alloc(200 * 200 * 4, Buffer.from([0, 0, 0xff, 0xff]))
|
|
110
|
+
const actual = await makeImage({width: 200, height: 200, data})
|
|
111
|
+
.frame(image, image, {x: 200, y: 200, width: 100, height: 200})
|
|
112
|
+
.toObject()
|
|
113
|
+
const expected = await makeImage('./test/fixtures/image/house.framed-wider.png').toObject()
|
|
114
|
+
assert.ok(pixelmatch(actual.data, expected.data, null, expected.width, expected.height) === 0)
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
it('should frame image in a shorter and thinner region', async () => {
|
|
118
|
+
const image = await makeImage('./test/fixtures/image/house.png')
|
|
119
|
+
const data = Buffer.alloc(200 * 200 * 4, Buffer.from([0xff, 0, 0xff, 0xff]))
|
|
120
|
+
const actual = await makeImage({width: 200, height: 200, data})
|
|
121
|
+
.frame(image, image, {x: 100, y: 100, width: 250, height: 250})
|
|
122
|
+
.toObject()
|
|
123
|
+
const expected = await makeImage('./test/fixtures/image/house.framed-shorter-thinner.png').toObject()
|
|
124
|
+
assert.ok(pixelmatch(actual.data, expected.data, null, expected.width, expected.height) === 0)
|
|
125
|
+
})
|
|
126
|
+
|
|
127
|
+
it('should frame image in a shorter region', async () => {
|
|
128
|
+
const image = await makeImage('./test/fixtures/image/house.png')
|
|
129
|
+
const data = Buffer.alloc(200 * 200 * 4, Buffer.from([0xff, 0, 0xff, 0xff]))
|
|
130
|
+
const actual = await makeImage({width: 200, height: 200, data})
|
|
131
|
+
.frame(image, image, {x: 100, y: 100, width: 200, height: 250})
|
|
132
|
+
.toObject()
|
|
133
|
+
const expected = await makeImage('./test/fixtures/image/house.framed-shorter-thinner.png').toObject()
|
|
134
|
+
assert.ok(pixelmatch(actual.data, expected.data, null, expected.width, expected.height) === 0)
|
|
135
|
+
})
|
|
136
|
+
|
|
137
|
+
it('should frame image in a thinner region', async () => {
|
|
138
|
+
const image = await makeImage('./test/fixtures/image/house.png')
|
|
139
|
+
const data = Buffer.alloc(200 * 200 * 4, Buffer.from([0xff, 0, 0xff, 0xff]))
|
|
140
|
+
const actual = await makeImage({width: 200, height: 200, data})
|
|
141
|
+
.frame(image, image, {x: 100, y: 100, width: 250, height: 200})
|
|
142
|
+
.toObject()
|
|
143
|
+
const expected = await makeImage('./test/fixtures/image/house.framed-shorter-thinner.png').toObject()
|
|
117
144
|
assert.ok(pixelmatch(actual.data, expected.data, null, expected.width, expected.height) === 0)
|
|
118
145
|
})
|
|
119
146
|
})
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
const utils = require('@applitools/utils')
|
|
2
|
-
|
|
3
|
-
async function calculateScreenshotRegions({context, screenshotRegion, regions}) {
|
|
4
|
-
const screenshotRegions = []
|
|
5
|
-
for (const region of regions) {
|
|
6
|
-
screenshotRegions.push(await transformRegion(region))
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
return screenshotRegions
|
|
10
|
-
|
|
11
|
-
async function transformRegion(region) {
|
|
12
|
-
if (utils.types.has(region, ['x', 'y', 'width', 'height'])) {
|
|
13
|
-
// if someday different coordinate systems will be supported (context or app based), the conversion will happen here
|
|
14
|
-
return [regions]
|
|
15
|
-
}
|
|
16
|
-
const elements = await context.elements(region)
|
|
17
|
-
return elements.reduce(async (regions, element) => {
|
|
18
|
-
regions = await regions
|
|
19
|
-
const region = await element.getRegion()
|
|
20
|
-
regions.push({
|
|
21
|
-
x: Math.max(0, region.x - screenshotRegion.x),
|
|
22
|
-
y: Math.max(0, region.y - screenshotRegion.y),
|
|
23
|
-
width: region.width,
|
|
24
|
-
height: region.height,
|
|
25
|
-
})
|
|
26
|
-
return regions
|
|
27
|
-
}, [])
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
module.exports = calculateScreenshotRegions
|