44 {
45 __block NSMutableArray<id>* messages = [[NSMutableArray<id> alloc] init];
47 __block NSMutableArray<NSNumber*>* responses = [[NSMutableArray<NSNumber*> alloc] init];
48
50 OCMStub([mockKeyEventChannel sendMessage:[OCMArg
any] reply:[OCMArg
any]])
51 .andDo((^(NSInvocation* invocation) {
52 [invocation retainArguments];
54 [invocation getArgument:&message atIndex:2];
55 [messages addObject:message];
56
58 [invocation getArgument:&callback atIndex:3];
59 NSDictionary* keyMessage = @{
60 @"handled" : @(next_response),
61 };
63 }));
64
65
70 [responses addObject:@(handled)];
71 }];
72
73 XCTAssertEqual([messages
count], 1u);
76 XCTAssertEqual([[messages lastObject][@"keyCode"] intValue], UIKeyboardHIDUsageKeyboardA);
77 XCTAssertEqual([[messages lastObject][@"modifiers"] intValue], 0x0);
80
81 XCTAssertEqual([responses
count], 1u);
82 XCTAssertEqual([[responses lastObject] boolValue],
TRUE);
83
84 [messages removeAllObjects];
85 [responses removeAllObjects];
86
87
88 next_response =
FALSE;
91 [responses addObject:@(handled)];
92 }];
93
94 XCTAssertEqual([messages
count], 1u);
97 XCTAssertEqual([[messages lastObject][@"keyCode"] intValue], UIKeyboardHIDUsageKeyboardA);
98 XCTAssertEqual([[messages lastObject][@"modifiers"] intValue], 0x0);
99
100 XCTAssertEqual([responses
count], 1u);
101 XCTAssertEqual([[responses lastObject] boolValue],
FALSE);
102
103 [messages removeAllObjects];
104 [responses removeAllObjects];
105}
NS_ASSUME_NONNULL_BEGIN typedef void(^ FlutterReply)(id _Nullable reply)
FlKeyEvent uint64_t FlKeyResponderAsyncCallback callback
void handlePress:callback:(nonnull FlutterUIPressProxy *press, [callback] ios(13.4) API_AVAILABLE)
#define XCTAssertStrEqual(value, expected)
SIT bool any(const Vec< 1, T > &x)