• tapted's avatar
    Mac: Refine ui_controls_mac's SynthesizeKeyEvent() · c3217c83
    tapted authored
    In preparation for moving SynthesizeKeyEvent to cocoa_test_event_utils,
    this refines the behavior of SynthesizeKeyEvent to more closely match
    actual events. There were two bugs:
    
    The unichar character being set on a simulated "Delete" key was actually
    the unichar that Mac uses for "Backspace" (0x7f). Cocoa actually uses
    0xf728 for the delete key (NSDeleteFunctionKey). Note "Backspace" stays
    sending 0x8 (Ctrl+H) rather than being updated to 0x7f (ASCII DEL).
    Either seems to work for Backspace (which meant simulated Deletes were
    becoming deleteBackward action messages rather than deleteForward).
    
    Also, SynthesizeKeyEvent is updated to closely follow the behavior on
    Mac wrt Command/Shift modifiers. The bug here was that when *just*
    Shift+letter is pressed, characters and charactersIgnoringModifiers
    should *both* be uppercase. (r311815 swapped them for Ctrl, but didn't
    try to fix Shift).
    
    These changes are needed for comprehensive testing of views::TextField
    on Mac. Specifically, to get TextfieldTest.ControlAndSelectTest and
    TextfieldTest.ControlAndSelectTest passing with simulated NSEvents.
    
    BUG=378134
    
    Review URL: https://codereview.chromium.org/856313003
    
    Cr-Commit-Position: refs/heads/master@{#313441}
    c3217c83
keyboard_code_conversion_mac.mm 20.1 KB