Changeset 246657 in webkit


Ignore:
Timestamp:
Jun 20, 2019 3:28:47 PM (5 years ago)
Author:
achristensen@apple.com
Message:

Add unit test for UIContextMenuConfiguration API
https://bugs.webkit.org/show_bug.cgi?id=199043

Reviewed by Wenson Hsieh.

Source/WebKit:

  • UIProcess/API/APIPageConfiguration.cpp:

(API::PageConfiguration::copy const):

  • UIProcess/API/APIPageConfiguration.h:

(API::PageConfiguration::clickInteractionDriverForTesting const):
(API::PageConfiguration::setClickInteractionDriverForTesting):

  • UIProcess/API/Cocoa/WKWebViewConfiguration.mm:

(-[WKWebViewConfiguration _setClickInteractionDriverForTesting:]):
(-[WKWebViewConfiguration _clickInteractionDriverForTesting]):

  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView _registerPreview]):

Tools:

  • TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
  • TestWebKitAPI/Tests/WebKitCocoa/ContextMenus.mm: Added.

(-[TestContextMenuUIDelegate webView:contextMenuConfigurationForElement:completionHandler:]):
(-[TestContextMenuUIDelegate webView:contextMenuWillPresentForElement:]):
(-[TestContextMenuUIDelegate webView:contextMenuForElement:willCommitWithAnimator:]):
(-[TestContextMenuUIDelegate webView:contextMenuDidEndForElement:]):
(TEST):

  • TestWebKitAPI/cocoa/TestContextMenuDriver.h: Added.
  • TestWebKitAPI/cocoa/TestContextMenuDriver.mm: Added.

(-[TestContextMenuDriver delegate]):
(-[TestContextMenuDriver setDelegate:]):
(-[TestContextMenuDriver view]):
(-[TestContextMenuDriver setView:]):
(-[TestContextMenuDriver allowableMovement]):
(-[TestContextMenuDriver setAllowableMovement:]):
(-[TestContextMenuDriver primaryGestureRecognizer]):
(-[TestContextMenuDriver setPrimaryGestureRecognizer:]):
(-[TestContextMenuDriver touchDuration]):
(-[TestContextMenuDriver setTouchDuration:]):
(-[TestContextMenuDriver locationInCoordinateSpace:]):
(-[TestContextMenuDriver cancelInteraction]):
(-[TestContextMenuDriver begin:]):
(-[TestContextMenuDriver clickDown]):
(-[TestContextMenuDriver clickUp]):
(-[TestContextMenuDriver end]):

  • TestWebKitAPI/ios/UIKitSPI.h:
Location:
trunk
Files:
3 added
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r246639 r246657  
     12019-06-20  Alex Christensen  <achristensen@webkit.org>
     2
     3        Add unit test for UIContextMenuConfiguration API
     4        https://bugs.webkit.org/show_bug.cgi?id=199043
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        * UIProcess/API/APIPageConfiguration.cpp:
     9        (API::PageConfiguration::copy const):
     10        * UIProcess/API/APIPageConfiguration.h:
     11        (API::PageConfiguration::clickInteractionDriverForTesting const):
     12        (API::PageConfiguration::setClickInteractionDriverForTesting):
     13        * UIProcess/API/Cocoa/WKWebViewConfiguration.mm:
     14        (-[WKWebViewConfiguration _setClickInteractionDriverForTesting:]):
     15        (-[WKWebViewConfiguration _clickInteractionDriverForTesting]):
     16        * UIProcess/ios/WKContentViewInteraction.mm:
     17        (-[WKContentView _registerPreview]):
     18
    1192019-06-20  Alexander Mikhaylenko  <exalm7659@gmail.com>
    220
  • trunk/Source/WebKit/Platform/spi/ios/UIKitSPI.h

    r246583 r246657  
    11911191@property (nonatomic, copy) UIContextMenuActionProvider actionProvider;
    11921192@end
     1193
     1194@protocol _UIClickInteractionDriverDelegate;
     1195@protocol _UIClickInteractionDriving <NSObject>
     1196@property (nonatomic, weak) id <_UIClickInteractionDriverDelegate> delegate;
     1197@end
     1198
     1199@class _UIClickPresentationInteraction;
     1200@interface UIContextMenuInteraction (Radar51288435)
     1201@property (nonatomic, strong) _UIClickPresentationInteraction *presentationInteraction;
     1202@end
     1203
     1204@interface _UIClickInteraction : NSObject <UIInteraction>
     1205@end
     1206
     1207@interface _UIClickPresentationInteraction : NSObject <UIInteraction>
     1208@end
     1209@interface _UIClickPresentationInteraction (NeededUntil51288435Fixed)
     1210@property (nonatomic, strong) _UIClickInteraction *previewClickInteraction;
     1211@end
     1212
     1213@interface _UIClickInteraction (Radar51288435)
     1214@property (nonatomic, strong) id<_UIClickInteractionDriving> driver;
     1215@end
     1216
    11931217#endif
    11941218
  • trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.cpp

    r245183 r246657  
    7474    copy->m_alwaysRunsAtForegroundPriority = this->m_alwaysRunsAtForegroundPriority;
    7575    copy->m_canShowWhileLocked = this->m_canShowWhileLocked;
     76    copy->m_clickInteractionDriverForTesting = this->m_clickInteractionDriverForTesting;
    7677#endif
    7778    copy->m_initialCapitalizationEnabled = this->m_initialCapitalizationEnabled;
  • trunk/Source/WebKit/UIProcess/API/APIPageConfiguration.h

    r245183 r246657  
    3131#include <wtf/Forward.h>
    3232#include <wtf/GetPtr.h>
     33
     34#if PLATFORM(IOS_FAMILY)
     35OBJC_PROTOCOL(_UIClickInteractionDriving);
     36#include <wtf/RetainPtr.h>
     37#endif
    3338
    3439namespace WebKit {
     
    99104    bool canShowWhileLocked() const { return m_canShowWhileLocked; }
    100105    void setCanShowWhileLocked(bool canShowWhileLocked) { m_canShowWhileLocked = canShowWhileLocked; }
     106
     107    const RetainPtr<_UIClickInteractionDriving>& clickInteractionDriverForTesting() const { return m_clickInteractionDriverForTesting; }
     108    void setClickInteractionDriverForTesting(RetainPtr<_UIClickInteractionDriving>&& driver) { m_clickInteractionDriverForTesting = WTFMove(driver); }
    101109#endif
    102110    bool initialCapitalizationEnabled() { return m_initialCapitalizationEnabled; }
     
    152160    bool m_alwaysRunsAtForegroundPriority { false };
    153161    bool m_canShowWhileLocked { false };
     162    RetainPtr<_UIClickInteractionDriving> m_clickInteractionDriverForTesting;
    154163#endif
    155164    bool m_initialCapitalizationEnabled { true };
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfiguration.mm

    r246236 r246657  
    792792}
    793793
     794- (void)_setClickInteractionDriverForTesting:(id<_UIClickInteractionDriving>)driver
     795{
     796    _pageConfiguration->setClickInteractionDriverForTesting((NSObject<_UIClickInteractionDriving> *)driver);
     797}
     798
     799- (id <_UIClickInteractionDriving>)_clickInteractionDriverForTesting
     800{
     801    return _pageConfiguration->clickInteractionDriverForTesting().get();
     802}
     803
    794804#endif // PLATFORM(IOS_FAMILY)
    795805
  • trunk/Source/WebKit/UIProcess/API/Cocoa/WKWebViewConfigurationPrivate.h

    r245294 r246657  
    3434    _WKDragLiftDelayLong
    3535} WK_API_AVAILABLE(ios(11.0));
     36
     37@protocol _UIClickInteractionDriving;
    3638#endif
    3739
     
    8587@property (nonatomic, setter=_setShouldDecidePolicyBeforeLoadingQuickLookPreview:) BOOL _shouldDecidePolicyBeforeLoadingQuickLookPreview WK_API_AVAILABLE(ios(WK_IOS_TBA));
    8688@property (nonatomic, setter=_setCanShowWhileLocked:) BOOL _canShowWhileLocked WK_API_AVAILABLE(ios(WK_IOS_TBA));
     89@property (nonatomic, setter=_setClickInteractionDriverForTesting:) id <_UIClickInteractionDriving> _clickInteractionDriverForTesting WK_API_AVAILABLE(ios(WK_IOS_TBA));
    8790#else
    8891@property (nonatomic, setter=_setShowsURLsInToolTips:) BOOL _showsURLsInToolTips WK_API_AVAILABLE(macos(10.12));
  • trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm

    r246626 r246657  
    74357435        [self addInteraction:_contextMenuInteraction.get()];
    74367436
     7437        if (id<_UIClickInteractionDriving> driver = _webView.configuration._clickInteractionDriverForTesting) {
     7438            _UIClickInteraction *previewClickInteraction = [[_contextMenuInteraction presentationInteraction] previewClickInteraction];
     7439            [previewClickInteraction setDriver:driver];
     7440            [driver setDelegate:(id<_UIClickInteractionDriverDelegate>)previewClickInteraction];
     7441        }
     7442
    74377443        [self _showLinkPreviewsPreferenceChanged:nil];
    74387444
  • trunk/Tools/ChangeLog

    r246656 r246657  
     12019-06-20  Alex Christensen  <achristensen@webkit.org>
     2
     3        Add unit test for UIContextMenuConfiguration API
     4        https://bugs.webkit.org/show_bug.cgi?id=199043
     5
     6        Reviewed by Wenson Hsieh.
     7
     8        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
     9        * TestWebKitAPI/Tests/WebKitCocoa/ContextMenus.mm: Added.
     10        (-[TestContextMenuUIDelegate webView:contextMenuConfigurationForElement:completionHandler:]):
     11        (-[TestContextMenuUIDelegate webView:contextMenuWillPresentForElement:]):
     12        (-[TestContextMenuUIDelegate webView:contextMenuForElement:willCommitWithAnimator:]):
     13        (-[TestContextMenuUIDelegate webView:contextMenuDidEndForElement:]):
     14        (TEST):
     15        * TestWebKitAPI/cocoa/TestContextMenuDriver.h: Added.
     16        * TestWebKitAPI/cocoa/TestContextMenuDriver.mm: Added.
     17        (-[TestContextMenuDriver delegate]):
     18        (-[TestContextMenuDriver setDelegate:]):
     19        (-[TestContextMenuDriver view]):
     20        (-[TestContextMenuDriver setView:]):
     21        (-[TestContextMenuDriver allowableMovement]):
     22        (-[TestContextMenuDriver setAllowableMovement:]):
     23        (-[TestContextMenuDriver primaryGestureRecognizer]):
     24        (-[TestContextMenuDriver setPrimaryGestureRecognizer:]):
     25        (-[TestContextMenuDriver touchDuration]):
     26        (-[TestContextMenuDriver setTouchDuration:]):
     27        (-[TestContextMenuDriver locationInCoordinateSpace:]):
     28        (-[TestContextMenuDriver cancelInteraction]):
     29        (-[TestContextMenuDriver begin:]):
     30        (-[TestContextMenuDriver clickDown]):
     31        (-[TestContextMenuDriver clickUp]):
     32        (-[TestContextMenuDriver end]):
     33        * TestWebKitAPI/ios/UIKitSPI.h:
     34
    1352019-06-20  Aakash Jain  <aakash_jain@apple.com>
    236
  • trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj

    r246623 r246657  
    320320                5C2936931D5BF70D00DEAB1E /* CookieAcceptPolicy.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C2936911D5BF63E00DEAB1E /* CookieAcceptPolicy.mm */; };
    321321                5C2936961D5C00ED00DEAB1E /* CookieMessage.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = 5C2936941D5BFD1900DEAB1E /* CookieMessage.html */; };
     322                5C3B1D2622A74F6700BCF4D0 /* ContextMenus.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C3B1D2522A74EA400BCF4D0 /* ContextMenus.mm */; };
    322323                5C4259462266A68A0039AA7A /* BasicProposedCredentialPlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C42594422669E9B0039AA7A /* BasicProposedCredentialPlugIn.mm */; };
    323324                5C4A84951F7EEFFC00ACFC54 /* Configuration.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5C4A84941F7EEFD400ACFC54 /* Configuration.mm */; };
     
    350351                5CCB10E4213457E000AC5AF0 /* ShouldGoToBackForwardListItem.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CCB10DF2134579D00AC5AF0 /* ShouldGoToBackForwardListItem.mm */; };
    351352                5CE354D91E70DA5C00BEFE3B /* WKContentExtensionStore.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CE354D81E70D9C300BEFE3B /* WKContentExtensionStore.mm */; };
     353                5CE7594922A883D200C12409 /* TestContextMenuDriver.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CE7594722A883A500C12409 /* TestContextMenuDriver.mm */; };
    352354                5CEAB5E11FA939F400A77FAA /* _WKInputDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CEAB5DF1FA937CB00A77FAA /* _WKInputDelegate.mm */; };
    353355                5CF540E92257E67C00E6BC0E /* DownloadThread.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5CF540E82257E64B00E6BC0E /* DownloadThread.mm */; };
     
    17681770                5C2936911D5BF63E00DEAB1E /* CookieAcceptPolicy.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CookieAcceptPolicy.mm; sourceTree = "<group>"; };
    17691771                5C2936941D5BFD1900DEAB1E /* CookieMessage.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = CookieMessage.html; sourceTree = "<group>"; };
     1772                5C3B1D2522A74EA400BCF4D0 /* ContextMenus.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ContextMenus.mm; sourceTree = "<group>"; };
    17701773                5C42594422669E9B0039AA7A /* BasicProposedCredentialPlugIn.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BasicProposedCredentialPlugIn.mm; sourceTree = "<group>"; };
    17711774                5C4A84941F7EEFD400ACFC54 /* Configuration.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Configuration.mm; sourceTree = "<group>"; };
     
    17991802                5CCB10E02134579D00AC5AF0 /* ResponsivenessTimer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ResponsivenessTimer.mm; sourceTree = "<group>"; };
    18001803                5CE354D81E70D9C300BEFE3B /* WKContentExtensionStore.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKContentExtensionStore.mm; sourceTree = "<group>"; };
     1804                5CE7594722A883A500C12409 /* TestContextMenuDriver.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TestContextMenuDriver.mm; path = cocoa/TestContextMenuDriver.mm; sourceTree = "<group>"; };
     1805                5CE7594822A883A500C12409 /* TestContextMenuDriver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestContextMenuDriver.h; path = cocoa/TestContextMenuDriver.h; sourceTree = "<group>"; };
    18011806                5CEAB5DF1FA937CB00A77FAA /* _WKInputDelegate.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = _WKInputDelegate.mm; sourceTree = "<group>"; };
    18021807                5CF540E82257E64B00E6BC0E /* DownloadThread.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = DownloadThread.mm; sourceTree = "<group>"; };
     
    25402545                                F44A531021B8976900DBB99C /* InstanceMethodSwizzler.mm */,
    25412546                                0F139E721A423A2B00F590F5 /* PlatformUtilitiesCocoa.mm */,
     2547                                5CE7594822A883A500C12409 /* TestContextMenuDriver.h */,
     2548                                5CE7594722A883A500C12409 /* TestContextMenuDriver.mm */,
    25422549                                2D1C04A51D76298B000A6816 /* TestNavigationDelegate.h */,
    25432550                                2D1C04A61D76298B000A6816 /* TestNavigationDelegate.mm */,
     
    26162623                                A14FC5891B89927100D107EB /* ContentFilteringPlugIn.mm */,
    26172624                                5CA1DED81F74A87100E71BD3 /* ContentRuleListNotification.mm */,
     2625                                5C3B1D2522A74EA400BCF4D0 /* ContextMenus.mm */,
    26182626                                5C2936911D5BF63E00DEAB1E /* CookieAcceptPolicy.mm */,
    26192627                                5C19A5231FD0F32600EEA323 /* CookiePrivateBrowsing.mm */,
     
    41714179                                8349D3C21DB96DDE004A9F65 /* ContextMenuDownload.mm in Sources */,
    41724180                                CD0BD0A61F79924D001AB2CF /* ContextMenuImgWithVideo.mm in Sources */,
     4181                                5C3B1D2622A74F6700BCF4D0 /* ContextMenus.mm in Sources */,
    41734182                                5C2936931D5BF70D00DEAB1E /* CookieAcceptPolicy.mm in Sources */,
    41744183                                51D1249B1E785425002B2820 /* CookieManager.cpp in Sources */,
     
    44744483                                7CCE7F161A411AE600447C4C /* TerminateTwice.cpp in Sources */,
    44754484                                7CCE7EA91A411A1D00447C4C /* TestBrowsingContextLoadDelegate.mm in Sources */,
     4485                                5CE7594922A883D200C12409 /* TestContextMenuDriver.mm in Sources */,
    44764486                                F46128CB211D475100D9FADB /* TestDraggingInfo.mm in Sources */,
    44774487                                F4E0A2B82122847400AF7C7F /* TestFilePromiseReceiver.mm in Sources */,
  • trunk/Tools/TestWebKitAPI/ios/UIKitSPI.h

    r245998 r246657  
    200200@end
    201201
     202typedef NS_ENUM(NSUInteger, _UIClickInteractionEvent) {
     203    _UIClickInteractionEventBegan = 0,
     204    _UIClickInteractionEventClickedDown,
     205    _UIClickInteractionEventClickedUp,
     206    _UIClickInteractionEventEnded,
     207    _UIClickInteractionEventCount
     208};
     209
     210@protocol _UIClickInteractionDriving;
     211@protocol _UIClickInteractionDriverDelegate <NSObject>
     212- (void)clickDriver:(id<_UIClickInteractionDriving>)driver shouldBegin:(void(^)(BOOL))completion;
     213- (void)clickDriver:(id<_UIClickInteractionDriving>)driver didPerformEvent:(_UIClickInteractionEvent)event;
     214@optional
     215- (void)clickDriver:(id<_UIClickInteractionDriving>)driver didUpdateHighlightProgress:(CGFloat)progress;
     216- (BOOL)clickDriver:(id<_UIClickInteractionDriving>)driver shouldDelayGestureRecognizer:(UIGestureRecognizer *)gestureRecognizer;
     217@end
     218
    202219#endif // PLATFORM(IOS)
    203220
Note: See TracChangeset for help on using the changeset viewer.