@luma.gl/test-utils 8.5.10 → 8.6.0-alpha.4
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/LICENSE +8 -1
- package/dist/create-headless-context.d.ts +2 -0
- package/dist/create-headless-context.d.ts.map +1 -0
- package/dist/create-headless-context.js +37 -0
- package/dist/create-headless-context.js.map +1 -0
- package/dist/create-test-context.d.ts +2 -0
- package/dist/create-test-context.d.ts.map +1 -0
- package/dist/create-test-context.js +6 -0
- package/dist/create-test-context.js.map +1 -0
- package/dist/create-test-device.d.ts +5 -0
- package/dist/create-test-device.d.ts.map +1 -0
- package/dist/create-test-device.js +32 -0
- package/dist/create-test-device.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/performance-test-runner.d.ts +10 -0
- package/dist/performance-test-runner.d.ts.map +1 -0
- package/dist/{esm/performance-test-runner.js → performance-test-runner.js} +7 -1
- package/dist/performance-test-runner.js.map +1 -0
- package/dist/snapshot-test-runner.d.ts +9 -0
- package/dist/snapshot-test-runner.d.ts.map +1 -0
- package/dist/{esm/snapshot-test-runner.js → snapshot-test-runner.js} +5 -1
- package/dist/snapshot-test-runner.js.map +1 -0
- package/dist/test-runner.d.ts +45 -0
- package/dist/test-runner.d.ts.map +1 -0
- package/dist/{esm/test-runner.js → test-runner.js} +17 -8
- package/dist/test-runner.js.map +1 -0
- package/dist/utils.d.ts +7 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/{esm/utils.js → utils.js} +0 -0
- package/dist/utils.js.map +1 -0
- package/package.json +13 -11
- package/src/create-headless-context.ts +36 -0
- package/src/create-test-context.ts +29 -0
- package/src/create-test-device.ts +31 -0
- package/src/index.ts +5 -0
- package/src/{performance-test-runner.js → performance-test-runner.ts} +8 -5
- package/src/{snapshot-test-runner.js → snapshot-test-runner.ts} +10 -7
- package/src/{test-runner.js → test-runner.ts} +46 -22
- package/src/{utils.js → utils.ts} +0 -0
- package/dist/es5/context.d.ts +0 -4
- package/dist/es5/context.js +0 -65
- package/dist/es5/context.js.map +0 -1
- package/dist/es5/index.d.ts +0 -3
- package/dist/es5/index.js +0 -38
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/performance-test-runner.d.ts +0 -5
- package/dist/es5/performance-test-runner.js +0 -96
- package/dist/es5/performance-test-runner.js.map +0 -1
- package/dist/es5/snapshot-test-runner.d.ts +0 -5
- package/dist/es5/snapshot-test-runner.js +0 -89
- package/dist/es5/snapshot-test-runner.js.map +0 -1
- package/dist/es5/test-runner.d.ts +0 -45
- package/dist/es5/test-runner.js +0 -239
- package/dist/es5/test-runner.js.map +0 -1
- package/dist/es5/utils.js +0 -17
- package/dist/es5/utils.js.map +0 -1
- package/dist/esm/context.d.ts +0 -4
- package/dist/esm/context.js +0 -57
- package/dist/esm/context.js.map +0 -1
- package/dist/esm/index.d.ts +0 -3
- package/dist/esm/index.js +0 -4
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/performance-test-runner.d.ts +0 -5
- package/dist/esm/performance-test-runner.js.map +0 -1
- package/dist/esm/snapshot-test-runner.d.ts +0 -5
- package/dist/esm/snapshot-test-runner.js.map +0 -1
- package/dist/esm/test-runner.d.ts +0 -45
- package/dist/esm/test-runner.js.map +0 -1
- package/dist/esm/utils.js.map +0 -1
- package/src/context.d.ts +0 -4
- package/src/context.js +0 -55
- package/src/index.d.ts +0 -3
- package/src/index.js +0 -3
- package/src/performance-test-runner.d.ts +0 -5
- package/src/snapshot-test-runner.d.ts +0 -5
- package/src/test-runner.d.ts +0 -45
package/LICENSE
CHANGED
|
@@ -1,9 +1,16 @@
|
|
|
1
|
+
Copyright (c) 2020 Urban Computing Foundation
|
|
2
|
+
|
|
3
|
+
This software includes parts initially developed by Uber and open sourced under MIT license.
|
|
1
4
|
Copyright (c) 2015 Uber Technologies, Inc.
|
|
2
5
|
|
|
3
6
|
This software includes parts of PhiloGL (https://github.com/philogb/philogl)
|
|
4
7
|
under MIT license. PhiloGL parts Copyright © 2013 Sencha Labs.
|
|
5
8
|
|
|
6
|
-
This software includes adaptations of postprocessing code from
|
|
9
|
+
This software includes adaptations of some postprocessing code from
|
|
10
|
+
THREE.js (https://github.com/mrdoob/three.js/) under MIT license.
|
|
11
|
+
THREE.js parts Copyright © 2010-2018 three.js authors.
|
|
12
|
+
|
|
13
|
+
Additional attribution given in specific source files.
|
|
7
14
|
|
|
8
15
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
9
16
|
of this software and associated documentation files (the "Software"), to deal
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-headless-context.d.ts","sourceRoot":"","sources":["../src/create-headless-context.ts"],"names":[],"mappings":"AAmBA,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,GAAG,GAAG,qBAAqB,CAgB1E"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import headlessGL from 'gl';
|
|
2
|
+
const ERR_HEADLESSGL_FAILED = 'Failed to create WebGL context in Node.js, headless gl returned null';
|
|
3
|
+
const ERR_HEADLESSGL_LOAD = " luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL contexts can not be created. This may not be an error. For example, this is a typical configuration for isorender applications running on the server.";
|
|
4
|
+
const CONTEXT_DEFAULTS = {
|
|
5
|
+
width: 1,
|
|
6
|
+
height: 1,
|
|
7
|
+
debug: true,
|
|
8
|
+
throwOnError: false
|
|
9
|
+
};
|
|
10
|
+
export function createHeadlessContext(options) {
|
|
11
|
+
options = { ...CONTEXT_DEFAULTS,
|
|
12
|
+
...options
|
|
13
|
+
};
|
|
14
|
+
const {
|
|
15
|
+
width,
|
|
16
|
+
height,
|
|
17
|
+
webgl1,
|
|
18
|
+
webgl2
|
|
19
|
+
} = options;
|
|
20
|
+
|
|
21
|
+
if (webgl2 && !webgl1) {
|
|
22
|
+
throw new Error('headless-gl does not support WebGL2');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
if (!headlessGL) {
|
|
26
|
+
throw new Error(ERR_HEADLESSGL_LOAD);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const gl = headlessGL(width, height, options);
|
|
30
|
+
|
|
31
|
+
if (!gl) {
|
|
32
|
+
throw new Error(ERR_HEADLESSGL_FAILED);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return gl;
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=create-headless-context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/create-headless-context.ts"],"names":["headlessGL","ERR_HEADLESSGL_FAILED","ERR_HEADLESSGL_LOAD","CONTEXT_DEFAULTS","width","height","debug","throwOnError","createHeadlessContext","options","webgl1","webgl2","Error","gl"],"mappings":"AAAA,OAAOA,UAAP,MAAuB,IAAvB;AAEA,MAAMC,qBAAqB,GACzB,sEADF;AAGA,MAAMC,mBAAmB,gPAAzB;AAKA,MAAMC,gBAAgB,GAAG;AACvBC,EAAAA,KAAK,EAAE,CADgB;AAEvBC,EAAAA,MAAM,EAAE,CAFe;AAGvBC,EAAAA,KAAK,EAAE,IAHgB;AAIvBC,EAAAA,YAAY,EAAE;AAJS,CAAzB;AASA,OAAO,SAASC,qBAAT,CAA+BC,OAA/B,EAAqE;AAC1EA,EAAAA,OAAO,GAAG,EAAC,GAAGN,gBAAJ;AAAsB,OAAGM;AAAzB,GAAV;AAEA,QAAM;AAACL,IAAAA,KAAD;AAAQC,IAAAA,MAAR;AAAgBK,IAAAA,MAAhB;AAAwBC,IAAAA;AAAxB,MAAkCF,OAAxC;;AAEA,MAAIE,MAAM,IAAI,CAACD,MAAf,EAAuB;AACrB,UAAM,IAAIE,KAAJ,CAAU,qCAAV,CAAN;AACD;;AACD,MAAI,CAACZ,UAAL,EAAiB;AACf,UAAM,IAAIY,KAAJ,CAAUV,mBAAV,CAAN;AACD;;AACD,QAAMW,EAAE,GAAGb,UAAU,CAACI,KAAD,EAAQC,MAAR,EAAgBI,OAAhB,CAArB;;AACA,MAAI,CAACI,EAAL,EAAS;AACP,UAAM,IAAID,KAAJ,CAAUX,qBAAV,CAAN;AACD;;AACD,SAAOY,EAAP;AACD","sourcesContent":["import headlessGL from 'gl';\n\nconst ERR_HEADLESSGL_FAILED =\n 'Failed to create WebGL context in Node.js, headless gl returned null';\n\nconst ERR_HEADLESSGL_LOAD = `\\\n luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \\\n contexts can not be created. This may not be an error. For example, this is a \\\n typical configuration for isorender applications running on the server.`;\n\nconst CONTEXT_DEFAULTS = {\n width: 1,\n height: 1,\n debug: true,\n throwOnError: false\n};\n\n// Create headless gl context (for running under Node.js)\n// Create headless gl context (for running under Node.js)\nexport function createHeadlessContext(options?: any): WebGLRenderingContext {\n options = {...CONTEXT_DEFAULTS, ...options};\n\n const {width, height, webgl1, webgl2} = options;\n\n if (webgl2 && !webgl1) {\n throw new Error('headless-gl does not support WebGL2');\n }\n if (!headlessGL) {\n throw new Error(ERR_HEADLESSGL_LOAD);\n }\n const gl = headlessGL(width, height, options);\n if (!gl) {\n throw new Error(ERR_HEADLESSGL_FAILED);\n }\n return gl;\n}\n"],"file":"create-headless-context.js"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-test-context.d.ts","sourceRoot":"","sources":["../src/create-test-context.ts"],"names":[],"mappings":"AAEA,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GAAG,qBAAqB,GAAG,IAAI,CAG9F"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/create-test-context.ts"],"names":["createTestDevice","createTestContext","opts","device","gl"],"mappings":"AAAA,SAASA,gBAAT,QAAiC,sBAAjC;AAEA,OAAO,SAASC,iBAAT,CAA2BC,IAAyB,GAAG,EAAvD,EAAyF;AAC9F,QAAMC,MAAM,GAAGH,gBAAgB,CAACE,IAAD,CAA/B;AACA,SAAOC,MAAM,IAAIA,MAAM,CAACC,EAAxB;AACD","sourcesContent":["import { createTestDevice } from \"./create-test-device\";\n\nexport function createTestContext(opts: Record<string, any> = {}): WebGLRenderingContext | null {\n const device = createTestDevice(opts);\n return device && device.gl;\n}\n\n /*\nimport {isBrowser} from 'probe.gl/env';\nimport {createGLContext, instrumentGLContext} from '@luma.gl/gltools';\nimport {createHeadlessContext} from './create-headless-context';\n\nexport function createTestContext(opts: Record<string, any> = {}): WebGLRenderingContext | null {\n // try {\n if (!isBrowser()) {\n if (opts.webgl2 && !opts.webgl1) {\n return null;\n }\n const gl = createHeadlessContext(opts);\n return gl ? instrumentGLContext(gl) : null;\n }\n return createGLContext(opts);\n // } catch {\n // if (opts.webgl2) {\n // return null;\n // }\n // }\n}\n*/\n"],"file":"create-test-context.js"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { WebGLDevice, WebGLDeviceProps } from '@luma.gl/webgl';
|
|
2
|
+
export declare function createTestDevice(props?: WebGLDeviceProps): WebGLDevice | null;
|
|
3
|
+
export declare const webgl1TestDevice: WebGLDevice;
|
|
4
|
+
export declare const webgl2TestDevice: WebGLDevice;
|
|
5
|
+
//# sourceMappingURL=create-test-device.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-test-device.d.ts","sourceRoot":"","sources":["../src/create-test-device.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,WAAW,EAAE,gBAAgB,EAAC,MAAM,gBAAgB,CAAC;AAiB7D,wBAAgB,gBAAgB,CAAC,KAAK,GAAE,gBAAqB,GAAG,WAAW,GAAG,IAAI,CASjF;AAED,eAAO,MAAM,gBAAgB,EAAE,WAA6D,CAAC;AAC7F,eAAO,MAAM,gBAAgB,EAAE,WAA6D,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { isBrowser } from 'probe.gl/env';
|
|
2
|
+
import { WebGLDevice } from '@luma.gl/webgl';
|
|
3
|
+
import { createHeadlessContext } from './create-headless-context';
|
|
4
|
+
const ERR_HEADLESSGL_FAILED = 'Failed to create WebGL context in Node.js, headless gl returned null';
|
|
5
|
+
const ERR_HEADLESSGL_LOAD = " luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL contexts can not be created. This may not be an error. For example, this is a typical configuration for isorender applications running on the server.";
|
|
6
|
+
const CONTEXT_DEFAULTS = {
|
|
7
|
+
width: 1,
|
|
8
|
+
height: 1,
|
|
9
|
+
debug: true
|
|
10
|
+
};
|
|
11
|
+
export function createTestDevice(props = {}) {
|
|
12
|
+
try {
|
|
13
|
+
const gl = !isBrowser() ? createHeadlessContext(props) : undefined;
|
|
14
|
+
props = { ...CONTEXT_DEFAULTS,
|
|
15
|
+
...props,
|
|
16
|
+
gl
|
|
17
|
+
};
|
|
18
|
+
return new WebGLDevice(props);
|
|
19
|
+
} catch (error) {
|
|
20
|
+
console.error(error.message);
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
export const webgl1TestDevice = createTestDevice({
|
|
25
|
+
webgl1: true,
|
|
26
|
+
webgl2: false
|
|
27
|
+
});
|
|
28
|
+
export const webgl2TestDevice = createTestDevice({
|
|
29
|
+
webgl1: false,
|
|
30
|
+
webgl2: true
|
|
31
|
+
});
|
|
32
|
+
//# sourceMappingURL=create-test-device.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/create-test-device.ts"],"names":["isBrowser","WebGLDevice","createHeadlessContext","ERR_HEADLESSGL_FAILED","ERR_HEADLESSGL_LOAD","CONTEXT_DEFAULTS","width","height","debug","createTestDevice","props","gl","undefined","error","console","message","webgl1TestDevice","webgl1","webgl2","webgl2TestDevice"],"mappings":"AAAA,SAAQA,SAAR,QAAwB,cAAxB;AACA,SAAQC,WAAR,QAA4C,gBAA5C;AACA,SAAQC,qBAAR,QAAoC,2BAApC;AAEA,MAAMC,qBAAqB,GACzB,sEADF;AAGA,MAAMC,mBAAmB,gPAAzB;AAKA,MAAMC,gBAA2C,GAAG;AAClDC,EAAAA,KAAK,EAAE,CAD2C;AAElDC,EAAAA,MAAM,EAAE,CAF0C;AAGlDC,EAAAA,KAAK,EAAE;AAH2C,CAApD;AAMA,OAAO,SAASC,gBAAT,CAA0BC,KAAuB,GAAG,EAApD,EAA4E;AACjF,MAAI;AACF,UAAMC,EAAE,GAAG,CAACX,SAAS,EAAV,GAAeE,qBAAqB,CAACQ,KAAD,CAApC,GAA8CE,SAAzD;AACAF,IAAAA,KAAK,GAAG,EAAC,GAAGL,gBAAJ;AAAsB,SAAGK,KAAzB;AAAgCC,MAAAA;AAAhC,KAAR;AACA,WAAO,IAAIV,WAAJ,CAAgBS,KAAhB,CAAP;AACD,GAJD,CAIE,OAAOG,KAAP,EAAc;AACdC,IAAAA,OAAO,CAACD,KAAR,CAAcA,KAAK,CAACE,OAApB;AACA,WAAO,IAAP;AACD;AACF;AAED,OAAO,MAAMC,gBAA6B,GAAGP,gBAAgB,CAAC;AAACQ,EAAAA,MAAM,EAAE,IAAT;AAAeC,EAAAA,MAAM,EAAE;AAAvB,CAAD,CAAtD;AACP,OAAO,MAAMC,gBAA6B,GAAGV,gBAAgB,CAAC;AAACQ,EAAAA,MAAM,EAAE,KAAT;AAAgBC,EAAAA,MAAM,EAAE;AAAxB,CAAD,CAAtD","sourcesContent":["import {isBrowser} from 'probe.gl/env';\nimport {WebGLDevice, WebGLDeviceProps} from '@luma.gl/webgl';\nimport {createHeadlessContext} from './create-headless-context';\n\nconst ERR_HEADLESSGL_FAILED =\n 'Failed to create WebGL context in Node.js, headless gl returned null';\n\nconst ERR_HEADLESSGL_LOAD = `\\\n luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \\\n contexts can not be created. This may not be an error. For example, this is a \\\n typical configuration for isorender applications running on the server.`;\n\nconst CONTEXT_DEFAULTS: Partial<WebGLDeviceProps> = {\n width: 1,\n height: 1,\n debug: true\n};\n\nexport function createTestDevice(props: WebGLDeviceProps = {}): WebGLDevice | null {\n try {\n const gl = !isBrowser() ? createHeadlessContext(props) : undefined;\n props = {...CONTEXT_DEFAULTS, ...props, gl};\n return new WebGLDevice(props);\n } catch (error) {\n console.error(error.message);\n return null;\n }\n}\n\nexport const webgl1TestDevice: WebGLDevice = createTestDevice({webgl1: true, webgl2: false});\nexport const webgl2TestDevice: WebGLDevice = createTestDevice({webgl1: false, webgl2: true});\n"],"file":"create-test-device.js"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as SnapshotTestRunner } from './snapshot-test-runner';
|
|
2
|
+
export { default as PerformanceTestRunner } from './performance-test-runner';
|
|
3
|
+
export { createHeadlessContext } from './create-headless-context';
|
|
4
|
+
export { createTestContext } from './create-test-context';
|
|
5
|
+
export { createTestDevice, webgl1TestDevice, webgl2TestDevice } from './create-test-device';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,kBAAkB,EAAC,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAC,OAAO,IAAI,qBAAqB,EAAC,MAAM,2BAA2B,CAAC;AAC3E,OAAO,EAAC,qBAAqB,EAAC,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAC,iBAAiB,EAAC,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAC,gBAAgB,EAAE,gBAAgB,EAAE,gBAAgB,EAAC,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as SnapshotTestRunner } from './snapshot-test-runner';
|
|
2
|
+
export { default as PerformanceTestRunner } from './performance-test-runner';
|
|
3
|
+
export { createHeadlessContext } from './create-headless-context';
|
|
4
|
+
export { createTestContext } from './create-test-context';
|
|
5
|
+
export { createTestDevice, webgl1TestDevice, webgl2TestDevice } from './create-test-device';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["default","SnapshotTestRunner","PerformanceTestRunner","createHeadlessContext","createTestContext","createTestDevice","webgl1TestDevice","webgl2TestDevice"],"mappings":"AAAA,SAAQA,OAAO,IAAIC,kBAAnB,QAA4C,wBAA5C;AACA,SAAQD,OAAO,IAAIE,qBAAnB,QAA+C,2BAA/C;AACA,SAAQC,qBAAR,QAAoC,2BAApC;AACA,SAAQC,iBAAR,QAAgC,uBAAhC;AACA,SAAQC,gBAAR,EAA0BC,gBAA1B,EAA4CC,gBAA5C,QAAmE,sBAAnE","sourcesContent":["export {default as SnapshotTestRunner} from './snapshot-test-runner';\nexport {default as PerformanceTestRunner} from './performance-test-runner';\nexport {createHeadlessContext} from './create-headless-context';\nexport {createTestContext} from './create-test-context';\nexport {createTestDevice, webgl1TestDevice, webgl2TestDevice} from './create-test-device';\n"],"file":"index.js"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import TestRunner, { TestRunnerOptions } from './test-runner';
|
|
2
|
+
export default class PerformanceTestRunner extends TestRunner {
|
|
3
|
+
private _stats;
|
|
4
|
+
private _fps;
|
|
5
|
+
constructor(props: TestRunnerOptions);
|
|
6
|
+
initTestCase(testCase: any): void;
|
|
7
|
+
shouldRender(animationProps: any): boolean;
|
|
8
|
+
assert(testCase: any): void;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=performance-test-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"performance-test-runner.d.ts","sourceRoot":"","sources":["../src/performance-test-runner.ts"],"names":[],"mappings":"AACA,OAAO,UAAU,EAAE,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAE5D,MAAM,CAAC,OAAO,OAAO,qBAAsB,SAAQ,UAAU;IAC3D,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,IAAI,CAAO;gBAEP,KAAK,EAAE,iBAAiB;IASpC,YAAY,CAAC,QAAQ,KAAA;IAMrB,YAAY,CAAC,cAAc,KAAA;IAY3B,MAAM,CAAC,QAAQ,KAAA;CAahB"}
|
|
@@ -1,8 +1,14 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import { Stats } from '@probe.gl/stats';
|
|
2
3
|
import TestRunner from './test-runner';
|
|
3
4
|
export default class PerformanceTestRunner extends TestRunner {
|
|
4
5
|
constructor(props) {
|
|
5
6
|
super(props);
|
|
7
|
+
|
|
8
|
+
_defineProperty(this, "_stats", void 0);
|
|
9
|
+
|
|
10
|
+
_defineProperty(this, "_fps", void 0);
|
|
11
|
+
|
|
6
12
|
Object.assign(this.testOptions, {
|
|
7
13
|
maxFramesToRender: 60,
|
|
8
14
|
targetFPS: 50
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/performance-test-runner.ts"],"names":["Stats","TestRunner","PerformanceTestRunner","constructor","props","Object","assign","testOptions","maxFramesToRender","targetFPS","initTestCase","testCase","_stats","id","name","_fps","get","shouldRender","animationProps","timeEnd","timeStart","count","done","assert","fps","getHz","_pass","framesRendered","_fail","_next"],"mappings":";AAAA,SAAQA,KAAR,QAA0B,iBAA1B;AACA,OAAOC,UAAP,MAA4C,eAA5C;AAEA,eAAe,MAAMC,qBAAN,SAAoCD,UAApC,CAA+C;AAI5DE,EAAAA,WAAW,CAACC,KAAD,EAA2B;AACpC,UAAMA,KAAN;;AADoC;;AAAA;;AAGpCC,IAAAA,MAAM,CAACC,MAAP,CAAc,KAAKC,WAAnB,EAAgC;AAC9BC,MAAAA,iBAAiB,EAAE,EADW;AAE9BC,MAAAA,SAAS,EAAE;AAFmB,KAAhC;AAID;;AAEDC,EAAAA,YAAY,CAACC,QAAD,EAAW;AACrB,UAAMD,YAAN,CAAmBC,QAAnB;AACA,SAAKC,MAAL,GAAc,IAAIZ,KAAJ,CAAU;AAACa,MAAAA,EAAE,EAAEF,QAAQ,CAACG;AAAd,KAAV,CAAd;AACA,SAAKC,IAAL,GAAY,KAAKH,MAAL,CAAYI,GAAZ,CAAgB,KAAhB,CAAZ;AACD;;AAEDC,EAAAA,YAAY,CAACC,cAAD,EAAiB;AAC3B,SAAKH,IAAL,CAAUI,OAAV;;AACA,SAAKJ,IAAL,CAAUK,SAAV;;AAGA,QAAI,KAAKL,IAAL,CAAUM,KAAV,GAAkB,KAAKd,WAAL,CAAiBC,iBAAvC,EAA0D;AACxDU,MAAAA,cAAc,CAACI,IAAf;AACD;;AAED,WAAO,IAAP;AACD;;AAEDC,EAAAA,MAAM,CAACZ,QAAD,EAAW;AAEf,UAAMF,SAAS,GAAGE,QAAQ,CAACF,SAAT,IAAsB,KAAKF,WAAL,CAAiBE,SAAzD;AACA,UAAMY,KAAK,GAAG,KAAKN,IAAL,CAAUM,KAAxB;;AACA,UAAMG,GAAG,GAAG,KAAKT,IAAL,CAAUU,KAAV,EAAZ;;AAEA,QAAID,GAAG,IAAIf,SAAX,EAAsB;AACpB,WAAKiB,KAAL,CAAW;AAACF,QAAAA,GAAD;AAAMG,QAAAA,cAAc,EAAEN;AAAtB,OAAX;AACD,KAFD,MAEO;AACL,WAAKO,KAAL,CAAW;AAACJ,QAAAA,GAAD;AAAMG,QAAAA,cAAc,EAAEN;AAAtB,OAAX;AACD;;AACD,SAAKQ,KAAL;AACD;;AA3C2D","sourcesContent":["import {Stats, Stat} from '@probe.gl/stats';\nimport TestRunner, {TestRunnerOptions} from './test-runner';\n\nexport default class PerformanceTestRunner extends TestRunner {\n private _stats: Stats;\n private _fps: Stat;\n\n constructor(props: TestRunnerOptions) {\n super(props);\n\n Object.assign(this.testOptions, {\n maxFramesToRender: 60,\n targetFPS: 50\n });\n }\n\n initTestCase(testCase) {\n super.initTestCase(testCase);\n this._stats = new Stats({id: testCase.name});\n this._fps = this._stats.get('fps');\n }\n\n shouldRender(animationProps) {\n this._fps.timeEnd();\n this._fps.timeStart();\n\n // @ts-expect-error\n if (this._fps.count > this.testOptions.maxFramesToRender) {\n animationProps.done();\n }\n\n return true;\n }\n\n assert(testCase) {\n // @ts-expect-error\n const targetFPS = testCase.targetFPS || this.testOptions.targetFPS;\n const count = this._fps.count;\n const fps = this._fps.getHz();\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"],"file":"performance-test-runner.js"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import TestRunner, { TestRunnerOptions } from './test-runner';
|
|
2
|
+
export default class SnapshotTestRunner extends TestRunner {
|
|
3
|
+
private isDiffing;
|
|
4
|
+
constructor(props: TestRunnerOptions);
|
|
5
|
+
initTestCase(testCase: any): void;
|
|
6
|
+
shouldRender(): boolean;
|
|
7
|
+
assert(testCase: any): void;
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=snapshot-test-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"snapshot-test-runner.d.ts","sourceRoot":"","sources":["../src/snapshot-test-runner.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,EAAE,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAC;AAI5D,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,UAAU;IACxD,OAAO,CAAC,SAAS,CAAkB;gBAEvB,KAAK,EAAE,iBAAiB;IAOpC,YAAY,CAAC,QAAQ,KAAA;IAOrB,YAAY;IAKZ,MAAM,CAAC,QAAQ,KAAA;CAiChB"}
|
|
@@ -1,8 +1,12 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
1
2
|
import TestRunner from './test-runner';
|
|
2
3
|
import { getBoundingBoxInPage } from './utils';
|
|
3
4
|
export default class SnapshotTestRunner extends TestRunner {
|
|
4
5
|
constructor(props) {
|
|
5
6
|
super(props);
|
|
7
|
+
|
|
8
|
+
_defineProperty(this, "isDiffing", false);
|
|
9
|
+
|
|
6
10
|
this.testOptions.imageDiffOptions = {};
|
|
7
11
|
}
|
|
8
12
|
|
|
@@ -10,7 +14,7 @@ export default class SnapshotTestRunner extends TestRunner {
|
|
|
10
14
|
super.initTestCase(testCase);
|
|
11
15
|
|
|
12
16
|
if (!testCase.goldenImage) {
|
|
13
|
-
throw new Error(
|
|
17
|
+
throw new Error("Test case ".concat(testCase.name, " does not have golden image"));
|
|
14
18
|
}
|
|
15
19
|
}
|
|
16
20
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/snapshot-test-runner.ts"],"names":["TestRunner","getBoundingBoxInPage","SnapshotTestRunner","constructor","props","testOptions","imageDiffOptions","initTestCase","testCase","goldenImage","Error","name","shouldRender","isDiffing","assert","diffOptions","Object","assign","region","_animationProps","canvas","window","browserTestDriver_captureAndDiffScreen","then","result","success","_pass","_fail","_next"],"mappings":";AAAA,OAAOA,UAAP,MAA4C,eAA5C;AACA,SAAQC,oBAAR,QAAmC,SAAnC;AAGA,eAAe,MAAMC,kBAAN,SAAiCF,UAAjC,CAA4C;AAGzDG,EAAAA,WAAW,CAACC,KAAD,EAA2B;AACpC,UAAMA,KAAN;;AADoC,uCAFT,KAES;;AAIpC,SAAKC,WAAL,CAAiBC,gBAAjB,GAAoC,EAApC;AACD;;AAEDC,EAAAA,YAAY,CAACC,QAAD,EAAW;AACrB,UAAMD,YAAN,CAAmBC,QAAnB;;AACA,QAAI,CAACA,QAAQ,CAACC,WAAd,EAA2B;AACzB,YAAM,IAAIC,KAAJ,qBAAuBF,QAAQ,CAACG,IAAhC,iCAAN;AACD;AACF;;AAEDC,EAAAA,YAAY,GAAG;AAEb,WAAO,CAAC,KAAKC,SAAb;AACD;;AAEDC,EAAAA,MAAM,CAACN,QAAD,EAAW;AACf,QAAI,KAAKK,SAAT,EAAoB;AAElB;AACD;;AACD,SAAKA,SAAL,GAAiB,IAAjB;AAEA,UAAME,WAAW,GAAGC,MAAM,CAACC,MAAP,CAClB,EADkB,EAGlB,KAAKZ,WAAL,CAAiBC,gBAHC,EAIlBE,QAAQ,CAACF,gBAJS,EAKlB;AACEG,MAAAA,WAAW,EAAED,QAAQ,CAACC,WADxB;AAGES,MAAAA,MAAM,EAAEjB,oBAAoB,CAAC,KAAKkB,eAAL,CAAqBC,MAAtB;AAH9B,KALkB,CAApB;AAcAC,IAAAA,MAAM,CAACC,sCAAP,CAA8CP,WAA9C,EAA2DQ,IAA3D,CAAiEC,MAAD,IAAY;AAE1E,UAAIA,MAAM,CAACC,OAAX,EAAoB;AAClB,aAAKC,KAAL,CAAWF,MAAX;AACD,OAFD,MAEO;AACL,aAAKG,KAAL,CAAWH,MAAX;AACD;;AAED,WAAKX,SAAL,GAAiB,KAAjB;;AACA,WAAKe,KAAL;AACD,KAVD;AAWD;;AAtDwD","sourcesContent":["import TestRunner, {TestRunnerOptions} from './test-runner';\nimport {getBoundingBoxInPage} from './utils';\n\n\nexport default class SnapshotTestRunner extends TestRunner {\n private isDiffing: boolean = false;\n\n constructor(props: TestRunnerOptions) {\n super(props);\n\n // @ts-expect-error\n this.testOptions.imageDiffOptions = {};\n }\n\n initTestCase(testCase) {\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 shouldRender() {\n // wait for the current diffing to finish\n return !this.isDiffing;\n }\n\n assert(testCase) {\n if (this.isDiffing) {\n // Already performing diffing\n return;\n }\n this.isDiffing = true;\n\n const diffOptions = Object.assign(\n {},\n // @ts-expect-error\n this.testOptions.imageDiffOptions,\n testCase.imageDiffOptions,\n {\n goldenImage: testCase.goldenImage,\n // @ts-expect-error\n region: getBoundingBoxInPage(this._animationProps.canvas)\n }\n );\n\n // Take screenshot and compare\n // @ts-expect-error\n window.browserTestDriver_captureAndDiffScreen(diffOptions).then((result) => {\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}\n"],"file":"snapshot-test-runner.js"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export declare type TestRunnerTestCase = {
|
|
2
|
+
name: string;
|
|
3
|
+
onInitialize: any;
|
|
4
|
+
onRender: any;
|
|
5
|
+
onFinalize: any;
|
|
6
|
+
};
|
|
7
|
+
export declare type TestRunnerOptions = {
|
|
8
|
+
onTestStart?: any;
|
|
9
|
+
onTestPass?: any;
|
|
10
|
+
onTestFail?: any;
|
|
11
|
+
timeout?: number;
|
|
12
|
+
};
|
|
13
|
+
export default class TestRunner {
|
|
14
|
+
props: any;
|
|
15
|
+
isRunning: boolean;
|
|
16
|
+
readonly testOptions: object;
|
|
17
|
+
readonly _animationProps: object;
|
|
18
|
+
private _testCases;
|
|
19
|
+
private _testCaseData;
|
|
20
|
+
/**
|
|
21
|
+
* props
|
|
22
|
+
* AnimationLoop props
|
|
23
|
+
*/
|
|
24
|
+
constructor(props?: {});
|
|
25
|
+
/**
|
|
26
|
+
* Add testCase(s)
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Add testCase(s)
|
|
30
|
+
*/
|
|
31
|
+
add(testCases: TestRunnerTestCase[]): this;
|
|
32
|
+
/**
|
|
33
|
+
* Returns a promise that resolves when all the test cases are done
|
|
34
|
+
*/
|
|
35
|
+
run(options?: object): Promise<void>;
|
|
36
|
+
initTestCase(testCase: any): void;
|
|
37
|
+
shouldRender(animationProps: any): boolean;
|
|
38
|
+
assert(testCase: any): void;
|
|
39
|
+
_pass(result: any): void;
|
|
40
|
+
_fail(result: any): void;
|
|
41
|
+
_next(): void;
|
|
42
|
+
_onRender(animationProps: any): void;
|
|
43
|
+
_nextTestCase(): TestRunnerTestCase;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=test-runner.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"test-runner.d.ts","sourceRoot":"","sources":["../src/test-runner.ts"],"names":[],"mappings":"AAKA,oBAAY,kBAAkB,GAAG;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,GAAG,CAAC;IAClB,QAAQ,EAAE,GAAG,CAAC;IACd,UAAU,EAAE,GAAG,CAAC;CACjB,CAAC;AAWF,oBAAY,iBAAiB,GAAG;IAE9B,WAAW,CAAC,EAAE,GAAG,CAAC;IAClB,UAAU,CAAC,EAAE,GAAG,CAAC;IACjB,UAAU,CAAC,EAAE,GAAG,CAAC;IAGjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAYF,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B,KAAK,MAAC;IACN,SAAS,UAAS;IAClB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAM;IACtC,OAAO,CAAC,UAAU,CAA4B;IAC9C,OAAO,CAAC,aAAa,CAAQ;IAE7B;;;OAGG;gBACS,KAAK,KAAK;IAStB;;OAEG;IACH;;OAEG;IACF,GAAG,CAAC,SAAS,EAAE,kBAAkB,EAAE,GAAG,IAAI;IAU1C;;OAEG;IACJ,GAAG,CAAC,OAAO,GAAE,MAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IA0BxC,YAAY,CAAC,QAAQ,KAAA;IAYrB,YAAY,CAAC,cAAc,KAAA;IAI3B,MAAM,CAAC,QAAQ,KAAA;IAOf,KAAK,CAAC,MAAM,KAAA;IAKZ,KAAK,CAAC,MAAM,KAAA;IAKZ,KAAK;IAML,SAAS,CAAC,cAAc,KAAA;IAqCxB,aAAa;CAqDd"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
1
2
|
import { AnimationLoop } from '@luma.gl/core';
|
|
2
|
-
import { pushContextState, popContextState } from '@luma.gl/
|
|
3
|
+
import { pushContextState, popContextState } from '@luma.gl/webgl';
|
|
3
4
|
|
|
4
5
|
function noop() {}
|
|
5
6
|
|
|
@@ -12,18 +13,26 @@ const DEFAULT_TEST_CASE = {
|
|
|
12
13
|
onFinalize: noop
|
|
13
14
|
};
|
|
14
15
|
const DEFAULT_TEST_OPTIONS = {
|
|
15
|
-
onTestStart: testCase => console.log(
|
|
16
|
-
onTestPass: testCase => console.log(
|
|
17
|
-
onTestFail: testCase => console.log(
|
|
16
|
+
onTestStart: testCase => console.log("# ".concat(testCase.name)),
|
|
17
|
+
onTestPass: testCase => console.log("ok ".concat(testCase.name, " passed")),
|
|
18
|
+
onTestFail: testCase => console.log("not ok ".concat(testCase.name, " failed")),
|
|
18
19
|
timeout: 2000
|
|
19
20
|
};
|
|
20
21
|
export default class TestRunner {
|
|
21
22
|
constructor(props = {}) {
|
|
23
|
+
_defineProperty(this, "props", void 0);
|
|
24
|
+
|
|
25
|
+
_defineProperty(this, "isRunning", false);
|
|
26
|
+
|
|
27
|
+
_defineProperty(this, "testOptions", void 0);
|
|
28
|
+
|
|
29
|
+
_defineProperty(this, "_animationProps", {});
|
|
30
|
+
|
|
31
|
+
_defineProperty(this, "_testCases", []);
|
|
32
|
+
|
|
33
|
+
_defineProperty(this, "_testCaseData", null);
|
|
34
|
+
|
|
22
35
|
this.props = props;
|
|
23
|
-
this.isRunning = false;
|
|
24
|
-
this._animationProps = {};
|
|
25
|
-
this._testCases = [];
|
|
26
|
-
this._testCaseData = null;
|
|
27
36
|
this.isHeadless = Boolean(window.browserTestDriver_isHeadless);
|
|
28
37
|
this.testOptions = Object.assign({}, DEFAULT_TEST_OPTIONS);
|
|
29
38
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/test-runner.ts"],"names":["AnimationLoop","pushContextState","popContextState","noop","DEFAULT_TEST_CASE","name","onInitialize","onRender","done","onFinalize","DEFAULT_TEST_OPTIONS","onTestStart","testCase","console","log","onTestPass","onTestFail","timeout","TestRunner","constructor","props","isHeadless","Boolean","window","browserTestDriver_isHeadless","testOptions","Object","assign","add","testCases","Array","isArray","_testCases","push","run","options","Promise","resolve","_animationLoop","_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","gl","shift","then","userData"],"mappings":"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","sourcesContent":["// @ts-nocheck TODO remove\n/* eslint-disable no-console */\nimport {AnimationLoop} from '@luma.gl/core';\nimport {pushContextState, popContextState} from '@luma.gl/webgl';\n\nexport type TestRunnerTestCase = {\n name: string;\n onInitialize: any;\n onRender: any;\n onFinalize: any;\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\nexport type TestRunnerOptions = {\n // test lifecycle callback\n onTestStart?: any;\n onTestPass?: any;\n onTestFail?: any;\n\n // milliseconds to wait for each test case before aborting\n timeout?: number;\n};\n\nconst DEFAULT_TEST_OPTIONS: Required<TestRunnerOptions> = {\n // test lifecycle callback\n onTestStart: (testCase) => console.log(`# ${testCase.name}`),\n onTestPass: (testCase) => console.log(`ok ${testCase.name} passed`),\n onTestFail: (testCase) => console.log(`not ok ${testCase.name} failed`),\n\n // milliseconds to wait for each test case before aborting\n timeout: 2000\n};\n\nexport default class TestRunner {\n props;\n isRunning = false;\n readonly testOptions: object;\n readonly _animationProps: object = {};\n private _testCases: TestRunnerTestCase[] = [];\n private _testCaseData = null;\n\n /**\n * props\n * AnimationLoop props\n */\n constructor(props = {}) {\n this.props = props;\n\n // @ts-expect-error\n this.isHeadless = Boolean(window.browserTestDriver_isHeadless);\n\n this.testOptions = Object.assign({}, DEFAULT_TEST_OPTIONS);\n }\n\n /**\n * Add testCase(s)\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 Object.assign(this.testOptions, options);\n\n return new Promise<void>(resolve => {\n this._animationLoop = new AnimationLoop(\n // @ts-expect-error TODO\n Object.assign({}, this.props, {\n onRender: this._onRender.bind(this),\n onFinalize: () => {\n this.isRunning = false;\n resolve();\n }\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 });\n }\n\n /* Lifecycle methods for subclassing */\n\n initTestCase(testCase) {\n const {animationLoop} = testCase;\n if (animationLoop) {\n testCase.onInitialize = animationLoop.onInitialize.bind(animationLoop);\n testCase.onRender = animationLoop.onRender.bind(animationLoop);\n testCase.onFinalize = animationLoop.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) {\n return true;\n }\n\n assert(testCase) {\n this._pass(testCase);\n this._next();\n }\n\n /* Utilities */\n\n _pass(result) {\n // @ts-expect-error\n this.testOptions.onTestPass(this._currentTestCase, result);\n }\n\n _fail(result) {\n // @ts-expect-error\n this.testOptions.onTestFail(this._currentTestCase, result);\n }\n\n _next() {\n this._nextTestCase();\n }\n\n /* Private methods */\n\n _onRender(animationProps) {\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 = Object.assign({}, animationProps, 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 // test case is initialized, render frame\n testCase.onRender(testCaseAnimationProps);\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() {\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 popContextState(animationProps.gl);\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 pushContextState(animationProps.gl);\n\n // aligned with the behavior of AnimationLoop.onInitialized\n // onInitialized could return a plain object or a promise\n Promise.resolve(\n testCase.onInitialize(\n Object.assign({}, animationProps, {\n // tick/time starts from 0 for each test case\n startTime: animationProps.time,\n time: 0,\n tick: 0\n })\n )\n ).then((userData) => {\n this._testCaseData = userData || {};\n });\n // invoke user callback\n this.testOptions.onTestStart(testCase);\n }\n return testCase;\n }\n}\n"],"file":"test-runner.js"}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,wBAAgB,oBAAoB,CAAC,UAAU,KAAA;;;;;EAQ9C"}
|
|
File without changes
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/utils.ts"],"names":["getBoundingBoxInPage","domElement","bbox","getBoundingClientRect","x","window","scrollX","y","scrollY","width","height"],"mappings":"AACA,OAAO,SAASA,oBAAT,CAA8BC,UAA9B,EAA0C;AAC/C,QAAMC,IAAI,GAAGD,UAAU,CAACE,qBAAX,EAAb;AACA,SAAO;AACLC,IAAAA,CAAC,EAAEC,MAAM,CAACC,OAAP,GAAiBJ,IAAI,CAACE,CADpB;AAELG,IAAAA,CAAC,EAAEF,MAAM,CAACG,OAAP,GAAiBN,IAAI,CAACK,CAFpB;AAGLE,IAAAA,KAAK,EAAEP,IAAI,CAACO,KAHP;AAILC,IAAAA,MAAM,EAAER,IAAI,CAACQ;AAJR,GAAP;AAMD","sourcesContent":["// Get the bounding box of a DOMElement relative to the page\nexport function getBoundingBoxInPage(domElement) {\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"],"file":"utils.js"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/test-utils",
|
|
3
|
-
"version": "8.
|
|
3
|
+
"version": "8.6.0-alpha.4",
|
|
4
4
|
"description": "Automated WebGL testing utilities with Puppeteer and image diffing",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -16,26 +16,28 @@
|
|
|
16
16
|
"automation",
|
|
17
17
|
"testing"
|
|
18
18
|
],
|
|
19
|
-
"types": "
|
|
20
|
-
"main": "dist/
|
|
21
|
-
"module": "dist/
|
|
19
|
+
"types": "dist/index.d.ts",
|
|
20
|
+
"main": "dist/index.js",
|
|
21
|
+
"module": "dist/index.js",
|
|
22
22
|
"files": [
|
|
23
23
|
"src",
|
|
24
24
|
"dist",
|
|
25
25
|
"README.md"
|
|
26
26
|
],
|
|
27
|
+
"browser": {
|
|
28
|
+
"gl": false
|
|
29
|
+
},
|
|
27
30
|
"scripts": {
|
|
28
31
|
"pre-build": "echo test utils has no bundle"
|
|
29
32
|
},
|
|
30
33
|
"dependencies": {
|
|
31
|
-
"probe.gl": "^3.
|
|
34
|
+
"@probe.gl/env": "^3.5.0"
|
|
32
35
|
},
|
|
33
36
|
"peerDependencies": {
|
|
34
|
-
"@luma.gl/core": "
|
|
35
|
-
"@luma.gl/debug": "
|
|
36
|
-
"@luma.gl/
|
|
37
|
-
"@
|
|
38
|
-
"@probe.gl/test-utils": "^3.4.0"
|
|
37
|
+
"@luma.gl/core": "8.6.0-alpha.1",
|
|
38
|
+
"@luma.gl/debug": "8.6.0-alpha.1",
|
|
39
|
+
"@luma.gl/webgl": "8.6.0-alpha.1",
|
|
40
|
+
"@probe.gl/test-utils": "^3.5.0"
|
|
39
41
|
},
|
|
40
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "c1c84f1bcaa6e6ff4f1e96f5d294baf8ce39846c"
|
|
41
43
|
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import headlessGL from 'gl';
|
|
2
|
+
|
|
3
|
+
const ERR_HEADLESSGL_FAILED =
|
|
4
|
+
'Failed to create WebGL context in Node.js, headless gl returned null';
|
|
5
|
+
|
|
6
|
+
const ERR_HEADLESSGL_LOAD = `\
|
|
7
|
+
luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \
|
|
8
|
+
contexts can not be created. This may not be an error. For example, this is a \
|
|
9
|
+
typical configuration for isorender applications running on the server.`;
|
|
10
|
+
|
|
11
|
+
const CONTEXT_DEFAULTS = {
|
|
12
|
+
width: 1,
|
|
13
|
+
height: 1,
|
|
14
|
+
debug: true,
|
|
15
|
+
throwOnError: false
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
// Create headless gl context (for running under Node.js)
|
|
19
|
+
// Create headless gl context (for running under Node.js)
|
|
20
|
+
export function createHeadlessContext(options?: any): WebGLRenderingContext {
|
|
21
|
+
options = {...CONTEXT_DEFAULTS, ...options};
|
|
22
|
+
|
|
23
|
+
const {width, height, webgl1, webgl2} = options;
|
|
24
|
+
|
|
25
|
+
if (webgl2 && !webgl1) {
|
|
26
|
+
throw new Error('headless-gl does not support WebGL2');
|
|
27
|
+
}
|
|
28
|
+
if (!headlessGL) {
|
|
29
|
+
throw new Error(ERR_HEADLESSGL_LOAD);
|
|
30
|
+
}
|
|
31
|
+
const gl = headlessGL(width, height, options);
|
|
32
|
+
if (!gl) {
|
|
33
|
+
throw new Error(ERR_HEADLESSGL_FAILED);
|
|
34
|
+
}
|
|
35
|
+
return gl;
|
|
36
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { createTestDevice } from "./create-test-device";
|
|
2
|
+
|
|
3
|
+
export function createTestContext(opts: Record<string, any> = {}): WebGLRenderingContext | null {
|
|
4
|
+
const device = createTestDevice(opts);
|
|
5
|
+
return device && device.gl;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/*
|
|
9
|
+
import {isBrowser} from 'probe.gl/env';
|
|
10
|
+
import {createGLContext, instrumentGLContext} from '@luma.gl/gltools';
|
|
11
|
+
import {createHeadlessContext} from './create-headless-context';
|
|
12
|
+
|
|
13
|
+
export function createTestContext(opts: Record<string, any> = {}): WebGLRenderingContext | null {
|
|
14
|
+
// try {
|
|
15
|
+
if (!isBrowser()) {
|
|
16
|
+
if (opts.webgl2 && !opts.webgl1) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
const gl = createHeadlessContext(opts);
|
|
20
|
+
return gl ? instrumentGLContext(gl) : null;
|
|
21
|
+
}
|
|
22
|
+
return createGLContext(opts);
|
|
23
|
+
// } catch {
|
|
24
|
+
// if (opts.webgl2) {
|
|
25
|
+
// return null;
|
|
26
|
+
// }
|
|
27
|
+
// }
|
|
28
|
+
}
|
|
29
|
+
*/
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import {isBrowser} from 'probe.gl/env';
|
|
2
|
+
import {WebGLDevice, WebGLDeviceProps} from '@luma.gl/webgl';
|
|
3
|
+
import {createHeadlessContext} from './create-headless-context';
|
|
4
|
+
|
|
5
|
+
const ERR_HEADLESSGL_FAILED =
|
|
6
|
+
'Failed to create WebGL context in Node.js, headless gl returned null';
|
|
7
|
+
|
|
8
|
+
const ERR_HEADLESSGL_LOAD = `\
|
|
9
|
+
luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \
|
|
10
|
+
contexts can not be created. This may not be an error. For example, this is a \
|
|
11
|
+
typical configuration for isorender applications running on the server.`;
|
|
12
|
+
|
|
13
|
+
const CONTEXT_DEFAULTS: Partial<WebGLDeviceProps> = {
|
|
14
|
+
width: 1,
|
|
15
|
+
height: 1,
|
|
16
|
+
debug: true
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export function createTestDevice(props: WebGLDeviceProps = {}): WebGLDevice | null {
|
|
20
|
+
try {
|
|
21
|
+
const gl = !isBrowser() ? createHeadlessContext(props) : undefined;
|
|
22
|
+
props = {...CONTEXT_DEFAULTS, ...props, gl};
|
|
23
|
+
return new WebGLDevice(props);
|
|
24
|
+
} catch (error) {
|
|
25
|
+
console.error(error.message);
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const webgl1TestDevice: WebGLDevice = createTestDevice({webgl1: true, webgl2: false});
|
|
31
|
+
export const webgl2TestDevice: WebGLDevice = createTestDevice({webgl1: false, webgl2: true});
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export {default as SnapshotTestRunner} from './snapshot-test-runner';
|
|
2
|
+
export {default as PerformanceTestRunner} from './performance-test-runner';
|
|
3
|
+
export {createHeadlessContext} from './create-headless-context';
|
|
4
|
+
export {createTestContext} from './create-test-context';
|
|
5
|
+
export {createTestDevice, webgl1TestDevice, webgl2TestDevice} from './create-test-device';
|
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
import {Stats} from 'probe.gl';
|
|
2
|
-
import TestRunner from './test-runner';
|
|
1
|
+
import {Stats, Stat} from '@probe.gl/stats';
|
|
2
|
+
import TestRunner, {TestRunnerOptions} from './test-runner';
|
|
3
3
|
|
|
4
4
|
export default class PerformanceTestRunner extends TestRunner {
|
|
5
|
-
|
|
5
|
+
private _stats: Stats;
|
|
6
|
+
private _fps: Stat;
|
|
7
|
+
|
|
8
|
+
constructor(props: TestRunnerOptions) {
|
|
6
9
|
super(props);
|
|
7
10
|
|
|
8
11
|
Object.assign(this.testOptions, {
|
|
@@ -21,7 +24,7 @@ export default class PerformanceTestRunner extends TestRunner {
|
|
|
21
24
|
this._fps.timeEnd();
|
|
22
25
|
this._fps.timeStart();
|
|
23
26
|
|
|
24
|
-
// @ts-
|
|
27
|
+
// @ts-expect-error
|
|
25
28
|
if (this._fps.count > this.testOptions.maxFramesToRender) {
|
|
26
29
|
animationProps.done();
|
|
27
30
|
}
|
|
@@ -30,7 +33,7 @@ export default class PerformanceTestRunner extends TestRunner {
|
|
|
30
33
|
}
|
|
31
34
|
|
|
32
35
|
assert(testCase) {
|
|
33
|
-
// @ts-
|
|
36
|
+
// @ts-expect-error
|
|
34
37
|
const targetFPS = testCase.targetFPS || this.testOptions.targetFPS;
|
|
35
38
|
const count = this._fps.count;
|
|
36
39
|
const fps = this._fps.getHz();
|
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import TestRunner from './test-runner';
|
|
1
|
+
import TestRunner, {TestRunnerOptions} from './test-runner';
|
|
2
2
|
import {getBoundingBoxInPage} from './utils';
|
|
3
3
|
|
|
4
|
+
|
|
4
5
|
export default class SnapshotTestRunner extends TestRunner {
|
|
5
|
-
|
|
6
|
+
private isDiffing: boolean = false;
|
|
7
|
+
|
|
8
|
+
constructor(props: TestRunnerOptions) {
|
|
6
9
|
super(props);
|
|
7
10
|
|
|
8
|
-
// @ts-
|
|
11
|
+
// @ts-expect-error
|
|
9
12
|
this.testOptions.imageDiffOptions = {};
|
|
10
13
|
}
|
|
11
14
|
|
|
@@ -30,19 +33,19 @@ export default class SnapshotTestRunner extends TestRunner {
|
|
|
30
33
|
|
|
31
34
|
const diffOptions = Object.assign(
|
|
32
35
|
{},
|
|
33
|
-
// @ts-
|
|
36
|
+
// @ts-expect-error
|
|
34
37
|
this.testOptions.imageDiffOptions,
|
|
35
38
|
testCase.imageDiffOptions,
|
|
36
39
|
{
|
|
37
40
|
goldenImage: testCase.goldenImage,
|
|
38
|
-
// @ts-
|
|
41
|
+
// @ts-expect-error
|
|
39
42
|
region: getBoundingBoxInPage(this._animationProps.canvas)
|
|
40
43
|
}
|
|
41
44
|
);
|
|
42
45
|
|
|
43
46
|
// Take screenshot and compare
|
|
44
|
-
// @ts-
|
|
45
|
-
window.browserTestDriver_captureAndDiffScreen(diffOptions).then(result => {
|
|
47
|
+
// @ts-expect-error
|
|
48
|
+
window.browserTestDriver_captureAndDiffScreen(diffOptions).then((result) => {
|
|
46
49
|
// invoke user callback
|
|
47
50
|
if (result.success) {
|
|
48
51
|
this._pass(result);
|