From d8149be3c363fd4d873b46136fd1af5ff0862ed4 Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Mon, 24 Oct 2022 10:19:01 -0700 Subject: [PATCH 1/4] Remove deprecated TextInputClient scribble method code --- .../ios/framework/Source/FlutterEngine.mm | 37 ------------------- .../Source/FlutterTextInputPlugin.mm | 10 ----- 2 files changed, 47 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm index 0ba83ef38090a..bb996706cb36e 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm @@ -975,10 +975,6 @@ - (void)flutterTextInputView:(FlutterTextInputView*)textInputView #pragma mark - FlutterViewEngineDelegate - (void)flutterTextInputView:(FlutterTextInputView*)textInputView showToolbar:(int)client { - // TODO(justinmc): Remove the TextInputClient usage when the framework has - // finished transitioning to using the Scribble channel. - // https://github.com/flutter/flutter/pull/104128 - [_textInputChannel.get() invokeMethod:@"TextInputClient.showToolbar" arguments:@[ @(client) ]]; [_scribbleChannel.get() invokeMethod:@"Scribble.showToolbar" arguments:@[ @(client) ]]; } @@ -986,13 +982,6 @@ - (void)flutterTextInputPlugin:(FlutterTextInputPlugin*)textInputPlugin focusElement:(UIScribbleElementIdentifier)elementIdentifier atPoint:(CGPoint)referencePoint result:(FlutterResult)callback { - // TODO(justinmc): Remove the TextInputClient usage when the framework has - // finished transitioning to using the Scribble channel. - // https://github.com/flutter/flutter/pull/104128 - [_textInputChannel.get() - invokeMethod:@"TextInputClient.focusElement" - arguments:@[ elementIdentifier, @(referencePoint.x), @(referencePoint.y) ] - result:callback]; [_scribbleChannel.get() invokeMethod:@"Scribble.focusElement" arguments:@[ elementIdentifier, @(referencePoint.x), @(referencePoint.y) ] @@ -1002,55 +991,29 @@ - (void)flutterTextInputPlugin:(FlutterTextInputPlugin*)textInputPlugin - (void)flutterTextInputPlugin:(FlutterTextInputPlugin*)textInputPlugin requestElementsInRect:(CGRect)rect result:(FlutterResult)callback { - // TODO(justinmc): Remove the TextInputClient usage when the framework has - // finished transitioning to using the Scribble channel. - // https://github.com/flutter/flutter/pull/104128 [_scribbleChannel.get() invokeMethod:@"Scribble.requestElementsInRect" arguments:@[ @(rect.origin.x), @(rect.origin.y), @(rect.size.width), @(rect.size.height) ] result:callback]; - [_textInputChannel.get() - invokeMethod:@"TextInputClient.requestElementsInRect" - arguments:@[ @(rect.origin.x), @(rect.origin.y), @(rect.size.width), @(rect.size.height) ] - result:callback]; } - (void)flutterTextInputViewScribbleInteractionBegan:(FlutterTextInputView*)textInputView { - // TODO(justinmc): Remove the TextInputClient usage when the framework has - // finished transitioning to using the Scribble channel. - // https://github.com/flutter/flutter/pull/104128 - [_textInputChannel.get() invokeMethod:@"TextInputClient.scribbleInteractionBegan" arguments:nil]; [_scribbleChannel.get() invokeMethod:@"Scribble.scribbleInteractionBegan" arguments:nil]; } - (void)flutterTextInputViewScribbleInteractionFinished:(FlutterTextInputView*)textInputView { - // TODO(justinmc): Remove the TextInputClient usage when the framework has - // finished transitioning to using the Scribble channel. - // https://github.com/flutter/flutter/pull/104128 - [_textInputChannel.get() invokeMethod:@"TextInputClient.scribbleInteractionFinished" - arguments:nil]; [_scribbleChannel.get() invokeMethod:@"Scribble.scribbleInteractionFinished" arguments:nil]; } - (void)flutterTextInputView:(FlutterTextInputView*)textInputView insertTextPlaceholderWithSize:(CGSize)size withClient:(int)client { - // TODO(justinmc): Remove the TextInputClient usage when the framework has - // finished transitioning to using the Scribble channel. - // https://github.com/flutter/flutter/pull/104128 - [_textInputChannel.get() invokeMethod:@"TextInputClient.insertTextPlaceholder" - arguments:@[ @(client), @(size.width), @(size.height) ]]; [_scribbleChannel.get() invokeMethod:@"Scribble.insertTextPlaceholder" arguments:@[ @(client), @(size.width), @(size.height) ]]; } - (void)flutterTextInputView:(FlutterTextInputView*)textInputView removeTextPlaceholder:(int)client { - // TODO(justinmc): Remove the TextInputClient usage when the framework has - // finished transitioning to using the Scribble channel. - // https://github.com/flutter/flutter/pull/104128 - [_textInputChannel.get() invokeMethod:@"TextInputClient.removeTextPlaceholder" - arguments:@[ @(client) ]]; [_scribbleChannel.get() invokeMethod:@"Scribble.removeTextPlaceholder" arguments:@[ @(client) ]]; } diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 4ecdc6845e73a..fc4230015cd26 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -48,10 +48,6 @@ @"TextInput.setEditableSizeAndTransform"; static NSString* const kSetMarkedTextRectMethod = @"TextInput.setMarkedTextRect"; static NSString* const kFinishAutofillContextMethod = @"TextInput.finishAutofillContext"; -// TODO(justinmc): Remove the TextInput method constant when the framework has -// finished transitioning to using the Scribble channel. -// https://github.com/flutter/flutter/pull/104128 -static NSString* const kDeprecatedSetSelectionRectsMethod = @"TextInput.setSelectionRects"; static NSString* const kSetSelectionRectsMethod = @"Scribble.setSelectionRects"; static NSString* const kStartLiveTextInputMethod = @"TextInput.startLiveTextInput"; @@ -2174,12 +2170,6 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result { } else if ([method isEqualToString:kFinishAutofillContextMethod]) { [self triggerAutofillSave:[args boolValue]]; result(nil); - // TODO(justinmc): Remove the TextInput method constant when the framework has - // finished transitioning to using the Scribble channel. - // https://github.com/flutter/flutter/pull/104128 - } else if ([method isEqualToString:kDeprecatedSetSelectionRectsMethod]) { - [self setSelectionRects:args]; - result(nil); } else if ([method isEqualToString:kSetSelectionRectsMethod]) { [self setSelectionRects:args]; result(nil); From ffcbbbea127c431ff3f286802ca5397f740d83d8 Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Mon, 24 Oct 2022 10:23:19 -0700 Subject: [PATCH 2/4] Test that old method doesnt work anymore --- .../Source/FlutterTextInputPluginTest.mm | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm index 462ea9e8359af..615c0190f54d8 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm @@ -1886,6 +1886,38 @@ - (void)testScribbleSetSelectionRects { XCTAssertEqual([textInputPlugin.activeView.selectionRects count], 1u); } +- (void)testScribbleSetSelectionRectsTICFails { + NSMutableDictionary* regularField = self.mutableTemplateCopy; + NSDictionary* editingValue = @{ + @"text" : @"REGULAR_TEXT_FIELD", + @"composingBase" : @0, + @"composingExtent" : @3, + @"selectionBase" : @1, + @"selectionExtent" : @4 + }; + [regularField setValue:@{ + @"uniqueIdentifier" : @"field1", + @"hints" : @[ @"hint2" ], + @"editingValue" : editingValue, + } + forKey:@"autofill"]; + [regularField addEntriesFromDictionary:editingValue]; + [self setClientId:123 configuration:regularField]; + XCTAssertEqual(self.installedInputViews.count, 1ul); + XCTAssertEqual([textInputPlugin.activeView.selectionRects count], 0u); + + NSArray* selectionRect = [NSArray arrayWithObjects:@0, @0, @100, @100, @0, nil]; + NSArray* selectionRects = [NSArray arrayWithObjects:selectionRect, nil]; + FlutterMethodCall* methodCall = + [FlutterMethodCall methodCallWithMethodName:@"TextInputClient.setSelectionRects" + arguments:selectionRects]; + XCTAssertThrows([textInputPlugin handleMethodCall:methodCall + result:^(id _Nullable result){ + }]); + + XCTAssertEqual([textInputPlugin.activeView.selectionRects count], 0u); +} + - (void)testDecommissionedViewAreNotReusedByAutofill { // Regression test for https://github.com/flutter/flutter/issues/84407. NSMutableDictionary* configuration = self.mutableTemplateCopy; From 3ba657cc38375747df048eb08137171f91b77102 Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Tue, 25 Oct 2022 10:22:17 -0700 Subject: [PATCH 3/4] Test shouldn't throw, but set result as unimplemented --- .../ios/framework/Source/FlutterTextInputPluginTest.mm | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm index 615c0190f54d8..45c1725a0a68f 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm @@ -1911,9 +1911,10 @@ - (void)testScribbleSetSelectionRectsTICFails { FlutterMethodCall* methodCall = [FlutterMethodCall methodCallWithMethodName:@"TextInputClient.setSelectionRects" arguments:selectionRects]; - XCTAssertThrows([textInputPlugin handleMethodCall:methodCall - result:^(id _Nullable result){ - }]); + [textInputPlugin handleMethodCall:methodCall + result:^(id _Nullable result) { + XCTAssertEqual(result, FlutterMethodNotImplemented); + }]; XCTAssertEqual([textInputPlugin.activeView.selectionRects count], 0u); } From 8dd34b99a7e10587839c340a2119e869bd20624a Mon Sep 17 00:00:00 2001 From: Justin McCandless Date: Thu, 27 Oct 2022 15:18:54 -0700 Subject: [PATCH 4/4] Remove test, doesn't add value --- .../Source/FlutterTextInputPluginTest.mm | 33 ------------------- 1 file changed, 33 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm index 45c1725a0a68f..462ea9e8359af 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm @@ -1886,39 +1886,6 @@ - (void)testScribbleSetSelectionRects { XCTAssertEqual([textInputPlugin.activeView.selectionRects count], 1u); } -- (void)testScribbleSetSelectionRectsTICFails { - NSMutableDictionary* regularField = self.mutableTemplateCopy; - NSDictionary* editingValue = @{ - @"text" : @"REGULAR_TEXT_FIELD", - @"composingBase" : @0, - @"composingExtent" : @3, - @"selectionBase" : @1, - @"selectionExtent" : @4 - }; - [regularField setValue:@{ - @"uniqueIdentifier" : @"field1", - @"hints" : @[ @"hint2" ], - @"editingValue" : editingValue, - } - forKey:@"autofill"]; - [regularField addEntriesFromDictionary:editingValue]; - [self setClientId:123 configuration:regularField]; - XCTAssertEqual(self.installedInputViews.count, 1ul); - XCTAssertEqual([textInputPlugin.activeView.selectionRects count], 0u); - - NSArray* selectionRect = [NSArray arrayWithObjects:@0, @0, @100, @100, @0, nil]; - NSArray* selectionRects = [NSArray arrayWithObjects:selectionRect, nil]; - FlutterMethodCall* methodCall = - [FlutterMethodCall methodCallWithMethodName:@"TextInputClient.setSelectionRects" - arguments:selectionRects]; - [textInputPlugin handleMethodCall:methodCall - result:^(id _Nullable result) { - XCTAssertEqual(result, FlutterMethodNotImplemented); - }]; - - XCTAssertEqual([textInputPlugin.activeView.selectionRects count], 0u); -} - - (void)testDecommissionedViewAreNotReusedByAutofill { // Regression test for https://github.com/flutter/flutter/issues/84407. NSMutableDictionary* configuration = self.mutableTemplateCopy;