Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 919fa04

Browse files
committed
[iOS] Fix TextInputAction.continueAction sends wrong action to framework
1 parent b6586ab commit 919fa04

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

shell/platform/darwin/ios/framework/Source/FlutterEngine.mm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1009,7 +1009,7 @@ - (void)flutterTextInputView:(FlutterTextInputView*)textInputView
10091009
actionString = @"TextInputAction.next";
10101010
break;
10111011
case FlutterTextInputActionContinue:
1012-
actionString = @"TextInputAction.continue";
1012+
actionString = @"TextInputAction.continueAction";
10131013
break;
10141014
case FlutterTextInputActionJoin:
10151015
actionString = @"TextInputAction.join";

shell/platform/darwin/ios/framework/Source/FlutterEngine_Test.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#import "flutter/shell/common/shell.h"
66
#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h"
7+
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h"
78
#import "flutter/shell/platform/darwin/ios/rendering_api_selection.h"
89
#include "flutter/shell/platform/embedder/embedder.h"
910

@@ -31,4 +32,7 @@ class ThreadHost;
3132
entrypointArgs:(/*nullable*/ NSArray<NSString*>*)entrypointArgs;
3233
- (const flutter::ThreadHost&)threadHost;
3334
- (void)updateDisplays;
35+
- (void)flutterTextInputView:(FlutterTextInputView*)textInputView
36+
performAction:(FlutterTextInputAction)action
37+
withClient:(int)client;
3438
@end

shell/platform/darwin/ios/framework/Source/FlutterTextInputPluginTest.mm

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
// Use of this source code is governed by a BSD-style license that can be
33
// found in the LICENSE file.
44

5+
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterBinaryMessengerRelay.h"
6+
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Test.h"
57
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h"
68

79
#import <OCMock/OCMock.h>
@@ -308,7 +310,7 @@ - (void)testAutocorrectionPromptRectAppears {
308310
withClient:0]);
309311
}
310312

311-
- (void)testIngoresSelectionChangeIfSelectionIsDisabled {
313+
- (void)testIgnoresSelectionChangeIfSelectionIsDisabled {
312314
FlutterTextInputView* inputView = [[FlutterTextInputView alloc] initWithOwner:textInputPlugin];
313315
__block int updateCount = 0;
314316
OCMStub([engine flutterTextInputView:inputView updateEditingClient:0 withState:[OCMArg isNotNil]])
@@ -678,6 +680,27 @@ - (void)testUpdateSecureTextEntry {
678680
XCTAssertFalse(inputView.isSecureTextEntry);
679681
}
680682

683+
- (void)testInputActionContinueAction {
684+
id mockBinaryMessenger = OCMClassMock([FlutterBinaryMessengerRelay class]);
685+
FlutterEngine* testEngine = [[FlutterEngine alloc] init];
686+
[testEngine setBinaryMessenger:mockBinaryMessenger];
687+
[testEngine runWithEntrypoint:FlutterDefaultDartEntrypoint initialRoute:@"test"];
688+
689+
FlutterTextInputPlugin* inputPlugin =
690+
[[FlutterTextInputPlugin alloc] initWithDelegate:(id<FlutterTextInputDelegate>)testEngine];
691+
FlutterTextInputView* inputView = [[FlutterTextInputView alloc] initWithOwner:inputPlugin];
692+
693+
[testEngine flutterTextInputView:inputView
694+
performAction:FlutterTextInputActionContinue
695+
withClient:123];
696+
697+
FlutterMethodCall* methodCall =
698+
[FlutterMethodCall methodCallWithMethodName:@"TextInputClient.performAction"
699+
arguments:@[ @(123), @"TextInputAction.continueAction" ]];
700+
NSData* encodedMethodCall = [[FlutterJSONMethodCodec sharedInstance] encodeMethodCall:methodCall];
701+
OCMVerify([mockBinaryMessenger sendOnChannel:@"flutter/textinput" message:encodedMethodCall]);
702+
}
703+
681704
#pragma mark - TextEditingDelta tests
682705
- (void)testTextEditingDeltasAreGeneratedOnTextInput {
683706
FlutterTextInputView* inputView = [[FlutterTextInputView alloc] initWithOwner:textInputPlugin];

0 commit comments

Comments
 (0)