@applitools/screenshoter 3.3.2 → 3.3.6
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/CHANGELOG.md +22 -0
- package/package.json +26 -15
- package/src/image.js +15 -12
- package/src/scroll-into-viewport.js +16 -7
- package/src/take-viewport-screenshot.js +8 -30
- package/.bongo/dry-run/package-lock.json +0 -73
- package/.bongo/dry-run/package.json +0 -5
- package/.bongo/dry-run.tgz +0 -0
- package/.eslintrc +0 -39
- package/test/e2e/android.spec.js +0 -335
- package/test/e2e/external.spec.js +0 -155
- package/test/e2e/ios.spec.js +0 -338
- package/test/e2e/web-ios.spec.js +0 -72
- package/test/e2e/web.spec.js +0 -334
- 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/app.png +0 -0
- package/test/fixtures/android/element.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.cropped-rect.png +0 -0
- package/test/fixtures/image/house.cropped-region.png +0 -0
- package/test/fixtures/image/house.framed-higher-wider.png +0 -0
- package/test/fixtures/image/house.framed-higher.png +0 -0
- package/test/fixtures/image/house.framed-shorter-thinner.png +0 -0
- package/test/fixtures/image/house.framed-wider.png +0 -0
- package/test/fixtures/image/house.png +0 -0
- package/test/fixtures/image/house.rotated.png +0 -0
- package/test/fixtures/image/house.scaled.png +0 -0
- package/test/fixtures/image/house.stitched.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/ios/webview-fully.png +0 -0
- package/test/fixtures/ios/webview.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_nomarker.png +0 -0
- package/test/fixtures/pattern/iPhone_XS_portrait_noviewport.png +0 -0
- package/test/fixtures/web/element-fully.png +0 -0
- package/test/fixtures/web/element.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-frame-fully.png +0 -0
- package/test/fixtures/web/inner-frame.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 +0 -33
- package/test/it/image.spec.js +0 -146
package/test/e2e/web.spec.js
DELETED
|
@@ -1,334 +0,0 @@
|
|
|
1
|
-
const assert = require('assert')
|
|
2
|
-
const pixelmatch = require('pixelmatch')
|
|
3
|
-
const {Driver} = require('@applitools/driver')
|
|
4
|
-
const spec = require('@applitools/spec-driver-webdriverio')
|
|
5
|
-
const takeScreenshot = require('../../index')
|
|
6
|
-
const makeImage = require('../../src/image')
|
|
7
|
-
|
|
8
|
-
const env = {
|
|
9
|
-
url: 'http://localhost:4444/wd/hub',
|
|
10
|
-
capabilities: {
|
|
11
|
-
browserName: 'chrome',
|
|
12
|
-
},
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
// TODO add overflowed regions tests
|
|
16
|
-
|
|
17
|
-
describe('screenshoter web', () => {
|
|
18
|
-
const logger = {log: () => {}, warn: () => {}, error: () => {}, verbose: () => {}}
|
|
19
|
-
let driver, browser, destroyBrowser
|
|
20
|
-
|
|
21
|
-
before(async () => {
|
|
22
|
-
;[browser, destroyBrowser] = await spec.build(env)
|
|
23
|
-
})
|
|
24
|
-
|
|
25
|
-
after(async () => {
|
|
26
|
-
await destroyBrowser()
|
|
27
|
-
})
|
|
28
|
-
|
|
29
|
-
beforeEach(async () => {
|
|
30
|
-
driver = await new Driver({driver: browser, spec, logger}).init()
|
|
31
|
-
await driver.visit('https://applitools.github.io/demo/TestPages/FramesTestPage/')
|
|
32
|
-
await driver.setViewportSize({width: 700, height: 460})
|
|
33
|
-
})
|
|
34
|
-
|
|
35
|
-
it('take viewport screenshot', () => {
|
|
36
|
-
return viewport()
|
|
37
|
-
})
|
|
38
|
-
|
|
39
|
-
it('take full page screenshot with "scroll" scrolling', () => {
|
|
40
|
-
return fullPage({scrollingMode: 'scroll'})
|
|
41
|
-
})
|
|
42
|
-
it('take full page screenshot with "css" scrolling', () => {
|
|
43
|
-
return fullPage({scrollingMode: 'css'})
|
|
44
|
-
})
|
|
45
|
-
|
|
46
|
-
it('take frame screenshot with "scroll" scrolling', () => {
|
|
47
|
-
return frame({scrollingMode: 'scroll'})
|
|
48
|
-
})
|
|
49
|
-
it('take frame screenshot with "css" scrolling', () => {
|
|
50
|
-
return frame({scrollingMode: 'css'})
|
|
51
|
-
})
|
|
52
|
-
|
|
53
|
-
it('take full frame screenshot with "scroll" scrolling', () => {
|
|
54
|
-
return fullFrame({scrollingMode: 'scroll'})
|
|
55
|
-
})
|
|
56
|
-
it('take full frame screenshot with "css" scrolling', () => {
|
|
57
|
-
return fullFrame({scrollingMode: 'css'})
|
|
58
|
-
})
|
|
59
|
-
|
|
60
|
-
it('take region screenshot with "scroll" scrolling', () => {
|
|
61
|
-
return region({scrollingMode: 'scroll'})
|
|
62
|
-
})
|
|
63
|
-
it('take region screenshot with "css" scrolling', () => {
|
|
64
|
-
return region({scrollingMode: 'css'})
|
|
65
|
-
})
|
|
66
|
-
|
|
67
|
-
it('take full region screenshot with "scroll" scrolling', () => {
|
|
68
|
-
return fullRegion({scrollingMode: 'scroll'})
|
|
69
|
-
})
|
|
70
|
-
it('take full region screenshot with "css" scrolling', () => {
|
|
71
|
-
return fullRegion({scrollingMode: 'css'})
|
|
72
|
-
})
|
|
73
|
-
|
|
74
|
-
it('take element screenshot with "scroll" scrolling', () => {
|
|
75
|
-
return element({scrollingMode: 'scroll'})
|
|
76
|
-
})
|
|
77
|
-
it('take element screenshot with "css" scrolling', () => {
|
|
78
|
-
return element({scrollingMode: 'css'})
|
|
79
|
-
})
|
|
80
|
-
|
|
81
|
-
it('take full element screenshot with "scroll" scrolling', () => {
|
|
82
|
-
return fullElement({scrollingMode: 'scroll'})
|
|
83
|
-
})
|
|
84
|
-
it('take full element screenshot with "css" scrolling', () => {
|
|
85
|
-
return fullElement({scrollingMode: 'css'})
|
|
86
|
-
})
|
|
87
|
-
|
|
88
|
-
it('take region in frame screenshot with "scroll" scrolling', () => {
|
|
89
|
-
return regionInFrame({scrollingMode: 'scroll'})
|
|
90
|
-
})
|
|
91
|
-
it('take region in frame screenshot with "css" scrolling', () => {
|
|
92
|
-
return regionInFrame({scrollingMode: 'css'})
|
|
93
|
-
})
|
|
94
|
-
|
|
95
|
-
it('take full region in frame screenshot with "scroll" scrolling', () => {
|
|
96
|
-
return fullRegionInFrame({scrollingMode: 'scroll'})
|
|
97
|
-
})
|
|
98
|
-
it('take full region in frame screenshot with "css" scrolling', () => {
|
|
99
|
-
return fullRegionInFrame({scrollingMode: 'css'})
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
it('take element in frame screenshot with "scroll" scrolling', () => {
|
|
103
|
-
return elementInFrame({scrollingMode: 'scroll'})
|
|
104
|
-
})
|
|
105
|
-
it('take element in frame screenshot with "css" scrolling', () => {
|
|
106
|
-
return elementInFrame({scrollingMode: 'css'})
|
|
107
|
-
})
|
|
108
|
-
|
|
109
|
-
it('take full element in frame screenshot with "scroll" scrolling', () => {
|
|
110
|
-
return fullElementInFrame({scrollingMode: 'scroll'})
|
|
111
|
-
})
|
|
112
|
-
it('take full element in frame screenshot with "css" scrolling', () => {
|
|
113
|
-
return fullElementInFrame({scrollingMode: 'css'})
|
|
114
|
-
})
|
|
115
|
-
|
|
116
|
-
it('take frame in frame screenshot with "scroll" scrolling', () => {
|
|
117
|
-
return frameInFrame({scrollingMode: 'scroll'})
|
|
118
|
-
})
|
|
119
|
-
it('take frame in frame screenshot with "css" scrolling', () => {
|
|
120
|
-
return frameInFrame({scrollingMode: 'css'})
|
|
121
|
-
})
|
|
122
|
-
|
|
123
|
-
it('take full frame in frame screenshot with "scroll" scrolling', () => {
|
|
124
|
-
return fullFrameInFrame({scrollingMode: 'scroll'})
|
|
125
|
-
})
|
|
126
|
-
it('take full frame in frame screenshot with "css" scrolling', () => {
|
|
127
|
-
return fullFrameInFrame({scrollingMode: 'css'})
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
async function viewport(options) {
|
|
131
|
-
const screenshot = await takeScreenshot({logger, driver, ...options})
|
|
132
|
-
try {
|
|
133
|
-
const actual = await screenshot.image.toObject()
|
|
134
|
-
const expected = await makeImage('./test/fixtures/web/page.png').toObject()
|
|
135
|
-
assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
|
|
136
|
-
} catch (err) {
|
|
137
|
-
await screenshot.image.debug({path: './logs', name: 'viewport_failed'})
|
|
138
|
-
throw err
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
async function fullPage(options) {
|
|
142
|
-
const screenshot = await takeScreenshot({logger, driver, fully: true, ...options})
|
|
143
|
-
try {
|
|
144
|
-
const actual = await screenshot.image.toObject()
|
|
145
|
-
const expected = await makeImage('./test/fixtures/web/page-fully.png').toObject()
|
|
146
|
-
assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
|
|
147
|
-
} catch (err) {
|
|
148
|
-
await screenshot.image.debug({path: './logs', name: 'full_page_failed'})
|
|
149
|
-
throw err
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
async function frame(options) {
|
|
153
|
-
const screenshot = await takeScreenshot({
|
|
154
|
-
logger,
|
|
155
|
-
driver,
|
|
156
|
-
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
157
|
-
...options,
|
|
158
|
-
})
|
|
159
|
-
try {
|
|
160
|
-
const actual = await screenshot.image.toObject()
|
|
161
|
-
const expected = await makeImage('./test/fixtures/web/frame.png').toObject()
|
|
162
|
-
assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
|
|
163
|
-
} catch (err) {
|
|
164
|
-
await screenshot.image.debug({path: './logs', name: 'frame_failed'})
|
|
165
|
-
throw err
|
|
166
|
-
}
|
|
167
|
-
}
|
|
168
|
-
async function fullFrame(options) {
|
|
169
|
-
const screenshot = await takeScreenshot({
|
|
170
|
-
logger,
|
|
171
|
-
driver,
|
|
172
|
-
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
173
|
-
fully: true,
|
|
174
|
-
...options,
|
|
175
|
-
})
|
|
176
|
-
try {
|
|
177
|
-
const actual = await screenshot.image.toObject()
|
|
178
|
-
const expected = await makeImage('./test/fixtures/web/frame-fully.png').toObject()
|
|
179
|
-
assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
|
|
180
|
-
} catch (err) {
|
|
181
|
-
await screenshot.image.debug({path: './logs', name: 'full_frame_failed'})
|
|
182
|
-
throw err
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
async function region(options) {
|
|
186
|
-
const region = {x: 30, y: 500, height: 100, width: 200}
|
|
187
|
-
const screenshot = await takeScreenshot({logger, driver, region, ...options})
|
|
188
|
-
try {
|
|
189
|
-
const actual = await screenshot.image.toObject()
|
|
190
|
-
const expected = await makeImage('./test/fixtures/web/region.png').toObject()
|
|
191
|
-
assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
|
|
192
|
-
} catch (err) {
|
|
193
|
-
await screenshot.image.debug({path: './logs', name: 'region_failed'})
|
|
194
|
-
throw err
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
async function fullRegion(options) {
|
|
198
|
-
const region = {x: 30, y: 500, height: 700, width: 200}
|
|
199
|
-
const screenshot = await takeScreenshot({logger, driver, region, fully: true, ...options})
|
|
200
|
-
try {
|
|
201
|
-
const actual = await screenshot.image.toObject()
|
|
202
|
-
const expected = await makeImage('./test/fixtures/web/region-fully.png').toObject()
|
|
203
|
-
assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
|
|
204
|
-
} catch (err) {
|
|
205
|
-
await screenshot.image.debug({path: './logs', name: 'full_region_failed'})
|
|
206
|
-
throw err
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
async function element(options) {
|
|
210
|
-
const screenshot = await takeScreenshot({logger, driver, region: '#overflowing-div-image', ...options})
|
|
211
|
-
try {
|
|
212
|
-
const actual = await screenshot.image.toObject()
|
|
213
|
-
const expected = await makeImage('./test/fixtures/web/element.png').toObject()
|
|
214
|
-
assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
|
|
215
|
-
} catch (err) {
|
|
216
|
-
await screenshot.image.debug({path: './logs', name: 'element_failed'})
|
|
217
|
-
throw err
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
async function fullElement(options) {
|
|
221
|
-
const screenshot = await takeScreenshot({logger, driver, region: '#overflowing-div-image', fully: true, ...options})
|
|
222
|
-
try {
|
|
223
|
-
const actual = await screenshot.image.toObject()
|
|
224
|
-
const expected = await makeImage('./test/fixtures/web/element-fully.png').toObject()
|
|
225
|
-
assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
|
|
226
|
-
} catch (err) {
|
|
227
|
-
await screenshot.image.debug({path: './logs', name: 'full_element_failed'})
|
|
228
|
-
throw err
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
async function regionInFrame(options) {
|
|
232
|
-
const screenshot = await takeScreenshot({
|
|
233
|
-
logger,
|
|
234
|
-
driver,
|
|
235
|
-
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
236
|
-
region: {x: 10, y: 20, width: 110, height: 120},
|
|
237
|
-
...options,
|
|
238
|
-
})
|
|
239
|
-
try {
|
|
240
|
-
const actual = await screenshot.image.toObject()
|
|
241
|
-
const expected = await makeImage('./test/fixtures/web/inner-region.png').toObject()
|
|
242
|
-
assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
|
|
243
|
-
} catch (err) {
|
|
244
|
-
await screenshot.image.debug({path: './logs', name: 'region_in_frame_failed'})
|
|
245
|
-
throw err
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
async function fullRegionInFrame(options) {
|
|
249
|
-
const screenshot = await takeScreenshot({
|
|
250
|
-
logger,
|
|
251
|
-
driver,
|
|
252
|
-
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
253
|
-
region: {x: 10, y: 100, width: 1000, height: 120},
|
|
254
|
-
fully: true,
|
|
255
|
-
...options,
|
|
256
|
-
})
|
|
257
|
-
try {
|
|
258
|
-
const actual = await screenshot.image.toObject()
|
|
259
|
-
const expected = await makeImage('./test/fixtures/web/inner-region-fully.png').toObject()
|
|
260
|
-
assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
|
|
261
|
-
} catch (err) {
|
|
262
|
-
await screenshot.image.debug({path: './logs', name: 'full_region_in_frame_failed'})
|
|
263
|
-
throw err
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
async function elementInFrame(options) {
|
|
267
|
-
const screenshot = await takeScreenshot({
|
|
268
|
-
logger,
|
|
269
|
-
driver,
|
|
270
|
-
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
271
|
-
region: '#inner-frame-div',
|
|
272
|
-
...options,
|
|
273
|
-
})
|
|
274
|
-
try {
|
|
275
|
-
const actual = await screenshot.image.toObject()
|
|
276
|
-
const expected = await makeImage('./test/fixtures/web/inner-element.png').toObject()
|
|
277
|
-
assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
|
|
278
|
-
} catch (err) {
|
|
279
|
-
await screenshot.image.debug({path: './logs', name: 'element_in_frame_failed'})
|
|
280
|
-
throw err
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
async function fullElementInFrame(options) {
|
|
284
|
-
const screenshot = await takeScreenshot({
|
|
285
|
-
logger,
|
|
286
|
-
driver,
|
|
287
|
-
frames: [{reference: 'iframe[name="frame1"]'}],
|
|
288
|
-
region: '#inner-frame-div',
|
|
289
|
-
fully: true,
|
|
290
|
-
...options,
|
|
291
|
-
})
|
|
292
|
-
try {
|
|
293
|
-
const actual = await screenshot.image.toObject()
|
|
294
|
-
const expected = await makeImage('./test/fixtures/web/inner-element-fully.png').toObject()
|
|
295
|
-
assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
|
|
296
|
-
} catch (err) {
|
|
297
|
-
await screenshot.image.debug({path: './logs', name: 'full_element_in_frame_failed'})
|
|
298
|
-
throw err
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
async function frameInFrame(options) {
|
|
302
|
-
const screenshot = await takeScreenshot({
|
|
303
|
-
logger,
|
|
304
|
-
driver,
|
|
305
|
-
frames: [{reference: 'iframe[name="frame1"]'}, {reference: 'iframe[name="frame1-1"]'}],
|
|
306
|
-
...options,
|
|
307
|
-
})
|
|
308
|
-
try {
|
|
309
|
-
const actual = await screenshot.image.toObject()
|
|
310
|
-
const expected = await makeImage('./test/fixtures/web/inner-frame.png').toObject()
|
|
311
|
-
assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
|
|
312
|
-
} catch (err) {
|
|
313
|
-
await screenshot.image.debug({path: './logs', name: 'frame_in_frame_failed'})
|
|
314
|
-
throw err
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
async function fullFrameInFrame(options) {
|
|
318
|
-
const screenshot = await takeScreenshot({
|
|
319
|
-
logger,
|
|
320
|
-
driver,
|
|
321
|
-
frames: [{reference: 'iframe[name="frame1"]'}, {reference: 'iframe[name="frame1-1"]'}],
|
|
322
|
-
fully: true,
|
|
323
|
-
...options,
|
|
324
|
-
})
|
|
325
|
-
try {
|
|
326
|
-
const actual = await screenshot.image.toObject()
|
|
327
|
-
const expected = await makeImage('./test/fixtures/web/inner-frame-fully.png').toObject()
|
|
328
|
-
assert.strictEqual(pixelmatch(actual.data, expected.data, null, expected.width, expected.height), 0)
|
|
329
|
-
} catch (err) {
|
|
330
|
-
await screenshot.image.debug({path: './logs', name: 'full_frame_in_frame_failed'})
|
|
331
|
-
throw err
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
})
|
|
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
|
|
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
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
const assert = require('assert')
|
|
2
|
-
const makeImage = require('../../src/image')
|
|
3
|
-
const findPattern = require('../../src/find-image-pattern')
|
|
4
|
-
|
|
5
|
-
describe('pattern', () => {
|
|
6
|
-
const fixtures = [
|
|
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: 640, y: 136}, offset: 1, pixelRatio: 2},
|
|
17
|
-
{name: 'iPhone_XS_portrait_noviewport', position: {x: 0, y: 282}, offset: 0, pixelRatio: 3},
|
|
18
|
-
{name: 'iPhone_XS_portrait_nomarker', position: null, pixelRatio: 3},
|
|
19
|
-
]
|
|
20
|
-
|
|
21
|
-
fixtures.forEach(({name, position, offset, pixelRatio}) => {
|
|
22
|
-
it(name, async () => {
|
|
23
|
-
const image = await makeImage(`./test/fixtures/pattern/${name}.png`)
|
|
24
|
-
const result = findPattern(await image.toObject(), {
|
|
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,
|
|
29
|
-
})
|
|
30
|
-
assert.deepStrictEqual(result, position)
|
|
31
|
-
})
|
|
32
|
-
})
|
|
33
|
-
})
|