From ea43b903a3f2a499752720f0102441dc2694611e Mon Sep 17 00:00:00 2001
From: murgatroid99 <mlumish@google.com>
Date: Fri, 15 May 2015 10:37:09 -0700
Subject: [PATCH] Added server_streaming interop test

---
 .../Sample/SampleTests/RemoteProtoTests.m     | 34 +++++++++++++++++--
 1 file changed, 32 insertions(+), 2 deletions(-)

diff --git a/src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m b/src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m
index 2ef6a6e4ab..322d86d04b 100644
--- a/src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m
+++ b/src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m
@@ -69,7 +69,7 @@
 }
 
 - (void)testLargeUnaryRPC {
-  __weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyUnary"];
+  __weak XCTestExpectation *expectation = [self expectationWithDescription:@"LargeUnary"];
 
   RMTSimpleRequest *request = [[[[[[RMTSimpleRequestBuilder alloc] init]
                                   setResponseType:RMTPayloadTypeCompressable]
@@ -95,7 +95,7 @@
 }
 
 - (void)testClientStreamingRPC {
-  __weak XCTestExpectation *expectation = [self expectationWithDescription:@"EmptyUnary"];
+  __weak XCTestExpectation *expectation = [self expectationWithDescription:@"ClientStreaming"];
 
   id request1 = [[[[RMTStreamingInputCallRequestBuilder alloc] init]
                   setPayloadBuilder:[[[RMTPayloadBuilder alloc] init]
@@ -130,4 +130,34 @@
   [self waitForExpectationsWithTimeout:4. handler:nil];
 }
 
+- (void)testServerStreamingRPC {
+  __weak XCTestExpectation *expectation = [self expectationWithDescription:@"ServerStreaming"];
+  NSArray *expectedSizes = @[@31415, @9, @2653, @58979];
+  int index = 0;
+  id request = [[[[[[[RMTStreamingOutputCallRequestBuilder alloc] init]
+                    addResponseParameters:[[[[RMTResponseParametersBuilder alloc] init]
+                                            setSize:31415] build]]
+                   addResponseParameters:[[[[RMTResponseParametersBuilder alloc] init]
+                                           setSize:9] build]]
+                  addResponseParameters:[[[[RMTResponseParametersBuilder alloc] init]
+                                          setSize:2653] build]]
+                 addResponseParameters:[[[[RMTResponseParametersBuilder alloc] init]
+                                         setSize:58979] build]]
+                build];
+  [_service streamingOutputCallWithRequest:request handler:^(BOOL done, RMTStreamingOutputCallResponse *response, NSError *error){
+    XCTAssertNil(error, @"Finished with unexpected error: %@", error);
+    
+    id expectedResponseBuilder = [[RMTStreamingOutputCallResponseBuilder alloc] init];
+    id expectedPayload = [[[RMTPayloadBuilder alloc] init]
+                          setBody:[NSMutableData dataWithLength:expectedSizes[index]]];
+    expectedResponseBuilder = [expectedResponseBuilder setPayload:expectedPayload];
+    id expectedResponse = [expectedResponseBuilder build];
+    XCTAssertEqualObjects(response, expectedResponse);
+    
+    [expectation fulfill];
+  }];
+  
+  [self waitForExpectationsWithTimeout:4 handler:nil];
+}
+
 @end
-- 
GitLab