@@ -16,7 +16,7 @@ @interface FlutterTextInputView ()
16
16
@property (nonatomic , copy ) NSString * autofillId;
17
17
18
18
- (void )setEditableTransform : (NSArray *)matrix ;
19
- - (BOOL )setTextInputState : (NSDictionary *)state ;
19
+ - (void )setTextInputState : (NSDictionary *)state ;
20
20
- (void )setMarkedRect : (CGRect)markedRect ;
21
21
- (void )updateEditingState ;
22
22
- (BOOL )isVisibleToAutofill ;
@@ -211,71 +211,45 @@ - (void)testUITextInputCallsUpdateEditingStateOnce {
211
211
XCTAssertEqual (updateCount, 6 );
212
212
}
213
213
214
- - (void )testTextChangesTriggerUpdateEditingClient {
214
+ - (void )testTextChangesDoNotTriggerUpdateEditingClient {
215
215
FlutterTextInputView* inputView = [[FlutterTextInputView alloc ] init ];
216
216
inputView.textInputDelegate = engine;
217
217
218
- [inputView.text setString: @" BEFORE" ];
219
- inputView.markedTextRange = nil ;
220
- inputView.selectedTextRange = nil ;
221
-
222
- // Text changes trigger update.
223
- XCTAssertTrue ([inputView setTextInputState: @{@" text" : @" AFTER" }]);
224
-
225
- // Don't send anything if there's nothing new.
226
- XCTAssertFalse ([inputView setTextInputState: @{@" text" : @" AFTER" }]);
227
- }
218
+ __block int updateCount = 0 ;
219
+ OCMStub ([engine updateEditingClient: 0 withState: [OCMArg isNotNil ]])
220
+ .andDo (^(NSInvocation * invocation) {
221
+ updateCount++;
222
+ });
228
223
229
- - (void )testSelectionChangeDoesNotTriggerUpdateEditingClient {
230
- FlutterTextInputView* inputView = [[FlutterTextInputView alloc ] init ];
231
- inputView.textInputDelegate = engine;
224
+ [inputView.text setString: @" BEFORE" ];
225
+ XCTAssertEqual (updateCount, 0 );
232
226
233
- [inputView.text setString: @" SELECTION" ];
234
227
inputView.markedTextRange = nil ;
235
228
inputView.selectedTextRange = nil ;
229
+ XCTAssertEqual (updateCount, 1 );
236
230
237
- BOOL shouldUpdate = [inputView
238
- setTextInputState: @{@" text" : @" SELECTION" , @" selectionBase" : @0 , @" selectionExtent" : @3 }];
239
- XCTAssertFalse (shouldUpdate);
231
+ // Text changes don't trigger an update.
232
+ XCTAssertEqual (updateCount, 1 );
233
+ [inputView setTextInputState: @{@" text" : @" AFTER" }];
234
+ XCTAssertEqual (updateCount, 1 );
235
+ [inputView setTextInputState: @{@" text" : @" AFTER" }];
236
+ XCTAssertEqual (updateCount, 1 );
240
237
241
- shouldUpdate = [inputView
238
+ // Selection changes don't trigger an update.
239
+ [inputView
240
+ setTextInputState: @{@" text" : @" SELECTION" , @" selectionBase" : @0 , @" selectionExtent" : @3 }];
241
+ XCTAssertEqual (updateCount, 1 );
242
+ [inputView
242
243
setTextInputState: @{@" text" : @" SELECTION" , @" selectionBase" : @1 , @" selectionExtent" : @3 }];
243
- XCTAssertFalse (shouldUpdate);
244
-
245
- shouldUpdate = [inputView
246
- setTextInputState: @{@" text" : @" SELECTION" , @" selectionBase" : @1 , @" selectionExtent" : @2 }];
247
- XCTAssertFalse (shouldUpdate);
248
-
249
- // Don't send anything if there's nothing new.
250
- shouldUpdate = [inputView
251
- setTextInputState: @{@" text" : @" SELECTION" , @" selectionBase" : @1 , @" selectionExtent" : @2 }];
252
- XCTAssertFalse (shouldUpdate);
253
- }
254
-
255
- - (void )testComposingChangeDoesNotTriggerUpdateEditingClient {
256
- FlutterTextInputView* inputView = [[FlutterTextInputView alloc ] init ];
257
- inputView.textInputDelegate = engine;
258
-
259
- // Reset to test marked text.
260
- [inputView.text setString: @" COMPOSING" ];
261
- inputView.markedTextRange = nil ;
262
- inputView.selectedTextRange = nil ;
263
-
264
- BOOL shouldUpdate = [inputView
265
- setTextInputState: @{@" text" : @" COMPOSING" , @" composingBase" : @0 , @" composingExtent" : @3 }];
266
- XCTAssertFalse (shouldUpdate);
267
-
268
- shouldUpdate = [inputView
269
- setTextInputState: @{@" text" : @" COMPOSING" , @" composingBase" : @1 , @" composingExtent" : @3 }];
270
- XCTAssertFalse (shouldUpdate);
271
-
272
- shouldUpdate = [inputView
273
- setTextInputState: @{@" text" : @" COMPOSING" , @" composingBase" : @1 , @" composingExtent" : @2 }];
274
- XCTAssertFalse (shouldUpdate);
244
+ XCTAssertEqual (updateCount, 1 );
275
245
276
- shouldUpdate = [inputView
246
+ // Composing region changes don't trigger an update.
247
+ [inputView
277
248
setTextInputState: @{@" text" : @" COMPOSING" , @" composingBase" : @1 , @" composingExtent" : @2 }];
278
- XCTAssertFalse (shouldUpdate);
249
+ XCTAssertEqual (updateCount, 1 );
250
+ [inputView
251
+ setTextInputState: @{@" text" : @" COMPOSING" , @" composingBase" : @1 , @" composingExtent" : @3 }];
252
+ XCTAssertEqual (updateCount, 1 );
279
253
}
280
254
281
255
- (void )testUITextInputAvoidUnnecessaryUndateEditingClientCalls {
0 commit comments