OLD | NEW |
| (Empty) |
1 <!-- | |
2 Copyright 2013 Google Inc. All Rights Reserved. | |
3 | |
4 Licensed under the Apache License, Version 2.0 (the "License"); | |
5 you may not use this file except in compliance with the License. | |
6 You may obtain a copy of the License at | |
7 | |
8 http://www.apache.org/licenses/LICENSE-2.0 | |
9 | |
10 Unless required by applicable law or agreed to in writing, software | |
11 distributed under the License is distributed on an "AS IS" BASIS, | |
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
13 See the License for the specific language governing permissions and | |
14 limitations under the License. | |
15 --> | |
16 | |
17 <!DOCTYPE html><meta charset="UTF-8"> | |
18 | |
19 <svg xmlns="http://www.w3.org/2000/svg" version="1.1"> | |
20 <path d="M0,0 L10,0 L30,0 L60,0 L100,0 L150,0" id="path" stroke="black" | |
21 stroke-width="1" fill="none" /> | |
22 </svg> | |
23 | |
24 <script src="../bootstrap.js"></script> | |
25 <script> | |
26 "use strict"; | |
27 | |
28 var PacedTimingFunction = _WebAnimationsTestingUtilities._pacedTimingFunction; | |
29 | |
30 var effect = | |
31 new MotionPathEffect(document.querySelector('#path').pathSegList); | |
32 | |
33 // Line has 5 segments of lengths 10, 20, 30, 40 and 50, giving a total length | |
34 // of 150. | |
35 var fullRangeTimingFunction = new PacedTimingFunction(effect); | |
36 fullRangeTimingFunction.setRange({min: 0, max: 1}); | |
37 | |
38 // Partial range runs from midpoint of first segment ot midpoint of last | |
39 // segment, giving total length of 5 + 20 + 30 + 40 + 25 = 120. | |
40 var partialRangeTimingFunction = new PacedTimingFunction(effect); | |
41 partialRangeTimingFunction.setRange({min: 0.1, max: 0.9}); | |
42 | |
43 test(function() { | |
44 assert_equals(fullRangeTimingFunction.scaleTime(0.5), (3 + 15/40) / 5); | |
45 }, 'Full range between bounds'); | |
46 | |
47 test(function() { | |
48 assert_equals(fullRangeTimingFunction.scaleTime(0), 0); | |
49 }, 'Full range lower bound'); | |
50 | |
51 test(function() { | |
52 assert_equals(fullRangeTimingFunction.scaleTime(1), 1); | |
53 }, 'Full range upper bound'); | |
54 | |
55 test(function() { | |
56 assert_equals(fullRangeTimingFunction.scaleTime(-0.5), 0); | |
57 }, 'Full range below lower bound'); | |
58 | |
59 test(function() { | |
60 assert_equals(fullRangeTimingFunction.scaleTime(1.5), 1); | |
61 }, 'Full range above upper bound'); | |
62 | |
63 test(function() { | |
64 assert_equals(partialRangeTimingFunction.scaleTime(0.5), (3 + 5/40) / 5); | |
65 }, 'Partial range between bounds'); | |
66 | |
67 test(function() { | |
68 assert_equals(partialRangeTimingFunction.scaleTime(0), 0.1); | |
69 }, 'Partial range lower bound'); | |
70 | |
71 test(function() { | |
72 assert_equals(partialRangeTimingFunction.scaleTime(1), 0.9); | |
73 }, 'Partial range upper bound'); | |
74 | |
75 test(function() { | |
76 assert_equals(partialRangeTimingFunction.scaleTime(-0.5), 0.1); | |
77 }, 'Partial range below lower bound'); | |
78 | |
79 test(function() { | |
80 assert_equals(partialRangeTimingFunction.scaleTime(1.5), 0.9); | |
81 }, 'Partial range above upper bound'); | |
82 | |
83 </script> | |
OLD | NEW |