@luma.gl/test-utils 9.0.0-beta.4 → 9.0.0-beta.5
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 +5 -2
- package/dist/create-test-device.d.ts +2 -6
- package/dist/create-test-device.d.ts.map +1 -1
- package/dist/create-test-device.js +43 -54
- package/dist/engine/classic-animation-loop.d.ts +5 -5
- package/dist/engine/classic-animation-loop.d.ts.map +1 -1
- package/dist/engine/classic-animation-loop.js +515 -422
- package/dist/index.cjs +57 -38
- package/dist/index.cjs.map +7 -0
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -7
- package/dist/performance-test-runner.js +36 -43
- package/dist/register-devices.js +3 -4
- package/dist/snapshot-test-runner.js +42 -37
- package/dist/test-runner.js +181 -154
- package/dist/utils/check-type.d.ts +6 -0
- package/dist/utils/check-type.d.ts.map +1 -0
- package/dist/utils/check-type.js +5 -0
- package/dist/utils/deep-copy.d.ts +3 -0
- package/dist/utils/deep-copy.d.ts.map +1 -0
- package/dist/utils/deep-copy.js +14 -0
- package/dist/utils/get-bounding-box.d.ts +7 -0
- package/dist/utils/get-bounding-box.d.ts.map +1 -0
- package/dist/utils/get-bounding-box.js +10 -0
- package/dist/utils/resource-tracker.d.ts +6 -0
- package/dist/utils/resource-tracker.d.ts.map +1 -0
- package/dist/utils/resource-tracker.js +23 -0
- package/dist/utils.js +8 -8
- package/package.json +17 -25
- package/src/create-test-device.ts +4 -13
- package/src/engine/classic-animation-loop.ts +5 -9
- package/src/index.ts +9 -2
- package/src/register-devices.ts +1 -4
- package/src/snapshot-test-runner.ts +1 -1
- package/src/utils/deep-copy.ts +16 -0
- package/src/utils/resource-tracker.ts +24 -0
- package/dist/check-type.js.map +0 -1
- package/dist/create-test-device.js.map +0 -1
- package/dist/engine/classic-animation-loop.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/performance-test-runner.js.map +0 -1
- package/dist/register-devices.js.map +0 -1
- package/dist/snapshot-test-runner.js.map +0 -1
- package/dist/test-runner.js.map +0 -1
- package/dist/utils.js.map +0 -1
- /package/src/{check-type.ts → utils/check-type.ts} +0 -0
- /package/src/{utils.ts → utils/get-bounding-box.ts} +0 -0
package/dist/test-runner.js
CHANGED
|
@@ -1,172 +1,199 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
import { webglDevice } from './create-test-device';
|
|
4
|
+
// TODO - Replace with new AnimationLoop from `@luma.gl/engine`
|
|
5
|
+
import { ClassicAnimationLoop as AnimationLoop } from './engine/classic-animation-loop';
|
|
3
6
|
const DEFAULT_TEST_CASE = {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
done
|
|
9
|
-
} = _ref;
|
|
10
|
-
return done();
|
|
11
|
-
},
|
|
12
|
-
onFinalize: () => {}
|
|
7
|
+
name: 'Unnamed test',
|
|
8
|
+
onInitialize: async () => { },
|
|
9
|
+
onRender: ({ done }) => done(),
|
|
10
|
+
onFinalize: () => { }
|
|
13
11
|
};
|
|
14
12
|
const DEFAULT_TEST_PROPS = {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
13
|
+
width: undefined,
|
|
14
|
+
height: undefined,
|
|
15
|
+
// test lifecycle callback
|
|
16
|
+
onTestStart: (testCase) => console.log(`# ${testCase.name}`),
|
|
17
|
+
onTestPass: (testCase, result) => console.log(`ok ${testCase.name} passed`),
|
|
18
|
+
onTestFail: (testCase, error) => console.log(`not ok ${testCase.name} failed`),
|
|
19
|
+
// milliseconds to wait for each test case before aborting
|
|
20
|
+
timeout: 2000,
|
|
21
|
+
maxFramesToRender: undefined,
|
|
22
|
+
imageDiffOptions: undefined
|
|
23
23
|
};
|
|
24
|
+
/** Runs an array of test cases */
|
|
24
25
|
export class TestRunner {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
testCases = [testCases];
|
|
26
|
+
device = webglDevice;
|
|
27
|
+
props;
|
|
28
|
+
isRunning = false;
|
|
29
|
+
testOptions = { ...DEFAULT_TEST_PROPS };
|
|
30
|
+
_animationProps;
|
|
31
|
+
_animationLoop;
|
|
32
|
+
_testCases = [];
|
|
33
|
+
_testCaseData = null;
|
|
34
|
+
_currentTestCase;
|
|
35
|
+
_currentTestCaseStartTime;
|
|
36
|
+
_currentTestCaseStartTick;
|
|
37
|
+
// should be defined in snapshot-test-runner
|
|
38
|
+
isDiffing = false;
|
|
39
|
+
// @ts-expect-error
|
|
40
|
+
isHeadless = Boolean(window.browserTestDriver_isHeadless);
|
|
41
|
+
/**
|
|
42
|
+
* props
|
|
43
|
+
* AnimationLoop props
|
|
44
|
+
*/
|
|
45
|
+
constructor(props = {}) {
|
|
46
|
+
this.props = props;
|
|
47
47
|
}
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
/**
|
|
49
|
+
* Add testCase(s)
|
|
50
|
+
*/
|
|
51
|
+
add(testCases) {
|
|
52
|
+
if (!Array.isArray(testCases)) {
|
|
53
|
+
testCases = [testCases];
|
|
54
|
+
}
|
|
55
|
+
for (const testCase of testCases) {
|
|
56
|
+
this._testCases.push(testCase);
|
|
57
|
+
}
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Returns a promise that resolves when all the test cases are done
|
|
62
|
+
*/
|
|
63
|
+
run(options = {}) {
|
|
64
|
+
this.testOptions = { ...this.testOptions, ...options };
|
|
65
|
+
return new Promise((resolve, reject) => {
|
|
66
|
+
this._animationLoop = new AnimationLoop({
|
|
67
|
+
...this.props,
|
|
68
|
+
device: this.device,
|
|
69
|
+
onRender: this._onRender.bind(this),
|
|
70
|
+
onFinalize: () => {
|
|
71
|
+
this.isRunning = false;
|
|
72
|
+
resolve();
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
this._animationLoop.start(this.props);
|
|
76
|
+
this.isRunning = true;
|
|
77
|
+
this.isDiffing = false;
|
|
78
|
+
this._currentTestCase = null;
|
|
79
|
+
}).catch(error => {
|
|
80
|
+
this._fail({ error: error.message });
|
|
81
|
+
// reject(error);
|
|
82
|
+
});
|
|
50
83
|
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
...this.props,
|
|
62
|
-
device: this.device,
|
|
63
|
-
onRender: this._onRender.bind(this),
|
|
64
|
-
onFinalize: () => {
|
|
65
|
-
this.isRunning = false;
|
|
66
|
-
resolve();
|
|
84
|
+
/* Lifecycle methods for subclassing */
|
|
85
|
+
initTestCase(testCase) {
|
|
86
|
+
const { animationLoop } = testCase;
|
|
87
|
+
if (animationLoop) {
|
|
88
|
+
testCase.onInitialize = animationLoop.props.onInitialize.bind(animationLoop);
|
|
89
|
+
testCase.onRender = animationLoop.props.onRender.bind(animationLoop);
|
|
90
|
+
testCase.onFinalize = animationLoop.props.onFinalize.bind(animationLoop);
|
|
91
|
+
}
|
|
92
|
+
for (const key in DEFAULT_TEST_CASE) {
|
|
93
|
+
testCase[key] = testCase[key] || DEFAULT_TEST_CASE[key];
|
|
67
94
|
}
|
|
68
|
-
});
|
|
69
|
-
this._animationLoop.start(this.props);
|
|
70
|
-
this.isRunning = true;
|
|
71
|
-
this.isDiffing = false;
|
|
72
|
-
this._currentTestCase = null;
|
|
73
|
-
}).catch(error => {
|
|
74
|
-
this._fail({
|
|
75
|
-
error: error.message
|
|
76
|
-
});
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
initTestCase(testCase) {
|
|
80
|
-
const {
|
|
81
|
-
animationLoop
|
|
82
|
-
} = testCase;
|
|
83
|
-
if (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);
|
|
87
95
|
}
|
|
88
|
-
|
|
89
|
-
|
|
96
|
+
shouldRender(animationProps) {
|
|
97
|
+
return true;
|
|
90
98
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
assert(testCase) {
|
|
96
|
-
this._pass(testCase);
|
|
97
|
-
this._next();
|
|
98
|
-
}
|
|
99
|
-
_pass(result) {
|
|
100
|
-
this.testOptions.onTestPass(this._currentTestCase, result);
|
|
101
|
-
}
|
|
102
|
-
_fail(result) {
|
|
103
|
-
this.testOptions.onTestFail(this._currentTestCase, result);
|
|
104
|
-
}
|
|
105
|
-
_next() {
|
|
106
|
-
this._nextTestCase();
|
|
107
|
-
}
|
|
108
|
-
_onRender(animationProps) {
|
|
109
|
-
this._animationProps = animationProps;
|
|
110
|
-
const testCase = this._currentTestCase || this._nextTestCase();
|
|
111
|
-
if (!testCase) {
|
|
112
|
-
this._animationLoop.stop();
|
|
113
|
-
return;
|
|
99
|
+
assert(testCase) {
|
|
100
|
+
this._pass(testCase);
|
|
101
|
+
this._next();
|
|
114
102
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
startTime: this._currentTestCaseStartTime,
|
|
120
|
-
time: animationProps.time - this._currentTestCaseStartTime,
|
|
121
|
-
tick: animationProps.tick - this._currentTestCaseStartTick,
|
|
122
|
-
done: () => {
|
|
123
|
-
isDone = true;
|
|
124
|
-
}
|
|
125
|
-
};
|
|
126
|
-
if (this._testCaseData && this.shouldRender(testCaseAnimationProps)) {
|
|
127
|
-
testCase.onRender(testCaseAnimationProps);
|
|
103
|
+
/* Utilities */
|
|
104
|
+
_pass(result) {
|
|
105
|
+
this.testOptions.onTestPass(this._currentTestCase, result);
|
|
106
|
+
// this._animationLoop?.stop();
|
|
128
107
|
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
108
|
+
_fail(result) {
|
|
109
|
+
this.testOptions.onTestFail(this._currentTestCase, result);
|
|
110
|
+
// this._animationLoop?.stop();
|
|
132
111
|
}
|
|
133
|
-
|
|
134
|
-
|
|
112
|
+
_next() {
|
|
113
|
+
this._nextTestCase();
|
|
135
114
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
115
|
+
/* Private methods */
|
|
116
|
+
_onRender(animationProps) {
|
|
117
|
+
this._animationProps = animationProps;
|
|
118
|
+
const testCase = this._currentTestCase || this._nextTestCase();
|
|
119
|
+
if (!testCase) {
|
|
120
|
+
// all test cases are done
|
|
121
|
+
this._animationLoop.stop();
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
let isDone = false;
|
|
125
|
+
const testCaseAnimationProps = {
|
|
126
|
+
...animationProps,
|
|
127
|
+
...this._testCaseData,
|
|
128
|
+
// tick/time starts from 0 for each test case
|
|
129
|
+
startTime: this._currentTestCaseStartTime,
|
|
130
|
+
time: animationProps.time - this._currentTestCaseStartTime,
|
|
131
|
+
tick: animationProps.tick - this._currentTestCaseStartTick,
|
|
132
|
+
// called by the test case when it is done rendering and ready for capture and diff
|
|
133
|
+
done: () => {
|
|
134
|
+
isDone = true;
|
|
135
|
+
}
|
|
136
|
+
};
|
|
137
|
+
if (this._testCaseData && this.shouldRender(testCaseAnimationProps)) {
|
|
138
|
+
// try {
|
|
139
|
+
// test case is initialized, render frame
|
|
140
|
+
testCase.onRender(testCaseAnimationProps);
|
|
141
|
+
// } catch {
|
|
142
|
+
// isDone = true;
|
|
143
|
+
// }
|
|
144
|
+
}
|
|
145
|
+
const timeout = testCase.timeout || this.testOptions.timeout;
|
|
146
|
+
if (timeout && testCaseAnimationProps.time > timeout) {
|
|
147
|
+
isDone = true;
|
|
148
|
+
}
|
|
149
|
+
if (isDone) {
|
|
150
|
+
this.assert(testCase);
|
|
144
151
|
}
|
|
145
|
-
}
|
|
146
|
-
this._currentTestCase.onFinalize(Object.assign({}, animationProps, this._testCaseData));
|
|
147
|
-
this.device.popState();
|
|
148
|
-
this._currentTestCase = null;
|
|
149
|
-
this._testCaseData = null;
|
|
150
152
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
153
|
+
_nextTestCase() {
|
|
154
|
+
const animationProps = this._animationProps;
|
|
155
|
+
// finalize the current test case
|
|
156
|
+
if (this._testCaseData) {
|
|
157
|
+
for (const key in this._testCaseData) {
|
|
158
|
+
const value = this._testCaseData[key];
|
|
159
|
+
if (value && value.delete) {
|
|
160
|
+
value.destroy();
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
this._currentTestCase.onFinalize(Object.assign({}, animationProps, this._testCaseData));
|
|
164
|
+
// reset WebGL context
|
|
165
|
+
this.device.popState();
|
|
166
|
+
this._currentTestCase = null;
|
|
167
|
+
this._testCaseData = null;
|
|
168
|
+
}
|
|
169
|
+
// get the next test case
|
|
170
|
+
const testCase = this._testCases.shift();
|
|
171
|
+
if (testCase) {
|
|
172
|
+
// start new test case
|
|
173
|
+
this._currentTestCase = testCase;
|
|
174
|
+
this._currentTestCaseStartTime = animationProps.time;
|
|
175
|
+
this._currentTestCaseStartTick = animationProps.tick;
|
|
176
|
+
this.initTestCase(testCase);
|
|
177
|
+
// initialize test case
|
|
178
|
+
// save WebGL context
|
|
179
|
+
this.device.pushState();
|
|
180
|
+
// aligned with the behavior of AnimationLoop.onInitialized
|
|
181
|
+
// onInitialized could return a plain object or a promise
|
|
182
|
+
const initProps = {
|
|
183
|
+
...animationProps,
|
|
184
|
+
// tick/time starts from 0 for each test case
|
|
185
|
+
startTime: animationProps.time,
|
|
186
|
+
time: 0,
|
|
187
|
+
tick: 0
|
|
188
|
+
};
|
|
189
|
+
// aligned with the behavior of AnimationLoop.onInitialized
|
|
190
|
+
// onInitialized could return a plain object or a promise
|
|
191
|
+
Promise.resolve(testCase.onInitialize(initProps)).then((userData) => {
|
|
192
|
+
this._testCaseData = userData || {};
|
|
193
|
+
});
|
|
194
|
+
// invoke user callback
|
|
195
|
+
this.testOptions.onTestStart(testCase);
|
|
196
|
+
}
|
|
197
|
+
return testCase;
|
|
168
198
|
}
|
|
169
|
-
return testCase;
|
|
170
|
-
}
|
|
171
199
|
}
|
|
172
|
-
//# sourceMappingURL=test-runner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"check-type.d.ts","sourceRoot":"","sources":["../../src/utils/check-type.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,IAAI,CAAG"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deep-copy.d.ts","sourceRoot":"","sources":["../../src/utils/deep-copy.ts"],"names":[],"mappings":"AAAA,iCAAiC;AACjC,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,OAcnD"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** Recursively copies objects */
|
|
2
|
+
export function deepCopy(object) {
|
|
3
|
+
if (Array.isArray(object)) {
|
|
4
|
+
return object.map((element) => deepCopy(element));
|
|
5
|
+
}
|
|
6
|
+
if (object !== null && typeof object === 'object') {
|
|
7
|
+
const newObject = {};
|
|
8
|
+
for (const key in object) {
|
|
9
|
+
newObject[key] = deepCopy(object[key]);
|
|
10
|
+
}
|
|
11
|
+
return newObject;
|
|
12
|
+
}
|
|
13
|
+
return object;
|
|
14
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-bounding-box.d.ts","sourceRoot":"","sources":["../../src/utils/get-bounding-box.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"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Get the bounding box of a DOMElement relative to the page
|
|
2
|
+
export function getBoundingBoxInPage(domElement) {
|
|
3
|
+
const bbox = domElement.getBoundingClientRect();
|
|
4
|
+
return {
|
|
5
|
+
x: window.scrollX + bbox.x,
|
|
6
|
+
y: window.scrollY + bbox.y,
|
|
7
|
+
width: bbox.width,
|
|
8
|
+
height: bbox.height
|
|
9
|
+
};
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resource-tracker.d.ts","sourceRoot":"","sources":["../../src/utils/resource-tracker.ts"],"names":[],"mappings":"AACA,wBAAgB,iBAAiB;;;EAOhC;AAED,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,GAAG,IAAI,CAaxH"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/* global luma */
|
|
2
|
+
export function getResourceCounts() {
|
|
3
|
+
// @ts-ignore
|
|
4
|
+
const resourceStats = luma.stats.get('Resource Counts');
|
|
5
|
+
return {
|
|
6
|
+
Texture2D: resourceStats.get('Texture2Ds Active').count,
|
|
7
|
+
Buffer: resourceStats.get('Buffers Active').count
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
export function getLeakedResources(startCounts, endCounts) {
|
|
11
|
+
let leakedResources = null;
|
|
12
|
+
const info = 'leaking: ';
|
|
13
|
+
for (const resourceName in endCounts) {
|
|
14
|
+
const leakCount = endCounts[resourceName] - startCounts[resourceName];
|
|
15
|
+
if (leakCount !== 0) {
|
|
16
|
+
leakedResources = Object.assign({}, leakedResources, {
|
|
17
|
+
[resourceName]: leakCount,
|
|
18
|
+
info: `${info} ${resourceName}: ${leakCount}, `
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
return leakedResources;
|
|
23
|
+
}
|
package/dist/utils.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
// Get the bounding box of a DOMElement relative to the page
|
|
1
2
|
export function getBoundingBoxInPage(domElement) {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
3
|
+
const bbox = domElement.getBoundingClientRect();
|
|
4
|
+
return {
|
|
5
|
+
x: window.scrollX + bbox.x,
|
|
6
|
+
y: window.scrollY + bbox.y,
|
|
7
|
+
width: bbox.width,
|
|
8
|
+
height: bbox.height
|
|
9
|
+
};
|
|
9
10
|
}
|
|
10
|
-
//# sourceMappingURL=utils.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luma.gl/test-utils",
|
|
3
|
-
"version": "9.0.0-beta.
|
|
3
|
+
"version": "9.0.0-beta.5",
|
|
4
4
|
"description": "Automated WebGL testing utilities with Puppeteer and image diffing",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
"url": "https://github.com/visgl/luma.gl"
|
|
13
13
|
},
|
|
14
14
|
"keywords": [
|
|
15
|
-
"
|
|
15
|
+
"webgpu",
|
|
16
16
|
"webgl",
|
|
17
17
|
"automation",
|
|
18
|
-
"
|
|
18
|
+
"test"
|
|
19
19
|
],
|
|
20
20
|
"types": "dist/index.d.ts",
|
|
21
21
|
"main": "dist/index.cjs",
|
|
@@ -32,32 +32,24 @@
|
|
|
32
32
|
"dist",
|
|
33
33
|
"README.md"
|
|
34
34
|
],
|
|
35
|
-
"browser": {
|
|
36
|
-
"gl": false
|
|
37
|
-
},
|
|
38
35
|
"scripts": {
|
|
39
36
|
"pre-build": "echo test utils has no bundle"
|
|
40
37
|
},
|
|
41
|
-
"dependencies": {
|
|
42
|
-
"@luma.gl/core": "9.0.0-beta.4",
|
|
43
|
-
"@luma.gl/engine": "9.0.0-beta.4",
|
|
44
|
-
"@luma.gl/webgl": "9.0.0-beta.4",
|
|
45
|
-
"@luma.gl/webgpu": "9.0.0-beta.4",
|
|
46
|
-
"@probe.gl/env": "^4.0.2",
|
|
47
|
-
"@types/gl": "^6.0.2",
|
|
48
|
-
"gl": "^6.0.1"
|
|
49
|
-
},
|
|
50
38
|
"peerDependencies": {
|
|
51
|
-
"@luma.gl/core": "9.0.0-beta.
|
|
52
|
-
"@luma.gl/
|
|
53
|
-
"@luma.gl/
|
|
54
|
-
"@
|
|
39
|
+
"@luma.gl/core": "^9.0.0-beta.4",
|
|
40
|
+
"@luma.gl/engine": "^9.0.0-beta.4",
|
|
41
|
+
"@luma.gl/shadertools": "^9.0.0-beta.4",
|
|
42
|
+
"@luma.gl/webgl": "^9.0.0-beta.4",
|
|
43
|
+
"@luma.gl/webgpu": "^9.0.0-beta.4"
|
|
44
|
+
},
|
|
45
|
+
"devDependencies": {
|
|
46
|
+
"@luma.gl/core": "9.0.0-beta.5",
|
|
47
|
+
"@luma.gl/engine": "9.0.0-beta.5",
|
|
48
|
+
"@luma.gl/webgl": "9.0.0-beta.5",
|
|
49
|
+
"@luma.gl/webgpu": "9.0.0-beta.5"
|
|
55
50
|
},
|
|
56
|
-
"
|
|
57
|
-
"gl
|
|
58
|
-
],
|
|
59
|
-
"engines": {
|
|
60
|
-
"node": ">=16.18.0"
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"@probe.gl/env": "^4.0.2"
|
|
61
53
|
},
|
|
62
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "793d3ab42f5a572b6cb603ea78aabaa73a873301"
|
|
63
55
|
}
|
|
@@ -13,7 +13,7 @@ const CONTEXT_DEFAULTS: Partial<DeviceProps> = {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
/** Create a test WebGL context */
|
|
16
|
-
export function createTestContext(opts: Record<string, any> = {}):
|
|
16
|
+
export function createTestContext(opts: Record<string, any> = {}): WebGL2RenderingContext | null {
|
|
17
17
|
const device = createTestDevice(opts);
|
|
18
18
|
return device && device.gl;
|
|
19
19
|
}
|
|
@@ -31,12 +31,8 @@ export function createTestDevice(props: DeviceProps = {}): WebGLDevice | null {
|
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
/** A WebGL
|
|
35
|
-
export const
|
|
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;
|
|
34
|
+
/** A WebGL 2 Device intended for testing */
|
|
35
|
+
export const webglDevice: WebGLDevice = createTestDevice({id: 'webgl2-test-device'}) ;
|
|
40
36
|
|
|
41
37
|
/** Only available after getTestDevices() has completed */
|
|
42
38
|
export let webgpuDevice: WebGPUDevice;
|
|
@@ -46,12 +42,7 @@ let webgpuCreated = false;
|
|
|
46
42
|
/** Synchronously get test devices (only WebGLDevices) */
|
|
47
43
|
export function getWebGLTestDevices(): WebGLDevice[] {
|
|
48
44
|
const devices: WebGLDevice[] = [];
|
|
49
|
-
|
|
50
|
-
devices.push(webgl2Device);
|
|
51
|
-
}
|
|
52
|
-
if (webgl1Device) {
|
|
53
|
-
devices.push(webgl1Device);
|
|
54
|
-
}
|
|
45
|
+
devices.push(webglDevice);
|
|
55
46
|
return devices;
|
|
56
47
|
}
|
|
57
48
|
|
|
@@ -12,7 +12,7 @@ import {Timeline, AnimationProps} from '@luma.gl/engine';
|
|
|
12
12
|
import {Stats, Stat} from '@probe.gl/stats';
|
|
13
13
|
import {isBrowser} from '@probe.gl/env';
|
|
14
14
|
|
|
15
|
-
import {
|
|
15
|
+
import {resetGLParameters} from '@luma.gl/webgl';
|
|
16
16
|
// import {default as Query} from '../classic/query';
|
|
17
17
|
// import {ClassicFramebuffer} from '../classic/framebuffer';
|
|
18
18
|
|
|
@@ -41,7 +41,7 @@ export type ClassicAnimationProps = AnimationProps & {
|
|
|
41
41
|
stop: () => ClassicAnimationLoop;
|
|
42
42
|
|
|
43
43
|
/** @deprecated Use .device */
|
|
44
|
-
gl:
|
|
44
|
+
gl: WebGL2RenderingContext;
|
|
45
45
|
/** @deprecated Will be removed */
|
|
46
46
|
framebuffer: unknown;
|
|
47
47
|
|
|
@@ -56,7 +56,7 @@ export type ClassicAnimationProps = AnimationProps & {
|
|
|
56
56
|
/** ClassicAnimationLoop properties */
|
|
57
57
|
export type ClassicAnimationLoopProps = {
|
|
58
58
|
onCreateDevice?: (props: DeviceProps) => Promise<Device>;
|
|
59
|
-
onCreateContext?: (props: ContextProps) =>
|
|
59
|
+
onCreateContext?: (props: ContextProps) => WebGL2RenderingContext; // TODO: signature from createGLContext
|
|
60
60
|
onAddHTML?: (div: HTMLDivElement) => string; // innerHTML
|
|
61
61
|
onInitialize?: (animationProps: ClassicAnimationProps) => {} | void | Promise<{} | void>;
|
|
62
62
|
onRender?: (animationProps: ClassicAnimationProps) => void;
|
|
@@ -75,7 +75,7 @@ export type ClassicAnimationLoopProps = {
|
|
|
75
75
|
useDevicePixels?: number | boolean;
|
|
76
76
|
|
|
77
77
|
/** @deprecated Use .device */
|
|
78
|
-
gl?:
|
|
78
|
+
gl?: WebGL2RenderingContext | null;
|
|
79
79
|
/** @deprecated Will be removed */
|
|
80
80
|
createFramebuffer?: boolean;
|
|
81
81
|
};
|
|
@@ -137,7 +137,7 @@ export class ClassicAnimationLoop {
|
|
|
137
137
|
// _gpuTimeQuery: Query | null = null;
|
|
138
138
|
|
|
139
139
|
/** @deprecated */
|
|
140
|
-
gl:
|
|
140
|
+
gl: WebGL2RenderingContext;
|
|
141
141
|
|
|
142
142
|
/*
|
|
143
143
|
*/
|
|
@@ -575,10 +575,6 @@ export class ClassicAnimationLoop {
|
|
|
575
575
|
// @ts-expect-error
|
|
576
576
|
this.gl = this.device.gl;
|
|
577
577
|
|
|
578
|
-
if (!isWebGL(this.gl)) {
|
|
579
|
-
throw new Error('ClassicAnimationLoop.onCreateContext - illegal context returned');
|
|
580
|
-
}
|
|
581
|
-
|
|
582
578
|
// Reset the WebGL context.
|
|
583
579
|
resetGLParameters(this.gl);
|
|
584
580
|
|
package/src/index.ts
CHANGED
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
import './register-devices';
|
|
2
2
|
|
|
3
|
+
// TEST RUNNERS
|
|
3
4
|
export type {TestRunnerTestCase} from './test-runner';
|
|
4
5
|
export type {SnapshotTestRunnerTestCase} from './snapshot-test-runner';
|
|
5
6
|
|
|
6
7
|
export {SnapshotTestRunner} from './snapshot-test-runner';
|
|
7
8
|
export {PerformanceTestRunner} from './performance-test-runner';
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
// TEST DEVICES
|
|
11
|
+
export {webglDevice, webgpuDevice} from './create-test-device';
|
|
9
12
|
export {getTestDevices, getWebGLTestDevices} from './create-test-device';
|
|
13
|
+
export {createTestDevice, createTestContext} from './create-test-device';
|
|
10
14
|
|
|
11
|
-
|
|
15
|
+
// UTILS
|
|
16
|
+
export {checkType} from './utils/check-type';
|
|
17
|
+
export {deepCopy} from './utils/deep-copy';
|
|
18
|
+
export {getResourceCounts, getLeakedResources} from './utils/resource-tracker';
|