@luma.gl/test-utils 9.0.0-alpha.15 → 9.0.0-alpha.17
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/dist/check-type.js +0 -1
- package/dist/check-type.js.map +1 -1
- package/dist/create-test-device.d.ts.map +1 -1
- package/dist/create-test-device.js +6 -10
- package/dist/create-test-device.js.map +1 -1
- package/dist/index.cjs +404 -0
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/performance-test-runner.js +1 -14
- package/dist/performance-test-runner.js.map +1 -1
- package/dist/register-devices.js.map +1 -1
- package/dist/snapshot-test-runner.d.ts.map +1 -1
- package/dist/snapshot-test-runner.js +5 -18
- package/dist/snapshot-test-runner.js.map +1 -1
- package/dist/test-runner.d.ts +3 -3
- package/dist/test-runner.d.ts.map +1 -1
- package/dist/test-runner.js +21 -57
- package/dist/test-runner.js.map +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +13 -5
- package/src/check-type.ts +1 -1
- package/src/create-test-device.ts +3 -2
- package/src/snapshot-test-runner.ts +1 -2
- package/src/test-runner.ts +5 -5
package/dist/check-type.js
CHANGED
package/dist/check-type.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"check-type.js","names":["checkType","value"],"sources":["../src/check-type.ts"],"sourcesContent":["\n/**\n * Tests that an argument matches the type.\n * @note fails during typescript type check, not during runtime.\n */\nexport function checkType<T>(value: T): void {}\n"],"mappings":"AAKA,OAAO,SAASA,SAASA,CAAIC,KAAQ,EAAQ,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-test-device.d.ts","sourceRoot":"","sources":["../src/create-test-device.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAQ7C,kCAAkC;AAClC,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAAG,qBAAqB,GAAG,IAAI,CAG9F;AAED,gCAAgC;AAChC,wBAAgB,gBAAgB,CAAC,KAAK,GAAE,WAAgB,GAAG,WAAW,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"create-test-device.d.ts","sourceRoot":"","sources":["../src/create-test-device.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAC,MAAM,EAAE,WAAW,EAAC,MAAM,cAAc,CAAC;AAEtD,OAAO,EAAC,WAAW,EAAC,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAQ7C,kCAAkC;AAClC,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAAG,qBAAqB,GAAG,IAAI,CAG9F;AAED,gCAAgC;AAChC,wBAAgB,gBAAgB,CAAC,KAAK,GAAE,WAAgB,GAAG,WAAW,GAAG,IAAI,CAU5E;AAED,4CAA4C;AAC5C,eAAO,MAAM,YAAY,EAAE,WAAuF,CAAE;AACpH,yDAAyD;AACzD,eAAO,MAAM,YAAY,EAAE,WAAuF,CAAE;AACpH,wEAAwE;AACxE,eAAO,MAAM,WAAW,EAAE,WAA0C,CAAC;AAErE,0DAA0D;AAC1D,eAAO,IAAI,YAAY,EAAE,YAAY,CAAC;AAItC,yDAAyD;AACzD,wBAAgB,mBAAmB,IAAI,WAAW,EAAE,CASnD;AAED,0CAA0C;AAC1C,wBAAsB,cAAc,IAAK,OAAO,CAAC,MAAM,EAAE,CAAC,CAezD"}
|
|
@@ -5,13 +5,16 @@ const CONTEXT_DEFAULTS = {
|
|
|
5
5
|
height: 1,
|
|
6
6
|
debug: true
|
|
7
7
|
};
|
|
8
|
-
export function createTestContext(
|
|
8
|
+
export function createTestContext() {
|
|
9
|
+
let opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
9
10
|
const device = createTestDevice(opts);
|
|
10
11
|
return device && device.gl;
|
|
11
12
|
}
|
|
12
|
-
export function createTestDevice(
|
|
13
|
+
export function createTestDevice() {
|
|
14
|
+
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
13
15
|
try {
|
|
14
|
-
props = {
|
|
16
|
+
props = {
|
|
17
|
+
...CONTEXT_DEFAULTS,
|
|
15
18
|
...props,
|
|
16
19
|
debug: true
|
|
17
20
|
};
|
|
@@ -36,21 +39,17 @@ export let webgpuDevice;
|
|
|
36
39
|
let webgpuCreated = false;
|
|
37
40
|
export function getWebGLTestDevices() {
|
|
38
41
|
const devices = [];
|
|
39
|
-
|
|
40
42
|
if (webgl2Device) {
|
|
41
43
|
devices.push(webgl2Device);
|
|
42
44
|
}
|
|
43
|
-
|
|
44
45
|
if (webgl1Device) {
|
|
45
46
|
devices.push(webgl1Device);
|
|
46
47
|
}
|
|
47
|
-
|
|
48
48
|
return devices;
|
|
49
49
|
}
|
|
50
50
|
export async function getTestDevices() {
|
|
51
51
|
if (!webgpuCreated) {
|
|
52
52
|
webgpuCreated = true;
|
|
53
|
-
|
|
54
53
|
try {
|
|
55
54
|
webgpuDevice = await luma.createDevice({
|
|
56
55
|
id: 'webgpu-test-device',
|
|
@@ -58,13 +57,10 @@ export async function getTestDevices() {
|
|
|
58
57
|
});
|
|
59
58
|
} catch {}
|
|
60
59
|
}
|
|
61
|
-
|
|
62
60
|
const devices = getWebGLTestDevices();
|
|
63
|
-
|
|
64
61
|
if (webgpuDevice) {
|
|
65
62
|
devices.unshift(webgpuDevice);
|
|
66
63
|
}
|
|
67
|
-
|
|
68
64
|
return devices;
|
|
69
65
|
}
|
|
70
66
|
//# sourceMappingURL=create-test-device.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"create-test-device.js","names":["luma","WebGLDevice","CONTEXT_DEFAULTS","width","height","debug","createTestContext","opts","arguments","length","undefined","device","createTestDevice","gl","props","error","console","concat","id","message","webgl1Device","webgl1","webgl2","webgl2Device","webglDevice","webgpuDevice","webgpuCreated","getWebGLTestDevices","devices","push","getTestDevices","createDevice","type","unshift"],"sources":["../src/create-test-device.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport type {Device, DeviceProps} from '@luma.gl/api';\nimport {luma} from '@luma.gl/api';\nimport {WebGLDevice} from '@luma.gl/webgl';\nimport {WebGPUDevice} from '@luma.gl/webgpu';\n\nconst CONTEXT_DEFAULTS: Partial<DeviceProps> = {\n width: 1,\n height: 1,\n debug: true\n};\n\n/** Create a test WebGL context */\nexport function createTestContext(opts: Record<string, any> = {}): WebGLRenderingContext | null {\n const device = createTestDevice(opts);\n return device && device.gl;\n}\n\n/** Create a test WebGLDevice */\nexport function createTestDevice(props: DeviceProps = {}): WebGLDevice | null {\n try {\n props = {...CONTEXT_DEFAULTS, ...props, debug: true};\n // We dont use luma.createDevice since this tests current expect this context to be created synchronously\n return new WebGLDevice(props);\n } catch (error) {\n // eslint-disable-next-line no-console\n console.error(`Failed to created device '${props.id}': ${(error as Error).message}`);\n return null;\n }\n}\n\n/** A WebGL 1 Device intended for testing */\nexport const webgl1Device: WebGLDevice = createTestDevice({id: 'webgl1-test-device', webgl1: true, webgl2: false}) ;\n/** A WebGL 2 Device intended for testing. Can be null */\nexport const webgl2Device: WebGLDevice = createTestDevice({id: 'webgl2-test-device', webgl1: false, webgl2: true}) ;\n/** A WebGL 2 or WebGL 1 Device intended for testing. Best available. */\nexport const webglDevice: WebGLDevice = webgl2Device || webgl1Device;\n\n/** Only available after getTestDevices() has completed */\nexport let webgpuDevice: WebGPUDevice;\n\nlet webgpuCreated = false;\n\n/** Synchronously get test devices (only WebGLDevices) */\nexport function getWebGLTestDevices(): WebGLDevice[] {\n const devices: WebGLDevice[] = [];\n if (webgl2Device) {\n devices.push(webgl2Device);\n }\n if (webgl1Device) {\n devices.push(webgl1Device);\n }\n return devices;\n}\n\n/** Includes WebGPU device if available */\nexport async function getTestDevices() : Promise<Device[]> {\n if (!webgpuCreated) {\n webgpuCreated = true;\n try {\n webgpuDevice = await luma.createDevice({id: 'webgpu-test-device', type: 'webgpu'}) as WebGPUDevice;\n } catch {\n // ignore (assume WebGPU was not available)\n }\n }\n\n const devices: Device[] = getWebGLTestDevices();\n if (webgpuDevice) {\n devices.unshift(webgpuDevice);\n }\n return devices;\n}\n"],"mappings":"AAGA,SAAQA,IAAI,QAAO,cAAc;AACjC,SAAQC,WAAW,QAAO,gBAAgB;AAG1C,MAAMC,gBAAsC,GAAG;EAC7CC,KAAK,EAAE,CAAC;EACRC,MAAM,EAAE,CAAC;EACTC,KAAK,EAAE;AACT,CAAC;AAGD,OAAO,SAASC,iBAAiBA,CAAA,EAA+D;EAAA,IAA9DC,IAAyB,GAAAC,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EAC9D,MAAMG,MAAM,GAAGC,gBAAgB,CAACL,IAAI,CAAC;EACrC,OAAOI,MAAM,IAAIA,MAAM,CAACE,EAAE;AAC5B;AAGA,OAAO,SAASD,gBAAgBA,CAAA,EAA8C;EAAA,IAA7CE,KAAkB,GAAAN,SAAA,CAAAC,MAAA,QAAAD,SAAA,QAAAE,SAAA,GAAAF,SAAA,MAAG,CAAC,CAAC;EACtD,IAAI;IACFM,KAAK,GAAG;MAAC,GAAGZ,gBAAgB;MAAE,GAAGY,KAAK;MAAET,KAAK,EAAE;IAAI,CAAC;IAEpD,OAAO,IAAIJ,WAAW,CAACa,KAAK,CAAC;EAC/B,CAAC,CAAC,OAAOC,KAAK,EAAE;IAEdC,OAAO,CAACD,KAAK,8BAAAE,MAAA,CAA8BH,KAAK,CAACI,EAAE,SAAAD,MAAA,CAAOF,KAAK,CAAWI,OAAO,EAAG;IACpF,OAAO,IAAI;EACb;AACF;AAGA,OAAO,MAAMC,YAAyB,GAAGR,gBAAgB,CAAC;EAACM,EAAE,EAAE,oBAAoB;EAAEG,MAAM,EAAE,IAAI;EAAEC,MAAM,EAAE;AAAK,CAAC,CAAC;AAElH,OAAO,MAAMC,YAAyB,GAAGX,gBAAgB,CAAC;EAACM,EAAE,EAAE,oBAAoB;EAAEG,MAAM,EAAE,KAAK;EAAEC,MAAM,EAAE;AAAI,CAAC,CAAC;AAElH,OAAO,MAAME,WAAwB,GAAGD,YAAY,IAAIH,YAAY;AAGpE,OAAO,IAAIK,YAA0B;AAErC,IAAIC,aAAa,GAAG,KAAK;AAGzB,OAAO,SAASC,mBAAmBA,CAAA,EAAkB;EACnD,MAAMC,OAAsB,GAAG,EAAE;EACjC,IAAIL,YAAY,EAAE;IAChBK,OAAO,CAACC,IAAI,CAACN,YAAY,CAAC;EAC5B;EACA,IAAIH,YAAY,EAAE;IAChBQ,OAAO,CAACC,IAAI,CAACT,YAAY,CAAC;EAC5B;EACA,OAAOQ,OAAO;AAChB;AAGA,OAAO,eAAeE,cAAcA,CAAA,EAAuB;EACzD,IAAI,CAACJ,aAAa,EAAE;IAClBA,aAAa,GAAG,IAAI;IACpB,IAAI;MACFD,YAAY,GAAG,MAAMzB,IAAI,CAAC+B,YAAY,CAAC;QAACb,EAAE,EAAE,oBAAoB;QAAEc,IAAI,EAAE;MAAQ,CAAC,CAAiB;IACpG,CAAC,CAAC,MAAM,CAER;EACF;EAEA,MAAMJ,OAAiB,GAAGD,mBAAmB,EAAE;EAC/C,IAAIF,YAAY,EAAE;IAChBG,OAAO,CAACK,OAAO,CAACR,YAAY,CAAC;EAC/B;EACA,OAAOG,OAAO;AAChB"}
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,404 @@
|
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
8
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
9
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
10
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
11
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
12
|
+
var __spreadValues = (a, b) => {
|
|
13
|
+
for (var prop in b || (b = {}))
|
|
14
|
+
if (__hasOwnProp.call(b, prop))
|
|
15
|
+
__defNormalProp(a, prop, b[prop]);
|
|
16
|
+
if (__getOwnPropSymbols)
|
|
17
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
18
|
+
if (__propIsEnum.call(b, prop))
|
|
19
|
+
__defNormalProp(a, prop, b[prop]);
|
|
20
|
+
}
|
|
21
|
+
return a;
|
|
22
|
+
};
|
|
23
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
24
|
+
var __export = (target, all) => {
|
|
25
|
+
for (var name in all)
|
|
26
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
27
|
+
};
|
|
28
|
+
var __copyProps = (to, from, except, desc) => {
|
|
29
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
30
|
+
for (let key of __getOwnPropNames(from))
|
|
31
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
32
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
33
|
+
}
|
|
34
|
+
return to;
|
|
35
|
+
};
|
|
36
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
37
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
38
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
39
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
40
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
41
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
42
|
+
mod
|
|
43
|
+
));
|
|
44
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
45
|
+
var __async = (__this, __arguments, generator) => {
|
|
46
|
+
return new Promise((resolve, reject) => {
|
|
47
|
+
var fulfilled = (value) => {
|
|
48
|
+
try {
|
|
49
|
+
step(generator.next(value));
|
|
50
|
+
} catch (e) {
|
|
51
|
+
reject(e);
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
var rejected = (value) => {
|
|
55
|
+
try {
|
|
56
|
+
step(generator.throw(value));
|
|
57
|
+
} catch (e) {
|
|
58
|
+
reject(e);
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
62
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
63
|
+
});
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
// src/index.ts
|
|
67
|
+
var src_exports = {};
|
|
68
|
+
__export(src_exports, {
|
|
69
|
+
PerformanceTestRunner: () => PerformanceTestRunner,
|
|
70
|
+
SnapshotTestRunner: () => SnapshotTestRunner,
|
|
71
|
+
checkType: () => checkType,
|
|
72
|
+
createTestContext: () => createTestContext,
|
|
73
|
+
createTestDevice: () => createTestDevice,
|
|
74
|
+
getTestDevices: () => getTestDevices,
|
|
75
|
+
getWebGLTestDevices: () => getWebGLTestDevices,
|
|
76
|
+
webgl1Device: () => webgl1Device,
|
|
77
|
+
webgl2Device: () => webgl2Device,
|
|
78
|
+
webgpuDevice: () => webgpuDevice
|
|
79
|
+
});
|
|
80
|
+
module.exports = __toCommonJS(src_exports);
|
|
81
|
+
|
|
82
|
+
// src/register-devices.ts
|
|
83
|
+
var import_api = require("@luma.gl/api");
|
|
84
|
+
var import_webgl = require("@luma.gl/webgl");
|
|
85
|
+
var import_webgpu = require("@luma.gl/webgpu");
|
|
86
|
+
var import_gl = __toESM(require("gl"), 1);
|
|
87
|
+
(0, import_webgl.registerHeadlessGL)(import_gl.default);
|
|
88
|
+
import_api.luma.registerDevices([import_webgl.WebGLDevice, import_webgpu.WebGPUDevice]);
|
|
89
|
+
|
|
90
|
+
// src/test-runner.ts
|
|
91
|
+
var import_webgl_legacy = require("@luma.gl/webgl-legacy");
|
|
92
|
+
|
|
93
|
+
// src/create-test-device.ts
|
|
94
|
+
var import_api2 = require("@luma.gl/api");
|
|
95
|
+
var import_webgl2 = require("@luma.gl/webgl");
|
|
96
|
+
var CONTEXT_DEFAULTS = {
|
|
97
|
+
width: 1,
|
|
98
|
+
height: 1,
|
|
99
|
+
debug: true
|
|
100
|
+
};
|
|
101
|
+
function createTestContext(opts = {}) {
|
|
102
|
+
const device = createTestDevice(opts);
|
|
103
|
+
return device && device.gl;
|
|
104
|
+
}
|
|
105
|
+
function createTestDevice(props = {}) {
|
|
106
|
+
try {
|
|
107
|
+
props = __spreadProps(__spreadValues(__spreadValues({}, CONTEXT_DEFAULTS), props), { debug: true });
|
|
108
|
+
return new import_webgl2.WebGLDevice(props);
|
|
109
|
+
} catch (error) {
|
|
110
|
+
console.error(`Failed to created device '${props.id}': ${error.message}`);
|
|
111
|
+
return null;
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
var webgl1Device = createTestDevice({ id: "webgl1-test-device", webgl1: true, webgl2: false });
|
|
115
|
+
var webgl2Device = createTestDevice({ id: "webgl2-test-device", webgl1: false, webgl2: true });
|
|
116
|
+
var webglDevice = webgl2Device || webgl1Device;
|
|
117
|
+
var webgpuDevice;
|
|
118
|
+
var webgpuCreated = false;
|
|
119
|
+
function getWebGLTestDevices() {
|
|
120
|
+
const devices = [];
|
|
121
|
+
if (webgl2Device) {
|
|
122
|
+
devices.push(webgl2Device);
|
|
123
|
+
}
|
|
124
|
+
if (webgl1Device) {
|
|
125
|
+
devices.push(webgl1Device);
|
|
126
|
+
}
|
|
127
|
+
return devices;
|
|
128
|
+
}
|
|
129
|
+
function getTestDevices() {
|
|
130
|
+
return __async(this, null, function* () {
|
|
131
|
+
if (!webgpuCreated) {
|
|
132
|
+
webgpuCreated = true;
|
|
133
|
+
try {
|
|
134
|
+
webgpuDevice = yield import_api2.luma.createDevice({ id: "webgpu-test-device", type: "webgpu" });
|
|
135
|
+
} catch (e) {
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
const devices = getWebGLTestDevices();
|
|
139
|
+
if (webgpuDevice) {
|
|
140
|
+
devices.unshift(webgpuDevice);
|
|
141
|
+
}
|
|
142
|
+
return devices;
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
// src/test-runner.ts
|
|
147
|
+
function noop() {
|
|
148
|
+
}
|
|
149
|
+
var DEFAULT_TEST_CASE = {
|
|
150
|
+
name: "Unnamed test",
|
|
151
|
+
onInitialize: noop,
|
|
152
|
+
onRender: ({ done }) => done(),
|
|
153
|
+
onFinalize: noop
|
|
154
|
+
};
|
|
155
|
+
var DEFAULT_TEST_PROPS = {
|
|
156
|
+
// test lifecycle callback
|
|
157
|
+
onTestStart: (testCase) => console.log(`# ${testCase.name}`),
|
|
158
|
+
onTestPass: (testCase) => console.log(`ok ${testCase.name} passed`),
|
|
159
|
+
onTestFail: (testCase) => console.log(`not ok ${testCase.name} failed`),
|
|
160
|
+
// milliseconds to wait for each test case before aborting
|
|
161
|
+
timeout: 2e3
|
|
162
|
+
};
|
|
163
|
+
var TestRunner = class {
|
|
164
|
+
/**
|
|
165
|
+
* props
|
|
166
|
+
* AnimationLoop props
|
|
167
|
+
*/
|
|
168
|
+
constructor(props = {}) {
|
|
169
|
+
this.device = webglDevice;
|
|
170
|
+
this.isRunning = false;
|
|
171
|
+
this.testOptions = __spreadValues({}, DEFAULT_TEST_PROPS);
|
|
172
|
+
this._animationProps = {};
|
|
173
|
+
this._testCases = [];
|
|
174
|
+
this._testCaseData = null;
|
|
175
|
+
// @ts-expect-error
|
|
176
|
+
this.isHeadless = Boolean(window.browserTestDriver_isHeadless);
|
|
177
|
+
this.props = props;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Add testCase(s)
|
|
181
|
+
*/
|
|
182
|
+
add(testCases) {
|
|
183
|
+
if (!Array.isArray(testCases)) {
|
|
184
|
+
testCases = [testCases];
|
|
185
|
+
}
|
|
186
|
+
for (const testCase of testCases) {
|
|
187
|
+
this._testCases.push(testCase);
|
|
188
|
+
}
|
|
189
|
+
return this;
|
|
190
|
+
}
|
|
191
|
+
/**
|
|
192
|
+
* Returns a promise that resolves when all the test cases are done
|
|
193
|
+
*/
|
|
194
|
+
run(options = {}) {
|
|
195
|
+
this.testOptions = __spreadValues(__spreadValues({}, this.testOptions), options);
|
|
196
|
+
return new Promise((resolve, reject) => {
|
|
197
|
+
this._animationLoop = new import_webgl_legacy.AnimationLoop(__spreadProps(__spreadValues({}, this.props), {
|
|
198
|
+
device: this.device,
|
|
199
|
+
onRender: this._onRender.bind(this),
|
|
200
|
+
onFinalize: () => {
|
|
201
|
+
this.isRunning = false;
|
|
202
|
+
resolve();
|
|
203
|
+
}
|
|
204
|
+
}));
|
|
205
|
+
this._animationLoop.start(this.props);
|
|
206
|
+
this.isRunning = true;
|
|
207
|
+
this.isDiffing = false;
|
|
208
|
+
this._currentTestCase = null;
|
|
209
|
+
}).catch((error) => {
|
|
210
|
+
this._fail({ error: error.message });
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
/* Lifecycle methods for subclassing */
|
|
214
|
+
initTestCase(testCase) {
|
|
215
|
+
const { animationLoop } = testCase;
|
|
216
|
+
if (animationLoop) {
|
|
217
|
+
testCase.onInitialize = animationLoop.props.onInitialize.bind(animationLoop);
|
|
218
|
+
testCase.onRender = animationLoop.props.onRender.bind(animationLoop);
|
|
219
|
+
testCase.onFinalize = animationLoop.props.onFinalize.bind(animationLoop);
|
|
220
|
+
}
|
|
221
|
+
for (const key in DEFAULT_TEST_CASE) {
|
|
222
|
+
testCase[key] = testCase[key] || DEFAULT_TEST_CASE[key];
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
shouldRender(animationProps) {
|
|
226
|
+
return true;
|
|
227
|
+
}
|
|
228
|
+
assert(testCase) {
|
|
229
|
+
this._pass(testCase);
|
|
230
|
+
this._next();
|
|
231
|
+
}
|
|
232
|
+
/* Utilities */
|
|
233
|
+
_pass(result) {
|
|
234
|
+
this.testOptions.onTestPass(this._currentTestCase, result);
|
|
235
|
+
}
|
|
236
|
+
_fail(result) {
|
|
237
|
+
this.testOptions.onTestFail(this._currentTestCase, result);
|
|
238
|
+
}
|
|
239
|
+
_next() {
|
|
240
|
+
this._nextTestCase();
|
|
241
|
+
}
|
|
242
|
+
/* Private methods */
|
|
243
|
+
_onRender(animationProps) {
|
|
244
|
+
this._animationProps = animationProps;
|
|
245
|
+
const testCase = this._currentTestCase || this._nextTestCase();
|
|
246
|
+
if (!testCase) {
|
|
247
|
+
this._animationLoop.stop();
|
|
248
|
+
return;
|
|
249
|
+
}
|
|
250
|
+
let isDone = false;
|
|
251
|
+
const testCaseAnimationProps = __spreadProps(__spreadValues(__spreadValues({}, animationProps), this._testCaseData), {
|
|
252
|
+
// tick/time starts from 0 for each test case
|
|
253
|
+
startTime: this._currentTestCaseStartTime,
|
|
254
|
+
time: animationProps.time - this._currentTestCaseStartTime,
|
|
255
|
+
tick: animationProps.tick - this._currentTestCaseStartTick,
|
|
256
|
+
// called by the test case when it is done rendering and ready for capture and diff
|
|
257
|
+
done: () => {
|
|
258
|
+
isDone = true;
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
if (this._testCaseData && this.shouldRender(testCaseAnimationProps)) {
|
|
262
|
+
testCase.onRender(testCaseAnimationProps);
|
|
263
|
+
}
|
|
264
|
+
const timeout = testCase.timeout || this.testOptions.timeout;
|
|
265
|
+
if (timeout && testCaseAnimationProps.time > timeout) {
|
|
266
|
+
isDone = true;
|
|
267
|
+
}
|
|
268
|
+
if (isDone) {
|
|
269
|
+
this.assert(testCase);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
_nextTestCase() {
|
|
273
|
+
const animationProps = this._animationProps;
|
|
274
|
+
if (this._testCaseData) {
|
|
275
|
+
for (const key in this._testCaseData) {
|
|
276
|
+
const value = this._testCaseData[key];
|
|
277
|
+
if (value && value.delete) {
|
|
278
|
+
value.delete();
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
this._currentTestCase.onFinalize(Object.assign({}, animationProps, this._testCaseData));
|
|
282
|
+
this.device.popState();
|
|
283
|
+
this._currentTestCase = null;
|
|
284
|
+
this._testCaseData = null;
|
|
285
|
+
}
|
|
286
|
+
const testCase = this._testCases.shift();
|
|
287
|
+
if (testCase) {
|
|
288
|
+
this._currentTestCase = testCase;
|
|
289
|
+
this._currentTestCaseStartTime = animationProps.time;
|
|
290
|
+
this._currentTestCaseStartTick = animationProps.tick;
|
|
291
|
+
this.initTestCase(testCase);
|
|
292
|
+
this.device.pushState();
|
|
293
|
+
const initProps = __spreadProps(__spreadValues({}, animationProps), {
|
|
294
|
+
// tick/time starts from 0 for each test case
|
|
295
|
+
startTime: animationProps.time,
|
|
296
|
+
time: 0,
|
|
297
|
+
tick: 0
|
|
298
|
+
});
|
|
299
|
+
Promise.resolve(testCase.onInitialize(initProps)).then((userData) => {
|
|
300
|
+
this._testCaseData = userData || {};
|
|
301
|
+
});
|
|
302
|
+
this.testOptions.onTestStart(testCase);
|
|
303
|
+
}
|
|
304
|
+
return testCase;
|
|
305
|
+
}
|
|
306
|
+
};
|
|
307
|
+
|
|
308
|
+
// src/utils.ts
|
|
309
|
+
function getBoundingBoxInPage(domElement) {
|
|
310
|
+
const bbox = domElement.getBoundingClientRect();
|
|
311
|
+
return {
|
|
312
|
+
x: window.scrollX + bbox.x,
|
|
313
|
+
y: window.scrollY + bbox.y,
|
|
314
|
+
width: bbox.width,
|
|
315
|
+
height: bbox.height
|
|
316
|
+
};
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
// src/snapshot-test-runner.ts
|
|
320
|
+
var SnapshotTestRunner = class extends TestRunner {
|
|
321
|
+
constructor(props) {
|
|
322
|
+
super(props);
|
|
323
|
+
this.isDiffing = false;
|
|
324
|
+
this.testOptions.imageDiffOptions = {};
|
|
325
|
+
}
|
|
326
|
+
initTestCase(testCase) {
|
|
327
|
+
super.initTestCase(testCase);
|
|
328
|
+
if (!testCase.goldenImage) {
|
|
329
|
+
throw new Error(`Test case ${testCase.name} does not have golden image`);
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
shouldRender() {
|
|
333
|
+
return !this.isDiffing;
|
|
334
|
+
}
|
|
335
|
+
assert(testCase) {
|
|
336
|
+
return __async(this, null, function* () {
|
|
337
|
+
var _a;
|
|
338
|
+
if (this.isDiffing) {
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
this.isDiffing = true;
|
|
342
|
+
const canvas = (_a = this._animationProps) == null ? void 0 : _a.canvas;
|
|
343
|
+
if (!(canvas instanceof HTMLCanvasElement)) {
|
|
344
|
+
throw new Error("canvas");
|
|
345
|
+
}
|
|
346
|
+
const diffOptions = __spreadProps(__spreadValues(__spreadValues({}, this.testOptions.imageDiffOptions), testCase.imageDiffOptions), {
|
|
347
|
+
goldenImage: testCase.goldenImage,
|
|
348
|
+
region: getBoundingBoxInPage(canvas)
|
|
349
|
+
});
|
|
350
|
+
const result = yield globalThis.browserTestDriver_captureAndDiffScreen(diffOptions);
|
|
351
|
+
if (result.success) {
|
|
352
|
+
this._pass(result);
|
|
353
|
+
} else {
|
|
354
|
+
this._fail(result);
|
|
355
|
+
}
|
|
356
|
+
this.isDiffing = false;
|
|
357
|
+
this._next();
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
// src/performance-test-runner.ts
|
|
363
|
+
var import_stats = require("@probe.gl/stats");
|
|
364
|
+
var PerformanceTestRunner = class extends TestRunner {
|
|
365
|
+
constructor(props) {
|
|
366
|
+
super(props);
|
|
367
|
+
this._stats = null;
|
|
368
|
+
this._fps = null;
|
|
369
|
+
Object.assign(this.testOptions, {
|
|
370
|
+
maxFramesToRender: 60,
|
|
371
|
+
targetFPS: 50
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
initTestCase(testCase) {
|
|
375
|
+
super.initTestCase(testCase);
|
|
376
|
+
this._stats = new import_stats.Stats({ id: testCase.name });
|
|
377
|
+
this._fps = this._stats.get("fps");
|
|
378
|
+
}
|
|
379
|
+
shouldRender(animationProps) {
|
|
380
|
+
var _a, _b;
|
|
381
|
+
(_a = this._fps) == null ? void 0 : _a.timeEnd();
|
|
382
|
+
(_b = this._fps) == null ? void 0 : _b.timeStart();
|
|
383
|
+
if (this._fps.count > this.testOptions.maxFramesToRender) {
|
|
384
|
+
animationProps.done();
|
|
385
|
+
}
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
388
|
+
assert(testCase) {
|
|
389
|
+
var _a, _b;
|
|
390
|
+
const targetFPS = testCase.targetFPS || this.testOptions.targetFPS;
|
|
391
|
+
const count = (_a = this._fps) == null ? void 0 : _a.count;
|
|
392
|
+
const fps = ((_b = this._fps) == null ? void 0 : _b.getHz()) || 0;
|
|
393
|
+
if (fps >= targetFPS) {
|
|
394
|
+
this._pass({ fps, framesRendered: count });
|
|
395
|
+
} else {
|
|
396
|
+
this._fail({ fps, framesRendered: count });
|
|
397
|
+
}
|
|
398
|
+
this._next();
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
|
|
402
|
+
// src/check-type.ts
|
|
403
|
+
function checkType(value) {
|
|
404
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
export { default as SnapshotTestRunner } from
|
|
3
|
-
export { default as PerformanceTestRunner } from
|
|
4
|
-
export { createTestDevice, createTestContext, webgl1Device, webgl2Device, webgpuDevice } from
|
|
5
|
-
export { getTestDevices, getWebGLTestDevices } from
|
|
6
|
-
export { checkType } from
|
|
1
|
+
import "./register-devices.js";
|
|
2
|
+
export { default as SnapshotTestRunner } from "./snapshot-test-runner.js";
|
|
3
|
+
export { default as PerformanceTestRunner } from "./performance-test-runner.js";
|
|
4
|
+
export { createTestDevice, createTestContext, webgl1Device, webgl2Device, webgpuDevice } from "./create-test-device.js";
|
|
5
|
+
export { getTestDevices, getWebGLTestDevices } from "./create-test-device.js";
|
|
6
|
+
export { checkType } from "./check-type.js";
|
|
7
7
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"index.js","names":["default","SnapshotTestRunner","PerformanceTestRunner","createTestDevice","createTestContext","webgl1Device","webgl2Device","webgpuDevice","getTestDevices","getWebGLTestDevices","checkType"],"sources":["../src/index.ts"],"sourcesContent":["import './register-devices';\n\nexport type {TestRunnerTestCase} from './test-runner';\nexport type {SnapshotTestRunnerTestCase} from './snapshot-test-runner';\n\nexport {default as SnapshotTestRunner} from './snapshot-test-runner';\nexport {default as PerformanceTestRunner} from './performance-test-runner';\nexport {createTestDevice, createTestContext, webgl1Device, webgl2Device, webgpuDevice} from './create-test-device';\nexport {getTestDevices, getWebGLTestDevices} from './create-test-device';\n\nexport {checkType} from './check-type';\n"],"mappings":";SAKQA,OAAO,IAAIC,kBAAkB;AAAA,SAC7BD,OAAO,IAAIE,qBAAqB;AAAA,SAChCC,gBAAgB,EAAEC,iBAAiB,EAAEC,YAAY,EAAEC,YAAY,EAAEC,YAAY;AAAA,SAC7EC,cAAc,EAAEC,mBAAmB;AAAA,SAEnCC,SAAS"}
|
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import { Stats } from '@probe.gl/stats';
|
|
3
|
-
import TestRunner from
|
|
3
|
+
import TestRunner from "./test-runner.js";
|
|
4
4
|
export default class PerformanceTestRunner extends TestRunner {
|
|
5
5
|
constructor(props) {
|
|
6
6
|
super(props);
|
|
7
|
-
|
|
8
7
|
_defineProperty(this, "_stats", null);
|
|
9
|
-
|
|
10
8
|
_defineProperty(this, "_fps", null);
|
|
11
|
-
|
|
12
9
|
Object.assign(this.testOptions, {
|
|
13
10
|
maxFramesToRender: 60,
|
|
14
11
|
targetFPS: 50
|
|
15
12
|
});
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
initTestCase(testCase) {
|
|
19
15
|
super.initTestCase(testCase);
|
|
20
16
|
this._stats = new Stats({
|
|
@@ -22,27 +18,20 @@ export default class PerformanceTestRunner extends TestRunner {
|
|
|
22
18
|
});
|
|
23
19
|
this._fps = this._stats.get('fps');
|
|
24
20
|
}
|
|
25
|
-
|
|
26
21
|
shouldRender(animationProps) {
|
|
27
22
|
var _this$_fps, _this$_fps2;
|
|
28
|
-
|
|
29
23
|
(_this$_fps = this._fps) === null || _this$_fps === void 0 ? void 0 : _this$_fps.timeEnd();
|
|
30
24
|
(_this$_fps2 = this._fps) === null || _this$_fps2 === void 0 ? void 0 : _this$_fps2.timeStart();
|
|
31
|
-
|
|
32
25
|
if (this._fps.count > this.testOptions.maxFramesToRender) {
|
|
33
26
|
animationProps.done();
|
|
34
27
|
}
|
|
35
|
-
|
|
36
28
|
return true;
|
|
37
29
|
}
|
|
38
|
-
|
|
39
30
|
assert(testCase) {
|
|
40
31
|
var _this$_fps3, _this$_fps4;
|
|
41
|
-
|
|
42
32
|
const targetFPS = testCase.targetFPS || this.testOptions.targetFPS;
|
|
43
33
|
const count = (_this$_fps3 = this._fps) === null || _this$_fps3 === void 0 ? void 0 : _this$_fps3.count;
|
|
44
34
|
const fps = ((_this$_fps4 = this._fps) === null || _this$_fps4 === void 0 ? void 0 : _this$_fps4.getHz()) || 0;
|
|
45
|
-
|
|
46
35
|
if (fps >= targetFPS) {
|
|
47
36
|
this._pass({
|
|
48
37
|
fps,
|
|
@@ -54,9 +43,7 @@ export default class PerformanceTestRunner extends TestRunner {
|
|
|
54
43
|
framesRendered: count
|
|
55
44
|
});
|
|
56
45
|
}
|
|
57
|
-
|
|
58
46
|
this._next();
|
|
59
47
|
}
|
|
60
|
-
|
|
61
48
|
}
|
|
62
49
|
//# sourceMappingURL=performance-test-runner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"performance-test-runner.js","names":["Stats","TestRunner","PerformanceTestRunner","constructor","props","_defineProperty","Object","assign","testOptions","maxFramesToRender","targetFPS","initTestCase","testCase","_stats","id","name","_fps","get","shouldRender","animationProps","_this$_fps","_this$_fps2","timeEnd","timeStart","count","done","assert","_this$_fps3","_this$_fps4","fps","getHz","_pass","framesRendered","_fail","_next"],"sources":["../src/performance-test-runner.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport {Stats, Stat} from '@probe.gl/stats';\nimport TestRunner, {TestRunnerProps, TestRunnerTestCase} from './test-runner';\n\nexport type PerformanceTestRunnerProps = TestRunnerProps;\n\nexport default class PerformanceTestRunner extends TestRunner {\n private _stats: Stats | null = null;\n private _fps: Stat | null = null;\n\n constructor(props: PerformanceTestRunnerProps) {\n super(props);\n\n Object.assign(this.testOptions, {\n maxFramesToRender: 60,\n targetFPS: 50\n });\n }\n\n override initTestCase(testCase: TestRunnerTestCase): void {\n super.initTestCase(testCase);\n this._stats = new Stats({id: testCase.name});\n this._fps = this._stats.get('fps');\n }\n\n override shouldRender(animationProps: Record<string, any>): boolean {\n this._fps?.timeEnd();\n this._fps?.timeStart();\n\n if (this._fps.count > this.testOptions.maxFramesToRender) {\n animationProps.done();\n }\n\n return true;\n }\n\n override assert(testCase: TestRunnerTestCase): void {\n // @ts-expect-error\n const targetFPS = testCase.targetFPS || this.testOptions.targetFPS;\n const count = this._fps?.count;\n const fps = this._fps?.getHz() || 0;\n\n if (fps >= targetFPS) {\n this._pass({fps, framesRendered: count});\n } else {\n this._fail({fps, framesRendered: count});\n }\n this._next();\n }\n}\n"],"mappings":";AAEA,SAAQA,KAAK,QAAa,iBAAiB;AAAC,OACrCC,UAAU;AAIjB,eAAe,MAAMC,qBAAqB,SAASD,UAAU,CAAC;EAI5DE,WAAWA,CAACC,KAAiC,EAAE;IAC7C,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA,iBAJgB,IAAI;IAAAA,eAAA,eACP,IAAI;IAK9BC,MAAM,CAACC,MAAM,CAAC,IAAI,CAACC,WAAW,EAAE;MAC9BC,iBAAiB,EAAE,EAAE;MACrBC,SAAS,EAAE;IACb,CAAC,CAAC;EACJ;EAESC,YAAYA,CAACC,QAA4B,EAAQ;IACxD,KAAK,CAACD,YAAY,CAACC,QAAQ,CAAC;IAC5B,IAAI,CAACC,MAAM,GAAG,IAAIb,KAAK,CAAC;MAACc,EAAE,EAAEF,QAAQ,CAACG;IAAI,CAAC,CAAC;IAC5C,IAAI,CAACC,IAAI,GAAG,IAAI,CAACH,MAAM,CAACI,GAAG,CAAC,KAAK,CAAC;EACpC;EAESC,YAAYA,CAACC,cAAmC,EAAW;IAAA,IAAAC,UAAA,EAAAC,WAAA;IAClE,CAAAD,UAAA,OAAI,CAACJ,IAAI,cAAAI,UAAA,uBAATA,UAAA,CAAWE,OAAO,EAAE;IACpB,CAAAD,WAAA,OAAI,CAACL,IAAI,cAAAK,WAAA,uBAATA,WAAA,CAAWE,SAAS,EAAE;IAEtB,IAAI,IAAI,CAACP,IAAI,CAACQ,KAAK,GAAG,IAAI,CAAChB,WAAW,CAACC,iBAAiB,EAAE;MACxDU,cAAc,CAACM,IAAI,EAAE;IACvB;IAEA,OAAO,IAAI;EACb;EAESC,MAAMA,CAACd,QAA4B,EAAQ;IAAA,IAAAe,WAAA,EAAAC,WAAA;IAElD,MAAMlB,SAAS,GAAGE,QAAQ,CAACF,SAAS,IAAI,IAAI,CAACF,WAAW,CAACE,SAAS;IAClE,MAAMc,KAAK,IAAAG,WAAA,GAAG,IAAI,CAACX,IAAI,cAAAW,WAAA,uBAATA,WAAA,CAAWH,KAAK;IAC9B,MAAMK,GAAG,GAAG,EAAAD,WAAA,OAAI,CAACZ,IAAI,cAAAY,WAAA,uBAATA,WAAA,CAAWE,KAAK,EAAE,KAAI,CAAC;IAEnC,IAAID,GAAG,IAAInB,SAAS,EAAE;MACpB,IAAI,CAACqB,KAAK,CAAC;QAACF,GAAG;QAAEG,cAAc,EAAER;MAAK,CAAC,CAAC;IAC1C,CAAC,MAAM;MACL,IAAI,CAACS,KAAK,CAAC;QAACJ,GAAG;QAAEG,cAAc,EAAER;MAAK,CAAC,CAAC;IAC1C;IACA,IAAI,CAACU,KAAK,EAAE;EACd;AACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"register-devices.js","names":["luma","WebGLDevice","registerHeadlessGL","WebGPUDevice","headlessGL","registerDevices"],"sources":["../src/register-devices.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport {luma} from '@luma.gl/api';\nimport {WebGLDevice, registerHeadlessGL} from '@luma.gl/webgl';\nimport {WebGPUDevice} from '@luma.gl/webgpu';\n\nimport headlessGL from 'gl';\n\nregisterHeadlessGL(headlessGL);\nluma.registerDevices([WebGLDevice, WebGPUDevice]);\n"],"mappings":"AAEA,SAAQA,IAAI,QAAO,cAAc;AACjC,SAAQC,WAAW,EAAEC,kBAAkB,QAAO,gBAAgB;AAC9D,SAAQC,YAAY,QAAO,iBAAiB;AAE5C,OAAOC,UAAU,MAAM,IAAI;AAE3BF,kBAAkB,CAACE,UAAU,CAAC;AAC9BJ,IAAI,CAACK,eAAe,CAAC,CAACJ,WAAW,EAAEE,YAAY,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot-test-runner.d.ts","sourceRoot":"","sources":["../src/snapshot-test-run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AKjB,MAAM,CAAC,QAAQ,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC;CAgC3E"}
|
|
@@ -1,58 +1,45 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import TestRunner from
|
|
3
|
-
import { getBoundingBoxInPage } from
|
|
2
|
+
import TestRunner from "./test-runner.js";
|
|
3
|
+
import { getBoundingBoxInPage } from "./utils.js";
|
|
4
4
|
export default class SnapshotTestRunner extends TestRunner {
|
|
5
5
|
constructor(props) {
|
|
6
6
|
super(props);
|
|
7
|
-
|
|
8
7
|
_defineProperty(this, "isDiffing", false);
|
|
9
|
-
|
|
10
8
|
this.testOptions.imageDiffOptions = {};
|
|
11
9
|
}
|
|
12
|
-
|
|
13
10
|
initTestCase(testCase) {
|
|
14
11
|
super.initTestCase(testCase);
|
|
15
|
-
|
|
16
12
|
if (!testCase.goldenImage) {
|
|
17
13
|
throw new Error("Test case ".concat(testCase.name, " does not have golden image"));
|
|
18
14
|
}
|
|
19
15
|
}
|
|
20
|
-
|
|
21
16
|
shouldRender() {
|
|
22
17
|
return !this.isDiffing;
|
|
23
18
|
}
|
|
24
|
-
|
|
25
19
|
async assert(testCase) {
|
|
26
20
|
var _this$_animationProps;
|
|
27
|
-
|
|
28
21
|
if (this.isDiffing) {
|
|
29
22
|
return;
|
|
30
23
|
}
|
|
31
|
-
|
|
32
24
|
this.isDiffing = true;
|
|
33
25
|
const canvas = (_this$_animationProps = this._animationProps) === null || _this$_animationProps === void 0 ? void 0 : _this$_animationProps.canvas;
|
|
34
|
-
|
|
35
26
|
if (!(canvas instanceof HTMLCanvasElement)) {
|
|
36
27
|
throw new Error('canvas');
|
|
37
28
|
}
|
|
38
|
-
|
|
39
|
-
|
|
29
|
+
const diffOptions = {
|
|
30
|
+
...this.testOptions.imageDiffOptions,
|
|
40
31
|
...testCase.imageDiffOptions,
|
|
41
32
|
goldenImage: testCase.goldenImage,
|
|
42
33
|
region: getBoundingBoxInPage(canvas)
|
|
43
34
|
};
|
|
44
|
-
const result = await
|
|
45
|
-
|
|
35
|
+
const result = await globalThis.browserTestDriver_captureAndDiffScreen(diffOptions);
|
|
46
36
|
if (result.success) {
|
|
47
37
|
this._pass(result);
|
|
48
38
|
} else {
|
|
49
39
|
this._fail(result);
|
|
50
40
|
}
|
|
51
|
-
|
|
52
41
|
this.isDiffing = false;
|
|
53
|
-
|
|
54
42
|
this._next();
|
|
55
43
|
}
|
|
56
|
-
|
|
57
44
|
}
|
|
58
45
|
//# sourceMappingURL=snapshot-test-runner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"snapshot-test-runner.js","names":["TestRunner","getBoundingBoxInPage","SnapshotTestRunner","constructor","props","_defineProperty","testOptions","imageDiffOptions","initTestCase","testCase","goldenImage","Error","concat","name","shouldRender","isDiffing","assert","_this$_animationProps","canvas","_animationProps","HTMLCanvasElement","diffOptions","region","result","globalThis","browserTestDriver_captureAndDiffScreen","success","_pass","_fail","_next"],"sources":["../src/snapshot-test-runner.ts"],"sourcesContent":["import TestRunner, {TestRunnerProps, TestRunnerTestCase} from './test-runner';\nimport {getBoundingBoxInPage} from './utils';\n\n/** A snapshot test case */\nexport type SnapshotTestRunnerTestCase = TestRunnerTestCase & {\n /** URL to golden image */\n goldenImage: string;\n /** Diff options */\n imageDiffOptions?: {[key: string]: any}; \n}\n\nexport type SnapshotTestRunnerProps = TestRunnerProps;\n\nexport default class SnapshotTestRunner extends TestRunner {\n private isDiffing: boolean = false;\n\n constructor(props: SnapshotTestRunnerProps) {\n super(props);\n this.testOptions.imageDiffOptions = {};\n }\n\n override initTestCase(testCase: SnapshotTestRunnerTestCase): void {\n super.initTestCase(testCase);\n if (!testCase.goldenImage) {\n throw new Error(`Test case ${testCase.name} does not have golden image`);\n }\n }\n\n override shouldRender(): boolean {\n // wait for the current diffing to finish\n return !this.isDiffing;\n }\n\n override async assert(testCase: SnapshotTestRunnerTestCase): Promise<void> {\n if (this.isDiffing) {\n // Already performing diffing\n return;\n }\n this.isDiffing = true;\n\n const canvas = this._animationProps?.canvas;\n if (!(canvas instanceof HTMLCanvasElement)) {\n throw new Error('canvas');\n }\n\n const diffOptions = {\n ...this.testOptions.imageDiffOptions,\n ...testCase.imageDiffOptions,\n goldenImage: testCase.goldenImage,\n region: getBoundingBoxInPage(canvas)\n };\n\n // Take screenshot and compare\n const result = await globalThis.browserTestDriver_captureAndDiffScreen(diffOptions);\n\n // invoke user callback\n if (result.success) {\n this._pass(result);\n } else {\n this._fail(result);\n }\n\n this.isDiffing = false;\n this._next();\n }\n}\n"],"mappings":";OAAOA,UAAU;AAAA,SACTC,oBAAoB;AAY5B,eAAe,MAAMC,kBAAkB,SAASF,UAAU,CAAC;EAGzDG,WAAWA,CAACC,KAA8B,EAAE;IAC1C,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA,oBAHc,KAAK;IAIhC,IAAI,CAACC,WAAW,CAACC,gBAAgB,GAAG,CAAC,CAAC;EACxC;EAESC,YAAYA,CAACC,QAAoC,EAAQ;IAChE,KAAK,CAACD,YAAY,CAACC,QAAQ,CAAC;IAC5B,IAAI,CAACA,QAAQ,CAACC,WAAW,EAAE;MACzB,MAAM,IAAIC,KAAK,cAAAC,MAAA,CAAcH,QAAQ,CAACI,IAAI,iCAA8B;IAC1E;EACF;EAESC,YAAYA,CAAA,EAAY;IAE/B,OAAO,CAAC,IAAI,CAACC,SAAS;EACxB;EAEA,MAAeC,MAAMA,CAACP,QAAoC,EAAiB;IAAA,IAAAQ,qBAAA;IACzE,IAAI,IAAI,CAACF,SAAS,EAAE;MAElB;IACF;IACA,IAAI,CAACA,SAAS,GAAG,IAAI;IAErB,MAAMG,MAAM,IAAAD,qBAAA,GAAG,IAAI,CAACE,eAAe,cAAAF,qBAAA,uBAApBA,qBAAA,CAAsBC,MAAM;IAC3C,IAAI,EAAEA,MAAM,YAAYE,iBAAiB,CAAC,EAAE;MAC1C,MAAM,IAAIT,KAAK,CAAC,QAAQ,CAAC;IAC3B;IAEA,MAAMU,WAAW,GAAG;MAClB,GAAG,IAAI,CAACf,WAAW,CAACC,gBAAgB;MACpC,GAAGE,QAAQ,CAACF,gBAAgB;MAC5BG,WAAW,EAAED,QAAQ,CAACC,WAAW;MACjCY,MAAM,EAAErB,oBAAoB,CAACiB,MAAM;IACrC,CAAC;IAGD,MAAMK,MAAM,GAAG,MAAMC,UAAU,CAACC,sCAAsC,CAACJ,WAAW,CAAC;IAGnF,IAAIE,MAAM,CAACG,OAAO,EAAE;MAClB,IAAI,CAACC,KAAK,CAACJ,MAAM,CAAC;IACpB,CAAC,MAAM;MACL,IAAI,CAACK,KAAK,CAACL,MAAM,CAAC;IACpB;IAEA,IAAI,CAACR,SAAS,GAAG,KAAK;IACtB,IAAI,CAACc,KAAK,EAAE;EACd;AACF"}
|
package/dist/test-runner.d.ts
CHANGED
|
@@ -26,7 +26,7 @@ export declare type TestRunnerProps = {
|
|
|
26
26
|
};
|
|
27
27
|
/** Runs an array of test cases */
|
|
28
28
|
export default class TestRunner {
|
|
29
|
-
device: import("
|
|
29
|
+
device: import("modules/webgl/dist").WebGLDevice;
|
|
30
30
|
props: Record<string, any>;
|
|
31
31
|
isRunning: boolean;
|
|
32
32
|
readonly testOptions: Required<TestRunnerProps>;
|
|
@@ -45,8 +45,8 @@ export default class TestRunner {
|
|
|
45
45
|
*/
|
|
46
46
|
add(testCases: TestRunnerTestCase[]): this;
|
|
47
47
|
/**
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
* Returns a promise that resolves when all the test cases are done
|
|
49
|
+
*/
|
|
50
50
|
run(options?: object): Promise<void>;
|
|
51
51
|
initTestCase(testCase: TestRunnerTestCase): void;
|
|
52
52
|
shouldRender(animationProps: any): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-runner.d.ts","sourceRoot":"","sources":["../src/test-runner.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,cAA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;;QAEI;IACJ,GAAG,CAAC,OAAO,GAAE,MAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IA2BxC,YAAY,CAAC,QAAQ,EAAE,kBAAkB;IAYzC,YAAY,CAAC,cAAc,KAAA,GAAG,OAAO;IAIrC,MAAM,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAO1C,KAAK,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAK5B,KAAK,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAK5B,KAAK,IAAI,IAAI;IAMb,SAAS,CAAC,cAAc,KAAA,GAAG,IAAI;IA2C/B,aAAa,IAAI,OAAO,CAAC,kBAAkB,CAAC;CAuD7C"}
|
package/dist/test-runner.js
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import { AnimationLoop } from '@luma.gl/webgl-legacy';
|
|
3
|
-
import { webglDevice } from
|
|
4
|
-
|
|
3
|
+
import { webglDevice } from "./create-test-device.js";
|
|
5
4
|
function noop() {}
|
|
6
|
-
|
|
7
5
|
const DEFAULT_TEST_CASE = {
|
|
8
6
|
name: 'Unnamed test',
|
|
9
7
|
onInitialize: noop,
|
|
10
|
-
onRender:
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
onRender: _ref => {
|
|
9
|
+
let {
|
|
10
|
+
done
|
|
11
|
+
} = _ref;
|
|
12
|
+
return done();
|
|
13
|
+
},
|
|
13
14
|
onFinalize: noop
|
|
14
15
|
};
|
|
15
16
|
const DEFAULT_TEST_PROPS = {
|
|
@@ -19,47 +20,39 @@ const DEFAULT_TEST_PROPS = {
|
|
|
19
20
|
timeout: 2000
|
|
20
21
|
};
|
|
21
22
|
export default class TestRunner {
|
|
22
|
-
constructor(
|
|
23
|
+
constructor() {
|
|
24
|
+
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
23
25
|
_defineProperty(this, "device", webglDevice);
|
|
24
|
-
|
|
25
26
|
_defineProperty(this, "props", void 0);
|
|
26
|
-
|
|
27
27
|
_defineProperty(this, "isRunning", false);
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
_defineProperty(this, "testOptions", {
|
|
29
|
+
...DEFAULT_TEST_PROPS
|
|
30
30
|
});
|
|
31
|
-
|
|
32
31
|
_defineProperty(this, "_animationProps", {});
|
|
33
|
-
|
|
34
32
|
_defineProperty(this, "_animationLoop", void 0);
|
|
35
|
-
|
|
36
33
|
_defineProperty(this, "_testCases", []);
|
|
37
|
-
|
|
38
34
|
_defineProperty(this, "_testCaseData", null);
|
|
39
|
-
|
|
40
35
|
_defineProperty(this, "isHeadless", Boolean(window.browserTestDriver_isHeadless));
|
|
41
|
-
|
|
42
36
|
this.props = props;
|
|
43
37
|
}
|
|
44
|
-
|
|
45
38
|
add(testCases) {
|
|
46
39
|
if (!Array.isArray(testCases)) {
|
|
47
40
|
testCases = [testCases];
|
|
48
41
|
}
|
|
49
|
-
|
|
50
42
|
for (const testCase of testCases) {
|
|
51
43
|
this._testCases.push(testCase);
|
|
52
44
|
}
|
|
53
|
-
|
|
54
45
|
return this;
|
|
55
46
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
this.testOptions = {
|
|
47
|
+
run() {
|
|
48
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
49
|
+
this.testOptions = {
|
|
50
|
+
...this.testOptions,
|
|
59
51
|
...options
|
|
60
52
|
};
|
|
61
53
|
return new Promise((resolve, reject) => {
|
|
62
|
-
this._animationLoop = new AnimationLoop({
|
|
54
|
+
this._animationLoop = new AnimationLoop({
|
|
55
|
+
...this.props,
|
|
63
56
|
device: this.device,
|
|
64
57
|
onRender: this._onRender.bind(this),
|
|
65
58
|
onFinalize: () => {
|
|
@@ -67,9 +60,7 @@ export default class TestRunner {
|
|
|
67
60
|
resolve();
|
|
68
61
|
}
|
|
69
62
|
});
|
|
70
|
-
|
|
71
63
|
this._animationLoop.start(this.props);
|
|
72
|
-
|
|
73
64
|
this.isRunning = true;
|
|
74
65
|
this.isDiffing = false;
|
|
75
66
|
this._currentTestCase = null;
|
|
@@ -77,62 +68,47 @@ export default class TestRunner {
|
|
|
77
68
|
this._fail({
|
|
78
69
|
error: error.message
|
|
79
70
|
});
|
|
80
|
-
|
|
81
|
-
reject(error);
|
|
82
71
|
});
|
|
83
72
|
}
|
|
84
|
-
|
|
85
73
|
initTestCase(testCase) {
|
|
86
74
|
const {
|
|
87
75
|
animationLoop
|
|
88
76
|
} = testCase;
|
|
89
|
-
|
|
90
77
|
if (animationLoop) {
|
|
91
78
|
testCase.onInitialize = animationLoop.props.onInitialize.bind(animationLoop);
|
|
92
79
|
testCase.onRender = animationLoop.props.onRender.bind(animationLoop);
|
|
93
80
|
testCase.onFinalize = animationLoop.props.onFinalize.bind(animationLoop);
|
|
94
81
|
}
|
|
95
|
-
|
|
96
82
|
for (const key in DEFAULT_TEST_CASE) {
|
|
97
83
|
testCase[key] = testCase[key] || DEFAULT_TEST_CASE[key];
|
|
98
84
|
}
|
|
99
85
|
}
|
|
100
|
-
|
|
101
86
|
shouldRender(animationProps) {
|
|
102
87
|
return true;
|
|
103
88
|
}
|
|
104
|
-
|
|
105
89
|
assert(testCase) {
|
|
106
90
|
this._pass(testCase);
|
|
107
|
-
|
|
108
91
|
this._next();
|
|
109
92
|
}
|
|
110
|
-
|
|
111
93
|
_pass(result) {
|
|
112
94
|
this.testOptions.onTestPass(this._currentTestCase, result);
|
|
113
95
|
}
|
|
114
|
-
|
|
115
96
|
_fail(result) {
|
|
116
97
|
this.testOptions.onTestFail(this._currentTestCase, result);
|
|
117
98
|
}
|
|
118
|
-
|
|
119
99
|
_next() {
|
|
120
100
|
this._nextTestCase();
|
|
121
101
|
}
|
|
122
|
-
|
|
123
102
|
_onRender(animationProps) {
|
|
124
103
|
this._animationProps = animationProps;
|
|
125
|
-
|
|
126
104
|
const testCase = this._currentTestCase || this._nextTestCase();
|
|
127
|
-
|
|
128
105
|
if (!testCase) {
|
|
129
106
|
this._animationLoop.stop();
|
|
130
|
-
|
|
131
107
|
return;
|
|
132
108
|
}
|
|
133
|
-
|
|
134
109
|
let isDone = false;
|
|
135
|
-
const testCaseAnimationProps = {
|
|
110
|
+
const testCaseAnimationProps = {
|
|
111
|
+
...animationProps,
|
|
136
112
|
...this._testCaseData,
|
|
137
113
|
startTime: this._currentTestCaseStartTime,
|
|
138
114
|
time: animationProps.time - this._currentTestCaseStartTime,
|
|
@@ -141,50 +117,40 @@ export default class TestRunner {
|
|
|
141
117
|
isDone = true;
|
|
142
118
|
}
|
|
143
119
|
};
|
|
144
|
-
|
|
145
120
|
if (this._testCaseData && this.shouldRender(testCaseAnimationProps)) {
|
|
146
121
|
testCase.onRender(testCaseAnimationProps);
|
|
147
122
|
}
|
|
148
|
-
|
|
149
123
|
const timeout = testCase.timeout || this.testOptions.timeout;
|
|
150
|
-
|
|
151
124
|
if (timeout && testCaseAnimationProps.time > timeout) {
|
|
152
125
|
isDone = true;
|
|
153
126
|
}
|
|
154
|
-
|
|
155
127
|
if (isDone) {
|
|
156
128
|
this.assert(testCase);
|
|
157
129
|
}
|
|
158
130
|
}
|
|
159
|
-
|
|
160
131
|
_nextTestCase() {
|
|
161
132
|
const animationProps = this._animationProps;
|
|
162
|
-
|
|
163
133
|
if (this._testCaseData) {
|
|
164
134
|
for (const key in this._testCaseData) {
|
|
165
135
|
const value = this._testCaseData[key];
|
|
166
|
-
|
|
167
136
|
if (value && value.delete) {
|
|
168
137
|
value.delete();
|
|
169
138
|
}
|
|
170
139
|
}
|
|
171
|
-
|
|
172
140
|
this._currentTestCase.onFinalize(Object.assign({}, animationProps, this._testCaseData));
|
|
173
|
-
|
|
174
141
|
this.device.popState();
|
|
175
142
|
this._currentTestCase = null;
|
|
176
143
|
this._testCaseData = null;
|
|
177
144
|
}
|
|
178
|
-
|
|
179
145
|
const testCase = this._testCases.shift();
|
|
180
|
-
|
|
181
146
|
if (testCase) {
|
|
182
147
|
this._currentTestCase = testCase;
|
|
183
148
|
this._currentTestCaseStartTime = animationProps.time;
|
|
184
149
|
this._currentTestCaseStartTick = animationProps.tick;
|
|
185
150
|
this.initTestCase(testCase);
|
|
186
151
|
this.device.pushState();
|
|
187
|
-
const initProps = {
|
|
152
|
+
const initProps = {
|
|
153
|
+
...animationProps,
|
|
188
154
|
startTime: animationProps.time,
|
|
189
155
|
time: 0,
|
|
190
156
|
tick: 0
|
|
@@ -194,9 +160,7 @@ export default class TestRunner {
|
|
|
194
160
|
});
|
|
195
161
|
this.testOptions.onTestStart(testCase);
|
|
196
162
|
}
|
|
197
|
-
|
|
198
163
|
return testCase;
|
|
199
164
|
}
|
|
200
|
-
|
|
201
165
|
}
|
|
202
166
|
//# sourceMappingURL=test-runner.js.map
|
package/dist/test-runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/test-runner.ts"],"names":["AnimationLoop","webglDevice","noop","DEFAULT_TEST_CASE","name","onInitialize","onRender","done","onFinalize","DEFAULT_TEST_PROPS","onTestStart","testCase","console","log","onTestPass","onTestFail","timeout","TestRunner","constructor","props","Boolean","window","browserTestDriver_isHeadless","add","testCases","Array","isArray","_testCases","push","run","options","testOptions","Promise","resolve","reject","_animationLoop","device","_onRender","bind","isRunning","start","isDiffing","_currentTestCase","catch","error","_fail","message","initTestCase","animationLoop","key","shouldRender","animationProps","assert","_pass","_next","result","_nextTestCase","_animationProps","stop","isDone","testCaseAnimationProps","_testCaseData","startTime","_currentTestCaseStartTime","time","tick","_currentTestCaseStartTick","value","delete","Object","assign","popState","shift","pushState","initProps","then","userData"],"mappings":";AAEA,SAAQA,aAAR,QAA4C,uBAA5C;AACA,SAAQC,WAAR,QAA0B,sBAA1B;;AAcA,SAASC,IAAT,GAAgB,CAAE;;AAElB,MAAMC,iBAAqC,GAAG;AAC5CC,EAAAA,IAAI,EAAE,cADsC;AAE5CC,EAAAA,YAAY,EAAEH,IAF8B;AAG5CI,EAA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AAL,CAAYqC,SAAZ;AAIA,YAAMC,SAAS,GAAG,EAChB,GAAGvB,cADa;AAGhBW,QAAAA,SAAS,EAAEX,cAAc,CAACa,IAHV;AAIhBA,QAAAA,IAAI,EAAE,CAJU;AAKhBC,QAAAA,IAAI,EAAE;AALU,OAAlB;AAUAjC,MAAAA,OAAO,CAACC,OAAR,CAAgBtB,QAAQ,CAACN,YAAT,CAAsBqE,SAAtB,CAAhB,EAAkDC,IAAlD,CAAwDC,QAAD,IAAc;AACnE,aAAKf,aAAL,GAAqBe,QAAQ,IAAI,EAAjC;AACD,OAFD;AAKA,WAAK7C,WAAL,CAAiBrB,WAAjB,CAA6BC,QAA7B;AACD;;AACD,WAAOA,QAAP;AACD;;AAxM6B","sourcesContent":["// @ts-nocheck TODO remove\n/* eslint-disable no-console */\nimport {AnimationLoop, AnimationProps} from '@luma.gl/webgl-legacy';\nimport {webglDevice} from './create-test-device';\n\n/** Describes a test case */\nexport type TestRunnerTestCase = {\n /** Name of the test case (for logging) */\n name: string;\n /** Initialize the test case. Can return a promise */\n onInitialize: (props: AnimationProps) => Promise<unknown>;\n /** Perform rendering */\n onRender: (props: AnimationProps & {done}) => void;\n /** Clean up after the test case */\n onFinalize: (props: AnimationProps) => void;\n};\n\nfunction noop() {}\n\nconst DEFAULT_TEST_CASE: TestRunnerTestCase = {\n name: 'Unnamed test',\n onInitialize: noop,\n onRender: ({done}) => done(),\n onFinalize: noop\n};\n\n/** Options for a TestRunner */\nexport type TestRunnerProps = {\n width?: number;\n height?: number;\n // test lifecycle callback\n onTestStart?: (testCase: TestRunnerTestCase) => void;\n onTestPass?: (testCase: TestRunnerTestCase) => void;\n onTestFail?: (testCase: TestRunnerTestCase) => void;\n /** milliseconds to wait for each test case before aborting */\n timeout?: number;\n maxFramesToRender?: number;\n // HACK - this is for the snapshot test runner\n imageDiffOptions?: any;\n};\n\nconst DEFAULT_TEST_PROPS: Required<TestRunnerProps> = {\n // test lifecycle callback\n onTestStart: (testCase: TestRunnerTestCase) => console.log(`# ${testCase.name}`),\n onTestPass: (testCase: TestRunnerTestCase) => console.log(`ok ${testCase.name} passed`),\n onTestFail: (testCase: TestRunnerTestCase) => console.log(`not ok ${testCase.name} failed`),\n\n // milliseconds to wait for each test case before aborting\n timeout: 2000\n};\n\n/** Runs an array of test cases */\nexport default class TestRunner {\n device = webglDevice;\n props: Record<string, any>;\n isRunning: boolean = false;\n readonly testOptions: Required<TestRunnerProps> = {...DEFAULT_TEST_PROPS};\n readonly _animationProps?: AnimationProps = {};\n private _animationLoop: AnimationLoop | null;\n private _testCases: TestRunnerTestCase[] = [];\n private _testCaseData: any = null;\n\n // @ts-expect-error\n isHeadless: boolean = Boolean(window.browserTestDriver_isHeadless);\n\n /**\n * props\n * AnimationLoop props\n */\n constructor(props: Record<string, any> = {}) {\n this.props = props;\n }\n\n /**\n * Add testCase(s)\n */\n add(testCases: TestRunnerTestCase[]): this {\n if (!Array.isArray(testCases)) {\n testCases = [testCases];\n }\n for (const testCase of testCases) {\n this._testCases.push(testCase);\n }\n return this;\n }\n\n /**\n * Returns a promise that resolves when all the test cases are done\n */\n run(options: object = {}): Promise<void> {\n this.testOptions = {...this.testOptions, ...options};\n\n return new Promise<void>((resolve, reject) => {\n this._animationLoop = new AnimationLoop({\n // @ts-expect-error TODO\n ...this.props,\n device: this.device,\n onRender: this._onRender.bind(this),\n onFinalize: () => {\n this.isRunning = false;\n resolve();\n }\n });\n this._animationLoop.start(this.props);\n\n this.isRunning = true;\n this.isDiffing = false;\n this._currentTestCase = null;\n }).catch (error => {\n this._fail({error: error.message});\n reject(error);\n });\n }\n\n /* Lifecycle methods for subclassing */\n\n initTestCase(testCase: TestRunnerTestCase) {\n const {animationLoop} = testCase;\n if (animationLoop) {\n testCase.onInitialize = animationLoop.props.onInitialize.bind(animationLoop);\n testCase.onRender = animationLoop.props.onRender.bind(animationLoop);\n testCase.onFinalize = animationLoop.props.onFinalize.bind(animationLoop);\n }\n for (const key in DEFAULT_TEST_CASE) {\n testCase[key] = testCase[key] || DEFAULT_TEST_CASE[key];\n }\n }\n\n shouldRender(animationProps): boolean {\n return true;\n }\n\n assert(testCase: TestRunnerTestCase): void {\n this._pass(testCase);\n this._next();\n }\n\n /* Utilities */\n\n _pass(result: unknown): void {\n this.testOptions.onTestPass(this._currentTestCase, result);\n // this._animationLoop?.stop();\n }\n\n _fail(result: unknown): void {\n this.testOptions.onTestFail(this._currentTestCase, result);\n // this._animationLoop?.stop();\n }\n\n _next(): void {\n this._nextTestCase();\n }\n\n /* Private methods */\n\n _onRender(animationProps): void {\n this._animationProps = animationProps;\n\n const testCase = this._currentTestCase || this._nextTestCase();\n if (!testCase) {\n // all test cases are done\n this._animationLoop.stop();\n return;\n }\n\n let isDone = false;\n const testCaseAnimationProps: AnimationProps = {\n ...animationProps, \n ...this._testCaseData,\n // tick/time starts from 0 for each test case\n startTime: this._currentTestCaseStartTime,\n time: animationProps.time - this._currentTestCaseStartTime,\n tick: animationProps.tick - this._currentTestCaseStartTick,\n // called by the test case when it is done rendering and ready for capture and diff\n done: () => {\n isDone = true;\n }\n };\n\n if (this._testCaseData && this.shouldRender(testCaseAnimationProps)) {\n // try {\n // test case is initialized, render frame\n testCase.onRender(testCaseAnimationProps);\n // } catch {\n // isDone = true;\n // }\n }\n\n const timeout = testCase.timeout || this.testOptions.timeout;\n if (timeout && testCaseAnimationProps.time > timeout) {\n isDone = true;\n }\n\n if (isDone) {\n this.assert(testCase);\n }\n }\n\n _nextTestCase(): Promise<TestRunnerTestCase> {\n const animationProps = this._animationProps;\n\n // finalize the current test case\n if (this._testCaseData) {\n for (const key in this._testCaseData) {\n const value = this._testCaseData[key];\n if (value && value.delete) {\n value.delete();\n }\n }\n this._currentTestCase.onFinalize(Object.assign({}, animationProps, this._testCaseData));\n\n // reset WebGL context\n this.device.popState();\n\n this._currentTestCase = null;\n this._testCaseData = null;\n }\n\n // get the next test case\n const testCase = this._testCases.shift();\n if (testCase) {\n // start new test case\n this._currentTestCase = testCase;\n this._currentTestCaseStartTime = animationProps.time;\n this._currentTestCaseStartTick = animationProps.tick;\n this.initTestCase(testCase);\n\n // initialize test case\n\n // save WebGL context\n this.device.pushState();\n\n // aligned with the behavior of AnimationLoop.onInitialized\n // onInitialized could return a plain object or a promise\n const initProps = {\n ...animationProps,\n // tick/time starts from 0 for each test case\n startTime: animationProps.time,\n time: 0,\n tick: 0\n };\n\n // aligned with the behavior of AnimationLoop.onInitialized\n // onInitialized could return a plain object or a promise\n Promise.resolve(testCase.onInitialize(initProps)).then((userData) => {\n this._testCaseData = userData || {};\n });\n\n // invoke user callback\n this.testOptions.onTestStart(testCase);\n }\n return testCase;\n }\n}\n"],"file":"test-runner.js"}
|
|
1
|
+
{"version":3,"file":"test-runner.js","names":["AnimationLoop","webglDevice","noop","DEFAULT_TEST_CASE","name","onInitialize","onRender","_ref","done","onFinalize","DEFAULT_TEST_PROPS","onTestStart","testCase","console","log","concat","onTestPass","onTestFail","timeout","TestRunner","constructor","props","arguments","length","undefined","_defineProperty","Boolean","window","browserTestDriver_isHeadless","add","testCases","Array","isArray","_testCases","push","run","options","testOptions","Promise","resolve","reject","_animationLoop","device","_onRender","bind","isRunning","start","isDiffing","_currentTestCase","catch","error","_fail","message","initTestCase","animationLoop","key","shouldRender","animationProps","assert","_pass","_next","result","_nextTestCase","_animationProps","stop","isDone","testCaseAnimationProps","_testCaseData","startTime","_currentTestCaseStartTime","time","tick","_currentTestCaseStartTick","value","delete","Object","assign","popState","shift","pushState","initProps","then","userData"],"sources":["../src/test-runner.ts"],"sourcesContent":["// @ts-nocheck TODO remove\n/* eslint-disable no-console */\nimport {AnimationLoop, AnimationProps} from '@luma.gl/webgl-legacy';\nimport {webglDevice} from './create-test-device';\n\n/** Describes a test case */\nexport type TestRunnerTestCase = {\n /** Name of the test case (for logging) */\n name: string;\n /** Initialize the test case. Can return a promise */\n onInitialize: (props: AnimationProps) => Promise<unknown>;\n /** Perform rendering */\n onRender: (props: AnimationProps & {done}) => void;\n /** Clean up after the test case */\n onFinalize: (props: AnimationProps) => void;\n};\n\nfunction noop() {}\n\nconst DEFAULT_TEST_CASE: TestRunnerTestCase = {\n name: 'Unnamed test',\n onInitialize: noop,\n onRender: ({done}) => done(),\n onFinalize: noop\n};\n\n/** Options for a TestRunner */\nexport type TestRunnerProps = {\n width?: number;\n height?: number;\n // test lifecycle callback\n onTestStart?: (testCase: TestRunnerTestCase) => void;\n onTestPass?: (testCase: TestRunnerTestCase) => void;\n onTestFail?: (testCase: TestRunnerTestCase) => void;\n /** milliseconds to wait for each test case before aborting */\n timeout?: number;\n maxFramesToRender?: number;\n // HACK - this is for the snapshot test runner\n imageDiffOptions?: any;\n};\n\nconst DEFAULT_TEST_PROPS: Required<TestRunnerProps> = {\n // test lifecycle callback\n onTestStart: (testCase: TestRunnerTestCase) => console.log(`# ${testCase.name}`),\n onTestPass: (testCase: TestRunnerTestCase) => console.log(`ok ${testCase.name} passed`),\n onTestFail: (testCase: TestRunnerTestCase) => console.log(`not ok ${testCase.name} failed`),\n\n // milliseconds to wait for each test case before aborting\n timeout: 2000\n};\n\n/** Runs an array of test cases */\nexport default class TestRunner {\n device = webglDevice;\n props: Record<string, any>;\n isRunning: boolean = false;\n readonly testOptions: Required<TestRunnerProps> = {...DEFAULT_TEST_PROPS};\n readonly _animationProps?: AnimationProps = {};\n private _animationLoop: AnimationLoop | null;\n private _testCases: TestRunnerTestCase[] = [];\n private _testCaseData: any = null;\n\n // @ts-expect-error\n isHeadless: boolean = Boolean(window.browserTestDriver_isHeadless);\n\n /**\n * props\n * AnimationLoop props\n */\n constructor(props: Record<string, any> = {}) {\n this.props = props;\n }\n\n /**\n * Add testCase(s)\n */\n add(testCases: TestRunnerTestCase[]): this {\n if (!Array.isArray(testCases)) {\n testCases = [testCases];\n }\n for (const testCase of testCases) {\n this._testCases.push(testCase);\n }\n return this;\n }\n\n /**\n * Returns a promise that resolves when all the test cases are done\n */\n run(options: object = {}): Promise<void> {\n this.testOptions = {...this.testOptions, ...options};\n\n return new Promise<void>((resolve, reject) => {\n this._animationLoop = new AnimationLoop({\n // @ts-expect-error TODO\n ...this.props,\n device: this.device,\n onRender: this._onRender.bind(this),\n onFinalize: () => {\n this.isRunning = false;\n resolve();\n }\n });\n this._animationLoop.start(this.props);\n\n this.isRunning = true;\n this.isDiffing = false;\n this._currentTestCase = null;\n }).catch (error => {\n this._fail({error: error.message});\n // reject(error);\n });\n }\n\n /* Lifecycle methods for subclassing */\n\n initTestCase(testCase: TestRunnerTestCase) {\n const {animationLoop} = testCase;\n if (animationLoop) {\n testCase.onInitialize = animationLoop.props.onInitialize.bind(animationLoop);\n testCase.onRender = animationLoop.props.onRender.bind(animationLoop);\n testCase.onFinalize = animationLoop.props.onFinalize.bind(animationLoop);\n }\n for (const key in DEFAULT_TEST_CASE) {\n testCase[key] = testCase[key] || DEFAULT_TEST_CASE[key];\n }\n }\n\n shouldRender(animationProps): boolean {\n return true;\n }\n\n assert(testCase: TestRunnerTestCase): void {\n this._pass(testCase);\n this._next();\n }\n\n /* Utilities */\n\n _pass(result: unknown): void {\n this.testOptions.onTestPass(this._currentTestCase, result);\n // this._animationLoop?.stop();\n }\n\n _fail(result: unknown): void {\n this.testOptions.onTestFail(this._currentTestCase, result);\n // this._animationLoop?.stop();\n }\n\n _next(): void {\n this._nextTestCase();\n }\n\n /* Private methods */\n\n _onRender(animationProps): void {\n this._animationProps = animationProps;\n\n const testCase = this._currentTestCase || this._nextTestCase();\n if (!testCase) {\n // all test cases are done\n this._animationLoop.stop();\n return;\n }\n\n let isDone = false;\n const testCaseAnimationProps: AnimationProps = {\n ...animationProps, \n ...this._testCaseData,\n // tick/time starts from 0 for each test case\n startTime: this._currentTestCaseStartTime,\n time: animationProps.time - this._currentTestCaseStartTime,\n tick: animationProps.tick - this._currentTestCaseStartTick,\n // called by the test case when it is done rendering and ready for capture and diff\n done: () => {\n isDone = true;\n }\n };\n\n if (this._testCaseData && this.shouldRender(testCaseAnimationProps)) {\n // try {\n // test case is initialized, render frame\n testCase.onRender(testCaseAnimationProps);\n // } catch {\n // isDone = true;\n // }\n }\n\n const timeout = testCase.timeout || this.testOptions.timeout;\n if (timeout && testCaseAnimationProps.time > timeout) {\n isDone = true;\n }\n\n if (isDone) {\n this.assert(testCase);\n }\n }\n\n _nextTestCase(): Promise<TestRunnerTestCase> {\n const animationProps = this._animationProps;\n\n // finalize the current test case\n if (this._testCaseData) {\n for (const key in this._testCaseData) {\n const value = this._testCaseData[key];\n if (value && value.delete) {\n value.delete();\n }\n }\n this._currentTestCase.onFinalize(Object.assign({}, animationProps, this._testCaseData));\n\n // reset WebGL context\n this.device.popState();\n\n this._currentTestCase = null;\n this._testCaseData = null;\n }\n\n // get the next test case\n const testCase = this._testCases.shift();\n if (testCase) {\n // start new test case\n this._currentTestCase = testCase;\n this._currentTestCaseStartTime = animationProps.time;\n this._currentTestCaseStartTick = animationProps.tick;\n this.initTestCase(testCase);\n\n // initialize test case\n\n // save WebGL context\n this.device.pushState();\n\n // aligned with the behavior of AnimationLoop.onInitialized\n // onInitialized could return a plain object or a promise\n const initProps = {\n ...animationProps,\n // tick/time starts from 0 for each test case\n startTime: animationProps.time,\n time: 0,\n tick: 0\n };\n\n // aligned with the behavior of AnimationLoop.onInitialized\n // onInitialized could return a plain object or a promise\n Promise.resolve(testCase.onInitialize(initProps)).then((userData) => {\n this._testCaseData = userData || {};\n });\n\n // invoke user callback\n this.testOptions.onTestStart(testCase);\n }\n return testCase;\n }\n}\n"],"mappings":";AAEA,SAAQA,aAAa,QAAuB,uBAAuB;AAAC,SAC5DC,WAAW;AAcnB,SAASC,IAAIA,CAAA,EAAG,CAAC;AAEjB,MAAMC,iBAAqC,GAAG;EAC5CC,IAAI,EAAE,cAAc;EACpBC,YAAY,EAAEH,IAAI;EAClBI,QAAQ,EAAEC,IAAA;IAAA,IAAC;MAACC;IAAI,CAAC,GAAAD,IAAA;IAAA,OAAKC,IAAI,EAAE;EAAA;EAC5BC,UAAU,EAAEP;AACd,CAAC;AAiBD,MAA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B,GAAGf,cAAc,CAACc,IAAI;MACpD,IAAI,CAAClB,YAAY,CAACzC,QAAQ,CAAC;MAK3B,IAAI,CAAC8B,MAAM,CAACqC,SAAS,EAAE;MAIvB,MAAMC,SAAS,GAAG;QAChB,GAAGvB,cAAc;QAEjBW,SAAS,EAAEX,cAAc,CAACa,IAAI;QAC9BA,IAAI,EAAE,CAAC;QACPC,IAAI,EAAE;MACR,CAAC;MAIDjC,OAAO,CAACC,OAAO,CAAC3B,QAAQ,CAACP,YAAY,CAAC2E,SAAS,CAAC,CAAC,CAACC,IAAI,CAAEC,QAAQ,IAAK;QACnE,IAAI,CAACf,aAAa,GAAGe,QAAQ,IAAI,CAAC,CAAC;MACrC,CAAC,CAAC;MAGF,IAAI,CAAC7C,WAAW,CAAC1B,WAAW,CAACC,QAAQ,CAAC;IACxC;IACA,OAAOA,QAAQ;EACjB;AACF"}
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils.js","names":["getBoundingBoxInPage","domElement","bbox","getBoundingClientRect","x","window","scrollX","y","scrollY","width","height"],"sources":["../src/utils.ts"],"sourcesContent":["// Get the bounding box of a DOMElement relative to the page\nexport function getBoundingBoxInPage(domElement: HTMLElement): {x: number; y: number; width: number; height: number;} {\n const bbox = domElement.getBoundingClientRect();\n return {\n x: window.scrollX + bbox.x,\n y: window.scrollY + bbox.y,\n width: bbox.width,\n height: bbox.height\n };\n}\n"],"mappings":"AACA,OAAO,SAASA,oBAAoBA,CAACC,UAAuB,EAA0D;EACpH,MAAMC,IAAI,GAAGD,UAAU,CAACE,qBAAqB,EAAE;EAC/C,OAAO;IACLC,CAAC,EAAEC,MAAM,CAACC,OAAO,GAAGJ,IAAI,CAACE,CAAC;IAC1BG,CAAC,EAAEF,MAAM,CAACG,OAAO,GAAGN,IAAI,CAACK,CAAC;IAC1BE,KAAK,EAAEP,IAAI,CAACO,KAAK;IACjBC,MAAM,EAAER,IAAI,CAACQ;EACf,CAAC;AACH"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/test-utils",
|
|
3
|
-
"version": "9.0.0-alpha.
|
|
3
|
+
"version": "9.0.0-alpha.17",
|
|
4
4
|
"description": "Automated WebGL testing utilities with Puppeteer and image diffing",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"publishConfig": {
|
|
7
8
|
"access": "public"
|
|
@@ -17,8 +18,15 @@
|
|
|
17
18
|
"testing"
|
|
18
19
|
],
|
|
19
20
|
"types": "dist/index.d.ts",
|
|
20
|
-
"main": "dist/index.
|
|
21
|
+
"main": "dist/index.cjs",
|
|
21
22
|
"module": "dist/index.js",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"import": "./dist/index.js",
|
|
26
|
+
"require": "./dist/index.cjs",
|
|
27
|
+
"types": "./dist/index.d.ts"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
22
30
|
"files": [
|
|
23
31
|
"src",
|
|
24
32
|
"dist",
|
|
@@ -31,7 +39,7 @@
|
|
|
31
39
|
"pre-build": "echo test utils has no bundle"
|
|
32
40
|
},
|
|
33
41
|
"dependencies": {
|
|
34
|
-
"@probe.gl/env": "4.0.
|
|
42
|
+
"@probe.gl/env": "^4.0.2",
|
|
35
43
|
"@types/gl": "^6.0.2",
|
|
36
44
|
"gl": "^6.0.1"
|
|
37
45
|
},
|
|
@@ -39,7 +47,7 @@
|
|
|
39
47
|
"@luma.gl/api": "9.0.0-alpha.13",
|
|
40
48
|
"@luma.gl/webgl": "9.0.0-alpha.13",
|
|
41
49
|
"@luma.gl/webgpu": "9.0.0-alpha.13",
|
|
42
|
-
"@probe.gl/test-utils": "4.0.
|
|
50
|
+
"@probe.gl/test-utils": "^4.0.2"
|
|
43
51
|
},
|
|
44
52
|
"engines_comment": [
|
|
45
53
|
"gl needs recent minor version of Node 16.x"
|
|
@@ -47,5 +55,5 @@
|
|
|
47
55
|
"engines": {
|
|
48
56
|
"node": ">=16.18.0"
|
|
49
57
|
},
|
|
50
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "9385b56a95f5f53ee5f11d2ccef5b6114a527d94"
|
|
51
59
|
}
|
package/src/check-type.ts
CHANGED
|
@@ -24,15 +24,16 @@ export function createTestDevice(props: DeviceProps = {}): WebGLDevice | null {
|
|
|
24
24
|
// We dont use luma.createDevice since this tests current expect this context to be created synchronously
|
|
25
25
|
return new WebGLDevice(props);
|
|
26
26
|
} catch (error) {
|
|
27
|
+
// eslint-disable-next-line no-console
|
|
27
28
|
console.error(`Failed to created device '${props.id}': ${(error as Error).message}`);
|
|
28
29
|
return null;
|
|
29
30
|
}
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
/** A WebGL 1 Device intended for testing */
|
|
33
|
-
export const webgl1Device: WebGLDevice = createTestDevice({id: 'webgl1-test-device', webgl1: true, webgl2: false})
|
|
34
|
+
export const webgl1Device: WebGLDevice = createTestDevice({id: 'webgl1-test-device', webgl1: true, webgl2: false}) ;
|
|
34
35
|
/** A WebGL 2 Device intended for testing. Can be null */
|
|
35
|
-
export const webgl2Device: WebGLDevice = createTestDevice({id: 'webgl2-test-device', webgl1: false, webgl2: true})
|
|
36
|
+
export const webgl2Device: WebGLDevice = createTestDevice({id: 'webgl2-test-device', webgl1: false, webgl2: true}) ;
|
|
36
37
|
/** A WebGL 2 or WebGL 1 Device intended for testing. Best available. */
|
|
37
38
|
export const webglDevice: WebGLDevice = webgl2Device || webgl1Device;
|
|
38
39
|
|
|
@@ -51,8 +51,7 @@ export default class SnapshotTestRunner extends TestRunner {
|
|
|
51
51
|
};
|
|
52
52
|
|
|
53
53
|
// Take screenshot and compare
|
|
54
|
-
|
|
55
|
-
const result = await window.browserTestDriver_captureAndDiffScreen(diffOptions);
|
|
54
|
+
const result = await globalThis.browserTestDriver_captureAndDiffScreen(diffOptions);
|
|
56
55
|
|
|
57
56
|
// invoke user callback
|
|
58
57
|
if (result.success) {
|
package/src/test-runner.ts
CHANGED
|
@@ -74,7 +74,7 @@ export default class TestRunner {
|
|
|
74
74
|
/**
|
|
75
75
|
* Add testCase(s)
|
|
76
76
|
*/
|
|
77
|
-
|
|
77
|
+
add(testCases: TestRunnerTestCase[]): this {
|
|
78
78
|
if (!Array.isArray(testCases)) {
|
|
79
79
|
testCases = [testCases];
|
|
80
80
|
}
|
|
@@ -84,7 +84,7 @@ export default class TestRunner {
|
|
|
84
84
|
return this;
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
|
|
87
|
+
/**
|
|
88
88
|
* Returns a promise that resolves when all the test cases are done
|
|
89
89
|
*/
|
|
90
90
|
run(options: object = {}): Promise<void> {
|
|
@@ -108,7 +108,7 @@ export default class TestRunner {
|
|
|
108
108
|
this._currentTestCase = null;
|
|
109
109
|
}).catch (error => {
|
|
110
110
|
this._fail({error: error.message});
|
|
111
|
-
reject(error);
|
|
111
|
+
// reject(error);
|
|
112
112
|
});
|
|
113
113
|
}
|
|
114
114
|
|
|
@@ -179,8 +179,8 @@ export default class TestRunner {
|
|
|
179
179
|
|
|
180
180
|
if (this._testCaseData && this.shouldRender(testCaseAnimationProps)) {
|
|
181
181
|
// try {
|
|
182
|
-
|
|
183
|
-
|
|
182
|
+
// test case is initialized, render frame
|
|
183
|
+
testCase.onRender(testCaseAnimationProps);
|
|
184
184
|
// } catch {
|
|
185
185
|
// isDone = true;
|
|
186
186
|
// }
|