Changeset 204525 in webkit


Ignore:
Timestamp:
Aug 16, 2016, 3:15:47 PM (9 years ago)
Author:
Simon Fraser
Message:

Make it possible to test iOS select elements, and add iPhone and iPad tests for them
https://bugs.webkit.org/show_bug.cgi?id=160909

Reviewed by Enrica Casucci.

Source/WebKit2:

Hook up form-related UIScriptController functions, and plumb through the various
<select> pickers the ability to select a row.

  • UIProcess/API/Cocoa/WKWebView.mm:

(-[WKWebView dismissFormAccessoryView]):
(-[WKWebView selectFormAccessoryPickerRow:]):

  • UIProcess/API/Cocoa/WKWebViewPrivate.h:
  • UIProcess/ios/WKContentViewInteraction.h:
  • UIProcess/ios/WKContentViewInteraction.mm:

(-[WKContentView selectFormAccessoryPickerRow:]):

  • UIProcess/ios/forms/WKFormSelectControl.h:
  • UIProcess/ios/forms/WKFormSelectControl.mm:

(-[WKFormSelectControl selectRow:inComponent:extendingSelection:]):

  • UIProcess/ios/forms/WKFormSelectPicker.mm:

(-[WKMultipleSelectPicker selectRow:inComponent:extendingSelection:]):
(-[WKSelectSinglePicker selectRow:inComponent:extendingSelection:]):

  • UIProcess/ios/forms/WKFormSelectPopover.mm:

(-[WKSelectPopover selectRow:inComponent:extendingSelection:]):

Tools:

Add functions to UIScriptController to dismiss the form accessory view for iOS,
and to programmatically pick a row from a <select> picker.

  • WebKitTestRunner/UIScriptContext/Bindings/UIScriptController.idl:
  • WebKitTestRunner/UIScriptContext/UIScriptController.cpp:

(WTR::UIScriptController::dismissFormAccessoryView):
(WTR::UIScriptController::selectFormAccessoryPickerRow):

  • WebKitTestRunner/UIScriptContext/UIScriptController.h:
  • WebKitTestRunner/ios/UIScriptControllerIOS.mm:

(WTR::UIScriptController::dismissFormAccessoryView):
(WTR::UIScriptController::selectFormAccessoryPickerRow):

LayoutTests:

Add iPhone and iPad tests for the <select> pickers. The iPhone test has to
use a didShowKeyboardCallback to know when to select the appropriate row,
and to dismiss the picker. The iPad test can just select the row, which also
dismisses the popover.

  • fast/forms/ios/choose-select-option-expected.txt: Added.
  • fast/forms/ios/choose-select-option.html: Added.
  • fast/forms/ios/ipad/choose-select-option-expected.txt: Added.
  • fast/forms/ios/ipad/choose-select-option.html: Added.
Location:
trunk
Files:
4 added
15 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r204523 r204525  
     12016-08-16  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make it possible to test iOS select elements, and add iPhone and iPad tests for them
     4        https://bugs.webkit.org/show_bug.cgi?id=160909
     5
     6        Reviewed by Enrica Casucci.
     7       
     8        Add iPhone and iPad tests for the <select> pickers. The iPhone test has to
     9        use a didShowKeyboardCallback to know when to select the appropriate row,
     10        and to dismiss the picker. The iPad test can just select the row, which also
     11        dismisses the popover.
     12
     13        * fast/forms/ios/choose-select-option-expected.txt: Added.
     14        * fast/forms/ios/choose-select-option.html: Added.
     15        * fast/forms/ios/ipad/choose-select-option-expected.txt: Added.
     16        * fast/forms/ios/ipad/choose-select-option.html: Added.
     17
    1182016-08-15  Simon Fraser  <simon.fraser@apple.com>
    219
  • trunk/Source/WebKit2/ChangeLog

    r204524 r204525  
     12016-08-16  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make it possible to test iOS select elements, and add iPhone and iPad tests for them
     4        https://bugs.webkit.org/show_bug.cgi?id=160909
     5
     6        Reviewed by Enrica Casucci.
     7       
     8        Hook up form-related UIScriptController functions, and plumb through the various
     9        <select> pickers the ability to select a row.
     10
     11        * UIProcess/API/Cocoa/WKWebView.mm:
     12        (-[WKWebView dismissFormAccessoryView]):
     13        (-[WKWebView selectFormAccessoryPickerRow:]):
     14        * UIProcess/API/Cocoa/WKWebViewPrivate.h:
     15        * UIProcess/ios/WKContentViewInteraction.h:
     16        * UIProcess/ios/WKContentViewInteraction.mm:
     17        (-[WKContentView selectFormAccessoryPickerRow:]):
     18        * UIProcess/ios/forms/WKFormSelectControl.h:
     19        * UIProcess/ios/forms/WKFormSelectControl.mm:
     20        (-[WKFormSelectControl selectRow:inComponent:extendingSelection:]):
     21        * UIProcess/ios/forms/WKFormSelectPicker.mm:
     22        (-[WKMultipleSelectPicker selectRow:inComponent:extendingSelection:]):
     23        (-[WKSelectSinglePicker selectRow:inComponent:extendingSelection:]):
     24        * UIProcess/ios/forms/WKFormSelectPopover.mm:
     25        (-[WKSelectPopover selectRow:inComponent:extendingSelection:]):
     26
    1272016-08-16  Brady Eidson  <beidson@apple.com>
    228
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebView.mm

    r204523 r204525  
    45184518}
    45194519
     4520- (void)dismissFormAccessoryView
     4521{
     4522    [_contentView accessoryDone];
     4523}
     4524
     4525- (void)selectFormAccessoryPickerRow:(int)rowIndex
     4526{
     4527    [_contentView selectFormAccessoryPickerRow:rowIndex];
     4528}
     4529
    45204530#endif // PLATFORM(IOS)
    45214531
  • trunk/Source/WebKit2/UIProcess/API/Cocoa/WKWebViewPrivate.h

    r204523 r204525  
    255255
    256256#if TARGET_OS_IPHONE
     257
    257258@property (nonatomic, readonly) CGRect _contentVisibleRect WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
    258259- (CGPoint)_convertPointFromContentsToView:(CGPoint)point WK_API_AVAILABLE(macosx(WK_MAC_TBA), ios(WK_IOS_TBA));
     
    261262- (void)keyboardAccessoryBarNext WK_API_AVAILABLE(ios(WK_IOS_TBA));
    262263- (void)keyboardAccessoryBarPrevious WK_API_AVAILABLE(ios(WK_IOS_TBA));
     264- (void)dismissFormAccessoryView WK_API_AVAILABLE(ios(WK_IOS_TBA));
     265- (void)selectFormAccessoryPickerRow:(int)rowIndex WK_API_AVAILABLE(ios(WK_IOS_TBA));
     266
    263267#endif
    264268
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.h

    r204523 r204525  
    224224@end
    225225
     226@interface WKContentView (WKTesting)
     227
     228- (void)selectFormAccessoryPickerRow:(NSInteger)rowIndex;
     229
     230@end
     231
    226232#if HAVE(LINK_PREVIEW)
    227233@interface WKContentView (WKInteractionPreview) <UIPreviewItemDelegate>
  • trunk/Source/WebKit2/UIProcess/ios/WKContentViewInteraction.mm

    r204523 r204525  
    37983798@end
    37993799
     3800@implementation WKContentView (WKTesting)
     3801
     3802- (void)selectFormAccessoryPickerRow:(NSInteger)rowIndex
     3803{
     3804    if ([_inputPeripheral isKindOfClass:[WKFormSelectControl self]])
     3805        [(WKFormSelectControl *)_inputPeripheral selectRow:rowIndex inComponent:0 extendingSelection:NO];
     3806}
     3807
     3808@end
     3809
    38003810#if HAVE(LINK_PREVIEW)
    38013811
     
    41094119@end
    41104120
    4111 #endif
     4121#endif // HAVE(LINK_PREVIEW)
    41124122
    41134123// UITextRange, UITextPosition and UITextSelectionRect implementations for WK2
  • trunk/Source/WebKit2/UIProcess/ios/forms/WKFormSelectControl.h

    r199960 r204525  
    4040@end
    4141
     42@interface WKFormSelectControl(WKTesting)
     43- (void)selectRow:(NSInteger)rowIndex inComponent:(NSInteger)componentIndex extendingSelection:(BOOL)extendingSelection;
     44@end
     45
    4246@interface WKSelectPopover : WKFormRotatingAccessoryPopover<WKFormControl>
    4347- (instancetype)initWithView:(WKContentView *)view hasGroups:(BOOL)hasGroups;
     
    5357@end
    5458
     59@protocol WKSelectTesting
     60@optional
     61- (void)selectRow:(NSInteger)rowIndex inComponent:(NSInteger)componentIndex extendingSelection:(BOOL)extendingSelection;
     62@end
     63
    5564#endif // PLATFORM(IOS)
    5665
  • trunk/Source/WebKit2/UIProcess/ios/forms/WKFormSelectControl.mm

    r199960 r204525  
    5959
    6060@implementation WKFormSelectControl {
    61     RetainPtr<id<WKFormControl>> _control;
     61    RetainPtr<NSObject<WKFormControl>> _control;
    6262}
    6363
     
    102102@end
    103103
     104@implementation WKFormSelectControl(WKTesting)
     105
     106- (void)selectRow:(NSInteger)rowIndex inComponent:(NSInteger)componentIndex extendingSelection:(BOOL)extendingSelection
     107{
     108    if ([_control respondsToSelector:@selector(selectRow:inComponent:extendingSelection:)])
     109        [id<WKSelectTesting>(_control.get()) selectRow:rowIndex inComponent:componentIndex extendingSelection:extendingSelection];
     110}
     111
     112@end
     113
    104114#endif  // PLATFORM(IOS)
  • trunk/Source/WebKit2/UIProcess/ios/forms/WKFormSelectPicker.mm

    r204466 r204525  
    304304}
    305305
     306// WKSelectTesting
     307- (void)selectRow:(NSInteger)rowIndex inComponent:(NSInteger)componentIndex extendingSelection:(BOOL)extendingSelection
     308{
     309    // FIXME: handle extendingSelection.
     310    [self selectRow:rowIndex inComponent:0 animated:NO];
     311    // Progammatic selection changes don't call the delegate, so do that manually.
     312    [self.delegate pickerView:self didSelectRow:rowIndex inComponent:0];
     313}
     314
    306315@end
    307316
     
    431440}
    432441
     442// WKSelectTesting
     443- (void)selectRow:(NSInteger)rowIndex inComponent:(NSInteger)componentIndex extendingSelection:(BOOL)extendingSelection
     444{
     445    // FIXME: handle extendingSelection.
     446    [self selectRow:rowIndex inComponent:0 animated:NO];
     447    // Progammatic selection changes don't call the delegate, so do that manually.
     448    [self.delegate pickerView:self didSelectRow:rowIndex inComponent:0];
     449}
     450
    433451@end
    434452
  • trunk/Source/WebKit2/UIProcess/ios/forms/WKFormSelectPopover.mm

    r200910 r204525  
    449449@end
    450450
     451@implementation WKSelectPopover(WKTesting)
     452
     453- (void)selectRow:(NSInteger)rowIndex inComponent:(NSInteger)componentIndex extendingSelection:(BOOL)extendingSelection
     454{
     455    NSIndexPath *indexPath = [NSIndexPath indexPathForRow:rowIndex inSection:componentIndex];
     456    [[_tableViewController tableView] selectRowAtIndexPath:indexPath animated:NO scrollPosition:UITableViewScrollPositionMiddle];
     457    // Inform the delegate, since -selectRowAtIndexPath:... doesn't do that.
     458    [_tableViewController tableView:[_tableViewController tableView] didSelectRowAtIndexPath:indexPath];
     459}
     460
     461@end
     462
    451463#endif  // PLATFORM(IOS)
  • trunk/Tools/ChangeLog

    r204523 r204525  
     12016-08-16  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Make it possible to test iOS select elements, and add iPhone and iPad tests for them
     4        https://bugs.webkit.org/show_bug.cgi?id=160909
     5
     6        Reviewed by Enrica Casucci.
     7       
     8        Add functions to UIScriptController to dismiss the form accessory view for iOS,
     9        and to programmatically pick a row from a <select> picker.
     10
     11        * WebKitTestRunner/UIScriptContext/Bindings/UIScriptController.idl:
     12        * WebKitTestRunner/UIScriptContext/UIScriptController.cpp:
     13        (WTR::UIScriptController::dismissFormAccessoryView):
     14        (WTR::UIScriptController::selectFormAccessoryPickerRow):
     15        * WebKitTestRunner/UIScriptContext/UIScriptController.h:
     16        * WebKitTestRunner/ios/UIScriptControllerIOS.mm:
     17        (WTR::UIScriptController::dismissFormAccessoryView):
     18        (WTR::UIScriptController::selectFormAccessoryPickerRow):
     19
    1202016-08-15  Simon Fraser  <simon.fraser@apple.com>
    221
  • trunk/Tools/WebKitTestRunner/UIScriptContext/Bindings/UIScriptController.idl

    r204523 r204525  
    4343    void keyUpUsingHardwareKeyboard(DOMString character, object callback);
    4444
     45    // Equivalent of pressing the Done button in the form accessory bar.
     46    void dismissFormAccessoryView();
     47
     48    // <select> picker
     49    void selectFormAccessoryPickerRow(long rowIndex);
     50
    4551    void keyboardAccessoryBarNext();
    4652    void keyboardAccessoryBarPrevious();
    4753
     54    // These callbacks also work for the form accessory views.
    4855    attribute object didShowKeyboardCallback;
    4956    attribute object didHideKeyboardCallback;
  • trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.cpp

    r204523 r204525  
    151151}
    152152
     153void UIScriptController::dismissFormAccessoryView()
     154{
     155}
     156
     157void UIScriptController::selectFormAccessoryPickerRow(long)
     158{
     159}
     160
    153161void UIScriptController::keyboardAccessoryBarNext()
    154162{
  • trunk/Tools/WebKitTestRunner/UIScriptContext/UIScriptController.h

    r204523 r204525  
    6060    void keyboardAccessoryBarNext();
    6161    void keyboardAccessoryBarPrevious();
     62   
     63    void dismissFormAccessoryView();
     64    void selectFormAccessoryPickerRow(long);
    6265
    6366    void setWillBeginZoomingCallback(JSValueRef);
  • trunk/Tools/WebKitTestRunner/ios/UIScriptControllerIOS.mm

    r204523 r204525  
    176176}
    177177
     178void UIScriptController::dismissFormAccessoryView()
     179{
     180    TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
     181    [webView dismissFormAccessoryView];
     182}
     183
     184void UIScriptController::selectFormAccessoryPickerRow(long rowIndex)
     185{
     186    TestRunnerWKWebView *webView = TestController::singleton().mainWebView()->platformView();
     187    [webView selectFormAccessoryPickerRow:rowIndex];
     188}
     189
    178190void UIScriptController::keyboardAccessoryBarNext()
    179191{
Note: See TracChangeset for help on using the changeset viewer.