OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <meta charset=utf-8> | 2 <meta charset=utf-8> |
3 <title>Simple iteration progress tests</title> | 3 <title>Simple iteration progress tests</title> |
4 <link rel="help" | 4 <link rel="help" |
5 href="https://w3c.github.io/web-animations/#simple-iteration-progress"> | 5 href="https://w3c.github.io/web-animations/#simple-iteration-progress"> |
6 <script src="/resources/testharness.js"></script> | 6 <script src="/resources/testharness.js"></script> |
7 <script src="/resources/testharnessreport.js"></script> | 7 <script src="/resources/testharnessreport.js"></script> |
8 <script src="../../testcommon.js"></script> | 8 <script src="../../testcommon.js"></script> |
9 <body> | 9 <body> |
10 <div id="log"></div> | 10 <div id="log"></div> |
11 <script> | 11 <script> |
12 'use strict'; | 12 'use strict'; |
13 | 13 |
14 function executeTests(tests, description) { | 14 function runTests(tests, description) { |
15 tests.forEach(function(currentTest) { | 15 tests.forEach(function(currentTest) { |
16 var testParams = ''; | 16 var testParams = ''; |
17 for (var attr in currentTest.input) { | 17 for (var attr in currentTest.input) { |
18 testParams += ' ' + attr + ':' + currentTest.input[attr]; | 18 testParams += ' ' + attr + ':' + currentTest.input[attr]; |
19 } | 19 } |
20 test(function(t) { | 20 test(function(t) { |
21 var div = createDiv(t); | 21 var div = createDiv(t); |
22 var anim = div.animate({ opacity: [ 0, 1 ] }, currentTest.input); | 22 var anim = div.animate({ opacity: [ 0, 1 ] }, currentTest.input); |
23 assert_equals(anim.effect.getComputedTiming().progress, | 23 assert_equals(anim.effect.getComputedTiming().progress, |
24 currentTest.before); | 24 currentTest.before); |
25 anim.currentTime = currentTest.input.delay || 0; | 25 anim.currentTime = currentTest.input.delay || 0; |
26 assert_equals(anim.effect.getComputedTiming().progress, | 26 assert_equals(anim.effect.getComputedTiming().progress, |
27 currentTest.active); | 27 currentTest.active); |
28 if (typeof currentTest.after !== 'undefined') { | 28 if (typeof currentTest.after !== 'undefined') { |
29 anim.finish(); | 29 anim.finish(); |
30 assert_equals(anim.effect.getComputedTiming().progress, | 30 assert_equals(anim.effect.getComputedTiming().progress, |
31 currentTest.after); | 31 currentTest.after); |
32 } | 32 } |
33 }, description + testParams); | 33 }, description + ':' + testParams); |
34 }); | 34 }); |
35 } | 35 } |
36 | 36 |
37 var gTests_zero_iterations = [ | 37 |
| 38 // -------------------------------------------------------------------- |
| 39 // |
| 40 // Zero iteration duration tests |
| 41 // |
| 42 // -------------------------------------------------------------------- |
| 43 |
| 44 runTests([ |
38 { | 45 { |
39 input: { iterations: 0, | 46 input: { iterations: 0, |
40 iterationStart: 0, | 47 iterationStart: 0, |
41 duration: 0, | 48 duration: 0, |
42 delay: 1, | 49 delay: 1, |
43 fill: 'both' }, | 50 fill: 'both' }, |
44 before: 0, | 51 before: 0, |
45 active: 0, | 52 active: 0, |
46 after: 0 | 53 after: 0 |
47 }, | 54 }, |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 { | 133 { |
127 input: { iterations: 0, | 134 input: { iterations: 0, |
128 iterationStart: 3, | 135 iterationStart: 3, |
129 duration: Infinity, | 136 duration: Infinity, |
130 delay: 1, | 137 delay: 1, |
131 fill: 'both' }, | 138 fill: 'both' }, |
132 before: 0, | 139 before: 0, |
133 active: 0, | 140 active: 0, |
134 after: 0 | 141 after: 0 |
135 } | 142 } |
136 ]; | 143 ], 'Test zero iterations'); |
137 | 144 |
138 var gTests_integer_iterations = [ | 145 |
| 146 // -------------------------------------------------------------------- |
| 147 // |
| 148 // Tests where the iteration count is an integer |
| 149 // |
| 150 // -------------------------------------------------------------------- |
| 151 |
| 152 runTests([ |
139 { | 153 { |
140 input: { iterations: 3, | 154 input: { iterations: 3, |
141 iterationStart: 0, | 155 iterationStart: 0, |
142 duration: 0, | 156 duration: 0, |
143 delay: 1, | 157 delay: 1, |
144 fill: 'both' }, | 158 fill: 'both' }, |
145 before: 0, | 159 before: 0, |
146 active: 1, | 160 active: 1, |
147 after: 1 | 161 after: 1 |
148 }, | 162 }, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 | 238 |
225 { | 239 { |
226 input: { iterations: 3, | 240 input: { iterations: 3, |
227 iterationStart: 3, | 241 iterationStart: 3, |
228 duration: Infinity, | 242 duration: Infinity, |
229 delay: 1, | 243 delay: 1, |
230 fill: 'both' }, | 244 fill: 'both' }, |
231 before: 0, | 245 before: 0, |
232 active: 0 | 246 active: 0 |
233 } | 247 } |
234 ]; | 248 ], 'Test integer iterations'); |
235 | 249 |
236 var gTests_fractional_iterations = [ | 250 |
| 251 // -------------------------------------------------------------------- |
| 252 // |
| 253 // Tests where the iteration count is a fraction |
| 254 // |
| 255 // -------------------------------------------------------------------- |
| 256 |
| 257 runTests([ |
237 { | 258 { |
238 input: { iterations: 3.5, | 259 input: { iterations: 3.5, |
239 iterationStart: 0, | 260 iterationStart: 0, |
240 duration: 0, | 261 duration: 0, |
241 delay: 1, | 262 delay: 1, |
242 fill: 'both' }, | 263 fill: 'both' }, |
243 before: 0, | 264 before: 0, |
244 active: 0.5, | 265 active: 0.5, |
245 after: 0.5 | 266 after: 0.5 |
246 }, | 267 }, |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 | 343 |
323 { | 344 { |
324 input: { iterations: 3.5, | 345 input: { iterations: 3.5, |
325 iterationStart: 3, | 346 iterationStart: 3, |
326 duration: Infinity, | 347 duration: Infinity, |
327 delay: 1, | 348 delay: 1, |
328 fill: 'both' }, | 349 fill: 'both' }, |
329 before: 0, | 350 before: 0, |
330 active: 0 | 351 active: 0 |
331 } | 352 } |
332 ]; | 353 ], 'Test fractional iterations'); |
333 | 354 |
334 var gTests_infinity_iterations = [ | 355 |
| 356 // -------------------------------------------------------------------- |
| 357 // |
| 358 // Tests where the iteration count is Infinity |
| 359 // |
| 360 // -------------------------------------------------------------------- |
| 361 |
| 362 runTests([ |
335 { | 363 { |
336 input: { iterations: Infinity, | 364 input: { iterations: Infinity, |
337 iterationStart: 0, | 365 iterationStart: 0, |
338 duration: 0, | 366 duration: 0, |
339 delay: 1, | 367 delay: 1, |
340 fill: 'both' }, | 368 fill: 'both' }, |
341 before: 0, | 369 before: 0, |
342 active: 1, | 370 active: 1, |
343 after: 1 | 371 after: 1 |
344 }, | 372 }, |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
417 | 445 |
418 { | 446 { |
419 input: { iterations: Infinity, | 447 input: { iterations: Infinity, |
420 iterationStart: 3, | 448 iterationStart: 3, |
421 duration: Infinity, | 449 duration: Infinity, |
422 delay: 1, | 450 delay: 1, |
423 fill: 'both' }, | 451 fill: 'both' }, |
424 before: 0, | 452 before: 0, |
425 active: 0 | 453 active: 0 |
426 } | 454 } |
427 ]; | 455 ], 'Test infinity iterations'); |
428 | 456 |
429 executeTests(gTests_zero_iterations, "Test zero iterations:"); | 457 |
430 executeTests(gTests_integer_iterations, "Test integer iterations:"); | 458 // -------------------------------------------------------------------- |
431 executeTests(gTests_fractional_iterations, "Test fractional iterations:"); | 459 // |
432 executeTests(gTests_infinity_iterations, "Test infinity iterations:"); | 460 // End delay tests |
| 461 // |
| 462 // -------------------------------------------------------------------- |
| 463 |
| 464 runTests([ |
| 465 { |
| 466 input: { duration: 100, |
| 467 delay: 1, |
| 468 fill: 'both', |
| 469 endDelay: 50 }, |
| 470 before: 0, |
| 471 active: 0, |
| 472 after: 1 |
| 473 }, |
| 474 |
| 475 { |
| 476 input: { duration: 100, |
| 477 delay: 1, |
| 478 fill: 'both', |
| 479 endDelay: -50 }, |
| 480 before: 0, |
| 481 active: 0, |
| 482 after: 0.5 |
| 483 }, |
| 484 |
| 485 { |
| 486 input: { duration: 100, |
| 487 delay: 1, |
| 488 fill: 'both', |
| 489 endDelay: -100 }, |
| 490 before: 0, |
| 491 active: 0, |
| 492 after: 0 |
| 493 }, |
| 494 |
| 495 { |
| 496 input: { duration: 100, |
| 497 delay: 1, |
| 498 fill: 'both', |
| 499 endDelay: -200 }, |
| 500 before: 0, |
| 501 active: 0, |
| 502 after: 0 |
| 503 }, |
| 504 |
| 505 { |
| 506 input: { iterationStart: 0.5, |
| 507 duration: 100, |
| 508 delay: 1, |
| 509 fill: 'both', |
| 510 endDelay: 50 }, |
| 511 before: 0.5, |
| 512 active: 0.5, |
| 513 after: 0.5 |
| 514 }, |
| 515 |
| 516 { |
| 517 input: { iterationStart: 0.5, |
| 518 duration: 100, |
| 519 delay: 1, |
| 520 fill: 'both', |
| 521 endDelay: -50 }, |
| 522 before: 0.5, |
| 523 active: 0.5, |
| 524 after: 1 |
| 525 }, |
| 526 |
| 527 { |
| 528 input: { iterationStart: 0.5, |
| 529 duration: 100, |
| 530 delay: 1, |
| 531 fill: 'both', |
| 532 endDelay: -100 }, |
| 533 before: 0.5, |
| 534 active: 0.5, |
| 535 after: 0.5 |
| 536 }, |
| 537 |
| 538 { |
| 539 input: { iterations: 2, |
| 540 duration: 100, |
| 541 delay: 1, |
| 542 fill: 'both', |
| 543 endDelay: -100 }, |
| 544 before: 0, |
| 545 active: 0, |
| 546 after: 1 |
| 547 }, |
| 548 |
| 549 { |
| 550 input: { iterations: 1, |
| 551 iterationStart: 2, |
| 552 duration: 100, |
| 553 delay: 1, |
| 554 fill: 'both', |
| 555 endDelay: -50 }, |
| 556 before: 0, |
| 557 active: 0, |
| 558 after: 0.5 |
| 559 }, |
| 560 |
| 561 { |
| 562 input: { iterations: 1, |
| 563 iterationStart: 2, |
| 564 duration: 100, |
| 565 delay: 1, |
| 566 fill: 'both', |
| 567 endDelay: -100 }, |
| 568 before: 0, |
| 569 active: 0, |
| 570 after: 0 |
| 571 }, |
| 572 ], 'Test end delay'); |
433 | 573 |
434 </script> | 574 </script> |
435 </body> | 575 </body> |
OLD | NEW |