diff options
Diffstat (limited to 'Firestore/Example')
5 files changed, 30 insertions, 18 deletions
diff --git a/Firestore/Example/Tests/Core/FSTSyncEngine+Testing.h b/Firestore/Example/Tests/Core/FSTSyncEngine+Testing.h index ab0697b..6e7c45b 100644 --- a/Firestore/Example/Tests/Core/FSTSyncEngine+Testing.h +++ b/Firestore/Example/Tests/Core/FSTSyncEngine+Testing.h @@ -18,14 +18,15 @@ #import "Firestore/Source/Core/FSTSyncEngine.h" -@class FSTDocumentKey; +#include "Firestore/core/src/firebase/firestore/model/document_key.h" NS_ASSUME_NONNULL_BEGIN @interface FSTSyncEngine (Testing) /** Returns the current set of limbo document keys and their associated target IDs. */ -- (NSDictionary<FSTDocumentKey *, FSTBoxedTargetID *> *)currentLimboDocuments; +- (std::map<firebase::firestore::model::DocumentKey, firebase::firestore::model::TargetId>) + currentLimboDocuments; @end diff --git a/Firestore/Example/Tests/Integration/FSTDatastoreTests.mm b/Firestore/Example/Tests/Integration/FSTDatastoreTests.mm index 9ce3d30..430366f 100644 --- a/Firestore/Example/Tests/Integration/FSTDatastoreTests.mm +++ b/Firestore/Example/Tests/Integration/FSTDatastoreTests.mm @@ -48,6 +48,7 @@ namespace util = firebase::firestore::util; using firebase::firestore::auth::EmptyCredentialsProvider; using firebase::firestore::core::DatabaseInfo; using firebase::firestore::model::DatabaseId; +using firebase::firestore::model::TargetId; NS_ASSUME_NONNULL_BEGIN @@ -126,7 +127,7 @@ NS_ASSUME_NONNULL_BEGIN [expectation fulfill]; } -- (void)rejectListenWithTargetID:(FSTBoxedTargetID *)targetID error:(NSError *)error { +- (void)rejectListenWithTargetID:(const TargetId)targetID error:(NSError *)error { FSTFail(@"Not implemented"); } diff --git a/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm b/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm index 0c3d9a1..f66e6c7 100644 --- a/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm +++ b/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm @@ -16,6 +16,7 @@ #import "Firestore/Example/Tests/SpecTests/FSTSpecTests.h" +#include <map> #include <utility> #import <FirebaseFirestore/FIRFirestoreErrors.h> @@ -44,10 +45,13 @@ #import "Firestore/Example/Tests/Util/FSTHelpers.h" #include "Firestore/core/src/firebase/firestore/auth/user.h" +#include "Firestore/core/src/firebase/firestore/model/document_key.h" #include "Firestore/core/src/firebase/firestore/util/string_apple.h" namespace util = firebase::firestore::util; using firebase::firestore::auth::User; +using firebase::firestore::model::DocumentKey; +using firebase::firestore::model::TargetId; NS_ASSUME_NONNULL_BEGIN @@ -561,22 +565,22 @@ static NSString *const kNoIOSTag = @"no-ios"; - (void)validateLimboDocuments { // Make a copy so it can modified while checking against the expected limbo docs. - NSMutableDictionary<FSTDocumentKey *, FSTBoxedTargetID *> *actualLimboDocs = - [NSMutableDictionary dictionaryWithDictionary:self.driver.currentLimboDocuments]; + std::map<DocumentKey, TargetId> actualLimboDocs = self.driver.currentLimboDocuments; // Validate that each limbo doc has an expected active target - [actualLimboDocs enumerateKeysAndObjectsUsingBlock:^(FSTDocumentKey *key, - FSTBoxedTargetID *targetID, BOOL *stop) { - XCTAssertNotNil(self.driver.expectedActiveTargets[targetID], + for (const auto &kv : actualLimboDocs) { + XCTAssertNotNil(self.driver.expectedActiveTargets[@(kv.second)], @"Found limbo doc without an expected active target"); - }]; + } for (FSTDocumentKey *expectedLimboDoc in self.driver.expectedLimboDocuments) { - XCTAssertNotNil(actualLimboDocs[expectedLimboDoc], - @"Expected doc to be in limbo, but was not: %@", expectedLimboDoc); - [actualLimboDocs removeObjectForKey:expectedLimboDoc]; + XCTAssert(actualLimboDocs.find(expectedLimboDoc) != actualLimboDocs.end(), + @"Expected doc to be in limbo, but was not: %@", expectedLimboDoc); + actualLimboDocs.erase(expectedLimboDoc); } - XCTAssertTrue(actualLimboDocs.count == 0, "Unexpected docs in limbo: %@", actualLimboDocs); + XCTAssertTrue(actualLimboDocs.empty(), "%lu Unexpected docs in limbo, the first one is <%s, %d>", + actualLimboDocs.size(), actualLimboDocs.begin()->first.ToString().c_str(), + actualLimboDocs.begin()->second); } - (void)validateActiveTargets { diff --git a/Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.h b/Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.h index f3d9a5d..ac44cb5 100644 --- a/Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.h +++ b/Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.h @@ -16,6 +16,7 @@ #import <Foundation/Foundation.h> +#include <map> #include <unordered_map> #import "Firestore/Source/Core/FSTTypes.h" @@ -23,6 +24,7 @@ #import "Firestore/Source/Util/FSTDispatchQueue.h" #include "Firestore/core/src/firebase/firestore/auth/user.h" +#include "Firestore/core/src/firebase/firestore/model/document_key.h" @class FSTDocumentKey; @class FSTMutation; @@ -242,6 +244,10 @@ typedef std::unordered_map<firebase::firestore::auth::User, */ - (NSArray<FSTQueryEvent *> *)capturedEventsSinceLastCall; +/** The current set of documents in limbo. */ +- (std::map<firebase::firestore::model::DocumentKey, firebase::firestore::model::TargetId>) + currentLimboDocuments; + /** * The writes that have been sent to the FSTSyncEngine via writeUserMutation: but not yet * acknowledged by calling receiveWriteAck/Error:. They are tracked per-user. @@ -263,10 +269,6 @@ typedef std::unordered_map<firebase::firestore::auth::User, /** The current user for the FSTSyncEngine; determines which mutation queue is active. */ @property(nonatomic, assign, readonly) const firebase::firestore::auth::User ¤tUser; -/** The current set of documents in limbo. */ -@property(nonatomic, strong, readonly) - NSDictionary<FSTDocumentKey *, FSTBoxedTargetID *> *currentLimboDocuments; - /** The expected set of documents in limbo. */ @property(nonatomic, strong, readwrite) NSSet<FSTDocumentKey *> *expectedLimboDocuments; diff --git a/Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm b/Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm index bfcd4dd..42a0ac0 100644 --- a/Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm +++ b/Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm @@ -16,6 +16,7 @@ #import "Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.h" +#include <map> #include <unordered_map> #import <FirebaseFirestore/FIRFirestoreErrors.h> @@ -40,12 +41,15 @@ #include "Firestore/core/src/firebase/firestore/auth/user.h" #include "Firestore/core/src/firebase/firestore/core/database_info.h" #include "Firestore/core/src/firebase/firestore/model/database_id.h" +#include "Firestore/core/src/firebase/firestore/model/document_key.h" using firebase::firestore::auth::EmptyCredentialsProvider; using firebase::firestore::auth::HashUser; using firebase::firestore::auth::User; using firebase::firestore::core::DatabaseInfo; using firebase::firestore::model::DatabaseId; +using firebase::firestore::model::DocumentKey; +using firebase::firestore::model::TargetId; NS_ASSUME_NONNULL_BEGIN @@ -349,7 +353,7 @@ NS_ASSUME_NONNULL_BEGIN }]; } -- (NSDictionary<FSTDocumentKey *, FSTBoxedTargetID *> *)currentLimboDocuments { +- (std::map<DocumentKey, TargetId>)currentLimboDocuments { return [self.syncEngine currentLimboDocuments]; } |