forked from bbc/VideoContext
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheffects.spec.js
133 lines (102 loc) · 4.23 KB
/
effects.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
// Only need to capture at one time
const SCREEN_SHOT_TIMES = [1];
beforeEach(() => {
cy.visit("index.html");
cy.viewport("macbook-11");
});
it("Color Threshold", () => {
// Set up VideoContext
cy.window().then(({ ctx, VideoContext }) => {
const videoNode = ctx.video("../assets/video1.webm");
const colorThresholdEffect = ctx.effect(VideoContext.DEFINITIONS.COLORTHRESHOLD);
// Configure color threshold properties
colorThresholdEffect.colorAlphaThreshold = [0.5, 0.5, 0.5];
videoNode.startAt(0);
// Apply effect
videoNode.connect(colorThresholdEffect);
colorThresholdEffect.connect(ctx.destination);
});
// Check output matches the snapshots at times on the timeline
cy.videoContextScreenShotsAtTimes(SCREEN_SHOT_TIMES, { id: "effect-color-threshold" });
});
it("Crop", () => {
// Set up VideoContext
cy.window().then(({ ctx, VideoContext }) => {
const videoNode = ctx.video("../assets/video1.webm");
const cropEffect = ctx.effect(VideoContext.DEFINITIONS.CROP);
// Configure crop properties
cropEffect.height = 0.75;
cropEffect.width = 0.75;
videoNode.startAt(0);
// Apply effect
videoNode.connect(cropEffect);
cropEffect.connect(ctx.destination);
});
// Check output matches the snapshots at times on the timeline
cy.videoContextScreenShotsAtTimes(SCREEN_SHOT_TIMES, { id: "effect-crop" });
});
it("Horizontal Blur", () => {
// Set up VideoContext
cy.window().then(({ ctx, VideoContext }) => {
const videoNode = ctx.video("../assets/video1.webm");
const horizontalBlurEffect = ctx.effect(VideoContext.DEFINITIONS.HORIZONTAL_BLUR);
videoNode.startAt(0);
// Apply effect
videoNode.connect(horizontalBlurEffect);
horizontalBlurEffect.connect(ctx.destination);
});
// Check output matches the snapshots at times on the timeline
cy.videoContextScreenShotsAtTimes(SCREEN_SHOT_TIMES, { id: "effect-horizontal-blur" });
});
it("Monochrome", () => {
// Set up VideoContext
cy.window().then(({ ctx, VideoContext }) => {
const videoNode = ctx.video("../assets/video1.webm");
const monochromeEffect = ctx.effect(VideoContext.DEFINITIONS.MONOCHROME);
videoNode.startAt(0);
// Apply effect
videoNode.connect(monochromeEffect);
monochromeEffect.connect(ctx.destination);
});
// Check output matches the snapshots at times on the timeline
cy.videoContextScreenShotsAtTimes(SCREEN_SHOT_TIMES, { id: "effect-monochrome" });
});
it("Opacity", () => {
// Set up VideoContext
cy.window().then(({ ctx, VideoContext }) => {
const videoNode = ctx.video("../assets/video1.webm");
const opacityEffect = ctx.effect(VideoContext.DEFINITIONS.OPACITY);
videoNode.startAt(0);
// Apply effect
videoNode.connect(opacityEffect);
opacityEffect.connect(ctx.destination);
});
// Check output matches the snapshots at times on the timeline
cy.videoContextScreenShotsAtTimes(SCREEN_SHOT_TIMES, { id: "effect-opacity" });
});
it("Static", () => {
// Set up VideoContext
cy.window().then(({ ctx, VideoContext }) => {
const videoNode = ctx.video("../assets/video1.webm");
const staticEffect = ctx.effect(VideoContext.DEFINITIONS.STATIC_EFFECT);
videoNode.startAt(0);
// Apply effect
videoNode.connect(staticEffect);
staticEffect.connect(ctx.destination);
});
// Check output matches the snapshots at times on the timeline
cy.videoContextScreenShotsAtTimes(SCREEN_SHOT_TIMES, { id: "effect-static" });
});
it("Vertical Blur", () => {
// Set up VideoContext
cy.window().then(({ ctx, VideoContext }) => {
const videoNode = ctx.video("../assets/video1.webm");
const verticalBlurEffect = ctx.effect(VideoContext.DEFINITIONS.VERTICAL_BLUR);
videoNode.startAt(0);
// Apply effect
videoNode.connect(verticalBlurEffect);
verticalBlurEffect.connect(ctx.destination);
});
// Check output matches the snapshots at times on the timeline
cy.videoContextScreenShotsAtTimes(SCREEN_SHOT_TIMES, { id: "effect-vertical-blur" });
});