Skip to content

Commit eef7419

Browse files
Closing the write and watch stream after 60s of idleness
1 parent a9b5543 commit eef7419

File tree

14 files changed

+955
-438
lines changed

14 files changed

+955
-438
lines changed

Firestore/Example/Firestore.xcodeproj/project.pbxproj

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,9 @@
5858
873B8AEB1B1F5CCA007FD442 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 873B8AEA1B1F5CCA007FD442 /* Main.storyboard */; };
5959
AFE6114F0D4DAECBA7B7C089 /* Pods_Firestore_IntegrationTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = B2FA635DF5D116A67A7441CD /* Pods_Firestore_IntegrationTests.framework */; };
6060
C4E749275AD0FBDF9F4716A8 /* Pods_SwiftBuildTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 32AD40BF6B0E849B07FFD05E /* Pods_SwiftBuildTest.framework */; };
61+
D5B2532E4676014F57A7EAB9 /* FSTStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = D5B25C0D4AADFCA3ADB883E4 /* FSTStreamTests.m */; };
62+
D5B25B66FE2390963E000FDE /* FIRTestDispatchQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = D5B25F48D1536205E8E67F2A /* FIRTestDispatchQueue.m */; };
63+
D5B25EF6FF29F02249573A35 /* FIRTestDispatchQueue.m in Sources */ = {isa = PBXBuildFile; fileRef = D5B25F48D1536205E8E67F2A /* FIRTestDispatchQueue.m */; };
6164
DE03B2C91F2149D600A30B9C /* FSTTransactionTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1C61F0D48AC0013853F /* FSTTransactionTests.m */; };
6265
DE03B2D41F2149D600A30B9C /* XCTest.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F5AF195388D20070C39A /* XCTest.framework */; };
6366
DE03B2D51F2149D600A30B9C /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; };
@@ -119,7 +122,6 @@
119122
DE51B1F31F0D491B0013853F /* FSTDatastoreTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1B31F0D48AC0013853F /* FSTDatastoreTests.m */; };
120123
DE51B1F41F0D491B0013853F /* FSTRemoteEventTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1B41F0D48AC0013853F /* FSTRemoteEventTests.m */; };
121124
DE51B1F61F0D491B0013853F /* FSTSerializerBetaTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1B61F0D48AC0013853F /* FSTSerializerBetaTests.m */; };
122-
DE51B1F71F0D491B0013853F /* FSTStreamTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1B71F0D48AC0013853F /* FSTStreamTests.m */; };
123125
DE51B1F81F0D491F0013853F /* FSTWatchChange+Testing.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1B91F0D48AC0013853F /* FSTWatchChange+Testing.m */; };
124126
DE51B1F91F0D491F0013853F /* FSTWatchChangeTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1BA1F0D48AC0013853F /* FSTWatchChangeTests.m */; };
125127
DE51B1FA1F0D492C0013853F /* FSTLevelDBSpecTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE51B1941F0D48AC0013853F /* FSTLevelDBSpecTests.m */; };
@@ -222,6 +224,9 @@
222224
B2FA635DF5D116A67A7441CD /* Pods_Firestore_IntegrationTests.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Firestore_IntegrationTests.framework; sourceTree = BUILT_PRODUCTS_DIR; };
223225
CE00BABB5A3AAB44A4C209E2 /* Pods-Firestore_Tests.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_Tests.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_Tests/Pods-Firestore_Tests.debug.xcconfig"; sourceTree = "<group>"; };
224226
D3CC3DC5338DCAF43A211155 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = "<group>"; };
227+
D5B25C0D4AADFCA3ADB883E4 /* FSTStreamTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FSTStreamTests.m; sourceTree = "<group>"; };
228+
D5B25C8BBBB84E96C06ED244 /* FIRTestDispatchQueue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FIRTestDispatchQueue.h; sourceTree = "<group>"; };
229+
D5B25F48D1536205E8E67F2A /* FIRTestDispatchQueue.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FIRTestDispatchQueue.m; sourceTree = "<group>"; };
225230
DB17FEDFB80770611A935A60 /* Pods-Firestore_IntegrationTests.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Firestore_IntegrationTests.release.xcconfig"; path = "Pods/Target Support Files/Pods-Firestore_IntegrationTests/Pods-Firestore_IntegrationTests.release.xcconfig"; sourceTree = "<group>"; };
226231
DE03B2E91F2149D600A30B9C /* Firestore_IntegrationTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = Firestore_IntegrationTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
227232
DE03B3621F215E1600A30B9C /* CAcert.pem */ = {isa = PBXFileReference; lastKnownFileType = text; path = CAcert.pem; sourceTree = "<group>"; };
@@ -292,7 +297,6 @@
292297
DE51B1B31F0D48AC0013853F /* FSTDatastoreTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTDatastoreTests.m; sourceTree = "<group>"; };
293298
DE51B1B41F0D48AC0013853F /* FSTRemoteEventTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTRemoteEventTests.m; sourceTree = "<group>"; };
294299
DE51B1B61F0D48AC0013853F /* FSTSerializerBetaTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTSerializerBetaTests.m; sourceTree = "<group>"; };
295-
DE51B1B71F0D48AC0013853F /* FSTStreamTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTStreamTests.m; sourceTree = "<group>"; };
296300
DE51B1B81F0D48AC0013853F /* FSTWatchChange+Testing.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "FSTWatchChange+Testing.h"; sourceTree = "<group>"; };
297301
DE51B1B91F0D48AC0013853F /* FSTWatchChange+Testing.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = "FSTWatchChange+Testing.m"; sourceTree = "<group>"; };
298302
DE51B1BA1F0D48AC0013853F /* FSTWatchChangeTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = FSTWatchChangeTests.m; sourceTree = "<group>"; };
@@ -561,6 +565,8 @@
561565
DE51B18A1F0D48AC0013853F /* FSTUtilTests.m */,
562566
54E9282A1F339CAD00C1953E /* XCTestCase+Await.h */,
563567
54E9282B1F339CAD00C1953E /* XCTestCase+Await.m */,
568+
D5B25F48D1536205E8E67F2A /* FIRTestDispatchQueue.m */,
569+
D5B25C8BBBB84E96C06ED244 /* FIRTestDispatchQueue.h */,
564570
);
565571
path = Util;
566572
sourceTree = "<group>";
@@ -622,7 +628,6 @@
622628
DE51B1B31F0D48AC0013853F /* FSTDatastoreTests.m */,
623629
DE51B1B41F0D48AC0013853F /* FSTRemoteEventTests.m */,
624630
DE51B1B61F0D48AC0013853F /* FSTSerializerBetaTests.m */,
625-
DE51B1B71F0D48AC0013853F /* FSTStreamTests.m */,
626631
DE51B1B81F0D48AC0013853F /* FSTWatchChange+Testing.h */,
627632
DE51B1B91F0D48AC0013853F /* FSTWatchChange+Testing.m */,
628633
DE51B1BA1F0D48AC0013853F /* FSTWatchChangeTests.m */,
@@ -639,6 +644,7 @@
639644
DE51B1C51F0D48AC0013853F /* FSTSmokeTests.m */,
640645
DE51B1C61F0D48AC0013853F /* FSTTransactionTests.m */,
641646
DE51B1C71F0D48AC0013853F /* Util */,
647+
D5B25C0D4AADFCA3ADB883E4 /* FSTStreamTests.m */,
642648
);
643649
path = Integration;
644650
sourceTree = "<group>";
@@ -1162,7 +1168,6 @@
11621168
DE51B1E91F0D490D0013853F /* FSTLevelDBMutationQueueTests.mm in Sources */,
11631169
DE51B1E61F0D490D0013853F /* FSTRemoteDocumentCacheTests.m in Sources */,
11641170
DE51B1D91F0D490D0013853F /* FSTEagerGarbageCollectorTests.m in Sources */,
1165-
DE51B1F71F0D491B0013853F /* FSTStreamTests.m in Sources */,
11661171
DE51B1E21F0D490D0013853F /* FSTMutationQueueTests.m in Sources */,
11671172
DE51B1E81F0D490D0013853F /* FSTLevelDBKeyTests.mm in Sources */,
11681173
DE51B1E31F0D490D0013853F /* FSTPersistenceTestHelpers.m in Sources */,
@@ -1176,6 +1181,7 @@
11761181
DE51B1CD1F0D48CD0013853F /* FSTDatabaseInfoTests.m in Sources */,
11771182
DE51B1F21F0D49140013853F /* FSTPathTests.m in Sources */,
11781183
DE51B1DD1F0D490D0013853F /* FSTLocalStoreTests.m in Sources */,
1184+
D5B25B66FE2390963E000FDE /* FIRTestDispatchQueue.m in Sources */,
11791185
);
11801186
runOnlyForDeploymentPostprocessing = 0;
11811187
};
@@ -1199,6 +1205,8 @@
11991205
DE03B2F21F214BAA00A30B9C /* FIRListenerRegistrationTests.m in Sources */,
12001206
DE03B2C91F2149D600A30B9C /* FSTTransactionTests.m in Sources */,
12011207
54DA12B11F315F3800DD57A1 /* FIRValidationTests.m in Sources */,
1208+
D5B2532E4676014F57A7EAB9 /* FSTStreamTests.m in Sources */,
1209+
D5B25EF6FF29F02249573A35 /* FIRTestDispatchQueue.m in Sources */,
12021210
);
12031211
runOnlyForDeploymentPostprocessing = 0;
12041212
};

Firestore/Example/Tests/Integration/API/FIRDatabaseTests.m

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -845,4 +845,22 @@ - (void)testCantGetDocumentsWhileOffline {
845845
[self awaitExpectations];
846846
}
847847

848+
- (void)testWriteStreamReconnectsAfterIdle {
849+
FIRDocumentReference *doc = [self documentRef];
850+
FIRFirestore *firestore = doc.firestore;
851+
852+
[self writeDocumentRef:doc data:@{@"foo" : @"bar"}];
853+
[self waitForIdle:firestore];
854+
[self writeDocumentRef:doc data:@{@"foo" : @"bar"}];
855+
}
856+
857+
- (void)testWatchStreamReconnectsAfterIdle {
858+
FIRDocumentReference *doc = [self documentRef];
859+
FIRFirestore *firestore = doc.firestore;
860+
861+
[self readSnapshotForRef:[self documentRef] online:YES];
862+
[self waitForIdle:firestore];
863+
[self readSnapshotForRef:[self documentRef] online:YES];
864+
}
865+
848866
@end

0 commit comments

Comments
 (0)