Title: [222813] trunk/LayoutTests
Revision
222813
Author
megan_gard...@apple.com
Date
2017-10-03 15:12:37 -0700 (Tue, 03 Oct 2017)

Log Message

Add long press and drag test
https://bugs.webkit.org/show_bug.cgi?id=177289

Reviewed by Wenson Hsieh.

Adding a test to test the long press and then drag functionality of selection.
Also add additional helper functions to basic gestures, so that this and other
tests can be written. Mostly deals with not lifting between gestures.

* fast/events/touch/ios/long-press-then-drag-to-select-text-expected.txt: Added.
* fast/events/touch/ios/long-press-then-drag-to-select-text.html: Added.
* fast/events/touch/ios/resources/basic-gestures.js:
(longPressAndHoldAtPoint):
(touchAndDragFromPointToPoint):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (222812 => 222813)


--- trunk/LayoutTests/ChangeLog	2017-10-03 21:56:53 UTC (rev 222812)
+++ trunk/LayoutTests/ChangeLog	2017-10-03 22:12:37 UTC (rev 222813)
@@ -1,3 +1,20 @@
+2017-10-03  Megan Gardner  <megan_gard...@apple.com>
+
+        Add long press and drag test
+        https://bugs.webkit.org/show_bug.cgi?id=177289
+
+        Reviewed by Wenson Hsieh.
+
+        Adding a test to test the long press and then drag functionality of selection.
+        Also add additional helper functions to basic gestures, so that this and other
+        tests can be written. Mostly deals with not lifting between gestures.
+
+        * fast/events/touch/ios/long-press-then-drag-to-select-text-expected.txt: Added.
+        * fast/events/touch/ios/long-press-then-drag-to-select-text.html: Added.
+        * fast/events/touch/ios/resources/basic-gestures.js:
+        (longPressAndHoldAtPoint):
+        (touchAndDragFromPointToPoint):
+
 2017-10-03  Ryan Haddad  <ryanhad...@apple.com>
 
         Skip imported/w3c/web-platform-tests/payment-request/rejects_if_not_active.https.html on iOS.

Added: trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-to-select-text-expected.txt (0 => 222813)


--- trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-to-select-text-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-to-select-text-expected.txt	2017-10-03 22:12:37 UTC (rev 222813)
@@ -0,0 +1,3 @@
+PASS: Correct Selection
+PASS: Correct Selection
+

Added: trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-to-select-text.html (0 => 222813)


--- trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-to-select-text.html	                        (rev 0)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-to-select-text.html	2017-10-03 22:12:37 UTC (rev 222813)
@@ -0,0 +1,68 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <script src=""
+    <script>
+        if (window.testRunner) {
+            testRunner.dumpAsText();
+            testRunner.waitUntilDone();
+        }
+    
+        function runTest()
+        {
+            if (!testRunner.runUIScript)
+                return;
+
+            var output = '';
+            var firstTargetRect = document.getElementById('firstSelection').getBoundingClientRect();
+            var secondTargetRect = document.getElementById('secondSelection').getBoundingClientRect();
+        
+            var pressPointX = firstTargetRect.x + firstTargetRect.width / 2;
+            var pressPointY = firstTargetRect.y + firstTargetRect.height / 2;
+            var dragX = secondTargetRect.x + secondTargetRect.width / 2;
+            var dragY = secondTargetRect.y + secondTargetRect.height / 2;
+        
+            if (testRunner.runUIScript) {
+                testRunner.runUIScript(longPressAndHoldAtPoint(pressPointX, pressPointY), function(result) {
+                    if (document.getSelection().toString() == "magna")
+                        output += 'PASS: Correct Selection';
+                    else
+                        output += 'FAIL: failed to select a word as a result of a long press. Incorrect Selection: ' + document.getSelection().toString();
+                    output += '<br>';
+
+                    testRunner.runUIScript(continueTouchAndDragFromPointToPoint(pressPointX, pressPointY, dragX, dragY), function(result) {
+                        if (document.getSelection().toString() == "labore")
+                            output += 'PASS: Correct Selection';
+                        else
+                            output += 'FAIL: failed to reduce selection to a single character by dragging down. Incorrect Selection: ' +     document.getSelection().toString();
+                        output += '<br>';
+                        output += result;
+                        document.getElementById('target').innerHTML = output;
+                        testRunner.notifyDone();
+                    });
+                });
+            }
+        }
+
+        window.addEventListener('load', runTest, false);
+    </script>
+    <style>
+        #target {
+            height: 400px;
+            width: 300px;
+            background-color: silver;
+            font-family: monospace;
+            font-size: 18px;
+        }
+    </style>
+    <meta name="viewport" content="initial-scale=1">
+</head>
+<body>
+    <div id="target">
+        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut <span id="secondSelection">labore</span> et dolore <span id="firstSelection">magna</span> aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
+        
+        This test requires UIScriptController to run.
+    </div>
+</body>
+</html>

Modified: trunk/LayoutTests/fast/events/touch/ios/resources/basic-gestures.js (222812 => 222813)


--- trunk/LayoutTests/fast/events/touch/ios/resources/basic-gestures.js	2017-10-03 21:56:53 UTC (rev 222812)
+++ trunk/LayoutTests/fast/events/touch/ios/resources/basic-gestures.js	2017-10-03 22:12:37 UTC (rev 222813)
@@ -8,6 +8,51 @@
     })();`
 }
 
+function longPressAndHoldAtPoint(X, Y)
+{
+    return `
+    (function() {
+    var eventStream = {
+    events : [
+        {
+            interpolate : "linear",
+            timestep: 0.1,
+            coordinateSpace : "content",
+            startEvent : {
+                inputType : "hand",
+                timeOffset : 0,
+                touches : [
+                    {
+                        inputType : "finger",
+                        phase : "began",
+                        id : 1,
+                        x : ${X},
+                        y : ${Y},
+                        pressure : 0
+                    }
+                ]
+            },
+            endEvent : {
+                inputType : "hand",
+                timeOffset : 2.0,
+                touches : [
+                    {
+                        inputType : "finger",
+                        phase : "moved",
+                        id : 1,
+                        x : ${X},
+                        y : ${Y},
+                        pressure : 0
+                    }
+                ]
+            }
+    }]};
+    
+    uiController.sendEventStream(JSON.stringify(eventStream), function() {});
+        uiController.uiScriptComplete();
+    })();`
+}
+
 function tapAtPoint(x, y)
 {
     return `
@@ -62,3 +107,48 @@
         uiController.uiScriptComplete();
     })();`
 }
+
+function continueTouchAndDragFromPointToPoint(startX, startY, endX, endY)
+{
+    return `
+    (function() {
+     var eventStream = {
+     events : [
+               {
+               interpolate : "linear",
+               timestep: 0.1,
+               coordinateSpace : "content",
+               startEvent : {
+                   inputType : "hand",
+                   timeOffset : 0,
+                   touches : [
+                       {
+                           inputType : "finger",
+                           phase : "moved",
+                           id : 1,
+                           x : ${startX},
+                           y : ${startY},
+                           pressure : 0
+                       }
+                   ]
+               },
+               endEvent : {
+                   inputType : "hand",
+                   timeOffset : 0.5,
+                   touches : [
+                       {
+                           inputType : "finger",
+                           phase : "moved",
+                           id : 1,
+                           x : ${endX},
+                           y : ${endY},
+                           pressure : 0
+                       }
+                   ]
+               }
+     }]};
+     
+     uiController.sendEventStream(JSON.stringify(eventStream), function() {});
+         uiController.uiScriptComplete();
+     })();`
+}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to