diff options
Diffstat (limited to 'src/objective-c/tests/GRPCClientTests.m')
-rw-r--r-- | src/objective-c/tests/GRPCClientTests.m | 36 |
1 files changed, 24 insertions, 12 deletions
diff --git a/src/objective-c/tests/GRPCClientTests.m b/src/objective-c/tests/GRPCClientTests.m index 09a55e0704..00c4b8830d 100644 --- a/src/objective-c/tests/GRPCClientTests.m +++ b/src/objective-c/tests/GRPCClientTests.m @@ -42,9 +42,6 @@ #import <RxLibrary/GRXWriteable.h> #import <RxLibrary/GRXWriter+Immediate.h> -// These are a few tests similar to InteropTests, but which use the generic gRPC client (GRPCCall) -// rather than a generated proto library on top of it. - static NSString * const kHostAddress = @"localhost:5050"; static NSString * const kPackage = @"grpc.testing"; static NSString * const kService = @"TestService"; @@ -53,11 +50,10 @@ static ProtoMethod *kInexistentMethod; static ProtoMethod *kEmptyCallMethod; static ProtoMethod *kUnaryCallMethod; -// This is an observer class for testing that responseMetadata is KVO-compliant - +/** Observer class for testing that responseMetadata is KVO-compliant */ @interface PassthroughObserver : NSObject - -- (instancetype) initWithCallback:(void (^)(NSString*, id, NSDictionary*))callback; +- (instancetype) initWithCallback:(void (^)(NSString*, id, NSDictionary*))callback + NS_DESIGNATED_INITIALIZER; - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context; @@ -67,23 +63,38 @@ static ProtoMethod *kUnaryCallMethod; void (^_callback)(NSString*, id, NSDictionary*); } +- (instancetype)init { + return [self initWithCallback:nil]; +} + - (instancetype)initWithCallback:(void (^)(NSString *, id, NSDictionary *))callback { - self = [super init]; - if (self) { + if (!callback) { + return nil; + } + if ((self = [super init])) { _callback = callback; } return self; - } -- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context -{ +- (void)observeValueForKeyPath:(NSString *)keyPath + ofObject:(id)object + change:(NSDictionary *)change + context:(void *)context { _callback(keyPath, object, change); [object removeObserver:self forKeyPath:keyPath]; } @end +# pragma mark Tests + +/** + * A few tests similar to InteropTests, but which use the generic gRPC client (GRPCCall) rather than + * a generated proto library on top of it. Its RPCs are sent to a local cleartext server. + * + * TODO(jcanizales): Run them also against a local SSL server and against a remote server. + */ @interface GRPCClientTests : XCTestCase @end @@ -180,6 +191,7 @@ static ProtoMethod *kUnaryCallMethod; [self waitForExpectationsWithTimeout:8 handler:nil]; } +// TODO(jcanizales): Activate this test against the remote server. - (void)testMetadata { __weak XCTestExpectation *expectation = [self expectationWithDescription:@"RPC unauthorized."]; |