Skip to content

Commit

Permalink
[iOSTextInput] remove floating cursor asserts (flutter#28868)
Browse files Browse the repository at this point in the history
  • Loading branch information
LongCatIsLooong authored Sep 27, 2021
1 parent 778ae9f commit c55c8f2
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1368,24 +1368,20 @@ - (void)beginFloatingCursorAtPoint:(CGPoint)point {
// It seems impossible to use a negative "width" or "height", as the "convertRect"
// call always turns a CGRect's negative dimensions into non-negative values, e.g.,
// (1, 2, -3, -4) would become (-2, -2, 3, 4).
NSAssert(!_isFloatingCursorActive, @"Another floating cursor is currently active.");
_isFloatingCursorActive = true;
[self.textInputDelegate updateFloatingCursor:FlutterFloatingCursorDragStateStart
withClient:_textInputClient
withPosition:@{@"X" : @(point.x), @"Y" : @(point.y)}];
}

- (void)updateFloatingCursorAtPoint:(CGPoint)point {
NSAssert(_isFloatingCursorActive,
@"updateFloatingCursorAtPoint is called without an active floating cursor.");
_isFloatingCursorActive = true;
[self.textInputDelegate updateFloatingCursor:FlutterFloatingCursorDragStateUpdate
withClient:_textInputClient
withPosition:@{@"X" : @(point.x), @"Y" : @(point.y)}];
}

- (void)endFloatingCursor {
NSAssert(_isFloatingCursorActive,
@"endFloatingCursor is called without an active floating cursor.");
_isFloatingCursorActive = false;
[self.textInputDelegate updateFloatingCursor:FlutterFloatingCursorDragStateEnd
withClient:_textInputClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -825,6 +825,16 @@ - (void)testInputViewsHaveUIInteractions {
}
}

- (void)testFloatingCursorDoesNotThrow {
// The keyboard implementation may send unbalanced calls to the input view.
FlutterTextInputView* inputView = [[FlutterTextInputView alloc] init];
[inputView beginFloatingCursorAtPoint:CGPointMake(123, 321)];
[inputView beginFloatingCursorAtPoint:CGPointMake(123, 321)];
[inputView endFloatingCursor];
[inputView beginFloatingCursorAtPoint:CGPointMake(123, 321)];
[inputView endFloatingCursor];
}

- (void)testBoundsForFloatingCursor {
FlutterTextInputView* inputView = [[FlutterTextInputView alloc] init];

Expand Down

0 comments on commit c55c8f2

Please sign in to comment.