Changeset 206282 in webkit


Ignore:
Timestamp:
Sep 22, 2016 4:53:33 PM (8 years ago)
Author:
commit-queue@webkit.org
Message:

Add long press selection test
https://bugs.webkit.org/show_bug.cgi?id=162367

Patch by Megan Gardner <Megan Gardner> on 2016-09-22
Reviewed by Simon Fraser.

Tools:

Add support to UIScriptController to synthesize long press events on iOS.
This required adding long-press functionality to HIDEventGenerator.

HIDEventGenerator sends the touchDown, but must then send the touchUp with
a dispatch_after (rather than sleeping, as we do for other events) in order
for the gesture recognizers to correctly detect a long press.

Use the long press synthesis in a test that detects whether a long press
gesture triggers text selection.

Fixed incorrect constants. NSTimeInterval is in seconds, original numbers
were nanoseconds and typedefed to long without regard to the type
differences. Redid constants to be the right value, and converted upon use.

Cleaned up unused enum types.

  • DumpRenderTree/ios/UIScriptControllerIOS.mm:

(WTR::UIScriptController::longPressAtPoint):
(WTR::UIScriptController::forcePressAtPoint):
(WTR::UIScriptController::dragFromPointToPoint): Deleted.

  • Scripts/webkitpy/common/config/contributors.json:
  • TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
  • TestRunnerShared/UIScriptContext/UIScriptController.cpp:

(WTR::UIScriptController::longPressAtPoint):
(WTR::UIScriptController::forcePressAtPoint):
(WTR::UIScriptController::dragFromPointToPoint): Deleted.

  • TestRunnerShared/UIScriptContext/UIScriptController.h:
  • WebKitTestRunner/ios/HIDEventGenerator.h:
  • WebKitTestRunner/ios/HIDEventGenerator.mm:

(-[HIDEventGenerator _createIOHIDEventType:]):
(-[HIDEventGenerator sendTaps:location:withNumberOfTouches:completionBlock:]):
(-[HIDEventGenerator clearTap:]):
(-[HIDEventGenerator longPressTimerCall:]):
(-[HIDEventGenerator longPressFinish:completionBlock:]):
(-[HIDEventGenerator longPress:completionBlock:]):
(-[HIDEventGenerator forcePress:completionBlock:]):

  • WebKitTestRunner/ios/UIScriptControllerIOS.mm:

(WTR::UIScriptController::longPressAtPoint):
(WTR::UIScriptController::forcePressAtPoint):
(WTR::UIScriptController::dragFromPointToPoint): Deleted.

LayoutTests:

Added test for long press selection.

  • fast/events/touch/ios/long-press-to-select-text-expected.txt: Added.
  • fast/events/touch/ios/long-press-to-select-text.html: Added.
Location:
trunk
Files:
2 added
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r206280 r206282  
     12016-09-22  Megan Gardner  <megan_gardner@apple.com>
     2
     3        Add long press selection test
     4        https://bugs.webkit.org/show_bug.cgi?id=162367
     5
     6        Reviewed by Simon Fraser.
     7
     8        Added test for long press selection.
     9
     10        * fast/events/touch/ios/long-press-to-select-text-expected.txt: Added.
     11        * fast/events/touch/ios/long-press-to-select-text.html: Added.
     12
    1132016-09-22  Brady Eidson  <beidson@apple.com>
    214
  • trunk/Tools/ChangeLog

    r206261 r206282  
     12016-09-22  Megan Gardner  <megan_gardner@apple.com>
     2
     3        Add long press selection test
     4        https://bugs.webkit.org/show_bug.cgi?id=162367
     5
     6        Reviewed by Simon Fraser.
     7
     8        Add support to UIScriptController to synthesize long press events on iOS.
     9        This required adding long-press functionality to HIDEventGenerator.
     10
     11        HIDEventGenerator sends the touchDown, but must then send the touchUp with
     12        a dispatch_after (rather than sleeping, as we do for other events) in order
     13        for the gesture recognizers to correctly detect a long press.
     14
     15        Use the long press synthesis in a test that detects whether a long press
     16        gesture triggers text selection.
     17
     18        Fixed incorrect constants. NSTimeInterval is in seconds, original numbers
     19        were nanoseconds and typedefed to long without regard to the type
     20        differences. Redid constants to be the right value, and converted upon use.
     21
     22        Cleaned up unused enum types.
     23
     24        * DumpRenderTree/ios/UIScriptControllerIOS.mm:
     25        (WTR::UIScriptController::longPressAtPoint):
     26        (WTR::UIScriptController::forcePressAtPoint):
     27        (WTR::UIScriptController::dragFromPointToPoint): Deleted.
     28        * Scripts/webkitpy/common/config/contributors.json:
     29        * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl:
     30        * TestRunnerShared/UIScriptContext/UIScriptController.cpp:
     31        (WTR::UIScriptController::longPressAtPoint):
     32        (WTR::UIScriptController::forcePressAtPoint):
     33        (WTR::UIScriptController::dragFromPointToPoint): Deleted.
     34        * TestRunnerShared/UIScriptContext/UIScriptController.h:
     35        * WebKitTestRunner/ios/HIDEventGenerator.h:
     36        * WebKitTestRunner/ios/HIDEventGenerator.mm:
     37        (-[HIDEventGenerator _createIOHIDEventType:]):
     38        (-[HIDEventGenerator sendTaps:location:withNumberOfTouches:completionBlock:]):
     39        (-[HIDEventGenerator clearTap:]):
     40        (-[HIDEventGenerator longPressTimerCall:]):
     41        (-[HIDEventGenerator longPressFinish:completionBlock:]):
     42        (-[HIDEventGenerator longPress:completionBlock:]):
     43        (-[HIDEventGenerator forcePress:completionBlock:]):
     44        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
     45        (WTR::UIScriptController::longPressAtPoint):
     46        (WTR::UIScriptController::forcePressAtPoint):
     47        (WTR::UIScriptController::dragFromPointToPoint): Deleted.
     48
    1492016-09-22  Jonathan Bedard  <jbedard@apple.com>
    250
  • trunk/Tools/DumpRenderTree/ios/UIScriptControllerIOS.mm

    r205572 r206282  
    8686
    8787void UIScriptController::dragFromPointToPoint(long startX, long startY, long endX, long endY, double durationSeconds, JSValueRef callback)
     88{
     89}
     90   
     91void UIScriptController::longPressAtPoint(long x, long y, JSValueRef)
    8892{
    8993}
  • trunk/Tools/TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl

    r205572 r206282  
    3838    void doubleTapAtPoint(long x, long y, object callback);
    3939    void dragFromPointToPoint(long startX, long startY, long endX, long endY, double durationSeconds, object callback);
     40
     41    void longPressAtPoint(long x, long y, object callback);
    4042
    4143    void stylusDownAtPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, object callback);
  • trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.cpp

    r205572 r206282  
    160160{
    161161}
     162   
     163void UIScriptController::longPressAtPoint(long x, long y, JSValueRef)
     164{
     165}
    162166
    163167void UIScriptController::stylusDownAtPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback)
  • trunk/Tools/TestRunnerShared/UIScriptContext/UIScriptController.h

    r205572 r206282  
    6363    void stylusTapAtPoint(long x, long y, float azimuthAngle, float altitudeAngle, float pressure, JSValueRef callback);
    6464
     65    void longPressAtPoint(long x, long y, JSValueRef callback);
     66   
    6567    void typeCharacterUsingHardwareKeyboard(JSStringRef character, JSValueRef callback);
    6668    void keyDownUsingHardwareKeyboard(JSStringRef character, JSValueRef callback);
  • trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.h

    r205572 r206282  
    4747- (void)twoFingerTap:(CGPoint)location completionBlock:(void (^)(void))completionBlock;
    4848
     49// Long Press
     50- (void)longPress:(CGPoint)location completionBlock:(void (^)(void))completionBlock;
     51
    4952// Drags
    5053- (void)dragWithStartPoint:(CGPoint)startLocation endPoint:(CGPoint)endLocation duration:(double)seconds completionBlock:(void (^)(void))completionBlock;
  • trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.mm

    r205766 r206282  
    3232#import <mach/mach_time.h>
    3333#import <wtf/Assertions.h>
     34#import <wtf/BlockPtr.h>
    3435#import <wtf/RetainPtr.h>
    3536
     
    3738SOFT_LINK(BackBoardServices, BKSHIDEventSetDigitizerInfo, void, (IOHIDEventRef digitizerEvent, uint32_t contextID, uint8_t systemGestureisPossible, uint8_t isSystemGestureStateChangeEvent, CFStringRef displayUUID, CFTimeInterval initialTouchTimestamp, float maxForce), (digitizerEvent, contextID, systemGestureisPossible, isSystemGestureStateChangeEvent, displayUUID, initialTouchTimestamp, maxForce));
    3839
    39 static const NSTimeInterval fingerLiftDelay = 5e7;
    40 static const NSTimeInterval multiTapInterval = 15e7;
     40static const NSTimeInterval fingerLiftDelay = 0.05;
     41static const NSTimeInterval multiTapInterval = 0.15;
    4142static const NSTimeInterval fingerMoveInterval = 0.016;
     43static const NSTimeInterval longPressHoldDelay = 2.0;
    4244static const IOHIDFloat defaultMajorRadius = 5;
    4345static const IOHIDFloat defaultPathPressure = 0;
     
    5456    HandEventLifted,
    5557    HandEventCanceled,
    56     HandEventInRange,
    57     HandEventInRangeLift,
    5858    StylusEventTouched,
    5959    StylusEventMoved,
     
    159159        eventMask |= kIOHIDDigitizerEventPosition;
    160160        eventMask |= kIOHIDDigitizerEventAttribute;
    161     } else if (eventType == HandEventTouched  || eventType == HandEventCanceled) {
    162         eventMask |= kIOHIDDigitizerEventIdentity;
    163     } else if (eventType == HandEventLifted)
     161    } else if (eventType == HandEventTouched || eventType == HandEventCanceled || eventType == HandEventLifted)
    164162        eventMask |= kIOHIDDigitizerEventIdentity;
    165163
     
    495493- (void)stylusTapAtPoint:(CGPoint)location azimuthAngle:(CGFloat)azimuthAngle altitudeAngle:(CGFloat)altitudeAngle pressure:(CGFloat)pressure completionBlock:(void (^)(void))completionBlock
    496494{
    497     struct timespec pressDelay = { 0, static_cast<long>(fingerLiftDelay) };
     495    struct timespec pressDelay = { 0, static_cast<long>(fingerLiftDelay * nanosecondsPerSecond) };
    498496
    499497    [self stylusDownAtPoint:location azimuthAngle:azimuthAngle altitudeAngle:altitudeAngle pressure:pressure];
     
    506504- (void)sendTaps:(int)tapCount location:(CGPoint)location withNumberOfTouches:(int)touchCount completionBlock:(void (^)(void))completionBlock
    507505{
    508     struct timespec doubleDelay = { 0, static_cast<long>(multiTapInterval) };
    509     struct timespec pressDelay = { 0, static_cast<long>(fingerLiftDelay) };
     506    struct timespec doubleDelay = { 0, static_cast<long>(multiTapInterval * nanosecondsPerSecond) };
     507    struct timespec pressDelay = { 0, static_cast<long>(fingerLiftDelay * nanosecondsPerSecond) };
    510508
    511509    for (int i = 0; i < tapCount; i++) {
     
    533531{
    534532    [self sendTaps:1 location:location withNumberOfTouches:2 completionBlock:completionBlock];
     533}
     534
     535- (void)longPress:(CGPoint)location completionBlock:(void (^)(void))completionBlock
     536{
     537    [self touchDown:location touchCount:1];
     538    auto completionBlockCopy = makeBlockPtr(completionBlock);
     539
     540    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, longPressHoldDelay * nanosecondsPerSecond), dispatch_get_main_queue(), ^ {
     541        [self liftUp:location];
     542        [self _sendMarkerHIDEventWithCompletionBlock:completionBlockCopy.get()];
     543    });
    535544}
    536545
  • trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

    r205572 r206282  
    188188    }];
    189189}
     190   
     191void UIScriptController::longPressAtPoint(long x, long y, JSValueRef callback)
     192{
     193    unsigned callbackID = m_context->prepareForAsyncTask(callback, CallbackTypeNonPersistent);
     194   
     195    [[HIDEventGenerator sharedHIDEventGenerator] longPress:globalToContentCoordinates(TestController::singleton().mainWebView()->platformView(), x, y) completionBlock:^{
     196        if (!m_context)
     197            return;
     198        m_context->asyncTaskComplete(callbackID);
     199    }];
     200}
    190201
    191202void UIScriptController::typeCharacterUsingHardwareKeyboard(JSStringRef character, JSValueRef callback)
Note: See TracChangeset for help on using the changeset viewer.