diff options
author | Michael Lehenbauer <mikelehen@gmail.com> | 2018-02-15 16:17:44 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-02-15 16:17:44 -0800 |
commit | 81ee594e325a922a91557d82563132f22977c947 (patch) | |
tree | 89ea78b6ccc77fa2f11e1c6b1fa40f3c8d54a3b2 /Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm | |
parent | fd9fd271d0dba3935a6f5611a1554f2c59b696af (diff) |
DispatchQueue delayed callback improvements + testing (#784)
Basically a port of https://github.com/firebase/firebase-js-sdk/commit/a1e346ff93c6cbcc0a1b3b33f0fbc3a7b66e7e12 and https://github.com/firebase/firebase-js-sdk/commit/fce4168309f42aa038125f39818fbf654b65b05f
* Introduces a DelayedCallback helper class in FSTDispatchQueue to encapsulate delayed callback logic.
* Adds cancellation support.
* Updates the idle timer in FSTStream to use new cancellation support.
* Adds a FSTTimerId enum for identifying delayed operations on the queue and uses it to identify our existing backoff and idle timers.
* Added containsDelayedCallback: and runDelayedCallbacksUntil: methods to FSTDispatchQueue which can be used from tests to check for the presence of a callback or to schedule them to run early.
* Removes FSTTestDispatchQueue and changes idle tests to use new test methods.
Diffstat (limited to 'Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm')
-rw-r--r-- | Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm | 15 |
1 files changed, 5 insertions, 10 deletions
diff --git a/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm b/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm index df591b0..e34b2a5 100644 --- a/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm +++ b/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm @@ -30,7 +30,6 @@ #import "Firestore/Source/Util/FSTDispatchQueue.h" #import "Firestore/Example/Tests/Util/FSTEventAccumulator.h" -#import "Firestore/Example/Tests/Util/FSTTestDispatchQueue.h" #include "Firestore/core/src/firebase/firestore/model/database_id.h" #include "Firestore/core/src/firebase/firestore/util/string_apple.h" @@ -133,7 +132,7 @@ NS_ASSUME_NONNULL_BEGIN - (FIRFirestore *)firestoreWithProjectID:(NSString *)projectID { NSString *persistenceKey = [NSString stringWithFormat:@"db%lu", (unsigned long)_firestores.count]; - FSTTestDispatchQueue *workerDispatchQueue = [FSTTestDispatchQueue + FSTDispatchQueue *workerDispatchQueue = [FSTDispatchQueue queueWith:dispatch_queue_create("com.google.firebase.firestore", DISPATCH_QUEUE_SERIAL)]; FSTEmptyCredentialsProvider *credentialsProvider = [[FSTEmptyCredentialsProvider alloc] init]; @@ -155,14 +154,6 @@ NS_ASSUME_NONNULL_BEGIN return firestore; } -- (void)waitForIdleFirestore:(FIRFirestore *)firestore { - XCTestExpectation *expectation = [self expectationWithDescription:@"idle"]; - // Note that we wait on any task that is scheduled with a delay of 60s. Currently, the idle - // timeout is the only task that uses this delay. - [((FSTTestDispatchQueue *)firestore.workerDispatchQueue) fulfillOnExecution:expectation]; - [self awaitExpectations]; -} - - (void)shutdownFirestore:(FIRFirestore *)firestore { [firestore shutdownWithCompletion:[self completionForExpectationWithName:@"shutdown"]]; [self awaitExpectations]; @@ -289,6 +280,10 @@ NS_ASSUME_NONNULL_BEGIN [self awaitExpectations]; } +- (FSTDispatchQueue *)queueForFirestore:(FIRFirestore *)firestore { + return firestore.workerDispatchQueue; +} + - (void)waitUntil:(BOOL (^)())predicate { NSTimeInterval start = [NSDate timeIntervalSinceReferenceDate]; double waitSeconds = [self defaultExpectationWaitSeconds]; |