[iOS] Fix TextInputAction.continueAction sends wrong action to framework (flutter/engine#42615)

## Description

This PR fixes an issue related to text input plugin, on IOS, sending a wrong action string to the engine for `FlutterTextInputActionContinue`.

## Related Issue

Fixes https://github.com/flutter/flutter/issues/126922

## Tests

Adds 1 test.
This commit is contained in:
Bruno Leroux
2023-06-07 22:11:47 +02:00
committed by GitHub
parent 02591dca4d
commit a3843d747d
3 changed files with 29 additions and 2 deletions

View File

@@ -1009,7 +1009,7 @@ static void SetEntryPoint(flutter::Settings* settings, NSString* entrypoint, NSS
actionString = @"TextInputAction.next";
break;
case FlutterTextInputActionContinue:
actionString = @"TextInputAction.continue";
actionString = @"TextInputAction.continueAction";
break;
case FlutterTextInputActionJoin:
actionString = @"TextInputAction.join";

View File

@@ -4,6 +4,7 @@
#import "flutter/shell/common/shell.h"
#import "flutter/shell/platform/darwin/ios/framework/Headers/FlutterEngine.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputDelegate.h"
#import "flutter/shell/platform/darwin/ios/rendering_api_selection.h"
#include "flutter/shell/platform/embedder/embedder.h"
@@ -31,4 +32,7 @@ class ThreadHost;
entrypointArgs:(/*nullable*/ NSArray<NSString*>*)entrypointArgs;
- (const flutter::ThreadHost&)threadHost;
- (void)updateDisplays;
- (void)flutterTextInputView:(FlutterTextInputView*)textInputView
performAction:(FlutterTextInputAction)action
withClient:(int)client;
@end

View File

@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterBinaryMessengerRelay.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterEngine_Test.h"
#import "flutter/shell/platform/darwin/ios/framework/Source/FlutterTextInputPlugin.h"
#import <OCMock/OCMock.h>
@@ -308,7 +310,7 @@ FLUTTER_ASSERT_ARC
withClient:0]);
}
- (void)testIngoresSelectionChangeIfSelectionIsDisabled {
- (void)testIgnoresSelectionChangeIfSelectionIsDisabled {
FlutterTextInputView* inputView = [[FlutterTextInputView alloc] initWithOwner:textInputPlugin];
__block int updateCount = 0;
OCMStub([engine flutterTextInputView:inputView updateEditingClient:0 withState:[OCMArg isNotNil]])
@@ -678,6 +680,27 @@ FLUTTER_ASSERT_ARC
XCTAssertFalse(inputView.isSecureTextEntry);
}
- (void)testInputActionContinueAction {
id mockBinaryMessenger = OCMClassMock([FlutterBinaryMessengerRelay class]);
FlutterEngine* testEngine = [[FlutterEngine alloc] init];
[testEngine setBinaryMessenger:mockBinaryMessenger];
[testEngine runWithEntrypoint:FlutterDefaultDartEntrypoint initialRoute:@"test"];
FlutterTextInputPlugin* inputPlugin =
[[FlutterTextInputPlugin alloc] initWithDelegate:(id<FlutterTextInputDelegate>)testEngine];
FlutterTextInputView* inputView = [[FlutterTextInputView alloc] initWithOwner:inputPlugin];
[testEngine flutterTextInputView:inputView
performAction:FlutterTextInputActionContinue
withClient:123];
FlutterMethodCall* methodCall =
[FlutterMethodCall methodCallWithMethodName:@"TextInputClient.performAction"
arguments:@[ @(123), @"TextInputAction.continueAction" ]];
NSData* encodedMethodCall = [[FlutterJSONMethodCodec sharedInstance] encodeMethodCall:methodCall];
OCMVerify([mockBinaryMessenger sendOnChannel:@"flutter/textinput" message:encodedMethodCall]);
}
#pragma mark - TextEditingDelta tests
- (void)testTextEditingDeltasAreGeneratedOnTextInput {
FlutterTextInputView* inputView = [[FlutterTextInputView alloc] initWithOwner:textInputPlugin];