chang.shu@nokia.com | d5cb910 | 2010-05-21 20:47:13 +0000 | [diff] [blame] | 1 | <!DOCTYPE html> |
| 2 | <title>Canvas test: 2d.text.draw.baseline.middle</title> |
| 3 | <script src="../tests.js"></script> |
| 4 | <link rel="stylesheet" href="../tests.css"> |
chang.shu@nokia.com | d5cb910 | 2010-05-21 20:47:13 +0000 | [diff] [blame] | 5 | <style> |
| 6 | @font-face { |
| 7 | font-family: CanvasTest; |
| 8 | src: url("../fonts/CanvasTest.ttf"); |
| 9 | } |
andreas.kling@nokia.com | 7817c16 | 2010-11-07 13:49:39 +0000 | [diff] [blame] | 10 | </style> |
| 11 | <body> |
| 12 | <p id="passtext">Pass</p> |
| 13 | <p id="failtext">Fail</p> |
chang.shu@nokia.com | d5cb910 | 2010-05-21 20:47:13 +0000 | [diff] [blame] | 14 | <span style="font-family: CanvasTest; position: absolute; visibility: hidden">A</span> |
andreas.kling@nokia.com | 7817c16 | 2010-11-07 13:49:39 +0000 | [diff] [blame] | 15 | <p class="output">These images should be identical:</p> |
chang.shu@nokia.com | d5cb910 | 2010-05-21 20:47:13 +0000 | [diff] [blame] | 16 | <canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas> |
| 17 | <p class="output expectedtext">Expected output:<p><img src="green-100x50.png" class="output expected" id="expected" alt=""> |
| 18 | <ul id="d"></ul> |
| 19 | <script> |
| 20 | _addTest(function(canvas, ctx) { |
| 21 | |
| 22 | ctx.font = '50px CanvasTest'; |
| 23 | deferTest(); |
| 24 | setTimeout(wrapFunction(function () { |
| 25 | ctx.fillStyle = '#f00'; |
| 26 | ctx.fillRect(0, 0, 100, 50); |
| 27 | ctx.fillStyle = '#0f0'; |
| 28 | ctx.textBaseline = 'middle'; |
| 29 | ctx.fillText('CC', 0, 25); |
| 30 | _assertPixelApprox(canvas, 5,5, 0,255,0,255, "5,5", "0,255,0,255", 2); |
| 31 | _assertPixelApprox(canvas, 95,5, 0,255,0,255, "95,5", "0,255,0,255", 2); |
| 32 | _assertPixelApprox(canvas, 25,25, 0,255,0,255, "25,25", "0,255,0,255", 2); |
| 33 | _assertPixelApprox(canvas, 75,25, 0,255,0,255, "75,25", "0,255,0,255", 2); |
| 34 | _assertPixelApprox(canvas, 5,45, 0,255,0,255, "5,45", "0,255,0,255", 2); |
| 35 | _assertPixelApprox(canvas, 95,45, 0,255,0,255, "95,45", "0,255,0,255", 2); |
| 36 | }), 500); |
| 37 | |
| 38 | |
| 39 | }); |
| 40 | </script> |
| 41 | |