diff options
author | Sebastian Schmidt <mrschmidt@google.com> | 2017-12-04 16:42:43 -0800 |
---|---|---|
committer | Sebastian Schmidt <mrschmidt@google.com> | 2017-12-05 23:22:16 -0800 |
commit | a8948ced263e7d3ce870dff47cf7c29b12806247 (patch) | |
tree | e0720cc0d4e6738e317d4b9f75e73fd344135829 /Firestore/Example/Tests/Util | |
parent | ed3e4982f9f0194851509603e5e649e5152ba897 (diff) |
Adding SnapshotOptions to deal with pending ServerTimestamps
Diffstat (limited to 'Firestore/Example/Tests/Util')
-rw-r--r-- | Firestore/Example/Tests/Util/FSTEventAccumulator.h | 7 | ||||
-rw-r--r-- | Firestore/Example/Tests/Util/FSTEventAccumulator.m | 14 |
2 files changed, 17 insertions, 4 deletions
diff --git a/Firestore/Example/Tests/Util/FSTEventAccumulator.h b/Firestore/Example/Tests/Util/FSTEventAccumulator.h index ae5392c..e32f08b 100644 --- a/Firestore/Example/Tests/Util/FSTEventAccumulator.h +++ b/Firestore/Example/Tests/Util/FSTEventAccumulator.h @@ -23,7 +23,8 @@ NS_ASSUME_NONNULL_BEGIN -typedef void (^FSTGenericEventHandler)(id _Nullable, NSError *error); +typedef void (^FSTValueEventHandler)(id _Nullable, NSError *error); +typedef void (^FSTErrorEventHandler)(NSError *error); @interface FSTEventAccumulator : NSObject @@ -35,7 +36,9 @@ typedef void (^FSTGenericEventHandler)(id _Nullable, NSError *error); - (NSArray<id> *)awaitEvents:(NSUInteger)events name:(NSString *)name; -@property(nonatomic, strong, readonly) FSTGenericEventHandler handler; +@property(nonatomic, strong, readonly) FSTValueEventHandler valueEventHandler; +@property(nonatomic, strong, readonly) FSTErrorEventHandler errorEventHandler; + @end NS_ASSUME_NONNULL_END diff --git a/Firestore/Example/Tests/Util/FSTEventAccumulator.m b/Firestore/Example/Tests/Util/FSTEventAccumulator.m index b44ec67..9e48ce7 100644 --- a/Firestore/Example/Tests/Util/FSTEventAccumulator.m +++ b/Firestore/Example/Tests/Util/FSTEventAccumulator.m @@ -68,8 +68,8 @@ NS_ASSUME_NONNULL_BEGIN return events[0]; } -// Overrides the handler property -- (void (^)(id _Nullable, NSError *))handler { +// Override the valueEventHandler property +- (void (^)(id _Nullable, NSError *))valueEventHandler { return ^void(id _Nullable value, NSError *error) { // We can't store nil in the _events array, but these are still interesting to tests so store // NSNull instead. @@ -82,6 +82,16 @@ NS_ASSUME_NONNULL_BEGIN }; } +// Override the errorEventHandler property +- (void (^)(NSError *))errorEventHandler { + return ^void(NSError *error) { + @synchronized(self) { + [_events addObject:[NSNull null]]; + [self checkFulfilled]; + } + }; +} + - (void)checkFulfilled { if (_events.count >= self.maxEvents) { [self.expectation fulfill]; |