Need to be able to test default behaviors on force click
authorbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Sep 2015 18:45:48 +0000 (18:45 +0000)
committerbdakin@apple.com <bdakin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 4 Sep 2015 18:45:48 +0000 (18:45 +0000)
commitdaaae22d94e8c720fc86e2d20fb40513a78a470a
tree0b70c7786d6fbcbfe095f2d3962fddbe5df74e9e
parent10079d00169ef94cb99e96057d14b5b7cd794263
Need to be able to test default behaviors on force click
https://bugs.webkit.org/show_bug.cgi?id=148758

Reviewed by Tim Horton.

Source/WebCore:

WKTR needs access to this.
* platform/spi/mac/NSEventSPI.h:

Source/WebKit2:

The hit test seems to return synchronously in WKTR, so we need to do the hit
test last before we clear state otherwise we will trample the hit test
result.
* UIProcess/mac/WKImmediateActionController.mm:
(-[WKImmediateActionController immediateActionRecognizerWillPrepare:]):
(-[WKImmediateActionController immediateActionRecognizerWillBeginAnimation:]):

Tools:

This patch adds a new eventSender method to do a full, completed force click,
and it re-works all of the existing force methods to dispatch their events in
such a way that they will trigger the NSImmediateAction gesture recognizer.
To do this, first we need to send the events to the app rather than straight
to the view, and also needed to tweak some state and send the events in a
delayed fashion.

New public function mouseForceClick() and private helper functions to make
NSEvents.
* WebKitTestRunner/EventSenderProxy.h:

New public function mouseForceClick().
* WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl:
* WebKitTestRunner/InjectedBundle/EventSendingController.cpp:
(WTR::EventSendingController::mouseMoveTo):
(WTR::EventSendingController::mouseForceClick):
(WTR::EventSendingController::mouseForceDown):
* WebKitTestRunner/InjectedBundle/EventSendingController.h:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::didReceiveSynchronousMessageFromInjectedBundle):

initPressureEventAtLocation needs to take a stageTransition and a window.
* WebKitTestRunner/mac/EventSenderProxy.mm:
(-[EventSenderSyntheticEvent initPressureEventAtLocation:globalLocation:stage:pressure:stageTransition:phase:time:eventNumber:window:]):
(-[EventSenderSyntheticEvent stageTransition]):
(-[EventSenderSyntheticEvent timestamp]):
(-[EventSenderSyntheticEvent _cgsEventRecord]):
(-[EventSenderSyntheticEvent window]):

In order to enter the gesture recognizer, we need to start with a mouse down
that has a NSEventMaskPressure modifier.
(WTR::EventSenderProxy::sendMouseDownToStartPressureEvents):

This ensures that the events queue properly for the force monitor in AppKit.
(WTR::spinRunLoopForForce):

 We need to start the pressure change events with a began.
(WTR::EventSenderProxy::beginPressureEvent):

These functions can be used to create the NSEvent for a pressure change every
time we need one.
(WTR::EventSenderProxy::pressureChangeEvent):

Send the right series of events to emulate a full, completed force click.
(WTR::EventSenderProxy::mouseForceClick):

Use all of the new things for these existing functions.
(WTR::EventSenderProxy::mouseForceDown):
(WTR::EventSenderProxy::mouseForceUp):
(WTR::EventSenderProxy::mouseForceChanged):

Set NSFakeForceTouchDevice to YES.
* WebKitTestRunner/mac/main.mm:
(setDefaultsToConsistentValuesForTesting):

LayoutTests:

One new test that tests a regression found during the work for
http://trac.webkit.org/changeset/181660

* fast/events/force-click-on-link-navigation-expected.txt: Added.
* fast/events/force-click-on-link-navigation.html: Added.
* fast/events/resources/do-not-navigate-here.html: Added.
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/ios-simulator/TestExpectations:
* platform/mac-mavericks/TestExpectations:
* platform/mac-wk1/TestExpectations:
* platform/win/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@189365 268f45cc-cd09-0410-ab3c-d52691b4dbfc
22 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/events/force-click-on-link-navigation-expected.txt [new file with mode: 0644]
LayoutTests/fast/events/force-click-on-link-navigation.html [new file with mode: 0644]
LayoutTests/fast/events/resources/do-not-navigate-here.html [new file with mode: 0644]
LayoutTests/platform/efl/TestExpectations
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/ios-simulator/TestExpectations
LayoutTests/platform/mac-mavericks/TestExpectations
LayoutTests/platform/mac-wk1/TestExpectations
LayoutTests/platform/win/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/platform/spi/mac/NSEventSPI.h
Source/WebKit2/ChangeLog
Source/WebKit2/UIProcess/mac/WKImmediateActionController.mm
Tools/ChangeLog
Tools/WebKitTestRunner/EventSenderProxy.h
Tools/WebKitTestRunner/InjectedBundle/Bindings/EventSendingController.idl
Tools/WebKitTestRunner/InjectedBundle/EventSendingController.cpp
Tools/WebKitTestRunner/InjectedBundle/EventSendingController.h
Tools/WebKitTestRunner/TestController.cpp
Tools/WebKitTestRunner/mac/EventSenderProxy.mm
Tools/WebKitTestRunner/mac/main.mm