Files
cocos4/tests/animation/embedded-player/embedded-particle-system-player.test.ts
T
minggo 0d7c5c8f56 move cocos/core/scene-graph to cocos/scene-graph (#12868)
* move `cocos/core/scene-graph` to `cocos/scene-graph`
* move some files in `cocos/core/components` to `cocos/scene-graph`:
  - component.ts
  - component-event-handler.ts
  - component-event-handler-schema.ts
* move some files in `cocos/core/components` to `cocos/misc`: 
  - missing-script.ts
  - model-renderer.ts
  - renderer.ts
  - camera-component.ts
* move  `cocos/core/components/system.ts` to ``cocos/core/system.ts``
2022-09-26 11:02:22 +08:00

50 lines
2.2 KiB
TypeScript

import { Node } from "../../../cocos/scene-graph";
import { EmbeddedPlayer } from "../../../cocos/animation/embedded-player/embedded-player";
import { EmbeddedParticleSystemPlayable } from "../../../cocos/animation/embedded-player/embedded-particle-system-player";
import { EmbeddedPlayerHostMock } from "./util";
import { ParticleSystem } from "../../../cocos/particle";
import { captureWarns } from "../../utils/log-capture";
test('Particle system embedded player test', () => {
const rootNode = new Node('Root Node');
const nodeThatDoesNotIncludeAParticleSystem = new Node('Does Not Include a Particle System');
rootNode.addChild(nodeThatDoesNotIncludeAParticleSystem);
const particleSystemNode = new Node('Particle System Node');
particleSystemNode.addComponent(ParticleSystem);
rootNode.addChild(particleSystemNode);
{
const embeddedPlayer = new EmbeddedPlayer();
const player = embeddedPlayer.playable = new EmbeddedParticleSystemPlayable();
player.path = 'Non-existing node';
const warnWatcher = captureWarns();
const host = new EmbeddedPlayerHostMock(rootNode, embeddedPlayer, 1.3);
expect(warnWatcher.captured).toHaveLength(1);
expect(warnWatcher.captured[0][0]).toMatch(/Non-existing node/);
warnWatcher.stop();
}
{
const embeddedPlayer = new EmbeddedPlayer();
const player = embeddedPlayer.playable = new EmbeddedParticleSystemPlayable();
player.path = 'Does Not Include a Particle System';
const warnWatcher = captureWarns();
const host = new EmbeddedPlayerHostMock(rootNode, embeddedPlayer, 1.3);
expect(warnWatcher.captured).toHaveLength(1);
expect(warnWatcher.captured[0][0]).toMatch(/Does Not Include a Particle System/);
warnWatcher.stop();
}
{
const embeddedPlayer = new EmbeddedPlayer();
const player = embeddedPlayer.playable = new EmbeddedParticleSystemPlayable();
player.path = 'Particle System Node';
const warnWatcher = captureWarns();
const host = new EmbeddedPlayerHostMock(rootNode, embeddedPlayer, 1.3);
expect(host.randomAccessible).toBe(false);
expect(warnWatcher.captured).toHaveLength(0);
warnWatcher.stop();
}
});