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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
tci-gateway-module
Grpc
Commits
a8d40b56
Commit
a8d40b56
authored
May 24, 2017
by
Muxi Yan
Browse files
Options
Downloads
Patches
Plain Diff
Asynchronously wait for tests
parent
49b7f834
Branches
Branches containing commit
Tags
Tags containing commit
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/objective-c/tests/RxLibraryUnitTests.m
+16
-6
16 additions, 6 deletions
src/objective-c/tests/RxLibraryUnitTests.m
with
16 additions
and
6 deletions
src/objective-c/tests/RxLibraryUnitTests.m
+
16
−
6
View file @
a8d40b56
...
@@ -38,6 +38,8 @@
...
@@ -38,6 +38,8 @@
#import <RxLibrary/GRXWriteable.h>
#import <RxLibrary/GRXWriteable.h>
#import <RxLibrary/GRXWriter.h>
#import <RxLibrary/GRXWriter.h>
#define TEST_TIMEOUT 1
// A mock of a GRXSingleValueHandler block that can be queried for how many times it was called and
// A mock of a GRXSingleValueHandler block that can be queried for how many times it was called and
// what were the last values passed to it.
// what were the last values passed to it.
//
//
...
@@ -155,9 +157,14 @@
...
@@ -155,9 +157,14 @@
#pragma mark BufferedPipe
#pragma mark BufferedPipe
-
(
void
)
testBufferedPipePropagatesValue
{
-
(
void
)
testBufferedPipePropagatesValue
{
__weak
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
@"Response received"
];
// Given:
// Given:
CapturingSingleValueHandler
*
handler
=
[
CapturingSingleValueHandler
handler
];
CapturingSingleValueHandler
*
handler
=
[
CapturingSingleValueHandler
handler
];
id
<
GRXWriteable
>
writeable
=
[
GRXWriteable
writeableWithSingleHandler
:
handler
.
block
];
id
<
GRXWriteable
>
writeable
=
[
GRXWriteable
writeableWithSingleHandler
:
^
(
id
value
,
NSError
*
errorOrNil
)
{
handler
.
block
(
value
,
errorOrNil
);
[
expectation
fulfill
];
}];
id
anyValue
=
@7
;
id
anyValue
=
@7
;
// If:
// If:
...
@@ -166,13 +173,12 @@
...
@@ -166,13 +173,12 @@
[
pipe
writeValue
:
anyValue
];
[
pipe
writeValue
:
anyValue
];
[
pipe
writesFinishedWithError
:
nil
];
[
pipe
writesFinishedWithError
:
nil
];
// Wait buffered pipe to be flushed.
sleep
(
1
);
// Then:
// Then:
[
self
waitForExpectationsWithTimeout
:
TEST_TIMEOUT
handler
:
nil
];
XCTAssertEqual
(
handler
.
timesCalled
,
1
);
XCTAssertEqual
(
handler
.
timesCalled
,
1
);
XCTAssertEqualObjects
(
handler
.
value
,
anyValue
);
XCTAssertEqualObjects
(
handler
.
value
,
anyValue
);
XCTAssertEqualObjects
(
handler
.
errorOrNil
,
nil
);
XCTAssertEqualObjects
(
handler
.
errorOrNil
,
nil
);
}
}
-
(
void
)
testBufferedPipePropagatesError
{
-
(
void
)
testBufferedPipePropagatesError
{
...
@@ -193,9 +199,13 @@
...
@@ -193,9 +199,13 @@
}
}
-
(
void
)
testBufferedPipeFinishWriteWhilePaused
{
-
(
void
)
testBufferedPipeFinishWriteWhilePaused
{
__weak
XCTestExpectation
*
expectation
=
[
self
expectationWithDescription
:
@"Response received"
];
// Given:
// Given:
CapturingSingleValueHandler
*
handler
=
[
CapturingSingleValueHandler
handler
];
CapturingSingleValueHandler
*
handler
=
[
CapturingSingleValueHandler
handler
];
id
<
GRXWriteable
>
writeable
=
[
GRXWriteable
writeableWithSingleHandler
:
handler
.
block
];
id
<
GRXWriteable
>
writeable
=
[
GRXWriteable
writeableWithSingleHandler
:
^
(
id
value
,
NSError
*
errorOrNil
)
{
handler
.
block
(
value
,
errorOrNil
);
[
expectation
fulfill
];
}];
id
anyValue
=
@7
;
id
anyValue
=
@7
;
// If:
// If:
...
@@ -205,9 +215,9 @@
...
@@ -205,9 +215,9 @@
[
pipe
writesFinishedWithError
:
nil
];
[
pipe
writesFinishedWithError
:
nil
];
// then start the writeable
// then start the writeable
[
pipe
startWithWriteable
:
writeable
];
[
pipe
startWithWriteable
:
writeable
];
sleep
(
1
);
// Then:
// Then:
[
self
waitForExpectationsWithTimeout
:
TEST_TIMEOUT
handler
:
nil
];
XCTAssertEqual
(
handler
.
timesCalled
,
1
);
XCTAssertEqual
(
handler
.
timesCalled
,
1
);
XCTAssertEqualObjects
(
handler
.
value
,
anyValue
);
XCTAssertEqualObjects
(
handler
.
value
,
anyValue
);
XCTAssertEqualObjects
(
handler
.
errorOrNil
,
nil
);
XCTAssertEqualObjects
(
handler
.
errorOrNil
,
nil
);
...
...
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
sign in
to comment