aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Example/Tests/Util
diff options
context:
space:
mode:
authorGravatar zxu <zxu@google.com>2018-02-06 13:51:11 -0500
committerGravatar GitHub <noreply@github.com>2018-02-06 13:51:11 -0500
commita441190635d494f128cf02e07566ae2003af4e08 (patch)
tree618e6b0ecdb5d243f6e97f319f98f09dc9ca0a7e /Firestore/Example/Tests/Util
parent7cac9dc47a8c6b7321ebf5fc13fa7140e784c8ca (diff)
Implement Firestore DatabaseInfo and port both Database{Id,Info} C++ to the iOS code (#738)
* implement Firestore DatabaseInfo in C++ * temporary stash changes; blocking on the massive renaming of .m to .mm * add database_info_test to project * finish port DatabaseId and fix style, modular fixing DatabaseInfo * port DatabaseInfo * remove FSTDatabase{ID,Info} and their tests from project * fix unit test * use namespace alias * use namespace alias, leftover * address more changes * refactoring to use raw pointer instead of value for property * address changes * remove self-> * fix style * remove the name suffix Alloc * fix a bug
Diffstat (limited to 'Firestore/Example/Tests/Util')
-rw-r--r--Firestore/Example/Tests/Util/FSTHelpers.mm21
-rw-r--r--Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm19
2 files changed, 27 insertions, 13 deletions
diff --git a/Firestore/Example/Tests/Util/FSTHelpers.mm b/Firestore/Example/Tests/Util/FSTHelpers.mm
index 64fe213..406d4dd 100644
--- a/Firestore/Example/Tests/Util/FSTHelpers.mm
+++ b/Firestore/Example/Tests/Util/FSTHelpers.mm
@@ -17,6 +17,7 @@
#import "Firestore/Example/Tests/Util/FSTHelpers.h"
#include <inttypes.h>
+#include <vector>
#import <FirebaseFirestore/FIRFieldPath.h>
#import <FirebaseFirestore/FIRGeoPoint.h>
@@ -30,7 +31,6 @@
#import "Firestore/Source/Core/FSTViewSnapshot.h"
#import "Firestore/Source/Local/FSTLocalViewChanges.h"
#import "Firestore/Source/Local/FSTQueryData.h"
-#import "Firestore/Source/Model/FSTDatabaseID.h"
#import "Firestore/Source/Model/FSTDocument.h"
#import "Firestore/Source/Model/FSTDocumentKey.h"
#import "Firestore/Source/Model/FSTDocumentSet.h"
@@ -41,6 +41,12 @@
#import "Firestore/Source/Remote/FSTWatchChange.h"
#import "Firestore/Source/Util/FSTAssert.h"
+#include "Firestore/core/src/firebase/firestore/model/database_id.h"
+#include "Firestore/core/src/firebase/firestore/util/string_apple.h"
+
+namespace util = firebase::firestore::util;
+using firebase::firestore::model::DatabaseId;
+
NS_ASSUME_NONNULL_BEGIN
/** A string sentinel that can be used with FSTTestPatchMutation() to mark a field for deletion. */
@@ -100,10 +106,10 @@ FSTFieldPath *FSTTestFieldPath(NSString *field) {
}
FSTFieldValue *FSTTestFieldValue(id _Nullable value) {
- FSTDatabaseID *databaseID =
- [FSTDatabaseID databaseIDWithProject:@"project" database:kDefaultDatabaseID];
+ // This owns the DatabaseIds since we do not have FirestoreClient instance to own them.
+ static DatabaseId database_id{"project", DatabaseId::kDefaultDatabaseId};
FSTUserDataConverter *converter =
- [[FSTUserDataConverter alloc] initWithDatabaseID:databaseID
+ [[FSTUserDataConverter alloc] initWithDatabaseID:&database_id
preConverter:^id _Nullable(id _Nullable input) {
return input;
}];
@@ -167,8 +173,11 @@ FSTResourcePath *FSTTestPath(NSString *path) {
}
FSTDocumentKeyReference *FSTTestRef(NSString *projectID, NSString *database, NSString *path) {
- FSTDatabaseID *databaseID = [FSTDatabaseID databaseIDWithProject:projectID database:database];
- return [[FSTDocumentKeyReference alloc] initWithKey:FSTTestDocKey(path) databaseID:databaseID];
+ // This owns the DatabaseIds since we do not have FirestoreClient instance to own them.
+ static std::vector<DatabaseId> database_ids;
+ database_ids.emplace_back(util::MakeStringView(projectID), util::MakeStringView(database));
+ return [[FSTDocumentKeyReference alloc] initWithKey:FSTTestDocKey(path)
+ databaseID:&database_ids.back()];
}
FSTQuery *FSTTestQuery(NSString *path) {
diff --git a/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm b/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm
index ef15056..df591b0 100644
--- a/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm
+++ b/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm
@@ -27,12 +27,16 @@
#import "Firestore/Source/Auth/FSTEmptyCredentialsProvider.h"
#import "Firestore/Source/Core/FSTFirestoreClient.h"
#import "Firestore/Source/Local/FSTLevelDB.h"
-#import "Firestore/Source/Model/FSTDatabaseID.h"
#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"
+
+namespace util = firebase::firestore::util;
+using firebase::firestore::model::DatabaseId;
using firebase::firestore::util::CreateAutoId;
NS_ASSUME_NONNULL_BEGIN
@@ -137,12 +141,13 @@ NS_ASSUME_NONNULL_BEGIN
FIRSetLoggerLevel(FIRLoggerLevelDebug);
// HACK: FIRFirestore expects a non-nil app, but for tests we cheat.
FIRApp *app = nil;
- FIRFirestore *firestore = [[FIRFirestore alloc] initWithProjectID:projectID
- database:kDefaultDatabaseID
- persistenceKey:persistenceKey
- credentialsProvider:credentialsProvider
- workerDispatchQueue:workerDispatchQueue
- firebaseApp:app];
+ FIRFirestore *firestore = [[FIRFirestore alloc]
+ initWithProjectID:projectID
+ database:util::WrapNSStringNoCopy(DatabaseId::kDefaultDatabaseId)
+ persistenceKey:persistenceKey
+ credentialsProvider:credentialsProvider
+ workerDispatchQueue:workerDispatchQueue
+ firebaseApp:app];
firestore.settings = [FSTIntegrationTestCase settings];