@@ -669,10 +669,26 @@ TEST_F(FirestoreIntegrationTest,
669
669
EXPECT_EQ (1 , test_data.GetEventCount ());
670
670
test_data.ClearEvents ();
671
671
672
+ #if defined(FIREBASE_USE_STD_FUNCTION)
672
673
ListenerRegistration sync_registration =
673
674
TestFirestore ()->AddSnapshotsInSyncListener (
674
675
[&test_data] { test_data.AddEvent (" snapshots-in-sync" ); });
675
676
677
+ #else
678
+ class SyncEventListener : public EventListener <void > {
679
+ public:
680
+ explicit SyncEventListener (TestData& test_data) : test_data_(test_data) {}
681
+
682
+ void OnEvent (Error) override { test_data_.AddEvent (" snapshots-in-sync" ); }
683
+
684
+ private:
685
+ TestData& test_data_;
686
+ };
687
+ SyncEventListener sync_listener{test_data};
688
+ ListenerRegistration sync_registration =
689
+ TestFirestore ()->AddSnapshotsInSyncListener (sync_listener);
690
+ #endif // defined(FIREBASE_USE_STD_FUNCTION)
691
+
676
692
Await (document.Set (MapFieldValue{{" foo" , FieldValue::Double (3.0 )}}));
677
693
// Wait for the snapshots-in-sync listener to fire afterwards.
678
694
test_data.WaitForEventCount (" snapshots-in-sync" , 2 );
@@ -719,6 +735,7 @@ TEST_F(FirestoreIntegrationTest, TestQueriesAreValidatedOnClient) {
719
735
// The test harness will generate Java JUnit test regardless whether this is
720
736
// inside a #if or not. So we move #if inside instead of enclose the whole case.
721
737
TEST_F (FirestoreIntegrationTest, TestListenCanBeCalledMultipleTimes) {
738
+ #if defined(FIREBASE_USE_STD_FUNCTION)
722
739
class TestData {
723
740
public:
724
741
void SetDocumentSnapshot (const DocumentSnapshot& document_snapshot) {
@@ -762,6 +779,7 @@ TEST_F(FirestoreIntegrationTest, TestListenCanBeCalledMultipleTimes) {
762
779
763
780
EXPECT_THAT (test_data.WaitForDocumentSnapshot ().GetData (),
764
781
ContainerEq (MapFieldValue{{" foo" , FieldValue::String (" bar" )}}));
782
+ #endif // defined(FIREBASE_USE_STD_FUNCTION)
765
783
}
766
784
767
785
TEST_F (FirestoreIntegrationTest, TestDocumentSnapshotEventsNonExistent) {
0 commit comments