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 <div id="anim"></div> |
| 19 |
| 20 <script src="../bootstrap.js"></script> |
| 21 <script> |
| 22 "use strict"; |
| 23 |
| 24 var anim1 = new Animation(document.getElementById("anim"), {left: "100px"}, |
| 25 {iterations: 3.0, duration: 1.0}); |
| 26 var anim2 = new Animation(document.getElementById("anim"), {left: "100px"}, |
| 27 {duration: 2.0}); |
| 28 var parGroup = new ParGroup([anim1, anim2]); |
| 29 |
| 30 function expectDuration(anim, duration, error) { |
| 31 test(function() {assert_equals(anim.activeDuration, duration)}, error); |
| 32 } |
| 33 |
| 34 function expectEndTime(anim, endTime, error) { |
| 35 test(function() {assert_equals(anim.endTime, endTime)}, error); |
| 36 } |
| 37 |
| 38 expectDuration(anim1, 3.0, "Animation 1 duration should match specified value"); |
| 39 expectDuration(anim2, 2.0, "Animation 2 duration should match specified value"); |
| 40 expectDuration(parGroup, 3.0, |
| 41 "ParGroup duration should be max of childrens' end times"); |
| 42 anim1.specified.delay = 2.0; |
| 43 expectDuration(anim1, 3.0, "Animation 1 duration should not include delay"); |
| 44 expectEndTime(anim1, 5.0, "Animation 1 end time should include delay"); |
| 45 expectDuration(parGroup, 5.0, |
| 46 "ParGroup duration should still be max of childrens' end times"); |
| 47 anim2.specified.endDelay = 4.0; |
| 48 expectDuration(anim2, 2.0, "Animation 2 duration should not include endDelay"); |
| 49 expectEndTime(anim2, 6.0, "Animation 2 end time should include endDelay"); |
| 50 expectDuration(parGroup, 6.0, |
| 51 "ParGroup duration should STILL be max of childrens' end times"); |
| 52 |
| 53 var seqGroup = new SeqGroup([anim1, anim2]); |
| 54 expectDuration(seqGroup, 11.0, |
| 55 "SeqGroup duration should be sum of childrens' total durations"); |
| 56 expectEndTime(anim2, 11.0, "Animation 2 end time should include Animation 1"); |
| 57 anim1.specified.delay = 4.0; |
| 58 expectEndTime(anim2, 13.0, |
| 59 "Animation 2 end time should be updated by changes to animation 1 delay"); |
| 60 anim1.specified.endDelay = 3.0; |
| 61 expectDuration(anim1, 3.0, "Animation 1 duration should not include endDelay"); |
| 62 expectEndTime(anim1, 10.0, "Animation 1 end time should include endDelay"); |
| 63 expectEndTime(anim2, 16.0, "Animation 2 end time should include Animation 1 endD
elay"); |
| 64 expectDuration(seqGroup, 16.0, |
| 65 "SeqGroup duration should still be sum of childrens' total durations"); |
| 66 </script> |
OLD | NEW |