|
|
|
@ -457,57 +457,4 @@ |
|
|
|
|
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
- (void)testAlternateDispatchQueue { |
|
|
|
|
XCTAssertNotNil(self.class.host); |
|
|
|
|
NSNumber *kPayloadSize = @256; |
|
|
|
|
id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:kPayloadSize |
|
|
|
|
requestedResponseSize:kPayloadSize]; |
|
|
|
|
|
|
|
|
|
__weak XCTestExpectation *expectation1 = [self expectationWithDescription:@"AlternateDispatchQueue1"]; |
|
|
|
|
|
|
|
|
|
// Set the default dispatch queue |
|
|
|
|
NSString *queue_label = @"test.queue1"; |
|
|
|
|
dispatch_queue_t queue = dispatch_queue_create([queue_label UTF8String], DISPATCH_QUEUE_SERIAL); |
|
|
|
|
GRXBufferedPipe *requestsBuffer1 = [[GRXBufferedPipe alloc] init]; |
|
|
|
|
|
|
|
|
|
[requestsBuffer1 writeValue:request]; |
|
|
|
|
|
|
|
|
|
[_service fullDuplexCallWithRequestsWriter:requestsBuffer1 |
|
|
|
|
eventHandler:^(BOOL done, |
|
|
|
|
RMTStreamingOutputCallResponse *response, |
|
|
|
|
NSError *error) { |
|
|
|
|
XCTAssertNil(error, @"Finished with unexpected error: %@", error); |
|
|
|
|
XCTAssertTrue(done || response, @"Event handler called without an event."); |
|
|
|
|
NSString *label = [NSString stringWithUTF8String:dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL)]; |
|
|
|
|
NSLog(@"main queue label:%@", label); |
|
|
|
|
NSString *main_queue_label = [NSString stringWithUTF8String:dispatch_queue_get_label(dispatch_get_main_queue())]; |
|
|
|
|
XCTAssert([label isEqualToString:main_queue_label]); |
|
|
|
|
|
|
|
|
|
[expectation1 fulfill]; |
|
|
|
|
}]; |
|
|
|
|
|
|
|
|
|
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; |
|
|
|
|
|
|
|
|
|
// Test overriding default queue with another queue |
|
|
|
|
__weak XCTestExpectation *expectation2 = [self expectationWithDescription:@"AlternateDispatchQueue2"]; |
|
|
|
|
GRXBufferedPipe *requestsBuffer2 = [[GRXBufferedPipe alloc] init]; |
|
|
|
|
|
|
|
|
|
[requestsBuffer2 writeValue:request]; |
|
|
|
|
|
|
|
|
|
GRPCProtoCall *rpc = [_service RPCToFullDuplexCallWithRequestsWriter:requestsBuffer2 |
|
|
|
|
eventHandler:^(BOOL done, |
|
|
|
|
RMTStreamingOutputCallResponse *response, |
|
|
|
|
NSError *error) { |
|
|
|
|
XCTAssertNil(error, @"Finished with unexpected error: %@", error); |
|
|
|
|
XCTAssertTrue(done || response, @"Event handler called without an event."); |
|
|
|
|
NSString *label = [NSString stringWithUTF8String:dispatch_queue_get_label(DISPATCH_CURRENT_QUEUE_LABEL)]; |
|
|
|
|
XCTAssert([label isEqualToString:queue_label]); |
|
|
|
|
[expectation2 fulfill]; |
|
|
|
|
}]; |
|
|
|
|
[rpc setResponseDispatchQueue:queue]; |
|
|
|
|
[rpc start]; |
|
|
|
|
|
|
|
|
|
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil]; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@end |
|
|
|
|