Title: [222337] trunk/LayoutTests
Revision
222337
Author
[email protected]
Date
2017-09-21 11:48:08 -0700 (Thu, 21 Sep 2017)

Log Message

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

Reviewed by Simon Fraser and Tim Horton.

Adding a test to test the long press and then drag functionality of selection.
Also add additional helper functions to basic gestures, and clarified the existing function
names, as to be more clear in what behavior to expect from them.

* 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:
(touchAndDragFromPointToPoint):

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (222336 => 222337)


--- trunk/LayoutTests/ChangeLog	2017-09-21 18:43:35 UTC (rev 222336)
+++ trunk/LayoutTests/ChangeLog	2017-09-21 18:48:08 UTC (rev 222337)
@@ -1,3 +1,19 @@
+2017-09-21  Megan Gardner  <[email protected]>
+
+        Add long press and drag test
+        https://bugs.webkit.org/show_bug.cgi?id=177289
+
+        Reviewed by Simon Fraser and Tim Horton.
+
+        Adding a test to test the long press and then drag functionality of selection.
+        Also add additional helper functions to basic gestures, and clarified the existing function
+        names, as to be more clear in what behavior to expect from them.
+
+        * 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:
+        (touchAndDragFromPointToPoint):
+
 2017-09-21  Ryan Haddad  <[email protected]>
 
         Rebaseline some tests for macOS.

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


--- 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-09-21 18:48:08 UTC (rev 222337)
@@ -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 => 222337)


--- 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-09-21 18:48:08 UTC (rev 222337)
@@ -0,0 +1,67 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <script src=""
+    <script>
+        if (window.testRunner) {
+            testRunner.dumpAsText();
+            testRunner.waitUntilDone();
+        }
+
+        function runTest()
+        {
+            if (!testRunner.runUIScript)
+                return;
+
+            var output = '';
+            var target = document.getElementById('target');
+
+            if (testRunner.runUIScript) {
+                testRunner.runUIScript(pressAndHoldAtPoint(147, 85), function(result) {
+                    if (document.getSelection().toString() == "elit")
+                        output += 'PASS: Correct Selection';
+                    else if(document.getSelection().toString() == "")
+                        output += 'FAIL: failed to select a word as a result of a long press';
+                    else
+                        output += 'FAIL: failed to select correct word as a result of a long press. Incorrect selection: ' + document.getSelection().toString();
+                    output += '<br>';
+                   
+                    testRunner.runUIScript(continueTouchAndDragFromPointToPoint(147,85,60,85), function(result) {
+                        if (document.getSelection().toString() == "adipiscing")
+                            output += 'PASS: Correct Selection';
+                        else if(document.getSelection().toString() == "")
+                            output += 'FAIL: failed to select a word as a result of a drag after long press';
+                        else
+                            output += 'FAIL: failed to select correct word as a result of a drag after long press. Incorrect selection: ' + document.getSelection().toString();
+                      
+                       output += '<br>';
+                       document.getElementById('target').innerHTML = output;
+                       testRunner.notifyDone();
+                   });
+               });
+            }
+        }
+
+        window.addEventListener('load', runTest, false);
+    </script>
+    <style>
+        #target {
+            height: 380px;
+            width: 200px;
+            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 labore et dolore magna aliqua.</p>
+        <p>Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
+        
+        This test requires UIScriptController to run.
+    </div>
+</body>
+</html>

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


--- trunk/LayoutTests/fast/events/touch/ios/resources/basic-gestures.js	2017-09-21 18:43:35 UTC (rev 222336)
+++ trunk/LayoutTests/fast/events/touch/ios/resources/basic-gestures.js	2017-09-21 18:48:08 UTC (rev 222337)
@@ -8,6 +8,14 @@
     })();`
 }
 
+// We should switch to this method in all tests, as it is more clear what is being done.
+// The original helper function should not be used
+function touchAndDragFromPointToPoint(startX, startY, endX, endY)
+{
+    return dragFromPointToPoint(startX, startY, endX, endY);
+}
+
+
 function dragFromPointToPoint(startX, startY, endX, endY)
 {
     return `
@@ -52,3 +60,94 @@
         uiController.uiScriptComplete();
     })();`
 }
+
+function pressAndHoldAtPoint(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 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
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to