Title: [222643] trunk/LayoutTests
Revision
222643
Author
megan_gard...@apple.com
Date
2017-09-28 19:22:22 -0700 (Thu, 28 Sep 2017)

Log Message

Clean up Long Press Selection Tests
https://bugs.webkit.org/show_bug.cgi?id=177636

Reviewed by Tim Horton.

Clean up tests to use better methods of finding selection locations so that 
tests are more robust and less likely to be affected by unrelated changes.

* fast/events/touch/ios/long-press-then-drag-down-to-change-selected-text.html:
* fast/events/touch/ios/long-press-then-drag-left-to-change-selected-text.html:
* fast/events/touch/ios/long-press-then-drag-right-to-change-selected-text.html:
* fast/events/touch/ios/long-press-then-drag-up-to-change-selected-text.html:
* fast/events/touch/ios/long-press-to-select-and-tap-to-clear-expected.txt:
* fast/events/touch/ios/long-press-to-select-and-tap-to-clear.html:
* fast/events/touch/ios/long-press-to-select-text-expected.txt:
* fast/events/touch/ios/long-press-to-select-text.html:
* fast/events/touch/ios/resources/basic-gestures.js:
(longPressAtPoint):
(tapAtPoint):
(touchAndDragFromPointToPoint):
(pressAtPoint): Deleted.
(dragFromPointToPoint): Deleted.

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (222642 => 222643)


--- trunk/LayoutTests/ChangeLog	2017-09-29 00:15:30 UTC (rev 222642)
+++ trunk/LayoutTests/ChangeLog	2017-09-29 02:22:22 UTC (rev 222643)
@@ -1,3 +1,28 @@
+2017-09-28  Megan Gardner  <megan_gard...@apple.com>
+
+        Clean up Long Press Selection Tests
+        https://bugs.webkit.org/show_bug.cgi?id=177636
+
+        Reviewed by Tim Horton.
+
+        Clean up tests to use better methods of finding selection locations so that 
+        tests are more robust and less likely to be affected by unrelated changes.
+
+        * fast/events/touch/ios/long-press-then-drag-down-to-change-selected-text.html:
+        * fast/events/touch/ios/long-press-then-drag-left-to-change-selected-text.html:
+        * fast/events/touch/ios/long-press-then-drag-right-to-change-selected-text.html:
+        * fast/events/touch/ios/long-press-then-drag-up-to-change-selected-text.html:
+        * fast/events/touch/ios/long-press-to-select-and-tap-to-clear-expected.txt:
+        * fast/events/touch/ios/long-press-to-select-and-tap-to-clear.html:
+        * fast/events/touch/ios/long-press-to-select-text-expected.txt:
+        * fast/events/touch/ios/long-press-to-select-text.html:
+        * fast/events/touch/ios/resources/basic-gestures.js:
+        (longPressAtPoint):
+        (tapAtPoint):
+        (touchAndDragFromPointToPoint):
+        (pressAtPoint): Deleted.
+        (dragFromPointToPoint): Deleted.
+
 2017-09-28  Joanmarie Diggs  <jdi...@igalia.com>
 
         AX: [ATK] object:state-changed notifications missing for multiple ARIA attributes

Modified: trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-down-to-change-selected-text.html (222642 => 222643)


--- trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-down-to-change-selected-text.html	2017-09-29 00:15:30 UTC (rev 222642)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-down-to-change-selected-text.html	2017-09-29 02:22:22 UTC (rev 222643)
@@ -2,116 +2,72 @@
 
 <html>
 <head>
+    <script src=""
     <script>
         if (window.testRunner) {
             testRunner.dumpAsText();
             testRunner.waitUntilDone();
         }
-
-        function getInitalPressScript()
-        {
-            return `
-            (function() {
-                uiController.longPressAtPoint(65, 100, function() {
-                        uiController.uiScriptComplete();
-                });
-            })();`
-        }
-
-        function getDragScript(startX, startY, endX, endY)
-        {
-            return `
-            (function() {
-            var eventStream = {
-            events : [
-                {
-                interpolate : "linear",
-                timestep: 0.1,
-                coordinateSpace : "global",
-                startEvent : {
-                    inputType : "hand",
-                    timeOffset : 0,
-                    touches : [
-                        {
-                        inputType : "finger",
-                        phase : "began",
-                        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();
-            })();`
-        }
-
+    
         function runTest()
         {
             if (!testRunner.runUIScript)
                 return;
-
+        
             var output = '';
-            var target = document.getElementById('target');
-            
+            var firstTargetRect = document.getElementById('firstSelection').getBoundingClientRect();
+            var secondTargetRect = document.getElementById('secondSelection').getBoundingClientRect();
+            var thirdTargetRect = document.getElementById('thirdSelection').getBoundingClientRect();
+        
+            var pressPointX = firstTargetRect.x + firstTargetRect.width / 2;
+            var pressPointY = firstTargetRect.y + firstTargetRect.height / 2;
+            var dragY = firstTargetRect.y + firstTargetRect.height;
+            var dragX = firstTargetRect.x + firstTargetRect.width;
+            var dragY2 = secondTargetRect.y + secondTargetRect.height;
+            var dragY3 = thirdTargetRect.y + thirdTargetRect.height;
+            var dragY4 = firstTargetRect.y - firstTargetRect.height;
+        
             if (testRunner.runUIScript) {
-                testRunner.runUIScript(getInitalPressScript(), function(result) {
-                    if (document.getSelection().toString() == "Ut")
+                testRunner.runUIScript(longPressAtPoint(pressPointX,pressPointY), function(result) {
+                    if (document.getSelection().toString() == "sed")
                         output += 'PASS: Correct Selection';
                     else
-                        output += 'FAIL: failed to select a word as a result of a long press';
+                        output += 'FAIL: failed to select a word as a result of a long press. Incorrect Selection: ' + document.getSelection().toString();
                     output += '<br>';
-
-                    testRunner.runUIScript(getDragScript(72, 120, 72, 140), function(result) {
-                        if (document.getSelection().toString() == "Ut enim ad minim veniam, q")
+                                   
+                    testRunner.runUIScript(touchAndDragFromPointToPoint(dragX, dragY, dragX, dragY2), function(result) {
+                        if (document.getSelection().toString() == "sed do eiusmod tempor incididun")
                             output += 'PASS: Correct Selection';
                         else
-                            output += 'FAIL: failed to select additional line after a drag.'
+                            output += 'FAIL: failed to select additional line after a drag. Incorrect Selection: ' + document.getSelection().toString();
                         output += '<br>';
-                                          
-                        testRunner.runUIScript(getDragScript(72, 140, 72, 160), function(result) {
-                            if (document.getSelection().toString() == "Ut enim ad minim veniam, quis nostrud exercitati")
+                                                          
+                        testRunner.runUIScript(touchAndDragFromPointToPoint(dragX, dragY2, dragX, dragY3), function(result) {
+                            if (document.getSelection().toString() == "sed do eiusmod tempor incididunt ut labore et dolore ma")
                                 output += 'PASS: Correct Selection';
                             else
-                                output += 'FAIL: failed to select additional line after a drag.'
+                                output += 'FAIL: failed to select additional line after a drag. Incorrect Selection: ' + document.getSelection().toString();
                             output += '<br>';
-
-                            testRunner.runUIScript(getDragScript(72, 160, 72, 140), function(result) {
-                                if (document.getSelection().toString() == "Ut enim ad minim veniam, q")
+                       
+                            testRunner.runUIScript(touchAndDragFromPointToPoint(dragX, dragY3, dragX, dragY2), function(result) {
+                                if (document.getSelection().toString() == "sed do eiusmod tempor incididun")
                                     output += 'PASS: Correct Selection';
                                 else
-                                    output += 'FAIL: failed to deselect line after a drag.'
+                                    output += 'FAIL: failed to deselect line after a drag. Incorrect Selection: ' + document.getSelection().toString();
                                 output += '<br>';
-
-                                testRunner.runUIScript(getDragScript(72, 140, 72, 115), function(result) {
-                                    if (document.getSelection().toString() == "Ut")
+                                                                                                        
+                                testRunner.runUIScript(touchAndDragFromPointToPoint(dragX, dragY2, dragX, dragY), function(result) {
+                                    if (document.getSelection().toString() == "sed")
                                         output += 'PASS: Correct Selection';
                                     else
-                                        output += 'FAIL: failed to deselect line after a drag.'
+                                        output += 'FAIL: failed to deselect line after a drag. Incorrect Selection: ' + document.getSelection().toString();
                                     output += '<br>';
-                            
-                                    testRunner.runUIScript(getDragScript(72, 115, 72, 80), function(result) {
-                                        if (document.getSelection().toString() == "U")
+                                                                                                                               
+                                    testRunner.runUIScript(touchAndDragFromPointToPoint(dragX, dragY, dragX, dragY4), function(result) {
+                                        if (document.getSelection().toString() == "s")
                                             output += 'PASS: Correct Selection';
                                         else
-                                            output += 'FAIL: failed to reduce selection to a single character by dragging up.'
+                                            output += 'FAIL: failed to reduce selection to a single character by dragging up. Incorrect Selection: ' + document.getSelection().toString();
                                         output += '<br>';
                                         output += result;
                                         document.getElementById('target').innerHTML = output;
@@ -124,23 +80,25 @@
                 });
             }
         }
-
+    
         window.addEventListener('load', runTest, false);
     </script>
     <style>
         #target {
             height: 400px;
-            width: 200px;
+            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 labore et dolore magna 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. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
-
-    This test requires UIScriptController to run.
-</div>
+    <div id="target">
+        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, <span id="firstSelection">sed</span> do eiusmod tempor incididun<span id="secondSelection"></span>t ut labore et dolore mag<span id="thirdSelection"></span>na aliqua. 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/long-press-then-drag-left-to-change-selected-text.html (222642 => 222643)


--- trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-left-to-change-selected-text.html	2017-09-29 00:15:30 UTC (rev 222642)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-left-to-change-selected-text.html	2017-09-29 02:22:22 UTC (rev 222643)
@@ -13,51 +13,61 @@
         {
             if (!testRunner.runUIScript)
                 return;
-
+        
             var output = '';
-            var target = document.getElementById('target');
-            
+            var firstTargetRect = document.getElementById('firstSelection').getBoundingClientRect();
+            var secondTargetRect = document.getElementById('secondSelection').getBoundingClientRect();
+            var thirdTargetRect = document.getElementById('thirdSelection').getBoundingClientRect();
+        
+            var pressPointX = firstTargetRect.x+firstTargetRect.width / 2;
+            var pressPointY = firstTargetRect.y+firstTargetRect.height / 2;
+            var dragY = firstTargetRect.y;
+            var dragX = firstTargetRect.x;
+            var dragX2 = secondTargetRect.x;
+            var dragX3 = thirdTargetRect.x;
+            var dragX4 = firstTargetRect.x + firstTargetRect.width;
+        
             if (testRunner.runUIScript) {
-                testRunner.runUIScript(pressAtPoint(181, 104), function(result) {
+                testRunner.runUIScript(longPressAtPoint(pressPointX, pressPointY), function(result) {
                     if (document.getSelection().toString() == "aliqua")
                         output += 'PASS: Correct Selection';
                     else
-                        output += 'FAIL: failed to select a word as a result of a long press';
+                        output += 'FAIL: failed to select a word as a result of a long press. Incorrect Selection: ' + document.getSelection().toString();
                     output += '<br>';
-
-                    testRunner.runUIScript(dragFromPointToPoint(149,90,84,90), function(result) {
+            
+                    testRunner.runUIScript(touchAndDragFromPointToPoint(dragX, dragY, dragX2, dragY), function(result) {
                         if (document.getSelection().toString() == "magna aliqua")
                             output += 'PASS: Correct Selection';
                         else
-                            output += 'FAIL: failed to select additional line after a drag.' + document.getSelection().toString()
+                            output += 'FAIL: failed to select additional word after a drag. Incorrect Selection: ' + document.getSelection().toString();
                         output += '<br>';
-                                          
-                        testRunner.runUIScript(dragFromPointToPoint(84,90,8,90), function(result) {
+                                       
+                        testRunner.runUIScript(touchAndDragFromPointToPoint(dragX2, dragY, dragX3, dragY), function(result) {
                             if (document.getSelection().toString() == "dolore magna aliqua")
                                 output += 'PASS: Correct Selection';
                             else
-                                output += 'FAIL: failed to select additional line after a drag.' + document.getSelection().toString()
+                                output += 'FAIL: failed to select additional word after a drag. Incorrect Selection: ' + document.getSelection().toString();
                             output += '<br>';
-
-                            testRunner.runUIScript(dragFromPointToPoint(8,90,84,90), function(result) {
+                                           
+                            testRunner.runUIScript(touchAndDragFromPointToPoint(dragX3, dragY, dragX2, dragY), function(result) {
                                 if (document.getSelection().toString() == "magna aliqua")
                                     output += 'PASS: Correct Selection';
                                 else
-                                    output += 'FAIL: failed to deselect line after a drag.' + document.getSelection().toString()
+                                    output += 'FAIL: failed to deselect word after a drag. Incorrect Selection: ' + document.getSelection().toString();
                                 output += '<br>';
-
-                                testRunner.runUIScript(dragFromPointToPoint(84,90,149,90), function(result) {
+                        
+                                testRunner.runUIScript(touchAndDragFromPointToPoint(dragX2, dragY, dragX, dragY), function(result) {
                                     if (document.getSelection().toString() == "aliqua")
                                         output += 'PASS: Correct Selection';
                                     else
-                                        output += 'FAIL: failed to deselect line after a drag.' + document.getSelection().toString()
+                                        output += 'FAIL: failed to deselect word after a drag. Incorrect Selection: ' + document.getSelection().toString();
                                     output += '<br>';
                             
-                                    testRunner.runUIScript(dragFromPointToPoint(149,90,250,90), function(result) {
+                                    testRunner.runUIScript(touchAndDragFromPointToPoint(dragX, dragY, dragX4, dragY), function(result) {
                                         if (document.getSelection().toString() == "a")
                                             output += 'PASS: Correct Selection';
                                         else
-                                            output += 'FAIL: failed to reduce selection to a single character by dragging up.'
+                                            output += 'FAIL: failed to reduce selection to a single character by dragging right. Incorrect Selection: ' +     document.getSelection().toString();
                                         output += '<br>';
                                         output += result;
                                         document.getElementById('target').innerHTML = output;
@@ -70,7 +80,7 @@
                 });
             }
         }
-
+    
         window.addEventListener('load', runTest, false);
     </script>
     <style>
@@ -82,12 +92,13 @@
             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. 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. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
-
-    This test requires UIScriptController to run.
-</div>
+    <div id="target">
+        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et <span id="thirdSelection"></span>dolore <span id="secondSelection"></span>magna <span id="firstSelection">aliqua</span>. 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/long-press-then-drag-right-to-change-selected-text.html (222642 => 222643)


--- trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-right-to-change-selected-text.html	2017-09-29 00:15:30 UTC (rev 222642)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-right-to-change-selected-text.html	2017-09-29 02:22:22 UTC (rev 222643)
@@ -15,49 +15,59 @@
                 return;
 
             var output = '';
-            var target = document.getElementById('target');
-            
+            var firstTargetRect = document.getElementById('firstSelection').getBoundingClientRect();
+            var secondTargetRect = document.getElementById('secondSelection').getBoundingClientRect();
+            var thirdTargetRect = document.getElementById('thirdSelection').getBoundingClientRect();
+
+            var pressPointX = firstTargetRect.x + firstTargetRect.width / 2;
+            var pressPointY = firstTargetRect.y + firstTargetRect.height / 2;
+            var dragY = firstTargetRect.y + firstTargetRect.height;
+            var dragX = firstTargetRect.x + firstTargetRect.width;
+            var dragX2 = secondTargetRect.x;
+            var dragX3 = thirdTargetRect.x;
+            var dragX4 = firstTargetRect.x - firstTargetRect.width;
+        
             if (testRunner.runUIScript) {
-                testRunner.runUIScript(pressAtPoint(110, 104), function(result) {
+                testRunner.runUIScript(longPressAtPoint(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';
+                        output += 'FAIL: failed to select a word as a result of a long press. Incorrect Selection: ' + document.getSelection().toString();
                     output += '<br>';
 
-                    testRunner.runUIScript(dragFromPointToPoint(139,120,224,120), function(result) {
+                    testRunner.runUIScript(touchAndDragFromPointToPoint(dragX, dragY, dragX2, dragY), function(result) {
                         if (document.getSelection().toString() == "magna aliqua.")
                             output += 'PASS: Correct Selection';
                         else
-                            output += 'FAIL: failed to select additional line after a drag.' + document.getSelection().toString()
+                            output += 'FAIL: failed to select additional word after a drag. Incorrect Selection: ' + document.getSelection().toString();
                         output += '<br>';
-                                          
-                        testRunner.runUIScript(dragFromPointToPoint(224,120,255,120), function(result) {
-                            if (document.getSelection().toString() == "magna aliqua. Ut ")
+                                      
+                        testRunner.runUIScript(touchAndDragFromPointToPoint(dragX2, dragY, dragX3, dragY), function(result) {
+                            if (document.getSelection().toString() == "magna aliqua. Ut")
                                 output += 'PASS: Correct Selection';
                             else
-                                output += 'FAIL: failed to select additional line after a drag.' + document.getSelection().toString()+'/end'
+                                output += 'FAIL: failed to select additional word after a drag. Incorrect Selection: ' + document.getSelection().toString();
                             output += '<br>';
 
-                            testRunner.runUIScript(dragFromPointToPoint(255,120,224,120), function(result) {
+                            testRunner.runUIScript(touchAndDragFromPointToPoint(dragX3, dragY, dragX2, dragY), function(result) {
                                 if (document.getSelection().toString() == "magna aliqua.")
                                     output += 'PASS: Correct Selection';
                                 else
-                                    output += 'FAIL: failed to deselect line after a drag.' + document.getSelection().toString()
+                                    output += 'FAIL: failed to deselect word after a drag. Incorrect Selection: ' + document.getSelection().toString();
                                 output += '<br>';
 
-                                testRunner.runUIScript(dragFromPointToPoint(224,120,139,120), function(result) {
+                                testRunner.runUIScript(touchAndDragFromPointToPoint(dragX2, dragY, dragX, dragY), function(result) {
                                     if (document.getSelection().toString() == "magna")
                                         output += 'PASS: Correct Selection';
                                     else
-                                        output += 'FAIL: failed to deselect line after a drag.' + document.getSelection().toString()
+                                        output += 'FAIL: failed to deselect word after a drag. Incorrect Selection: ' + document.getSelection().toString();
                                     output += '<br>';
-                            
-                                    testRunner.runUIScript(dragFromPointToPoint(139,120,40,120), function(result) {
+                        
+                                    testRunner.runUIScript(touchAndDragFromPointToPoint(dragX, dragY, dragX4, dragY), function(result) {
                                         if (document.getSelection().toString() == "m")
                                             output += 'PASS: Correct Selection';
                                         else
-                                            output += 'FAIL: failed to reduce selection to a single character by dragging up.'
+                                            output += 'FAIL: failed to reduce selection to a single character by dragging left. Incorrect Selection: ' + document.getSelection().toString();
                                         output += '<br>';
                                         output += result;
                                         document.getElementById('target').innerHTML = output;
@@ -82,12 +92,13 @@
             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. 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>
+    <div id="target">
+        <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore <span id="firstSelection">magna</span> aliqua.<span id="secondSelection"></span> Ut<span id="thirdSelection"></span> 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>
+        This test requires UIScriptController to run.
+    </div>
 </body>
 </html>

Modified: trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-up-to-change-selected-text.html (222642 => 222643)


--- trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-up-to-change-selected-text.html	2017-09-29 00:15:30 UTC (rev 222642)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-then-drag-up-to-change-selected-text.html	2017-09-29 02:22:22 UTC (rev 222643)
@@ -2,67 +2,13 @@
 
 <html>
 <head>
+    <script src=""
     <script>
         if (window.testRunner) {
             testRunner.dumpAsText();
             testRunner.waitUntilDone();
         }
-
-        function getInitalPressScript()
-        {
-            return `
-            (function() {
-                uiController.longPressAtPoint(65, 100, function() {
-                        uiController.uiScriptComplete();
-                });
-            })();`
-        }
     
-        function getDragScript(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 : "began",
-                        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();
-            })();`
-        }
-    
         function runTest()
         {
             if (!testRunner.runUIScript)
@@ -69,49 +15,59 @@
                 return;
 
             var output = '';
-            var target = document.getElementById('target');
-            
+            var firstTargetRect = document.getElementById('firstSelection').getBoundingClientRect();
+            var secondTargetRect = document.getElementById('secondSelection').getBoundingClientRect();
+            var thirdTargetRect = document.getElementById('thirdSelection').getBoundingClientRect();
+        
+            var pressPointX = firstTargetRect.x+firstTargetRect.width / 2;
+            var pressPointY = firstTargetRect.y+firstTargetRect.height / 2;
+            var dragY = firstTargetRect.y;
+            var dragX = firstTargetRect.x;
+            var dragY2 = secondTargetRect.y;
+            var dragY3 = thirdTargetRect.y;
+            var dragY4 = firstTargetRect.y + firstTargetRect.height;
+        
             if (testRunner.runUIScript) {
-                testRunner.runUIScript(getInitalPressScript(), function(result) {
+                testRunner.runUIScript(longPressAtPoint(pressPointX, pressPointY), function(result) {
                     if (document.getSelection().toString() == "Ut")
                         output += 'PASS: Correct Selection';
                     else
-                        output += 'FAIL: failed to select a word as a result of a long press';
+                        output += 'FAIL: failed to select a word as a result of a long press. Incorrect Selection: ' + document.getSelection().toString();
                     output += '<br>';
 
-                    testRunner.runUIScript(getDragScript(56, 89, 56, 74), function(result) {
+                    testRunner.runUIScript(touchAndDragFromPointToPoint(dragX, dragY, dragX, dragY2), function(result) {
                         if (document.getSelection().toString() == "e et dolore magna aliqua. Ut")
                             output += 'PASS: Correct Selection';
                         else
-                            output += 'FAIL: failed to select additional line after a drag.' + document.getSelection().toString()
+                            output += 'FAIL: failed to select additional line after a drag. Incorrect Selection: ' + document.getSelection().toString();
                         output += '<br>';
-                                          
-                        testRunner.runUIScript(getDragScript(56, 74, 56, 55), function(result) {
+                                      
+                        testRunner.runUIScript(touchAndDragFromPointToPoint(dragX, dragY2, dragX, dragY3), function(result) {
                             if (document.getSelection().toString() == "mod tempor incididunt ut labore et dolore magna aliqua. Ut")
                                 output += 'PASS: Correct Selection';
                             else
-                                output += 'FAIL: failed to select additional line after a drag.' + document.getSelection().toString()
+                                output += 'FAIL: failed to select additional line after a drag. Incorrect Selection: ' + document.getSelection().toString();
                             output += '<br>';
 
-                            testRunner.runUIScript(getDragScript(56, 55, 56, 74), function(result) {
+                            testRunner.runUIScript(touchAndDragFromPointToPoint(dragX, dragY3, dragX, dragY2), function(result) {
                                 if (document.getSelection().toString() == "e et dolore magna aliqua. Ut")
                                     output += 'PASS: Correct Selection';
                                 else
-                                    output += 'FAIL: failed to deselect line after a drag.' + document.getSelection().toString()
+                                    output += 'FAIL: failed to deselect line after a drag. Incorrect Selection: ' + document.getSelection().toString();
                                 output += '<br>';
 
-                                testRunner.runUIScript(getDragScript(56, 74, 56, 92), function(result) {
+                                testRunner.runUIScript(touchAndDragFromPointToPoint(dragX, dragY2, dragX, dragY), function(result) {
                                     if (document.getSelection().toString() == "Ut")
                                         output += 'PASS: Correct Selection';
                                     else
-                                        output += 'FAIL: failed to deselect line after a drag.' + document.getSelection().toString()
+                                        output += 'FAIL: failed to deselect line after a drag. Incorrect Selection: ' + document.getSelection().toString();
                                     output += '<br>';
-                            
-                                    testRunner.runUIScript(getDragScript(56, 92, 56, 120), function(result) {
+                        
+                                    testRunner.runUIScript(touchAndDragFromPointToPoint(dragX, dragY, dragX, dragY4), function(result) {
                                         if (document.getSelection().toString() == "t")
                                             output += 'PASS: Correct Selection';
                                         else
-                                            output += 'FAIL: failed to reduce selection to a single character by dragging up.'
+                                            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;
@@ -130,17 +86,19 @@
     <style>
         #target {
             height: 400px;
-            width: 200px;
+            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 labore et dolore magna 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. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
-
-    This test requires UIScriptController to run.
-</div>
+    <div id="target">
+        <p>Lorem ipsum dolor sit amet, consectetur<span id="thirdSelection"></span> adipiscing elit, sed d<span id="secondSelection"></span>o eiusmod tempor incididunt <span id="firstSelection">ut</span> labore et dolore magna 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/long-press-to-select-and-tap-to-clear-expected.txt (222642 => 222643)


--- trunk/LayoutTests/fast/events/touch/ios/long-press-to-select-and-tap-to-clear-expected.txt	2017-09-29 00:15:30 UTC (rev 222642)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-to-select-and-tap-to-clear-expected.txt	2017-09-29 02:22:22 UTC (rev 222643)
@@ -1,3 +1,3 @@
-PASS: Selected: PressMe
+PASS: Correct Selection
 PASS: Cleared selection
 

Modified: trunk/LayoutTests/fast/events/touch/ios/long-press-to-select-and-tap-to-clear.html (222642 => 222643)


--- trunk/LayoutTests/fast/events/touch/ios/long-press-to-select-and-tap-to-clear.html	2017-09-29 00:15:30 UTC (rev 222642)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-to-select-and-tap-to-clear.html	2017-09-29 02:22:22 UTC (rev 222643)
@@ -2,32 +2,13 @@
 
 <html>
 <head>
+    <script src=""
     <script>
         if (window.testRunner) {
             testRunner.dumpAsText();
             testRunner.waitUntilDone();
         }
-
-        function getPressScript()
-        {
-            return `
-            (function() {
-                uiController.longPressAtPoint(30, 20, function() {
-                    uiController.uiScriptComplete();
-                });
-            })();`
-        }
     
-        function getTapScript()
-        {
-            return `
-            (function() {
-             uiController.singleTapAtPoint(30, 20, function() {
-                 uiController.uiScriptComplete();
-                });
-             })();`
-        }
-    
         function runTest()
         {
             if (!testRunner.runUIScript)
@@ -34,24 +15,26 @@
                 return;
 
             var output = '';
-            var target = document.getElementById('target');
+            var targetRect = document.getElementById('selection').getBoundingClientRect();
+            
+            var pressPointX = targetRect.x + targetRect.width / 2;
+            var pressPointY = targetRect.y + targetRect.height / 2;
+            
             if (testRunner.runUIScript) {
-                testRunner.runUIScript(getPressScript(), function(result) {
-                    var selectionText = document.getSelection().toString();
-                    if (selectionText == "PressMe")
-                        output += 'PASS: Selected: ' + selectionText;
+                testRunner.runUIScript(longPressAtPoint(pressPointX, pressPointY), function(result) {
+                    if (document.getSelection().toString() == "PressMe")
+                        output += 'PASS: Correct Selection';
                     else
-                        output += 'FAIL: failed to select a word as a result of a long press';
+                        output += 'FAIL: failed to select a word as a result of a long press. Incorrect Selection: ' + document.getSelection().toString();
                     output += '<br>';
-                    testRunner.runUIScript(getTapScript(), function(result) {
-                      var secondSelectionText = document.getSelection().toString();
-                      if (secondSelectionText == "")
+                    testRunner.runUIScript(tapAtPoint(100, 100), function(result) {
+                        if (document.getSelection().toString() == "")
                             output += 'PASS: Cleared selection';
-                      else
-                            output += 'FAIL: failed to clear selection after tap.'
-                      output += '<br>';
-                      document.getElementById('target').innerHTML = output;
-                      testRunner.notifyDone();
+                        else
+                            output += 'FAIL: failed to clear selection after tap.' + document.getSelection().toString();
+                        output += '<br>';
+                        document.getElementById('target').innerHTML = output;
+                        testRunner.notifyDone();
                     });
                 });
             }
@@ -70,7 +53,7 @@
 </head>
 <body>
 <div id="target">
-	<p>PressMe</p>
+	<p><span id="selection">PressMe</span></p>
     This test requires UIScriptController to run.
 </div>
 </body>

Modified: trunk/LayoutTests/fast/events/touch/ios/long-press-to-select-text-expected.txt (222642 => 222643)


--- trunk/LayoutTests/fast/events/touch/ios/long-press-to-select-text-expected.txt	2017-09-29 00:15:30 UTC (rev 222642)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-to-select-text-expected.txt	2017-09-29 02:22:22 UTC (rev 222643)
@@ -1,2 +1,2 @@
-PASS: successfully selected the word PressMe
-Done
+PASS: Correct Selection
+

Modified: trunk/LayoutTests/fast/events/touch/ios/long-press-to-select-text.html (222642 => 222643)


--- trunk/LayoutTests/fast/events/touch/ios/long-press-to-select-text.html	2017-09-29 00:15:30 UTC (rev 222642)
+++ trunk/LayoutTests/fast/events/touch/ios/long-press-to-select-text.html	2017-09-29 02:22:22 UTC (rev 222643)
@@ -2,6 +2,7 @@
 
 <html>
 <head>
+    <script src=""
     <script>
         if (window.testRunner) {
             testRunner.dumpAsText();
@@ -8,16 +9,6 @@
             testRunner.waitUntilDone();
         }
 
-        function getUIScript()
-        {
-            return `
-            (function() {
-                uiController.longPressAtPoint(30, 20, function() {
-                    uiController.uiScriptComplete("Done");
-                });
-            })();`
-        }
-
         function runTest()
         {
             if (!testRunner.runUIScript)
@@ -24,15 +15,15 @@
                 return;
 
             var output = '';
-            var target = document.getElementById('target');
-            target.addEventListener('touchend', function(event) {
-                output += 'PASS: successfully selected the word ';
-            });
-            if (testRunner.runUIScript) {
-                testRunner.runUIScript(getUIScript(), function(result) {
-                    var selectionText = document.getSelection().toString();
-                    if (selectionText !== "")
-                        output += selectionText;
+            var targetRect = document.getElementById('selection').getBoundingClientRect();
+            
+            var pressPointX = targetRect.x + targetRect.width / 2;
+            var pressPointY = targetRect.y + targetRect.height / 2;
+            
+            if (testRunner.runUIScript) {                
+                testRunner.runUIScript(longPressAtPoint(pressPointX, pressPointY), function(result) {
+                    if (document.getSelection().toString() == "PressMe")
+                        output += 'PASS: Correct Selection';
                     else
                         output += 'FAIL: failed to select a word as a result of a long press';
                     output += '<br>';
@@ -56,7 +47,7 @@
 </head>
 <body>
 <div id="target">
-	<p>PressMe</p>
+	<p><span id="selection">PressMe</span></p>
     This test requires UIScriptController to run.
 </div>
 </body>

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


--- trunk/LayoutTests/fast/events/touch/ios/resources/basic-gestures.js	2017-09-29 00:15:30 UTC (rev 222642)
+++ trunk/LayoutTests/fast/events/touch/ios/resources/basic-gestures.js	2017-09-29 02:22:22 UTC (rev 222643)
@@ -1,4 +1,4 @@
-function pressAtPoint(x, y)
+function longPressAtPoint(x, y)
 {
     return `
     (function() {
@@ -8,10 +8,20 @@
     })();`
 }
 
-function dragFromPointToPoint(startX, startY, endX, endY)
+function tapAtPoint(x, y)
 {
     return `
     (function() {
+        uiController.singleTapAtPoint(${x}, ${y}, function() {
+            uiController.uiScriptComplete();
+        });
+    })();`
+}
+
+function touchAndDragFromPointToPoint(startX, startY, endX, endY)
+{
+    return `
+    (function() {
     var eventStream = {
     events : [
         {
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to