| Flutter macOS Embedder |

Instance Methods | List of all members
FlutterInputPluginTestObjc Class Reference
Inheritance diagram for FlutterInputPluginTestObjc:

## Instance Methods
(bool) | - testEmptyCompositionRange
(bool) | - testClearClientDuringComposing

## Detailed Description

Definition at line 51 of file FlutterTextInputPluginTest.mm.

## Method Documentation

## ◆ testClearClientDuringComposing

- (bool) testClearClientDuringComposing |  |  |

Definition at line 298 of file FlutterTextInputPluginTest.mm.

298 {
299 // Set up FlutterTextInputPlugin.
300 id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
301 id binaryMessengerMock = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
302 OCMStub( // NOLINT(google-objc-avoid-throwing-exception)
303 [engineMock binaryMessenger])
304 .andReturn(binaryMessengerMock);
305 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engineMock
306 nibName:@""
307 bundle:nil];
308 FlutterTextInputPlugin* plugin =
309 [[FlutterTextInputPlugin alloc] initWithViewController:viewController];
310
311 // Set input client 1.
312 NSDictionary* setClientConfig = @{
313 @"inputAction" : @"action",
314 @"inputType" : @{@"name" : @"inputName"},
315 };
316 [plugin handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"TextInput.setClient"
317 arguments:@[ @(1), setClientConfig ]]
318 result:^(id){
319 }];
320
321 // Set editing state with an active composing range.
322 [plugin handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"TextInput.setEditingState"
323 arguments:@{
324 @"text" : @"Text",
325 @"selectionBase" : @(0),
326 @"selectionExtent" : @(0),
327 @"composingBase" : @(0),
328 @"composingExtent" : @(1),
329 }]
330 result:^(id){
331 }];
332
333 // Verify composing range is (0, 1).
334 NSDictionary* editingState = [plugin editingState];
335 EXPECT_EQ([editingState[@"composingBase"] intValue], 0);
336 EXPECT_EQ([editingState[@"composingExtent"] intValue], 1);
337
338 // Clear input client.
339 [plugin handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"TextInput.clearClient"
340 arguments:@[]]
341 result:^(id){
342 }];
343
344 // Verify composing range is collapsed.
345 editingState = [plugin editingState];
346 EXPECT_EQ([editingState[@"composingBase"] intValue], [editingState[@"composingExtent"] intValue]);
347 return true;
348 }

References flutter::testing::CreateMockFlutterEngine(), FlutterTextInputPlugin::editingState, FlutterTextInputPlugin::handleMethodCall:result:, and FlutterMethodCall::methodCallWithMethodName:arguments:.

## ◆ testEmptyCompositionRange

- (bool) testEmptyCompositionRange |  |  |

Definition at line 58 of file FlutterTextInputPluginTest.mm.

58 {
59 id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
60 id binaryMessengerMock = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
61 OCMStub( // NOLINT(google-objc-avoid-throwing-exception)
62 [engineMock binaryMessenger])
63 .andReturn(binaryMessengerMock);
64
65 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engineMock
66 nibName:@""
67 bundle:nil];
68
69 FlutterTextInputPlugin* plugin =
70 [[FlutterTextInputPlugin alloc] initWithViewController:viewController];
71
72 NSDictionary* setClientConfig = @{
73 @"inputAction" : @"action",
74 @"inputType" : @{@"name" : @"inputName"},
75 };
76 [plugin handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"TextInput.setClient"
77 arguments:@[ @(1), setClientConfig ]]
78 result:^(id){
79 }];
80
81 FlutterMethodCall* call = [FlutterMethodCall methodCallWithMethodName:@"TextInput.setEditingState"
82 arguments:@{
83 @"text" : @"Text",
84 @"selectionBase" : @(0),
85 @"selectionExtent" : @(0),
86 @"composingBase" : @(-1),
87 @"composingExtent" : @(-1),
88 }];
89
90 [plugin handleMethodCall:call
91 result:^(id){
92 }];
93
94 // Verify editing state was set.
95 NSDictionary* editingState = [plugin editingState];
96 EXPECT_STREQ([editingState[@"text"] UTF8String], "Text");
97 EXPECT_STREQ([editingState[@"selectionAffinity"] UTF8String], "TextAffinity.upstream");
98 EXPECT_FALSE([editingState[@"selectionIsDirectional"] boolValue]);
99 EXPECT_EQ([editingState[@"selectionBase"] intValue], 0);
100 EXPECT_EQ([editingState[@"selectionExtent"] intValue], 0);
101 EXPECT_EQ([editingState[@"composingBase"] intValue], -1);
102 EXPECT_EQ([editingState[@"composingExtent"] intValue], -1);
103 return true;
104 }

References flutter::testing::CreateMockFlutterEngine(), FlutterTextInputPlugin::editingState, FlutterTextInputPlugin::handleMethodCall:result:, and FlutterMethodCall::methodCallWithMethodName:arguments:.

The documentation for this class was generated from the following file:

- shell/platform/darwin/macos/framework/Source/FlutterTextInputPluginTest.mm

+[FlutterMethodCall methodCallWithMethodName:arguments:]
instancetype methodCallWithMethodName:arguments:(NSString *method,[arguments] id _Nullable arguments)
-[FlutterTextInputPlugin handleMethodCall:result:]
void handleMethodCall:result:(FlutterMethodCall *call,[result] FlutterResult result)
FlutterViewController
Definition: FlutterViewController.h:62
flutter::testing::CreateMockFlutterEngine
id CreateMockFlutterEngine(NSString *pasteboardString)
Definition: FlutterEngineTestUtils.mm:47
-[FlutterTextInputPlugin editingState]
NSDictionary * editingState()
FlutterMethodCall
Definition: FlutterCodecs.h:220
FlutterTextInputPlugin
Definition: FlutterTextInputPlugin.h:29
FlutterBinaryMessenger-p
Definition: FlutterBinaryMessenger.h:48