Add test coverage for radiusX / radiusY in WebPlatformTouchPoint.
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Nov 2016 18:35:51 +0000 (18:35 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 9 Nov 2016 18:35:51 +0000 (18:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=162801
<rdar://problem/28807455>

Reviewed by Darin Adler.

Add test coverage for radiusX / radiusY in WebPlatformTouchPoint.

* fast/events/touch/ios/touch-event-radius-expected.txt: Added.
* fast/events/touch/ios/touch-event-radius.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/fast/events/touch/ios/touch-event-radius-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/touch-event-radius.html [new file with mode: 0644]

index 99c6954..c5ae831 100644 (file)
@@ -1,3 +1,16 @@
+2016-11-09  Chris Dumez  <cdumez@apple.com>
+
+        Add test coverage for radiusX / radiusY in WebPlatformTouchPoint.
+        https://bugs.webkit.org/show_bug.cgi?id=162801
+        <rdar://problem/28807455>
+
+        Reviewed by Darin Adler.
+
+        Add test coverage for radiusX / radiusY in WebPlatformTouchPoint.
+
+        * fast/events/touch/ios/touch-event-radius-expected.txt: Added.
+        * fast/events/touch/ios/touch-event-radius.html: Added.
+
 2016-11-09  Youenn Fablet  <youenn@apple.com>
 
         [WebRTC] Introduce asynchronous backend for other RTCPeerConnection API
diff --git a/LayoutTests/fast/events/touch/ios/touch-event-radius-expected.txt b/LayoutTests/fast/events/touch/ios/touch-event-radius-expected.txt
new file mode 100644 (file)
index 0000000..0d24669
--- /dev/null
@@ -0,0 +1,3 @@
+PASS: radiusX is 56.8
+PASS: radiusY is 56.8
+
diff --git a/LayoutTests/fast/events/touch/ios/touch-event-radius.html b/LayoutTests/fast/events/touch/ios/touch-event-radius.html
new file mode 100644 (file)
index 0000000..65657f8
--- /dev/null
@@ -0,0 +1,104 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+
+<html>
+<head>
+    <script>
+        if (window.testRunner) {
+            testRunner.dumpAsText();
+            testRunner.waitUntilDone();
+        }
+
+        function getUIScript()
+        {
+            return `
+            (function() {
+                var eventStream = {
+                    events : [
+                        {
+                            inputType : "hand",
+                            timeOffset : 0,
+                            touches : [
+                                {
+                                    inputType : "finger",
+                                    phase : "began",
+                                    id : 1,
+                                    x : 20,
+                                    y : 40,
+                                    majorRadius: 0.10,
+                                    minorRadius: 0.10,
+                                }
+                            ]
+                        },
+                        {
+                            inputType : "hand",
+                            timeOffset : 0.0005,
+                            touches : [
+                                {
+                                    inputType : "finger",
+                                    phase : "ended",
+                                    id : 1,
+                                    x : 20,
+                                    y : 40,
+                                    majorRadius: 0.10,
+                                    minorRadius: 0.10,
+                                }
+                            ]
+                        },
+                    ]
+                };
+
+                uiController.sendEventStream(JSON.stringify(eventStream), function() {
+                    uiController.uiScriptComplete();
+                });
+            })();`
+        }
+
+        function runTest()
+        {
+            if (!testRunner.runUIScript)
+                return;
+
+            var output = '';
+            var target = document.getElementById('target');
+            var forces = [];
+            
+            target.addEventListener('touchstart', function(event) {
+                var expected = Math.round(0.10 * 568 * 10) / 10;
+                var radiusX = Math.round(event.touches[0].radiusX * 10) / 10;
+                if (radiusX == expected)
+                    output += 'PASS: radiusX is ' + expected + '<br>';
+                else
+                    output += 'FAIL: radiusX should be ' + expected + ', was ' + radiusX + '<br>';
+
+                var radiusY = Math.round(event.touches[0].radiusY * 10) / 10;
+                if (radiusY == expected)
+                    output += 'PASS: radiusY is ' + expected + '<br>';
+                else
+                    output += 'FAIL: radiusY should be ' + expected + ', was ' + radiusY + '<br>';
+            });
+            
+            if (testRunner.runUIScript) {
+                testRunner.runUIScript(getUIScript(), function(result) {
+                    document.getElementById('target').innerHTML = output;
+                    testRunner.notifyDone();
+               });
+            }
+        }
+
+        window.addEventListener('load', runTest, false);
+    </script>
+    <style>
+        #target {
+            height: 100px;
+            width: 200px;
+            background-color: silver;
+        }
+    </style>
+    <meta name="viewport" content="initial-scale=1">
+</head>
+<body>
+<div id="target">
+    This test requires UIScriptController to run.
+</div>
+</body>
+</html>