@@ -125,6 +125,9 @@ @interface FlutterEmbedderKeyResponder (Tests)
125
125
@end
126
126
127
127
@interface FlutterViewController (Tests)
128
+
129
+ @property (nonatomic , assign ) double targetViewInsetBottom;
130
+
128
131
- (void )surfaceUpdated : (BOOL )appeared ;
129
132
- (void )performOrientationUpdate : (UIInterfaceOrientationMask)new_preferences ;
130
133
- (void )handlePressEvent : (FlutterUIPressProxy*)press
@@ -135,6 +138,7 @@ - (void)onUserSettingsChanged:(NSNotification*)notification;
135
138
- (void )applicationWillTerminate : (NSNotification *)notification ;
136
139
- (void )goToApplicationLifecycle : (nonnull NSString *)state ;
137
140
- (void )keyboardWillChangeFrame : (NSNotification *)notification ;
141
+ - (void )keyboardWillBeHidden : (NSNotification *)notification ;
138
142
- (void )startKeyBoardAnimation : (NSTimeInterval )duration ;
139
143
- (void )ensureViewportMetricsIsCorrect ;
140
144
- (void )invalidateDisplayLink ;
@@ -198,6 +202,30 @@ - (void)testkeyboardWillChangeFrameWillStartKeyboardAnimation {
198
202
[self waitForExpectationsWithTimeout: 5.0 handler: nil ];
199
203
}
200
204
205
+ - (void )testEnsureBottomInsetIsZeroWhenKeyboardDismissed {
206
+ FlutterEngine* mockEngine = OCMPartialMock ([[FlutterEngine alloc ] init ]);
207
+ [mockEngine createShell: @" " libraryURI: @" " initialRoute: nil ];
208
+ FlutterViewController* viewController = [[FlutterViewController alloc ] initWithEngine: mockEngine
209
+ nibName: nil
210
+ bundle: nil ];
211
+
212
+ FlutterViewController* viewControllerMock = OCMPartialMock (viewController);
213
+ CGRect keyboardFrame = CGRectMake (0 , 0 , 0 , 0 );
214
+ BOOL isLocal = YES ;
215
+ NSNotification * fakeNotification = [NSNotification
216
+ notificationWithName: @" "
217
+ object: nil
218
+ userInfo: @{
219
+ @" UIKeyboardFrameEndUserInfoKey" : [NSValue valueWithCGRect: keyboardFrame],
220
+ @" UIKeyboardAnimationDurationUserInfoKey" : @(0.25 ),
221
+ @" UIKeyboardIsLocalUserInfoKey" : @(isLocal)
222
+ }];
223
+
224
+ viewControllerMock.targetViewInsetBottom = 10 ;
225
+ [viewControllerMock keyboardWillBeHidden: fakeNotification];
226
+ XCTAssertTrue (viewControllerMock.targetViewInsetBottom == 0 );
227
+ }
228
+
201
229
- (void )testEnsureViewportMetricsWillInvokeAndDisplayLinkWillInvalidateInViewDidDisappear {
202
230
FlutterEngine* mockEngine = OCMPartialMock ([[FlutterEngine alloc ] init ]);
203
231
[mockEngine createShell: @" " libraryURI: @" " initialRoute: nil ];
0 commit comments