@@ -16,7 +16,7 @@ @interface FlutterTextInputView ()
1616@property (nonatomic , copy ) NSString * autofillId;
1717
1818- (void )setEditableTransform : (NSArray *)matrix ;
19- - (BOOL )setTextInputState : (NSDictionary *)state ;
19+ - (void )setTextInputState : (NSDictionary *)state ;
2020- (void )setMarkedRect : (CGRect)markedRect ;
2121- (void )updateEditingState ;
2222- (BOOL )isVisibleToAutofill ;
@@ -211,71 +211,45 @@ - (void)testUITextInputCallsUpdateEditingStateOnce {
211211 XCTAssertEqual (updateCount, 6 );
212212}
213213
214- - (void )testTextChangesTriggerUpdateEditingClient {
214+ - (void )testTextChangesDoNotTriggerUpdateEditingClient {
215215 FlutterTextInputView* inputView = [[FlutterTextInputView alloc ] init ];
216216 inputView.textInputDelegate = engine;
217217
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+ });
228223
229- - (void )testSelectionChangeDoesNotTriggerUpdateEditingClient {
230- FlutterTextInputView* inputView = [[FlutterTextInputView alloc ] init ];
231- inputView.textInputDelegate = engine;
224+ [inputView.text setString: @" BEFORE" ];
225+ XCTAssertEqual (updateCount, 0 );
232226
233- [inputView.text setString: @" SELECTION" ];
234227 inputView.markedTextRange = nil ;
235228 inputView.selectedTextRange = nil ;
229+ XCTAssertEqual (updateCount, 1 );
236230
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 );
240237
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
242243 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 );
275245
276- shouldUpdate = [inputView
246+ // Composing region changes don't trigger an update.
247+ [inputView
277248 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 );
279253}
280254
281255- (void )testUITextInputAvoidUnnecessaryUndateEditingClientCalls {
0 commit comments