address comment

pull/20560/head
Muxi Yan 5 years ago
parent ae168166e2
commit 0b2b94e2b8
  1. 4
      src/objective-c/ProtoRPC/ProtoRPC.m
  2. 18
      src/objective-c/tests/InteropTests/InteropTests.m

@ -39,9 +39,9 @@
if ((self = [super init])) {
_responseHandler = handler;
if (dispatchQueue == nil) {
_responseDispatchQueue = dispatchQueue;
} else {
_responseDispatchQueue = dispatch_get_main_queue();
} else {
_responseDispatchQueue = dispatchQueue;
}
}
return self;

@ -567,7 +567,8 @@ static dispatch_once_t initGlobalInterceptorFactory;
XCTAssertNotNil([[self class] host]);
// The test does not work on a remote server since it does not echo a trailer
if ([[self class] isRemoteTest]) return;
__weak XCTestExpectation *expectComplete = [self expectationWithDescription:@"received complete"];
XCTestExpectation *expectComplete = [self expectationWithDescription:@"call complete"];
XCTestExpectation *expectCompleteMainQueue = [self expectationWithDescription:@"main queue call complete"];
RMTSimpleRequest *request = [RMTSimpleRequest message];
request.responseType = RMTPayloadType_Compressable;
@ -600,7 +601,22 @@ static dispatch_once_t initGlobalInterceptorFactory;
[expectComplete fulfill];
}
responseDispatchQueue:dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL)];
__block GRPCUnaryResponseHandler *handlerMainQueue = [[GRPCUnaryResponseHandler alloc]
initWithResponseHandler:^(GPBMessage *response, NSError *error) {
XCTAssertNil(error, @"Unexpected error: %@", error);
RMTSimpleResponse *expectedResponse = [RMTSimpleResponse message];
expectedResponse.payload.type = RMTPayloadType_Compressable;
expectedResponse.payload.body = [NSMutableData dataWithLength:314159];
XCTAssertEqualObjects(response, expectedResponse);
XCTAssertEqualObjects(handlerMainQueue.responseHeaders[@"x-grpc-test-echo-initial"], @"test-header");
XCTAssertEqualObjects(handlerMainQueue.responseTrailers[@"x-grpc-test-echo-trailing-bin"],
trailer_data);
[expectCompleteMainQueue fulfill];
}
responseDispatchQueue:nil];
[[_service unaryCallWithMessage:request responseHandler:handler callOptions:options] start];
[[_service unaryCallWithMessage:request responseHandler:handlerMainQueue callOptions:options] start];
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
}

Loading…
Cancel
Save