File tree Expand file tree Collapse file tree 1 file changed +24
-0
lines changed
Firestore/Example/Tests/Integration/API Expand file tree Collapse file tree 1 file changed +24
-0
lines changed Original file line number Diff line number Diff line change @@ -1592,6 +1592,30 @@ - (void)testListenerCallbackCanCallRemoveWithoutBlocking {
1592
1592
XCTAssertEqualObjects (steps, @" 12" );
1593
1593
}
1594
1594
1595
+ - (void )testListenerCallbacksHappenOnMainThread {
1596
+ // Verify that callbacks occur on the main thread if settings.dispatchQueue is not specified.
1597
+ XCTestExpectation *invoked = [self expectationWithDescription: @" listener invoked" ];
1598
+ invoked.assertForOverFulfill = false ;
1599
+
1600
+ FIRDocumentReference *doc = [self documentRef ];
1601
+ [self writeDocumentRef: doc data: @{@" foo" : @" bar" }];
1602
+
1603
+ __block bool callbackThreadIsMainThread;
1604
+ __block NSString *callbackThreadDescription;
1605
+
1606
+ [doc addSnapshotListener: ^(FIRDocumentSnapshot *, NSError *) {
1607
+ callbackThreadIsMainThread = NSThread .isMainThread ;
1608
+ callbackThreadDescription = [NSString stringWithFormat: @" %@ " , NSThread .currentThread];
1609
+ [invoked fulfill ];
1610
+ }];
1611
+
1612
+ [self awaitExpectation: invoked];
1613
+ XCTAssertTrue (callbackThreadIsMainThread,
1614
+ @" The listener callback was expected to occur on the main thread, but instead it "
1615
+ @" occurred on the thread %@ " ,
1616
+ callbackThreadDescription);
1617
+ }
1618
+
1595
1619
- (void )testWaitForPendingWritesCompletes {
1596
1620
FIRDocumentReference *doc = [self documentRef ];
1597
1621
FIRFirestore *firestore = doc.firestore ;
You can’t perform that action at this time.
0 commit comments