Skip to content

Commit 397f851

Browse files
committed
Update test case
1 parent e21e9f1 commit 397f851

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

Tests/Tests/SDUtilsTests.m

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -157,35 +157,48 @@ - (void)testSDScaledImageForKey {
157157
- (void)testSDCallbackQueue {
158158
XCTestExpectation *expectation1 = [self expectationWithDescription:@"SDCallbackQueue SafeExecute works"];
159159
XCTestExpectation *expectation2 = [self expectationWithDescription:@"SDCallbackQueue Dispatch works"];
160+
XCTestExpectation *expectation3 = [self expectationWithDescription:@"SDCallbackQueue Invoke works"];
160161
dispatch_queue_t queue = dispatch_queue_create("testSDCallbackQueue", NULL);
161162
SDCallbackQueue *callbackQueue = [[SDCallbackQueue alloc] initWithDispatchQueue:queue];
162-
__block BOOL called1 = NO;
163+
__block BOOL called = NO;
163164
[callbackQueue sync:^{
164-
called1 = YES;
165+
called = YES;
165166
}];
166-
expect(called1).beTruthy();
167+
expect(called).beTruthy();
167168

168-
__block BOOL called2 = NO;
169+
__block BOOL called1 = NO;
169170
callbackQueue.policy = SDCallbackPolicySafeExecute;
170171
dispatch_async(queue, ^{
171172
// Should execute in sync
172173
[callbackQueue async:^{
173-
called2 = YES;
174+
called1 = YES;
174175
[expectation1 fulfill];
175176
}];
176-
expect(called2).beTruthy();
177+
expect(called1).beTruthy();
177178
});
178179

179180
SDCallbackQueue *callbackQueue2 = [[SDCallbackQueue alloc] initWithDispatchQueue:queue];
180-
__block BOOL called3 = NO;
181+
__block BOOL called2 = NO;
181182
callbackQueue2.policy = SDCallbackPolicyDispatch;
182183
dispatch_async(queue, ^{
183184
// Should execute in async
184185
[callbackQueue2 async:^{
185-
called3 = YES;
186+
called2 = YES;
186187
[expectation2 fulfill];
187188
}];
188-
expect(called3).beFalsy();
189+
expect(called2).beFalsy();
190+
});
191+
192+
SDCallbackQueue *callbackQueue3 = [[SDCallbackQueue alloc] initWithDispatchQueue:queue];
193+
__block BOOL called3 = NO;
194+
callbackQueue3.policy = SDCallbackPolicyInvoke;
195+
dispatch_async(queue, ^{
196+
// Should execute in sync
197+
[callbackQueue3 async:^{
198+
called3 = YES;
199+
[expectation3 fulfill];
200+
}];
201+
expect(called3).beTruthy();
189202
});
190203

191204
[self waitForExpectationsWithCommonTimeout];

0 commit comments

Comments
 (0)