@luma.gl/test-utils 8.6.0-alpha.1 → 8.6.0-alpha.2
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/create-test-context.d.ts.map +1 -1
- package/dist/create-test-context.js +3 -13
- package/dist/create-test-context.js.map +1 -1
- 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 +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/performance-test-runner.js +1 -1
- package/dist/performance-test-runner.js.map +1 -1
- package/dist/snapshot-test-runner.js.map +1 -1
- package/dist/test-runner.js +1 -1
- package/dist/test-runner.js.map +1 -1
- package/package.json +7 -8
- package/src/create-test-context.ts +10 -1
- package/src/create-test-device.ts +31 -0
- package/src/index.ts +1 -0
- package/src/performance-test-runner.ts +3 -3
- package/src/snapshot-test-runner.ts +4 -4
- package/src/test-runner.ts +5 -5
- package/dist/context.d.ts +0 -3
- package/dist/context.d.ts.map +0 -1
- package/dist/context.js +0 -54
- package/dist/context.js.map +0 -1
- package/src/context.ts +0 -56
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-test-context.d.ts","sourceRoot":"","sources":["../src/create-test-context.ts"],"names":[],"mappings":"
|
|
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"}
|
|
@@ -1,16 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createGLContext, instrumentGLContext } from '@luma.gl/gltools';
|
|
3
|
-
import { createHeadlessContext } from './create-headless-context';
|
|
1
|
+
import { createTestDevice } from "./create-test-device";
|
|
4
2
|
export function createTestContext(opts = {}) {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const gl = createHeadlessContext(opts);
|
|
11
|
-
return gl ? instrumentGLContext(gl) : null;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
return createGLContext(opts);
|
|
3
|
+
const device = createTestDevice(opts);
|
|
4
|
+
return device && device.gl;
|
|
15
5
|
}
|
|
16
6
|
//# sourceMappingURL=create-test-context.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/create-test-context.ts"],"names":["
|
|
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,aAAkD,CAAC;AAChF,eAAO,MAAM,gBAAgB,aAAkD,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,gBAAgB,GAAGP,gBAAgB,CAAC;AAACQ,EAAAA,MAAM,EAAE,IAAT;AAAeC,EAAAA,MAAM,EAAE;AAAvB,CAAD,CAAzC;AACP,OAAO,MAAMC,gBAAgB,GAAGV,gBAAgB,CAAC;AAACQ,EAAAA,MAAM,EAAE,KAAT;AAAgBC,EAAAA,MAAM,EAAE;AAAxB,CAAD,CAAzC","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 = createTestDevice({webgl1: true, webgl2: false});\nexport const webgl2TestDevice = createTestDevice({webgl1: false, webgl2: true});\n"],"file":"create-test-device.js"}
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,5 @@ export { default as SnapshotTestRunner } from './snapshot-test-runner';
|
|
|
2
2
|
export { default as PerformanceTestRunner } from './performance-test-runner';
|
|
3
3
|
export { createHeadlessContext } from './create-headless-context';
|
|
4
4
|
export { createTestContext } from './create-test-context';
|
|
5
|
+
export { createTestDevice, webgl1TestDevice, webgl2TestDevice } from './create-test-device';
|
|
5
6
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +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"}
|
|
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
CHANGED
|
@@ -2,4 +2,5 @@ export { default as SnapshotTestRunner } from './snapshot-test-runner';
|
|
|
2
2
|
export { default as PerformanceTestRunner } from './performance-test-runner';
|
|
3
3
|
export { createHeadlessContext } from './create-headless-context';
|
|
4
4
|
export { createTestContext } from './create-test-context';
|
|
5
|
+
export { createTestDevice, webgl1TestDevice, webgl2TestDevice } from './create-test-device';
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts"],"names":["default","SnapshotTestRunner","PerformanceTestRunner","createHeadlessContext","createTestContext"],"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","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';\n"],"file":"index.js"}
|
|
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"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import { Stats } from 'probe.gl';
|
|
2
|
+
import { Stats } from '@probe.gl/stats';
|
|
3
3
|
import TestRunner from './test-runner';
|
|
4
4
|
export default class PerformanceTestRunner extends TestRunner {
|
|
5
5
|
constructor(props) {
|
|
@@ -1 +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,
|
|
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"}
|
|
@@ -1 +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-
|
|
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"}
|
package/dist/test-runner.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import { AnimationLoop } from '@luma.gl/core';
|
|
3
|
-
import { pushContextState, popContextState } from '@luma.gl/
|
|
3
|
+
import { pushContextState, popContextState } from '@luma.gl/webgl';
|
|
4
4
|
|
|
5
5
|
function noop() {}
|
|
6
6
|
|
package/dist/test-runner.js.map
CHANGED
|
@@ -1 +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":";AAEA,SAAQA,aAAR,QAA4B,eAA5B;AACA,SAAQC,gBAAR,EAA0BC,eAA1B,QAAgD,kBAAhD;;AASA,SAASC,IAAT,GAAgB,CAAE;;AAElB,MAAMC,iBAAqC,GAAG;AAC5CC,EAAAA,IAAI,EAAE,cADsC;AAE5CC,EAAAA,YAAY,EAAEH,IAF8B;AAG5CI,EAAAA,QAAQ,EAAE,CAAC;AAACC,IAAAA;AAAD,GAAD,KAAYA,IAAI,EAHkB;AAI5CC,EAAAA,UAAU,EAAEN;AAJgC,CAA9C;AAiBA,MAAMO,oBAAiD,GAAG;AAExDC,EAAAA,WAAW,EAAGC,QAAD,IAAcC,OAAO,CAACC,GAAR,aAAiBF,QAAQ,CAACP,IAA1B,EAF6B;AAGxDU,EAAAA,UAAU,EAAGH,QAAD,IAAcC,OAAO,CAACC,GAAR,cAAkBF,QAAQ,CAACP,IAA3B,aAH8B;AAIxDW,EAAAA,UAAU,EAAGJ,QAAD,IAAcC,OAAO,CAACC,GAAR,kBAAsBF,QAAQ,CAACP,IAA/B,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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/gltools';\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-ignore\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-ignore 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-ignore\n this.testOptions.onTestPass(this._currentTestCase, result);\n }\n\n _fail(result) {\n // @ts-ignore\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"}
|
|
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":";AAEA,SAAQA,aAAR,QAA4B,eAA5B;AACA,SAAQC,gBAAR,EAA0BC,eAA1B,QAAgD,gBAAhD;;AASA,SAASC,IAAT,GAAg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c,CAACc,IAAhD;AACA,WAAKlB,YAAL,CAAkBrC,QAAlB;AAKAX,MAAAA,gBAAgB,CAACoD,cAAc,CAACkB,EAAhB,CAAhB;AAIAnC,MAAAA,OAAO,CAACC,OAAR,CACEzB,QAAQ,CAACN,YAAT,CACEoB,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkB0B,cAAlB,EAAkC;AAEhCW,QAAAA,SAAS,EAAEX,cAAc,CAACa,IAFM;AAGhCA,QAAAA,IAAI,EAAE,CAH0B;AAIhCC,QAAAA,IAAI,EAAE;AAJ0B,OAAlC,CADF,CADF,EASEM,IATF,CASQC,QAAD,IAAc;AACnB,aAAKX,aAAL,GAAqBW,QAAQ,IAAI,EAAjC;AACD,OAXD;AAaA,WAAKjD,WAAL,CAAiBd,WAAjB,CAA6BC,QAA7B;AACD;;AACD,WAAOA,QAAP;AACD;;AAlM6B","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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/test-utils",
|
|
3
|
-
"version": "8.6.0-alpha.
|
|
3
|
+
"version": "8.6.0-alpha.2",
|
|
4
4
|
"description": "Automated WebGL testing utilities with Puppeteer and image diffing",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -31,14 +31,13 @@
|
|
|
31
31
|
"pre-build": "echo test utils has no bundle"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"probe.gl": "
|
|
34
|
+
"@probe.gl/env": "3.5.0-alpha.5"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
|
-
"@luma.gl/core": "
|
|
38
|
-
"@luma.gl/debug": "
|
|
39
|
-
"@luma.gl/
|
|
40
|
-
"@
|
|
41
|
-
"@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-alpha.5"
|
|
42
41
|
},
|
|
43
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "bdcebda76c1b4e47b127cdbd3f426ea6cbae44f1"
|
|
44
43
|
}
|
|
@@ -1,6 +1,14 @@
|
|
|
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
|
+
/*
|
|
1
9
|
import {isBrowser} from 'probe.gl/env';
|
|
2
10
|
import {createGLContext, instrumentGLContext} from '@luma.gl/gltools';
|
|
3
|
-
import {
|
|
11
|
+
import {createHeadlessContext} from './create-headless-context';
|
|
4
12
|
|
|
5
13
|
export function createTestContext(opts: Record<string, any> = {}): WebGLRenderingContext | null {
|
|
6
14
|
// try {
|
|
@@ -18,3 +26,4 @@ export function createTestContext(opts: Record<string, any> = {}): WebGLRenderin
|
|
|
18
26
|
// }
|
|
19
27
|
// }
|
|
20
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 = createTestDevice({webgl1: true, webgl2: false});
|
|
31
|
+
export const webgl2TestDevice = createTestDevice({webgl1: false, webgl2: true});
|
package/src/index.ts
CHANGED
|
@@ -2,3 +2,4 @@ export {default as SnapshotTestRunner} from './snapshot-test-runner';
|
|
|
2
2
|
export {default as PerformanceTestRunner} from './performance-test-runner';
|
|
3
3
|
export {createHeadlessContext} from './create-headless-context';
|
|
4
4
|
export {createTestContext} from './create-test-context';
|
|
5
|
+
export {createTestDevice, webgl1TestDevice, webgl2TestDevice} from './create-test-device';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {Stats, Stat} from 'probe.gl';
|
|
1
|
+
import {Stats, Stat} from '@probe.gl/stats';
|
|
2
2
|
import TestRunner, {TestRunnerOptions} from './test-runner';
|
|
3
3
|
|
|
4
4
|
export default class PerformanceTestRunner extends TestRunner {
|
|
@@ -24,7 +24,7 @@ export default class PerformanceTestRunner extends TestRunner {
|
|
|
24
24
|
this._fps.timeEnd();
|
|
25
25
|
this._fps.timeStart();
|
|
26
26
|
|
|
27
|
-
// @ts-
|
|
27
|
+
// @ts-expect-error
|
|
28
28
|
if (this._fps.count > this.testOptions.maxFramesToRender) {
|
|
29
29
|
animationProps.done();
|
|
30
30
|
}
|
|
@@ -33,7 +33,7 @@ export default class PerformanceTestRunner extends TestRunner {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
assert(testCase) {
|
|
36
|
-
// @ts-
|
|
36
|
+
// @ts-expect-error
|
|
37
37
|
const targetFPS = testCase.targetFPS || this.testOptions.targetFPS;
|
|
38
38
|
const count = this._fps.count;
|
|
39
39
|
const fps = this._fps.getHz();
|
|
@@ -8,7 +8,7 @@ export default class SnapshotTestRunner extends TestRunner {
|
|
|
8
8
|
constructor(props: TestRunnerOptions) {
|
|
9
9
|
super(props);
|
|
10
10
|
|
|
11
|
-
// @ts-
|
|
11
|
+
// @ts-expect-error
|
|
12
12
|
this.testOptions.imageDiffOptions = {};
|
|
13
13
|
}
|
|
14
14
|
|
|
@@ -33,18 +33,18 @@ export default class SnapshotTestRunner extends TestRunner {
|
|
|
33
33
|
|
|
34
34
|
const diffOptions = Object.assign(
|
|
35
35
|
{},
|
|
36
|
-
// @ts-
|
|
36
|
+
// @ts-expect-error
|
|
37
37
|
this.testOptions.imageDiffOptions,
|
|
38
38
|
testCase.imageDiffOptions,
|
|
39
39
|
{
|
|
40
40
|
goldenImage: testCase.goldenImage,
|
|
41
|
-
// @ts-
|
|
41
|
+
// @ts-expect-error
|
|
42
42
|
region: getBoundingBoxInPage(this._animationProps.canvas)
|
|
43
43
|
}
|
|
44
44
|
);
|
|
45
45
|
|
|
46
46
|
// Take screenshot and compare
|
|
47
|
-
// @ts-
|
|
47
|
+
// @ts-expect-error
|
|
48
48
|
window.browserTestDriver_captureAndDiffScreen(diffOptions).then((result) => {
|
|
49
49
|
// invoke user callback
|
|
50
50
|
if (result.success) {
|
package/src/test-runner.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @ts-nocheck TODO remove
|
|
2
2
|
/* eslint-disable no-console */
|
|
3
3
|
import {AnimationLoop} from '@luma.gl/core';
|
|
4
|
-
import {pushContextState, popContextState} from '@luma.gl/
|
|
4
|
+
import {pushContextState, popContextState} from '@luma.gl/webgl';
|
|
5
5
|
|
|
6
6
|
export type TestRunnerTestCase = {
|
|
7
7
|
name: string;
|
|
@@ -54,7 +54,7 @@ export default class TestRunner {
|
|
|
54
54
|
constructor(props = {}) {
|
|
55
55
|
this.props = props;
|
|
56
56
|
|
|
57
|
-
// @ts-
|
|
57
|
+
// @ts-expect-error
|
|
58
58
|
this.isHeadless = Boolean(window.browserTestDriver_isHeadless);
|
|
59
59
|
|
|
60
60
|
this.testOptions = Object.assign({}, DEFAULT_TEST_OPTIONS);
|
|
@@ -84,7 +84,7 @@ export default class TestRunner {
|
|
|
84
84
|
|
|
85
85
|
return new Promise<void>(resolve => {
|
|
86
86
|
this._animationLoop = new AnimationLoop(
|
|
87
|
-
// @ts-
|
|
87
|
+
// @ts-expect-error TODO
|
|
88
88
|
Object.assign({}, this.props, {
|
|
89
89
|
onRender: this._onRender.bind(this),
|
|
90
90
|
onFinalize: () => {
|
|
@@ -129,12 +129,12 @@ export default class TestRunner {
|
|
|
129
129
|
/* Utilities */
|
|
130
130
|
|
|
131
131
|
_pass(result) {
|
|
132
|
-
// @ts-
|
|
132
|
+
// @ts-expect-error
|
|
133
133
|
this.testOptions.onTestPass(this._currentTestCase, result);
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
_fail(result) {
|
|
137
|
-
// @ts-
|
|
137
|
+
// @ts-expect-error
|
|
138
138
|
this.testOptions.onTestFail(this._currentTestCase, result);
|
|
139
139
|
}
|
|
140
140
|
|
package/dist/context.d.ts
DELETED
package/dist/context.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAkBA,wBAAgB,iBAAiB,CAAC,IAAI,KAAK,GAAG,qBAAqB,CAMlE;AAID,wBAAgB,qBAAqB,CAAC,OAAO,CAAC,EAAE,GAAG,GAAG,qBAAqB,CAkB1E"}
|
package/dist/context.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { createGLContext, instrumentGLContext } from '@luma.gl/gltools';
|
|
2
|
-
import { isBrowser } from 'probe.gl/env';
|
|
3
|
-
const ERR_HEADLESSGL_FAILED = 'Failed to create WebGL context in Node.js, headless gl returned null';
|
|
4
|
-
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.";
|
|
5
|
-
const CONTEXT_DEFAULTS = {
|
|
6
|
-
width: 1,
|
|
7
|
-
height: 1,
|
|
8
|
-
debug: true,
|
|
9
|
-
throwOnError: false
|
|
10
|
-
};
|
|
11
|
-
export function createTestContext(opts = {}) {
|
|
12
|
-
opts = Object.assign({}, CONTEXT_DEFAULTS, opts);
|
|
13
|
-
const context = isBrowser() ? createGLContext(opts) : instrumentGLContext(createHeadlessContext(opts), opts);
|
|
14
|
-
return context;
|
|
15
|
-
}
|
|
16
|
-
export function createHeadlessContext(options) {
|
|
17
|
-
const {
|
|
18
|
-
width,
|
|
19
|
-
height,
|
|
20
|
-
webgl1,
|
|
21
|
-
webgl2
|
|
22
|
-
} = options;
|
|
23
|
-
|
|
24
|
-
function onError(message) {
|
|
25
|
-
if (options.throwOnError) {
|
|
26
|
-
throw new Error(message);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (webgl2 && !webgl1) {
|
|
33
|
-
return onError('headless-gl does not support WebGL2');
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const gl = headlessGL(width, height, options);
|
|
37
|
-
|
|
38
|
-
if (!gl) {
|
|
39
|
-
return onError(ERR_HEADLESSGL_FAILED);
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
return gl;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
function headlessGL(...args) {
|
|
46
|
-
const headless = module.require('gl');
|
|
47
|
-
|
|
48
|
-
if (!headless) {
|
|
49
|
-
throw new Error(ERR_HEADLESSGL_LOAD);
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return headless(...args);
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=context.js.map
|
package/dist/context.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/context.ts"],"names":["createGLContext","instrumentGLContext","isBrowser","ERR_HEADLESSGL_FAILED","ERR_HEADLESSGL_LOAD","CONTEXT_DEFAULTS","width","height","debug","throwOnError","createTestContext","opts","Object","assign","context","createHeadlessContext","options","webgl1","webgl2","onError","message","Error","gl","headlessGL","args","headless","module","require"],"mappings":"AAAA,SAAQA,eAAR,EAAyBC,mBAAzB,QAAmD,kBAAnD;AACA,SAAQC,SAAR,QAAwB,cAAxB;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,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umentGLContext} from '@luma.gl/gltools';\nimport {isBrowser} from 'probe.gl/env';\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\nexport function createTestContext(opts = {}): WebGLRenderingContext {\n opts = Object.assign({}, CONTEXT_DEFAULTS, opts);\n const context = isBrowser()\n ? createGLContext(opts)\n : instrumentGLContext(createHeadlessContext(opts), opts);\n return context;\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 const {width, height, webgl1, webgl2} = options;\n\n function onError(message) {\n if (options.throwOnError) {\n throw new Error(message);\n }\n return null;\n }\n\n if (webgl2 && !webgl1) {\n return onError('headless-gl does not support WebGL2');\n }\n const gl = headlessGL(width, height, options);\n if (!gl) {\n return onError(ERR_HEADLESSGL_FAILED);\n }\n return gl;\n}\n\n// Load headless gl dynamically, if available\nfunction headlessGL(...args) {\n const headless = module.require('gl');\n if (!headless) {\n throw new Error(ERR_HEADLESSGL_LOAD);\n }\n return headless(...args);\n}\n"],"file":"context.js"}
|
package/src/context.ts
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import {createGLContext, instrumentGLContext} from '@luma.gl/gltools';
|
|
2
|
-
import {isBrowser} from 'probe.gl/env';
|
|
3
|
-
|
|
4
|
-
const ERR_HEADLESSGL_FAILED =
|
|
5
|
-
'Failed to create WebGL context in Node.js, headless gl returned null';
|
|
6
|
-
|
|
7
|
-
const ERR_HEADLESSGL_LOAD = `\
|
|
8
|
-
luma.gl: loaded under Node.js without headless gl installed, meaning that WebGL \
|
|
9
|
-
contexts can not be created. This may not be an error. For example, this is a \
|
|
10
|
-
typical configuration for isorender applications running on the server.`;
|
|
11
|
-
|
|
12
|
-
const CONTEXT_DEFAULTS = {
|
|
13
|
-
width: 1,
|
|
14
|
-
height: 1,
|
|
15
|
-
debug: true,
|
|
16
|
-
throwOnError: false
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
export function createTestContext(opts = {}): WebGLRenderingContext {
|
|
20
|
-
opts = Object.assign({}, CONTEXT_DEFAULTS, opts);
|
|
21
|
-
const context = isBrowser()
|
|
22
|
-
? createGLContext(opts)
|
|
23
|
-
: instrumentGLContext(createHeadlessContext(opts), opts);
|
|
24
|
-
return context;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
// Create headless gl context (for running under Node.js)
|
|
28
|
-
// Create headless gl context (for running under Node.js)
|
|
29
|
-
export function createHeadlessContext(options?: any): WebGLRenderingContext {
|
|
30
|
-
const {width, height, webgl1, webgl2} = options;
|
|
31
|
-
|
|
32
|
-
function onError(message) {
|
|
33
|
-
if (options.throwOnError) {
|
|
34
|
-
throw new Error(message);
|
|
35
|
-
}
|
|
36
|
-
return null;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
if (webgl2 && !webgl1) {
|
|
40
|
-
return onError('headless-gl does not support WebGL2');
|
|
41
|
-
}
|
|
42
|
-
const gl = headlessGL(width, height, options);
|
|
43
|
-
if (!gl) {
|
|
44
|
-
return onError(ERR_HEADLESSGL_FAILED);
|
|
45
|
-
}
|
|
46
|
-
return gl;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
// Load headless gl dynamically, if available
|
|
50
|
-
function headlessGL(...args) {
|
|
51
|
-
const headless = module.require('gl');
|
|
52
|
-
if (!headless) {
|
|
53
|
-
throw new Error(ERR_HEADLESSGL_LOAD);
|
|
54
|
-
}
|
|
55
|
-
return headless(...args);
|
|
56
|
-
}
|