@luma.gl/test-utils 9.0.0-alpha.8 → 9.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +3 -1
- package/dist/check-type.js +0 -1
- package/dist/check-type.js.map +1 -1
- package/dist/create-test-device.d.ts +8 -4
- package/dist/create-test-device.d.ts.map +1 -1
- package/dist/create-test-device.js +26 -13
- package/dist/create-test-device.js.map +1 -1
- package/dist/engine/classic-animation-loop.d.ts +135 -0
- package/dist/engine/classic-animation-loop.d.ts.map +1 -0
- package/dist/engine/classic-animation-loop.js +434 -0
- package/dist/engine/classic-animation-loop.js.map +1 -0
- package/dist/index.cjs +828 -0
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/performance-test-runner.d.ts +7 -6
- package/dist/performance-test-runner.d.ts.map +1 -1
- package/dist/performance-test-runner.js +10 -22
- package/dist/performance-test-runner.js.map +1 -1
- package/dist/register-devices.js +1 -1
- package/dist/register-devices.js.map +1 -1
- package/dist/snapshot-test-runner.d.ts +11 -7
- package/dist/snapshot-test-runner.d.ts.map +1 -1
- package/dist/snapshot-test-runner.js +23 -29
- package/dist/snapshot-test-runner.js.map +1 -1
- package/dist/test-runner.d.ts +35 -23
- package/dist/test-runner.d.ts.map +1 -1
- package/dist/test-runner.js +62 -81
- 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 +28 -8
- package/src/check-type.ts +1 -1
- package/src/create-test-device.ts +28 -9
- package/src/engine/classic-animation-loop.ts +714 -0
- package/src/index.ts +3 -3
- package/src/performance-test-runner.ts +17 -13
- package/src/register-devices.ts +2 -1
- package/src/snapshot-test-runner.ts +33 -31
- package/src/test-runner.ts +100 -75
- package/src/utils.ts +1 -1
package/dist/test-runner.js
CHANGED
|
@@ -1,68 +1,72 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { AnimationLoop } from
|
|
3
|
-
import { pushContextState, popContextState } from '@luma.gl/webgl';
|
|
4
|
-
|
|
5
|
-
function noop() {}
|
|
6
|
-
|
|
1
|
+
import { webglDevice } from "./create-test-device.js";
|
|
2
|
+
import { ClassicAnimationLoop as AnimationLoop } from "./engine/classic-animation-loop.js";
|
|
7
3
|
const DEFAULT_TEST_CASE = {
|
|
8
4
|
name: 'Unnamed test',
|
|
9
|
-
onInitialize:
|
|
10
|
-
onRender:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
5
|
+
onInitialize: async () => {},
|
|
6
|
+
onRender: _ref => {
|
|
7
|
+
let {
|
|
8
|
+
done
|
|
9
|
+
} = _ref;
|
|
10
|
+
return done();
|
|
11
|
+
},
|
|
12
|
+
onFinalize: () => {}
|
|
14
13
|
};
|
|
15
|
-
const
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
const DEFAULT_TEST_PROPS = {
|
|
15
|
+
width: undefined,
|
|
16
|
+
height: undefined,
|
|
17
|
+
onTestStart: testCase => console.log(`# ${testCase.name}`),
|
|
18
|
+
onTestPass: (testCase, result) => console.log(`ok ${testCase.name} passed`),
|
|
19
|
+
onTestFail: (testCase, error) => console.log(`not ok ${testCase.name} failed`),
|
|
20
|
+
timeout: 2000,
|
|
21
|
+
maxFramesToRender: undefined,
|
|
22
|
+
imageDiffOptions: undefined
|
|
20
23
|
};
|
|
21
|
-
export
|
|
22
|
-
constructor(
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
24
|
+
export class TestRunner {
|
|
25
|
+
constructor() {
|
|
26
|
+
let props = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
27
|
+
this.device = webglDevice;
|
|
28
|
+
this.props = void 0;
|
|
29
|
+
this.isRunning = false;
|
|
30
|
+
this.testOptions = {
|
|
31
|
+
...DEFAULT_TEST_PROPS
|
|
32
|
+
};
|
|
33
|
+
this._animationProps = void 0;
|
|
34
|
+
this._animationLoop = void 0;
|
|
35
|
+
this._testCases = [];
|
|
36
|
+
this._testCaseData = null;
|
|
37
|
+
this._currentTestCase = void 0;
|
|
38
|
+
this._currentTestCaseStartTime = void 0;
|
|
39
|
+
this._currentTestCaseStartTick = void 0;
|
|
40
|
+
this.isDiffing = false;
|
|
41
|
+
this.isHeadless = Boolean(window.browserTestDriver_isHeadless);
|
|
38
42
|
this.props = props;
|
|
39
43
|
}
|
|
40
|
-
|
|
41
44
|
add(testCases) {
|
|
42
45
|
if (!Array.isArray(testCases)) {
|
|
43
46
|
testCases = [testCases];
|
|
44
47
|
}
|
|
45
|
-
|
|
46
48
|
for (const testCase of testCases) {
|
|
47
49
|
this._testCases.push(testCase);
|
|
48
50
|
}
|
|
49
|
-
|
|
50
51
|
return this;
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
run() {
|
|
54
|
+
let options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
55
|
+
this.testOptions = {
|
|
56
|
+
...this.testOptions,
|
|
57
|
+
...options
|
|
58
|
+
};
|
|
59
|
+
return new Promise((resolve, reject) => {
|
|
60
|
+
this._animationLoop = new AnimationLoop({
|
|
61
|
+
...this.props,
|
|
62
|
+
device: this.device,
|
|
57
63
|
onRender: this._onRender.bind(this),
|
|
58
64
|
onFinalize: () => {
|
|
59
65
|
this.isRunning = false;
|
|
60
66
|
resolve();
|
|
61
67
|
}
|
|
62
|
-
})
|
|
63
|
-
|
|
68
|
+
});
|
|
64
69
|
this._animationLoop.start(this.props);
|
|
65
|
-
|
|
66
70
|
this.isRunning = true;
|
|
67
71
|
this.isDiffing = false;
|
|
68
72
|
this._currentTestCase = null;
|
|
@@ -72,120 +76,97 @@ export default class TestRunner {
|
|
|
72
76
|
});
|
|
73
77
|
});
|
|
74
78
|
}
|
|
75
|
-
|
|
76
79
|
initTestCase(testCase) {
|
|
77
80
|
const {
|
|
78
81
|
animationLoop
|
|
79
82
|
} = testCase;
|
|
80
|
-
|
|
81
83
|
if (animationLoop) {
|
|
82
|
-
testCase.onInitialize = animationLoop.onInitialize.bind(animationLoop);
|
|
83
|
-
testCase.onRender = animationLoop.onRender.bind(animationLoop);
|
|
84
|
-
testCase.onFinalize = animationLoop.onFinalize.bind(animationLoop);
|
|
84
|
+
testCase.onInitialize = animationLoop.props.onInitialize.bind(animationLoop);
|
|
85
|
+
testCase.onRender = animationLoop.props.onRender.bind(animationLoop);
|
|
86
|
+
testCase.onFinalize = animationLoop.props.onFinalize.bind(animationLoop);
|
|
85
87
|
}
|
|
86
|
-
|
|
87
88
|
for (const key in DEFAULT_TEST_CASE) {
|
|
88
89
|
testCase[key] = testCase[key] || DEFAULT_TEST_CASE[key];
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
|
-
|
|
92
92
|
shouldRender(animationProps) {
|
|
93
93
|
return true;
|
|
94
94
|
}
|
|
95
|
-
|
|
96
95
|
assert(testCase) {
|
|
97
96
|
this._pass(testCase);
|
|
98
|
-
|
|
99
97
|
this._next();
|
|
100
98
|
}
|
|
101
|
-
|
|
102
99
|
_pass(result) {
|
|
103
100
|
this.testOptions.onTestPass(this._currentTestCase, result);
|
|
104
101
|
}
|
|
105
|
-
|
|
106
102
|
_fail(result) {
|
|
107
103
|
this.testOptions.onTestFail(this._currentTestCase, result);
|
|
108
104
|
}
|
|
109
|
-
|
|
110
105
|
_next() {
|
|
111
106
|
this._nextTestCase();
|
|
112
107
|
}
|
|
113
|
-
|
|
114
108
|
_onRender(animationProps) {
|
|
115
109
|
this._animationProps = animationProps;
|
|
116
|
-
|
|
117
110
|
const testCase = this._currentTestCase || this._nextTestCase();
|
|
118
|
-
|
|
119
111
|
if (!testCase) {
|
|
120
112
|
this._animationLoop.stop();
|
|
121
|
-
|
|
122
113
|
return;
|
|
123
114
|
}
|
|
124
|
-
|
|
125
115
|
let isDone = false;
|
|
126
|
-
const testCaseAnimationProps =
|
|
116
|
+
const testCaseAnimationProps = {
|
|
117
|
+
...animationProps,
|
|
118
|
+
...this._testCaseData,
|
|
127
119
|
startTime: this._currentTestCaseStartTime,
|
|
128
120
|
time: animationProps.time - this._currentTestCaseStartTime,
|
|
129
121
|
tick: animationProps.tick - this._currentTestCaseStartTick,
|
|
130
122
|
done: () => {
|
|
131
123
|
isDone = true;
|
|
132
124
|
}
|
|
133
|
-
}
|
|
134
|
-
|
|
125
|
+
};
|
|
135
126
|
if (this._testCaseData && this.shouldRender(testCaseAnimationProps)) {
|
|
136
127
|
testCase.onRender(testCaseAnimationProps);
|
|
137
128
|
}
|
|
138
|
-
|
|
139
129
|
const timeout = testCase.timeout || this.testOptions.timeout;
|
|
140
|
-
|
|
141
130
|
if (timeout && testCaseAnimationProps.time > timeout) {
|
|
142
131
|
isDone = true;
|
|
143
132
|
}
|
|
144
|
-
|
|
145
133
|
if (isDone) {
|
|
146
134
|
this.assert(testCase);
|
|
147
135
|
}
|
|
148
136
|
}
|
|
149
|
-
|
|
150
137
|
_nextTestCase() {
|
|
151
138
|
const animationProps = this._animationProps;
|
|
152
|
-
|
|
153
139
|
if (this._testCaseData) {
|
|
154
140
|
for (const key in this._testCaseData) {
|
|
155
141
|
const value = this._testCaseData[key];
|
|
156
|
-
|
|
157
142
|
if (value && value.delete) {
|
|
158
|
-
value.
|
|
143
|
+
value.destroy();
|
|
159
144
|
}
|
|
160
145
|
}
|
|
161
|
-
|
|
162
146
|
this._currentTestCase.onFinalize(Object.assign({}, animationProps, this._testCaseData));
|
|
163
|
-
|
|
164
|
-
popContextState(animationProps.gl);
|
|
147
|
+
this.device.popState();
|
|
165
148
|
this._currentTestCase = null;
|
|
166
149
|
this._testCaseData = null;
|
|
167
150
|
}
|
|
168
|
-
|
|
169
151
|
const testCase = this._testCases.shift();
|
|
170
|
-
|
|
171
152
|
if (testCase) {
|
|
172
153
|
this._currentTestCase = testCase;
|
|
173
154
|
this._currentTestCaseStartTime = animationProps.time;
|
|
174
155
|
this._currentTestCaseStartTick = animationProps.tick;
|
|
175
156
|
this.initTestCase(testCase);
|
|
176
|
-
|
|
177
|
-
|
|
157
|
+
this.device.pushState();
|
|
158
|
+
const initProps = {
|
|
159
|
+
...animationProps,
|
|
178
160
|
startTime: animationProps.time,
|
|
179
161
|
time: 0,
|
|
180
162
|
tick: 0
|
|
181
|
-
}
|
|
163
|
+
};
|
|
164
|
+
Promise.resolve(testCase.onInitialize(initProps)).then(userData => {
|
|
182
165
|
this._testCaseData = userData || {};
|
|
183
166
|
});
|
|
184
167
|
this.testOptions.onTestStart(testCase);
|
|
185
168
|
}
|
|
186
|
-
|
|
187
169
|
return testCase;
|
|
188
170
|
}
|
|
189
|
-
|
|
190
171
|
}
|
|
191
172
|
//# 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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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":["webglDevice","ClassicAnimationLoop","AnimationLoop","DEFAULT_TEST_CASE","name","onInitialize","onRender","_ref","done","onFinalize","DEFAULT_TEST_PROPS","width","undefined","height","onTestStart","testCase","console","log","onTestPass","result","onTestFail","error","timeout","maxFramesToRender","imageDiffOptions","TestRunner","constructor","props","arguments","length","device","isRunning","testOptions","_animationProps","_animationLoop","_testCases","_testCaseData","_currentTestCase","_currentTestCaseStartTime","_currentTestCaseStartTick","isDiffing","isHeadless","Boolean","window","browserTestDriver_isHeadless","add","testCases","Array","isArray","push","run","options","Promise","resolve","reject","_onRender","bind","start","catch","_fail","message","initTestCase","animationLoop","key","shouldRender","animationProps","assert","_pass","_next","_nextTestCase","stop","isDone","testCaseAnimationProps","startTime","time","tick","value","delete","destroy","Object","assign","popState","shift","pushState","initProps","then","userData"],"sources":["../src/test-runner.ts"],"sourcesContent":["// @ts-nocheck\n/* eslint-disable */\n\nimport {AnimationProps} from '@luma.gl/engine';\nimport {webglDevice} from './create-test-device';\n\n// TODO - Replace with new AnimationLoop from `@luma.gl/engine`\nimport {ClassicAnimationLoop as AnimationLoop} from './engine/classic-animation-loop';\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<void | {}>;\n /** Perform rendering */\n onRender: (props: AnimationProps & {done}) => void;\n /** Clean up after the test case */\n onFinalize: (props: AnimationProps) => void;\n animationLoop?: AnimationLoop;\n};\n\nconst DEFAULT_TEST_CASE: TestRunnerTestCase = {\n name: 'Unnamed test',\n onInitialize: async () => {},\n onRender: ({done}) => done(),\n onFinalize: () => {}\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, result?: unknown) => void;\n onTestFail?: (testCase: TestRunnerTestCase, error?: unknown) => 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 width: undefined,\n height: undefined,\n\n // test lifecycle callback\n onTestStart: (testCase: TestRunnerTestCase) => console.log(`# ${testCase.name}`),\n onTestPass: (testCase: TestRunnerTestCase, result?: unknown) => console.log(`ok ${testCase.name} passed`),\n onTestFail: (testCase: TestRunnerTestCase, error?: unknown) => console.log(`not ok ${testCase.name} failed`),\n\n // milliseconds to wait for each test case before aborting\n timeout: 2000,\n maxFramesToRender: undefined,\n imageDiffOptions: undefined\n};\n\n/** Runs an array of test cases */\nexport class TestRunner {\n device = webglDevice;\n props: Record<string, any>;\n isRunning: boolean = false;\n 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 private _currentTestCase: TestRunnerTestCase | null;\n private _currentTestCaseStartTime: number;\n private _currentTestCaseStartTick: number;\n\n // should be defined in snapshot-test-runner\n isDiffing: boolean = false;\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 ...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.destroy();\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":"SAIQA,WAAW;AAAA,SAGXC,oBAAoB,IAAIC,aAAa;AAe7C,MAAMC,iBAAqC,GAAG;EAC5CC,IAAI,EAAE,cAAc;EACpBC,YAAY,EAAE,MAAAA,CAAA,KAAY,CAAC,CAAC;EAC5BC,QAAQ,EAAEC,IAAA;IAAA,IAAC;MAACC;IAAI,CAAC,GAAAD,IAAA;IAAA,OAAKC,IAAI,CAAC,CAAC;EAAA;EAC5BC,UAAU,EAAEA,CAAA,KAAM,CAAC;AACrB,CAAC;AAiBD,MAAMC,kBAA6C,GAAG;EACpDC,KAAK,EAAEC,SAAS;EAChBC,MAAM,EAAED,SAAS;EAGjB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,GAAG,IAAI;MAC5B,IAAI,CAACD,aAAa,GAAG,IAAI;IAC3B;IAGA,MAAMrB,QAAQ,GAAG,IAAI,CAACoB,UAAU,CAAC+C,KAAK,CAAC,CAAC;IACxC,IAAInE,QAAQ,EAAE;MAEZ,IAAI,CAACsB,gBAAgB,GAAGtB,QAAQ;MAChC,IAAI,CAACuB,yBAAyB,GAAG2B,cAAc,CAACS,IAAI;MACpD,IAAI,CAACnC,yBAAyB,GAAG0B,cAAc,CAACU,IAAI;MACpD,IAAI,CAACd,YAAY,CAAC9C,QAAQ,CAAC;MAK3B,IAAI,CAACe,MAAM,CAACqD,SAAS,CAAC,CAAC;MAIvB,MAAMC,SAAS,GAAG;QAChB,GAAGnB,cAAc;QAEjBQ,SAAS,EAAER,cAAc,CAACS,IAAI;QAC9BA,IAAI,EAAE,CAAC;QACPC,IAAI,EAAE;MACR,CAAC;MAIDvB,OAAO,CAACC,OAAO,CAACtC,QAAQ,CAACV,YAAY,CAAC+E,SAAS,CAAC,CAAC,CAACC,IAAI,CAAEC,QAAQ,IAAK;QACnE,IAAI,CAAClD,aAAa,GAAGkD,QAAQ,IAAI,CAAC,CAAC;MACrC,CAAC,CAAC;MAGF,IAAI,CAACtD,WAAW,CAAClB,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"}
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"
|
|
1
|
+
{"version":3,"file":"utils.js","names":["getBoundingBoxInPage","domElement","bbox","getBoundingClientRect","x","window","scrollX","y","scrollY","width","height"],"sources":["../src/utils.ts"],"sourcesContent":["// Get the bounding box of a DOMElement relative to the page\nexport function getBoundingBoxInPage(domElement: HTMLElement): {x: number; y: number; width: number; height: number;} {\n const bbox = domElement.getBoundingClientRect();\n return {\n x: window.scrollX + bbox.x,\n y: window.scrollY + bbox.y,\n width: bbox.width,\n height: bbox.height\n };\n}\n"],"mappings":"AACA,OAAO,SAASA,oBAAoBA,CAACC,UAAuB,EAA0D;EACpH,MAAMC,IAAI,GAAGD,UAAU,CAACE,qBAAqB,CAAC,CAAC;EAC/C,OAAO;IACLC,CAAC,EAAEC,MAAM,CAACC,OAAO,GAAGJ,IAAI,CAACE,CAAC;IAC1BG,CAAC,EAAEF,MAAM,CAACG,OAAO,GAAGN,IAAI,CAACK,CAAC;IAC1BE,KAAK,EAAEP,IAAI,CAACO,KAAK;IACjBC,MAAM,EAAER,IAAI,CAACQ;EACf,CAAC;AACH"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/test-utils",
|
|
3
|
-
"version": "9.0.0-
|
|
3
|
+
"version": "9.0.0-beta.1",
|
|
4
4
|
"description": "Automated WebGL testing utilities with Puppeteer and image diffing",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"license": "MIT",
|
|
6
7
|
"publishConfig": {
|
|
7
8
|
"access": "public"
|
|
@@ -17,8 +18,15 @@
|
|
|
17
18
|
"testing"
|
|
18
19
|
],
|
|
19
20
|
"types": "dist/index.d.ts",
|
|
20
|
-
"main": "dist/index.
|
|
21
|
+
"main": "dist/index.cjs",
|
|
21
22
|
"module": "dist/index.js",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js",
|
|
27
|
+
"require": "./dist/index.cjs"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
22
30
|
"files": [
|
|
23
31
|
"src",
|
|
24
32
|
"dist",
|
|
@@ -31,13 +39,25 @@
|
|
|
31
39
|
"pre-build": "echo test utils has no bundle"
|
|
32
40
|
},
|
|
33
41
|
"dependencies": {
|
|
34
|
-
"@
|
|
35
|
-
"gl": "
|
|
42
|
+
"@luma.gl/core": "9.0.0-beta.1",
|
|
43
|
+
"@luma.gl/engine": "9.0.0-beta.1",
|
|
44
|
+
"@luma.gl/webgl": "9.0.0-beta.1",
|
|
45
|
+
"@luma.gl/webgpu": "9.0.0-beta.1",
|
|
46
|
+
"@probe.gl/env": "^4.0.2",
|
|
47
|
+
"@types/gl": "^6.0.2",
|
|
48
|
+
"gl": "^6.0.1"
|
|
36
49
|
},
|
|
37
50
|
"peerDependencies": {
|
|
38
|
-
"@luma.gl/
|
|
39
|
-
"@luma.gl/webgl": "9.0.0-alpha.
|
|
40
|
-
"@
|
|
51
|
+
"@luma.gl/core": "9.0.0-alpha.42",
|
|
52
|
+
"@luma.gl/webgl": "9.0.0-alpha.42",
|
|
53
|
+
"@luma.gl/webgpu": "9.0.0-alpha.42",
|
|
54
|
+
"@probe.gl/test-utils": "^4.0.2"
|
|
55
|
+
},
|
|
56
|
+
"engines_comment": [
|
|
57
|
+
"gl needs recent minor version of Node 16.x"
|
|
58
|
+
],
|
|
59
|
+
"engines": {
|
|
60
|
+
"node": ">=16.18.0"
|
|
41
61
|
},
|
|
42
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "5fb42f651e80825336a372ca5a66de7d55611ddf"
|
|
43
63
|
}
|
package/src/check-type.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
// luma.gl, MIT license
|
|
2
|
+
// Copyright (c) vis.gl contributors
|
|
2
3
|
|
|
3
|
-
import type {Device, DeviceProps} from '@luma.gl/
|
|
4
|
-
import {luma} from '@luma.gl/
|
|
4
|
+
import type {Device, DeviceProps} from '@luma.gl/core';
|
|
5
|
+
import {luma} from '@luma.gl/core';
|
|
5
6
|
import {WebGLDevice} from '@luma.gl/webgl';
|
|
6
7
|
import {WebGPUDevice} from '@luma.gl/webgpu';
|
|
7
8
|
|
|
@@ -24,21 +25,34 @@ export function createTestDevice(props: DeviceProps = {}): WebGLDevice | null {
|
|
|
24
25
|
// We dont use luma.createDevice since this tests current expect this context to be created synchronously
|
|
25
26
|
return new WebGLDevice(props);
|
|
26
27
|
} catch (error) {
|
|
27
|
-
|
|
28
|
+
// eslint-disable-next-line no-console
|
|
29
|
+
console.error(`Failed to created device '${props.id}': ${(error as Error).message}`);
|
|
28
30
|
return null;
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
export const
|
|
34
|
+
/** A WebGL 1 Device intended for testing */
|
|
35
|
+
export const webgl1Device: WebGLDevice = createTestDevice({id: 'webgl1-test-device', webgl1: true, webgl2: false}) ;
|
|
36
|
+
/** A WebGL 2 Device intended for testing. Can be null */
|
|
37
|
+
export const webgl2Device: WebGLDevice = createTestDevice({id: 'webgl2-test-device', webgl1: false, webgl2: true}) ;
|
|
38
|
+
/** A WebGL 2 or WebGL 1 Device intended for testing. Best available. */
|
|
39
|
+
export const webglDevice: WebGLDevice = webgl2Device || webgl1Device;
|
|
40
|
+
|
|
34
41
|
/** Only available after getTestDevices() has completed */
|
|
35
|
-
export let
|
|
42
|
+
export let webgpuDevice: WebGPUDevice;
|
|
36
43
|
|
|
37
44
|
let webgpuCreated = false;
|
|
38
45
|
|
|
39
46
|
/** Synchronously get test devices (only WebGLDevices) */
|
|
40
47
|
export function getWebGLTestDevices(): WebGLDevice[] {
|
|
41
|
-
|
|
48
|
+
const devices: WebGLDevice[] = [];
|
|
49
|
+
if (webgl2Device) {
|
|
50
|
+
devices.push(webgl2Device);
|
|
51
|
+
}
|
|
52
|
+
if (webgl1Device) {
|
|
53
|
+
devices.push(webgl1Device);
|
|
54
|
+
}
|
|
55
|
+
return devices;
|
|
42
56
|
}
|
|
43
57
|
|
|
44
58
|
/** Includes WebGPU device if available */
|
|
@@ -46,10 +60,15 @@ export async function getTestDevices() : Promise<Device[]> {
|
|
|
46
60
|
if (!webgpuCreated) {
|
|
47
61
|
webgpuCreated = true;
|
|
48
62
|
try {
|
|
49
|
-
|
|
63
|
+
webgpuDevice = await luma.createDevice({id: 'webgpu-test-device', type: 'webgpu'}) as WebGPUDevice;
|
|
50
64
|
} catch {
|
|
51
65
|
// ignore (assume WebGPU was not available)
|
|
52
66
|
}
|
|
53
67
|
}
|
|
54
|
-
|
|
68
|
+
|
|
69
|
+
const devices: Device[] = getWebGLTestDevices();
|
|
70
|
+
if (webgpuDevice) {
|
|
71
|
+
devices.unshift(webgpuDevice);
|
|
72
|
+
}
|
|
73
|
+
return devices;
|
|
55
74
|
}
|