diff options
author | zxu <zxu@google.com> | 2018-03-14 08:57:31 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-03-14 08:57:31 -0400 |
commit | 9e815620e9f7f43b42e03db4e5118d7ad03ddee7 (patch) | |
tree | 86f362bad99281325fca7ee3ae116b6a0f36d511 /Firestore/Example/Tests/API | |
parent | d4d73ea53ecdf1e8ade3d00921419645dd5d66f7 (diff) |
grand PR to port the remaining paths (FieldPath and ResourcePath). (#865)
* naively remove FSTPath import and source/test files.
* port FieldPath, part I
* port FieldPath, part II
* port ResourcePath, part I
* port ResourcePath, part II
* the grand commit to fix build errors
* use testutil:: helper instead of those from FSTHelpers
* fix test and lint
* use c_str in errmsg directly
* fix
* fix
* make code clean
* fix integration test I missed
* fix to avoid naming collision in preprocessor
* address changes
* address changes
* address changes
* fix: fieldMask are actually shared with different context.
* address changes
* address changes
Diffstat (limited to 'Firestore/Example/Tests/API')
7 files changed, 40 insertions, 32 deletions
diff --git a/Firestore/Example/Tests/API/FIRCollectionReferenceTests.mm b/Firestore/Example/Tests/API/FIRCollectionReferenceTests.mm index 547078f..cb99d24 100644 --- a/Firestore/Example/Tests/API/FIRCollectionReferenceTests.mm +++ b/Firestore/Example/Tests/API/FIRCollectionReferenceTests.mm @@ -28,9 +28,9 @@ NS_ASSUME_NONNULL_BEGIN @implementation FIRCollectionReferenceTests - (void)testEquals { - FIRCollectionReference *referenceFoo = FSTTestCollectionRef(@"foo"); - FIRCollectionReference *referenceFooDup = FSTTestCollectionRef(@"foo"); - FIRCollectionReference *referenceBar = FSTTestCollectionRef(@"bar"); + FIRCollectionReference *referenceFoo = FSTTestCollectionRef("foo"); + FIRCollectionReference *referenceFooDup = FSTTestCollectionRef("foo"); + FIRCollectionReference *referenceBar = FSTTestCollectionRef("bar"); XCTAssertEqualObjects(referenceFoo, referenceFooDup); XCTAssertNotEqualObjects(referenceFoo, referenceBar); diff --git a/Firestore/Example/Tests/API/FIRDocumentReferenceTests.mm b/Firestore/Example/Tests/API/FIRDocumentReferenceTests.mm index cc2b431..4124cd0 100644 --- a/Firestore/Example/Tests/API/FIRDocumentReferenceTests.mm +++ b/Firestore/Example/Tests/API/FIRDocumentReferenceTests.mm @@ -28,9 +28,9 @@ NS_ASSUME_NONNULL_BEGIN @implementation FIRDocumentReferenceTests - (void)testEquals { - FIRDocumentReference *referenceFoo = FSTTestDocRef(@"rooms/foo"); - FIRDocumentReference *referenceFooDup = FSTTestDocRef(@"rooms/foo"); - FIRDocumentReference *referenceBar = FSTTestDocRef(@"rooms/bar"); + FIRDocumentReference *referenceFoo = FSTTestDocRef("rooms/foo"); + FIRDocumentReference *referenceFooDup = FSTTestDocRef("rooms/foo"); + FIRDocumentReference *referenceBar = FSTTestDocRef("rooms/bar"); XCTAssertEqualObjects(referenceFoo, referenceFooDup); XCTAssertNotEqualObjects(referenceFoo, referenceBar); diff --git a/Firestore/Example/Tests/API/FIRFieldPathTests.mm b/Firestore/Example/Tests/API/FIRFieldPathTests.mm index 679ea89..50d37c1 100644 --- a/Firestore/Example/Tests/API/FIRFieldPathTests.mm +++ b/Firestore/Example/Tests/API/FIRFieldPathTests.mm @@ -19,10 +19,13 @@ #import <XCTest/XCTest.h> #import "Firestore/Source/API/FIRFieldPath+Internal.h" -#import "Firestore/Source/Model/FSTPath.h" #import "Firestore/Example/Tests/Util/FSTHelpers.h" +#include "Firestore/core/test/firebase/firestore/testutil/testutil.h" + +namespace testutil = firebase::firestore::testutil; + NS_ASSUME_NONNULL_BEGIN @interface FIRFieldPathTests : XCTestCase @@ -31,9 +34,9 @@ NS_ASSUME_NONNULL_BEGIN @implementation FIRFieldPathTests - (void)testEquals { - FIRFieldPath *foo = [[FIRFieldPath alloc] initPrivate:FSTTestFieldPath(@"foo.ooo.oooo")]; - FIRFieldPath *fooDup = [[FIRFieldPath alloc] initPrivate:FSTTestFieldPath(@"foo.ooo.oooo")]; - FIRFieldPath *bar = [[FIRFieldPath alloc] initPrivate:FSTTestFieldPath(@"baa.aaa.aaar")]; + FIRFieldPath *foo = [[FIRFieldPath alloc] initPrivate:testutil::Field("foo.ooo.oooo")]; + FIRFieldPath *fooDup = [[FIRFieldPath alloc] initPrivate:testutil::Field("foo.ooo.oooo")]; + FIRFieldPath *bar = [[FIRFieldPath alloc] initPrivate:testutil::Field("baa.aaa.aaar")]; XCTAssertEqualObjects(foo, fooDup); XCTAssertNotEqualObjects(foo, bar); diff --git a/Firestore/Example/Tests/API/FIRQuerySnapshotTests.mm b/Firestore/Example/Tests/API/FIRQuerySnapshotTests.mm index 067425a..bb8110b 100644 --- a/Firestore/Example/Tests/API/FIRQuerySnapshotTests.mm +++ b/Firestore/Example/Tests/API/FIRQuerySnapshotTests.mm @@ -18,8 +18,6 @@ #import <XCTest/XCTest.h> -#import "Firestore/Source/Model/FSTPath.h" - #import "Firestore/Example/Tests/API/FSTAPIHelpers.h" NS_ASSUME_NONNULL_BEGIN diff --git a/Firestore/Example/Tests/API/FIRQueryTests.mm b/Firestore/Example/Tests/API/FIRQueryTests.mm index 83f90be..c02c92c 100644 --- a/Firestore/Example/Tests/API/FIRQueryTests.mm +++ b/Firestore/Example/Tests/API/FIRQueryTests.mm @@ -20,7 +20,6 @@ #import "Firestore/Source/API/FIRQuery+Internal.h" #import "Firestore/Source/Core/FSTQuery.h" -#import "Firestore/Source/Model/FSTPath.h" #import "Firestore/Example/Tests/API/FSTAPIHelpers.h" @@ -33,9 +32,9 @@ NS_ASSUME_NONNULL_BEGIN - (void)testEquals { FIRFirestore *firestore = FSTTestFirestore(); - FIRQuery *queryFoo = [FIRQuery referenceWithQuery:FSTTestQuery(@"foo") firestore:firestore]; - FIRQuery *queryFooDup = [FIRQuery referenceWithQuery:FSTTestQuery(@"foo") firestore:firestore]; - FIRQuery *queryBar = [FIRQuery referenceWithQuery:FSTTestQuery(@"bar") firestore:firestore]; + FIRQuery *queryFoo = [FIRQuery referenceWithQuery:FSTTestQuery("foo") firestore:firestore]; + FIRQuery *queryFooDup = [FIRQuery referenceWithQuery:FSTTestQuery("foo") firestore:firestore]; + FIRQuery *queryBar = [FIRQuery referenceWithQuery:FSTTestQuery("bar") firestore:firestore]; XCTAssertEqualObjects(queryFoo, queryFooDup); XCTAssertNotEqualObjects(queryFoo, queryBar); XCTAssertEqualObjects([queryFoo queryWhereField:@"f" isEqualTo:@1], @@ -53,7 +52,7 @@ NS_ASSUME_NONNULL_BEGIN - (void)testFilteringWithPredicate { FIRFirestore *firestore = FSTTestFirestore(); - FIRQuery *query = [FIRQuery referenceWithQuery:FSTTestQuery(@"foo") firestore:firestore]; + FIRQuery *query = [FIRQuery referenceWithQuery:FSTTestQuery("foo") firestore:firestore]; FIRQuery *query1 = [query queryWhereField:@"f" isLessThanOrEqualTo:@1]; FIRQuery *query2 = [query queryFilteredUsingPredicate:[NSPredicate predicateWithFormat:@"f<=1"]]; FIRQuery *query3 = diff --git a/Firestore/Example/Tests/API/FSTAPIHelpers.h b/Firestore/Example/Tests/API/FSTAPIHelpers.h index 0729af0..4edd7d5 100644 --- a/Firestore/Example/Tests/API/FSTAPIHelpers.h +++ b/Firestore/Example/Tests/API/FSTAPIHelpers.h @@ -41,10 +41,10 @@ FIRDocumentSnapshot *FSTTestDocSnapshot(NSString *path, BOOL fromCache); /** A convenience method for creating a collection reference from a path string. */ -FIRCollectionReference *FSTTestCollectionRef(NSString *path); +FIRCollectionReference *FSTTestCollectionRef(const absl::string_view path); /** A convenience method for creating a document reference from a path string. */ -FIRDocumentReference *FSTTestDocRef(NSString *path); +FIRDocumentReference *FSTTestDocRef(const absl::string_view path); /** * A convenience method for creating a particular query snapshot for tests. diff --git a/Firestore/Example/Tests/API/FSTAPIHelpers.mm b/Firestore/Example/Tests/API/FSTAPIHelpers.mm index d091842..c180dc4 100644 --- a/Firestore/Example/Tests/API/FSTAPIHelpers.mm +++ b/Firestore/Example/Tests/API/FSTAPIHelpers.mm @@ -31,7 +31,12 @@ #import "Firestore/Source/Model/FSTDocument.h" #import "Firestore/Source/Model/FSTDocumentKey.h" #import "Firestore/Source/Model/FSTDocumentSet.h" -#import "Firestore/Source/Model/FSTPath.h" + +#include "Firestore/core/src/firebase/firestore/util/string_apple.h" +#include "Firestore/core/test/firebase/firestore/testutil/testutil.h" + +namespace testutil = firebase::firestore::testutil; +namespace util = firebase::firestore::util; NS_ASSUME_NONNULL_BEGIN @@ -65,12 +70,14 @@ FIRDocumentSnapshot *FSTTestDocSnapshot(NSString *path, fromCache:fromCache]; } -FIRCollectionReference *FSTTestCollectionRef(NSString *path) { - return [FIRCollectionReference referenceWithPath:FSTTestPath(path) firestore:FSTTestFirestore()]; +FIRCollectionReference *FSTTestCollectionRef(const absl::string_view path) { + return [FIRCollectionReference referenceWithPath:testutil::Resource(path) + firestore:FSTTestFirestore()]; } -FIRDocumentReference *FSTTestDocRef(NSString *path) { - return [FIRDocumentReference referenceWithPath:FSTTestPath(path) firestore:FSTTestFirestore()]; +FIRDocumentReference *FSTTestDocRef(const absl::string_view path) { + return [FIRDocumentReference referenceWithPath:testutil::Resource(path) + firestore:FSTTestFirestore()]; } /** A convenience method for creating a query snapshots for tests. */ @@ -99,15 +106,16 @@ FIRQuerySnapshot *FSTTestQuerySnapshot( changeWithDocument:docToAdd type:FSTDocumentViewChangeTypeAdded]]; } - FSTViewSnapshot *viewSnapshot = [[FSTViewSnapshot alloc] initWithQuery:FSTTestQuery(path) - documents:newDocuments - oldDocuments:oldDocuments - documentChanges:documentChanges - fromCache:fromCache - hasPendingWrites:hasPendingWrites - syncStateChanged:YES]; + FSTViewSnapshot *viewSnapshot = + [[FSTViewSnapshot alloc] initWithQuery:FSTTestQuery(util::MakeStringView(path)) + documents:newDocuments + oldDocuments:oldDocuments + documentChanges:documentChanges + fromCache:fromCache + hasPendingWrites:hasPendingWrites + syncStateChanged:YES]; return [FIRQuerySnapshot snapshotWithFirestore:FSTTestFirestore() - originalQuery:FSTTestQuery(path) + originalQuery:FSTTestQuery(util::MakeStringView(path)) snapshot:viewSnapshot metadata:metadata]; } |