haikuwebkit/LayoutTests/contact-picker/contacts-select-expected.txt

20 lines
730 B
Plaintext
Raw Permalink Normal View History

[Contact Picker API] Add support for picker UI on iOS https://bugs.webkit.org/show_bug.cgi?id=218189 <rdar://problem/69862277> Reviewed by Devin Rousso. Source/WebKit: ContactsManager.select() should present a contact picker on platforms which support one. This patch enables the end-to-end functionality on iOS, presenting a contact picker upon a call to the API and returning the selected contacts upon dismissal. Tests: contact-picker/contacts-select-after-dismissing-picker.html contact-picker/contacts-select-while-presenting-picker.html contact-picker/contacts-select.html * Platform/spi/Cocoa/ContactsUISPI.h: Added. * SourcesCocoa.txt: * UIProcess/API/Cocoa/WKWebViewPrivateForTesting.h: * UIProcess/API/Cocoa/WKWebViewTesting.mm: (-[WKWebView _didPresentContactPicker]): (-[WKWebView _didDismissContactPicker]): (-[WKWebView _dismissContactPickerWithContacts:]): * UIProcess/Cocoa/WKContactPicker.h: Added. * UIProcess/Cocoa/WKContactPicker.mm: Added. WKContactPicker is a WebKit wrapper around CNContactPickerViewController. (-[WKCNContactPickerDelegate initWithContactPickerDelegate:]): WKCNContactPickerDelegate is wrapper around CNContactPickerDelegate. This is necessary as single/multiple selection in a CNContactPickerViewController is determined by which delegate methods are implemented. The two specializations of this class include the methods necessary to present a single-select and multi-select picker respectively. (-[WKCNContactPickerDelegate contactPickerDidCancel:]): (-[WKCNContactPickerSingleSelectDelegate contactPicker:didSelectContact:]): (-[WKCNContactPickerMultiSelectDelegate contactPicker:didSelectContacts:]): (-[WKContactPicker delegate]): (-[WKContactPicker setDelegate:]): (-[WKContactPicker initWithView:]): (-[WKContactPicker presentWithRequestData:completionHandler:]): (-[WKContactPicker contactPickerDidCancel:]): This delegate method is called when the picker is dismissed by tapping the done button or when the picker is dismissed by swiping down. (-[WKContactPicker contactPicker:didSelectContact:]): (-[WKContactPicker contactPicker:didSelectContacts:]): (-[WKContactPicker _contactPickerDidDismissWithContactInfo:]): (-[WKContactPicker _contactInfoFromCNContact:]): (-[WKContactPicker dismissWithContacts:]): (-[WKContactPicker _contactsFromJSContacts:]): * UIProcess/ios/PageClientImplIOS.h: * UIProcess/ios/PageClientImplIOS.mm: (WebKit::PageClientImpl::showContactPicker): * UIProcess/ios/WKContentViewInteraction.h: * UIProcess/ios/WKContentViewInteraction.mm: (-[WKContentView _showContactPicker:completionHandler:]): (-[WKContentView contactPickerDidPresent:]): (-[WKContentView contactPickerDidDismiss:]): (-[WKContentView _dismissContactPickerWithContacts:]): * WebKit.xcodeproj/project.pbxproj: Source/WTF: * wtf/PlatformHave.h: Added HAVE(CONTACTSUI) and HAVE(CNCONTACTPICKERVIEWCONTROLLER) macros. Tools: Added UIScriptController hooks to observe the presentation and dismissal of a contact picker. Furthermore, the dismissContactPickerWithContacts method was added to allow tests to dismiss the presented contact picker with a set of selected contacts. * TestRunnerShared/UIScriptContext/Bindings/UIScriptController.idl: * TestRunnerShared/UIScriptContext/UIScriptContext.h: * TestRunnerShared/UIScriptContext/UIScriptController.h: (WTR::UIScriptController::isShowingContactPicker const): (WTR::UIScriptController::dismissContactPickerWithContacts): * TestRunnerShared/UIScriptContext/UIScriptControllerShared.cpp: (WTR::UIScriptController::setDidShowContactPickerCallback): (WTR::UIScriptController::didShowContactPickerCallback const): (WTR::UIScriptController::setDidHideContactPickerCallback): (WTR::UIScriptController::didHideContactPickerCallback const): * WebKitTestRunner/cocoa/TestRunnerWKWebView.h: * WebKitTestRunner/cocoa/TestRunnerWKWebView.mm: (-[TestRunnerWKWebView resetInteractionCallbacks]): (-[TestRunnerWKWebView _didPresentContactPicker]): (-[TestRunnerWKWebView _didDismissContactPicker]): * WebKitTestRunner/cocoa/UIScriptControllerCocoa.h: * WebKitTestRunner/cocoa/UIScriptControllerCocoa.mm: (WTR::UIScriptControllerCocoa::setDidShowContactPickerCallback): (WTR::UIScriptControllerCocoa::setDidHideContactPickerCallback): (WTR::UIScriptControllerCocoa::isShowingContactPicker const): (WTR::UIScriptControllerCocoa::dismissContactPickerWithContacts): LayoutTests: Added tests to verify the presentation and dismissal of a contact picker on iOS. The new tests are only run on iOS WK2, since that is the only platform which currently supports the presentation of a contact picker. Note that these tests will be enabled on macOS WK2 once support is added in a forthcoming patch. * TestExpectations: * contact-picker/contacts-select-after-dismissing-picker-expected.txt: Added. * contact-picker/contacts-select-after-dismissing-picker.html: Added. * contact-picker/contacts-select-expected.txt: Added. * contact-picker/contacts-select-while-presenting-picker-expected.txt: Added. * contact-picker/contacts-select-while-presenting-picker.html: Added. * contact-picker/contacts-select.html: Added. * platform/ios-wk2/TestExpectations: * resources/ui-helper.js: (window.UIHelper.waitForContactPickerToShow): (window.UIHelper.waitForContactPickerToHide): (window.UIHelper.dismissContactPickerWithContacts): Canonical link: https://commits.webkit.org/231232@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@269394 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-11-04 22:36:46 +00:00
This test verifies that navigator.contacts.select presents a contact picker and returns the selected contacts.
On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
PASS contacts.length is 3
PASS areArraysEqual(contact1.name, addressBook[0].name) is true
PASS areArraysEqual(contact1.email, addressBook[0].email) is true
PASS contact1.tel.length is 0
PASS areArraysEqual(contact2.name, addressBook[1].name) is true
PASS areArraysEqual(contact2.email, addressBook[1].email) is true
PASS contact2.tel.length is 0
PASS areArraysEqual(contact3.name, addressBook[2].name) is true
PASS contact3.email.length is 0
PASS contact3.tel.length is 0
PASS successfullyParsed is true
TEST COMPLETE
Show contacts