Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
Grpc
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
dc73a32c
Commit
dc73a32c
authored
9 years ago
by
Jorge Canizales
Browse files
Options
Downloads
Plain Diff
Merge pull request #1626 from murgatroid99/objective_c_interop_tests
More Objective-C interop tests
parents
ac25e00d
25750d9b
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m
+61
-2
61 additions, 2 deletions
...bjective-c/examples/Sample/SampleTests/RemoteProtoTests.m
with
61 additions
and
2 deletions
src/objective-c/examples/Sample/SampleTests/RemoteProtoTests.m
+
61
−
2
View file @
dc73a32c
...
...
@@ -31,9 +31,12 @@
*
*/
#include
<grpc/status.h>
#import <UIKit/UIKit.h>
#import <XCTest/XCTest.h>
#import <gRPC/ProtoRPC.h>
#import <gRPC/GRXWriter+Immediate.h>
#import <RemoteTest/Messages.pb.h>
#import <RemoteTest/Test.pb.h>
...
...
@@ -69,7 +72,7 @@
}
-
(
void
)
testLargeUnaryRPC
{
__weak
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
@"
Empty
Unary"
];
__weak
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
@"
Large
Unary"
];
RMTSimpleRequest
*
request
=
[[[[[[
RMTSimpleRequestBuilder
alloc
]
init
]
setResponseType:
RMTPayloadTypeCompressable
]
...
...
@@ -95,7 +98,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 +133,60 @@
[
self
waitForExpectationsWithTimeout
:
4
.
handler
:
nil
];
}
-
(
void
)
testServerStreamingRPC
{
__weak
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
@"ServerStreaming"
];
NSArray
*
expectedSizes
=
@[
@31415
,
@9
,
@2653
,
@58979
];
__block
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
]
setType:
RMTPayloadTypeCompressable
]
setBody:
[
NSMutableData
dataWithLength
:[
expectedSizes
[
index
]
unsignedIntegerValue
]]]
build
];
expectedResponseBuilder
=
[
expectedResponseBuilder
setPayload
:
expectedPayload
];
id
expectedResponse
=
[
expectedResponseBuilder
build
];
XCTAssertEqualObjects
(
response
,
expectedResponse
);
[
expectation
fulfill
];
index
+=
1
;
}];
[
self
waitForExpectationsWithTimeout
:
4
handler
:
nil
];
}
-
(
void
)
testEmptyStreamRPC
{
__weak
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
@"EmptyStream"
];
[
_service
fullDuplexCallWithRequestsWriter
:[
GRXWriter
emptyWriter
]
handler:
^
(
bool
done
,
RMTStreamingOutputCallResponse
*
response
,
NSError
*
error
)
{
XCTAssertNil
(
error
,
@"Finished with unexpected error: %@"
,
error
);
XCTAssert
(
done
,
@"Unexpected response: %@"
,
response
);
[
expectation
fulfill
];
}];
[
self
waitForExpectationsWithTimeout
:
4
handler
:
nil
];
}
-
(
void
)
testCancelAfterBeginRPC
{
__weak
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
@"CancelAfterBegin"
];
// TODO(mlumish): change to writing that blocks instead of writing
ProtoRPC
*
call
=
[
_service
RPCToStreamingInputCallWithRequestsWriter
:[
GRXWriter
emptyWriter
]
handler:
^
(
RMTStreamingInputCallResponse
*
response
,
NSError
*
error
)
{
XCTAssertEqual
([
error
code
],
GRPC_STATUS_CANCELLED
);
[
expectation
fulfill
];
}];
[
call
start
];
[
call
cancel
];
[
self
waitForExpectationsWithTimeout
:
1
handler
:
nil
];
}
@end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment