aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/tests
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2018-12-06 12:08:43 -0800
committerGravatar Muxi Yan <mxyan@google.com>2018-12-06 12:08:43 -0800
commit70f34521deaeaf0d783f30d121fd26787135ac04 (patch)
tree5a15946876af9976c3f5214c674a436c6564b5f4 /src/objective-c/tests
parentdfec57a9a9ebfbe92709498074eb184527ef599e (diff)
isolate start: function from proto calls
Diffstat (limited to 'src/objective-c/tests')
-rw-r--r--src/objective-c/tests/InteropTests.m53
1 files changed, 47 insertions, 6 deletions
diff --git a/src/objective-c/tests/InteropTests.m b/src/objective-c/tests/InteropTests.m
index 2492718046..e94fd1493a 100644
--- a/src/objective-c/tests/InteropTests.m
+++ b/src/objective-c/tests/InteropTests.m
@@ -197,7 +197,7 @@ BOOL isRemoteInteropTest(NSString *host) {
- (void)testEmptyUnaryRPCWithV2API {
XCTAssertNotNil([[self class] host]);
- __weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyUnary"];
+ __weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyUnaryWithV2API"];
GPBEmpty *request = [GPBEmpty message];
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
@@ -205,7 +205,7 @@ BOOL isRemoteInteropTest(NSString *host) {
options.PEMRootCertificates = [[self class] PEMRootCertificates];
options.hostNameOverride = [[self class] hostNameOverride];
- [_service
+ GRPCUnaryProtoCall *call = [_service
emptyCallWithMessage:request
responseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil
messageCallback:^(id message) {
@@ -219,6 +219,7 @@ BOOL isRemoteInteropTest(NSString *host) {
XCTAssertNil(error, @"Unexpected error: %@", error);
}]
callOptions:options];
+ [call start];
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
}
@@ -246,6 +247,44 @@ BOOL isRemoteInteropTest(NSString *host) {
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
}
+- (void)testLargeUnaryRPCWithV2API {
+ XCTAssertNotNil([[self class] host]);
+ __weak XCTestExpectation *expectRecvMessage = [self expectationWithDescription:@"LargeUnaryWithV2API received message"];
+ __weak XCTestExpectation *expectRecvComplete = [self expectationWithDescription:@"LargeUnaryWithV2API received complete"];
+
+ RMTSimpleRequest *request = [RMTSimpleRequest message];
+ request.responseType = RMTPayloadType_Compressable;
+ request.responseSize = 314159;
+ request.payload.body = [NSMutableData dataWithLength:271828];
+
+ GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
+ options.transportType = [[self class] transportType];
+ options.PEMRootCertificates = [[self class] PEMRootCertificates];
+ options.hostNameOverride = [[self class] hostNameOverride];
+
+ GRPCUnaryProtoCall *call = [_service
+ unaryCallWithMessage:request
+ responseHandler:[[InteropTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil
+ messageCallback:^(id message) {
+ XCTAssertNotNil(message);
+ if (message) {
+ RMTSimpleResponse *expectedResponse = [RMTSimpleResponse message];
+ expectedResponse.payload.type = RMTPayloadType_Compressable;
+ expectedResponse.payload.body = [NSMutableData dataWithLength:314159];
+ XCTAssertEqualObjects(message, expectedResponse);
+
+ [expectRecvMessage fulfill];
+ }
+ }
+ closeCallback:^(NSDictionary *trailingMetadata, NSError *error) {
+ XCTAssertNil(error, @"Unexpected error: %@", error);
+ [expectRecvComplete fulfill];
+ }]
+ callOptions:options];
+ [call start];
+ [self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
+}
+
- (void)testPacketCoalescing {
XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *expectation = [self expectationWithDescription:@"LargeUnary"];
@@ -473,7 +512,7 @@ BOOL isRemoteInteropTest(NSString *host) {
- (void)testPingPongRPCWithV2API {
XCTAssertNotNil([[self class] host]);
- __weak XCTestExpectation *expectation = [self expectationWithDescription:@"PingPong"];
+ __weak XCTestExpectation *expectation = [self expectationWithDescription:@"PingPongWithV2API"];
NSArray *requests = @[ @27182, @8, @1828, @45904 ];
NSArray *responses = @[ @31415, @9, @2653, @58979 ];
@@ -517,6 +556,7 @@ BOOL isRemoteInteropTest(NSString *host) {
[expectation fulfill];
}]
callOptions:options];
+ [call start];
[call writeMessage:request];
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
@@ -562,7 +602,7 @@ BOOL isRemoteInteropTest(NSString *host) {
- (void)testCancelAfterBeginRPCWithV2API {
XCTAssertNotNil([[self class] host]);
- __weak XCTestExpectation *expectation = [self expectationWithDescription:@"CancelAfterBegin"];
+ __weak XCTestExpectation *expectation = [self expectationWithDescription:@"CancelAfterBeginWithV2API"];
// A buffered pipe to which we never write any value acts as a writer that just hangs.
__block GRPCStreamingProtoCall *call = [_service
@@ -577,6 +617,7 @@ BOOL isRemoteInteropTest(NSString *host) {
[expectation fulfill];
}]
callOptions:nil];
+ [call start];
[call cancel];
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
@@ -650,7 +691,7 @@ BOOL isRemoteInteropTest(NSString *host) {
[completionExpectation fulfill];
}]
callOptions:options];
-
+ [call start];
[call writeMessage:request];
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];
}
@@ -680,7 +721,7 @@ BOOL isRemoteInteropTest(NSString *host) {
[completionExpectation fulfill];
}]
callOptions:options];
-
+ [call start];
[call writeMessage:request];
[call cancel];
[self waitForExpectationsWithTimeout:TEST_TIMEOUT handler:nil];