summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/web-animations/resources/easing-tests.js
blob: a05264b0f5a990bae68e540a0006a2ad91338110 (plain)
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
'use strict';

const gEasingTests = [
  {
    desc: 'step-start function',
    easing: 'step-start',
    easingFunction: stepStart(1),
    serialization: 'steps(1, start)'
  },
  {
    desc: 'steps(1, start) function',
    easing: 'steps(1, start)',
    easingFunction: stepStart(1)
  },
  {
    desc: 'steps(2, start) function',
    easing: 'steps(2, start)',
    easingFunction: stepStart(2)
  },
  {
    desc: 'step-end function',
    easing: 'step-end',
    easingFunction: stepEnd(1),
    serialization: 'steps(1)'
  },
  {
    desc: 'steps(1) function',
    easing: 'steps(1)',
    easingFunction: stepEnd(1)
  },
  {
    desc: 'steps(1, end) function',
    easing: 'steps(1, end)',
    easingFunction: stepEnd(1),
    serialization: 'steps(1)'
  },
  {
    desc: 'steps(2, end) function',
    easing: 'steps(2, end)',
    easingFunction: stepEnd(2),
    serialization: 'steps(2)'
  },
  {
    desc: 'linear function',
    easing: 'linear', // cubic-bezier(0, 0, 1.0, 1.0)
    easingFunction: cubicBezier(0, 0, 1.0, 1.0)
  },
  {
    desc: 'ease function',
    easing: 'ease', // cubic-bezier(0.25, 0.1, 0.25, 1.0)
    easingFunction: cubicBezier(0.25, 0.1, 0.25, 1.0)
  },
  {
    desc: 'ease-in function',
    easing: 'ease-in', // cubic-bezier(0.42, 0, 1.0, 1.0)
    easingFunction: cubicBezier(0.42, 0, 1.0, 1.0)
  },
  {
    desc: 'ease-in-out function',
    easing: 'ease-in-out', // cubic-bezier(0.42, 0, 0.58, 1.0)
    easingFunction: cubicBezier(0.42, 0, 0.58, 1.0)
  },
  {
    desc: 'ease-out function',
    easing: 'ease-out', // cubic-bezier(0, 0, 0.58, 1.0)
    easingFunction: cubicBezier(0, 0, 0.58, 1.0)
  },
  {
    desc: 'easing function which produces values greater than 1',
    easing: 'cubic-bezier(0, 1.5, 1, 1.5)',
    easingFunction: cubicBezier(0, 1.5, 1, 1.5)
  },
  {
    desc: 'easing function which produces values less than 1',
    easing: 'cubic-bezier(0, -0.5, 1, -0.5)',
    easingFunction: cubicBezier(0, -0.5, 1, -0.5)
  }
];

const gEasingParsingTests = [
  ['linear', 'linear'],
  ['ease-in-out', 'ease-in-out'],
  ['Ease\\2d in-out', 'ease-in-out'],
  ['ease /**/', 'ease'],
];

const gInvalidEasings = [
  '',
  '7',
  'test',
  'initial',
  'inherit',
  'unset',
  'unrecognized',
  'var(--x)',
  'ease-in-out, ease-out',
  'cubic-bezier(1.1, 0, 1, 1)',
  'cubic-bezier(0, 0, 1.1, 1)',
  'cubic-bezier(-0.1, 0, 1, 1)',
  'cubic-bezier(0, 0, -0.1, 1)',
  'cubic-bezier(0.1, 0, 4, 0.4)',
  'steps(-1, start)',
  'steps(0.1, start)',
  'steps(3, nowhere)',
  'steps(-3, end)',
  'function (a){return a}',
  'function (x){return x}',
  'function(x, y){return 0.3}',
];

// Easings that should serialize to the same string
const gRoundtripEasings = [
  'ease',
  'linear',
  'ease-in',
  'ease-out',
  'ease-in-out',
  'cubic-bezier(0.1, 5, 0.23, 0)',
  'steps(3, start)',
  'steps(3)',
];