@@ -305,6 +305,18 @@ - (void)testKeyboardAnimationIsShowingAndCompounding {
305305 FlutterViewController* viewController = [[FlutterViewController alloc ] initWithEngine: engine
306306 nibName: nil
307307 bundle: nil ];
308+ FlutterMethodCall* setClientCall =
309+ [FlutterMethodCall methodCallWithMethodName: @" TextInput.setClient"
310+ arguments: @[ @(123 ), @{@" autocorrect" : @YES } ]];
311+ [engine.textInputPlugin handleMethodCall: setClientCall
312+ result: ^(id _Nullable result){
313+ }];
314+
315+ // Check if FlutterTextInputViewAccessibilityHider exist.
316+ FlutterTextInputPlugin* textInputPlugin = engine.textInputPlugin ;
317+ UIView* textInputHider = [[textInputPlugin textInputView ] superview ];
318+ XCTAssertNotNil (textInputHider);
319+
308320 FlutterViewController* viewControllerMock = OCMPartialMock (viewController);
309321 UIScreen* screen = [self setUpMockScreen ];
310322 CGRect viewFrame = screen.bounds ;
@@ -2188,4 +2200,46 @@ - (void)testFlutterViewControllerStartKeyboardAnimationWillCreateVsyncClientCorr
21882200 XCTAssertNil (viewController.keyboardAnimationVSyncClient );
21892201}
21902202
2203+ - (void )testAvoidKeyboardAnimationWhenFlutterTextInputViewAccessibilityHiderIsNil {
2204+ FlutterEngine* engine = [[FlutterEngine alloc ] init ];
2205+ [engine runWithEntrypoint: nil ];
2206+ FlutterViewController* viewController = [[FlutterViewController alloc ] initWithEngine: engine
2207+ nibName: nil
2208+ bundle: nil ];
2209+
2210+ FlutterViewController* viewControllerMock = OCMPartialMock (viewController);
2211+ UIScreen* screen = [self setUpMockScreen ];
2212+ CGRect viewFrame = screen.bounds ;
2213+ [self setUpMockView: viewControllerMock
2214+ screen: screen
2215+ viewFrame: viewFrame
2216+ convertedFrame: viewFrame];
2217+
2218+ CGFloat screenHeight = screen.bounds .size .height ;
2219+ CGFloat screenWidth = screen.bounds .size .height ;
2220+
2221+ // Check if FlutterTextInputViewAccessibilityHider is nil.
2222+ FlutterTextInputPlugin* textInputPlugin = engine.textInputPlugin ;
2223+ UIView* textInputHider = [[textInputPlugin textInputView ] superview ];
2224+ XCTAssertNil (textInputHider);
2225+
2226+ // Start show keyboard animation.
2227+ CGRect showKeyboardBeginFrame = CGRectMake (0 , screenHeight, screenWidth, 250 );
2228+ CGRect showKeyboardEndFrame = CGRectMake (0 , screenHeight - 250 , screenWidth, 250 );
2229+ NSNotification * fakeNotification =
2230+ [NSNotification notificationWithName: UIKeyboardWillChangeFrameNotification
2231+ object: nil
2232+ userInfo: @{
2233+ @" UIKeyboardFrameBeginUserInfoKey" : @(showKeyboardBeginFrame),
2234+ @" UIKeyboardFrameEndUserInfoKey" : @(showKeyboardEndFrame),
2235+ @" UIKeyboardAnimationDurationUserInfoKey" : @(0.25 ),
2236+ @" UIKeyboardIsLocalUserInfoKey" : @(YES )
2237+ }];
2238+
2239+ viewControllerMock.targetViewInsetBottom = 0 ;
2240+ [viewControllerMock handleKeyboardNotification: fakeNotification];
2241+ BOOL isShowingAnimation = viewControllerMock.keyboardAnimationIsShowing ;
2242+ XCTAssertFalse (isShowingAnimation);
2243+ }
2244+
21912245@end
0 commit comments