Convert ManualTests/svg-tooltip.svg to a DRT test
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Mar 2015 22:43:34 +0000 (22:43 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Mar 2015 22:43:34 +0000 (22:43 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140480

Patch by Daniel Bates <dabates@apple.com> on 2015-03-03
Reviewed by Alex Christensen.

.:

* ManualTests/svg-tooltip.svg: Removed.

LayoutTests:

* svg/hittest/svg-tooltip-expected.txt: Added.
* svg/hittest/svg-tooltip.svg: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@180957 268f45cc-cd09-0410-ab3c-d52691b4dbfc

ChangeLog
LayoutTests/ChangeLog
LayoutTests/svg/hittest/svg-tooltip-expected.txt [new file with mode: 0644]
LayoutTests/svg/hittest/svg-tooltip.svg [new file with mode: 0644]
ManualTests/svg-tooltip.svg [deleted file]

index 1941f1b..c364814 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2015-03-03  Daniel Bates  <dabates@apple.com>
+
+        Convert ManualTests/svg-tooltip.svg to a DRT test
+        https://bugs.webkit.org/show_bug.cgi?id=140480
+
+        Reviewed by Alex Christensen.
+
+        * ManualTests/svg-tooltip.svg: Removed.
+
 2015-03-02  Debarshi Ray  <debarshir@gnome.org>
 
         REGRESSION(r179409): [GTK] Undefined symbol prevents web extensions from being loaded
index 695ad12..738c65a 100644 (file)
@@ -1,3 +1,13 @@
+2015-03-03  Daniel Bates  <dabates@apple.com>
+
+        Convert ManualTests/svg-tooltip.svg to a DRT test
+        https://bugs.webkit.org/show_bug.cgi?id=140480
+
+        Reviewed by Alex Christensen.
+
+        * svg/hittest/svg-tooltip-expected.txt: Added.
+        * svg/hittest/svg-tooltip.svg: Added.
+
 2015-03-03  Timothy Horton  <timothy_horton@apple.com>
 
         <attachment> label can get very wide, doesn't wrap/truncate
diff --git a/LayoutTests/svg/hittest/svg-tooltip-expected.txt b/LayoutTests/svg/hittest/svg-tooltip-expected.txt
new file mode 100644 (file)
index 0000000..e91f7c2
--- /dev/null
@@ -0,0 +1,10 @@
+PASS document.title is 'SVG Tooltips'.
+PASS tooltip for <ellipse id="e1"> is 'PASS'.
+PASS tooltip for <ellipse id="e2"> is 'PASS'.
+PASS tooltip for <ellipse id="e3"> is 'PASS'.
+PASS tooltip for <use id="e4"> is ''.
+PASS tooltip for <use id="e5"> is 'PASS'.
+PASS tooltip for <ellipse id="e6"> is 'PASS'.
+PASS tooltip for <use id="e7"> is ''.
+PASS tooltip for <use id="e8"> is 'PASS'.
+
diff --git a/LayoutTests/svg/hittest/svg-tooltip.svg b/LayoutTests/svg/hittest/svg-tooltip.svg
new file mode 100644 (file)
index 0000000..0bae906
--- /dev/null
@@ -0,0 +1,120 @@
+<?xml version="1.0"?>
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
+    <style type="text/css">
+    <![CDATA[
+    text {
+        display: block;
+    }
+    ]]>
+    </style>
+    <script type="text/javascript">
+    <![CDATA[
+    if (window.testRunner)
+        testRunner.dumpAsText();
+
+    function log(message)
+    {
+        document.getElementById("log").appendChild(document.createTextNode(message + "\n"))
+    }
+
+    function testTooltipForElement(element)
+    {
+        console.assert(window.internals);
+        console.assert(element.id);
+        var testCaseName = "<" + element.tagName + ' id="' + element.id + '"' + ">";
+        var tooltip = internals.toolTipFromElement(element);
+        var expectedTooltip = element.getAttribute("data-expected-tooltip");
+        if (tooltip == expectedTooltip)
+            log("PASS tooltip for " + testCaseName + " is '" + expectedTooltip + "'.");
+        else
+            log("FAIL tooltip for " + testCaseName + " should be '" + expectedTooltip + "'. Was '" + tooltip + "'.");
+    }
+
+    function testDocumentTitle()
+    {
+        var expectedTitle = document.getElementById("expected-document-title").textContent;
+        if (document.title == expectedTitle)
+            log("PASS document.title is '" + expectedTitle + "'.");
+        else
+            log("FAIL document.title should be '" + expectedTitle + "'. Was '" + document.title + "'.");
+    }
+
+    function runTest()
+    {
+        if (!window.testRunner || !window.internals)
+            return;
+
+        testDocumentTitle();
+        var testCases = document.querySelectorAll(".test-case");
+        for (var i = 0; i < testCases.length; ++i)
+            testTooltipForElement(testCases[i]);
+
+        // Hide all <text> elements that describe the expected result for a human as they are not applicable
+        // when running this test in DRT/WTR.
+        document.styleSheets[0].rules[0].style.display = "none";
+    }
+
+    window.onload = runTest;
+    ]]>
+    </script>
+    <title id="expected-document-title">SVG Tooltips</title>
+    <defs>
+        <ellipse id="e4" cx="100" cy="200" rx="50" ry="30" fill="blue">
+            <title>PASS</title>
+        </ellipse>
+        <ellipse id="e5" cx="250" cy="200" rx="50" ry="30" fill="blue">
+            <title>FAIL</title>
+        </ellipse>
+        <symbol id="e7">
+            <ellipse cx="100" cy="300" rx="50" ry="30" fill="blue">
+            <title>PASS</title>
+            </ellipse>
+        </symbol>
+        <symbol id="e8">
+            <title>FAIL</title>
+            <ellipse cx="250" cy="300" rx="50" ry="30" fill="blue">
+            </ellipse>
+        </symbol>
+    </defs>
+
+    <text y="15" x="0" id="manual-instructions">Hover the cursor over each shape (below). This test passed if the tooltip for each shape that has a tooltip is "PASS". Otherwise, this test failed.</text>
+
+    <ellipse id="e1" cx="100" cy="100" rx="50" ry="30" fill="blue" class="test-case" data-expected-tooltip="PASS">
+        <title>PASS</title>
+    </ellipse>
+
+    <g>
+        <title>PASS</title>
+        <ellipse id="e2" cx="250" cy="100" rx="50" ry="30" fill="blue" class="test-case" data-expected-tooltip="PASS"/>
+    </g>
+
+    <a xlink:title="PASS" xlink:href="#">
+        <title>FAIL</title>
+        <ellipse id="e3" cx="400" cy="100" rx="50" ry="30" fill="blue" class="test-case" data-expected-tooltip="PASS"/>
+    </a>
+
+    <use id="e4" xlink:href="#e4" class="test-case" data-expected-tooltip=""/>
+    <text x="100" y="200" text-anchor="middle" fill="white">(no tooltip)</text>
+
+    <use id="e5" xlink:href="#e5" class="test-case" data-expected-tooltip="PASS">
+        <title>PASS</title>
+    </use>
+
+    <g>
+        <title>FAIL</title>
+        <ellipse id="e6" cx="400" cy="200" rx="50" ry="30" fill="blue" class="test-case" data-expected-tooltip="PASS">
+            <title>PASS</title>
+        </ellipse>
+    </g>
+
+    <use id="e7" xlink:href="#e7" class="test-case" data-expected-tooltip=""/>
+    <text x="100" y="300" text-anchor="middle" fill="white">(no tooltip)</text>
+
+    <use id="e8" xlink:href="#e8" class="test-case" data-expected-tooltip="PASS">
+        <title>PASS</title>
+    </use>
+
+    <foreignObject y="400" width="600" height="400">
+        <pre id="log" xmlns="http://www.w3.org/1999/xhtml"></pre>
+    </foreignObject>
+</svg>
diff --git a/ManualTests/svg-tooltip.svg b/ManualTests/svg-tooltip.svg
deleted file mode 100644 (file)
index 84fe1d7..0000000
+++ /dev/null
@@ -1,62 +0,0 @@
-<?xml version="1.0"?>
-<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
-  <title>This string should not show up as a tooltip</title>
-  <desc>
-  This test verifies that tooltips are properly rendered for SVG content in a variety of
-  scenarios.  Hovering over every shape should result in a tooltip of "PASS".
-  </desc>
-  <defs>
-    <ellipse id="e1" cx="100" cy="200" rx="50" ry="30" fill="blue">
-      <title>PASS</title>
-    </ellipse>
-    <ellipse id="e2" cx="250" cy="200" rx="50" ry="30" fill="blue">
-      <title>FAIL</title>
-    </ellipse>
-    <symbol id="e3">
-      <ellipse cx="100" cy="300" rx="50" ry="30" fill="blue">
-        <title>PASS</title>
-      </ellipse>
-    </symbol>
-    <symbol id="e4">
-      <title>FAIL</title>
-      <ellipse cx="250" cy="300" rx="50" ry="30" fill="blue">
-      </ellipse>
-    </symbol>
-  </defs>
-
-  <text y="15" x="0">When hovered, all shapes should show a "PASS" tooltip.  Anything else is a failure.</text>
-  
-  <ellipse cx="100" cy="100" rx="50" ry="30" fill="blue">
-    <title>PASS</title>
-  </ellipse>
-
-  <g>
-    <title>PASS</title>
-    <ellipse cx="250" cy="100" rx="50" ry="30" fill="blue"/>
-  </g>
-
-  <a xlink:title="PASS" xlink:href="#">
-    <title>FAIL</title>
-    <ellipse id="e4" cx="400" cy="100" rx="50" ry="30" fill="blue"/>
-  </a>
-  
-  <use xlink:href="#e1"/>
-  
-  <use xlink:href="#e2">
-    <title>PASS</title>
-  </use>
-
-  <g>
-    <title>FAIL</title>
-    <ellipse id="e8" cx="400" cy="200" rx="50" ry="30" fill="blue">
-      <title>PASS</title>
-    </ellipse>
-  </g>
-  
-  <use xlink:href="#e3"/>
-  <use xlink:href="#e4">
-    <title>PASS</title>
-  </use>
-  
-  
-</svg>