@luma.gl/test-utils 9.0.0-alpha.2 → 9.0.0-alpha.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/check-type.js +0 -1
- package/dist/check-type.js.map +1 -1
- package/dist/create-test-device.d.ts +10 -3
- package/dist/create-test-device.d.ts.map +1 -1
- package/dist/create-test-device.js +27 -16
- package/dist/create-test-device.js.map +1 -1
- package/dist/index.cjs +404 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -7
- package/dist/index.js.map +1 -1
- package/dist/performance-test-runner.d.ts +6 -5
- package/dist/performance-test-runner.d.ts.map +1 -1
- package/dist/performance-test-runner.js +9 -20
- package/dist/performance-test-runner.js.map +1 -1
- package/dist/register-devices.d.ts +2 -0
- package/dist/register-devices.d.ts.map +1 -0
- package/dist/register-devices.js +7 -0
- package/dist/register-devices.js.map +1 -0
- package/dist/snapshot-test-runner.d.ts +9 -4
- package/dist/snapshot-test-runner.d.ts.map +1 -1
- package/dist/snapshot-test-runner.js +21 -25
- package/dist/snapshot-test-runner.js.map +1 -1
- package/dist/test-runner.d.ts +27 -21
- package/dist/test-runner.d.ts.map +1 -1
- package/dist/test-runner.js +39 -64
- package/dist/test-runner.js.map +1 -1
- package/dist/utils.d.ts +5 -5
- package/dist/utils.d.ts.map +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +24 -7
- package/src/check-type.ts +1 -1
- package/src/create-test-device.ts +35 -19
- package/src/index.ts +3 -3
- package/src/performance-test-runner.ts +15 -12
- package/src/register-devices.ts +10 -0
- package/src/snapshot-test-runner.ts +30 -29
- package/src/test-runner.ts +76 -64
- package/src/utils.ts +1 -1
- package/dist/create-headless-context.d.ts +0 -2
- package/dist/create-headless-context.d.ts.map +0 -1
- package/dist/create-headless-context.js +0 -37
- package/dist/create-headless-context.js.map +0 -1
- package/dist/create-test-context.d.ts +0 -2
- package/dist/create-test-context.d.ts.map +0 -1
- package/dist/create-test-context.js +0 -6
- package/dist/create-test-context.js.map +0 -1
- package/src/create-headless-context.ts +0 -36
- package/src/create-test-context.ts +0 -29
|
@@ -1,20 +1,16 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
import { Stats } from '@probe.gl/stats';
|
|
3
|
-
import TestRunner from
|
|
3
|
+
import TestRunner from "./test-runner.js";
|
|
4
4
|
export default class PerformanceTestRunner extends TestRunner {
|
|
5
5
|
constructor(props) {
|
|
6
6
|
super(props);
|
|
7
|
-
|
|
8
|
-
_defineProperty(this, "
|
|
9
|
-
|
|
10
|
-
_defineProperty(this, "_fps", void 0);
|
|
11
|
-
|
|
7
|
+
_defineProperty(this, "_stats", null);
|
|
8
|
+
_defineProperty(this, "_fps", null);
|
|
12
9
|
Object.assign(this.testOptions, {
|
|
13
10
|
maxFramesToRender: 60,
|
|
14
11
|
targetFPS: 50
|
|
15
12
|
});
|
|
16
13
|
}
|
|
17
|
-
|
|
18
14
|
initTestCase(testCase) {
|
|
19
15
|
super.initTestCase(testCase);
|
|
20
16
|
this._stats = new Stats({
|
|
@@ -22,25 +18,20 @@ export default class PerformanceTestRunner extends TestRunner {
|
|
|
22
18
|
});
|
|
23
19
|
this._fps = this._stats.get('fps');
|
|
24
20
|
}
|
|
25
|
-
|
|
26
21
|
shouldRender(animationProps) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
this._fps.timeStart();
|
|
30
|
-
|
|
22
|
+
var _this$_fps, _this$_fps2;
|
|
23
|
+
(_this$_fps = this._fps) === null || _this$_fps === void 0 ? void 0 : _this$_fps.timeEnd();
|
|
24
|
+
(_this$_fps2 = this._fps) === null || _this$_fps2 === void 0 ? void 0 : _this$_fps2.timeStart();
|
|
31
25
|
if (this._fps.count > this.testOptions.maxFramesToRender) {
|
|
32
26
|
animationProps.done();
|
|
33
27
|
}
|
|
34
|
-
|
|
35
28
|
return true;
|
|
36
29
|
}
|
|
37
|
-
|
|
38
30
|
assert(testCase) {
|
|
31
|
+
var _this$_fps3, _this$_fps4;
|
|
39
32
|
const targetFPS = testCase.targetFPS || this.testOptions.targetFPS;
|
|
40
|
-
const count = this._fps.count;
|
|
41
|
-
|
|
42
|
-
const fps = this._fps.getHz();
|
|
43
|
-
|
|
33
|
+
const count = (_this$_fps3 = this._fps) === null || _this$_fps3 === void 0 ? void 0 : _this$_fps3.count;
|
|
34
|
+
const fps = ((_this$_fps4 = this._fps) === null || _this$_fps4 === void 0 ? void 0 : _this$_fps4.getHz()) || 0;
|
|
44
35
|
if (fps >= targetFPS) {
|
|
45
36
|
this._pass({
|
|
46
37
|
fps,
|
|
@@ -52,9 +43,7 @@ export default class PerformanceTestRunner extends TestRunner {
|
|
|
52
43
|
framesRendered: count
|
|
53
44
|
});
|
|
54
45
|
}
|
|
55
|
-
|
|
56
46
|
this._next();
|
|
57
47
|
}
|
|
58
|
-
|
|
59
48
|
}
|
|
60
49
|
//# sourceMappingURL=performance-test-runner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"performance-test-runner.js","names":["Stats","TestRunner","PerformanceTestRunner","constructor","props","_defineProperty","Object","assign","testOptions","maxFramesToRender","targetFPS","initTestCase","testCase","_stats","id","name","_fps","get","shouldRender","animationProps","_this$_fps","_this$_fps2","timeEnd","timeStart","count","done","assert","_this$_fps3","_this$_fps4","fps","getHz","_pass","framesRendered","_fail","_next"],"sources":["../src/performance-test-runner.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport {Stats, Stat} from '@probe.gl/stats';\nimport TestRunner, {TestRunnerProps, TestRunnerTestCase} from './test-runner';\n\nexport type PerformanceTestRunnerProps = TestRunnerProps;\n\nexport default class PerformanceTestRunner extends TestRunner {\n private _stats: Stats | null = null;\n private _fps: Stat | null = null;\n\n constructor(props: PerformanceTestRunnerProps) {\n super(props);\n\n Object.assign(this.testOptions, {\n maxFramesToRender: 60,\n targetFPS: 50\n });\n }\n\n override initTestCase(testCase: TestRunnerTestCase): void {\n super.initTestCase(testCase);\n this._stats = new Stats({id: testCase.name});\n this._fps = this._stats.get('fps');\n }\n\n override shouldRender(animationProps: Record<string, any>): boolean {\n this._fps?.timeEnd();\n this._fps?.timeStart();\n\n if (this._fps.count > this.testOptions.maxFramesToRender) {\n animationProps.done();\n }\n\n return true;\n }\n\n override assert(testCase: TestRunnerTestCase): void {\n // @ts-expect-error\n const targetFPS = testCase.targetFPS || this.testOptions.targetFPS;\n const count = this._fps?.count;\n const fps = this._fps?.getHz() || 0;\n\n if (fps >= targetFPS) {\n this._pass({fps, framesRendered: count});\n } else {\n this._fail({fps, framesRendered: count});\n }\n this._next();\n }\n}\n"],"mappings":";AAEA,SAAQA,KAAK,QAAa,iBAAiB;AAAC,OACrCC,UAAU;AAIjB,eAAe,MAAMC,qBAAqB,SAASD,UAAU,CAAC;EAI5DE,WAAWA,CAACC,KAAiC,EAAE;IAC7C,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA,iBAJgB,IAAI;IAAAA,eAAA,eACP,IAAI;IAK9BC,MAAM,CAACC,MAAM,CAAC,IAAI,CAACC,WAAW,EAAE;MAC9BC,iBAAiB,EAAE,EAAE;MACrBC,SAAS,EAAE;IACb,CAAC,CAAC;EACJ;EAESC,YAAYA,CAACC,QAA4B,EAAQ;IACxD,KAAK,CAACD,YAAY,CAACC,QAAQ,CAAC;IAC5B,IAAI,CAACC,MAAM,GAAG,IAAIb,KAAK,CAAC;MAACc,EAAE,EAAEF,QAAQ,CAACG;IAAI,CAAC,CAAC;IAC5C,IAAI,CAACC,IAAI,GAAG,IAAI,CAACH,MAAM,CAACI,GAAG,CAAC,KAAK,CAAC;EACpC;EAESC,YAAYA,CAACC,cAAmC,EAAW;IAAA,IAAAC,UAAA,EAAAC,WAAA;IAClE,CAAAD,UAAA,OAAI,CAACJ,IAAI,cAAAI,UAAA,uBAATA,UAAA,CAAWE,OAAO,EAAE;IACpB,CAAAD,WAAA,OAAI,CAACL,IAAI,cAAAK,WAAA,uBAATA,WAAA,CAAWE,SAAS,EAAE;IAEtB,IAAI,IAAI,CAACP,IAAI,CAACQ,KAAK,GAAG,IAAI,CAAChB,WAAW,CAACC,iBAAiB,EAAE;MACxDU,cAAc,CAACM,IAAI,EAAE;IACvB;IAEA,OAAO,IAAI;EACb;EAESC,MAAMA,CAACd,QAA4B,EAAQ;IAAA,IAAAe,WAAA,EAAAC,WAAA;IAElD,MAAMlB,SAAS,GAAGE,QAAQ,CAACF,SAAS,IAAI,IAAI,CAACF,WAAW,CAACE,SAAS;IAClE,MAAMc,KAAK,IAAAG,WAAA,GAAG,IAAI,CAACX,IAAI,cAAAW,WAAA,uBAATA,WAAA,CAAWH,KAAK;IAC9B,MAAMK,GAAG,GAAG,EAAAD,WAAA,OAAI,CAACZ,IAAI,cAAAY,WAAA,uBAATA,WAAA,CAAWE,KAAK,EAAE,KAAI,CAAC;IAEnC,IAAID,GAAG,IAAInB,SAAS,EAAE;MACpB,IAAI,CAACqB,KAAK,CAAC;QAACF,GAAG;QAAEG,cAAc,EAAER;MAAK,CAAC,CAAC;IAC1C,CAAC,MAAM;MACL,IAAI,CAACS,KAAK,CAAC;QAACJ,GAAG;QAAEG,cAAc,EAAER;MAAK,CAAC,CAAC;IAC1C;IACA,IAAI,CAACU,KAAK,EAAE;EACd;AACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-devices.d.ts","sourceRoot":"","sources":["../src/register-devices.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { luma } from '@luma.gl/api';
|
|
2
|
+
import { WebGLDevice, registerHeadlessGL } from '@luma.gl/webgl';
|
|
3
|
+
import { WebGPUDevice } from '@luma.gl/webgpu';
|
|
4
|
+
import headlessGL from 'gl';
|
|
5
|
+
registerHeadlessGL(headlessGL);
|
|
6
|
+
luma.registerDevices([WebGLDevice, WebGPUDevice]);
|
|
7
|
+
//# sourceMappingURL=register-devices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"register-devices.js","names":["luma","WebGLDevice","registerHeadlessGL","WebGPUDevice","headlessGL","registerDevices"],"sources":["../src/register-devices.ts"],"sourcesContent":["// luma.gl, MIT license\n\nimport {luma} from '@luma.gl/api';\nimport {WebGLDevice, registerHeadlessGL} from '@luma.gl/webgl';\nimport {WebGPUDevice} from '@luma.gl/webgpu';\n\nimport headlessGL from 'gl';\n\nregisterHeadlessGL(headlessGL);\nluma.registerDevices([WebGLDevice, WebGPUDevice]);\n"],"mappings":"AAEA,SAAQA,IAAI,QAAO,cAAc;AACjC,SAAQC,WAAW,EAAEC,kBAAkB,QAAO,gBAAgB;AAC9D,SAAQC,YAAY,QAAO,iBAAiB;AAE5C,OAAOC,UAAU,MAAM,IAAI;AAE3BF,kBAAkB,CAACE,UAAU,CAAC;AAC9BJ,IAAI,CAACK,eAAe,CAAC,CAACJ,WAAW,EAAEE,YAAY,CAAC,CAAC"}
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
import TestRunner, {
|
|
1
|
+
import TestRunner, { TestRunnerProps, TestRunnerTestCase } from './test-runner';
|
|
2
2
|
/** A snapshot test case */
|
|
3
3
|
export declare type SnapshotTestRunnerTestCase = TestRunnerTestCase & {
|
|
4
4
|
/** URL to golden image */
|
|
5
5
|
goldenImage: string;
|
|
6
|
+
/** Diff options */
|
|
7
|
+
imageDiffOptions?: {
|
|
8
|
+
[key: string]: any;
|
|
9
|
+
};
|
|
6
10
|
};
|
|
11
|
+
export declare type SnapshotTestRunnerProps = TestRunnerProps;
|
|
7
12
|
export default class SnapshotTestRunner extends TestRunner {
|
|
8
13
|
private isDiffing;
|
|
9
|
-
constructor(props:
|
|
10
|
-
initTestCase(testCase:
|
|
14
|
+
constructor(props: SnapshotTestRunnerProps);
|
|
15
|
+
initTestCase(testCase: SnapshotTestRunnerTestCase): void;
|
|
11
16
|
shouldRender(): boolean;
|
|
12
|
-
assert(testCase:
|
|
17
|
+
assert(testCase: SnapshotTestRunnerTestCase): Promise<void>;
|
|
13
18
|
}
|
|
14
19
|
//# sourceMappingURL=snapshot-test-runner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"snapshot-test-runner.d.ts","sourceRoot":"","sources":["../src/snapshot-test-runner.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,EAAE,EAAC,
|
|
1
|
+
{"version":3,"file":"snapshot-test-runner.d.ts","sourceRoot":"","sources":["../src/snapshot-test-runner.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,EAAE,EAAC,eAAe,EAAE,kBAAkB,EAAC,MAAM,eAAe,CAAC;AAG9E,2BAA2B;AAC3B,oBAAY,0BAA0B,GAAG,kBAAkB,GAAG;IAC5D,0BAA0B;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,mBAAmB;IACnB,gBAAgB,CAAC,EAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAC,CAAC;CACzC,CAAA;AAED,oBAAY,uBAAuB,GAAG,eAAe,CAAC;AAEtD,MAAM,CAAC,OAAO,OAAO,kBAAmB,SAAQ,UAAU;IACxD,OAAO,CAAC,SAAS,CAAkB;gBAEvB,KAAK,EAAE,uBAAuB;IAKjC,YAAY,CAAC,QAAQ,EAAE,0BAA0B,GAAG,IAAI;IAOxD,YAAY,IAAI,OAAO;IAKjB,MAAM,CAAC,QAAQ,EAAE,0BAA0B,GAAG,OAAO,CAAC,IAAI,CAAC;CAgC3E"}
|
|
@@ -1,49 +1,45 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import TestRunner from
|
|
3
|
-
import { getBoundingBoxInPage } from
|
|
2
|
+
import TestRunner from "./test-runner.js";
|
|
3
|
+
import { getBoundingBoxInPage } from "./utils.js";
|
|
4
4
|
export default class SnapshotTestRunner extends TestRunner {
|
|
5
5
|
constructor(props) {
|
|
6
6
|
super(props);
|
|
7
|
-
|
|
8
7
|
_defineProperty(this, "isDiffing", false);
|
|
9
|
-
|
|
10
8
|
this.testOptions.imageDiffOptions = {};
|
|
11
9
|
}
|
|
12
|
-
|
|
13
10
|
initTestCase(testCase) {
|
|
14
11
|
super.initTestCase(testCase);
|
|
15
|
-
|
|
16
12
|
if (!testCase.goldenImage) {
|
|
17
13
|
throw new Error("Test case ".concat(testCase.name, " does not have golden image"));
|
|
18
14
|
}
|
|
19
15
|
}
|
|
20
|
-
|
|
21
16
|
shouldRender() {
|
|
22
17
|
return !this.isDiffing;
|
|
23
18
|
}
|
|
24
|
-
|
|
25
|
-
|
|
19
|
+
async assert(testCase) {
|
|
20
|
+
var _this$_animationProps;
|
|
26
21
|
if (this.isDiffing) {
|
|
27
22
|
return;
|
|
28
23
|
}
|
|
29
|
-
|
|
30
24
|
this.isDiffing = true;
|
|
31
|
-
const
|
|
25
|
+
const canvas = (_this$_animationProps = this._animationProps) === null || _this$_animationProps === void 0 ? void 0 : _this$_animationProps.canvas;
|
|
26
|
+
if (!(canvas instanceof HTMLCanvasElement)) {
|
|
27
|
+
throw new Error('canvas');
|
|
28
|
+
}
|
|
29
|
+
const diffOptions = {
|
|
30
|
+
...this.testOptions.imageDiffOptions,
|
|
31
|
+
...testCase.imageDiffOptions,
|
|
32
32
|
goldenImage: testCase.goldenImage,
|
|
33
|
-
region: getBoundingBoxInPage(
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
this._next();
|
|
45
|
-
});
|
|
33
|
+
region: getBoundingBoxInPage(canvas)
|
|
34
|
+
};
|
|
35
|
+
const result = await globalThis.browserTestDriver_captureAndDiffScreen(diffOptions);
|
|
36
|
+
if (result.success) {
|
|
37
|
+
this._pass(result);
|
|
38
|
+
} else {
|
|
39
|
+
this._fail(result);
|
|
40
|
+
}
|
|
41
|
+
this.isDiffing = false;
|
|
42
|
+
this._next();
|
|
46
43
|
}
|
|
47
|
-
|
|
48
44
|
}
|
|
49
45
|
//# sourceMappingURL=snapshot-test-runner.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"snapshot-test-runner.js","names":["TestRunner","getBoundingBoxInPage","SnapshotTestRunner","constructor","props","_defineProperty","testOptions","imageDiffOptions","initTestCase","testCase","goldenImage","Error","concat","name","shouldRender","isDiffing","assert","_this$_animationProps","canvas","_animationProps","HTMLCanvasElement","diffOptions","region","result","globalThis","browserTestDriver_captureAndDiffScreen","success","_pass","_fail","_next"],"sources":["../src/snapshot-test-runner.ts"],"sourcesContent":["import TestRunner, {TestRunnerProps, TestRunnerTestCase} from './test-runner';\nimport {getBoundingBoxInPage} from './utils';\n\n/** A snapshot test case */\nexport type SnapshotTestRunnerTestCase = TestRunnerTestCase & {\n /** URL to golden image */\n goldenImage: string;\n /** Diff options */\n imageDiffOptions?: {[key: string]: any}; \n}\n\nexport type SnapshotTestRunnerProps = TestRunnerProps;\n\nexport default class SnapshotTestRunner extends TestRunner {\n private isDiffing: boolean = false;\n\n constructor(props: SnapshotTestRunnerProps) {\n super(props);\n this.testOptions.imageDiffOptions = {};\n }\n\n override initTestCase(testCase: SnapshotTestRunnerTestCase): void {\n super.initTestCase(testCase);\n if (!testCase.goldenImage) {\n throw new Error(`Test case ${testCase.name} does not have golden image`);\n }\n }\n\n override shouldRender(): boolean {\n // wait for the current diffing to finish\n return !this.isDiffing;\n }\n\n override async assert(testCase: SnapshotTestRunnerTestCase): Promise<void> {\n if (this.isDiffing) {\n // Already performing diffing\n return;\n }\n this.isDiffing = true;\n\n const canvas = this._animationProps?.canvas;\n if (!(canvas instanceof HTMLCanvasElement)) {\n throw new Error('canvas');\n }\n\n const diffOptions = {\n ...this.testOptions.imageDiffOptions,\n ...testCase.imageDiffOptions,\n goldenImage: testCase.goldenImage,\n region: getBoundingBoxInPage(canvas)\n };\n\n // Take screenshot and compare\n const result = await globalThis.browserTestDriver_captureAndDiffScreen(diffOptions);\n\n // invoke user callback\n if (result.success) {\n this._pass(result);\n } else {\n this._fail(result);\n }\n\n this.isDiffing = false;\n this._next();\n }\n}\n"],"mappings":";OAAOA,UAAU;AAAA,SACTC,oBAAoB;AAY5B,eAAe,MAAMC,kBAAkB,SAASF,UAAU,CAAC;EAGzDG,WAAWA,CAACC,KAA8B,EAAE;IAC1C,KAAK,CAACA,KAAK,CAAC;IAACC,eAAA,oBAHc,KAAK;IAIhC,IAAI,CAACC,WAAW,CAACC,gBAAgB,GAAG,CAAC,CAAC;EACxC;EAESC,YAAYA,CAACC,QAAoC,EAAQ;IAChE,KAAK,CAACD,YAAY,CAACC,QAAQ,CAAC;IAC5B,IAAI,CAACA,QAAQ,CAACC,WAAW,EAAE;MACzB,MAAM,IAAIC,KAAK,cAAAC,MAAA,CAAcH,QAAQ,CAACI,IAAI,iCAA8B;IAC1E;EACF;EAESC,YAAYA,CAAA,EAAY;IAE/B,OAAO,CAAC,IAAI,CAACC,SAAS;EACxB;EAEA,MAAeC,MAAMA,CAACP,QAAoC,EAAiB;IAAA,IAAAQ,qBAAA;IACzE,IAAI,IAAI,CAACF,SAAS,EAAE;MAElB;IACF;IACA,IAAI,CAACA,SAAS,GAAG,IAAI;IAErB,MAAMG,MAAM,IAAAD,qBAAA,GAAG,IAAI,CAACE,eAAe,cAAAF,qBAAA,uBAApBA,qBAAA,CAAsBC,MAAM;IAC3C,IAAI,EAAEA,MAAM,YAAYE,iBAAiB,CAAC,EAAE;MAC1C,MAAM,IAAIT,KAAK,CAAC,QAAQ,CAAC;IAC3B;IAEA,MAAMU,WAAW,GAAG;MAClB,GAAG,IAAI,CAACf,WAAW,CAACC,gBAAgB;MACpC,GAAGE,QAAQ,CAACF,gBAAgB;MAC5BG,WAAW,EAAED,QAAQ,CAACC,WAAW;MACjCY,MAAM,EAAErB,oBAAoB,CAACiB,MAAM;IACrC,CAAC;IAGD,MAAMK,MAAM,GAAG,MAAMC,UAAU,CAACC,sCAAsC,CAACJ,WAAW,CAAC;IAGnF,IAAIE,MAAM,CAACG,OAAO,EAAE;MAClB,IAAI,CAACC,KAAK,CAACJ,MAAM,CAAC;IACpB,CAAC,MAAM;MACL,IAAI,CAACK,KAAK,CAACL,MAAM,CAAC;IACpB;IAEA,IAAI,CAACR,SAAS,GAAG,KAAK;IACtB,IAAI,CAACc,KAAK,EAAE;EACd;AACF"}
|
package/dist/test-runner.d.ts
CHANGED
|
@@ -1,28 +1,37 @@
|
|
|
1
|
+
import { AnimationProps } from '@luma.gl/webgl-legacy';
|
|
1
2
|
/** Describes a test case */
|
|
2
3
|
export declare type TestRunnerTestCase = {
|
|
3
4
|
/** Name of the test case (for logging) */
|
|
4
5
|
name: string;
|
|
5
6
|
/** Initialize the test case. Can return a promise */
|
|
6
|
-
onInitialize:
|
|
7
|
+
onInitialize: (props: AnimationProps) => Promise<unknown>;
|
|
7
8
|
/** Perform rendering */
|
|
8
|
-
onRender:
|
|
9
|
+
onRender: (props: AnimationProps & {
|
|
10
|
+
done: any;
|
|
11
|
+
}) => void;
|
|
9
12
|
/** Clean up after the test case */
|
|
10
|
-
onFinalize:
|
|
13
|
+
onFinalize: (props: AnimationProps) => void;
|
|
11
14
|
};
|
|
12
15
|
/** Options for a TestRunner */
|
|
13
|
-
export declare type
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
export declare type TestRunnerProps = {
|
|
17
|
+
width?: number;
|
|
18
|
+
height?: number;
|
|
19
|
+
onTestStart?: (testCase: TestRunnerTestCase) => void;
|
|
20
|
+
onTestPass?: (testCase: TestRunnerTestCase) => void;
|
|
21
|
+
onTestFail?: (testCase: TestRunnerTestCase) => void;
|
|
17
22
|
/** milliseconds to wait for each test case before aborting */
|
|
18
23
|
timeout?: number;
|
|
24
|
+
maxFramesToRender?: number;
|
|
25
|
+
imageDiffOptions?: any;
|
|
19
26
|
};
|
|
20
27
|
/** Runs an array of test cases */
|
|
21
28
|
export default class TestRunner {
|
|
22
|
-
|
|
29
|
+
device: import("modules/webgl/dist").WebGLDevice;
|
|
30
|
+
props: Record<string, any>;
|
|
23
31
|
isRunning: boolean;
|
|
24
|
-
readonly testOptions:
|
|
25
|
-
readonly _animationProps
|
|
32
|
+
readonly testOptions: Required<TestRunnerProps>;
|
|
33
|
+
readonly _animationProps?: AnimationProps;
|
|
34
|
+
private _animationLoop;
|
|
26
35
|
private _testCases;
|
|
27
36
|
private _testCaseData;
|
|
28
37
|
isHeadless: boolean;
|
|
@@ -30,25 +39,22 @@ export default class TestRunner {
|
|
|
30
39
|
* props
|
|
31
40
|
* AnimationLoop props
|
|
32
41
|
*/
|
|
33
|
-
constructor(props?:
|
|
34
|
-
/**
|
|
35
|
-
* Add testCase(s)
|
|
36
|
-
*/
|
|
42
|
+
constructor(props?: Record<string, any>);
|
|
37
43
|
/**
|
|
38
44
|
* Add testCase(s)
|
|
39
45
|
*/
|
|
40
46
|
add(testCases: TestRunnerTestCase[]): this;
|
|
41
47
|
/**
|
|
42
|
-
|
|
43
|
-
|
|
48
|
+
* Returns a promise that resolves when all the test cases are done
|
|
49
|
+
*/
|
|
44
50
|
run(options?: object): Promise<void>;
|
|
45
|
-
initTestCase(testCase:
|
|
51
|
+
initTestCase(testCase: TestRunnerTestCase): void;
|
|
46
52
|
shouldRender(animationProps: any): boolean;
|
|
47
|
-
assert(testCase:
|
|
48
|
-
_pass(result:
|
|
49
|
-
_fail(result:
|
|
53
|
+
assert(testCase: TestRunnerTestCase): void;
|
|
54
|
+
_pass(result: unknown): void;
|
|
55
|
+
_fail(result: unknown): void;
|
|
50
56
|
_next(): void;
|
|
51
57
|
_onRender(animationProps: any): void;
|
|
52
|
-
_nextTestCase(): TestRunnerTestCase
|
|
58
|
+
_nextTestCase(): Promise<TestRunnerTestCase>;
|
|
53
59
|
}
|
|
54
60
|
//# sourceMappingURL=test-runner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test-runner.d.ts","sourceRoot":"","sources":["../src/test-runner.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test-runner.d.ts","sourceRoot":"","sources":["../src/test-runner.ts"],"names":[],"mappings":"AAEA,OAAO,EAAgB,cAAc,EAAC,MAAM,uBAAuB,CAAC;AAGpE,4BAA4B;AAC5B,oBAAY,kBAAkB,GAAG;IAC/B,0CAA0C;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,qDAAqD;IACrD,YAAY,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;IAC1D,wBAAwB;IACxB,QAAQ,EAAE,CAAC,KAAK,EAAE,cAAc,GAAG;QAAC,IAAI,MAAA;KAAC,KAAK,IAAI,CAAC;IACnD,mCAAmC;IACnC,UAAU,EAAE,CAAC,KAAK,EAAE,cAAc,KAAK,IAAI,CAAC;CAC7C,CAAC;AAWF,+BAA+B;AAC/B,oBAAY,eAAe,GAAG;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACrD,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACpD,UAAU,CAAC,EAAE,CAAC,QAAQ,EAAE,kBAAkB,KAAK,IAAI,CAAC;IACpD,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAE3B,gBAAgB,CAAC,EAAE,GAAG,CAAC;CACxB,CAAC;AAYF,kCAAkC;AAClC,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B,MAAM,2CAAe;IACrB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC3B,SAAS,EAAE,OAAO,CAAS;IAC3B,QAAQ,CAAC,WAAW,EAAE,QAAQ,CAAC,eAAe,CAAC,CAA2B;IAC1E,QAAQ,CAAC,eAAe,CAAC,EAAE,cAAc,CAAM;IAC/C,OAAO,CAAC,cAAc,CAAuB;IAC7C,OAAO,CAAC,UAAU,CAA4B;IAC9C,OAAO,CAAC,aAAa,CAAa;IAGlC,UAAU,EAAE,OAAO,CAAgD;IAEnE;;;OAGG;gBACS,KAAK,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;IAI3C;;OAEG;IACH,GAAG,CAAC,SAAS,EAAE,kBAAkB,EAAE,GAAG,IAAI;IAU1C;;QAEI;IACJ,GAAG,CAAC,OAAO,GAAE,MAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IA2BxC,YAAY,CAAC,QAAQ,EAAE,kBAAkB;IAYzC,YAAY,CAAC,cAAc,KAAA,GAAG,OAAO;IAIrC,MAAM,CAAC,QAAQ,EAAE,kBAAkB,GAAG,IAAI;IAO1C,KAAK,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAK5B,KAAK,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAK5B,KAAK,IAAI,IAAI;IAMb,SAAS,CAAC,cAAc,KAAA,GAAG,IAAI;IA2C/B,aAAa,IAAI,OAAO,CAAC,kBAAkB,CAAC;CAuD7C"}
|
package/dist/test-runner.js
CHANGED
|
@@ -1,68 +1,66 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
-
import { AnimationLoop } from '@luma.gl/
|
|
3
|
-
import {
|
|
4
|
-
|
|
2
|
+
import { AnimationLoop } from '@luma.gl/webgl-legacy';
|
|
3
|
+
import { webglDevice } from "./create-test-device.js";
|
|
5
4
|
function noop() {}
|
|
6
|
-
|
|
7
5
|
const DEFAULT_TEST_CASE = {
|
|
8
6
|
name: 'Unnamed test',
|
|
9
7
|
onInitialize: noop,
|
|
10
|
-
onRender:
|
|
11
|
-
|
|
12
|
-
|
|
8
|
+
onRender: _ref => {
|
|
9
|
+
let {
|
|
10
|
+
done
|
|
11
|
+
} = _ref;
|
|
12
|
+
return done();
|
|
13
|
+
},
|
|
13
14
|
onFinalize: noop
|
|
14
15
|
};
|
|
15
|
-
const
|
|
16
|
+
const DEFAULT_TEST_PROPS = {
|
|
16
17
|
onTestStart: testCase => console.log("# ".concat(testCase.name)),
|
|
17
18
|
onTestPass: testCase => console.log("ok ".concat(testCase.name, " passed")),
|
|
18
19
|
onTestFail: testCase => console.log("not ok ".concat(testCase.name, " failed")),
|
|
19
20
|
timeout: 2000
|
|
20
21
|
};
|
|
21
22
|
export default class TestRunner {
|
|
22
|
-
constructor(
|
|
23
|
+
constructor() {
|
|
24
|
+
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
25
|
+
_defineProperty(this, "device", webglDevice);
|
|
23
26
|
_defineProperty(this, "props", void 0);
|
|
24
|
-
|
|
25
27
|
_defineProperty(this, "isRunning", false);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
_defineProperty(this, "testOptions", {
|
|
29
|
+
...DEFAULT_TEST_PROPS
|
|
28
30
|
});
|
|
29
|
-
|
|
30
31
|
_defineProperty(this, "_animationProps", {});
|
|
31
|
-
|
|
32
|
+
_defineProperty(this, "_animationLoop", void 0);
|
|
32
33
|
_defineProperty(this, "_testCases", []);
|
|
33
|
-
|
|
34
34
|
_defineProperty(this, "_testCaseData", null);
|
|
35
|
-
|
|
36
35
|
_defineProperty(this, "isHeadless", Boolean(window.browserTestDriver_isHeadless));
|
|
37
|
-
|
|
38
36
|
this.props = props;
|
|
39
37
|
}
|
|
40
|
-
|
|
41
38
|
add(testCases) {
|
|
42
39
|
if (!Array.isArray(testCases)) {
|
|
43
40
|
testCases = [testCases];
|
|
44
41
|
}
|
|
45
|
-
|
|
46
42
|
for (const testCase of testCases) {
|
|
47
43
|
this._testCases.push(testCase);
|
|
48
44
|
}
|
|
49
|
-
|
|
50
45
|
return this;
|
|
51
46
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
run() {
|
|
48
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
49
|
+
this.testOptions = {
|
|
50
|
+
...this.testOptions,
|
|
51
|
+
...options
|
|
52
|
+
};
|
|
53
|
+
return new Promise((resolve, reject) => {
|
|
54
|
+
this._animationLoop = new AnimationLoop({
|
|
55
|
+
...this.props,
|
|
56
|
+
device: this.device,
|
|
57
57
|
onRender: this._onRender.bind(this),
|
|
58
58
|
onFinalize: () => {
|
|
59
59
|
this.isRunning = false;
|
|
60
60
|
resolve();
|
|
61
61
|
}
|
|
62
|
-
})
|
|
63
|
-
|
|
62
|
+
});
|
|
64
63
|
this._animationLoop.start(this.props);
|
|
65
|
-
|
|
66
64
|
this.isRunning = true;
|
|
67
65
|
this.isDiffing = false;
|
|
68
66
|
this._currentTestCase = null;
|
|
@@ -72,120 +70,97 @@ export default class TestRunner {
|
|
|
72
70
|
});
|
|
73
71
|
});
|
|
74
72
|
}
|
|
75
|
-
|
|
76
73
|
initTestCase(testCase) {
|
|
77
74
|
const {
|
|
78
75
|
animationLoop
|
|
79
76
|
} = testCase;
|
|
80
|
-
|
|
81
77
|
if (animationLoop) {
|
|
82
|
-
testCase.onInitialize = animationLoop.onInitialize.bind(animationLoop);
|
|
83
|
-
testCase.onRender = animationLoop.onRender.bind(animationLoop);
|
|
84
|
-
testCase.onFinalize = animationLoop.onFinalize.bind(animationLoop);
|
|
78
|
+
testCase.onInitialize = animationLoop.props.onInitialize.bind(animationLoop);
|
|
79
|
+
testCase.onRender = animationLoop.props.onRender.bind(animationLoop);
|
|
80
|
+
testCase.onFinalize = animationLoop.props.onFinalize.bind(animationLoop);
|
|
85
81
|
}
|
|
86
|
-
|
|
87
82
|
for (const key in DEFAULT_TEST_CASE) {
|
|
88
83
|
testCase[key] = testCase[key] || DEFAULT_TEST_CASE[key];
|
|
89
84
|
}
|
|
90
85
|
}
|
|
91
|
-
|
|
92
86
|
shouldRender(animationProps) {
|
|
93
87
|
return true;
|
|
94
88
|
}
|
|
95
|
-
|
|
96
89
|
assert(testCase) {
|
|
97
90
|
this._pass(testCase);
|
|
98
|
-
|
|
99
91
|
this._next();
|
|
100
92
|
}
|
|
101
|
-
|
|
102
93
|
_pass(result) {
|
|
103
94
|
this.testOptions.onTestPass(this._currentTestCase, result);
|
|
104
95
|
}
|
|
105
|
-
|
|
106
96
|
_fail(result) {
|
|
107
97
|
this.testOptions.onTestFail(this._currentTestCase, result);
|
|
108
98
|
}
|
|
109
|
-
|
|
110
99
|
_next() {
|
|
111
100
|
this._nextTestCase();
|
|
112
101
|
}
|
|
113
|
-
|
|
114
102
|
_onRender(animationProps) {
|
|
115
103
|
this._animationProps = animationProps;
|
|
116
|
-
|
|
117
104
|
const testCase = this._currentTestCase || this._nextTestCase();
|
|
118
|
-
|
|
119
105
|
if (!testCase) {
|
|
120
106
|
this._animationLoop.stop();
|
|
121
|
-
|
|
122
107
|
return;
|
|
123
108
|
}
|
|
124
|
-
|
|
125
109
|
let isDone = false;
|
|
126
|
-
const testCaseAnimationProps =
|
|
110
|
+
const testCaseAnimationProps = {
|
|
111
|
+
...animationProps,
|
|
112
|
+
...this._testCaseData,
|
|
127
113
|
startTime: this._currentTestCaseStartTime,
|
|
128
114
|
time: animationProps.time - this._currentTestCaseStartTime,
|
|
129
115
|
tick: animationProps.tick - this._currentTestCaseStartTick,
|
|
130
116
|
done: () => {
|
|
131
117
|
isDone = true;
|
|
132
118
|
}
|
|
133
|
-
}
|
|
134
|
-
|
|
119
|
+
};
|
|
135
120
|
if (this._testCaseData && this.shouldRender(testCaseAnimationProps)) {
|
|
136
121
|
testCase.onRender(testCaseAnimationProps);
|
|
137
122
|
}
|
|
138
|
-
|
|
139
123
|
const timeout = testCase.timeout || this.testOptions.timeout;
|
|
140
|
-
|
|
141
124
|
if (timeout && testCaseAnimationProps.time > timeout) {
|
|
142
125
|
isDone = true;
|
|
143
126
|
}
|
|
144
|
-
|
|
145
127
|
if (isDone) {
|
|
146
128
|
this.assert(testCase);
|
|
147
129
|
}
|
|
148
130
|
}
|
|
149
|
-
|
|
150
131
|
_nextTestCase() {
|
|
151
132
|
const animationProps = this._animationProps;
|
|
152
|
-
|
|
153
133
|
if (this._testCaseData) {
|
|
154
134
|
for (const key in this._testCaseData) {
|
|
155
135
|
const value = this._testCaseData[key];
|
|
156
|
-
|
|
157
136
|
if (value && value.delete) {
|
|
158
137
|
value.delete();
|
|
159
138
|
}
|
|
160
139
|
}
|
|
161
|
-
|
|
162
140
|
this._currentTestCase.onFinalize(Object.assign({}, animationProps, this._testCaseData));
|
|
163
|
-
|
|
164
|
-
popContextState(animationProps.gl);
|
|
141
|
+
this.device.popState();
|
|
165
142
|
this._currentTestCase = null;
|
|
166
143
|
this._testCaseData = null;
|
|
167
144
|
}
|
|
168
|
-
|
|
169
145
|
const testCase = this._testCases.shift();
|
|
170
|
-
|
|
171
146
|
if (testCase) {
|
|
172
147
|
this._currentTestCase = testCase;
|
|
173
148
|
this._currentTestCaseStartTime = animationProps.time;
|
|
174
149
|
this._currentTestCaseStartTick = animationProps.tick;
|
|
175
150
|
this.initTestCase(testCase);
|
|
176
|
-
|
|
177
|
-
|
|
151
|
+
this.device.pushState();
|
|
152
|
+
const initProps = {
|
|
153
|
+
...animationProps,
|
|
178
154
|
startTime: animationProps.time,
|
|
179
155
|
time: 0,
|
|
180
156
|
tick: 0
|
|
181
|
-
}
|
|
157
|
+
};
|
|
158
|
+
Promise.resolve(testCase.onInitialize(initProps)).then(userData => {
|
|
182
159
|
this._testCaseData = userData || {};
|
|
183
160
|
});
|
|
184
161
|
this.testOptions.onTestStart(testCase);
|
|
185
162
|
}
|
|
186
|
-
|
|
187
163
|
return testCase;
|
|
188
164
|
}
|
|
189
|
-
|
|
190
165
|
}
|
|
191
166
|
//# sourceMappingURL=test-runner.js.map
|
package/dist/test-runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/test-runner.ts"],"names":["AnimationLoop","pushContextState","popContextState","noop","DEFAULT_TEST_CASE","name","onInitialize","onRender","done","onFinalize","DEFAULT_TEST_OPTIONS","onTestStart","testCase","console","log","onTestPass","onTestFail","timeout","TestRunner","constructor","props","Boolean","window","browserTestDriver_isHeadless","add","testCases","Array","isArray","_testCases","push","run","options","Object","assign","testOptions","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;;AAcA,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;AAkBA,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,aAJ8B;AAOxDY,EAAAA,OAAO,EAAE;AAP+C,CAA1D;AAWA,eAAe,MAAMC,UAAN,CAAiB;AAe9BC,EAAAA,WAAW,CAACC,KAAK,GAAG,EAAT,EAAa;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ACC,MAAN;AACD;AACF;;AACD,WAAK1B,gBAAL,CAAsBlC,UAAtB,CAAiCuB,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBmB,cAAlB,EAAkC,KAAKU,aAAvC,CAAjC;;AAGA5D,MAAAA,eAAe,CAACkD,cAAc,CAACkB,EAAhB,CAAf;AAEA,WAAK3B,gBAAL,GAAwB,IAAxB;AACA,WAAKmB,aAAL,GAAqB,IAArB;AACD;;AAGD,UAAMlD,QAAQ,GAAG,KAAKgB,UAAL,CAAgB2C,KAAhB,EAAjB;;AACA,QAAI3D,QAAJ,EAAc;AAEZ,WAAK+B,gBAAL,GAAwB/B,QAAxB;AACA,WAAKoD,yBAAL,GAAiCZ,cAAc,CAACa,IAAhD;AACA,WAAKE,yBAAL,GAAiCf,cAAc,CAACc,IAAhD;AACA,WAAKlB,YAAL,CAAkBpC,QAAlB;AAKAX,MAAAA,gBAAgB,CAACmD,cAAc,CAACkB,EAAhB,CAAhB;AAIAnC,MAAAA,OAAO,CAACC,OAAR,CACExB,QAAQ,CAACN,YAAT,CACE0B,MAAM,CAACC,MAAP,CAAc,EAAd,EAAkBmB,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,WAAKvC,WAAL,CAAiBvB,WAAjB,CAA6BC,QAA7B;AACD;;AACD,WAAOA,QAAP;AACD;;AAhM6B","sourcesContent":["// @ts-nocheck TODO remove\n/* eslint-disable no-console */\nimport {AnimationLoop} from '@luma.gl/core';\nimport {pushContextState, popContextState} from '@luma.gl/webgl';\n\n/** Describes a test case */\nexport type TestRunnerTestCase = {\n /** Name of the test case (for logging) */\n name: string;\n /** Initialize the test case. Can return a promise */\n onInitialize: any;\n /** Perform rendering */\n onRender: any;\n /** Clean up after the test case */\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\n/** Options for a TestRunner */\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\n/** Runs an array of test cases */\nexport default class TestRunner {\n props;\n isRunning = false;\n readonly testOptions: object = {...DEFAULT_TEST_OPTIONS};\n readonly _animationProps: object = {};\n private _testCases: TestRunnerTestCase[] = [];\n private _testCaseData = null;\n\n // @ts-expect-error\n isHeadless: boolean = Boolean(window.browserTestDriver_isHeadless);\n\n /**\n * props\n * AnimationLoop props\n */\n constructor(props = {}) {\n this.props = props;\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"}
|
|
1
|
+
{"version":3,"file":"test-runner.js","names":["AnimationLoop","webglDevice","noop","DEFAULT_TEST_CASE","name","onInitialize","onRender","_ref","done","onFinalize","DEFAULT_TEST_PROPS","onTestStart","testCase","console","log","concat","onTestPass","onTestFail","timeout","TestRunner","constructor","props","arguments","length","undefined","_defineProperty","Boolean","window","browserTestDriver_isHeadless","add","testCases","Array","isArray","_testCases","push","run","options","testOptions","Promise","resolve","reject","_animationLoop","device","_onRender","bind","isRunning","start","isDiffing","_currentTestCase","catch","error","_fail","message","initTestCase","animationLoop","key","shouldRender","animationProps","assert","_pass","_next","result","_nextTestCase","_animationProps","stop","isDone","testCaseAnimationProps","_testCaseData","startTime","_currentTestCaseStartTime","time","tick","_currentTestCaseStartTick","value","delete","Object","assign","popState","shift","pushState","initProps","then","userData"],"sources":["../src/test-runner.ts"],"sourcesContent":["// @ts-nocheck TODO remove\n/* eslint-disable no-console */\nimport {AnimationLoop, AnimationProps} from '@luma.gl/webgl-legacy';\nimport {webglDevice} from './create-test-device';\n\n/** Describes a test case */\nexport type TestRunnerTestCase = {\n /** Name of the test case (for logging) */\n name: string;\n /** Initialize the test case. Can return a promise */\n onInitialize: (props: AnimationProps) => Promise<unknown>;\n /** Perform rendering */\n onRender: (props: AnimationProps & {done}) => void;\n /** Clean up after the test case */\n onFinalize: (props: AnimationProps) => void;\n};\n\nfunction noop() {}\n\nconst DEFAULT_TEST_CASE: TestRunnerTestCase = {\n name: 'Unnamed test',\n onInitialize: noop,\n onRender: ({done}) => done(),\n onFinalize: noop\n};\n\n/** Options for a TestRunner */\nexport type TestRunnerProps = {\n width?: number;\n height?: number;\n // test lifecycle callback\n onTestStart?: (testCase: TestRunnerTestCase) => void;\n onTestPass?: (testCase: TestRunnerTestCase) => void;\n onTestFail?: (testCase: TestRunnerTestCase) => void;\n /** milliseconds to wait for each test case before aborting */\n timeout?: number;\n maxFramesToRender?: number;\n // HACK - this is for the snapshot test runner\n imageDiffOptions?: any;\n};\n\nconst DEFAULT_TEST_PROPS: Required<TestRunnerProps> = {\n // test lifecycle callback\n onTestStart: (testCase: TestRunnerTestCase) => console.log(`# ${testCase.name}`),\n onTestPass: (testCase: TestRunnerTestCase) => console.log(`ok ${testCase.name} passed`),\n onTestFail: (testCase: TestRunnerTestCase) => console.log(`not ok ${testCase.name} failed`),\n\n // milliseconds to wait for each test case before aborting\n timeout: 2000\n};\n\n/** Runs an array of test cases */\nexport default class TestRunner {\n device = webglDevice;\n props: Record<string, any>;\n isRunning: boolean = false;\n readonly testOptions: Required<TestRunnerProps> = {...DEFAULT_TEST_PROPS};\n readonly _animationProps?: AnimationProps = {};\n private _animationLoop: AnimationLoop | null;\n private _testCases: TestRunnerTestCase[] = [];\n private _testCaseData: any = null;\n\n // @ts-expect-error\n isHeadless: boolean = Boolean(window.browserTestDriver_isHeadless);\n\n /**\n * props\n * AnimationLoop props\n */\n constructor(props: Record<string, any> = {}) {\n this.props = props;\n }\n\n /**\n * Add testCase(s)\n */\n add(testCases: TestRunnerTestCase[]): this {\n if (!Array.isArray(testCases)) {\n testCases = [testCases];\n }\n for (const testCase of testCases) {\n this._testCases.push(testCase);\n }\n return this;\n }\n\n /**\n * Returns a promise that resolves when all the test cases are done\n */\n run(options: object = {}): Promise<void> {\n this.testOptions = {...this.testOptions, ...options};\n\n return new Promise<void>((resolve, reject) => {\n this._animationLoop = new AnimationLoop({\n // @ts-expect-error TODO\n ...this.props,\n device: this.device,\n onRender: this._onRender.bind(this),\n onFinalize: () => {\n this.isRunning = false;\n resolve();\n }\n });\n this._animationLoop.start(this.props);\n\n this.isRunning = true;\n this.isDiffing = false;\n this._currentTestCase = null;\n }).catch (error => {\n this._fail({error: error.message});\n // reject(error);\n });\n }\n\n /* Lifecycle methods for subclassing */\n\n initTestCase(testCase: TestRunnerTestCase) {\n const {animationLoop} = testCase;\n if (animationLoop) {\n testCase.onInitialize = animationLoop.props.onInitialize.bind(animationLoop);\n testCase.onRender = animationLoop.props.onRender.bind(animationLoop);\n testCase.onFinalize = animationLoop.props.onFinalize.bind(animationLoop);\n }\n for (const key in DEFAULT_TEST_CASE) {\n testCase[key] = testCase[key] || DEFAULT_TEST_CASE[key];\n }\n }\n\n shouldRender(animationProps): boolean {\n return true;\n }\n\n assert(testCase: TestRunnerTestCase): void {\n this._pass(testCase);\n this._next();\n }\n\n /* Utilities */\n\n _pass(result: unknown): void {\n this.testOptions.onTestPass(this._currentTestCase, result);\n // this._animationLoop?.stop();\n }\n\n _fail(result: unknown): void {\n this.testOptions.onTestFail(this._currentTestCase, result);\n // this._animationLoop?.stop();\n }\n\n _next(): void {\n this._nextTestCase();\n }\n\n /* Private methods */\n\n _onRender(animationProps): void {\n this._animationProps = animationProps;\n\n const testCase = this._currentTestCase || this._nextTestCase();\n if (!testCase) {\n // all test cases are done\n this._animationLoop.stop();\n return;\n }\n\n let isDone = false;\n const testCaseAnimationProps: AnimationProps = {\n ...animationProps, \n ...this._testCaseData,\n // tick/time starts from 0 for each test case\n startTime: this._currentTestCaseStartTime,\n time: animationProps.time - this._currentTestCaseStartTime,\n tick: animationProps.tick - this._currentTestCaseStartTick,\n // called by the test case when it is done rendering and ready for capture and diff\n done: () => {\n isDone = true;\n }\n };\n\n if (this._testCaseData && this.shouldRender(testCaseAnimationProps)) {\n // try {\n // test case is initialized, render frame\n testCase.onRender(testCaseAnimationProps);\n // } catch {\n // isDone = true;\n // }\n }\n\n const timeout = testCase.timeout || this.testOptions.timeout;\n if (timeout && testCaseAnimationProps.time > timeout) {\n isDone = true;\n }\n\n if (isDone) {\n this.assert(testCase);\n }\n }\n\n _nextTestCase(): Promise<TestRunnerTestCase> {\n const animationProps = this._animationProps;\n\n // finalize the current test case\n if (this._testCaseData) {\n for (const key in this._testCaseData) {\n const value = this._testCaseData[key];\n if (value && value.delete) {\n value.delete();\n }\n }\n this._currentTestCase.onFinalize(Object.assign({}, animationProps, this._testCaseData));\n\n // reset WebGL context\n this.device.popState();\n\n this._currentTestCase = null;\n this._testCaseData = null;\n }\n\n // get the next test case\n const testCase = this._testCases.shift();\n if (testCase) {\n // start new test case\n this._currentTestCase = testCase;\n this._currentTestCaseStartTime = animationProps.time;\n this._currentTestCaseStartTick = animationProps.tick;\n this.initTestCase(testCase);\n\n // initialize test case\n\n // save WebGL context\n this.device.pushState();\n\n // aligned with the behavior of AnimationLoop.onInitialized\n // onInitialized could return a plain object or a promise\n const initProps = {\n ...animationProps,\n // tick/time starts from 0 for each test case\n startTime: animationProps.time,\n time: 0,\n tick: 0\n };\n\n // aligned with the behavior of AnimationLoop.onInitialized\n // onInitialized could return a plain object or a promise\n Promise.resolve(testCase.onInitialize(initProps)).then((userData) => {\n this._testCaseData = userData || {};\n });\n\n // invoke user callback\n this.testOptions.onTestStart(testCase);\n }\n return testCase;\n }\n}\n"],"mappings":";AAEA,SAAQA,aAAa,QAAuB,uBAAuB;AAAC,SAC5DC,WAAW;AAcnB,SAASC,IAAIA,CAAA,EAAG,CAAC;AAEjB,MAAMC,iBAAqC,GAAG;EAC5CC,IAAI,EAAE,cAAc;EACpBC,YAAY,EAAEH,IAAI;EAClBI,QAAQ,EAAEC,IAAA;I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,IAAI,CAACoC,gBAAgB,GAAGpC,QAAQ;MAChC,IAAI,CAACyD,yBAAyB,GAAGZ,cAAc,CAACa,IAAI;MACpD,IAAI,CAACE,yBAAyB,GAAGf,cAAc,CAACc,IAAI;MACpD,IAAI,CAAClB,YAAY,CAACzC,QAAQ,CAAC;MAK3B,IAAI,CAAC8B,MAAM,CAACqC,SAAS,EAAE;MAIvB,MAAMC,SAAS,GAAG;QAChB,GAAGvB,cAAc;QAEjBW,SAAS,EAAEX,cAAc,CAACa,IAAI;QAC9BA,IAAI,EAAE,CAAC;QACPC,IAAI,EAAE;MACR,CAAC;MAIDjC,OAAO,CAACC,OAAO,CAAC3B,QAAQ,CAACP,YAAY,CAAC2E,SAAS,CAAC,CAAC,CAACC,IAAI,CAAEC,QAAQ,IAAK;QACnE,IAAI,CAACf,aAAa,GAAGe,QAAQ,IAAI,CAAC,CAAC;MACrC,CAAC,CAAC;MAGF,IAAI,CAAC7C,WAAW,CAAC1B,WAAW,CAACC,QAAQ,CAAC;IACxC;IACA,OAAOA,QAAQ;EACjB;AACF"}
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export declare function getBoundingBoxInPage(domElement:
|
|
2
|
-
x:
|
|
3
|
-
y:
|
|
4
|
-
width:
|
|
5
|
-
height:
|
|
1
|
+
export declare function getBoundingBoxInPage(domElement: HTMLElement): {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
width: number;
|
|
5
|
+
height: number;
|
|
6
6
|
};
|
|
7
7
|
//# sourceMappingURL=utils.d.ts.map
|
package/dist/utils.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,wBAAgB,oBAAoB,CAAC,UAAU,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AACA,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,WAAW,GAAG;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAC;CAAC,CAQpH"}
|