aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Example
diff options
context:
space:
mode:
authorGravatar Konstantin Varlamov <var-const@users.noreply.github.com>2018-05-11 21:43:25 -0400
committerGravatar GitHub <noreply@github.com>2018-05-11 21:43:25 -0400
commit450d7a18ffffbaeb8722b2d84ec181fbff7e91bb (patch)
tree557eb31d4eebb09de046dbdae17ea7f983b6c880 /Firestore/Example
parent604de8e947ee8e58094bb2d7cb4cc7ac16e97876 (diff)
Firestore C++: make FSTDispatchQueue delegate to C++ implementation (#1240)
FSTDispatchQueue now doesn't contain any logic of its own and instead just passes through all method calls to AsyncQueue (backed by an ExecutorLibdispatch).
Diffstat (limited to 'Firestore/Example')
-rw-r--r--Firestore/Example/Tests/Util/FSTDispatchQueueTests.mm46
1 files changed, 28 insertions, 18 deletions
diff --git a/Firestore/Example/Tests/Util/FSTDispatchQueueTests.mm b/Firestore/Example/Tests/Util/FSTDispatchQueueTests.mm
index 811fa34..1f49aa4 100644
--- a/Firestore/Example/Tests/Util/FSTDispatchQueueTests.mm
+++ b/Firestore/Example/Tests/Util/FSTDispatchQueueTests.mm
@@ -66,9 +66,10 @@ static const FSTTimerID timerID3 = FSTTimerIDWriteStreamConnectionBackoff;
XCTAssertNotNil(caught);
XCTAssertEqualObjects(caught.name, NSInternalInconsistencyException);
- XCTAssertTrue(
- [caught.reason hasPrefix:@"FIRESTORE INTERNAL ASSERTION FAILED: "
- @"dispatchAsync called when we are already running on target"]);
+ XCTAssertTrue([caught.reason
+ hasPrefix:
+ @"FIRESTORE INTERNAL ASSERTION FAILED: "
+ @"Enqueue methods cannot be called when we are already running on target executor"]);
}
- (void)testDispatchAsyncAllowingSameQueueActuallyAllowsSameQueue {
@@ -133,9 +134,10 @@ static const FSTTimerID timerID3 = FSTTimerIDWriteStreamConnectionBackoff;
XCTAssertNotNil(caught);
XCTAssertEqualObjects(caught.name, NSInternalInconsistencyException);
- XCTAssertTrue(
- [caught.reason hasPrefix:@"FIRESTORE INTERNAL ASSERTION FAILED: "
- @"dispatchSync called when we are already running on target"]);
+ XCTAssertTrue([caught.reason
+ hasPrefix:
+ @"FIRESTORE INTERNAL ASSERTION FAILED: "
+ @"Enqueue methods cannot be called when we are already running on target executor"]);
}
- (void)testVerifyIsCurrentQueueActuallyRequiresCurrentQueue {
@@ -150,7 +152,8 @@ static const FSTTimerID timerID3 = FSTTimerIDWriteStreamConnectionBackoff;
}
XCTAssertNotNil(caught);
XCTAssertTrue([caught.reason hasPrefix:@"FIRESTORE INTERNAL ASSERTION FAILED: "
- @"We are running on the wrong dispatch queue"]);
+ @"Expected to be called by the executor "
+ @"associated with this queue"]);
}
- (void)testVerifyIsCurrentQueueRequiresOperationIsInProgress {
@@ -165,7 +168,7 @@ static const FSTTimerID timerID3 = FSTTimerIDWriteStreamConnectionBackoff;
XCTAssertNotNil(caught);
XCTAssertTrue(
[caught.reason hasPrefix:@"FIRESTORE INTERNAL ASSERTION FAILED: "
- @"verifyIsCurrentQueue called outside enterCheckedOperation"]);
+ @"VerifyIsCurrentQueue called when no operation is executing"]);
}
- (void)testVerifyIsCurrentQueueWorksWithOperationIsInProgress {
@@ -194,9 +197,10 @@ static const FSTTimerID timerID3 = FSTTimerIDWriteStreamConnectionBackoff;
}];
XCTAssertNil(problem);
XCTAssertNotNil(caught);
- XCTAssertTrue([caught.reason
- hasPrefix:@"FIRESTORE INTERNAL ASSERTION FAILED: "
- @"enterCheckedOperation may not be called when an operation is in progress"]);
+ XCTAssertTrue(
+ [caught.reason hasPrefix:@"FIRESTORE INTERNAL ASSERTION FAILED: "
+ @"ExecuteBlocking may not be called before the previous operation "
+ @"finishes executing"]);
}
/**
@@ -217,8 +221,10 @@ static const FSTTimerID timerID3 = FSTTimerIDWriteStreamConnectionBackoff;
_expectation = [self expectationWithDescription:@"Expected steps"];
_expectedSteps = @[ @1, @2, @3, @4 ];
[_queue dispatchAsync:[self blockForStep:1]];
- [_queue dispatchAfterDelay:0.005 timerID:timerID1 block:[self blockForStep:4]];
- [_queue dispatchAfterDelay:0.001 timerID:timerID2 block:[self blockForStep:3]];
+ [_queue dispatchAsync:^{
+ [_queue dispatchAfterDelay:0.005 timerID:timerID1 block:[self blockForStep:4]];
+ [_queue dispatchAfterDelay:0.001 timerID:timerID2 block:[self blockForStep:3]];
+ }];
[_queue dispatchAsync:[self blockForStep:2]];
[self awaitExpectations];
@@ -244,8 +250,10 @@ static const FSTTimerID timerID3 = FSTTimerIDWriteStreamConnectionBackoff;
- (void)testCanManuallyDrainAllDelayedCallbacksForTesting {
[_queue dispatchAsync:[self blockForStep:1]];
- [_queue dispatchAfterDelay:20 timerID:timerID1 block:[self blockForStep:4]];
- [_queue dispatchAfterDelay:10 timerID:timerID2 block:[self blockForStep:3]];
+ [_queue dispatchAsync:^{
+ [_queue dispatchAfterDelay:20 timerID:timerID1 block:[self blockForStep:4]];
+ [_queue dispatchAfterDelay:10 timerID:timerID2 block:[self blockForStep:3]];
+ }];
[_queue dispatchAsync:[self blockForStep:2]];
[_queue runDelayedCallbacksUntil:FSTTimerIDAll];
@@ -254,9 +262,11 @@ static const FSTTimerID timerID3 = FSTTimerIDWriteStreamConnectionBackoff;
- (void)testCanManuallyDrainSpecificDelayedCallbacksForTesting {
[_queue dispatchAsync:[self blockForStep:1]];
- [_queue dispatchAfterDelay:20 timerID:timerID1 block:[self blockForStep:5]];
- [_queue dispatchAfterDelay:10 timerID:timerID2 block:[self blockForStep:3]];
- [_queue dispatchAfterDelay:15 timerID:timerID3 block:[self blockForStep:4]];
+ [_queue dispatchAsync:^{
+ [_queue dispatchAfterDelay:20 timerID:timerID1 block:[self blockForStep:5]];
+ [_queue dispatchAfterDelay:10 timerID:timerID2 block:[self blockForStep:3]];
+ [_queue dispatchAfterDelay:15 timerID:timerID3 block:[self blockForStep:4]];
+ }];
[_queue dispatchAsync:[self blockForStep:2]];
[_queue runDelayedCallbacksUntil:timerID3];