-
Notifications
You must be signed in to change notification settings - Fork 6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
8f828bf
commit 60af9a5
Showing
5 changed files
with
154 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.m
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
// 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 <OCMock/OCMock.h> | ||
#import <XCTest/XCTest.h> | ||
#include "flutter/shell/platform/darwin/common/framework/Headers/FlutterMacros.h" | ||
#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h" | ||
#include "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h" | ||
|
||
FLUTTER_ASSERT_ARC | ||
|
||
@interface FlutterTextInputPluginTest : XCTestCase | ||
@end | ||
|
||
@implementation FlutterTextInputPluginTest | ||
|
||
- (void)testAutofillInputViews { | ||
// Setup test. | ||
id engine = OCMClassMock([FlutterEngine class]); | ||
FlutterTextInputPlugin* textInputPlugin = [[FlutterTextInputPlugin alloc] init]; | ||
textInputPlugin.textInputDelegate = engine; | ||
|
||
NSDictionary* template = @{ | ||
@"inputType" : @{@"name" : @"TextInuptType.text"}, | ||
@"keyboardAppearance" : @"Brightness.light", | ||
@"obscureText" : @NO, | ||
@"inputAction" : @"TextInputAction.unspecified", | ||
@"smartDashesType" : @"0", | ||
@"smartQuotesType" : @"0", | ||
@"autocorrect" : @YES | ||
}; | ||
|
||
NSMutableDictionary* field1 = [template mutableCopy]; | ||
[field1 setValue:@{ | ||
@"uniqueIdentifier" : @"field1", | ||
@"hints" : @[ @"hint1" ], | ||
@"editingValue" : @{@"text" : @""} | ||
} | ||
forKey:@"autofill"]; | ||
|
||
NSMutableDictionary* field2 = [template mutableCopy]; | ||
[field2 setValue:@{ | ||
@"uniqueIdentifier" : @"field2", | ||
@"hints" : @[ @"hint2" ], | ||
@"editingValue" : @{@"text" : @""} | ||
} | ||
forKey:@"autofill"]; | ||
|
||
NSMutableDictionary* config = [field1 mutableCopy]; | ||
[config setValue:@[ field1, field2 ] forKey:@"allFields"]; | ||
|
||
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<FlutterTextInputView*>* inputFields = | ||
[[[textInputPlugin textInputView] superview] subviews]; | ||
|
||
XCTAssertEqual(inputFields.count, 2); | ||
|
||
// Find the inactive autofillable input field. | ||
FlutterTextInputView* inactiveView = inputFields[1]; | ||
[inactiveView replaceRange:[FlutterTextRange rangeWithNSRange:NSMakeRange(0, 0)] | ||
withText:@"Autofilled!"]; | ||
|
||
// Verify behavior. | ||
OCMVerify([engine updateEditingClient:0 withState:[OCMArg isNotNil] withTag:@"field2"]); | ||
|
||
// Clean up mocks | ||
[engine stopMocking]; | ||
} | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters