-
Notifications
You must be signed in to change notification settings - Fork 6k
[iOSTextInputPlugin] bypass UIKit floating cursor coordinates clamping #26486
Changes from 3 commits
761aebc
d19cb61
39e8eaa
b13caac
fa1e498
659e74a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -79,7 +79,6 @@ - (void)setUp { | |
| } | ||
|
|
||
| - (void)tearDown { | ||
| [engine stopMocking]; | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This line caused all the tests in the file to fail. Did we upgrade ocmock or something?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nope we didn't. You shouldn't remove this line. The tests are running as part of CI so we know this works before the changes here. Let me know what errors you are getting and I can try to help.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I put it back it starts failing again: https://logs.chromium.org/logs/flutter/buildbucket/cr-buildbucket.appspot.com/8845604182114825824/+/u/Host_Tests_for_ios_debug_sim/stdout
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This means you are leaking an object beyond your test that is talking to the mock engine, probably a view controller. Let me look at your test code to see if I can spot it. (this can cause other tests to fail beyond yours)
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Looks like your test is fine. One of 2 things are happening:
Here's an example where I had to fix similar issues: I'd try running that test / writing one similar to make sure that the view controller is being deleted. If you run that one test and it fails, you'll know you introduced a leak. Otherwise tracking down the timing issue will take a bit more work.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Turns out UIKit is keeping some of the input views alive and modifying the content of these views even they're removed from the view hierarchy. #26547 |
||
| [[[[textInputPlugin textInputView] superview] subviews] | ||
| makeObjectsPerformSelector:@selector(removeFromSuperview)]; | ||
|
|
||
|
|
@@ -498,6 +497,53 @@ - (void)testUpdateFirstRectForRange { | |
| XCTAssertTrue(CGRectEqualToRect(kInvalidFirstRect, [inputView firstRectForRange:range])); | ||
| } | ||
|
|
||
| #pragma mark - Floating Cursor - Tests | ||
|
|
||
| - (void)testInputViewsHaveUIInteractions { | ||
| if (@available(iOS 13.0, *)) { | ||
| FlutterTextInputView* inputView = [[FlutterTextInputView alloc] init]; | ||
| XCTAssertGreaterThan(inputView.interactions.count, 0); | ||
| } | ||
| } | ||
|
|
||
| - (void)testBoundsForFloatingCursor { | ||
| FlutterTextInputView* inputView = [[FlutterTextInputView alloc] init]; | ||
|
|
||
| CGRect initialBounds = inputView.bounds; | ||
| // Make sure the initial bounds.size is not as large. | ||
| XCTAssertLessThan(inputView.bounds.size.width, 100); | ||
| XCTAssertLessThan(inputView.bounds.size.height, 100); | ||
|
|
||
| [inputView beginFloatingCursorAtPoint:CGPointMake(123, 321)]; | ||
| CGRect bounds = inputView.bounds; | ||
| XCTAssertGreaterThan(bounds.size.width, 1000); | ||
| XCTAssertGreaterThan(bounds.size.height, 1000); | ||
|
|
||
| // Verify the caret is centered. | ||
| XCTAssertEqual( | ||
| CGRectGetMidX(bounds), | ||
| CGRectGetMidX([inputView caretRectForPosition:[FlutterTextPosition positionWithIndex:1235]])); | ||
| XCTAssertEqual( | ||
| CGRectGetMidY(bounds), | ||
| CGRectGetMidY([inputView caretRectForPosition:[FlutterTextPosition positionWithIndex:4567]])); | ||
|
|
||
| [inputView updateFloatingCursorAtPoint:CGPointMake(456, 654)]; | ||
| bounds = inputView.bounds; | ||
| XCTAssertGreaterThan(bounds.size.width, 1000); | ||
| XCTAssertGreaterThan(bounds.size.height, 1000); | ||
|
|
||
| // Verify the caret is centered. | ||
| XCTAssertEqual( | ||
| CGRectGetMidX(bounds), | ||
| CGRectGetMidX([inputView caretRectForPosition:[FlutterTextPosition positionWithIndex:21]])); | ||
| XCTAssertEqual( | ||
| CGRectGetMidY(bounds), | ||
| CGRectGetMidY([inputView caretRectForPosition:[FlutterTextPosition positionWithIndex:42]])); | ||
|
|
||
| [inputView endFloatingCursor]; | ||
| XCTAssertTrue(CGRectEqualToRect(initialBounds, inputView.bounds)); | ||
| } | ||
|
|
||
| #pragma mark - Autofill - Utilities | ||
|
|
||
| - (NSMutableDictionary*)mutablePasswordTemplateCopy { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested on an iOS 12 simulator and couldn't reproduce the issue.