| 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 55 of file FlutterTextInputPluginTest.mm.

## Method Documentation

## ◆ testClearClientDuringComposing

- (bool) testClearClientDuringComposing |  |  |

Definition at line 69 of file FlutterTextInputPluginTest.mm.

352 {
353 // Set up FlutterTextInputPlugin.
354 id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
355 id binaryMessengerMock = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
356 OCMStub( // NOLINT(google-objc-avoid-throwing-exception)
357 [engineMock binaryMessenger])
358 .andReturn(binaryMessengerMock);
359 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engineMock
360 nibName:@""
361 bundle:nil];
362 FlutterTextInputPluginTestDelegate* delegate =
363 [[FlutterTextInputPluginTestDelegate alloc] initWithBinaryMessenger:binaryMessengerMock
364 viewController:viewController];
365
366 FlutterTextInputPlugin* plugin = [[FlutterTextInputPlugin alloc] initWithDelegate:delegate];
367
368 // Set input client 1.
369 NSDictionary* setClientConfig = @{
370 @"viewId" : @(kViewId),
371 @"inputAction" : @"action",
372 @"inputType" : @{@"name" : @"inputName"},
373 };
374 [plugin handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"TextInput.setClient"
375 arguments:@[ @(1), setClientConfig ]]
376 result:^(id){
377 }];
378
379 // Set editing state with an active composing range.
380 [plugin handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"TextInput.setEditingState"
381 arguments:@{
382 @"text" : @"Text",
383 @"selectionBase" : @(0),
384 @"selectionExtent" : @(0),
385 @"composingBase" : @(0),
386 @"composingExtent" : @(1),
387 }]
388 result:^(id){
389 }];
390
391 // Verify composing range is (0, 1).
392 NSDictionary* editingState = [plugin editingState];
393 EXPECT_EQ([editingState[@"composingBase"] intValue], 0);
394 EXPECT_EQ([editingState[@"composingExtent"] intValue], 1);
395
396 // Clear input client.
397 [plugin handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"TextInput.clearClient"
398 arguments:@[]]
399 result:^(id){
400 }];
401
402 // Verify composing range is collapsed.
403 editingState = [plugin editingState];
404 EXPECT_EQ([editingState[@"composingBase"] intValue], [editingState[@"composingExtent"] intValue]);
405 return true;
406 }
kViewId
static const FlutterViewIdentifier kViewId
Definition: FlutterTextInputPluginTest.mm:69
FlutterMethodCall
Definition: FlutterCodecs.h:221
+[FlutterMethodCall methodCallWithMethodName:arguments:]
instancetype methodCallWithMethodName:arguments:(NSString *method,[arguments] id _Nullable arguments)
FlutterTextInputPlugin
Definition: FlutterTextInputPlugin.h:42
-[FlutterTextInputPlugin handleMethodCall:result:]
void handleMethodCall:result:(FlutterMethodCall *call,[result] FlutterResult result)
-[FlutterTextInputPlugin editingState]
NSDictionary * editingState()
FlutterTextInputPluginTestDelegate
Definition: FlutterTextInputPluginTest.mm:60
FlutterViewController
Definition: FlutterViewController.h:73
flutter::testing::CreateMockFlutterEngine
id CreateMockFlutterEngine(NSString *pasteboardString)
Definition: FlutterEngineTestUtils.mm:76
FlutterBinaryMessenger-p
Definition: FlutterBinaryMessenger.h:49

References _binaryMessenger, and FlutterTextInputPluginTestDelegate::_viewController.

## ◆ testEmptyCompositionRange

- (bool) testEmptyCompositionRange |  |  |

Definition at line 69 of file FlutterTextInputPluginTest.mm.

96 {
97 id engineMock = flutter::testing::CreateMockFlutterEngine(@"");
98 id binaryMessengerMock = OCMProtocolMock(@protocol(FlutterBinaryMessenger));
99 OCMStub( // NOLINT(google-objc-avoid-throwing-exception)
100 [engineMock binaryMessenger])
101 .andReturn(binaryMessengerMock);
102
103 FlutterViewController* viewController = [[FlutterViewController alloc] initWithEngine:engineMock
104 nibName:@""
105 bundle:nil];
106
107 FlutterTextInputPluginTestDelegate* delegate =
108 [[FlutterTextInputPluginTestDelegate alloc] initWithBinaryMessenger:binaryMessengerMock
109 viewController:viewController];
110
111 FlutterTextInputPlugin* plugin = [[FlutterTextInputPlugin alloc] initWithDelegate:delegate];
112
113 NSDictionary* setClientConfig = @{
114 @"viewId" : @(kViewId),
115 @"inputAction" : @"action",
116 @"inputType" : @{@"name" : @"inputName"},
117 };
118 [plugin handleMethodCall:[FlutterMethodCall methodCallWithMethodName:@"TextInput.setClient"
119 arguments:@[ @(1), setClientConfig ]]
120 result:^(id){
121 }];
122
123 FlutterMethodCall* call = [FlutterMethodCall methodCallWithMethodName:@"TextInput.setEditingState"
124 arguments:@{
125 @"text" : @"Text",
126 @"selectionBase" : @(0),
127 @"selectionExtent" : @(0),
128 @"composingBase" : @(-1),
129 @"composingExtent" : @(-1),
130 }];
131
132 [plugin handleMethodCall:call
133 result:^(id){
134 }];
135
136 // Verify editing state was set.
137 NSDictionary* editingState = [plugin editingState];
138 EXPECT_STREQ([editingState[@"text"] UTF8String], "Text");
139 EXPECT_STREQ([editingState[@"selectionAffinity"] UTF8String], "TextAffinity.upstream");
140 EXPECT_FALSE([editingState[@"selectionIsDirectional"] boolValue]);
141 EXPECT_EQ([editingState[@"selectionBase"] intValue], 0);
142 EXPECT_EQ([editingState[@"selectionExtent"] intValue], 0);
143 EXPECT_EQ([editingState[@"composingBase"] intValue], -1);
144 EXPECT_EQ([editingState[@"composingExtent"] intValue], -1);
145 return true;
146 }

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

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