Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(965)

Side by Side Diff: LayoutTests/canvas/philip/tests/2d.text.draw.text.metrics.html

Issue 950773003: Improve 2D Canvas Text Metrics Test (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Adding missing endTest() statements Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Canvas test: 2d.text.draw.text.metrics</title> 2 <title>Canvas test: 2d.text.draw.text.metrics</title>
3 <script src="../tests.js"></script> 3 <script src="../tests.js"></script>
4 <link rel="stylesheet" href="../tests.css"> 4 <link rel="stylesheet" href="../tests.css">
5 <style> 5 <style>
6 @font-face { 6 @font-face {
7 font-family: CanvasTest; 7 font-family: Libertine;
8 src: url("../fonts/CanvasTest.ttf"); 8 src: url("../../../third_party/Libertine/LinLibertine_R.woff");
9 } 9 }
10 </style> 10 </style>
11 <body> 11 <body>
12 <p id="passtext">Pass</p> 12 <p id="passtext">Pass</p>
13 <p id="failtext">Fail</p> 13 <p id="failtext">Fail</p>
14 <span style="font-family: CanvasTest; position: absolute; visibility: hidden">A< /span>
15 <p class="output">These images should be identical:</p> 14 <p class="output">These images should be identical:</p>
16 <canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL ( fallback content)</p></canvas> 15 <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" cl ass="output expected" id="expected" alt=""> 16 <p class="output expectedtext">Expected output:<p><img src="green-100x50.png" cl ass="output expected" id="expected" alt="">
18 <ul id="d"></ul> 17 <ul id="d"></ul>
19 <script> 18 <script>
20 function _printTextMetrics(ctx) { 19 function _printTextMetrics(ctx) {
21 var someText = "Some Text"; 20 var someText = "Some Text";
22 var highText = "M"; 21 var highText = "M";
23 var lowText = "q"; 22 var lowText = "q";
24 var textMetrics = ctx.measureText(someText); 23 var textMetrics = ctx.measureText(someText);
(...skipping 24 matching lines...) Expand all
49 _warn("eM Height Ascent: " + ea); 48 _warn("eM Height Ascent: " + ea);
50 _warn("eM Height Descent: " + ed); 49 _warn("eM Height Descent: " + ed);
51 _warn("Actual Bounding Box Left: " + lb); 50 _warn("Actual Bounding Box Left: " + lb);
52 _warn("Actual Bounding Box Right: " + rb); 51 _warn("Actual Bounding Box Right: " + rb);
53 _warn("Actual Bounding Box Ascent (high): " + ah); 52 _warn("Actual Bounding Box Ascent (high): " + ah);
54 _warn("Actual Bounding Box Ascent (low): " + al); 53 _warn("Actual Bounding Box Ascent (low): " + al);
55 _warn("Actual Bounding Box Descent (high): " + dh); 54 _warn("Actual Bounding Box Descent (high): " + dh);
56 _warn("Actual Bounding Box Descent (low): " + dl); 55 _warn("Actual Bounding Box Descent (low): " + dl);
57 } 56 }
58 57
59 _addTest(function(canvas, ctx) {
60 58
61 ctx.font = '50px CanvasTest'; 59 function measureMetrics(ctx) {
62 deferTest();
63 setTimeout(wrapFunction(function () {
64 ctx.fillStyle = '#f00'; 60 ctx.fillStyle = '#f00';
65 ctx.fillRect(0, 0, 100, 50); 61 ctx.fillRect(0, 0, 100, 50);
66 ctx.fillStyle = '#0f0'; 62 ctx.fillStyle = '#0f0';
67 63
68 ctx.textBaseline="top"; 64 ctx.textBaseline="top";
69 _warn("Baseline: top"); 65 _warn("Baseline: top");
70 _printTextMetrics(ctx); 66 _printTextMetrics(ctx);
71 67
72 ctx.textBaseline="hanging"; 68 ctx.textBaseline="hanging";
73 _warn("Baseline: hanging"); 69 _warn("Baseline: hanging");
74 _printTextMetrics(ctx); 70 _printTextMetrics(ctx);
75 71
76 ctx.textBaseline="middle"; 72 ctx.textBaseline="middle";
77 _warn("Baseline: middle"); 73 _warn("Baseline: middle");
78 _printTextMetrics(ctx); 74 _printTextMetrics(ctx);
79 75
80 ctx.textBaseline="alphabetic"; 76 ctx.textBaseline="alphabetic";
81 _warn("Baseline: alphabetic"); 77 _warn("Baseline: alphabetic");
82 _printTextMetrics(ctx); 78 _printTextMetrics(ctx);
83 79
84 ctx.textBaseline="ideographic"; 80 ctx.textBaseline="ideographic";
85 _warn("Baseline: ideographic"); 81 _warn("Baseline: ideographic");
86 _printTextMetrics(ctx); 82 _printTextMetrics(ctx);
87 83
88 ctx.textBaseline="bottom"; 84 ctx.textBaseline="bottom";
89 _warn("Baseline: bottom"); 85 _warn("Baseline: bottom");
90 _printTextMetrics(ctx); 86 _printTextMetrics(ctx);
91 }), 500);
92 87
88 endTest();
89 }
93 90
91 function handleError() {
92 _warn("Unable to load required test font.");
93 endTest();
94 }
95
96 _addTest(function(canvas, ctx) {
97 ctx.font = '50px Libertine';
98 deferTest();
99 document.fonts.load(ctx.font)
100 .then(function() { measureMetrics(ctx) }, handleError);
94 }); 101 });
95 </script> 102 </script>
96 103
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698