clang-format

pull/16190/head
Muxi Yan 6 years ago
parent 94d220d32c
commit 8d0cf9ec0a
  1. 38
      src/objective-c/tests/ChannelTests/ChannelPoolTest.m
  2. 18
      src/objective-c/tests/ChannelTests/ChannelTests.m

@ -47,14 +47,10 @@ NSString *kDummyHost = @"dummy.host";
GRPCChannelPool *pool = [GRPCChannelPool sharedInstance]; GRPCChannelPool *pool = [GRPCChannelPool sharedInstance];
GRPCChannel *channel1 = [pool channelWithHost:kDummyHost GRPCChannel *channel1 = [pool channelWithHost:kDummyHost callOptions:options1];
callOptions:options1]; GRPCChannel *channel2 = [pool channelWithHost:kDummyHost callOptions:options2];
GRPCChannel *channel2 = [pool channelWithHost:kDummyHost GRPCChannel *channel3 = [pool channelWithHost:kDummyHost2 callOptions:options1];
callOptions:options2]; GRPCChannel *channel4 = [pool channelWithHost:kDummyHost callOptions:options3];
GRPCChannel *channel3 = [pool channelWithHost:kDummyHost2
callOptions:options1];
GRPCChannel *channel4 = [pool channelWithHost:kDummyHost
callOptions:options3];
XCTAssertEqual(channel1, channel2); XCTAssertEqual(channel1, channel2);
XCTAssertNotEqual(channel1, channel3); XCTAssertNotEqual(channel1, channel3);
XCTAssertNotEqual(channel1, channel4); XCTAssertNotEqual(channel1, channel4);
@ -66,16 +62,14 @@ NSString *kDummyHost = @"dummy.host";
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
GRPCChannelPool *pool = [GRPCChannelPool sharedInstance]; GRPCChannelPool *pool = [GRPCChannelPool sharedInstance];
GRPCChannel *channel = [pool channelWithHost:kDummyHost GRPCChannel *channel = [pool channelWithHost:kDummyHost callOptions:options];
callOptions:options];
grpc_call *call = [channel unmanagedCallWithPath:@"dummy.path" grpc_call *call = [channel unmanagedCallWithPath:@"dummy.path"
completionQueue:[GRPCCompletionQueue completionQueue] completionQueue:[GRPCCompletionQueue completionQueue]
callOptions:options callOptions:options
disconnected:nil]; disconnected:nil];
[pool destroyAllChannels]; [pool destroyAllChannels];
XCTAssertTrue(channel.disconnected); XCTAssertTrue(channel.disconnected);
GRPCChannel *channel2 = [pool channelWithHost:kDummyHost GRPCChannel *channel2 = [pool channelWithHost:kDummyHost callOptions:options];
callOptions:options];
XCTAssertNotEqual(channel, channel2); XCTAssertNotEqual(channel, channel2);
grpc_call_unref(call); grpc_call_unref(call);
} }
@ -86,9 +80,8 @@ NSString *kDummyHost = @"dummy.host";
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
GRPCChannelPool *pool = [GRPCChannelPool sharedInstance]; GRPCChannelPool *pool = [GRPCChannelPool sharedInstance];
GRPCChannel *channel = [pool channelWithHost:kDummyHost GRPCChannel *channel =
callOptions:options [pool channelWithHost:kDummyHost callOptions:options destroyDelay:kDestroyDelay];
destroyDelay:kDestroyDelay];
grpc_call *call = [channel unmanagedCallWithPath:@"dummy.path" grpc_call *call = [channel unmanagedCallWithPath:@"dummy.path"
completionQueue:[GRPCCompletionQueue completionQueue] completionQueue:[GRPCCompletionQueue completionQueue]
callOptions:options callOptions:options
@ -97,9 +90,8 @@ NSString *kDummyHost = @"dummy.host";
[channel unref]; [channel unref];
// Test that we can still get the channel at this time // Test that we can still get the channel at this time
GRPCChannel *channel2 = [pool channelWithHost:kDummyHost GRPCChannel *channel2 =
callOptions:options [pool channelWithHost:kDummyHost callOptions:options destroyDelay:kDestroyDelay];
destroyDelay:kDestroyDelay];
XCTAssertEqual(channel, channel2); XCTAssertEqual(channel, channel2);
call = [channel2 unmanagedCallWithPath:@"dummy.path" call = [channel2 unmanagedCallWithPath:@"dummy.path"
completionQueue:[GRPCCompletionQueue completionQueue] completionQueue:[GRPCCompletionQueue completionQueue]
@ -117,9 +109,8 @@ NSString *kDummyHost = @"dummy.host";
GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init]; GRPCMutableCallOptions *options = [[GRPCMutableCallOptions alloc] init];
GRPCChannelPool *pool = [GRPCChannelPool sharedInstance]; GRPCChannelPool *pool = [GRPCChannelPool sharedInstance];
GRPCChannel *channel = [pool channelWithHost:kDummyHost GRPCChannel *channel =
callOptions:options [pool channelWithHost:kDummyHost callOptions:options destroyDelay:kDestroyDelay];
destroyDelay:kDestroyDelay];
grpc_call *call = [channel unmanagedCallWithPath:@"dummy.path" grpc_call *call = [channel unmanagedCallWithPath:@"dummy.path"
completionQueue:[GRPCCompletionQueue completionQueue] completionQueue:[GRPCCompletionQueue completionQueue]
callOptions:options callOptions:options
@ -130,9 +121,8 @@ NSString *kDummyHost = @"dummy.host";
sleep(kDestroyDelay + 1); sleep(kDestroyDelay + 1);
// Test that we get new channel to the same host and with the same callOptions // Test that we get new channel to the same host and with the same callOptions
GRPCChannel *channel2 = [pool channelWithHost:kDummyHost GRPCChannel *channel2 =
callOptions:options [pool channelWithHost:kDummyHost callOptions:options destroyDelay:kDestroyDelay];
destroyDelay:kDestroyDelay];
XCTAssertNotEqual(channel, channel2); XCTAssertNotEqual(channel, channel2);
} }

@ -33,12 +33,13 @@
} }
- (void)testTimedDisconnection { - (void)testTimedDisconnection {
NSString * const kHost = @"grpc-test.sandbox.googleapis.com"; NSString *const kHost = @"grpc-test.sandbox.googleapis.com";
const NSTimeInterval kDestroyDelay = 1; const NSTimeInterval kDestroyDelay = 1;
GRPCCallOptions *options = [[GRPCCallOptions alloc] init]; GRPCCallOptions *options = [[GRPCCallOptions alloc] init];
GRPCChannelConfiguration *configuration = [[GRPCChannelConfiguration alloc] initWithHost:kHost callOptions:options]; GRPCChannelConfiguration *configuration =
GRPCChannel *channel = [[GRPCChannel alloc] initWithChannelConfiguration:configuration [[GRPCChannelConfiguration alloc] initWithHost:kHost callOptions:options];
destroyDelay:kDestroyDelay]; GRPCChannel *channel =
[[GRPCChannel alloc] initWithChannelConfiguration:configuration destroyDelay:kDestroyDelay];
BOOL disconnected; BOOL disconnected;
grpc_call *call = [channel unmanagedCallWithPath:@"dummy.path" grpc_call *call = [channel unmanagedCallWithPath:@"dummy.path"
completionQueue:[GRPCCompletionQueue completionQueue] completionQueue:[GRPCCompletionQueue completionQueue]
@ -61,12 +62,13 @@
} }
- (void)testForceDisconnection { - (void)testForceDisconnection {
NSString * const kHost = @"grpc-test.sandbox.googleapis.com"; NSString *const kHost = @"grpc-test.sandbox.googleapis.com";
const NSTimeInterval kDestroyDelay = 1; const NSTimeInterval kDestroyDelay = 1;
GRPCCallOptions *options = [[GRPCCallOptions alloc] init]; GRPCCallOptions *options = [[GRPCCallOptions alloc] init];
GRPCChannelConfiguration *configuration = [[GRPCChannelConfiguration alloc] initWithHost:kHost callOptions:options]; GRPCChannelConfiguration *configuration =
GRPCChannel *channel = [[GRPCChannel alloc] initWithChannelConfiguration:configuration [[GRPCChannelConfiguration alloc] initWithHost:kHost callOptions:options];
destroyDelay:kDestroyDelay]; GRPCChannel *channel =
[[GRPCChannel alloc] initWithChannelConfiguration:configuration destroyDelay:kDestroyDelay];
grpc_call *call = [channel unmanagedCallWithPath:@"dummy.path" grpc_call *call = [channel unmanagedCallWithPath:@"dummy.path"
completionQueue:[GRPCCompletionQueue completionQueue] completionQueue:[GRPCCompletionQueue completionQueue]
callOptions:options callOptions:options

Loading…
Cancel
Save