Additional selection tests and interpolation fix
authormegan_gardner@apple.com <megan_gardner@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jan 2017 23:30:33 +0000 (23:30 +0000)
committermegan_gardner@apple.com <megan_gardner@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Jan 2017 23:30:33 +0000 (23:30 +0000)
https://bugs.webkit.org/show_bug.cgi?id=167171

Reviewed by Simon Fraser.

Tools:

We weren't adding the final event when interpolating event streams.

* WebKitTestRunner/ios/HIDEventGenerator.mm:
(-[HIDEventGenerator interpolatedEvents:]):

LayoutTests:

Selections tests for dragging left and right.
Factored out common functions used across tests.

* fast/events/touch/ios/long-press-then-drag-left-to-change-selected-text-expected.txt: Added.
* fast/events/touch/ios/long-press-then-drag-left-to-change-selected-text.html: Added.
* fast/events/touch/ios/long-press-then-drag-right-to-change-selected-text-expected.txt: Added.
* fast/events/touch/ios/long-press-then-drag-right-to-change-selected-text.html: Added.
* fast/events/touch/ios/resources: Added.
* fast/events/touch/ios/resources/basic-gestures.js: Added.
(pressAtPoint):
(dragFromPointToPoint):

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

LayoutTests/ChangeLog
LayoutTests/fast/events/touch/ios/long-press-then-drag-left-to-change-selected-text-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/long-press-then-drag-left-to-change-selected-text.html [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/long-press-then-drag-right-to-change-selected-text-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/long-press-then-drag-right-to-change-selected-text.html [new file with mode: 0644]
LayoutTests/fast/events/touch/ios/resources/basic-gestures.js [new file with mode: 0644]
Tools/ChangeLog
Tools/WebKitTestRunner/ios/HIDEventGenerator.mm

index de1db01..420c6a4 100644 (file)
@@ -1,3 +1,22 @@
+2017-01-19  Megan Gardner  <megan_gardner@apple.com>
+
+        Additional selection tests and interpolation fix
+        https://bugs.webkit.org/show_bug.cgi?id=167171
+
+        Reviewed by Simon Fraser.
+
+        Selections tests for dragging left and right.
+        Factored out common functions used across tests.
+
+        * fast/events/touch/ios/long-press-then-drag-left-to-change-selected-text-expected.txt: Added.
+        * fast/events/touch/ios/long-press-then-drag-left-to-change-selected-text.html: Added.
+        * fast/events/touch/ios/long-press-then-drag-right-to-change-selected-text-expected.txt: Added.
+        * fast/events/touch/ios/long-press-then-drag-right-to-change-selected-text.html: Added.
+        * fast/events/touch/ios/resources: Added.
+        * fast/events/touch/ios/resources/basic-gestures.js: Added.
+        (pressAtPoint):
+        (dragFromPointToPoint):
+
 2017-01-19  Chris Dumez  <cdumez@apple.com>
 
         Make sure HTML validation bubble gets dismissed when its associated element's frame gets detached
diff --git a/LayoutTests/fast/events/touch/ios/long-press-then-drag-left-to-change-selected-text-expected.txt b/LayoutTests/fast/events/touch/ios/long-press-then-drag-left-to-change-selected-text-expected.txt
new file mode 100644 (file)
index 0000000..de51aa3
--- /dev/null
@@ -0,0 +1,7 @@
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+
diff --git a/LayoutTests/fast/events/touch/ios/long-press-then-drag-left-to-change-selected-text.html b/LayoutTests/fast/events/touch/ios/long-press-then-drag-left-to-change-selected-text.html
new file mode 100644 (file)
index 0000000..502bbf1
--- /dev/null
@@ -0,0 +1,93 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <script src="resources/basic-gestures.js"></script>
+    <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(pressAtPoint(181, 104), 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 += '<br>';
+
+                    testRunner.runUIScript(dragFromPointToPoint(149,90,84,90), 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 += '<br>';
+                                          
+                        testRunner.runUIScript(dragFromPointToPoint(84,90,8,90), 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 += '<br>';
+
+                            testRunner.runUIScript(dragFromPointToPoint(8,90,84,90), 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 += '<br>';
+
+                                testRunner.runUIScript(dragFromPointToPoint(84,90,149,90), 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 += '<br>';
+                            
+                                    testRunner.runUIScript(dragFromPointToPoint(149,90,250,90), 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 += '<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>
+</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>
+</body>
+</html>
diff --git a/LayoutTests/fast/events/touch/ios/long-press-then-drag-right-to-change-selected-text-expected.txt b/LayoutTests/fast/events/touch/ios/long-press-then-drag-right-to-change-selected-text-expected.txt
new file mode 100644 (file)
index 0000000..de51aa3
--- /dev/null
@@ -0,0 +1,7 @@
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+PASS: Correct Selection
+
diff --git a/LayoutTests/fast/events/touch/ios/long-press-then-drag-right-to-change-selected-text.html b/LayoutTests/fast/events/touch/ios/long-press-then-drag-right-to-change-selected-text.html
new file mode 100644 (file)
index 0000000..cf05fb8
--- /dev/null
@@ -0,0 +1,93 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+    <script src="resources/basic-gestures.js"></script>
+    <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(pressAtPoint(110, 104), 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 += '<br>';
+
+                    testRunner.runUIScript(dragFromPointToPoint(139,120,224,120), 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 += '<br>';
+                                          
+                        testRunner.runUIScript(dragFromPointToPoint(224,120,255,120), 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 += '<br>';
+
+                            testRunner.runUIScript(dragFromPointToPoint(255,120,224,120), 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 += '<br>';
+
+                                testRunner.runUIScript(dragFromPointToPoint(224,120,139,120), 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 += '<br>';
+                            
+                                    testRunner.runUIScript(dragFromPointToPoint(139,120,40,120), 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 += '<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>
+</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>
+
+    This test requires UIScriptController to run.
+</div>
+</body>
+</html>
diff --git a/LayoutTests/fast/events/touch/ios/resources/basic-gestures.js b/LayoutTests/fast/events/touch/ios/resources/basic-gestures.js
new file mode 100644 (file)
index 0000000..c29cbd5
--- /dev/null
@@ -0,0 +1,54 @@
+function pressAtPoint(x, y)
+{
+    return `
+    (function() {
+        uiController.longPressAtPoint(${x}, ${y}, function() {
+            uiController.uiScriptComplete();
+        });
+    })();`
+}
+
+function dragFromPointToPoint(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();
+    })();`
+}
index bf0304e..c93baab 100644 (file)
@@ -1,3 +1,15 @@
+2017-01-19  Megan Gardner  <megan_gardner@apple.com>
+
+        Additional selection tests and interpolation fix
+        https://bugs.webkit.org/show_bug.cgi?id=167171
+
+        Reviewed by Simon Fraser.
+
+        We weren't adding the final event when interpolating event streams.
+
+        * WebKitTestRunner/ios/HIDEventGenerator.mm:
+        (-[HIDEventGenerator interpolatedEvents:]):
+
 2017-01-19  Myles C. Maxfield  <mmaxfield@apple.com>
 
         [Cocoa] Variation fonts are erroneously disabled on iOS
index 73006ac..1de729c 100644 (file)
@@ -1031,6 +1031,8 @@ static inline uint32_t hidUsageCodeForCharacter(NSString *key)
         [newEvent release];
         time += timeStep;
     }
+    
+    [interpolatedEvents addObject:endEvent];
 
     return interpolatedEvents;
 }