Skip to content

Commit 17867c7

Browse files
authored
Resolve macros related to STLPort. (#486)
* Resolve macros related to STLPort. Read more: FIREBASE_USE_STD_FUNCTION: Always defined STLPORT: Always undefined _STLPORT_VERSION: Always undefined * Address code review. * Remove the fn definition/declarations that are only defined for DOXYGEN. * Remove EventListener from public API. * Address code review. * Remove event_listener.h from app/CMakeLists.txt.
1 parent fff6358 commit 17867c7

32 files changed

+26
-396
lines changed

app/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -468,7 +468,6 @@ if (IOS)
468468
${FIREBASE_SOURCE_DIR}/firestore/src/include/firebase/firestore/document_change.h
469469
${FIREBASE_SOURCE_DIR}/firestore/src/include/firebase/firestore/document_reference.h
470470
${FIREBASE_SOURCE_DIR}/firestore/src/include/firebase/firestore/document_snapshot.h
471-
${FIREBASE_SOURCE_DIR}/firestore/src/include/firebase/firestore/event_listener.h
472471
${FIREBASE_SOURCE_DIR}/firestore/src/include/firebase/firestore/field_path.h
473472
${FIREBASE_SOURCE_DIR}/firestore/src/include/firebase/firestore/field_value.h
474473
${FIREBASE_SOURCE_DIR}/firestore/src/include/firebase/firestore/listener_registration.h

firestore/integration_test/src/integration_test.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,6 @@ TEST_F(FirebaseFirestoreBasicTest, TestSetDelete) {
448448
}
449449

450450
TEST_F(FirebaseFirestoreBasicTest, TestDocumentListener) {
451-
SKIP_TEST_IF_USING_STLPORT; // STLPort uses EventListener<T> rather than
452-
// std::function.
453-
#if !defined(STLPORT)
454451
SignIn();
455452

456453
firebase::firestore::DocumentReference document = Doc();
@@ -487,7 +484,6 @@ TEST_F(FirebaseFirestoreBasicTest, TestDocumentListener) {
487484
{"val", firebase::firestore::FieldValue::String("start")}},
488485
firebase::firestore::MapFieldValue{
489486
{"val", firebase::firestore::FieldValue::String("update")}}));
490-
#endif // !defined(STLPORT)
491487
}
492488

493489
TEST_F(FirebaseFirestoreBasicTest, TestBatchWrite) {

firestore/integration_test_internal/src/cleanup_test.cc

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -99,12 +99,8 @@ void ExpectAllMethodsAreNoOps(DocumentReference* ptr) {
9999

100100
EXPECT_TRUE(ptr->Delete() == FailedFuture<void>());
101101

102-
#if defined(FIREBASE_USE_STD_FUNCTION)
103102
ptr->AddSnapshotListener(
104103
[](const DocumentSnapshot&, Error, const std::string&) {});
105-
#else
106-
ptr->AddSnapshotListener(nullptr);
107-
#endif
108104
}
109105

110106
void ExpectAllMethodsAreNoOps(DocumentSnapshot* ptr) {
@@ -215,12 +211,8 @@ void ExpectAllMethodsAreNoOps(Query* ptr) {
215211

216212
EXPECT_TRUE(ptr->Get() == FailedFuture<QuerySnapshot>());
217213

218-
#if defined(FIREBASE_USE_STD_FUNCTION)
219214
ptr->AddSnapshotListener(
220215
[](const QuerySnapshot&, Error, const std::string&) {});
221-
#else
222-
ptr->AddSnapshotListener(nullptr);
223-
#endif
224216
}
225217

226218
void ExpectAllMethodsAreNoOps(QuerySnapshot* ptr) {
@@ -358,7 +350,6 @@ TEST_F(CleanupTest, FieldValueIsBlankAfterCleanup) {
358350
// after cleanup. Thus, there is no case where a user could be accessing
359351
// a "blank" Firestore instance.
360352

361-
#if defined(FIREBASE_USE_STD_FUNCTION)
362353
TEST_F(CleanupTest, ListenerRegistrationIsBlankAfterCleanup) {
363354
{
364355
ListenerRegistration default_constructed;
@@ -373,7 +364,6 @@ TEST_F(CleanupTest, ListenerRegistrationIsBlankAfterCleanup) {
373364
SCOPED_TRACE("ListenerRegistration.AfterCleanup");
374365
ExpectAllMethodsAreNoOps(&reg);
375366
}
376-
#endif
377367

378368
// Note: `Query` cleanup is tested as part of `CollectionReference` cleanup
379369
// (`CollectionReference` is derived from `Query`).

firestore/integration_test_internal/src/firestore_integration_test.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,14 @@ class TestEventListener : public EventListener<T> {
108108
return last_results_[last_results_.size() - 1 - i];
109109
}
110110

111-
// Hides the STLPort-related quirk that `AddSnapshotListener` has different
112-
// signatures depending on whether `std::function` is available.
113111
template <typename U>
114112
ListenerRegistration AttachTo(
115113
U* ref, MetadataChanges metadata_changes = MetadataChanges::kExclude) {
116-
#if defined(FIREBASE_USE_STD_FUNCTION)
117114
return ref->AddSnapshotListener(
118115
metadata_changes, [this](const T& result, Error error_code,
119116
const std::string& error_message) {
120117
OnEvent(result, error_code, error_message);
121118
});
122-
#else
123-
return ref->AddSnapshotListener(metadata_changes, this);
124-
#endif
125119
}
126120

127121
std::string first_error_message() {

firestore/integration_test_internal/src/firestore_test.cc

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -669,26 +669,10 @@ TEST_F(FirestoreIntegrationTest,
669669
EXPECT_EQ(1, test_data.GetEventCount());
670670
test_data.ClearEvents();
671671

672-
#if defined(FIREBASE_USE_STD_FUNCTION)
673672
ListenerRegistration sync_registration =
674673
TestFirestore()->AddSnapshotsInSyncListener(
675674
[&test_data] { test_data.AddEvent("snapshots-in-sync"); });
676675

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-
692676
Await(document.Set(MapFieldValue{{"foo", FieldValue::Double(3.0)}}));
693677
// Wait for the snapshots-in-sync listener to fire afterwards.
694678
test_data.WaitForEventCount("snapshots-in-sync", 2);
@@ -735,7 +719,6 @@ TEST_F(FirestoreIntegrationTest, TestQueriesAreValidatedOnClient) {
735719
// The test harness will generate Java JUnit test regardless whether this is
736720
// inside a #if or not. So we move #if inside instead of enclose the whole case.
737721
TEST_F(FirestoreIntegrationTest, TestListenCanBeCalledMultipleTimes) {
738-
#if defined(FIREBASE_USE_STD_FUNCTION)
739722
class TestData {
740723
public:
741724
void SetDocumentSnapshot(const DocumentSnapshot& document_snapshot) {
@@ -779,7 +762,6 @@ TEST_F(FirestoreIntegrationTest, TestListenCanBeCalledMultipleTimes) {
779762

780763
EXPECT_THAT(test_data.WaitForDocumentSnapshot().GetData(),
781764
ContainerEq(MapFieldValue{{"foo", FieldValue::String("bar")}}));
782-
#endif // defined(FIREBASE_USE_STD_FUNCTION)
783765
}
784766

785767
TEST_F(FirestoreIntegrationTest, TestDocumentSnapshotEventsNonExistent) {

firestore/integration_test_internal/src/integration_test.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -448,9 +448,6 @@ TEST_F(FirebaseFirestoreBasicTest, TestSetDelete) {
448448
}
449449

450450
TEST_F(FirebaseFirestoreBasicTest, TestDocumentListener) {
451-
SKIP_TEST_IF_USING_STLPORT; // STLPort uses EventListener<T> rather than
452-
// std::function.
453-
#if !defined(STLPORT)
454451
SignIn();
455452

456453
firebase::firestore::DocumentReference document = Doc();
@@ -487,7 +484,6 @@ TEST_F(FirebaseFirestoreBasicTest, TestDocumentListener) {
487484
{"val", firebase::firestore::FieldValue::String("start")}},
488485
firebase::firestore::MapFieldValue{
489486
{"val", firebase::firestore::FieldValue::String("update")}}));
490-
#endif // !defined(STLPORT)
491487
}
492488

493489
TEST_F(FirebaseFirestoreBasicTest, TestBatchWrite) {

firestore/integration_test_internal/src/server_timestamp_test.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -246,31 +246,26 @@ TEST_F(ServerTimestampTest,
246246
}
247247

248248
TEST_F(ServerTimestampTest, TestServerTimestampsWorkViaTransactionSet) {
249-
#if defined(FIREBASE_USE_STD_FUNCTION)
250249
Await(TestFirestore()->RunTransaction(
251250
[this](Transaction& transaction, std::string&) -> Error {
252251
transaction.Set(doc_, set_data_);
253252
return Error::kErrorOk;
254253
}));
255254
VerifyTimestampsAreResolved(accumulator_.AwaitRemoteEvent());
256-
#endif // defined(FIREBASE_USE_STD_FUNCTION)
257255
}
258256

259257
TEST_F(ServerTimestampTest, TestServerTimestampsWorkViaTransactionUpdate) {
260-
#if defined(FIREBASE_USE_STD_FUNCTION)
261258
WriteInitialData();
262259
Await(TestFirestore()->RunTransaction(
263260
[this](Transaction& transaction, std::string&) -> Error {
264261
transaction.Update(doc_, update_data_);
265262
return Error::kErrorOk;
266263
}));
267264
VerifyTimestampsAreResolved(accumulator_.AwaitRemoteEvent());
268-
#endif // defined(FIREBASE_USE_STD_FUNCTION)
269265
}
270266

271267
TEST_F(ServerTimestampTest,
272268
TestServerTimestampsFailViaTransactionUpdateOnNonexistentDocument) {
273-
#if defined(FIREBASE_USE_STD_FUNCTION)
274269
Future<void> future = TestFirestore()->RunTransaction(
275270
[this](Transaction& transaction, std::string&) -> Error {
276271
transaction.Update(doc_, update_data_);
@@ -279,7 +274,6 @@ TEST_F(ServerTimestampTest,
279274
Await(future);
280275
EXPECT_EQ(FutureStatus::kFutureStatusComplete, future.status());
281276
EXPECT_EQ(Error::kErrorNotFound, future.error());
282-
#endif // defined(FIREBASE_USE_STD_FUNCTION)
283277
}
284278

285279
TEST_F(ServerTimestampTest,

firestore/integration_test_internal/src/transaction_extra_test.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ namespace firestore {
2424

2525
using TransactionExtraTest = FirestoreIntegrationTest;
2626

27-
#if defined(FIREBASE_USE_STD_FUNCTION)
28-
2927
TEST_F(TransactionExtraTest,
3028
TestRetriesWhenDocumentThatWasReadWithoutBeingWrittenChanges) {
3129
DocumentReference doc1 = TestFirestore()->Collection("counter").Document();
@@ -103,7 +101,5 @@ TEST_F(TransactionExtraTest, TestReadingADocTwiceWithDifferentVersions) {
103101
DocumentSnapshot snapshot = ReadDocument(doc);
104102
}
105103

106-
#endif // defined(FIREBASE_USE_STD_FUNCTION)
107-
108104
} // namespace firestore
109105
} // namespace firebase

firestore/integration_test_internal/src/transaction_test.cc

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ using ::testing::HasSubstr;
3737

3838
class TransactionTest : public FirestoreIntegrationTest {
3939
protected:
40-
#if defined(FIREBASE_USE_STD_FUNCTION)
4140
// We occasionally get transient error like "Could not reach Cloud Firestore
4241
// backend. Backend didn't respond within 10 seconds". Transaction requires
4342
// online and thus will not retry. So we do the retry in the testcase.
@@ -88,7 +87,6 @@ class TransactionTest : public FirestoreIntegrationTest {
8887
FAIL() << "Unexpected error code: " << error;
8988
}
9089
}
91-
#endif // defined(FIREBASE_USE_STD_FUNCTION)
9290
};
9391

9492
class TestTransactionFunction : public TransactionFunction {
@@ -125,8 +123,6 @@ TEST_F(TransactionTest, TestGetNonexistentDocumentThenCreatePortableVersion) {
125123
snapshot.Get(transaction.key()));
126124
}
127125

128-
#if defined(FIREBASE_USE_STD_FUNCTION)
129-
130126
class TransactionStage {
131127
public:
132128
TransactionStage(
@@ -735,7 +731,5 @@ TEST_F(TransactionTest, TestCancellationOnError) {
735731
EXPECT_FALSE(snapshot.exists());
736732
}
737733

738-
#endif // defined(FIREBASE_USE_STD_FUNCTION)
739-
740734
} // namespace firestore
741735
} // namespace firebase

firestore/integration_test_internal/src/validation_test.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ class ValidationTest : public FirestoreIntegrationTest {
9090
EXPECT_ERROR(TestFirestore()->batch().Update(document, data), reason);
9191
}
9292

93-
#if defined(FIREBASE_USE_STD_FUNCTION)
9493
Await(TestFirestore()->RunTransaction(
9594
[data, reason, include_sets, include_updates, document](
9695
Transaction& transaction, std::string& error_message) -> Error {
@@ -104,7 +103,6 @@ class ValidationTest : public FirestoreIntegrationTest {
104103
}
105104
return Error::kErrorOk;
106105
}));
107-
#endif // defined(FIREBASE_USE_STD_FUNCTION)
108106
}
109107

110108
/**
@@ -337,7 +335,6 @@ TEST_F(ValidationTest, WritesMayContainIndirectlyNestedLists) {
337335
Await(document.Update(data));
338336
Await(TestFirestore()->batch().Update(document, data).Commit());
339337

340-
#if defined(FIREBASE_USE_STD_FUNCTION)
341338
Await(TestFirestore()->RunTransaction(
342339
[data, document, another_document](Transaction& transaction,
343340
std::string& error_message) -> Error {
@@ -347,7 +344,6 @@ TEST_F(ValidationTest, WritesMayContainIndirectlyNestedLists) {
347344
transaction.Set(another_document, data);
348345
return Error::kErrorOk;
349346
}));
350-
#endif // defined(FIREBASE_USE_STD_FUNCTION)
351347
}
352348

353349
// TODO(zxu): There is no way to create Firestore with different project id yet.

0 commit comments

Comments
 (0)