aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/tests
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2018-12-06 22:41:03 -0800
committerGravatar Muxi Yan <mxyan@google.com>2018-12-06 22:41:03 -0800
commitf0f6e03212837c67d7e078e6f33074e80aa4bcc0 (patch)
tree28cf8e66afe60a741dda4fe07db29ff65dac6919 /src/objective-c/tests
parent1a9404876ce0315fc05fe82465dc389600db0965 (diff)
clang-format
Diffstat (limited to 'src/objective-c/tests')
-rw-r--r--src/objective-c/tests/ChannelTests/ChannelTests.m49
-rw-r--r--src/objective-c/tests/InteropTests.m73
2 files changed, 59 insertions, 63 deletions
diff --git a/src/objective-c/tests/ChannelTests/ChannelTests.m b/src/objective-c/tests/ChannelTests/ChannelTests.m
index 7c80868c2c..df78e8b116 100644
--- a/src/objective-c/tests/ChannelTests/ChannelTests.m
+++ b/src/objective-c/tests/ChannelTests/ChannelTests.m
@@ -20,8 +20,8 @@
#import "../../GRPCClient/GRPCCallOptions.h"
#import "../../GRPCClient/private/GRPCChannel.h"
-#import "../../GRPCClient/private/GRPCChannelPool.h"
#import "../../GRPCClient/private/GRPCChannelPool+Test.h"
+#import "../../GRPCClient/private/GRPCChannelPool.h"
#import "../../GRPCClient/private/GRPCCompletionQueue.h"
#import "../../GRPCClient/private/GRPCWrappedCall.h"
@@ -40,13 +40,12 @@ static NSString *kDummyPath = @"/dummy/path";
- (void)testPooledChannelCreatingChannel {
GRPCCallOptions *options = [[GRPCCallOptions alloc] init];
- GRPCChannelConfiguration *config = [[GRPCChannelConfiguration alloc] initWithHost:kDummyHost
- callOptions:options];
+ GRPCChannelConfiguration *config =
+ [[GRPCChannelConfiguration alloc] initWithHost:kDummyHost callOptions:options];
GRPCPooledChannel *channel = [[GRPCPooledChannel alloc] initWithChannelConfiguration:config];
GRPCCompletionQueue *cq = [GRPCCompletionQueue completionQueue];
- GRPCWrappedCall *wrappedCall = [channel wrappedCallWithPath:kDummyPath
- completionQueue:cq
- callOptions:options];
+ GRPCWrappedCall *wrappedCall =
+ [channel wrappedCallWithPath:kDummyPath completionQueue:cq callOptions:options];
XCTAssertNotNil(channel.wrappedChannel);
(void)wrappedCall;
}
@@ -54,26 +53,22 @@ static NSString *kDummyPath = @"/dummy/path";
- (void)testTimedDestroyChannel {
const NSTimeInterval kDestroyDelay = 1.0;
GRPCCallOptions *options = [[GRPCCallOptions alloc] init];
- GRPCChannelConfiguration *config = [[GRPCChannelConfiguration alloc] initWithHost:kDummyHost
- callOptions:options];
- GRPCPooledChannel *channel = [[GRPCPooledChannel alloc] initWithChannelConfiguration:config
- destroyDelay:kDestroyDelay];
+ GRPCChannelConfiguration *config =
+ [[GRPCChannelConfiguration alloc] initWithHost:kDummyHost callOptions:options];
+ GRPCPooledChannel *channel =
+ [[GRPCPooledChannel alloc] initWithChannelConfiguration:config destroyDelay:kDestroyDelay];
GRPCCompletionQueue *cq = [GRPCCompletionQueue completionQueue];
GRPCWrappedCall *wrappedCall;
GRPCChannel *wrappedChannel;
@autoreleasepool {
- wrappedCall = [channel wrappedCallWithPath:kDummyPath
- completionQueue:cq
- callOptions:options];
+ wrappedCall = [channel wrappedCallWithPath:kDummyPath completionQueue:cq callOptions:options];
XCTAssertNotNil(channel.wrappedChannel);
// Unref and ref channel immediately; expect using the same raw channel.
wrappedChannel = channel.wrappedChannel;
wrappedCall = nil;
- wrappedCall = [channel wrappedCallWithPath:kDummyPath
- completionQueue:cq
- callOptions:options];
+ wrappedCall = [channel wrappedCallWithPath:kDummyPath completionQueue:cq callOptions:options];
XCTAssertEqual(channel.wrappedChannel, wrappedChannel);
// Unref and ref channel after destroy delay; expect a new raw channel.
@@ -81,23 +76,20 @@ static NSString *kDummyPath = @"/dummy/path";
}
sleep(kDestroyDelay + 1);
XCTAssertNil(channel.wrappedChannel);
- wrappedCall = [channel wrappedCallWithPath:kDummyPath
- completionQueue:cq
- callOptions:options];
+ wrappedCall = [channel wrappedCallWithPath:kDummyPath completionQueue:cq callOptions:options];
XCTAssertNotEqual(channel.wrappedChannel, wrappedChannel);
}
- (void)testDisconnect {
const NSTimeInterval kDestroyDelay = 1.0;
GRPCCallOptions *options = [[GRPCCallOptions alloc] init];
- GRPCChannelConfiguration *config = [[GRPCChannelConfiguration alloc] initWithHost:kDummyHost
- callOptions:options];
- GRPCPooledChannel *channel = [[GRPCPooledChannel alloc] initWithChannelConfiguration:config
- destroyDelay:kDestroyDelay];
+ GRPCChannelConfiguration *config =
+ [[GRPCChannelConfiguration alloc] initWithHost:kDummyHost callOptions:options];
+ GRPCPooledChannel *channel =
+ [[GRPCPooledChannel alloc] initWithChannelConfiguration:config destroyDelay:kDestroyDelay];
GRPCCompletionQueue *cq = [GRPCCompletionQueue completionQueue];
- GRPCWrappedCall *wrappedCall = [channel wrappedCallWithPath:kDummyPath
- completionQueue:cq
- callOptions:options];
+ GRPCWrappedCall *wrappedCall =
+ [channel wrappedCallWithPath:kDummyPath completionQueue:cq callOptions:options];
XCTAssertNotNil(channel.wrappedChannel);
// Disconnect; expect wrapped channel to be dropped
@@ -106,9 +98,8 @@ static NSString *kDummyPath = @"/dummy/path";
// Create a new call and unref the old call; confirm that destroy of the old call does not make
// the channel disconnect, even after the destroy delay.
- GRPCWrappedCall *wrappedCall2 = [channel wrappedCallWithPath:kDummyPath
- completionQueue:cq
- callOptions:options];
+ GRPCWrappedCall *wrappedCall2 =
+ [channel wrappedCallWithPath:kDummyPath completionQueue:cq callOptions:options];
XCTAssertNotNil(channel.wrappedChannel);
GRPCChannel *wrappedChannel = channel.wrappedChannel;
wrappedCall = nil;
diff --git a/src/objective-c/tests/InteropTests.m b/src/objective-c/tests/InteropTests.m
index d17a07f929..3665e9705d 100644
--- a/src/objective-c/tests/InteropTests.m
+++ b/src/objective-c/tests/InteropTests.m
@@ -249,8 +249,10 @@ BOOL isRemoteInteropTest(NSString *host) {
- (void)testLargeUnaryRPCWithV2API {
XCTAssertNotNil([[self class] host]);
- __weak XCTestExpectation *expectRecvMessage = [self expectationWithDescription:@"LargeUnaryWithV2API received message"];
- __weak XCTestExpectation *expectRecvComplete = [self expectationWithDescription:@"LargeUnaryWithV2API received complete"];
+ __weak XCTestExpectation *expectRecvMessage =
+ [self expectationWithDescription:@"LargeUnaryWithV2API received message"];
+ __weak XCTestExpectation *expectRecvComplete =
+ [self expectationWithDescription:@"LargeUnaryWithV2API received complete"];
RMTSimpleRequest *request = [RMTSimpleRequest message];
request.responseType = RMTPayloadType_Compressable;
@@ -263,24 +265,26 @@ BOOL isRemoteInteropTest(NSString *host) {
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];
+ 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];
}
@@ -602,7 +606,8 @@ BOOL isRemoteInteropTest(NSString *host) {
- (void)testCancelAfterBeginRPCWithV2API {
XCTAssertNotNil([[self class] host]);
- __weak XCTestExpectation *expectation = [self expectationWithDescription:@"CancelAfterBeginWithV2API"];
+ __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
@@ -699,7 +704,7 @@ BOOL isRemoteInteropTest(NSString *host) {
- (void)testCancelAfterFirstRequestWithV2API {
XCTAssertNotNil([[self class] host]);
__weak XCTestExpectation *completionExpectation =
- [self expectationWithDescription:@"Call completed."];
+ [self expectationWithDescription:@"Call completed."];
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
options.transportType = self.class.transportType;
@@ -707,20 +712,20 @@ BOOL isRemoteInteropTest(NSString *host) {
options.hostNameOverride = [[self class] hostNameOverride];
id request =
- [RMTStreamingOutputCallRequest messageWithPayloadSize:@21782 requestedResponseSize:@31415];
+ [RMTStreamingOutputCallRequest messageWithPayloadSize:@21782 requestedResponseSize:@31415];
__block GRPCStreamingProtoCall *call = [_service
- fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc]
- initWithInitialMetadataCallback:nil
- messageCallback:^(id message) {
- XCTFail(@"Received unexpected response.");
- }
- closeCallback:^(NSDictionary *trailingMetadata,
- NSError *error) {
- XCTAssertEqual(error.code, GRPC_STATUS_CANCELLED);
- [completionExpectation fulfill];
- }]
- callOptions:options];
+ fullDuplexCallWithResponseHandler:[[InteropTestsBlockCallbacks alloc]
+ initWithInitialMetadataCallback:nil
+ messageCallback:^(id message) {
+ XCTFail(@"Received unexpected response.");
+ }
+ closeCallback:^(NSDictionary *trailingMetadata,
+ NSError *error) {
+ XCTAssertEqual(error.code, GRPC_STATUS_CANCELLED);
+ [completionExpectation fulfill];
+ }]
+ callOptions:options];
[call start];
[call writeMessage:request];
[call cancel];