aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Example/Tests/SpecTests
diff options
context:
space:
mode:
authorGravatar zxu <zxu@google.com>2018-03-27 14:33:39 -0400
committerGravatar GitHub <noreply@github.com>2018-03-27 14:33:39 -0400
commitcb8c4b6b1f1ad213a5b3272e2c2e94f755bbabf9 (patch)
treeeb3eeddefb5fca423f59432933721d6d47100aa5 /Firestore/Example/Tests/SpecTests
parenta335d78a62c213b1ae6465bad28aaedfafd828bc (diff)
port C++ DocumentKey to the rest of Firestore code (#977)
* port C++ DocumentKey to API's and Core's * address changes * address changes * fix Hash return types
Diffstat (limited to 'Firestore/Example/Tests/SpecTests')
-rw-r--r--Firestore/Example/Tests/SpecTests/FSTSpecTests.mm24
-rw-r--r--Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.h10
-rw-r--r--Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm6
3 files changed, 25 insertions, 15 deletions
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 &currentUser;
-/** 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];
}