-
Notifications
You must be signed in to change notification settings - Fork 161
Expand file tree
/
Copy pathvideocontext.test.js
More file actions
72 lines (58 loc) · 2.89 KB
/
Copy pathvideocontext.test.js
File metadata and controls
72 lines (58 loc) · 2.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import VideoContext from "../../src/videocontext";
let videocontext;
require("webgl-mock");
beforeEach(function() {
const canvas = new HTMLCanvasElement(500, 500);
videocontext = new VideoContext(canvas);
});
describe("VideoContext", function() {
describe("#effect()", function() {
it("should create an EffectNode from the passed definition", function() {
var effectNode = videocontext.effect(VideoContext.DEFINITIONS.MONOCHROME);
expect(effectNode.maximumConnections).not.toBe(Infinity); // effect nodes limit connections
expect(effectNode.inputNames).toEqual(["u_image"]);
});
});
describe("#transition()", function() {
it("should create a TransitionNode from the passed definition", function() {
var transitionNode = videocontext.transition(VideoContext.DEFINITIONS.CROSSFADE);
expect(transitionNode.maximumConnections).not.toEqual(Infinity); // transition nodes limit connections
expect(transitionNode.transition).not.toEqual(undefined);
expect(transitionNode.clearTransitions).not.toEqual(undefined);
expect(transitionNode.inputNames).toEqual(["u_image_a", "u_image_b"]);
});
});
describe("#compositor()", function() {
it("should create a CompositingNode from the passed definition", function() {
var compositingNode = videocontext.compositor(VideoContext.DEFINITIONS.MONOCHROME);
expect(compositingNode.maximumConnections).toEqual(Infinity);
expect(compositingNode.inputNames).toEqual(["u_image"]);
});
});
describe("#duration", function() {
it("should return the time in seconds between time=0 and the stop time of the last SourceNode", function() {
var videoElement = document.createElement("video");
var videoNode1 = videocontext.video(videoElement);
var videoNode2 = videocontext.video(videoElement);
videoNode1.start(10);
videoNode1.stop(20.245);
videoNode2.start(0);
videoNode2.stop(10);
expect(videocontext.duration).toEqual(20.245);
});
it("should return Infinity if no stop time has been specified on one of the Nodes", function() {
var imageElement = document.createElement("img");
var imageNode = videocontext.createImageSourceNode(imageElement);
imageNode.start(0);
expect(videocontext.duration).toBe(Infinity);
});
it("should return 0 if all source nodes have had clearTimelineState called on them", function() {
var videoElement = document.createElement("video");
var videoNode = videocontext.video(videoElement);
videoNode.start(0);
videoNode.stop(10);
videoNode.clearTimelineState();
expect(videocontext.duration).toEqual(0);
});
});
});