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

Unified Diff: third_party/WebKit/LayoutTests/canvas/philip/tests/2d.text.draw.text.metrics.html

Issue 2232243002: Rewrite canvas/philip/tests/2d.text.draw.text.metrics.html test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: needs to be a async_test Created 4 years, 4 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/canvas/philip/tests/2d.text.draw.text.metrics.html
diff --git a/third_party/WebKit/LayoutTests/canvas/philip/tests/2d.text.draw.text.metrics.html b/third_party/WebKit/LayoutTests/canvas/philip/tests/2d.text.draw.text.metrics.html
deleted file mode 100644
index dfd5e00536438a388fa04ce5342dce17d3a38205..0000000000000000000000000000000000000000
--- a/third_party/WebKit/LayoutTests/canvas/philip/tests/2d.text.draw.text.metrics.html
+++ /dev/null
@@ -1,103 +0,0 @@
-<!DOCTYPE html>
-<title>Canvas test: 2d.text.draw.text.metrics</title>
-<script src="../tests.js"></script>
-<link rel="stylesheet" href="../tests.css">
-<style>
-@font-face {
- font-family: Libertine;
- src: url("../../../third_party/Libertine/LinLibertine_R.woff");
-}
-</style>
-<body>
-<p id="passtext">Pass</p>
-<p id="failtext">Fail</p>
-<p class="output">These images should be identical:</p>
-<canvas id="c" class="output" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
-<p class="output expectedtext">Expected output:<p><img src="green-100x50.png" class="output expected" id="expected" alt="">
-<ul id="d"></ul>
-<script>
-function _printTextMetrics(ctx) {
- var someText = "Some Text";
- var highText = "M";
- var lowText = "q";
- var textMetrics = ctx.measureText(someText);
- var highTextMetrics = ctx.measureText(highText);
- var lowTextMetrics = ctx.measureText(lowText);
- var w = textMetrics.width;
- var ab = textMetrics.alphabeticBaseline;
- var hb = textMetrics.hangingBaseline;
- var ib = textMetrics.ideographicBaseline;
- var fa = textMetrics.fontBoundingBoxAscent;
- var fd = textMetrics.fontBoundingBoxDescent;
- var ea = textMetrics.emHeightAscent;
- var ed = textMetrics.emHeightDescent;
- var lb = textMetrics.actualBoundingBoxLeft;
- var rb = textMetrics.actualBoundingBoxRight;
-
- var ah = highTextMetrics.actualBoundingBoxAscent;
- var al = lowTextMetrics.actualBoundingBoxAscent;
- var dh = highTextMetrics.actualBoundingBoxDescent;
- var dl = lowTextMetrics.actualBoundingBoxDescent;
-
- _warn("Width: " + w);
- _warn("Alphabetic Baseline: " + ab);
- _warn("Hanging Baseline: " + hb);
- _warn("Ideographic Baseline: " + ib);
- _warn("Font Bounding Box Ascent: " + fa);
- _warn("Font Bounding Box Descent: " + fd);
- _warn("eM Height Ascent: " + ea);
- _warn("eM Height Descent: " + ed);
- _warn("Actual Bounding Box Left: " + lb);
- _warn("Actual Bounding Box Right: " + rb);
- _warn("Actual Bounding Box Ascent (high): " + ah);
- _warn("Actual Bounding Box Ascent (low): " + al);
- _warn("Actual Bounding Box Descent (high): " + dh);
- _warn("Actual Bounding Box Descent (low): " + dl);
-}
-
-
-function measureMetrics(ctx) {
- ctx.fillStyle = '#f00';
- ctx.fillRect(0, 0, 100, 50);
- ctx.fillStyle = '#0f0';
-
- ctx.textBaseline="top";
- _warn("Baseline: top");
- _printTextMetrics(ctx);
-
- ctx.textBaseline="hanging";
- _warn("Baseline: hanging");
- _printTextMetrics(ctx);
-
- ctx.textBaseline="middle";
- _warn("Baseline: middle");
- _printTextMetrics(ctx);
-
- ctx.textBaseline="alphabetic";
- _warn("Baseline: alphabetic");
- _printTextMetrics(ctx);
-
- ctx.textBaseline="ideographic";
- _warn("Baseline: ideographic");
- _printTextMetrics(ctx);
-
- ctx.textBaseline="bottom";
- _warn("Baseline: bottom");
- _printTextMetrics(ctx);
-
- endTest();
-}
-
-function handleError() {
- _warn("Unable to load required test font.");
- endTest();
-}
-
-_addTest(function(canvas, ctx) {
- ctx.font = '50px Libertine';
- deferTest();
- document.fonts.load(ctx.font)
- .then(function() { measureMetrics(ctx) }, handleError);
-});
-</script>
-

Powered by Google App Engine
This is Rietveld 408576698