OLD | NEW |
(Empty) | |
| 1 <!DOCTYPE html> |
| 2 <title>HitRegion Clip Test</title> |
| 3 <script src="../../resources/testharness.js"></script> |
| 4 <script src="../../resources/testharnessreport.js"></script> |
| 5 <script src="./resources/test-helpers.js"></script> |
| 6 <canvas width="400" height="400"></canvas> |
| 7 <style> |
| 8 |
| 9 body { |
| 10 margin : 0px; |
| 11 padding : 0px; |
| 12 } |
| 13 |
| 14 </style> |
| 15 <script> |
| 16 |
| 17 var canvas = document.querySelector('canvas'); |
| 18 var context = canvas.getContext('2d'); |
| 19 |
| 20 function simple_rect_clip_test(test_set) |
| 21 { |
| 22 context.save(); |
| 23 context.beginPath(); |
| 24 context.rect(0, 0, 100, 100); |
| 25 context.clip(); |
| 26 context.beginPath(); |
| 27 context.rect(50, 50, 100, 100); |
| 28 context.fill(); |
| 29 context.addHitRegion({ id : 'clip' }); |
| 30 context.restore(); |
| 31 generate_tests(assert_equals, test_set); |
| 32 } |
| 33 |
| 34 function non_rect_clip_test(test_set) |
| 35 { |
| 36 context.save(); |
| 37 context.beginPath(); |
| 38 context.arc(50, 50, 50, 0, Math.PI * 2); |
| 39 context.clip(); |
| 40 context.beginPath(); |
| 41 context.rect(0, 0, 100, 100); |
| 42 context.fill(); |
| 43 context.addHitRegion({ id : 'clip' }); |
| 44 context.restore(); |
| 45 generate_tests(assert_equals, test_set); |
| 46 } |
| 47 |
| 48 coroutine(function*() { |
| 49 setup({ explicit_done : true, explicit_timeout : true }); |
| 50 |
| 51 simple_rect_clip_test([ |
| 52 [ 'null', yield clickOrTouch(10, 10), null ], |
| 53 [ 'clip', yield clickOrTouch(60, 60), 'clip' ] |
| 54 ]); |
| 55 |
| 56 non_rect_clip_test([ |
| 57 [ 'null', yield clickOrTouch(0, 0), null ], |
| 58 [ 'null', yield clickOrTouch(100, 0), null ], |
| 59 [ 'null', yield clickOrTouch(100, 100), null ], |
| 60 [ 'null', yield clickOrTouch(0, 100), null ], |
| 61 [ 'clip', yield clickOrTouch(50, 50), 'clip' ] |
| 62 ]); |
| 63 |
| 64 done(); |
| 65 }); |
| 66 |
| 67 </script> |
OLD | NEW |