Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit ea4d76c

Browse files
improve test
1 parent be5e120 commit ea4d76c

File tree

1 file changed

+7
-16
lines changed

1 file changed

+7
-16
lines changed

shell/platform/darwin/macos/framework/Source/FlutterKeyboardManagerUnittests.mm

Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -365,35 +365,26 @@ - (bool)textInputPlugin {
365365
}
366366

367367
- (bool)forwardKeyEventsToSystemWhenComposing {
368-
KeyboardTester* tester = [[KeyboardTester alloc] init];
369-
370-
tester.isComposing = YES;
371-
// Send a down event with composing == YES.
372-
[tester.manager handleEvent:keyDownEvent(0x50)];
368+
KeyboardTester* tester = OCMPartialMock([[KeyboardTester alloc] init]);
373369

374370
NSMutableArray<FlutterAsyncKeyCallback>* channelCallbacks =
375371
[NSMutableArray<FlutterAsyncKeyCallback> array];
376372
NSMutableArray<FlutterAsyncKeyCallback>* embedderCallbacks =
377373
[NSMutableArray<FlutterAsyncKeyCallback> array];
378374
[tester recordEmbedderCallsTo:embedderCallbacks];
379375
[tester recordChannelCallsTo:channelCallbacks];
380-
// TextInputPlugin does not claim the event.
376+
// The event shouldn't propagate further even if TextInputPlugin does not
377+
// claim the event.
381378
[tester respondTextInputWith:NO];
379+
380+
tester.isComposing = YES;
381+
// Send a down event with composing == YES.
382382
[tester.manager handleEvent:keyUpEvent(0x50)];
383383

384384
// Nobody gets the event except for the text input plugin.
385385
EXPECT_EQ([channelCallbacks count], 0u);
386386
EXPECT_EQ([embedderCallbacks count], 0u);
387-
388-
// Send another down event with composing == NO.
389-
tester.isComposing = NO;
390-
[tester respondTextInputWith:YES];
391-
[tester.manager handleEvent:keyDownEvent(0x50)];
392-
// Now the responders get the event.
393-
EXPECT_EQ([channelCallbacks count], 1u);
394-
EXPECT_EQ([embedderCallbacks count], 1u);
395-
embedderCallbacks[0](TRUE);
396-
channelCallbacks[0](TRUE);
387+
OCMVerify(times(1), [tester handleTextInputKeyEvent: checkKeyDownEvent(0x50)]);
397388

398389
return true;
399390
}

0 commit comments

Comments
 (0)