diff options
author | Gil <mcg@google.com> | 2018-04-15 16:56:43 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-15 16:56:43 -0700 |
commit | 4de2d80e4371e50419823961789424d40561f75a (patch) | |
tree | df0248786efd946233490508557d10faf2021554 /Firestore/Example/Tests/Integration | |
parent | 5368c9e22f9a6b427466e9422645d688953013c0 (diff) |
Replace `QueryListenOptions` with simple booleans (#1106)
* Replace `QueryListenOptions` with simple booleans
Instead of calling
addSnapshotListener(
options:QueryListenOptions.includeQueryMetadataChanges()
.includeDocumentMetadataChanges())
call
addSnapshotListener(includeMetadataChanges:true)
Also change `QuerySnapshot.documentChanges()` into a method which
optionally takes `includeMetadataChanges:true`. By default even when
listening to a query with `inlcudeMetadataChanges:true` metadata-only
document changes are suppressed because they're confusing.
* Revert QuerySnapshot.documentChanges back to a property
Add usage.
Diffstat (limited to 'Firestore/Example/Tests/Integration')
-rw-r--r-- | Firestore/Example/Tests/Integration/API/FIRQueryTests.mm | 26 | ||||
-rw-r--r-- | Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.mm | 15 |
2 files changed, 17 insertions, 24 deletions
diff --git a/Firestore/Example/Tests/Integration/API/FIRQueryTests.mm b/Firestore/Example/Tests/Integration/API/FIRQueryTests.mm index 32d746e..d1c0d75 100644 --- a/Firestore/Example/Tests/Integration/API/FIRQueryTests.mm +++ b/Firestore/Example/Tests/Integration/API/FIRQueryTests.mm @@ -221,16 +221,14 @@ FIRFirestore *firestore = collectionRef.firestore; - FIRQueryListenOptions *options = [[[FIRQueryListenOptions options] - includeDocumentMetadataChanges:YES] includeQueryMetadataChanges:YES]; - - [collectionRef addSnapshotListenerWithOptions:options - listener:^(FIRQuerySnapshot *snapshot, NSError *error) { - XCTAssertNil(error); - if (!snapshot.empty && !snapshot.metadata.fromCache) { - [testExpectiation fulfill]; - } - }]; + [collectionRef + addSnapshotListenerWithIncludeMetadataChanges:YES + listener:^(FIRQuerySnapshot *snapshot, NSError *error) { + XCTAssertNil(error); + if (!snapshot.empty && !snapshot.metadata.fromCache) { + [testExpectiation fulfill]; + } + }]; [firestore disableNetworkWithCompletion:^(NSError *error) { XCTAssertNil(error); @@ -249,11 +247,9 @@ }; FIRCollectionReference *collection = [self collectionRefWithDocuments:testDocs]; - FIRQueryListenOptions *options = [[[FIRQueryListenOptions options] - includeDocumentMetadataChanges:YES] includeQueryMetadataChanges:YES]; - id<FIRListenerRegistration> registration = - [collection addSnapshotListenerWithOptions:options - listener:self.eventAccumulator.valueEventHandler]; + id<FIRListenerRegistration> registration = [collection + addSnapshotListenerWithIncludeMetadataChanges:YES + listener:self.eventAccumulator.valueEventHandler]; FIRQuerySnapshot *querySnap = [self.eventAccumulator awaitEventWithName:@"initial event"]; XCTAssertEqualObjects(FIRQuerySnapshotGetData(querySnap), @[ @{ @"foo" : @1 } ]); diff --git a/Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.mm b/Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.mm index 3f2d64b..5340873 100644 --- a/Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.mm +++ b/Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.mm @@ -147,9 +147,8 @@ FIRDocumentReference *docA = [collection documentWithPath:@"a"]; FIRDocumentReference *docB = [collection documentWithPath:@"b"]; FSTEventAccumulator *accumulator = [FSTEventAccumulator accumulatorForTest:self]; - [collection addSnapshotListenerWithOptions:[[FIRQueryListenOptions options] - includeQueryMetadataChanges:YES] - listener:accumulator.valueEventHandler]; + [collection addSnapshotListenerWithIncludeMetadataChanges:YES + listener:accumulator.valueEventHandler]; FIRQuerySnapshot *initialSnap = [accumulator awaitEventWithName:@"initial event"]; XCTAssertEqual(initialSnap.count, 0); @@ -177,9 +176,8 @@ FIRDocumentReference *docA = [collection documentWithPath:@"a"]; FIRDocumentReference *docB = [collection documentWithPath:@"b"]; FSTEventAccumulator *accumulator = [FSTEventAccumulator accumulatorForTest:self]; - [collection addSnapshotListenerWithOptions:[[FIRQueryListenOptions options] - includeQueryMetadataChanges:YES] - listener:accumulator.valueEventHandler]; + [collection addSnapshotListenerWithIncludeMetadataChanges:YES + listener:accumulator.valueEventHandler]; FIRQuerySnapshot *initialSnap = [accumulator awaitEventWithName:@"initial event"]; XCTAssertEqual(initialSnap.count, 0); @@ -211,9 +209,8 @@ FIRDocumentReference *docA = [collection documentWithPath:@"a"]; FIRDocumentReference *docB = [collection documentWithPath:@"b"]; FSTEventAccumulator *accumulator = [FSTEventAccumulator accumulatorForTest:self]; - [collection addSnapshotListenerWithOptions:[[FIRQueryListenOptions options] - includeQueryMetadataChanges:YES] - listener:accumulator.valueEventHandler]; + [collection addSnapshotListenerWithIncludeMetadataChanges:YES + listener:accumulator.valueEventHandler]; FIRQuerySnapshot *initialSnap = [accumulator awaitEventWithName:@"initial event"]; XCTAssertEqual(initialSnap.count, 0); |