@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.
Files changed (48) hide show
  1. package/dist/check-type.js +5 -2
  2. package/dist/create-test-device.d.ts +2 -6
  3. package/dist/create-test-device.d.ts.map +1 -1
  4. package/dist/create-test-device.js +43 -54
  5. package/dist/engine/classic-animation-loop.d.ts +5 -5
  6. package/dist/engine/classic-animation-loop.d.ts.map +1 -1
  7. package/dist/engine/classic-animation-loop.js +515 -422
  8. package/dist/index.cjs +57 -38
  9. package/dist/index.cjs.map +7 -0
  10. package/dist/index.d.ts +5 -2
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +11 -7
  13. package/dist/performance-test-runner.js +36 -43
  14. package/dist/register-devices.js +3 -4
  15. package/dist/snapshot-test-runner.js +42 -37
  16. package/dist/test-runner.js +181 -154
  17. package/dist/utils/check-type.d.ts +6 -0
  18. package/dist/utils/check-type.d.ts.map +1 -0
  19. package/dist/utils/check-type.js +5 -0
  20. package/dist/utils/deep-copy.d.ts +3 -0
  21. package/dist/utils/deep-copy.d.ts.map +1 -0
  22. package/dist/utils/deep-copy.js +14 -0
  23. package/dist/utils/get-bounding-box.d.ts +7 -0
  24. package/dist/utils/get-bounding-box.d.ts.map +1 -0
  25. package/dist/utils/get-bounding-box.js +10 -0
  26. package/dist/utils/resource-tracker.d.ts +6 -0
  27. package/dist/utils/resource-tracker.d.ts.map +1 -0
  28. package/dist/utils/resource-tracker.js +23 -0
  29. package/dist/utils.js +8 -8
  30. package/package.json +17 -25
  31. package/src/create-test-device.ts +4 -13
  32. package/src/engine/classic-animation-loop.ts +5 -9
  33. package/src/index.ts +9 -2
  34. package/src/register-devices.ts +1 -4
  35. package/src/snapshot-test-runner.ts +1 -1
  36. package/src/utils/deep-copy.ts +16 -0
  37. package/src/utils/resource-tracker.ts +24 -0
  38. package/dist/check-type.js.map +0 -1
  39. package/dist/create-test-device.js.map +0 -1
  40. package/dist/engine/classic-animation-loop.js.map +0 -1
  41. package/dist/index.js.map +0 -1
  42. package/dist/performance-test-runner.js.map +0 -1
  43. package/dist/register-devices.js.map +0 -1
  44. package/dist/snapshot-test-runner.js.map +0 -1
  45. package/dist/test-runner.js.map +0 -1
  46. package/dist/utils.js.map +0 -1
  47. /package/src/{check-type.ts → utils/check-type.ts} +0 -0
  48. /package/src/{utils.ts → utils/get-bounding-box.ts} +0 -0
@@ -1,172 +1,199 @@
1
- import { webglDevice } from "./create-test-device.js";
2
- import { ClassicAnimationLoop as AnimationLoop } from "./engine/classic-animation-loop.js";
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
- name: 'Unnamed test',
5
- onInitialize: async () => {},
6
- onRender: _ref => {
7
- let {
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
- 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
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
- 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);
42
- this.props = props;
43
- }
44
- add(testCases) {
45
- if (!Array.isArray(testCases)) {
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
- for (const testCase of testCases) {
49
- this._testCases.push(testCase);
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
- return this;
52
- }
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,
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
- for (const key in DEFAULT_TEST_CASE) {
89
- testCase[key] = testCase[key] || DEFAULT_TEST_CASE[key];
96
+ shouldRender(animationProps) {
97
+ return true;
90
98
  }
91
- }
92
- shouldRender(animationProps) {
93
- return true;
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
- let isDone = false;
116
- const testCaseAnimationProps = {
117
- ...animationProps,
118
- ...this._testCaseData,
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
- const timeout = testCase.timeout || this.testOptions.timeout;
130
- if (timeout && testCaseAnimationProps.time > timeout) {
131
- isDone = true;
108
+ _fail(result) {
109
+ this.testOptions.onTestFail(this._currentTestCase, result);
110
+ // this._animationLoop?.stop();
132
111
  }
133
- if (isDone) {
134
- this.assert(testCase);
112
+ _next() {
113
+ this._nextTestCase();
135
114
  }
136
- }
137
- _nextTestCase() {
138
- const animationProps = this._animationProps;
139
- if (this._testCaseData) {
140
- for (const key in this._testCaseData) {
141
- const value = this._testCaseData[key];
142
- if (value && value.delete) {
143
- value.destroy();
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
- const testCase = this._testCases.shift();
152
- if (testCase) {
153
- this._currentTestCase = testCase;
154
- this._currentTestCaseStartTime = animationProps.time;
155
- this._currentTestCaseStartTick = animationProps.tick;
156
- this.initTestCase(testCase);
157
- this.device.pushState();
158
- const initProps = {
159
- ...animationProps,
160
- startTime: animationProps.time,
161
- time: 0,
162
- tick: 0
163
- };
164
- Promise.resolve(testCase.onInitialize(initProps)).then(userData => {
165
- this._testCaseData = userData || {};
166
- });
167
- this.testOptions.onTestStart(testCase);
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,6 @@
1
+ /**
2
+ * Tests that an argument matches the type.
3
+ * @note fails during typescript type check, not during runtime.
4
+ */
5
+ export declare function checkType<T>(value: T): void;
6
+ //# sourceMappingURL=check-type.d.ts.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,5 @@
1
+ /**
2
+ * Tests that an argument matches the type.
3
+ * @note fails during typescript type check, not during runtime.
4
+ */
5
+ export function checkType(value) { }
@@ -0,0 +1,3 @@
1
+ /** Recursively copies objects */
2
+ export declare function deepCopy(object: Record<string, any>): any;
3
+ //# sourceMappingURL=deep-copy.d.ts.map
@@ -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,7 @@
1
+ export declare function getBoundingBoxInPage(domElement: HTMLElement): {
2
+ x: number;
3
+ y: number;
4
+ width: number;
5
+ height: number;
6
+ };
7
+ //# sourceMappingURL=get-bounding-box.d.ts.map
@@ -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,6 @@
1
+ export declare function getResourceCounts(): {
2
+ Texture2D: any;
3
+ Buffer: any;
4
+ };
5
+ export declare function getLeakedResources(startCounts: Record<string, number>, endCounts: Record<string, number>): number | null;
6
+ //# sourceMappingURL=resource-tracker.d.ts.map
@@ -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
- const bbox = domElement.getBoundingClientRect();
3
- return {
4
- x: window.scrollX + bbox.x,
5
- y: window.scrollY + bbox.y,
6
- width: bbox.width,
7
- height: bbox.height
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.4",
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
- "webgl2",
15
+ "webgpu",
16
16
  "webgl",
17
17
  "automation",
18
- "testing"
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.1",
52
- "@luma.gl/webgl": "9.0.0-beta.1",
53
- "@luma.gl/webgpu": "9.0.0-beta.1",
54
- "@probe.gl/test-utils": "^4.0.2"
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
- "engines_comment": [
57
- "gl needs recent minor version of Node 16.x"
58
- ],
59
- "engines": {
60
- "node": ">=16.18.0"
51
+ "dependencies": {
52
+ "@probe.gl/env": "^4.0.2"
61
53
  },
62
- "gitHead": "bf6bb45b25d59de5b3d05dab4b2e91ad583059e6"
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> = {}): WebGLRenderingContext | null {
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 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;
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
- if (webgl2Device) {
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 {isWebGL, resetGLParameters} from '@luma.gl/webgl';
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: WebGLRenderingContext;
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) => WebGLRenderingContext; // TODO: signature from createGLContext
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?: WebGLRenderingContext | null;
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: WebGLRenderingContext;
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
- export {createTestDevice, createTestContext, webgl1Device, webgl2Device, webgpuDevice} from './create-test-device';
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
- export {checkType} from './check-type';
15
+ // UTILS
16
+ export {checkType} from './utils/check-type';
17
+ export {deepCopy} from './utils/deep-copy';
18
+ export {getResourceCounts, getLeakedResources} from './utils/resource-tracker';