Skip to content

Commit

Permalink
feat(test-utils): Avoid registering devices (#2275)
Browse files Browse the repository at this point in the history
  • Loading branch information
ibgreen authored Sep 23, 2024
1 parent 9c01ec7 commit 8e55d60
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 19 deletions.
9 changes: 5 additions & 4 deletions modules/core/test/adapter/luma.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import test from 'tape-promise/tape';
import {nullAdapter, NullDevice} from '@luma.gl/test-utils';
import {luma} from '@luma.gl/core';
import {webgl2Adapter} from '../../../webgl/dist/adapter/webgl-adapter';

test('luma#attachDevice', async t => {
const device = await luma.attachDevice({handle: null, adapters: [nullAdapter]});
Expand Down Expand Up @@ -37,12 +38,12 @@ test('luma#getSupportedAdapters', async t => {
t.ok(types.includes('unknown'), 'null device is supported');
});

test('luma#getBestAvailableDeviceType', async t => {
test.skip('luma#getBestAvailableDeviceType', async t => {
luma.registerAdapters([nullAdapter]);
// Somewhat dummy test, as tests rely on test utils registering webgl and webgpu devices
// But they might not be supported on all devices.
const types = luma.getBestAvailableAdapter();
t.ok(typeof types === 'string', 'does not crash');
t.ok(typeof types === 'undefined', 'does not crash');
});

// To suppress @typescript-eslint/unbound-method
Expand Down Expand Up @@ -72,7 +73,7 @@ test('luma#enforceWebGL2', async t => {
);
t.equal(prototype.getContext('webgl2'), 'webgl2-mock', 'mocked getContext webgl2 ok');

luma.enforceWebGL2();
luma.enforceWebGL2(true, [webgl2Adapter]);

t.true(prototype.originalGetContext, 'originalGetContext ok');
t.equal(prototype.getContext('webgl'), 'webgl2-mock', 'getContext enforce webgl2 ok');
Expand All @@ -83,7 +84,7 @@ test('luma#enforceWebGL2', async t => {
);
t.equal(prototype.getContext('webgl2'), 'webgl2-mock', 'getContext webgl2 ok');

luma.enforceWebGL2(false);
luma.enforceWebGL2(false, [webgl2Adapter]);

t.false(prototype.originalGetContext, 'originalGetContext ok');
t.equal(prototype.getContext('webgl'), 'webgl-mock', 'mocked getContext revert webgl ok');
Expand Down
2 changes: 0 additions & 2 deletions modules/test-utils/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import './register-devices';

// TEST RUNNERS
export type {TestRunnerTestCase} from './test-runner';
export type {SnapshotTestRunnerTestCase} from './snapshot-test-runner';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ export class NullRenderPass extends RenderPass {

end(): void {}

pushDebugGroup(groupLabel: string): void {}
popDebugGroup(): void {}
insertDebugMarker(markerLabel: string): void {}
override pushDebugGroup(groupLabel: string): void {}
override popDebugGroup(): void {}
override insertDebugMarker(markerLabel: string): void {}

setParameters(parameters: RenderPassParameters = {}): void {}

Expand Down
9 changes: 0 additions & 9 deletions modules/test-utils/src/register-devices.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
getGLParameters,
setGLParameters,
resetGLParameters,
WebGLStateTracker
WebGLStateTracker,
webgl2Adapter
} from '@luma.gl/webgl';

import {stringifyTypedArray} from './context-state.spec';
Expand All @@ -25,6 +26,7 @@ import {ENUM_STYLE_SETTINGS_SET1, ENUM_STYLE_SETTINGS_SET2} from './data/sample-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
const devicePromise = luma.createDevice({
type: 'webgl',
adapters: [webgl2Adapter],
createCanvasContext: true
}) as Promise<WebGLDevice>;

Expand Down

0 comments on commit 8e55d60

Please sign in to comment.