[iOS] Fix:Keyboard inset is not correct when presenting a native ViewController on FlutterViewController#29862
[iOS] Fix:Keyboard inset is not correct when presenting a native ViewController on FlutterViewController#29862jmagman merged 2 commits intoflutter:mainfrom luckysmg:keyboard_anim_fix
Conversation
…ewController on FlutterViewController
|
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact Hixie on the #hackers channel in Chat. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
| } | ||
| if (finished) { |
There was a problem hiding this comment.
Yep, this looks like a good change to me. This will be tricky to write a test for.
There was a problem hiding this comment.
This will definitely be tricky to test. I don't love the partial mocks we use for this now since we're not really testing the behavior, but that the code is being executed in the right order
This doesn't really test that the change is fixed, but you could add an expectation/verification that the engine -updateViewportMetrics: is called after startKeyBoardAnimation.
There was a problem hiding this comment.
This test passed on this diff and fails on main:
}];
+
+ XCTestExpectation* expectation = [self expectationWithDescription:@"update viewport"];
+ OCMStub([mockEngine updateViewportMetrics:flutter::ViewportMetrics()])
+ .ignoringNonObjectArgs()
+ .andDo(^(NSInvocation* invocation) {
+ [expectation fulfill];
+ });
id viewControllerMock = OCMPartialMock(viewController);
[viewControllerMock keyboardWillChangeFrame:notification];
OCMVerify([viewControllerMock startKeyBoardAnimation:0.25]);
+ [self waitForExpectationsWithTimeout:5.0 handler:nil];There was a problem hiding this comment.
I took the liberty of pushing this test to your fork since this bug fix is blocking an internal release. Hope you don't mind. 🙂
jmagman
left a comment
There was a problem hiding this comment.
Code LGTM, I think we can add a verification that the viewPort metrics are updated after startKeyBoardAnimation.
| @@ -1200,9 +1200,10 @@ - (void)startKeyBoardAnimation:(NSTimeInterval)duration { | |||
| } | |||
| completion:^(BOOL finished) { | |||
There was a problem hiding this comment.
finished may be false here because the keyboardAnimationView with the animation was removed from the superView before the animation was completed? Not sure though.
| // Indicates the displaylink captured by this block is the original one,which also | ||
| // indicates the animation has not been interrupted from its beginning. Moreover,indicates | ||
| // the animation is over and there is no more animation about to exectute. |
There was a problem hiding this comment.
| // Indicates the displaylink captured by this block is the original one,which also | |
| // indicates the animation has not been interrupted from its beginning. Moreover,indicates | |
| // the animation is over and there is no more animation about to exectute. | |
| // Indicates the displayLink captured by this block is the original one, which also | |
| // indicates the animation has not been interrupted. Moreover, indicates | |
| // the animation is over and there is no more to execute. |
| } | ||
| if (finished) { |
There was a problem hiding this comment.
This will definitely be tricky to test. I don't love the partial mocks we use for this now since we're not really testing the behavior, but that the code is being executed in the right order
This doesn't really test that the change is fixed, but you could add an expectation/verification that the engine -updateViewportMetrics: is called after startKeyBoardAnimation.
| @"UIKeyboardIsLocalUserInfoKey" : [NSNumber numberWithBool:isLocal] | ||
| }]; | ||
|
|
||
| XCTestExpectation* expectation = [self expectationWithDescription:@"update viewport"]; |
There was a problem hiding this comment.
@gaaclarke would you mind reviewing this test change? I just added it.
|
@luckysmg Thanks for fixing this so quickly. I'm going to merge this, if you have any code changes to the test I wrote please let me know and we can discuss in a follow-up commit. Merging. |
…ative ViewController on FlutterViewController (flutter/engine#29862)
…ative ViewController on FlutterViewController (flutter/engine#29862)
…ewController on FlutterViewController (flutter#29862)
…ewController on FlutterViewController (flutter#29862)
Before:
before.mov
After:
After.mov
List which issues are fixed by this PR. You must list at least one issue.
flutter/flutter#93944
Pre-launch Checklist
writing and running engine tests.
///).If you need help, consider asking for advice on the #hackers-new channel on [Discord].