Skip to content

Commit

Permalink
fix tests by using a null device
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Valigursky committed Apr 26, 2024
1 parent a14285f commit 23eb524
Show file tree
Hide file tree
Showing 18 changed files with 36 additions and 48 deletions.
3 changes: 2 additions & 1 deletion test/framework/anim/controller/anim-controller.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { AnimData } from '../../../../src/framework/anim/evaluator/anim-data.js'
import { AnimCurve } from '../../../../src/framework/anim/evaluator/anim-curve.js';
import { INTERPOLATION_LINEAR } from '../../../../src/framework/anim/constants.js';
import { ANIM_LESS_THAN } from '../../../../src/framework/anim/controller/constants.js';
import { NullGraphicsDevice } from '../../../../src/platform/graphics/null/null-graphics-device.js';
import { HTMLCanvasElement } from '@playcanvas/canvas-mock';
import { expect } from 'chai';

Expand All @@ -18,7 +19,7 @@ describe('AnimController', function () {

beforeEach(function () {
const canvas = new HTMLCanvasElement(500, 500);
app = new Application(canvas);
app = new Application(canvas, { graphicsDevice: new NullGraphicsDevice(canvas) });
const states = [
{
name: 'START'
Expand Down
5 changes: 3 additions & 2 deletions test/framework/anim/evaluator/anim-evaluator.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { AnimEvents } from '../../../../src/framework/anim/evaluator/anim-events
import { Application } from '../../../../src/framework/application.js';
import { DefaultAnimBinder } from '../../../../src/framework/anim/binder/default-anim-binder.js';
import { GraphNode } from '../../../../src/scene/graph-node.js';
import { NullGraphicsDevice } from '../../../../src/platform/graphics/null/null-graphics-device.js';

import { HTMLCanvasElement } from '@playcanvas/canvas-mock';

Expand All @@ -17,7 +18,7 @@ describe('AnimEvaluator', function () {

it('AnimEvaluator: update with clip blending', function () {
const canvas = new HTMLCanvasElement(500, 500);
const app = new Application(canvas);
const app = new Application(canvas, { graphicsDevice: new NullGraphicsDevice(canvas) });

// build the graph to be animated
const parent = new GraphNode('parent');
Expand Down Expand Up @@ -90,7 +91,7 @@ describe('AnimEvaluator', function () {

it('AnimEvaluator: update without clip blending', function () {
const canvas = new HTMLCanvasElement(500, 500);
const app = new Application(canvas);
const app = new Application(canvas, { graphicsDevice: new NullGraphicsDevice(canvas) });

// build the graph to be animated
const parent = new GraphNode('parent');
Expand Down
5 changes: 3 additions & 2 deletions test/framework/application.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Scene } from '../../src/scene/scene.js';
import { SceneRegistry } from '../../src/framework/scene-registry.js';
import { ScriptRegistry } from '../../src/framework/script/script-registry.js';
import { XrManager } from '../../src/framework/xr/xr-manager.js';
import { NullGraphicsDevice } from '../../src/platform/graphics/null/null-graphics-device.js';

import { HTMLCanvasElement } from '@playcanvas/canvas-mock';

Expand All @@ -23,7 +24,7 @@ describe('Application', function () {

it('support no options', function () {
const canvas = new HTMLCanvasElement(500, 500);
const app = new Application(canvas);
const app = new Application(canvas, { graphicsDevice: new NullGraphicsDevice(canvas) });

expect(app.assets).to.be.instanceOf(AssetRegistry);
expect(app.autoRender).to.be.true;
Expand Down Expand Up @@ -56,7 +57,7 @@ describe('Application', function () {

it('destroys the application', function () {
const canvas = new HTMLCanvasElement(500, 500);
const app = new Application(canvas);
const app = new Application(canvas, { graphicsDevice: new NullGraphicsDevice(canvas) });

app.destroy();
// expect(app.assets).to.be.null;
Expand Down
3 changes: 2 additions & 1 deletion test/framework/asset/asset-list-loader.test.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Application } from '../../../src/framework/application.js';
import { AssetListLoader } from '../../../src/framework/asset/asset-list-loader.js';
import { Asset } from '../../../src/framework/asset/asset.js';
import { NullGraphicsDevice } from '../../../src/platform/graphics/null/null-graphics-device.js';

import { HTMLCanvasElement } from '@playcanvas/canvas-mock';

Expand All @@ -13,7 +14,7 @@ describe('AssetListLoader', function () {

beforeEach(function () {
const canvas = new HTMLCanvasElement(500, 500);
app = new Application(canvas);
app = new Application(canvas, { graphicsDevice: new NullGraphicsDevice(canvas) });
});

afterEach(function () {
Expand Down
3 changes: 2 additions & 1 deletion test/framework/asset/asset-localized.test.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { LocalizedAsset } from '../../../src/framework/asset/asset-localized.js';
import { Application } from '../../../src/framework/application.js';
import { Asset } from '../../../src/framework/asset/asset.js';
import { NullGraphicsDevice } from '../../../src/platform/graphics/null/null-graphics-device.js';

import { HTMLCanvasElement } from '@playcanvas/canvas-mock';

Expand All @@ -12,7 +13,7 @@ describe('LocalizedAsset', function () {

beforeEach(function () {
const canvas = new HTMLCanvasElement(500, 500);
app = new Application(canvas);
app = new Application(canvas, { graphicsDevice: new NullGraphicsDevice(canvas) });
});

afterEach(function () {
Expand Down
3 changes: 2 additions & 1 deletion test/framework/asset/asset-registry.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { AssetRegistry } from '../../../src/framework/asset/asset-registry.js';
import { GlbContainerResource } from '../../../src/framework/parsers/glb-container-resource.js';
import { ResourceLoader } from '../../../src/framework/handlers/loader.js';
import { http, Http } from '../../../src/platform/net/http.js';
import { NullGraphicsDevice } from '../../../src/platform/graphics/null/null-graphics-device.js';

import { HTMLCanvasElement } from '@playcanvas/canvas-mock';

Expand All @@ -19,7 +20,7 @@ describe('AssetRegistry', function () {
retryDelay = Http.retryDelay;
Http.retryDelay = 1;
const canvas = new HTMLCanvasElement(500, 500);
app = new Application(canvas);
app = new Application(canvas, { graphicsDevice: new NullGraphicsDevice(canvas) });
});

afterEach(function () {
Expand Down
3 changes: 2 additions & 1 deletion test/framework/asset/asset.test.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Application } from '../../../src/framework/application.js';
import { Asset } from '../../../src/framework/asset/asset.js';
import { NullGraphicsDevice } from '../../../src/platform/graphics/null/null-graphics-device.js';

import { HTMLCanvasElement } from '@playcanvas/canvas-mock';

Expand All @@ -11,7 +12,7 @@ describe('Asset', function () {

beforeEach(function () {
const canvas = new HTMLCanvasElement(500, 500);
app = new Application(canvas);
app = new Application(canvas, { graphicsDevice: new NullGraphicsDevice(canvas) });
});

afterEach(function () {
Expand Down
3 changes: 2 additions & 1 deletion test/framework/components/element/component.test.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { LAYERID_UI } from '../../../../src/scene/constants.js';
import { Application } from '../../../../src/framework/application.js';
import { Entity } from '../../../../src/framework/entity.js';
import { NullGraphicsDevice } from '../../../../src/platform/graphics/null/null-graphics-device.js';

import { HTMLCanvasElement } from '@playcanvas/canvas-mock';

Expand All @@ -11,7 +12,7 @@ describe('ElementComponent', function () {

beforeEach(function () {
const canvas = new HTMLCanvasElement(500, 500);
app = new Application(canvas);
app = new Application(canvas, { graphicsDevice: new NullGraphicsDevice(canvas) });
});

afterEach(function () {
Expand Down
3 changes: 2 additions & 1 deletion test/framework/components/layout-group/component.test.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { ELEMENTTYPE_GROUP } from '../../../../src/framework/components/element/constants.js';
import { Application } from '../../../../src/framework/application.js';
import { Entity } from '../../../../src/framework/entity.js';
import { NullGraphicsDevice } from '../../../../src/platform/graphics/null/null-graphics-device.js';

import { HTMLCanvasElement } from '@playcanvas/canvas-mock';

Expand Down Expand Up @@ -32,7 +33,7 @@ describe('LayoutGroupComponent', function () {

beforeEach(function () {
const canvas = new HTMLCanvasElement(500, 500);
app = new Application(canvas);
app = new Application(canvas, { graphicsDevice: new NullGraphicsDevice(canvas) });
system = app.systems.layoutgroup;

entity0 = buildLayoutGroupEntity('0');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Entity } from '../../../../src/framework/entity.js';
import { LayoutCalculator } from '../../../../src/framework/components/layout-group/layout-calculator.js';
import { Vec2 } from '../../../../src/core/math/vec2.js';
import { Vec4 } from '../../../../src/core/math/vec4.js';
import { NullGraphicsDevice } from '../../../../src/platform/graphics/null/null-graphics-device.js';

import { HTMLCanvasElement } from '@playcanvas/canvas-mock';

Expand Down Expand Up @@ -62,7 +63,7 @@ describe('LayoutCalculator', function () {

beforeEach(function () {
const canvas = new HTMLCanvasElement(500, 500);
app = new Application(canvas);
app = new Application(canvas, { graphicsDevice: new NullGraphicsDevice(canvas) });
calculator = new LayoutCalculator();

options = {
Expand Down
3 changes: 2 additions & 1 deletion test/framework/components/model/component.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Application } from '../../../../src/framework/application.js';
import { Asset } from '../../../../src/framework/asset/asset.js';
import { Entity } from '../../../../src/framework/entity.js';
import { LAYERID_WORLD, LAYERID_UI } from '../../../../src/scene/constants.js';
import { NullGraphicsDevice } from '../../../../src/platform/graphics/null/null-graphics-device.js';

import { HTMLCanvasElement } from '@playcanvas/canvas-mock';

Expand Down Expand Up @@ -47,7 +48,7 @@ describe('ModelComponent', function () {

beforeEach(function (done) {
const canvas = new HTMLCanvasElement(500, 500);
app = new Application(canvas);
app = new Application(canvas, { graphicsDevice: new NullGraphicsDevice(canvas) });

loadAssets(function () {
done();
Expand Down
3 changes: 2 additions & 1 deletion test/framework/components/system.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { ComponentSystem } from '../../../src/framework/components/system.js';
import { Vec2 } from '../../../src/core/math/vec2.js';
import { Vec3 } from '../../../src/core/math/vec3.js';
import { Vec4 } from '../../../src/core/math/vec4.js';
import { NullGraphicsDevice } from '../../../src/platform/graphics/null/null-graphics-device.js';

import { HTMLCanvasElement } from '@playcanvas/canvas-mock';

Expand All @@ -17,7 +18,7 @@ describe('ComponentSystem', function () {

beforeEach(function () {
const canvas = new HTMLCanvasElement(500, 500);
app = new Application(canvas);
app = new Application(canvas, { graphicsDevice: new NullGraphicsDevice(canvas) });

system = new ComponentSystem(app);
});
Expand Down
3 changes: 2 additions & 1 deletion test/framework/entity.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import { ScrollViewComponent } from '../../src/framework/components/scroll-view/
import { SoundComponent } from '../../src/framework/components/sound/component.js';
import { SpriteComponent } from '../../src/framework/components/sprite/component.js';
import { ZoneComponent } from '../../src/framework/components/zone/component.js';
import { NullGraphicsDevice } from '../../src/platform/graphics/null/null-graphics-device.js';

import { DummyComponentSystem } from './test-component/system.mjs';

Expand All @@ -39,7 +40,7 @@ describe('Entity', function () {

beforeEach(function () {
const canvas = new HTMLCanvasElement(500, 500);
app = new Application(canvas);
app = new Application(canvas, { graphicsDevice: new NullGraphicsDevice(canvas) });

app.systems.add(new DummyComponentSystem(app));
});
Expand Down
3 changes: 2 additions & 1 deletion test/framework/i18n/i18n.test.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Application } from '../../../src/framework/application.js';
import { Asset } from '../../../src/framework/asset/asset.js';
import { JsonHandler } from '../../../src/framework/handlers/json.js';
import { NullGraphicsDevice } from '../../../src/platform/graphics/null/null-graphics-device.js';

import { HTMLCanvasElement } from '@playcanvas/canvas-mock';

Expand All @@ -13,7 +14,7 @@ describe('I18n', function () {

beforeEach(function () {
const canvas = new HTMLCanvasElement(500, 500);
app = new Application(canvas);
app = new Application(canvas, { graphicsDevice: new NullGraphicsDevice(canvas) });
});

afterEach(function () {
Expand Down
3 changes: 2 additions & 1 deletion test/framework/scene-registry.test.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Application } from '../../src/framework/application.js';
import { SceneRegistry } from '../../src/framework/scene-registry.js';
import { NullGraphicsDevice } from '../../src/platform/graphics/null/null-graphics-device.js';

import { HTMLCanvasElement } from '@playcanvas/canvas-mock';

Expand All @@ -11,7 +12,7 @@ describe('SceneRegistry', function () {

beforeEach(function () {
const canvas = new HTMLCanvasElement(500, 500);
app = new Application(canvas);
app = new Application(canvas, { graphicsDevice: new NullGraphicsDevice(canvas) });
});

afterEach(function () {
Expand Down
3 changes: 2 additions & 1 deletion test/framework/utils/entity-reference.test.mjs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Application } from '../../../src/framework/application.js';
import { Entity } from '../../../src/framework/entity.js';
import { EntityReference } from '../../../src/framework/utils/entity-reference.js';
import { NullGraphicsDevice } from '../../../src/platform/graphics/null/null-graphics-device.js';

import { DummyComponentSystem } from '../test-component/system.mjs';

Expand All @@ -25,7 +26,7 @@ describe('EntityReference', function () {

beforeEach(function () {
const canvas = new HTMLCanvasElement(500, 500);
app = new Application(canvas);
app = new Application(canvas, { graphicsDevice: new NullGraphicsDevice(canvas) });

app.systems.add(new DummyComponentSystem(app));

Expand Down
29 changes: 0 additions & 29 deletions test/platform/graphics/webgl-graphics-device.test.mjs

This file was deleted.

3 changes: 2 additions & 1 deletion test/scene/batching/batch-manager.test.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Application } from '../../../src/framework/application.js';
import { Entity } from '../../../src/framework/entity.js';
import { NullGraphicsDevice } from '../../../src/platform/graphics/null/null-graphics-device.js';
import { LAYERID_WORLD } from '../../../src/scene/constants.js';

import { HTMLCanvasElement } from '@playcanvas/canvas-mock';
Expand All @@ -10,7 +11,7 @@ describe('BatchManager', function () {

beforeEach(function () {
const canvas = new HTMLCanvasElement(500, 500);
this.app = new Application(canvas);
this.app = new Application(canvas, { graphicsDevice: new NullGraphicsDevice(canvas) });

this.bg = this.app.batcher.addGroup('Test Group', false, 100);
});
Expand Down

0 comments on commit 23eb524

Please sign in to comment.