84 {
85 __block int registerUndoCount = 0;
86 __block void (^undoHandler)(
id target);
88 .andDo(^(NSInvocation* invocation) {
89 registerUndoCount++;
90 __weak void (^handler)(
id target);
91 [invocation retainArguments];
92 [invocation getArgument:&handler atIndex:3];
93 undoHandler = handler;
94 });
95 __block int removeAllActionsCount = 0;
97 .andDo(^(NSInvocation* invocation) {
98 removeAllActionsCount++;
99 });
100 __block int undoCount = 0;
101 OCMStub([
self.
undoManager undo]).andDo(^(NSInvocation* invocation) {
102 undoCount++;
104 });
105
106
109 arguments:@{@"canUndo" : @NO, @"canRedo" : @NO}];
110 [self.undoManagerPlugin handleMethodCall:setUndoStateCall
111 result:^(id _Nullable result){
112 }];
113 XCTAssertEqual(1, removeAllActionsCount);
114 XCTAssertEqual(0, registerUndoCount);
115
116
117 setUndoStateCall =
119 arguments:@{@"canUndo" : @YES, @"canRedo" : @NO}];
120 [self.undoManagerPlugin handleMethodCall:setUndoStateCall
121 result:^(id _Nullable result){
122 }];
123 XCTAssertEqual(2, removeAllActionsCount);
124 XCTAssertEqual(1, registerUndoCount);
125
126
130 XCTAssertEqual(2, registerUndoCount);
131
132
136 XCTAssertEqual(3, registerUndoCount);
137
138
139 setUndoStateCall =
141 arguments:@{@"canUndo" : @NO, @"canRedo" : @YES}];
142 [self.undoManagerPlugin handleMethodCall:setUndoStateCall
143 result:^(id _Nullable result){
144 }];
145 XCTAssertEqual(3, removeAllActionsCount);
146 XCTAssertEqual(5, registerUndoCount);
147 XCTAssertEqual(1, undoCount);
148
149
153}
instancetype methodCallWithMethodName:arguments:(NSString *method,[arguments] id _Nullable arguments)
FakeFlutterUndoManagerDelegate * undoManagerDelegate
FlutterUndoManagerPlugin * undoManagerPlugin
NSUndoManager * undoManager
SIT bool any(const Vec< 1, T > &x)