From 0b0000d4b109edc8bcd47e408e012fa099012957 Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Fri, 21 Jun 2019 14:35:29 -0700 Subject: [PATCH 01/19] add new method for autocorrection --- shell/platform/darwin/ios/framework/Source/FlutterEngine.mm | 5 +++++ .../darwin/ios/framework/Source/FlutterTextInputDelegate.h | 2 +- .../darwin/ios/framework/Source/FlutterTextInputPlugin.mm | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm index 4ba2e83daa05b..6f8d49db194a7 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm @@ -490,6 +490,11 @@ - (void)performAction:(FlutterTextInputAction)action withClient:(int)client { arguments:@[ @(client), actionString ]]; } +- (void)showAutocorrectionPromptWithClient:(int)client { + [_textInputChannel.get() invokeMethod:@"TextInputClient.showAutocorrectionPrompt" + arguments:@[@(client)]]; +} + #pragma mark - Screenshot Delegate - (flutter::Rasterizer::Screenshot)takeScreenshot:(flutter::Rasterizer::ScreenshotType)type diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h b/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h index d3451b5bd4cd4..a4cfa0331bac0 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h @@ -34,7 +34,7 @@ typedef NS_ENUM(NSInteger, FlutterFloatingCursorDragState) { - (void)updateFloatingCursor:(FlutterFloatingCursorDragState)state withClient:(int)client withPosition:(NSDictionary*)point; - +- (void)showAutocorrectionPromptWithClient:(int)client; @end #endif // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERTEXTINPUTDELEGATE_H_ diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 1a056f365c996..b5d36901f4756 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -537,6 +537,7 @@ - (void)setBaseWritingDirection:(UITextWritingDirection)writingDirection - (CGRect)firstRectForRange:(UITextRange*)range { // TODO(cbracken) Implement. + [_textInputDelegate showAutocorrectionPromptWithClient:_textInputClient]; return CGRectZero; } From 4846f35af06dff22001710cfd3aef21600e5d2b4 Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Mon, 24 Jun 2019 11:24:06 -0700 Subject: [PATCH 02/19] account for multistage input --- .../platform/darwin/ios/framework/Source/FlutterEngine.mm | 8 ++++++-- .../ios/framework/Source/FlutterTextInputDelegate.h | 4 +++- .../darwin/ios/framework/Source/FlutterTextInputPlugin.mm | 4 +++- 3 files changed, 12 insertions(+), 4 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm index 6f8d49db194a7..89f15efd9d5ef 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm @@ -490,9 +490,13 @@ - (void)performAction:(FlutterTextInputAction)action withClient:(int)client { arguments:@[ @(client), actionString ]]; } +- (void)showPromptRectForStart:(NSUInteger)start end:(NSUInteger)end withClient:(int)client { + [_textInputChannel.get() invokeMethod:@"TextInputClient.showPromptRect" + arguments:@[@(client), @(start), @(end)]]; +} + - (void)showAutocorrectionPromptWithClient:(int)client { - [_textInputChannel.get() invokeMethod:@"TextInputClient.showAutocorrectionPrompt" - arguments:@[@(client)]]; + } #pragma mark - Screenshot Delegate diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h b/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h index a4cfa0331bac0..40ce1c2e0d6f7 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h @@ -34,7 +34,9 @@ typedef NS_ENUM(NSInteger, FlutterFloatingCursorDragState) { - (void)updateFloatingCursor:(FlutterFloatingCursorDragState)state withClient:(int)client withPosition:(NSDictionary*)point; -- (void)showAutocorrectionPromptWithClient:(int)client; +- (void)showPromptRectForStart:(NSUInteger)start + end:(NSUInteger)end + withClient:(int)client; @end #endif // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERTEXTINPUTDELEGATE_H_ diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index b5d36901f4756..1a55b537efe06 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -537,7 +537,9 @@ - (void)setBaseWritingDirection:(UITextWritingDirection)writingDirection - (CGRect)firstRectForRange:(UITextRange*)range { // TODO(cbracken) Implement. - [_textInputDelegate showAutocorrectionPromptWithClient:_textInputClient]; + NSUInteger start = ((FlutterTextPosition*)range.start).index; + NSUInteger end = ((FlutterTextPosition*)range.end).index; + [_textInputDelegate showPromptRectForStart:start end:end withClient:_textInputClient]; return CGRectZero; } From 6246afcadfb0ea6c963684be47ba9400c171a934 Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Wed, 26 Jun 2019 15:16:26 -0700 Subject: [PATCH 03/19] add cause --- .../darwin/ios/framework/Source/FlutterEngine.mm | 7 +++++-- .../ios/framework/Source/FlutterTextInputDelegate.h | 7 +++++++ .../ios/framework/Source/FlutterTextInputPlugin.mm | 12 +++++++++++- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm index e514f0d9b555f..0a2e65c259b5d 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm @@ -490,9 +490,12 @@ - (void)performAction:(FlutterTextInputAction)action withClient:(int)client { arguments:@[ @(client), actionString ]]; } -- (void)showPromptRectForStart:(NSUInteger)start end:(NSUInteger)end withClient:(int)client { +- (void)showPromptRectForStart:(NSUInteger)start + end:(NSUInteger)end + cause:(FlutterTextPromptRectAppearCause)cause + withClient:(int)client { [_textInputChannel.get() invokeMethod:@"TextInputClient.showPromptRect" - arguments:@[@(client), @(start), @(end)]]; + arguments:@[@(client), @(start), @(end), @(cause)]]; } #pragma mark - Screenshot Delegate diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h b/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h index 40ce1c2e0d6f7..311e9405b437b 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h @@ -27,6 +27,12 @@ typedef NS_ENUM(NSInteger, FlutterFloatingCursorDragState) { FlutterFloatingCursorDragStateEnd, }; +typedef NS_ENUM(NSInteger, FlutterTextPromptRectAppearCause) { + FlutterTextPromptRectAppearCauseUnspecified, + FlutterTextPromptRectAppearCauseAutocorrection, + FlutterTextPromptRectAppearCauseMultistageTextInput, +}; + @protocol FlutterTextInputDelegate - (void)updateEditingClient:(int)client withState:(NSDictionary*)state; @@ -36,6 +42,7 @@ typedef NS_ENUM(NSInteger, FlutterFloatingCursorDragState) { withPosition:(NSDictionary*)point; - (void)showPromptRectForStart:(NSUInteger)start end:(NSUInteger)end + cause:(FlutterTextPromptRectAppearCause)cause withClient:(int)client; @end diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 1a55b537efe06..cde613b3760b1 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -539,7 +539,17 @@ - (CGRect)firstRectForRange:(UITextRange*)range { // TODO(cbracken) Implement. NSUInteger start = ((FlutterTextPosition*)range.start).index; NSUInteger end = ((FlutterTextPosition*)range.end).index; - [_textInputDelegate showPromptRectForStart:start end:end withClient:_textInputClient]; + FlutterTextPromptRectAppearCause cause; + if (_markedTextRange == nil) { + cause = FlutterTextPromptRectAppearCauseAutocorrection; + } else { + cause = FlutterTextPromptRectAppearCauseMultistageTextInput; + } + + [_textInputDelegate showPromptRectForStart:start + end:end + cause:cause + withClient:_textInputClient]; return CGRectZero; } From a5f99ceaa1fa506c33644cecdbc5a5ad6ced684f Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Wed, 26 Jun 2019 15:19:57 -0700 Subject: [PATCH 04/19] move TODO around --- .../darwin/ios/framework/Source/FlutterTextInputPlugin.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index cde613b3760b1..36db1e3ab7985 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -536,7 +536,6 @@ - (void)setBaseWritingDirection:(UITextWritingDirection)writingDirection // physical keyboard. - (CGRect)firstRectForRange:(UITextRange*)range { - // TODO(cbracken) Implement. NSUInteger start = ((FlutterTextPosition*)range.start).index; NSUInteger end = ((FlutterTextPosition*)range.end).index; FlutterTextPromptRectAppearCause cause; @@ -550,6 +549,7 @@ - (CGRect)firstRectForRange:(UITextRange*)range { end:end cause:cause withClient:_textInputClient]; + // TODO(cbracken) Implement. return CGRectZero; } From ee9bd5baca23f037b591df90a47f7613573b96d7 Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Thu, 27 Jun 2019 10:51:07 -0700 Subject: [PATCH 05/19] fix format --- shell/platform/darwin/ios/framework/Source/FlutterEngine.mm | 2 +- .../darwin/ios/framework/Source/FlutterTextInputPlugin.mm | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm index 0a2e65c259b5d..4a96c8e98c4e1 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm @@ -495,7 +495,7 @@ - (void)showPromptRectForStart:(NSUInteger)start cause:(FlutterTextPromptRectAppearCause)cause withClient:(int)client { [_textInputChannel.get() invokeMethod:@"TextInputClient.showPromptRect" - arguments:@[@(client), @(start), @(end), @(cause)]]; + arguments:@[ @(client), @(start), @(end), @(cause) ]]; } #pragma mark - Screenshot Delegate diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 36db1e3ab7985..ff93232b4548b 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -545,10 +545,7 @@ - (CGRect)firstRectForRange:(UITextRange*)range { cause = FlutterTextPromptRectAppearCauseMultistageTextInput; } - [_textInputDelegate showPromptRectForStart:start - end:end - cause:cause - withClient:_textInputClient]; + [_textInputDelegate showPromptRectForStart:start end:end cause:cause withClient:_textInputClient]; // TODO(cbracken) Implement. return CGRectZero; } From 24fceebabe5b8f1ab3206faeae4b1d151fa995d2 Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Mon, 28 Oct 2019 14:05:21 -0700 Subject: [PATCH 06/19] update --- .../darwin/ios/framework/Source/FlutterEngine.mm | 12 ++++++------ .../framework/Source/FlutterTextInputDelegate.h | 15 +++++++-------- .../framework/Source/FlutterTextInputPlugin.mm | 8 ++++---- 3 files changed, 17 insertions(+), 18 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm index db754cc9c2194..9ecd71c9db5a4 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm @@ -537,12 +537,12 @@ - (void)performAction:(FlutterTextInputAction)action withClient:(int)client { arguments:@[ @(client), actionString ]]; } -- (void)showPromptRectForStart:(NSUInteger)start - end:(NSUInteger)end - cause:(FlutterTextPromptRectAppearCause)cause - withClient:(int)client { - [_textInputChannel.get() invokeMethod:@"TextInputClient.showPromptRect" - arguments:@[ @(client), @(start), @(end), @(cause) ]]; +- (void)updatePromptRectForStart:(NSUInteger)start + end:(NSUInteger)end + type:(FlutterTextPromptRectType)type + withClient:(int)client { + [_textInputChannel.get() invokeMethod:@"TextInputClient.updatePromptRect" + arguments:@[ @(client), @(start), @(end), @(type) ]]; } #pragma mark - Screenshot Delegate diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h b/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h index 311e9405b437b..6853ac9bd8833 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h @@ -27,10 +27,9 @@ typedef NS_ENUM(NSInteger, FlutterFloatingCursorDragState) { FlutterFloatingCursorDragStateEnd, }; -typedef NS_ENUM(NSInteger, FlutterTextPromptRectAppearCause) { - FlutterTextPromptRectAppearCauseUnspecified, - FlutterTextPromptRectAppearCauseAutocorrection, - FlutterTextPromptRectAppearCauseMultistageTextInput, +typedef NS_ENUM(NSInteger, FlutterTextPromptRectType) { + FlutterTextPromptRectTypeAutocorrection, + FlutterTextPromptRectTypeMultistageTextInput, }; @protocol FlutterTextInputDelegate @@ -40,10 +39,10 @@ typedef NS_ENUM(NSInteger, FlutterTextPromptRectAppearCause) { - (void)updateFloatingCursor:(FlutterFloatingCursorDragState)state withClient:(int)client withPosition:(NSDictionary*)point; -- (void)showPromptRectForStart:(NSUInteger)start - end:(NSUInteger)end - cause:(FlutterTextPromptRectAppearCause)cause - withClient:(int)client; +- (void)updatePromptRectForStart:(NSUInteger)start + end:(NSUInteger)end + type:(FlutterTextPromptRectType)promptType + withClient:(int)client; @end #endif // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERTEXTINPUTDELEGATE_H_ diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 91b1d27927dd3..883783cb30b3e 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -544,14 +544,14 @@ - (void)setBaseWritingDirection:(UITextWritingDirection)writingDirection - (CGRect)firstRectForRange:(UITextRange*)range { NSUInteger start = ((FlutterTextPosition*)range.start).index; NSUInteger end = ((FlutterTextPosition*)range.end).index; - FlutterTextPromptRectAppearCause cause; + FlutterTextPromptRectType promptType; if (_markedTextRange == nil) { - cause = FlutterTextPromptRectAppearCauseAutocorrection; + promptType = FlutterTextPromptRectTypeAutocorrection; } else { - cause = FlutterTextPromptRectAppearCauseMultistageTextInput; + promptType = FlutterTextPromptRectTypeMultistageTextInput; } - [_textInputDelegate showPromptRectForStart:start end:end cause:cause withClient:_textInputClient]; + [_textInputDelegate updatePromptRectForStart:start end:end type:promptType withClient:_textInputClient]; // TODO(cbracken) Implement. return CGRectZero; } From 920f44627349daf0abf568dce17563acc76e2dab Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Mon, 28 Oct 2019 14:47:01 -0700 Subject: [PATCH 07/19] update --- .../darwin/ios/framework/Source/FlutterEngine.mm | 11 +++++------ .../framework/Source/FlutterTextInputDelegate.h | 12 +++--------- .../framework/Source/FlutterTextInputPlugin.mm | 15 +++++++-------- 3 files changed, 15 insertions(+), 23 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm index 9ecd71c9db5a4..74b1f8325c296 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterEngine.mm @@ -537,12 +537,11 @@ - (void)performAction:(FlutterTextInputAction)action withClient:(int)client { arguments:@[ @(client), actionString ]]; } -- (void)updatePromptRectForStart:(NSUInteger)start - end:(NSUInteger)end - type:(FlutterTextPromptRectType)type - withClient:(int)client { - [_textInputChannel.get() invokeMethod:@"TextInputClient.updatePromptRect" - arguments:@[ @(client), @(start), @(end), @(type) ]]; +- (void)showAutocorrectionPromptRectForStart:(NSUInteger)start + end:(NSUInteger)end + withClient:(int)client { + [_textInputChannel.get() invokeMethod:@"TextInputClient.showAutocorrectionPromptRect" + arguments:@[ @(client), @(start), @(end) ]]; } #pragma mark - Screenshot Delegate diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h b/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h index 6853ac9bd8833..61382fba300a4 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h @@ -27,11 +27,6 @@ typedef NS_ENUM(NSInteger, FlutterFloatingCursorDragState) { FlutterFloatingCursorDragStateEnd, }; -typedef NS_ENUM(NSInteger, FlutterTextPromptRectType) { - FlutterTextPromptRectTypeAutocorrection, - FlutterTextPromptRectTypeMultistageTextInput, -}; - @protocol FlutterTextInputDelegate - (void)updateEditingClient:(int)client withState:(NSDictionary*)state; @@ -39,10 +34,9 @@ typedef NS_ENUM(NSInteger, FlutterTextPromptRectType) { - (void)updateFloatingCursor:(FlutterFloatingCursorDragState)state withClient:(int)client withPosition:(NSDictionary*)point; -- (void)updatePromptRectForStart:(NSUInteger)start - end:(NSUInteger)end - type:(FlutterTextPromptRectType)promptType - withClient:(int)client; +- (void)showAutocorrectionPromptRectForStart:(NSUInteger)start + end:(NSUInteger)end + withClient:(int)client; @end #endif // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERTEXTINPUTDELEGATE_H_ diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 883783cb30b3e..4acf511ea35d0 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -542,16 +542,15 @@ - (void)setBaseWritingDirection:(UITextWritingDirection)writingDirection // physical keyboard. - (CGRect)firstRectForRange:(UITextRange*)range { + // If _markedTextRange is not nil, then the prompt rect is showing to + // indicate multi-stage text, which is handled somewhere else. + if (_markedTextRange != nil) { + return CGRectZero; + } + NSUInteger start = ((FlutterTextPosition*)range.start).index; NSUInteger end = ((FlutterTextPosition*)range.end).index; - FlutterTextPromptRectType promptType; - if (_markedTextRange == nil) { - promptType = FlutterTextPromptRectTypeAutocorrection; - } else { - promptType = FlutterTextPromptRectTypeMultistageTextInput; - } - - [_textInputDelegate updatePromptRectForStart:start end:end type:promptType withClient:_textInputClient]; + [_textInputDelegate showAutocorrectionPromptRectForStart:start end:end withClient:_textInputClient]; // TODO(cbracken) Implement. return CGRectZero; } From 6531251112f446273c53d221a6b40884d86ab27b Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Mon, 28 Oct 2019 15:47:11 -0700 Subject: [PATCH 08/19] add test --- .../Source/FlutterViewControllerTest.m | 75 ++++++++++--------- 1 file changed, 38 insertions(+), 37 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.m b/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.m index b33e8cda6f56d..09d7f26e721a3 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.m +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.m @@ -110,7 +110,8 @@ - (void)testItReportsPlatformBrightnessWhenViewWillAppear { } - (void)testItReportsDarkPlatformBrightnessWhenTraitCollectionRequestsIt { - if (!@available(iOS 13, *)) { + if (@available(iOS 13, *)) { + } else { return; } @@ -159,7 +160,8 @@ - (UITraitCollection*)fakeTraitCollectionWithUserInterfaceStyle:(UIUserInterface #pragma mark - Platform Contrast - (void)testItReportsNormalPlatformContrastByDefault { - if (!@available(iOS 13, *)) { + if (@available(iOS 13, *)) { + } else { return; } @@ -187,7 +189,8 @@ - (void)testItReportsNormalPlatformContrastByDefault { } - (void)testItReportsPlatformContrastWhenViewWillAppear { - if (!@available(iOS 13, *)) { + if (@available(iOS 13, *)) { + } else { return; } @@ -215,41 +218,39 @@ - (void)testItReportsPlatformContrastWhenViewWillAppear { } - (void)testItReportsHighContrastWhenTraitCollectionRequestsIt { - if (!@available(iOS 13, *)) { - return; + if (@available(iOS 13, *)) { + // Setup test. + id engine = OCMClassMock([FlutterEngine class]); + + id settingsChannel = OCMClassMock([FlutterBasicMessageChannel class]); + OCMStub([engine settingsChannel]).andReturn(settingsChannel); + + FlutterViewController* realVC = [[FlutterViewController alloc] initWithEngine:engine + nibName:nil + bundle:nil]; + id mockTraitCollection = [self fakeTraitCollectionWithContrast:UIAccessibilityContrastHigh]; + + // We partially mock the real FlutterViewController to act as the OS and report + // the UITraitCollection of our choice. Mocking the object under test is not + // desirable, but given that the OS does not offer a DI approach to providing + // our own UITraitCollection, this seems to be the least bad option. + id partialMockVC = OCMPartialMock(realVC); + OCMStub([partialMockVC traitCollection]).andReturn(mockTraitCollection); + + // Exercise behavior under test. + [partialMockVC traitCollectionDidChange:mockTraitCollection]; + + // Verify behavior. + OCMVerify([settingsChannel sendMessage:[OCMArg checkWithBlock:^BOOL(id message) { + return [message[@"platformContrast"] isEqualToString:@"high"]; + }]]); + + // Clean up mocks + [partialMockVC stopMocking]; + [engine stopMocking]; + [settingsChannel stopMocking]; + [mockTraitCollection stopMocking]; } - - // Setup test. - id engine = OCMClassMock([FlutterEngine class]); - - id settingsChannel = OCMClassMock([FlutterBasicMessageChannel class]); - OCMStub([engine settingsChannel]).andReturn(settingsChannel); - - FlutterViewController* realVC = [[FlutterViewController alloc] initWithEngine:engine - nibName:nil - bundle:nil]; - id mockTraitCollection = [self fakeTraitCollectionWithContrast:UIAccessibilityContrastHigh]; - - // We partially mock the real FlutterViewController to act as the OS and report - // the UITraitCollection of our choice. Mocking the object under test is not - // desirable, but given that the OS does not offer a DI approach to providing - // our own UITraitCollection, this seems to be the least bad option. - id partialMockVC = OCMPartialMock(realVC); - OCMStub([partialMockVC traitCollection]).andReturn(mockTraitCollection); - - // Exercise behavior under test. - [partialMockVC traitCollectionDidChange:mockTraitCollection]; - - // Verify behavior. - OCMVerify([settingsChannel sendMessage:[OCMArg checkWithBlock:^BOOL(id message) { - return [message[@"platformContrast"] isEqualToString:@"high"]; - }]]); - - // Clean up mocks - [partialMockVC stopMocking]; - [engine stopMocking]; - [settingsChannel stopMocking]; - [mockTraitCollection stopMocking]; } // Creates a mocked UITraitCollection with nil values for everything except accessibilityContrast, From 7d12820dcaae31bce71c07dd8c7c2a25d220ee23 Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Tue, 19 Nov 2019 18:37:27 -0800 Subject: [PATCH 09/19] add tests --- .../framework/Source/FlutterTextInputPlugin.h | 30 ++++++++++++++++ .../Source/FlutterTextInputPlugin.mm | 23 ------------- .../Source/FlutterTextInputPluginTest.m | 34 +++++++++++++++++++ .../IosUnitTests.xcodeproj/project.pbxproj | 4 +++ 4 files changed, 68 insertions(+), 23 deletions(-) create mode 100644 shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h index 70bd949579ce2..66942b91b7b27 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h @@ -36,6 +36,9 @@ @end /** A range of text in the buffer of a Flutter text editing widget. */ +#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG +FLUTTER_EXPORT +#endif @interface FlutterTextRange : UITextRange @property(nonatomic, readonly) NSRange range; @@ -44,4 +47,31 @@ @end +#if FLUTTER_RUNTIME_MODE == FLUTTER_RUNTIME_MODE_DEBUG +FLUTTER_EXPORT +#endif +@interface FlutterTextInputView : UIView + +// UITextInput +@property(nonatomic, readonly) NSMutableString* text; +@property(nonatomic, readonly) NSMutableString* markedText; +@property(readwrite, copy) UITextRange* selectedTextRange; +@property(nonatomic, strong) UITextRange* markedTextRange; +@property(nonatomic, copy) NSDictionary* markedTextStyle; +@property(nonatomic, assign) id inputDelegate; + +// UITextInputTraits +@property(nonatomic) UITextAutocapitalizationType autocapitalizationType; +@property(nonatomic) UITextAutocorrectionType autocorrectionType; +@property(nonatomic) UITextSpellCheckingType spellCheckingType; +@property(nonatomic) BOOL enablesReturnKeyAutomatically; +@property(nonatomic) UIKeyboardAppearance keyboardAppearance; +@property(nonatomic) UIKeyboardType keyboardType; +@property(nonatomic) UIReturnKeyType returnKeyType; +@property(nonatomic, getter=isSecureTextEntry) BOOL secureTextEntry; + +@property(nonatomic, assign) id textInputDelegate; + +@end #endif // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERTEXTINPUTPLUGIN_H_ + diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 4acf511ea35d0..ddb340baac0af 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -140,29 +140,6 @@ - (id)copyWithZone:(NSZone*)zone { @end -@interface FlutterTextInputView : UIView - -// UITextInput -@property(nonatomic, readonly) NSMutableString* text; -@property(nonatomic, readonly) NSMutableString* markedText; -@property(readwrite, copy) UITextRange* selectedTextRange; -@property(nonatomic, strong) UITextRange* markedTextRange; -@property(nonatomic, copy) NSDictionary* markedTextStyle; -@property(nonatomic, assign) id inputDelegate; - -// UITextInputTraits -@property(nonatomic) UITextAutocapitalizationType autocapitalizationType; -@property(nonatomic) UITextAutocorrectionType autocorrectionType; -@property(nonatomic) UITextSpellCheckingType spellCheckingType; -@property(nonatomic) BOOL enablesReturnKeyAutomatically; -@property(nonatomic) UIKeyboardAppearance keyboardAppearance; -@property(nonatomic) UIKeyboardType keyboardType; -@property(nonatomic) UIReturnKeyType returnKeyType; -@property(nonatomic, getter=isSecureTextEntry) BOOL secureTextEntry; - -@property(nonatomic, assign) id textInputDelegate; - -@end @implementation FlutterTextInputView { int _textInputClient; diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m new file mode 100644 index 0000000000000..bc950c0b69f2a --- /dev/null +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m @@ -0,0 +1,34 @@ +// Copyright 2013 The Flutter Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#import +#import +#include "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" +#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h" +#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h" + +//FLUTTER_ASSERT_ARC + +@interface FlutterTextInputPluginTest : XCTestCase +@end + +@implementation FlutterTextInputPluginTest + +- (void)testItReportsLightPlatformBrightnessByDefault { + // Setup test. + id engine = OCMClassMock([FlutterEngine class]); + + FlutterTextInputView* inputView = [[FlutterTextInputView alloc] initWithFrame:CGRectZero]; + inputView.textInputDelegate = engine; + [inputView firstRectForRange: [FlutterTextRange rangeWithNSRange:NSMakeRange(0, 1)]]; + + // Verify behavior. + OCMVerify([engine showAutocorrectionPromptRectForStart:0 + end:1 + withClient:0]); + + // Clean up mocks + [engine stopMocking]; +} +@end diff --git a/testing/ios/IosUnitTests/IosUnitTests.xcodeproj/project.pbxproj b/testing/ios/IosUnitTests/IosUnitTests.xcodeproj/project.pbxproj index 82f36199ac95a..7b42a75d8998d 100644 --- a/testing/ios/IosUnitTests/IosUnitTests.xcodeproj/project.pbxproj +++ b/testing/ios/IosUnitTests/IosUnitTests.xcodeproj/project.pbxproj @@ -20,6 +20,7 @@ 0D6AB6EB22BB40E700EEE540 /* FlutterEngineTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0D6AB6E722BB40CF00EEE540 /* FlutterEngineTest.mm */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; 0D6AB72C22BC339F00EEE540 /* libOCMock.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0D6AB72522BC336100EEE540 /* libOCMock.a */; }; 0D6AB73F22BD8F0200EEE540 /* FlutterEngineConfig.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 0D6AB73E22BD8F0200EEE540 /* FlutterEngineConfig.xcconfig */; }; + 3D8AF6182384C5420033B95F /* FlutterTextInputPluginTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D8AF6172384C5420033B95F /* FlutterTextInputPluginTest.m */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -94,6 +95,7 @@ 0D6AB6E722BB40CF00EEE540 /* FlutterEngineTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = FlutterEngineTest.mm; sourceTree = ""; }; 0D6AB71722BC336100EEE540 /* OCMock.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = OCMock.xcodeproj; path = ../../../../../third_party/ocmock/Source/OCMock.xcodeproj; sourceTree = ""; }; 0D6AB73E22BD8F0200EEE540 /* FlutterEngineConfig.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = FlutterEngineConfig.xcconfig; sourceTree = ""; }; + 3D8AF6172384C5420033B95F /* FlutterTextInputPluginTest.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FlutterTextInputPluginTest.m; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -176,6 +178,7 @@ children = ( 0D52D3B622C566D50011DEBD /* FlutterBinaryMessengerRelayTest.mm */, 0D6AB6E722BB40CF00EEE540 /* FlutterEngineTest.mm */, + 3D8AF6172384C5420033B95F /* FlutterTextInputPluginTest.m */, 0D17A5BF22D78FCD0057279F /* FlutterViewControllerTest.m */, 0D4C3FAF22DF9F5300A67C70 /* FlutterPluginAppLifeCycleDelegateTest.m */, ); @@ -387,6 +390,7 @@ buildActionMask = 2147483647; files = ( 0D6AB6EB22BB40E700EEE540 /* FlutterEngineTest.mm in Sources */, + 3D8AF6182384C5420033B95F /* FlutterTextInputPluginTest.m in Sources */, 0D17A5C022D78FCD0057279F /* FlutterViewControllerTest.m in Sources */, 0D1CE5D8233430F400E5D880 /* FlutterChannelsTest.m in Sources */, 0D52D3BD22C566D50011DEBD /* FlutterBinaryMessengerRelayTest.mm in Sources */, From 2c194d6ea3a8716fe15027c2aecfe32805b42fca Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Wed, 20 Nov 2019 11:44:13 -0800 Subject: [PATCH 10/19] using arc for xctest --- .../ios/framework/Source/FlutterTextInputPluginTest.m | 7 ++----- .../IosUnitTests/IosUnitTests.xcodeproj/project.pbxproj | 2 +- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m index bc950c0b69f2a..e07b5cf97c157 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m @@ -8,13 +8,12 @@ #include "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h" #import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h" -//FLUTTER_ASSERT_ARC +FLUTTER_ASSERT_ARC @interface FlutterTextInputPluginTest : XCTestCase @end @implementation FlutterTextInputPluginTest - - (void)testItReportsLightPlatformBrightnessByDefault { // Setup test. id engine = OCMClassMock([FlutterEngine class]); @@ -24,9 +23,7 @@ - (void)testItReportsLightPlatformBrightnessByDefault { [inputView firstRectForRange: [FlutterTextRange rangeWithNSRange:NSMakeRange(0, 1)]]; // Verify behavior. - OCMVerify([engine showAutocorrectionPromptRectForStart:0 - end:1 - withClient:0]); + OCMVerify([engine showAutocorrectionPromptRectForStart:0 end:1 withClient:0]); // Clean up mocks [engine stopMocking]; diff --git a/testing/ios/IosUnitTests/IosUnitTests.xcodeproj/project.pbxproj b/testing/ios/IosUnitTests/IosUnitTests.xcodeproj/project.pbxproj index 7b42a75d8998d..533ff80fd389c 100644 --- a/testing/ios/IosUnitTests/IosUnitTests.xcodeproj/project.pbxproj +++ b/testing/ios/IosUnitTests/IosUnitTests.xcodeproj/project.pbxproj @@ -20,7 +20,7 @@ 0D6AB6EB22BB40E700EEE540 /* FlutterEngineTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = 0D6AB6E722BB40CF00EEE540 /* FlutterEngineTest.mm */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; 0D6AB72C22BC339F00EEE540 /* libOCMock.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 0D6AB72522BC336100EEE540 /* libOCMock.a */; }; 0D6AB73F22BD8F0200EEE540 /* FlutterEngineConfig.xcconfig in Resources */ = {isa = PBXBuildFile; fileRef = 0D6AB73E22BD8F0200EEE540 /* FlutterEngineConfig.xcconfig */; }; - 3D8AF6182384C5420033B95F /* FlutterTextInputPluginTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D8AF6172384C5420033B95F /* FlutterTextInputPluginTest.m */; }; + 3D8AF6182384C5420033B95F /* FlutterTextInputPluginTest.m in Sources */ = {isa = PBXBuildFile; fileRef = 3D8AF6172384C5420033B95F /* FlutterTextInputPluginTest.m */; settings = {COMPILER_FLAGS = "-fobjc-arc"; }; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ From 180ed362224f3aef3b0f29d06ce8d1bdf6695706 Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Wed, 20 Nov 2019 11:48:17 -0800 Subject: [PATCH 11/19] revert changes --- .../Source/FlutterViewControllerTest.m | 75 +++++++++---------- 1 file changed, 37 insertions(+), 38 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.m b/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.m index 519f04124c950..31c2bcc077706 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.m +++ b/shell/platform/darwin/ios/framework/Source/FlutterViewControllerTest.m @@ -114,8 +114,7 @@ - (void)testItReportsPlatformBrightnessWhenViewWillAppear { } - (void)testItReportsDarkPlatformBrightnessWhenTraitCollectionRequestsIt { - if (@available(iOS 13, *)) { - } else { + if (!@available(iOS 13, *)) { return; } @@ -164,8 +163,7 @@ - (UITraitCollection*)fakeTraitCollectionWithUserInterfaceStyle:(UIUserInterface #pragma mark - Platform Contrast - (void)testItReportsNormalPlatformContrastByDefault { - if (@available(iOS 13, *)) { - } else { + if (!@available(iOS 13, *)) { return; } @@ -193,8 +191,7 @@ - (void)testItReportsNormalPlatformContrastByDefault { } - (void)testItReportsPlatformContrastWhenViewWillAppear { - if (@available(iOS 13, *)) { - } else { + if (!@available(iOS 13, *)) { return; } @@ -222,39 +219,41 @@ - (void)testItReportsPlatformContrastWhenViewWillAppear { } - (void)testItReportsHighContrastWhenTraitCollectionRequestsIt { - if (@available(iOS 13, *)) { - // Setup test. - id engine = OCMClassMock([FlutterEngine class]); - - id settingsChannel = OCMClassMock([FlutterBasicMessageChannel class]); - OCMStub([engine settingsChannel]).andReturn(settingsChannel); - - FlutterViewController* realVC = [[FlutterViewController alloc] initWithEngine:engine - nibName:nil - bundle:nil]; - id mockTraitCollection = [self fakeTraitCollectionWithContrast:UIAccessibilityContrastHigh]; - - // We partially mock the real FlutterViewController to act as the OS and report - // the UITraitCollection of our choice. Mocking the object under test is not - // desirable, but given that the OS does not offer a DI approach to providing - // our own UITraitCollection, this seems to be the least bad option. - id partialMockVC = OCMPartialMock(realVC); - OCMStub([partialMockVC traitCollection]).andReturn(mockTraitCollection); - - // Exercise behavior under test. - [partialMockVC traitCollectionDidChange:mockTraitCollection]; - - // Verify behavior. - OCMVerify([settingsChannel sendMessage:[OCMArg checkWithBlock:^BOOL(id message) { - return [message[@"platformContrast"] isEqualToString:@"high"]; - }]]); - - // Clean up mocks - [partialMockVC stopMocking]; - [engine stopMocking]; - [settingsChannel stopMocking]; - [mockTraitCollection stopMocking]; + if (!@available(iOS 13, *)) { + return; } + + // Setup test. + id engine = OCMClassMock([FlutterEngine class]); + + id settingsChannel = OCMClassMock([FlutterBasicMessageChannel class]); + OCMStub([engine settingsChannel]).andReturn(settingsChannel); + + FlutterViewController* realVC = [[FlutterViewController alloc] initWithEngine:engine + nibName:nil + bundle:nil]; + id mockTraitCollection = [self fakeTraitCollectionWithContrast:UIAccessibilityContrastHigh]; + + // We partially mock the real FlutterViewController to act as the OS and report + // the UITraitCollection of our choice. Mocking the object under test is not + // desirable, but given that the OS does not offer a DI approach to providing + // our own UITraitCollection, this seems to be the least bad option. + id partialMockVC = OCMPartialMock(realVC); + OCMStub([partialMockVC traitCollection]).andReturn(mockTraitCollection); + + // Exercise behavior under test. + [partialMockVC traitCollectionDidChange:mockTraitCollection]; + + // Verify behavior. + OCMVerify([settingsChannel sendMessage:[OCMArg checkWithBlock:^BOOL(id message) { + return [message[@"platformContrast"] isEqualToString:@"high"]; + }]]); + + // Clean up mocks + [partialMockVC stopMocking]; + [engine stopMocking]; + [settingsChannel stopMocking]; + [mockTraitCollection stopMocking]; } - (void)testPerformOrientationUpdateForcesOrientationChange { From 2d20e8ff9dd7312a129cd59403fe643b4cae86ff Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Wed, 20 Nov 2019 11:52:17 -0800 Subject: [PATCH 12/19] format --- .../darwin/ios/framework/Source/FlutterTextInputDelegate.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h b/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h index 61382fba300a4..8446a79946d63 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h @@ -35,8 +35,8 @@ typedef NS_ENUM(NSInteger, FlutterFloatingCursorDragState) { withClient:(int)client withPosition:(NSDictionary*)point; - (void)showAutocorrectionPromptRectForStart:(NSUInteger)start - end:(NSUInteger)end - withClient:(int)client; + end:(NSUInteger)end + withClient:(int)client; @end #endif // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERTEXTINPUTDELEGATE_H_ From 56ead3c64163b7d2d8e1d66fcab0f1bc5e9d757f Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Wed, 20 Nov 2019 11:54:10 -0800 Subject: [PATCH 13/19] comments --- .../darwin/ios/framework/Source/FlutterTextInputPlugin.mm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index ddb340baac0af..1289a2b1f3835 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -519,8 +519,7 @@ - (void)setBaseWritingDirection:(UITextWritingDirection)writingDirection // physical keyboard. - (CGRect)firstRectForRange:(UITextRange*)range { - // If _markedTextRange is not nil, then the prompt rect is showing to - // indicate multi-stage text, which is handled somewhere else. + // multi-stage text is handled somewhere else. if (_markedTextRange != nil) { return CGRectZero; } From bb8168095b83882674a0ac613e992018575b09ab Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Wed, 20 Nov 2019 15:26:40 -0800 Subject: [PATCH 14/19] update test name --- .../darwin/ios/framework/Source/FlutterTextInputPluginTest.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m index e07b5cf97c157..73243d5cacd4b 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m @@ -14,7 +14,8 @@ @interface FlutterTextInputPluginTest : XCTestCase @end @implementation FlutterTextInputPluginTest -- (void)testItReportsLightPlatformBrightnessByDefault { + +- (void)testAutocorrectionPromptRectAppears { // Setup test. id engine = OCMClassMock([FlutterEngine class]); From cf097bef5f0be1870273cacf0ae5789937a04da9 Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Wed, 20 Nov 2019 19:27:15 -0800 Subject: [PATCH 15/19] remove newline --- .../darwin/ios/framework/Source/FlutterTextInputPlugin.h | 1 - 1 file changed, 1 deletion(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h index 66942b91b7b27..437ca99b9ef8a 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h @@ -74,4 +74,3 @@ FLUTTER_EXPORT @end #endif // SHELL_PLATFORM_IOS_FRAMEWORK_SOURCE_FLUTTERTEXTINPUTPLUGIN_H_ - From 223760315d9d3a7badffd0781f43089d1b23aa11 Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Tue, 26 Nov 2019 10:26:46 -0800 Subject: [PATCH 16/19] formatting --- .../darwin/ios/framework/Source/FlutterTextInputPlugin.mm | 7 ++++--- .../ios/framework/Source/FlutterTextInputPluginTest.m | 8 ++++---- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 1289a2b1f3835..147343c6ec8a7 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -140,7 +140,6 @@ - (id)copyWithZone:(NSZone*)zone { @end - @implementation FlutterTextInputView { int _textInputClient; const char* _selectionAffinity; @@ -523,10 +522,12 @@ - (CGRect)firstRectForRange:(UITextRange*)range { if (_markedTextRange != nil) { return CGRectZero; } - + NSUInteger start = ((FlutterTextPosition*)range.start).index; NSUInteger end = ((FlutterTextPosition*)range.end).index; - [_textInputDelegate showAutocorrectionPromptRectForStart:start end:end withClient:_textInputClient]; + [_textInputDelegate showAutocorrectionPromptRectForStart:start + end:end + withClient:_textInputClient]; // TODO(cbracken) Implement. return CGRectZero; } diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m index 73243d5cacd4b..6610d9fe4d8cd 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m @@ -5,8 +5,8 @@ #import #import #include "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" -#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h" #import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h" +#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h" FLUTTER_ASSERT_ARC @@ -18,11 +18,11 @@ @implementation FlutterTextInputPluginTest - (void)testAutocorrectionPromptRectAppears { // Setup test. id engine = OCMClassMock([FlutterEngine class]); - + FlutterTextInputView* inputView = [[FlutterTextInputView alloc] initWithFrame:CGRectZero]; inputView.textInputDelegate = engine; - [inputView firstRectForRange: [FlutterTextRange rangeWithNSRange:NSMakeRange(0, 1)]]; - + [inputView firstRectForRange:[FlutterTextRange rangeWithNSRange:NSMakeRange(0, 1)]]; + // Verify behavior. OCMVerify([engine showAutocorrectionPromptRectForStart:0 end:1 withClient:0]); From cc7eb04ef3176fe0923d7f7bd5ddd7510a5f0f01 Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Tue, 26 Nov 2019 11:56:06 -0800 Subject: [PATCH 17/19] update licenses --- ci/licenses_golden/licenses_flutter | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index 33569a6ced33a..ccc0e5c5b22e2 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -787,6 +787,7 @@ FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterPluginA FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterUmbrellaImport.m FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterView.h FILE: ../../../flutter/shell/platform/darwin/ios/framework/Source/FlutterView.mm From 792c37fe541940c435e4fb0b15df329d57f8bc80 Mon Sep 17 00:00:00 2001 From: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Wed, 4 Dec 2019 16:16:33 -0800 Subject: [PATCH 18/19] Update FlutterTextInputPluginTest.m --- .../darwin/ios/framework/Source/FlutterTextInputPluginTest.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m index 6610d9fe4d8cd..d3d2a50a53773 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m @@ -1,4 +1,4 @@ -// Copyright 2013 The Flutter Authors. All rights reserved. +// Copyright 2019 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. From e9071743a020a4a1263136ac987e74115f76d2b6 Mon Sep 17 00:00:00 2001 From: LongCat is Looong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Wed, 18 Dec 2019 11:03:59 -0800 Subject: [PATCH 19/19] license --- .../darwin/ios/framework/Source/FlutterTextInputPluginTest.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m index d3d2a50a53773..6610d9fe4d8cd 100644 --- a/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m +++ b/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m @@ -1,4 +1,4 @@ -// Copyright 2019 The Flutter Authors. All rights reserved. +// Copyright 2013 The Flutter Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file.