[iOS] uiController.keyDown() does not translate Control modified key
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Jan 2019 22:35:10 +0000 (22:35 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 25 Jan 2019 22:35:10 +0000 (22:35 +0000)
commite8c5791b4b5c6fcf69098e92b4b4597b1022513f
tree1d937808784342c77a1eb7f9b882e8842448e9ca
parentd9336d62a4d80beb35aecbbd28a5495221d070d3
[iOS] uiController.keyDown() does not translate Control modified key
https://bugs.webkit.org/show_bug.cgi?id=192898

Reviewed by Wenson Hsieh.

Tools:

Implement uiController.keyDown() in terms of HIDEventGenerator so that UIKit performs
key translation, as applicable. Among other cases, key translation occurs when performing
a Control key modified key sequence. Writing uiController.keyDown() in terms of HIDEventGenerator
also makes the behavior of uiController.keyDown() more closely match the behavior of a
human pressing down and releasing key(s) using a hardware keyboard.

* WebKitTestRunner/ios/HIDEventGenerator.h:
* WebKitTestRunner/ios/HIDEventGenerator.mm:
(-[HIDEventGenerator sendMarkerHIDEventWithCompletionBlock:]): Renamed; formerly named _sendMarkerHIDEventWithCompletionBlock.

(-[HIDEventGenerator touchDown:touchCount:completionBlock:]):
(-[HIDEventGenerator liftUp:touchCount:completionBlock:]):
(-[HIDEventGenerator stylusDownAtPoint:azimuthAngle:altitudeAngle:pressure:completionBlock:]):
(-[HIDEventGenerator stylusMoveToPoint:azimuthAngle:altitudeAngle:pressure:completionBlock:]):
(-[HIDEventGenerator stylusUpAtPoint:completionBlock:]):
(-[HIDEventGenerator stylusTapAtPoint:azimuthAngle:altitudeAngle:pressure:completionBlock:]):
(-[HIDEventGenerator sendTaps:location:withNumberOfTouches:completionBlock:]):
(-[HIDEventGenerator longPress:completionBlock:]):
(-[HIDEventGenerator dragWithStartPoint:endPoint:duration:completionBlock:]):
Update code for above renaming.

(hidUsageCodeForCharacter): Translate \b to a backspace and teach this function to recognize the
DumpRenderTree EventSender-compatible modifier key names (e.g. "metaKey").

(-[HIDEventGenerator keyDown:]): Added.
(-[HIDEventGenerator keyUp:]): Added.
(-[HIDEventGenerator keyPress:completionBlock:]):
(-[HIDEventGenerator eventDispatchThreadEntry:]):
(-[HIDEventGenerator _sendMarkerHIDEventWithCompletionBlock:]): Deleted; renamed to sendMarkerHIDEventWithCompletionBlock.
* WebKitTestRunner/ios/UIScriptControllerIOS.mm:
(WTR::parseModifierArray): Modified to return a vector of strings that represent the modifier keys to press.
(WTR::UIScriptController::keyDown): Write in terms of HIDEventGenerator.
(WTR::parseModifier): Deleted.

LayoutTests:

Make tests more robusts.

* fast/events/ios/key-command-italic-dispatches-keydown.html: Remove the need to special-case the test runner and
expect a single key event that represents Command + I. Now that uiController.keyDown() makes use of HIDEventGenerator
we emit separate key events for each key pressed in the sequence: keydown Command, keydown i, keyup i, keyup Command.
This matches how a human being would execute such a key sequence.
* fast/forms/auto-fill-button/caps-lock-indicator-should-not-be-visible-when-auto-fill-strong-password-button-is-visible-expected.html:
Make the test less flaky by hiding the tap highlight. Depending on timing, the tap highlight may be snapshotted and thus
cause the reference test to mismatch the test. Mitigate this by hiding the tap highlight.
* fast/text/scroll-text-overflow-ellipsis.html: Wait for a keyup event for the down arrow before declaring the
test complete.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240512 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/fast/events/ios/key-command-italic-dispatches-keydown.html
LayoutTests/fast/forms/auto-fill-button/caps-lock-indicator-should-not-be-visible-when-auto-fill-strong-password-button-is-visible-expected.html
LayoutTests/fast/text/scroll-text-overflow-ellipsis.html
Tools/ChangeLog
Tools/WebKitTestRunner/ios/HIDEventGenerator.h
Tools/WebKitTestRunner/ios/HIDEventGenerator.mm
Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm