forked from bbc/VideoContext
-
Notifications
You must be signed in to change notification settings - Fork 0
/
playback.spec.js
67 lines (56 loc) · 2.11 KB
/
playback.spec.js
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
beforeEach(() => {
cy.visit("index.html");
cy.viewport("macbook-11");
});
it("plays back video", () => {
// Set up VideoContext
cy.window().then(({ ctx }) => {
const videoNode = ctx.video("../assets/video1.webm"); // Path relative to index.html
videoNode.startAt(0);
videoNode.connect(ctx.destination);
});
// Check output match the snapshots at times on the timeline
cy.videoContextScreenShotsAtTimes([0.5, 1, 1.5], { id: "playback-video" });
});
it("plays back image", () => {
// Set up VideoContext
cy.window().then(({ ctx }) => {
const imageNode = ctx.image("../assets/test-image.png");
imageNode.startAt(0);
imageNode.connect(ctx.destination);
});
// Check output match the snapshots at times on the timeline
cy.videoContextScreenShotsAtTimes([0.5, 1, 1.5], { id: "playback-image" });
});
it("plays back image with no creatImageBitmap", () => {
// Set up VideoContext
cy.window().then(win => {
const ctx = win.ctx;
// Remove createImageBitmap to simulate being in a browser with no support
win.createImageBitmap = undefined;
const imageNode = ctx.image("../assets/test-image.png");
imageNode.startAt(0);
imageNode.connect(ctx.destination);
});
// Check output match the snapshots at times on the timeline
cy.videoContextScreenShotsAtTimes([0.5, 1, 1.5], {
id: "playback-image-with-no-createImageBitmap"
});
});
it("plays back with user supplied element and start offset", () => {
// Set up VideoContext
cy.window().then(win => {
const ctx = win.ctx;
const video = win.document.createElement("video");
video.src = "../assets/video1.webm";
video.crossOrigin = "anonymous";
const sourceOffset = 10;
const videoNode = ctx.video(video, sourceOffset);
videoNode.startAt(0);
videoNode.connect(ctx.destination);
});
// Check output match the snapshots at times on the timeline
cy.videoContextScreenShotsAtTimes([0.5, 1, 1.5], {
id: "playback-user-supplied-element"
});
});