Fix iOS TestWebKitAPI failures following <https://trac.webkit.org/changeset/236619>
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Oct 2018 19:42:25 +0000 (19:42 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 2 Oct 2018 19:42:25 +0000 (19:42 +0000)
(https://bugs.webkit.org/show_bug.cgi?id=190017)

For now swizzle +[UIKeyboard isInHardwareKeyboardMode] to return NO in the following tests:
    WKWebViewAutofillTests.AutofillRequiresInputSession
    DragAndDropTests.ExternalSourceJPEGOnly
    DragAndDropTests.ExternalSourceUTF8PlainTextOnly

so that the presence of a hardware keyboad does not effect their results. In <https://bugs.webkit.org/show_bug.cgi?id=190211>
we will look to swizzle this method for all test by default.

* TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm:
(TestWebKitAPI::overrideIsInHardwareKeyboardMode):
(TestWebKitAPI::TEST):
* TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm:
(TestWebKitAPI::overrideIsInHardwareKeyboardMode):
(TestWebKitAPI::TEST):
* TestWebKitAPI/ios/UIKitSPI.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236761 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm
Tools/TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm
Tools/TestWebKitAPI/ios/UIKitSPI.h

index fe2eca8..ce638ed 100644 (file)
@@ -1,3 +1,24 @@
+2018-10-02  Daniel Bates  <dabates@apple.com>
+
+        Fix iOS TestWebKitAPI failures following <https://trac.webkit.org/changeset/236619>
+        (https://bugs.webkit.org/show_bug.cgi?id=190017)
+
+        For now swizzle +[UIKeyboard isInHardwareKeyboardMode] to return NO in the following tests:
+            WKWebViewAutofillTests.AutofillRequiresInputSession
+            DragAndDropTests.ExternalSourceJPEGOnly
+            DragAndDropTests.ExternalSourceUTF8PlainTextOnly
+
+        so that the presence of a hardware keyboad does not effect their results. In <https://bugs.webkit.org/show_bug.cgi?id=190211>
+        we will look to swizzle this method for all test by default.
+
+        * TestWebKitAPI/Tests/ios/DragAndDropTestsIOS.mm:
+        (TestWebKitAPI::overrideIsInHardwareKeyboardMode):
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/Tests/ios/WKWebViewAutofillTests.mm:
+        (TestWebKitAPI::overrideIsInHardwareKeyboardMode):
+        (TestWebKitAPI::TEST):
+        * TestWebKitAPI/ios/UIKitSPI.h:
+
 2018-10-02  Dawei Fenton  <realdawei@apple.com>
 
         Unreviewed, rolling out r236751.
index 386d93b..6ac440a 100644 (file)
@@ -27,6 +27,7 @@
 
 #if ENABLE(DRAG_SUPPORT) && PLATFORM(IOS) && WK_API_ENABLED
 
+#import "ClassMethodSwizzler.h"
 #import "DragAndDropSimulator.h"
 #import "PlatformUtilities.h"
 #import "TestWKWebView.h"
@@ -907,8 +908,15 @@ TEST(DragAndDropTests, RespectsExternalSourceFidelityRankings)
     EXPECT_TRUE([webView editorContainsImageElement]);
 }
 
+static BOOL overrideIsInHardwareKeyboardMode()
+{
+    return NO;
+}
+
 TEST(DragAndDropTests, ExternalSourceUTF8PlainTextOnly)
 {
+    ClassMethodSwizzler swizzler([UIKeyboard class], @selector(isInHardwareKeyboardMode), reinterpret_cast<IMP>(overrideIsInHardwareKeyboardMode));
+
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
     [webView synchronouslyLoadTestPageNamed:@"autofocus-contenteditable"];
 
@@ -928,6 +936,8 @@ TEST(DragAndDropTests, ExternalSourceUTF8PlainTextOnly)
 
 TEST(DragAndDropTests, ExternalSourceJPEGOnly)
 {
+    ClassMethodSwizzler swizzler([UIKeyboard class], @selector(isInHardwareKeyboardMode), reinterpret_cast<IMP>(overrideIsInHardwareKeyboardMode));
+
     auto webView = adoptNS([[TestWKWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
     [webView synchronouslyLoadTestPageNamed:@"autofocus-contenteditable"];
 
index fa6b1cd..61e3210 100644 (file)
@@ -27,6 +27,7 @@
 
 #if WK_API_ENABLED && PLATFORM(IOS)
 
+#import "ClassMethodSwizzler.h"
 #import "PlatformUtilities.h"
 #import "TestInputDelegate.h"
 #import "TestWKWebView.h"
@@ -164,8 +165,15 @@ TEST(WKWebViewAutofillTests, AccountCreationPage)
     EXPECT_FALSE([webView textInputHasAutofillContext]);
 }
 
+static BOOL overrideIsInHardwareKeyboardMode()
+{
+    return NO;
+}
+
 TEST(WKWebViewAutofillTests, AutofillRequiresInputSession)
 {
+    ClassMethodSwizzler swizzler([UIKeyboard class], @selector(isInHardwareKeyboardMode), reinterpret_cast<IMP>(overrideIsInHardwareKeyboardMode));
+
     auto webView = adoptNS([[AutofillTestView alloc] initWithFrame:CGRectMake(0, 0, 320, 500)]);
     [(TestInputDelegate *)[webView _inputDelegate] setFocusStartsInputSessionPolicyHandler:[] (WKWebView *, id <_WKFocusedElementInfo>) -> _WKFocusStartsInputSessionPolicy {
         return _WKFocusStartsInputSessionPolicyAuto;
index 6bd3cb6..63f252e 100644 (file)
@@ -30,6 +30,7 @@
 #if USE(APPLE_INTERNAL_SDK)
 
 #import <UIKit/UIApplication_Private.h>
+#import <UIKit/UIKeyboard_Private.h>
 #import <UIKit/UIResponder_Private.h>
 #import <UIKit/UITextInputMultiDocument.h>
 #import <UIKit/UITextInputTraits_Private.h>
@@ -122,6 +123,9 @@ WTF_EXTERN_C_END
 
 #endif
 
+@interface UIKeyboard : UIView
+@end
+
 #endif
 
 @protocol UITextInputTraits_Private_Proposed_SPI_34583628 <UITextInputPrivate>
@@ -160,4 +164,8 @@ WTF_EXTERN_C_END
 - (UIResponder *)firstResponder;
 @end
 
+@interface UIKeyboard ()
++ (BOOL)isInHardwareKeyboardMode;
+@end
+
 #endif // PLATFORM(IOS)