aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/objective-c/tests
diff options
context:
space:
mode:
authorGravatar Muxi Yan <mxyan@google.com>2018-10-18 17:04:03 -0700
committerGravatar Muxi Yan <mxyan@google.com>2018-10-18 17:04:03 -0700
commit4264ea2b55f46c1904fc179fb0db7b733b8c3e4b (patch)
treef0894f19b96ae1d8b3c120646b7df47c016b22b7 /src/objective-c/tests
parent6ae2ea643d89f7b2e7839f9016a61361ce92b5d5 (diff)
clang-format
Diffstat (limited to 'src/objective-c/tests')
-rw-r--r--src/objective-c/tests/ChannelTests/ChannelPoolTest.m35
-rw-r--r--src/objective-c/tests/GRPCClientTests.m101
-rw-r--r--src/objective-c/tests/InteropTests.m2
3 files changed, 63 insertions, 75 deletions
diff --git a/src/objective-c/tests/ChannelTests/ChannelPoolTest.m b/src/objective-c/tests/ChannelTests/ChannelPoolTest.m
index db64ac6339..f4a9fb4a2c 100644
--- a/src/objective-c/tests/ChannelTests/ChannelPoolTest.m
+++ b/src/objective-c/tests/ChannelTests/ChannelPoolTest.m
@@ -57,11 +57,9 @@ NSString *kDummyHost = @"dummy.host";
GRPCChannelConfiguration *config1 =
[[GRPCChannelConfiguration alloc] initWithHost:kDummyHost callOptions:options1];
GRPCChannelPool *pool = [[GRPCChannelPool alloc] init];
- GRPCChannel *channel1 =
- [pool channelWithConfiguration:config1];
+ GRPCChannel *channel1 = [pool channelWithConfiguration:config1];
[pool removeChannel:channel1];
- GRPCChannel *channel2 =
- [pool channelWithConfiguration:config1];
+ GRPCChannel *channel2 = [pool channelWithConfiguration:config1];
XCTAssertNotEqual(channel1, channel2);
}
@@ -74,18 +72,14 @@ extern NSTimeInterval kChannelDestroyDelay;
options1.transportType = GRPCTransportTypeInsecure;
GRPCChannelConfiguration *config1 =
[[GRPCChannelConfiguration alloc] initWithHost:kDummyHost callOptions:options1];
- GRPCChannelPool *pool =
- [[GRPCChannelPool alloc] init];
- GRPCChannel *channel1 =
- [pool channelWithConfiguration:config1];
+ GRPCChannelPool *pool = [[GRPCChannelPool alloc] init];
+ GRPCChannel *channel1 = [pool channelWithConfiguration:config1];
[channel1 unmanagedCallUnref];
sleep(1);
- GRPCChannel *channel2 =
- [pool channelWithConfiguration:config1];
+ GRPCChannel *channel2 = [pool channelWithConfiguration:config1];
XCTAssertEqual(channel1, channel2);
sleep((int)kChannelDestroyDelay + 2);
- GRPCChannel *channel3 =
- [pool channelWithConfiguration:config1];
+ GRPCChannel *channel3 = [pool channelWithConfiguration:config1];
XCTAssertEqual(channel1, channel3);
kChannelDestroyDelay = kOriginalInterval;
}
@@ -96,12 +90,11 @@ extern NSTimeInterval kChannelDestroyDelay;
options1.transportType = GRPCTransportTypeInsecure;
GRPCCallOptions *options2 = [options1 copy];
GRPCChannelConfiguration *config1 =
- [[GRPCChannelConfiguration alloc] initWithHost:kDummyHost callOptions:options1];
+ [[GRPCChannelConfiguration alloc] initWithHost:kDummyHost callOptions:options1];
GRPCChannelConfiguration *config2 =
- [[GRPCChannelConfiguration alloc] initWithHost:kDummyHost callOptions:options2];
+ [[GRPCChannelConfiguration alloc] initWithHost:kDummyHost callOptions:options2];
GRPCChannelPool *pool = [[GRPCChannelPool alloc] init];
-
GRPCChannel *channel1 = [pool channelWithConfiguration:config1];
[pool removeAndCloseAllChannels];
GRPCChannel *channel2 = [pool channelWithConfiguration:config2];
@@ -119,17 +112,13 @@ extern NSTimeInterval kChannelDestroyDelay;
[[GRPCChannelConfiguration alloc] initWithHost:kDummyHost callOptions:options2];
GRPCChannelPool *pool = [[GRPCChannelPool alloc] init];
- GRPCChannel *channel1 =
- [pool channelWithConfiguration:config1];
- GRPCChannel *channel2 =
- [pool channelWithConfiguration:config2];
+ GRPCChannel *channel1 = [pool channelWithConfiguration:config1];
+ GRPCChannel *channel2 = [pool channelWithConfiguration:config2];
XCTAssertNotEqual(channel1, channel2);
[pool removeAndCloseAllChannels];
- GRPCChannel *channel3 =
- [pool channelWithConfiguration:config1];
- GRPCChannel *channel4 =
- [pool channelWithConfiguration:config2];
+ GRPCChannel *channel3 = [pool channelWithConfiguration:config1];
+ GRPCChannel *channel4 = [pool channelWithConfiguration:config2];
XCTAssertNotEqual(channel1, channel3);
XCTAssertNotEqual(channel2, channel4);
}
diff --git a/src/objective-c/tests/GRPCClientTests.m b/src/objective-c/tests/GRPCClientTests.m
index f961b6a86f..387fcab7e9 100644
--- a/src/objective-c/tests/GRPCClientTests.m
+++ b/src/objective-c/tests/GRPCClientTests.m
@@ -446,42 +446,40 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
options.initialMetadata = headers;
GRPCCall2 *call = [[GRPCCall2 alloc]
initWithRequestOptions:request
- responseHandler:[[ClientTestsBlockCallbacks alloc] initWithInitialMetadataCallback:^(
+ responseHandler:[[ClientTestsBlockCallbacks alloc] initWithInitialMetadataCallback:^(
NSDictionary *initialMetadata) {
- NSString *userAgent = initialMetadata[@"x-grpc-test-echo-useragent"];
- // Test the regex is correct
- NSString *expectedUserAgent = @"Foo grpc-objc/";
- expectedUserAgent =
- [expectedUserAgent stringByAppendingString:GRPC_OBJC_VERSION_STRING];
- expectedUserAgent = [expectedUserAgent stringByAppendingString:@" grpc-c/"];
- expectedUserAgent =
- [expectedUserAgent stringByAppendingString:GRPC_C_VERSION_STRING];
- expectedUserAgent =
- [expectedUserAgent stringByAppendingString:@" (ios; chttp2; "];
- expectedUserAgent = [expectedUserAgent
- stringByAppendingString:[NSString
- stringWithUTF8String:grpc_g_stands_for()]];
- expectedUserAgent = [expectedUserAgent stringByAppendingString:@")"];
- XCTAssertEqualObjects(userAgent, expectedUserAgent);
-
- NSError *error = nil;
- // Change in format of user-agent field in a direction that does not match
- // the regex will likely cause problem for certain gRPC users. For details,
- // refer to internal doc https://goo.gl/c2diBc
- NSRegularExpression *regex = [NSRegularExpression
- regularExpressionWithPattern:
- @" grpc-[a-zA-Z0-9]+(-[a-zA-Z0-9]+)?/[^ ,]+( \\([^)]*\\))?"
- options:0
- error:&error];
-
- NSString *customUserAgent = [regex
- stringByReplacingMatchesInString:userAgent
- options:0
- range:NSMakeRange(0, [userAgent length])
- withTemplate:@""];
- XCTAssertEqualObjects(customUserAgent, @"Foo");
- [recvInitialMd fulfill];
- }
+ NSString *userAgent = initialMetadata[@"x-grpc-test-echo-useragent"];
+ // Test the regex is correct
+ NSString *expectedUserAgent = @"Foo grpc-objc/";
+ expectedUserAgent =
+ [expectedUserAgent stringByAppendingString:GRPC_OBJC_VERSION_STRING];
+ expectedUserAgent = [expectedUserAgent stringByAppendingString:@" grpc-c/"];
+ expectedUserAgent =
+ [expectedUserAgent stringByAppendingString:GRPC_C_VERSION_STRING];
+ expectedUserAgent = [expectedUserAgent stringByAppendingString:@" (ios; chttp2; "];
+ expectedUserAgent = [expectedUserAgent
+ stringByAppendingString:[NSString stringWithUTF8String:grpc_g_stands_for()]];
+ expectedUserAgent = [expectedUserAgent stringByAppendingString:@")"];
+ XCTAssertEqualObjects(userAgent, expectedUserAgent);
+
+ NSError *error = nil;
+ // Change in format of user-agent field in a direction that does not match
+ // the regex will likely cause problem for certain gRPC users. For details,
+ // refer to internal doc https://goo.gl/c2diBc
+ NSRegularExpression *regex = [NSRegularExpression
+ regularExpressionWithPattern:
+ @" grpc-[a-zA-Z0-9]+(-[a-zA-Z0-9]+)?/[^ ,]+( \\([^)]*\\))?"
+ options:0
+ error:&error];
+
+ NSString *customUserAgent =
+ [regex stringByReplacingMatchesInString:userAgent
+ options:0
+ range:NSMakeRange(0, [userAgent length])
+ withTemplate:@""];
+ XCTAssertEqualObjects(customUserAgent, @"Foo");
+ [recvInitialMd fulfill];
+ }
messageCallback:^(id message) {
XCTAssertNotNil(message);
XCTAssertEqual([message length], 0,
@@ -609,7 +607,7 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
options.transportType = GRPCTransportTypeInsecure;
GRPCCall2 *call = [[GRPCCall2 alloc]
initWithRequestOptions:requestOptions
- responseHandler:[[ClientTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil
+ responseHandler:[[ClientTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil
messageCallback:^(id message) {
NSData *data = (NSData *)message;
XCTAssertNotNil(data, @"nil value received as response.");
@@ -739,19 +737,18 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
GRPCCall2 *call = [[GRPCCall2 alloc]
initWithRequestOptions:requestOptions
- responseHandler:
- [[ClientTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil
- messageCallback:^(id data) {
- XCTFail(
- @"Failure: response received; Expect: no response received.");
- }
- closeCallback:^(NSDictionary *trailingMetadata, NSError *error) {
- XCTAssertNotNil(error,
- @"Failure: no error received; Expect: receive "
- @"deadline exceeded.");
- XCTAssertEqual(error.code, GRPCErrorCodeDeadlineExceeded);
- [completion fulfill];
- }]
+ responseHandler:
+ [[ClientTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil
+ messageCallback:^(id data) {
+ XCTFail(@"Failure: response received; Expect: no response received.");
+ }
+ closeCallback:^(NSDictionary *trailingMetadata, NSError *error) {
+ XCTAssertNotNil(error,
+ @"Failure: no error received; Expect: receive "
+ @"deadline exceeded.");
+ XCTAssertEqual(error.code, GRPCErrorCodeDeadlineExceeded);
+ [completion fulfill];
+ }]
callOptions:options];
[call start];
@@ -837,7 +834,9 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
__weak XCTestExpectation *completion = [self expectationWithDescription:@"Timeout in a second."];
NSString *const kDummyAddress = [NSString stringWithFormat:@"127.0.0.1:10000"];
GRPCRequestOptions *requestOptions =
- [[GRPCRequestOptions alloc] initWithHost:kDummyAddress path:@"/dummy/path" safety:GRPCCallSafetyDefault];
+ [[GRPCRequestOptions alloc] initWithHost:kDummyAddress
+ path:@"/dummy/path"
+ safety:GRPCCallSafetyDefault];
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
options.connectMinTimeout = timeout;
options.connectInitialBackoff = backoff;
@@ -846,7 +845,7 @@ static GRPCProtoMethod *kFullDuplexCallMethod;
NSDate *startTime = [NSDate date];
GRPCCall2 *call = [[GRPCCall2 alloc]
initWithRequestOptions:requestOptions
- responseHandler:[[ClientTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil
+ responseHandler:[[ClientTestsBlockCallbacks alloc] initWithInitialMetadataCallback:nil
messageCallback:^(id data) {
XCTFail(@"Received message. Should not reach here.");
}
diff --git a/src/objective-c/tests/InteropTests.m b/src/objective-c/tests/InteropTests.m
index ca49b5fc39..1188a75df7 100644
--- a/src/objective-c/tests/InteropTests.m
+++ b/src/objective-c/tests/InteropTests.m
@@ -483,7 +483,7 @@ BOOL isRemoteInteropTest(NSString *host) {
id request = [RMTStreamingOutputCallRequest messageWithPayloadSize:requests[index]
requestedResponseSize:responses[index]];
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
- options.transportType = [[self class] transportType ];
+ options.transportType = [[self class] transportType];
options.PEMRootCertificates = [[self class] PEMRootCertificates];
options.hostNameOverride = [[self class] hostNameOverride];