From c399be3ab7cee51ebb451cda7ddd8c58683208ba Mon Sep 17 00:00:00 2001 From: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Mon, 20 Apr 2020 11:39:55 -0700 Subject: [PATCH] Fix a typo so that the secure input view is properly initialized (flutter/engine#17816) --- .../Source/FlutterTextInputPlugin.mm | 2 +- .../Source/FlutterTextInputPluginTest.m | 36 +++++++++++++++++++ 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm index 068b8bcb76..df376b5534 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.mm @@ -819,7 +819,7 @@ static NSString* uniqueIdFromDictionary(NSDictionary* dictionary) { if (self) { _nonAutofillInputView = [[FlutterTextInputView alloc] init]; _nonAutofillInputView.secureTextEntry = NO; - _nonAutofillInputView = [[FlutterTextInputView alloc] init]; + _nonAutofillSecureInputView = [[FlutterTextInputView alloc] init]; _nonAutofillSecureInputView.secureTextEntry = YES; _inputViews = [[NSMutableArray alloc] init]; diff --git a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m index df6e1a5a2f..a8eb3ce006 100644 --- a/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m +++ b/engine/src/flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m @@ -14,7 +14,43 @@ FLUTTER_ASSERT_ARC @end @implementation FlutterTextInputPluginTest +- (void)testSecureInput { + // Setup test. + id engine = OCMClassMock([FlutterEngine class]); + FlutterTextInputPlugin* textInputPlugin = [[FlutterTextInputPlugin alloc] init]; + textInputPlugin.textInputDelegate = engine; + NSDictionary* config = @{ + @"inputType" : @{@"name" : @"TextInuptType.text"}, + @"keyboardAppearance" : @"Brightness.light", + @"obscureText" : @YES, + @"inputAction" : @"TextInputAction.unspecified", + @"smartDashesType" : @"0", + @"smartQuotesType" : @"0", + @"autocorrect" : @YES + }; + + FlutterMethodCall* setClientCall = + [FlutterMethodCall methodCallWithMethodName:@"TextInput.setClient" + arguments:@[ @123, config ]]; + + [textInputPlugin handleMethodCall:setClientCall + result:^(id _Nullable result){ + }]; + + // Find all input views in the input hider view. + NSArray* inputFields = + [[[textInputPlugin textInputView] superview] subviews]; + + // Find the inactive autofillable input field. + FlutterTextInputView* inputView = inputFields[0]; + + // Verify secureTextEntry is set to the correct value. + XCTAssertTrue(inputView.secureTextEntry); + + // Clean up mocks + [engine stopMocking]; +} - (void)testAutofillInputViews { // Setup test. id engine = OCMClassMock([FlutterEngine class]);