aboutsummaryrefslogtreecommitdiffhomepage
path: root/Firestore/Example/Tests/Integration/API
diff options
context:
space:
mode:
Diffstat (limited to 'Firestore/Example/Tests/Integration/API')
-rw-r--r--Firestore/Example/Tests/Integration/API/FIRQueryTests.m13
-rw-r--r--Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.m12
-rw-r--r--Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.m6
3 files changed, 8 insertions, 23 deletions
diff --git a/Firestore/Example/Tests/Integration/API/FIRQueryTests.m b/Firestore/Example/Tests/Integration/API/FIRQueryTests.m
index 14351a8..e92bbcf 100644
--- a/Firestore/Example/Tests/Integration/API/FIRQueryTests.m
+++ b/Firestore/Example/Tests/Integration/API/FIRQueryTests.m
@@ -227,12 +227,8 @@
FIRQuerySnapshot *querySnap = [self.eventAccumulator awaitEventWithName:@"initial event"];
XCTAssertEqualObjects(FIRQuerySnapshotGetData(querySnap), @[ @{ @"foo" : @1 } ]);
XCTAssertEqual(querySnap.metadata.isFromCache, NO);
- XCTestExpectation *networkDisabled = [self expectationWithDescription:@"disable network"];
- [collection.firestore.client disableNetworkWithCompletion:^(NSError *error) {
- [networkDisabled fulfill];
- }];
- [self awaitExpectations];
+ [self disableNetwork];
querySnap = [self.eventAccumulator awaitEventWithName:@"offline event with isFromCache=YES"];
XCTAssertEqual(querySnap.metadata.isFromCache, YES);
@@ -241,12 +237,7 @@
// sufficient.
[NSThread sleepForTimeInterval:0.2f];
- XCTestExpectation *networkEnabled = [self expectationWithDescription:@"enable network"];
- [collection.firestore.client enableNetworkWithCompletion:^(NSError *error) {
- [networkEnabled fulfill];
- }];
- [self awaitExpectations];
-
+ [self enableNetwork];
querySnap = [self.eventAccumulator awaitEventWithName:@"back online event with isFromCache=NO"];
XCTAssertEqual(querySnap.metadata.isFromCache, NO);
}
diff --git a/Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.m b/Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.m
index 2a21dc0..5cda053 100644
--- a/Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.m
+++ b/Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.m
@@ -167,18 +167,6 @@
[self awaitExpectations];
}
-/** Disables the network synchronously. */
-- (void)disableNetwork {
- [_docRef.firestore.client disableNetworkWithCompletion:_accumulator.errorEventHandler];
- [_accumulator awaitEventWithName:@"Disconnect event."];
-}
-
-/** Enables the network synchronously. */
-- (void)enableNetwork {
- [_docRef.firestore.client enableNetworkWithCompletion:_accumulator.errorEventHandler];
- [_accumulator awaitEventWithName:@"Reconnect event."];
-}
-
#pragma mark - Test Cases
- (void)testServerTimestampsWorkViaSet {
diff --git a/Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.m b/Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.m
index 8ac5491..5e7f6d7 100644
--- a/Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.m
+++ b/Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.m
@@ -47,6 +47,12 @@
FIRWriteBatch *batch2 = [doc.firestore batch];
[batch2 setData:@{@"cc" : @"dd"} forDocument:doc];
[batch2 commit];
+
+ // TODO(b/70631617): There's currently a backend bug that prevents us from using a resume token
+ // right away (against hexa at least). So we sleep. :-( :-( Anything over ~10ms seems to be
+ // sufficient.
+ [NSThread sleepForTimeInterval:0.2f];
+
FIRDocumentSnapshot *snapshot2 = [self readDocumentForRef:doc];
XCTAssertTrue(snapshot2.exists);
XCTAssertEqualObjects(snapshot2.data, @{@"cc" : @"dd"});