chartjs-test-utils 0.4.0 → 1.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.
- package/README.md +230 -4
- package/package.json +58 -22
- package/src/canvas.js +69 -0
- package/src/chart.js +241 -0
- package/src/context.js +171 -0
- package/src/fixtures.js +149 -0
- package/src/index.js +92 -0
- package/src/matchers.js +224 -0
- package/src/matchers.options.js +114 -0
- package/src/node.js +43 -0
- package/src/spriting.js +104 -0
- package/types/entry.d.ts +134 -0
- package/types/generated/canvas.d.ts +35 -0
- package/types/generated/chart.d.ts +93 -0
- package/types/generated/context.d.ts +49 -0
- package/types/generated/fixtures.d.ts +24 -0
- package/types/generated/index.d.ts +38 -0
- package/types/generated/matchers.d.ts +55 -0
- package/types/generated/matchers.options.d.ts +10 -0
- package/types/generated/node.d.ts +33 -0
- package/types/generated/spriting.d.ts +2 -0
- package/dist/chartjs-test-utils.js +0 -1178
|
@@ -1,1178 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
* chartjs-test-utils v0.4.0
|
|
3
|
-
* https://github.com/chartjs/chartjs-test-utils#readme
|
|
4
|
-
* (c) 2022 chartjs-plugin-annotation Contributors
|
|
5
|
-
* Released under the MIT License
|
|
6
|
-
*/
|
|
7
|
-
// Code from https://stackoverflow.com/questions/4406864/html-canvas-unit-testing
|
|
8
|
-
class Context {
|
|
9
|
-
constructor() {
|
|
10
|
-
this._calls = []; // names/args of recorded calls
|
|
11
|
-
this._initMethods();
|
|
12
|
-
|
|
13
|
-
this._fillStyle = null;
|
|
14
|
-
this._font = null;
|
|
15
|
-
this._lineCap = null;
|
|
16
|
-
this._lineDashOffset = null;
|
|
17
|
-
this._lineJoin = null;
|
|
18
|
-
this._lineWidth = null;
|
|
19
|
-
this._strokeStyle = null;
|
|
20
|
-
this._textAlign = null;
|
|
21
|
-
this._textBaseline = null;
|
|
22
|
-
|
|
23
|
-
// Define properties here so that we can record each time they are set
|
|
24
|
-
Object.defineProperties(this, {
|
|
25
|
-
fillStyle: {
|
|
26
|
-
get: function() {
|
|
27
|
-
return this._fillStyle;
|
|
28
|
-
},
|
|
29
|
-
set: function(style) {
|
|
30
|
-
this._fillStyle = style;
|
|
31
|
-
this.record('setFillStyle', [style]);
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
font: {
|
|
35
|
-
get: function() {
|
|
36
|
-
return this._font;
|
|
37
|
-
},
|
|
38
|
-
set: function(font) {
|
|
39
|
-
this._font = font;
|
|
40
|
-
this.record('setFont', [font]);
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
lineCap: {
|
|
44
|
-
get: function() {
|
|
45
|
-
return this._lineCap;
|
|
46
|
-
},
|
|
47
|
-
set: function(cap) {
|
|
48
|
-
this._lineCap = cap;
|
|
49
|
-
this.record('setLineCap', [cap]);
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
lineDashOffset: {
|
|
53
|
-
get: function() {
|
|
54
|
-
return this._lineDashOffset;
|
|
55
|
-
},
|
|
56
|
-
set: function(offset) {
|
|
57
|
-
this._lineDashOffset = offset;
|
|
58
|
-
this.record('setLineDashOffset', [offset]);
|
|
59
|
-
}
|
|
60
|
-
},
|
|
61
|
-
lineJoin: {
|
|
62
|
-
get: function() {
|
|
63
|
-
return this._lineJoin;
|
|
64
|
-
},
|
|
65
|
-
set: function(join) {
|
|
66
|
-
this._lineJoin = join;
|
|
67
|
-
this.record('setLineJoin', [join]);
|
|
68
|
-
}
|
|
69
|
-
},
|
|
70
|
-
lineWidth: {
|
|
71
|
-
get: function() {
|
|
72
|
-
return this._lineWidth;
|
|
73
|
-
},
|
|
74
|
-
set: function(width) {
|
|
75
|
-
this._lineWidth = width;
|
|
76
|
-
this.record('setLineWidth', [width]);
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
strokeStyle: {
|
|
80
|
-
get: function() {
|
|
81
|
-
return this._strokeStyle;
|
|
82
|
-
},
|
|
83
|
-
set: function(style) {
|
|
84
|
-
this._strokeStyle = style;
|
|
85
|
-
this.record('setStrokeStyle', [style]);
|
|
86
|
-
}
|
|
87
|
-
},
|
|
88
|
-
textAlign: {
|
|
89
|
-
get: function() {
|
|
90
|
-
return this._textAlign;
|
|
91
|
-
},
|
|
92
|
-
set: function(align) {
|
|
93
|
-
this._textAlign = align;
|
|
94
|
-
this.record('setTextAlign', [align]);
|
|
95
|
-
}
|
|
96
|
-
},
|
|
97
|
-
textBaseline: {
|
|
98
|
-
get: function() {
|
|
99
|
-
return this._textBaseline;
|
|
100
|
-
},
|
|
101
|
-
set: function(baseline) {
|
|
102
|
-
this._textBaseline = baseline;
|
|
103
|
-
this.record('setTextBaseline', [baseline]);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
});
|
|
107
|
-
}
|
|
108
|
-
_initMethods() {
|
|
109
|
-
// define methods to test here
|
|
110
|
-
// no way to introspect so we have to do some extra work :(
|
|
111
|
-
var me = this;
|
|
112
|
-
var methods = {
|
|
113
|
-
arc: function() { },
|
|
114
|
-
arcTo: function() { },
|
|
115
|
-
beginPath: function() { },
|
|
116
|
-
bezierCurveTo: function() { },
|
|
117
|
-
clearRect: function() { },
|
|
118
|
-
clip: function() { },
|
|
119
|
-
closePath: function() { },
|
|
120
|
-
fill: function() { },
|
|
121
|
-
fillRect: function() { },
|
|
122
|
-
fillText: function() { },
|
|
123
|
-
strokeText: function() { },
|
|
124
|
-
lineTo: function() { },
|
|
125
|
-
measureText: function(text) {
|
|
126
|
-
// return the number of characters * fixed size
|
|
127
|
-
// Uses fake numbers for the bounding box
|
|
128
|
-
return text ? {
|
|
129
|
-
actualBoundingBoxAscent: 4,
|
|
130
|
-
actualBoundingBoxDescent: 8,
|
|
131
|
-
actualBoundingBoxLeft: 15,
|
|
132
|
-
actualBoundingBoxRight: 25,
|
|
133
|
-
width: text.length * 10
|
|
134
|
-
} : {
|
|
135
|
-
actualBoundingBoxAscent: 0,
|
|
136
|
-
actualBoundingBoxDescent: 0,
|
|
137
|
-
actualBoundingBoxLeft: 0,
|
|
138
|
-
actualBoundingBoxRight: 0,
|
|
139
|
-
width: 0
|
|
140
|
-
};
|
|
141
|
-
},
|
|
142
|
-
moveTo: function() { },
|
|
143
|
-
quadraticCurveTo: function() { },
|
|
144
|
-
rect: function() { },
|
|
145
|
-
restore: function() { },
|
|
146
|
-
rotate: function() { },
|
|
147
|
-
save: function() { },
|
|
148
|
-
setLineDash: function() { },
|
|
149
|
-
stroke: function() { },
|
|
150
|
-
strokeRect: function() { },
|
|
151
|
-
setTransform: function() { },
|
|
152
|
-
translate: function() { },
|
|
153
|
-
};
|
|
154
|
-
|
|
155
|
-
Object.keys(methods).forEach(function(name) {
|
|
156
|
-
me[name] = function() {
|
|
157
|
-
me.record(name, arguments);
|
|
158
|
-
return methods[name].apply(me, arguments);
|
|
159
|
-
};
|
|
160
|
-
});
|
|
161
|
-
}
|
|
162
|
-
record(methodName, args) {
|
|
163
|
-
this._calls.push({
|
|
164
|
-
name: methodName,
|
|
165
|
-
args: Array.prototype.slice.call(args)
|
|
166
|
-
});
|
|
167
|
-
}
|
|
168
|
-
getCalls() {
|
|
169
|
-
return this._calls;
|
|
170
|
-
}
|
|
171
|
-
resetCalls() {
|
|
172
|
-
this._calls = [];
|
|
173
|
-
}
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
var pixelmatch_1 = pixelmatch;
|
|
177
|
-
|
|
178
|
-
const defaultOptions = {
|
|
179
|
-
threshold: 0.1, // matching threshold (0 to 1); smaller is more sensitive
|
|
180
|
-
includeAA: false, // whether to skip anti-aliasing detection
|
|
181
|
-
alpha: 0.1, // opacity of original image in diff ouput
|
|
182
|
-
aaColor: [255, 255, 0], // color of anti-aliased pixels in diff output
|
|
183
|
-
diffColor: [255, 0, 0], // color of different pixels in diff output
|
|
184
|
-
diffColorAlt: null, // whether to detect dark on light differences between img1 and img2 and set an alternative color to differentiate between the two
|
|
185
|
-
diffMask: false // draw the diff over a transparent background (a mask)
|
|
186
|
-
};
|
|
187
|
-
|
|
188
|
-
function pixelmatch(img1, img2, output, width, height, options) {
|
|
189
|
-
|
|
190
|
-
if (!isPixelData(img1) || !isPixelData(img2) || (output && !isPixelData(output)))
|
|
191
|
-
throw new Error('Image data: Uint8Array, Uint8ClampedArray or Buffer expected.');
|
|
192
|
-
|
|
193
|
-
if (img1.length !== img2.length || (output && output.length !== img1.length))
|
|
194
|
-
throw new Error('Image sizes do not match.');
|
|
195
|
-
|
|
196
|
-
if (img1.length !== width * height * 4) throw new Error('Image data size does not match width/height.');
|
|
197
|
-
|
|
198
|
-
options = Object.assign({}, defaultOptions, options);
|
|
199
|
-
|
|
200
|
-
// check if images are identical
|
|
201
|
-
const len = width * height;
|
|
202
|
-
const a32 = new Uint32Array(img1.buffer, img1.byteOffset, len);
|
|
203
|
-
const b32 = new Uint32Array(img2.buffer, img2.byteOffset, len);
|
|
204
|
-
let identical = true;
|
|
205
|
-
|
|
206
|
-
for (let i = 0; i < len; i++) {
|
|
207
|
-
if (a32[i] !== b32[i]) { identical = false; break; }
|
|
208
|
-
}
|
|
209
|
-
if (identical) { // fast path if identical
|
|
210
|
-
if (output && !options.diffMask) {
|
|
211
|
-
for (let i = 0; i < len; i++) drawGrayPixel(img1, 4 * i, options.alpha, output);
|
|
212
|
-
}
|
|
213
|
-
return 0;
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
// maximum acceptable square distance between two colors;
|
|
217
|
-
// 35215 is the maximum possible value for the YIQ difference metric
|
|
218
|
-
const maxDelta = 35215 * options.threshold * options.threshold;
|
|
219
|
-
let diff = 0;
|
|
220
|
-
|
|
221
|
-
// compare each pixel of one image against the other one
|
|
222
|
-
for (let y = 0; y < height; y++) {
|
|
223
|
-
for (let x = 0; x < width; x++) {
|
|
224
|
-
|
|
225
|
-
const pos = (y * width + x) * 4;
|
|
226
|
-
|
|
227
|
-
// squared YUV distance between colors at this pixel position, negative if the img2 pixel is darker
|
|
228
|
-
const delta = colorDelta(img1, img2, pos, pos);
|
|
229
|
-
|
|
230
|
-
// the color difference is above the threshold
|
|
231
|
-
if (Math.abs(delta) > maxDelta) {
|
|
232
|
-
// check it's a real rendering difference or just anti-aliasing
|
|
233
|
-
if (!options.includeAA && (antialiased(img1, x, y, width, height, img2) ||
|
|
234
|
-
antialiased(img2, x, y, width, height, img1))) {
|
|
235
|
-
// one of the pixels is anti-aliasing; draw as yellow and do not count as difference
|
|
236
|
-
// note that we do not include such pixels in a mask
|
|
237
|
-
if (output && !options.diffMask) drawPixel(output, pos, ...options.aaColor);
|
|
238
|
-
|
|
239
|
-
} else {
|
|
240
|
-
// found substantial difference not caused by anti-aliasing; draw it as such
|
|
241
|
-
if (output) {
|
|
242
|
-
drawPixel(output, pos, ...(delta < 0 && options.diffColorAlt || options.diffColor));
|
|
243
|
-
}
|
|
244
|
-
diff++;
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
} else if (output) {
|
|
248
|
-
// pixels are similar; draw background as grayscale image blended with white
|
|
249
|
-
if (!options.diffMask) drawGrayPixel(img1, pos, options.alpha, output);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
// return the number of different pixels
|
|
255
|
-
return diff;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
function isPixelData(arr) {
|
|
259
|
-
// work around instanceof Uint8Array not working properly in some Jest environments
|
|
260
|
-
return ArrayBuffer.isView(arr) && arr.constructor.BYTES_PER_ELEMENT === 1;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
// check if a pixel is likely a part of anti-aliasing;
|
|
264
|
-
// based on "Anti-aliased Pixel and Intensity Slope Detector" paper by V. Vysniauskas, 2009
|
|
265
|
-
|
|
266
|
-
function antialiased(img, x1, y1, width, height, img2) {
|
|
267
|
-
const x0 = Math.max(x1 - 1, 0);
|
|
268
|
-
const y0 = Math.max(y1 - 1, 0);
|
|
269
|
-
const x2 = Math.min(x1 + 1, width - 1);
|
|
270
|
-
const y2 = Math.min(y1 + 1, height - 1);
|
|
271
|
-
const pos = (y1 * width + x1) * 4;
|
|
272
|
-
let zeroes = x1 === x0 || x1 === x2 || y1 === y0 || y1 === y2 ? 1 : 0;
|
|
273
|
-
let min = 0;
|
|
274
|
-
let max = 0;
|
|
275
|
-
let minX, minY, maxX, maxY;
|
|
276
|
-
|
|
277
|
-
// go through 8 adjacent pixels
|
|
278
|
-
for (let x = x0; x <= x2; x++) {
|
|
279
|
-
for (let y = y0; y <= y2; y++) {
|
|
280
|
-
if (x === x1 && y === y1) continue;
|
|
281
|
-
|
|
282
|
-
// brightness delta between the center pixel and adjacent one
|
|
283
|
-
const delta = colorDelta(img, img, pos, (y * width + x) * 4, true);
|
|
284
|
-
|
|
285
|
-
// count the number of equal, darker and brighter adjacent pixels
|
|
286
|
-
if (delta === 0) {
|
|
287
|
-
zeroes++;
|
|
288
|
-
// if found more than 2 equal siblings, it's definitely not anti-aliasing
|
|
289
|
-
if (zeroes > 2) return false;
|
|
290
|
-
|
|
291
|
-
// remember the darkest pixel
|
|
292
|
-
} else if (delta < min) {
|
|
293
|
-
min = delta;
|
|
294
|
-
minX = x;
|
|
295
|
-
minY = y;
|
|
296
|
-
|
|
297
|
-
// remember the brightest pixel
|
|
298
|
-
} else if (delta > max) {
|
|
299
|
-
max = delta;
|
|
300
|
-
maxX = x;
|
|
301
|
-
maxY = y;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
// if there are no both darker and brighter pixels among siblings, it's not anti-aliasing
|
|
307
|
-
if (min === 0 || max === 0) return false;
|
|
308
|
-
|
|
309
|
-
// if either the darkest or the brightest pixel has 3+ equal siblings in both images
|
|
310
|
-
// (definitely not anti-aliased), this pixel is anti-aliased
|
|
311
|
-
return (hasManySiblings(img, minX, minY, width, height) && hasManySiblings(img2, minX, minY, width, height)) ||
|
|
312
|
-
(hasManySiblings(img, maxX, maxY, width, height) && hasManySiblings(img2, maxX, maxY, width, height));
|
|
313
|
-
}
|
|
314
|
-
|
|
315
|
-
// check if a pixel has 3+ adjacent pixels of the same color.
|
|
316
|
-
function hasManySiblings(img, x1, y1, width, height) {
|
|
317
|
-
const x0 = Math.max(x1 - 1, 0);
|
|
318
|
-
const y0 = Math.max(y1 - 1, 0);
|
|
319
|
-
const x2 = Math.min(x1 + 1, width - 1);
|
|
320
|
-
const y2 = Math.min(y1 + 1, height - 1);
|
|
321
|
-
const pos = (y1 * width + x1) * 4;
|
|
322
|
-
let zeroes = x1 === x0 || x1 === x2 || y1 === y0 || y1 === y2 ? 1 : 0;
|
|
323
|
-
|
|
324
|
-
// go through 8 adjacent pixels
|
|
325
|
-
for (let x = x0; x <= x2; x++) {
|
|
326
|
-
for (let y = y0; y <= y2; y++) {
|
|
327
|
-
if (x === x1 && y === y1) continue;
|
|
328
|
-
|
|
329
|
-
const pos2 = (y * width + x) * 4;
|
|
330
|
-
if (img[pos] === img[pos2] &&
|
|
331
|
-
img[pos + 1] === img[pos2 + 1] &&
|
|
332
|
-
img[pos + 2] === img[pos2 + 2] &&
|
|
333
|
-
img[pos + 3] === img[pos2 + 3]) zeroes++;
|
|
334
|
-
|
|
335
|
-
if (zeroes > 2) return true;
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
return false;
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
// calculate color difference according to the paper "Measuring perceived color difference
|
|
343
|
-
// using YIQ NTSC transmission color space in mobile applications" by Y. Kotsarenko and F. Ramos
|
|
344
|
-
|
|
345
|
-
function colorDelta(img1, img2, k, m, yOnly) {
|
|
346
|
-
let r1 = img1[k + 0];
|
|
347
|
-
let g1 = img1[k + 1];
|
|
348
|
-
let b1 = img1[k + 2];
|
|
349
|
-
let a1 = img1[k + 3];
|
|
350
|
-
|
|
351
|
-
let r2 = img2[m + 0];
|
|
352
|
-
let g2 = img2[m + 1];
|
|
353
|
-
let b2 = img2[m + 2];
|
|
354
|
-
let a2 = img2[m + 3];
|
|
355
|
-
|
|
356
|
-
if (a1 === a2 && r1 === r2 && g1 === g2 && b1 === b2) return 0;
|
|
357
|
-
|
|
358
|
-
if (a1 < 255) {
|
|
359
|
-
a1 /= 255;
|
|
360
|
-
r1 = blend(r1, a1);
|
|
361
|
-
g1 = blend(g1, a1);
|
|
362
|
-
b1 = blend(b1, a1);
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
if (a2 < 255) {
|
|
366
|
-
a2 /= 255;
|
|
367
|
-
r2 = blend(r2, a2);
|
|
368
|
-
g2 = blend(g2, a2);
|
|
369
|
-
b2 = blend(b2, a2);
|
|
370
|
-
}
|
|
371
|
-
|
|
372
|
-
const y1 = rgb2y(r1, g1, b1);
|
|
373
|
-
const y2 = rgb2y(r2, g2, b2);
|
|
374
|
-
const y = y1 - y2;
|
|
375
|
-
|
|
376
|
-
if (yOnly) return y; // brightness difference only
|
|
377
|
-
|
|
378
|
-
const i = rgb2i(r1, g1, b1) - rgb2i(r2, g2, b2);
|
|
379
|
-
const q = rgb2q(r1, g1, b1) - rgb2q(r2, g2, b2);
|
|
380
|
-
|
|
381
|
-
const delta = 0.5053 * y * y + 0.299 * i * i + 0.1957 * q * q;
|
|
382
|
-
|
|
383
|
-
// encode whether the pixel lightens or darkens in the sign
|
|
384
|
-
return y1 > y2 ? -delta : delta;
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
function rgb2y(r, g, b) { return r * 0.29889531 + g * 0.58662247 + b * 0.11448223; }
|
|
388
|
-
function rgb2i(r, g, b) { return r * 0.59597799 - g * 0.27417610 - b * 0.32180189; }
|
|
389
|
-
function rgb2q(r, g, b) { return r * 0.21147017 - g * 0.52261711 + b * 0.31114694; }
|
|
390
|
-
|
|
391
|
-
// blend semi-transparent color with white
|
|
392
|
-
function blend(c, a) {
|
|
393
|
-
return 255 + (c - 255) * a;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
function drawPixel(output, pos, r, g, b) {
|
|
397
|
-
output[pos + 0] = r;
|
|
398
|
-
output[pos + 1] = g;
|
|
399
|
-
output[pos + 2] = b;
|
|
400
|
-
output[pos + 3] = 255;
|
|
401
|
-
}
|
|
402
|
-
|
|
403
|
-
function drawGrayPixel(img, i, alpha, output) {
|
|
404
|
-
const r = img[i + 0];
|
|
405
|
-
const g = img[i + 1];
|
|
406
|
-
const b = img[i + 2];
|
|
407
|
-
const val = blend(rgb2y(r, g, b), alpha * img[i + 3] / 255);
|
|
408
|
-
drawPixel(output, i, val, val, val);
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
const characters = new Image();
|
|
412
|
-
// data url for image containing all the characters
|
|
413
|
-
characters.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAIAAADTED8xAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAC0NSURBVHhe7Z1PiBXZ9cd/7SpZ6Sa6EHQgw7jUZMAYZiExgZCFvTIwEcJsItgwgQnjZoIyhAjJwmYWWSg6m6Eh3cRsxoZkEw1mMUoWjk1WymxsmIWdTXdCwuzy+9b9nr59+lbVrXNvvyqr37sf8HnOrXPu/3/Vdeu9uf/973//VyjMKgfk/0JhJpnOATA3NydSoRAlcwCgh6V2Mu/iBQvz8/OBEGdjY2NhYQECPiEzMM7jx4+RH3xSXVlZef78OeUITAiOxoRcoZOHJXLC4liApSXndTIyNj3gHiCDDF/v4oVOXrx4cePGDS10cvXq1adPnyJ+fF6+fFlCo5w/f35zcxOfVI1eMEMqcMSnxaUqc3ptI+bl5WVRuoClMfMe1Ort27eZCgQJnSWGGwCoa3ZiL3Ry//79e/fuaaET5iopb9rl0aNHSMsFd4ABAxeMTHz6wRPBXmoPI8dIFr0Ljnx4iW4DuYJXat6mhrRO7MGckTrZpIJWCZALUdAXsQgYjYleAVAoyAyPw97GYYBhI6ETBbMyIrd3aA4Y+4oBMOvDHo6YX1JXAKQFRNm3ZBbATWe9zxl+jNkHGxqSDYPsvXz5UkKjoPv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nkjBpLyhhixmdqcwzQlKPrIq+EvOYhmAjLd9F1spca7hXZAvmXSOzvakyTSwaY/5AEePfddy0vXtC4LkfQZlqOoM20HEGbabmNhYUF2GCXBZl7LfshJbQI7FF1orezl1TSwKAM3jywvHgxTS4Z8IiOP57Et3biwAzU5QjaTMsRtJmWI2gzLbfB8zmoXsisZMtBHRfxTrug3uRCC3mpZFCVNuPc6dS4wCZALkQ57062+rcUbhjeO6NlXY6gzbQcQZtpOYI203IbLDWLjE/IGeMfFUi5jbxUMqjyVGWt51oD2kzLEbSZliNoMy1PFsaMhmHbALnQjjbTcgRtpuUI2kzLEbSZliNw/G+m/Eqki7j3VDKo7gE4a3oCtZFpcgHYYgJRDLDfX7lyhYfU2VSzA8vLP83lld3itfdUTGAQDLPVHq0LgCUQxQAXaGxkeeTudtfvigIOxZcvXzKHQC60M1oXfdAQsoRGoTEahb6d9wAgI5UMpLS4w8AgA/ZbjWlySUW3zdWrVy2vqsAFWUJv83cOcqGd0boAWgJsUSQoCo3RIvjE+imhXdALGFPJwFTaQh10F5FmEn5PBz5F74L9WBQzqalkUM4CZTLLD782Njb46OPChQsM6YNhUikDoJDG3NzckSNHjh49inuGkydPSuikGSYVUI5CFGaasgIUZpj/+7//B6WwXaZq8jObAAAAAElFTkSuQmCC';
|
|
414
|
-
|
|
415
|
-
// the data url image size
|
|
416
|
-
const imgWidth = 256;
|
|
417
|
-
const imgHeight = 256;
|
|
418
|
-
// individual characted bounding box
|
|
419
|
-
const cellWidth = 17;
|
|
420
|
-
const cellHeight = 17;
|
|
421
|
-
// char code for [0, 0]
|
|
422
|
-
const startIndex = 32;
|
|
423
|
-
// number of columns in image
|
|
424
|
-
const columns = Math.floor(imgWidth / cellWidth);
|
|
425
|
-
// number of rows in image
|
|
426
|
-
const rows = Math.floor(imgHeight / cellHeight);
|
|
427
|
-
// font height (in pixels)
|
|
428
|
-
const fontHeight = 16;
|
|
429
|
-
// the font widths by char code, starting at startIndex
|
|
430
|
-
const fontWidth = [
|
|
431
|
-
4, 4, 6, 7, 7, 10, 9, 3, 4, 4, 5, 8, 4, 4, 4, 4,
|
|
432
|
-
7, 7, 7, 7, 7, 7, 7, 7, 7, 7, 4, 4, 8, 8, 8, 8,
|
|
433
|
-
13, 9, 9, 9, 9, 8, 8, 10, 9, 4, 7, 9, 8, 11, 9, 10,
|
|
434
|
-
9, 10, 9, 9, 8, 9, 9, 13, 9, 8, 7, 4, 4, 4, 8, 7,
|
|
435
|
-
4, 8, 8, 7, 8, 8, 4, 8, 8, 4, 4, 7, 4, 12, 8, 8,
|
|
436
|
-
8, 8, 5, 6, 4, 8, 7, 11, 8, 7, 7, 5, 3, 5, 8, 10,
|
|
437
|
-
7, 10, 4, 7, 7, 13, 7, 7, 4, 12, 9, 4, 14, 10, 7, 10,
|
|
438
|
-
10, 4, 4, 7, 7, 5, 7, 13, 4, 13, 6, 4, 12, 10, 7, 8,
|
|
439
|
-
4, 4, 7, 7, 7, 7, 3, 7, 4, 10, 5, 7, 8, 4, 10, 7,
|
|
440
|
-
5, 7, 4, 4, 4, 7, 7, 4, 4, 4, 5, 7, 11, 11, 11, 8,
|
|
441
|
-
9, 9, 9, 9, 9, 9, 13, 9, 8, 8, 8, 8, 4, 4, 4, 4,
|
|
442
|
-
9, 9, 10, 10, 10, 10, 10, 8, 10, 9, 9, 9, 9, 8, 9, 8,
|
|
443
|
-
8, 8, 8, 8, 8, 8, 12, 7, 8, 8, 8, 8, 4, 4, 4, 4,
|
|
444
|
-
8, 8, 8, 8, 8, 8, 8, 7, 8, 8, 8, 8, 8, 7, 8, 7
|
|
445
|
-
];
|
|
446
|
-
|
|
447
|
-
// get coordinates and size for one character
|
|
448
|
-
function getChar(asciiCode) {
|
|
449
|
-
const index = asciiCode - startIndex;
|
|
450
|
-
const x = Math.min(index % columns, columns - 1);
|
|
451
|
-
const y = Math.min(Math.floor(index / columns), rows - 1);
|
|
452
|
-
return {sx: x * cellWidth, sy: y * cellHeight, w: fontWidth[index], h: fontHeight};
|
|
453
|
-
}
|
|
454
|
-
|
|
455
|
-
function measureText(text) {
|
|
456
|
-
let width = 0;
|
|
457
|
-
if (text && text.charCodeAt) {
|
|
458
|
-
for (let i = 0; i < text.length; ++i) {
|
|
459
|
-
width += fontWidth[Math.min(223, text.charCodeAt(i) - startIndex)];
|
|
460
|
-
}
|
|
461
|
-
}
|
|
462
|
-
return {width};
|
|
463
|
-
}
|
|
464
|
-
|
|
465
|
-
function spriteWrite(text, x, y) {
|
|
466
|
-
if (text && text.charCodeAt) {
|
|
467
|
-
const align = this.textAlign;
|
|
468
|
-
if (align === 'center' || align === 'right') {
|
|
469
|
-
const w = measureText(text).width;
|
|
470
|
-
x -= align === 'center' ? w / 2 : w;
|
|
471
|
-
}
|
|
472
|
-
const base = this.textBaseline;
|
|
473
|
-
switch (base) {
|
|
474
|
-
case 'top':
|
|
475
|
-
case 'hanging':
|
|
476
|
-
y -= fontHeight;
|
|
477
|
-
break;
|
|
478
|
-
case 'middle':
|
|
479
|
-
case 'alphabetic':
|
|
480
|
-
case 'ideaographic':
|
|
481
|
-
y -= fontHeight / 2;
|
|
482
|
-
break;
|
|
483
|
-
}
|
|
484
|
-
for (let i = 0; i < text.length; ++i) {
|
|
485
|
-
const {sx, sy, w, h} = getChar(text.charCodeAt(i));
|
|
486
|
-
this.drawImage(characters, sx, sy, w, h, x, y, w, h);
|
|
487
|
-
x += w;
|
|
488
|
-
}
|
|
489
|
-
}
|
|
490
|
-
}
|
|
491
|
-
|
|
492
|
-
function spritingOn(ctx) {
|
|
493
|
-
if (ctx && !ctx._fillText) {
|
|
494
|
-
ctx._fillText = ctx.fillText;
|
|
495
|
-
ctx._measureText = ctx.measureText;
|
|
496
|
-
|
|
497
|
-
ctx.fillText = spriteWrite;
|
|
498
|
-
ctx.measureText = measureText;
|
|
499
|
-
}
|
|
500
|
-
}
|
|
501
|
-
|
|
502
|
-
function spritingOff(ctx) {
|
|
503
|
-
if (ctx && ctx._fillText) {
|
|
504
|
-
ctx.fillText = ctx._fillText;
|
|
505
|
-
ctx.measureText = ctx._measureText;
|
|
506
|
-
delete ctx._fillText;
|
|
507
|
-
delete ctx._measureText;
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
|
|
511
|
-
function createCanvas(w, h) {
|
|
512
|
-
var canvas = document.createElement('canvas');
|
|
513
|
-
canvas.width = w;
|
|
514
|
-
canvas.height = h;
|
|
515
|
-
return canvas;
|
|
516
|
-
}
|
|
517
|
-
|
|
518
|
-
function readImageData(url, callback) {
|
|
519
|
-
var image = new Image();
|
|
520
|
-
|
|
521
|
-
image.onload = function() {
|
|
522
|
-
var h = image.height;
|
|
523
|
-
var w = image.width;
|
|
524
|
-
var canvas = createCanvas(w, h);
|
|
525
|
-
var ctx = canvas.getContext('2d');
|
|
526
|
-
ctx.drawImage(image, 0, 0, w, h);
|
|
527
|
-
callback(ctx.getImageData(0, 0, w, h));
|
|
528
|
-
};
|
|
529
|
-
|
|
530
|
-
image.src = url;
|
|
531
|
-
}
|
|
532
|
-
|
|
533
|
-
/**
|
|
534
|
-
* Injects a new canvas (and div wrapper) and creates the associated Chart instance
|
|
535
|
-
* using the given config. Additional options allow tweaking elements generation.
|
|
536
|
-
* @param {object} [config] - Chart config.
|
|
537
|
-
* @param {object} [options] - Chart acquisition options.
|
|
538
|
-
* @param {object} [options.canvas] - Canvas attributes.
|
|
539
|
-
* @param {object} [options.wrapper] - Canvas wrapper attributes.
|
|
540
|
-
* @param {boolean} [options.useOffscreenCanvas] - use an OffscreenCanvas instead of the normal HTMLCanvasElement.
|
|
541
|
-
* @param {boolean} [options.useShadowDOM] - use shadowDom
|
|
542
|
-
* @param {boolean} [options.persistent] - If true, the chart will not be released after the spec.
|
|
543
|
-
*/
|
|
544
|
-
function _acquireChart(config, options) {
|
|
545
|
-
var wrapper = document.createElement('div');
|
|
546
|
-
var canvas = document.createElement('canvas');
|
|
547
|
-
var chart, key;
|
|
548
|
-
|
|
549
|
-
config = config || {};
|
|
550
|
-
options = options || {};
|
|
551
|
-
options.canvas = options.canvas || {height: 512, width: 512};
|
|
552
|
-
options.wrapper = options.wrapper || {class: 'chartjs-wrapper'};
|
|
553
|
-
|
|
554
|
-
for (key in options.canvas) {
|
|
555
|
-
if (Object.prototype.hasOwnProperty.call(options.canvas, key)) {
|
|
556
|
-
canvas.setAttribute(key, options.canvas[key]);
|
|
557
|
-
}
|
|
558
|
-
}
|
|
559
|
-
|
|
560
|
-
for (key in options.wrapper) {
|
|
561
|
-
if (Object.prototype.hasOwnProperty.call(options.wrapper, key)) {
|
|
562
|
-
wrapper.setAttribute(key, options.wrapper[key]);
|
|
563
|
-
}
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
// by default, remove chart animation and auto resize
|
|
567
|
-
config.options = config.options || {};
|
|
568
|
-
config.options.animation = config.options.animation === undefined ? false : config.options.animation;
|
|
569
|
-
config.options.responsive = config.options.responsive === undefined ? false : config.options.responsive;
|
|
570
|
-
config.options.locale = config.options.locale || 'en-US';
|
|
571
|
-
|
|
572
|
-
if (options.useShadowDOM) {
|
|
573
|
-
if (!wrapper.attachShadow) {
|
|
574
|
-
// If shadowDOM is not supported by the browsers, mark test as 'pending'.
|
|
575
|
-
return pending();
|
|
576
|
-
}
|
|
577
|
-
wrapper.attachShadow({mode: 'open'}).appendChild(canvas);
|
|
578
|
-
} else {
|
|
579
|
-
wrapper.appendChild(canvas);
|
|
580
|
-
}
|
|
581
|
-
window.document.body.appendChild(wrapper);
|
|
582
|
-
|
|
583
|
-
try {
|
|
584
|
-
var ctx;
|
|
585
|
-
if (options.useOffscreenCanvas) {
|
|
586
|
-
if (!canvas.transferControlToOffscreen) {
|
|
587
|
-
// If this browser does not support offscreen canvas, mark the test as 'pending', which will skip the
|
|
588
|
-
// test.
|
|
589
|
-
// TODO: switch to skip() once it's implemented (https://github.com/jasmine/jasmine/issues/1709), or
|
|
590
|
-
// remove if all browsers implement `transferControlToOffscreen`
|
|
591
|
-
return pending();
|
|
592
|
-
}
|
|
593
|
-
var offscreenCanvas = canvas.transferControlToOffscreen();
|
|
594
|
-
ctx = offscreenCanvas.getContext('2d');
|
|
595
|
-
} else {
|
|
596
|
-
ctx = canvas.getContext('2d');
|
|
597
|
-
}
|
|
598
|
-
if (options.spriteText) {
|
|
599
|
-
spritingOn(ctx);
|
|
600
|
-
}
|
|
601
|
-
chart = new Chart(ctx, config);
|
|
602
|
-
} catch (e) {
|
|
603
|
-
window.document.body.removeChild(wrapper);
|
|
604
|
-
throw e;
|
|
605
|
-
}
|
|
606
|
-
|
|
607
|
-
chart.$test = {
|
|
608
|
-
persistent: options.persistent,
|
|
609
|
-
wrapper: wrapper
|
|
610
|
-
};
|
|
611
|
-
|
|
612
|
-
return chart;
|
|
613
|
-
}
|
|
614
|
-
|
|
615
|
-
function _releaseChart(chart) {
|
|
616
|
-
spritingOff(chart.ctx);
|
|
617
|
-
chart.destroy();
|
|
618
|
-
|
|
619
|
-
var wrapper = (chart.$test || {}).wrapper;
|
|
620
|
-
if (wrapper && wrapper.parentNode) {
|
|
621
|
-
wrapper.parentNode.removeChild(wrapper);
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
|
|
625
|
-
function injectCSS(css) {
|
|
626
|
-
// https://stackoverflow.com/q/3922139
|
|
627
|
-
var head = document.getElementsByTagName('head')[0];
|
|
628
|
-
var style = document.createElement('style');
|
|
629
|
-
style.setAttribute('type', 'text/css');
|
|
630
|
-
if (style.styleSheet) { // IE
|
|
631
|
-
style.styleSheet.cssText = css;
|
|
632
|
-
} else {
|
|
633
|
-
style.appendChild(document.createTextNode(css));
|
|
634
|
-
}
|
|
635
|
-
head.appendChild(style);
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
function waitForResize(chart, callback) {
|
|
639
|
-
var override = chart.resize;
|
|
640
|
-
chart.resize = function() {
|
|
641
|
-
chart.resize = override;
|
|
642
|
-
override.apply(this, arguments);
|
|
643
|
-
callback();
|
|
644
|
-
};
|
|
645
|
-
}
|
|
646
|
-
|
|
647
|
-
function afterEvent(chart, type, callback) {
|
|
648
|
-
var override = chart._eventHandler;
|
|
649
|
-
chart._eventHandler = function(event) {
|
|
650
|
-
override.call(this, event);
|
|
651
|
-
if (event.type === type || (event.native && event.native.type === type)) {
|
|
652
|
-
chart._eventHandler = override;
|
|
653
|
-
// eslint-disable-next-line callback-return
|
|
654
|
-
callback();
|
|
655
|
-
}
|
|
656
|
-
};
|
|
657
|
-
}
|
|
658
|
-
|
|
659
|
-
function _resolveElementPoint(el) {
|
|
660
|
-
var point = {x: 0, y: 0};
|
|
661
|
-
if (el) {
|
|
662
|
-
if (typeof el.getCenterPoint === 'function') {
|
|
663
|
-
point = el.getCenterPoint();
|
|
664
|
-
} else if (el.x !== undefined && el.y !== undefined) {
|
|
665
|
-
point = el;
|
|
666
|
-
}
|
|
667
|
-
}
|
|
668
|
-
return point;
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
async function triggerMouseEvent(chart, type, el) {
|
|
672
|
-
var node = chart.canvas;
|
|
673
|
-
var rect = node.getBoundingClientRect();
|
|
674
|
-
var point = _resolveElementPoint(el);
|
|
675
|
-
var event = new MouseEvent(type, {
|
|
676
|
-
clientX: rect.left + point.x,
|
|
677
|
-
clientY: rect.top + point.y,
|
|
678
|
-
cancelable: true,
|
|
679
|
-
bubbles: true,
|
|
680
|
-
view: window
|
|
681
|
-
});
|
|
682
|
-
|
|
683
|
-
var promise = new Promise((resolve) => {
|
|
684
|
-
afterEvent(chart, type, resolve);
|
|
685
|
-
});
|
|
686
|
-
|
|
687
|
-
node.dispatchEvent(event);
|
|
688
|
-
|
|
689
|
-
await promise;
|
|
690
|
-
|
|
691
|
-
return event;
|
|
692
|
-
}
|
|
693
|
-
|
|
694
|
-
function isObject(value) {
|
|
695
|
-
return Object.prototype.toString.call(value) === '[object Object]';
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
function isArray(value) {
|
|
699
|
-
return Object.prototype.toString.call(value) === '[object Array]';
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
function fmt(val) {
|
|
703
|
-
if (typeof val === 'string') {
|
|
704
|
-
return `"${val}"`;
|
|
705
|
-
}
|
|
706
|
-
if (isArray(val) || isObject(val)) {
|
|
707
|
-
return JSON.stringify(val);
|
|
708
|
-
}
|
|
709
|
-
return `${val}`;
|
|
710
|
-
}
|
|
711
|
-
|
|
712
|
-
function compareArray(actual, expected, path) {
|
|
713
|
-
let ret = true;
|
|
714
|
-
const diff = [];
|
|
715
|
-
|
|
716
|
-
if (!isArray(actual)) {
|
|
717
|
-
diff.push(`${path}: Expected ${fmt(actual)} to be an array`);
|
|
718
|
-
ret = false;
|
|
719
|
-
actual = {};
|
|
720
|
-
}
|
|
721
|
-
|
|
722
|
-
if (actual.length !== expected.length) {
|
|
723
|
-
diff.push(`${path}.length: Expected ${actual.length} to equal ${expected.length}`);
|
|
724
|
-
ret = false;
|
|
725
|
-
}
|
|
726
|
-
for (let i = 0; i < expected.length; i++) {
|
|
727
|
-
const act = actual[i];
|
|
728
|
-
const exp = expected[i];
|
|
729
|
-
const cmp = compareOption(act, exp, `${path}[${i}]`);
|
|
730
|
-
if (isObject(cmp)) {
|
|
731
|
-
if (!cmp.pass) {
|
|
732
|
-
diff.push(cmp.message);
|
|
733
|
-
ret = false;
|
|
734
|
-
}
|
|
735
|
-
} else if (!cmp) {
|
|
736
|
-
diff.push(`${path}[${i}]: Expected ${fmt(act)} to equal ${fmt(exp)}`);
|
|
737
|
-
ret = false;
|
|
738
|
-
}
|
|
739
|
-
}
|
|
740
|
-
return {
|
|
741
|
-
pass: ret,
|
|
742
|
-
message: diff.join('\n')
|
|
743
|
-
};
|
|
744
|
-
}
|
|
745
|
-
|
|
746
|
-
function compareObject(actual, expected, path = '') {
|
|
747
|
-
let ret = true;
|
|
748
|
-
const diff = [];
|
|
749
|
-
|
|
750
|
-
if (!isObject(actual)) {
|
|
751
|
-
diff.push(`${path}: Expected ${fmt(actual)} to be an object`);
|
|
752
|
-
ret = false;
|
|
753
|
-
actual = {};
|
|
754
|
-
}
|
|
755
|
-
|
|
756
|
-
if (path !== '') {
|
|
757
|
-
path = path + '.';
|
|
758
|
-
}
|
|
759
|
-
|
|
760
|
-
for (const key in expected) {
|
|
761
|
-
if (typeof key === 'string' && key.startsWith('_')) {
|
|
762
|
-
continue;
|
|
763
|
-
}
|
|
764
|
-
if (!Object.prototype.hasOwnProperty.call(expected, key)) {
|
|
765
|
-
continue;
|
|
766
|
-
}
|
|
767
|
-
const act = actual[key];
|
|
768
|
-
const exp = expected[key];
|
|
769
|
-
const cmp = compareOption(act, exp, `${path}${key}`);
|
|
770
|
-
if (isObject(cmp)) {
|
|
771
|
-
if (!cmp.pass) {
|
|
772
|
-
diff.push(cmp.message);
|
|
773
|
-
ret = false;
|
|
774
|
-
}
|
|
775
|
-
} else if (!cmp) {
|
|
776
|
-
diff.push(`${path}${key}: Expected ${fmt(act)} to equal ${fmt(exp)}`);
|
|
777
|
-
ret = false;
|
|
778
|
-
}
|
|
779
|
-
}
|
|
780
|
-
return {
|
|
781
|
-
pass: ret,
|
|
782
|
-
message: diff.join('\n')
|
|
783
|
-
};
|
|
784
|
-
}
|
|
785
|
-
|
|
786
|
-
function compareOption(actual, expected, path) {
|
|
787
|
-
let ret = true;
|
|
788
|
-
|
|
789
|
-
if (isObject(expected)) {
|
|
790
|
-
ret = compareObject(actual, expected, path);
|
|
791
|
-
} else if (isArray(expected)) {
|
|
792
|
-
ret = compareArray(actual, expected, path);
|
|
793
|
-
} else {
|
|
794
|
-
ret = actual === expected;
|
|
795
|
-
}
|
|
796
|
-
return ret;
|
|
797
|
-
}
|
|
798
|
-
|
|
799
|
-
function toEqualOptions() {
|
|
800
|
-
return {
|
|
801
|
-
compare(actual, expected) {
|
|
802
|
-
return compareObject(actual, expected);
|
|
803
|
-
}
|
|
804
|
-
};
|
|
805
|
-
}
|
|
806
|
-
|
|
807
|
-
function toPercent(value) {
|
|
808
|
-
return Math.round(value * 10000) / 100;
|
|
809
|
-
}
|
|
810
|
-
|
|
811
|
-
function createImageData(w, h) {
|
|
812
|
-
var canvas = createCanvas(w, h);
|
|
813
|
-
var context = canvas.getContext('2d');
|
|
814
|
-
return context.getImageData(0, 0, w, h);
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
function canvasFromImageData(data) {
|
|
818
|
-
var canvas = createCanvas(data.width, data.height);
|
|
819
|
-
var context = canvas.getContext('2d');
|
|
820
|
-
context.putImageData(data, 0, 0);
|
|
821
|
-
return canvas;
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
function buildPixelMatchPreview(actual, expected, diff, threshold, tolerance, count, description) {
|
|
825
|
-
var ratio = count / (actual.width * actual.height);
|
|
826
|
-
var wrapper = document.createElement('div');
|
|
827
|
-
wrapper.appendChild(document.createTextNode(description));
|
|
828
|
-
|
|
829
|
-
wrapper.style.cssText = 'display: flex; overflow-y: auto';
|
|
830
|
-
|
|
831
|
-
[
|
|
832
|
-
{data: actual, label: 'Actual'},
|
|
833
|
-
{data: expected, label: 'Expected'},
|
|
834
|
-
{data: diff, label:
|
|
835
|
-
'diff: ' + count + 'px ' +
|
|
836
|
-
'(' + toPercent(ratio) + '%)<br/>' +
|
|
837
|
-
'thr: ' + toPercent(threshold) + '%, ' +
|
|
838
|
-
'tol: ' + toPercent(tolerance) + '%'
|
|
839
|
-
}
|
|
840
|
-
].forEach(function(values) {
|
|
841
|
-
var item = document.createElement('div');
|
|
842
|
-
item.style.cssText = 'text-align: center; font: 12px monospace; line-height: 1.4; margin: 8px';
|
|
843
|
-
item.innerHTML = '<div style="margin: 8px; height: 32px">' + values.label + '</div>';
|
|
844
|
-
var canvas = canvasFromImageData(values.data);
|
|
845
|
-
canvas.style.cssText = 'border: 1px dashed red';
|
|
846
|
-
item.appendChild(canvas);
|
|
847
|
-
wrapper.appendChild(item);
|
|
848
|
-
});
|
|
849
|
-
|
|
850
|
-
wrapper.toString = () => `Fixture test failed:
|
|
851
|
-
Difference: ${count}px / ${toPercent(ratio)}%
|
|
852
|
-
Threshold: ${toPercent(threshold)}%
|
|
853
|
-
Tolerance: ${toPercent(tolerance)}%`;
|
|
854
|
-
|
|
855
|
-
return wrapper;
|
|
856
|
-
}
|
|
857
|
-
|
|
858
|
-
function toBeCloseToPixel() {
|
|
859
|
-
return {
|
|
860
|
-
compare: function(actual, expected) {
|
|
861
|
-
var result = false;
|
|
862
|
-
|
|
863
|
-
if (!isNaN(actual) && !isNaN(expected)) {
|
|
864
|
-
var diff = Math.abs(actual - expected);
|
|
865
|
-
var A = Math.abs(actual);
|
|
866
|
-
var B = Math.abs(expected);
|
|
867
|
-
var percentDiff = 0.005; // 0.5% diff
|
|
868
|
-
result = (diff <= (A > B ? A : B) * percentDiff) || diff < 2; // 2 pixels is fine
|
|
869
|
-
}
|
|
870
|
-
|
|
871
|
-
return {pass: result};
|
|
872
|
-
}
|
|
873
|
-
};
|
|
874
|
-
}
|
|
875
|
-
|
|
876
|
-
function toBeCloseToPoint() {
|
|
877
|
-
function rnd(v) {
|
|
878
|
-
return Math.round(v * 100) / 100;
|
|
879
|
-
}
|
|
880
|
-
return {
|
|
881
|
-
compare: function(actual, expected) {
|
|
882
|
-
return {
|
|
883
|
-
pass: rnd(actual.x) === rnd(expected.x) && rnd(actual.y) === rnd(expected.y)
|
|
884
|
-
};
|
|
885
|
-
}
|
|
886
|
-
};
|
|
887
|
-
}
|
|
888
|
-
|
|
889
|
-
function toEqualOneOf() {
|
|
890
|
-
return {
|
|
891
|
-
compare: function(actual, expecteds) {
|
|
892
|
-
var result = false;
|
|
893
|
-
for (var i = 0, l = expecteds.length; i < l; i++) {
|
|
894
|
-
if (actual === expecteds[i]) {
|
|
895
|
-
result = true;
|
|
896
|
-
break;
|
|
897
|
-
}
|
|
898
|
-
}
|
|
899
|
-
return {
|
|
900
|
-
pass: result
|
|
901
|
-
};
|
|
902
|
-
}
|
|
903
|
-
};
|
|
904
|
-
}
|
|
905
|
-
|
|
906
|
-
function toBeValidChart() {
|
|
907
|
-
return {
|
|
908
|
-
compare: function(actual) {
|
|
909
|
-
var message = null;
|
|
910
|
-
|
|
911
|
-
if (!(actual instanceof Chart)) {
|
|
912
|
-
message = 'Expected ' + actual + ' to be an instance of Chart';
|
|
913
|
-
} else if (Object.prototype.toString.call(actual.canvas) !== '[object HTMLCanvasElement]') {
|
|
914
|
-
message = 'Expected canvas to be an instance of HTMLCanvasElement';
|
|
915
|
-
} else if (Object.prototype.toString.call(actual.ctx) !== '[object CanvasRenderingContext2D]') {
|
|
916
|
-
message = 'Expected context to be an instance of CanvasRenderingContext2D';
|
|
917
|
-
} else if (typeof actual.height !== 'number' || !isFinite(actual.height)) {
|
|
918
|
-
message = 'Expected height to be a strict finite number';
|
|
919
|
-
} else if (typeof actual.width !== 'number' || !isFinite(actual.width)) {
|
|
920
|
-
message = 'Expected width to be a strict finite number';
|
|
921
|
-
}
|
|
922
|
-
|
|
923
|
-
return {
|
|
924
|
-
message: message ? message : 'Expected ' + actual + ' to be valid chart',
|
|
925
|
-
pass: !message
|
|
926
|
-
};
|
|
927
|
-
}
|
|
928
|
-
};
|
|
929
|
-
}
|
|
930
|
-
|
|
931
|
-
function toBeChartOfSize() {
|
|
932
|
-
return {
|
|
933
|
-
compare: function(actual, expected) {
|
|
934
|
-
var res = toBeValidChart().compare(actual);
|
|
935
|
-
if (!res.pass) {
|
|
936
|
-
return res;
|
|
937
|
-
}
|
|
938
|
-
|
|
939
|
-
var message = null;
|
|
940
|
-
var canvas = actual.ctx.canvas;
|
|
941
|
-
var style = getComputedStyle(canvas);
|
|
942
|
-
var pixelRatio = actual.options.devicePixelRatio || window.devicePixelRatio;
|
|
943
|
-
var dh = parseInt(style.height, 10) || 0;
|
|
944
|
-
var dw = parseInt(style.width, 10) || 0;
|
|
945
|
-
var rh = canvas.height;
|
|
946
|
-
var rw = canvas.width;
|
|
947
|
-
var orh = rh / pixelRatio;
|
|
948
|
-
var orw = rw / pixelRatio;
|
|
949
|
-
|
|
950
|
-
// sanity checks
|
|
951
|
-
if (actual.height !== orh) {
|
|
952
|
-
message = 'Expected chart height ' + actual.height + ' to be equal to original render height ' + orh;
|
|
953
|
-
} else if (actual.width !== orw) {
|
|
954
|
-
message = 'Expected chart width ' + actual.width + ' to be equal to original render width ' + orw;
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
// validity checks
|
|
958
|
-
if (dh !== expected.dh) {
|
|
959
|
-
message = 'Expected display height ' + dh + ' to be equal to ' + expected.dh;
|
|
960
|
-
} else if (dw !== expected.dw) {
|
|
961
|
-
message = 'Expected display width ' + dw + ' to be equal to ' + expected.dw;
|
|
962
|
-
} else if (rh !== expected.rh) {
|
|
963
|
-
message = 'Expected render height ' + rh + ' to be equal to ' + expected.rh;
|
|
964
|
-
} else if (rw !== expected.rw) {
|
|
965
|
-
message = 'Expected render width ' + rw + ' to be equal to ' + expected.rw;
|
|
966
|
-
}
|
|
967
|
-
|
|
968
|
-
return {
|
|
969
|
-
message: message ? message : 'Expected ' + actual + ' to be a chart of size ' + expected,
|
|
970
|
-
pass: !message
|
|
971
|
-
};
|
|
972
|
-
}
|
|
973
|
-
};
|
|
974
|
-
}
|
|
975
|
-
|
|
976
|
-
function toEqualImageData() {
|
|
977
|
-
return {
|
|
978
|
-
compare: function(actual, expected, opts) {
|
|
979
|
-
var message = null;
|
|
980
|
-
var debug = opts.debug || false;
|
|
981
|
-
var tolerance = opts.tolerance === undefined ? 0.001 : opts.tolerance;
|
|
982
|
-
var threshold = opts.threshold === undefined ? 0.1 : opts.threshold;
|
|
983
|
-
var ctx, idata, ddata, w, h, aw, ah, count, ratio;
|
|
984
|
-
|
|
985
|
-
if (actual instanceof Chart) {
|
|
986
|
-
ctx = actual.ctx;
|
|
987
|
-
} else if (actual instanceof HTMLCanvasElement) {
|
|
988
|
-
ctx = actual.getContext('2d');
|
|
989
|
-
} else if (actual instanceof CanvasRenderingContext2D) {
|
|
990
|
-
ctx = actual;
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
if (ctx) {
|
|
994
|
-
h = expected.height;
|
|
995
|
-
w = expected.width;
|
|
996
|
-
aw = ctx.canvas.width;
|
|
997
|
-
ah = ctx.canvas.height;
|
|
998
|
-
idata = ctx.getImageData(0, 0, aw, ah);
|
|
999
|
-
ddata = createImageData(w, h);
|
|
1000
|
-
if (aw === w && ah === h) {
|
|
1001
|
-
count = pixelmatch_1(idata.data, expected.data, ddata.data, w, h, {threshold: threshold});
|
|
1002
|
-
} else {
|
|
1003
|
-
count = Math.abs(aw * ah - w * h);
|
|
1004
|
-
}
|
|
1005
|
-
ratio = count / (w * h);
|
|
1006
|
-
|
|
1007
|
-
if ((ratio > tolerance) || debug) {
|
|
1008
|
-
message = buildPixelMatchPreview(idata, expected, ddata, threshold, tolerance, count, opts.description);
|
|
1009
|
-
}
|
|
1010
|
-
} else {
|
|
1011
|
-
message = 'Input value is not a valid image source.';
|
|
1012
|
-
}
|
|
1013
|
-
|
|
1014
|
-
return {
|
|
1015
|
-
message: message,
|
|
1016
|
-
pass: !message
|
|
1017
|
-
};
|
|
1018
|
-
}
|
|
1019
|
-
};
|
|
1020
|
-
}
|
|
1021
|
-
|
|
1022
|
-
var matchers = {
|
|
1023
|
-
toBeCloseToPixel,
|
|
1024
|
-
toBeCloseToPoint,
|
|
1025
|
-
toEqualOneOf,
|
|
1026
|
-
toBeValidChart,
|
|
1027
|
-
toBeChartOfSize,
|
|
1028
|
-
toEqualImageData,
|
|
1029
|
-
toEqualOptions
|
|
1030
|
-
};
|
|
1031
|
-
|
|
1032
|
-
function readFile(url, callback) {
|
|
1033
|
-
var request = new XMLHttpRequest();
|
|
1034
|
-
request.onreadystatechange = function() {
|
|
1035
|
-
if (request.readyState === 4) {
|
|
1036
|
-
return callback(request.responseText);
|
|
1037
|
-
}
|
|
1038
|
-
};
|
|
1039
|
-
|
|
1040
|
-
request.open('GET', url, false);
|
|
1041
|
-
request.send(null);
|
|
1042
|
-
}
|
|
1043
|
-
|
|
1044
|
-
function loadConfig(url, callback) {
|
|
1045
|
-
var regex = /\.(json|js)$/i;
|
|
1046
|
-
var matches = url.match(regex);
|
|
1047
|
-
var type = matches ? matches[1] : 'json';
|
|
1048
|
-
var cfg = null;
|
|
1049
|
-
|
|
1050
|
-
readFile(url, function(content) {
|
|
1051
|
-
switch (type) {
|
|
1052
|
-
case 'js':
|
|
1053
|
-
cfg = new Function('"use strict"; var module = {};' + content + '; return module.exports || fixture;')();
|
|
1054
|
-
break;
|
|
1055
|
-
case 'json':
|
|
1056
|
-
cfg = JSON.parse(content);
|
|
1057
|
-
break;
|
|
1058
|
-
}
|
|
1059
|
-
|
|
1060
|
-
callback(cfg);
|
|
1061
|
-
});
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
function specFromFixture(description, inputs) {
|
|
1065
|
-
var input = inputs.js || inputs.json;
|
|
1066
|
-
it(input, function(done) {
|
|
1067
|
-
loadConfig(input, function(json) {
|
|
1068
|
-
var descr = json.description || (json.description = description);
|
|
1069
|
-
|
|
1070
|
-
var config = json.config;
|
|
1071
|
-
var options = config.options || (config.options = {});
|
|
1072
|
-
|
|
1073
|
-
// plugins are disabled by default, except if the path contains 'plugin' or there are instance plugins
|
|
1074
|
-
if (input.indexOf('plugin') === -1 && config.plugins === undefined) {
|
|
1075
|
-
options.plugins = options.plugins || false;
|
|
1076
|
-
}
|
|
1077
|
-
|
|
1078
|
-
var chart = _acquireChart(config, json.options);
|
|
1079
|
-
const _done = () => {
|
|
1080
|
-
if (!inputs.png) {
|
|
1081
|
-
fail(descr + '\r\nMissing PNG comparison file for ' + input);
|
|
1082
|
-
done();
|
|
1083
|
-
}
|
|
1084
|
-
|
|
1085
|
-
readImageData(inputs.png, function(expected) {
|
|
1086
|
-
expect(chart).toEqualImageData(expected, json);
|
|
1087
|
-
_releaseChart(chart);
|
|
1088
|
-
done();
|
|
1089
|
-
});
|
|
1090
|
-
};
|
|
1091
|
-
const run = json.options && json.options.run;
|
|
1092
|
-
if (typeof run === 'function') {
|
|
1093
|
-
Promise.resolve(run(chart)).finally(_done);
|
|
1094
|
-
} else {
|
|
1095
|
-
_done();
|
|
1096
|
-
}
|
|
1097
|
-
});
|
|
1098
|
-
});
|
|
1099
|
-
}
|
|
1100
|
-
|
|
1101
|
-
function specsFromFixtures(path) {
|
|
1102
|
-
var regex = new RegExp('(^/base/test/fixtures/' + path + '.+)\\.(png|json|js)');
|
|
1103
|
-
var inputs = {};
|
|
1104
|
-
|
|
1105
|
-
Object.keys(__karma__.files || {}).forEach(function(file) {
|
|
1106
|
-
var matches = file.match(regex);
|
|
1107
|
-
var name = matches && matches[1];
|
|
1108
|
-
var type = matches && matches[2];
|
|
1109
|
-
|
|
1110
|
-
if (name && type) {
|
|
1111
|
-
inputs[name] = inputs[name] || {};
|
|
1112
|
-
inputs[name][type] = file;
|
|
1113
|
-
}
|
|
1114
|
-
});
|
|
1115
|
-
|
|
1116
|
-
return function() {
|
|
1117
|
-
Object.keys(inputs).forEach(function(key) {
|
|
1118
|
-
specFromFixture(key, inputs[key]);
|
|
1119
|
-
});
|
|
1120
|
-
};
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
// Keep track of all acquired charts to automatically release them after each specs
|
|
1124
|
-
var charts = {};
|
|
1125
|
-
|
|
1126
|
-
/**
|
|
1127
|
-
* Injects a new canvas (and div wrapper) and creates the associated Chart instance
|
|
1128
|
-
* using the given config. Additional options allow tweaking elements generation.
|
|
1129
|
-
* @param {object} [config] - Chart config.
|
|
1130
|
-
* @param {object} [options] - Chart acquisition options.
|
|
1131
|
-
* @param {object} [options.canvas] - Canvas attributes.
|
|
1132
|
-
* @param {object} [options.wrapper] - Canvas wrapper attributes.
|
|
1133
|
-
* @param {boolean} [options.useOffscreenCanvas] - use an OffscreenCanvas instead of the normal HTMLCanvasElement.
|
|
1134
|
-
* @param {boolean} [options.useShadowDOM] - use shadowDom
|
|
1135
|
-
* @param {boolean} [options.persistent] - If true, the chart will not be released after the spec.
|
|
1136
|
-
*/
|
|
1137
|
-
function acquireChart(config, options) {
|
|
1138
|
-
var chart = _acquireChart(config, options);
|
|
1139
|
-
charts[chart.id] = chart;
|
|
1140
|
-
return chart;
|
|
1141
|
-
}
|
|
1142
|
-
|
|
1143
|
-
function releaseChart(chart) {
|
|
1144
|
-
_releaseChart(chart);
|
|
1145
|
-
delete charts[chart.id];
|
|
1146
|
-
}
|
|
1147
|
-
|
|
1148
|
-
function createMockContext() {
|
|
1149
|
-
return new Context();
|
|
1150
|
-
}
|
|
1151
|
-
|
|
1152
|
-
function injectWrapperCSS() {
|
|
1153
|
-
// some style initialization to limit differences between browsers across different platforms.
|
|
1154
|
-
injectCSS(
|
|
1155
|
-
'.chartjs-wrapper, .chartjs-wrapper canvas {' +
|
|
1156
|
-
'border: 0;' +
|
|
1157
|
-
'margin: 0;' +
|
|
1158
|
-
'padding: 0;' +
|
|
1159
|
-
'}' +
|
|
1160
|
-
'.chartjs-wrapper {' +
|
|
1161
|
-
'position: absolute' +
|
|
1162
|
-
'}');
|
|
1163
|
-
}
|
|
1164
|
-
|
|
1165
|
-
function addMatchers() {
|
|
1166
|
-
jasmine.addMatchers(matchers);
|
|
1167
|
-
}
|
|
1168
|
-
|
|
1169
|
-
function releaseCharts() {
|
|
1170
|
-
Object.keys(charts).forEach(function(id) {
|
|
1171
|
-
var chart = charts[id];
|
|
1172
|
-
if (!(chart.$test || {}).persistent) {
|
|
1173
|
-
_releaseChart(chart);
|
|
1174
|
-
}
|
|
1175
|
-
});
|
|
1176
|
-
}
|
|
1177
|
-
|
|
1178
|
-
export { acquireChart, addMatchers, afterEvent, createMockContext, injectWrapperCSS, releaseChart, releaseCharts, specsFromFixtures, triggerMouseEvent, waitForResize };
|