Skip to content

Commit

Permalink
Move core-tests into core/tests (#2010)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pessimistress committed May 10, 2024
1 parent 455d3be commit de88b48
Show file tree
Hide file tree
Showing 28 changed files with 78 additions and 164 deletions.
1 change: 1 addition & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@
<title>luma.gl tests</title>
</head>
<body>
<script type="module" src="./test/browser.ts"></script>
</body>
</html>
47 changes: 0 additions & 47 deletions modules/core-tests/package.json

This file was deleted.

5 changes: 0 additions & 5 deletions modules/core-tests/src/index.ts

This file was deleted.

58 changes: 0 additions & 58 deletions modules/core-tests/test/adapter/canvas-context.spec.ts

This file was deleted.

32 changes: 0 additions & 32 deletions modules/core-tests/test/index.ts

This file was deleted.

18 changes: 0 additions & 18 deletions modules/core-tests/tsconfig.json

This file was deleted.

51 changes: 51 additions & 0 deletions modules/core/test/adapter/canvas-context.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,57 @@
import test from 'tape-promise/tape';
import {CanvasContext, Framebuffer} from '@luma.gl/core';
import {isBrowser} from '@probe.gl/env';
import {getTestDevices} from '@luma.gl/test-utils';

test('CanvasContext#defined', t => {
t.ok(CanvasContext, 'CanvasContext defined');
// t.ok(new WEBGLCanvasContext()), 'Context creation ok');
t.end();
});

test('CanvasContext#getDevicePixelRatio', async t => {
const windowPixelRatio = (typeof window !== 'undefined' && window.devicePixelRatio) || 1;
const TEST_CASES = [
{
name: 'useDevicePixels: true: should use window.devicePixelRatio or 1',
useDevicePixels: true,
expected: windowPixelRatio
},
{
name: 'useDevicePixels: false: should use 1',
useDevicePixels: false,
expected: 1
},
{
name: 'Non Finite useDevicePixels null: should use 1',
useDevicePixels: null,
expected: 1
},
{
name: 'Non valid useDevicePixels 0: should use 1',
useDevicePixels: 0,
expected: 1
},
{
name: 'Non valid useDevicePixels negative: should use 1',
useDevicePixels: -3.2,
expected: 1
},
{
name: 'Valid useDevicePixels, should use it',
useDevicePixels: 1.5,
expected: 1.5
}
];

for (const device of await getTestDevices()) {
TEST_CASES.forEach(tc => {
const result = device.canvasContext?.getDevicePixelRatio(tc.useDevicePixels);
t.equal(result, tc.expected, tc.name);
});
}
t.end();
});

// @ts-expect-error
class TestCanvasContext extends CanvasContext {
Expand Down
File renamed without changes.
26 changes: 26 additions & 0 deletions modules/core/test/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,17 @@ import './adapter/type-utils/decode-texture-format.spec';
import './adapter/type-utils/vertex-format-from-attribute.spec';

// adapter

// WebGLDevice, features & limits
import './adapter/device-helpers/device-info.spec';
import './adapter/device-helpers/device-features.spec';
import './adapter/device-helpers/device-limits.spec';
import './adapter/device-helpers/set-device-parameters.spec';

import './adapter/helpers/parse-shader-compiler-log.spec';
// import './adapter/helpers/get-shader-layout.spec';

import './adapter/device.spec';
import './adapter/canvas-context.spec';
import './adapter/luma.spec';

Expand All @@ -23,3 +34,18 @@ import './lib/uniforms/uniform-buffer-layout.spec';

// compiler logs
import './lib/compiler-log/format-compiler-log.spec';

// Resources
import './adapter/texture-formats.spec';

// Resources - TODO these tests only depend on Device and could move to API...
import './adapter/resources/buffer.spec';
import './adapter/resources/command-buffer.spec';
import './adapter/resources/shader.spec';
import './adapter/resources/render-pipeline.spec';
import './adapter/resources/compute-pipeline.spec';
import './adapter/resources/sampler.spec';
import './adapter/resources/texture.spec';
import './adapter/resources/framebuffer.spec';
import './adapter/resources/vertex-array.spec';
import './adapter/resources/query-set.spec';
1 change: 0 additions & 1 deletion test/modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import '@luma.gl/shadertools/test';

// DEVICE INDEPENDENT TESTS
import '@luma.gl/core/test';
import '@luma.gl/core-tests/test';

// WEBGL ADAPTER TESTS
import '@luma.gl/webgl/test';
Expand Down
2 changes: 0 additions & 2 deletions tsconfig.build.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
"references": [
{"path": "modules/constants"},
{"path": "modules/core"},
{"path": "modules/core-tests"},
{"path": "modules/engine"},
{"path": "modules/gltf"},
{"path": "modules/shadertools"},
{"path": "modules/test-utils"},
{"path": "modules/webgl"},
{"path": "modules/webgpu"}
// {"path": "modules/experimental"}
]
}
1 change: 0 additions & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
"paths": {
"@luma.gl/core/*": ["modules/core/src/*"],
"@luma.gl/core/test/*": ["modules/core/test/*"],
"@luma.gl/core-tests/test/*": ["modules/core-tests/test/*"],
"@luma.gl/constants/*": ["modules/constants/src/*"],
"@luma.gl/constants/test/*": ["modules/constants/test/*"],
"@luma.gl/engine/*": ["modules/engine/src/*"],
Expand Down

0 comments on commit de88b48

Please sign in to comment.