Skip to content

Commit 12968c3

Browse files
authored
Remove STLPort support from public API. (#510)
* Remove STLPort support from public API. * Don't use EventListener in integration tests.
1 parent 0ff0c6d commit 12968c3

33 files changed

+33
-403
lines changed

app/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,6 @@ if (IOS)
469469
${FIREBASE_SOURCE_DIR}/firestore/src/include/firebase/firestore/document_change.h
470470
${FIREBASE_SOURCE_DIR}/firestore/src/include/firebase/firestore/document_reference.h
471471
${FIREBASE_SOURCE_DIR}/firestore/src/include/firebase/firestore/document_snapshot.h
472-
${FIREBASE_SOURCE_DIR}/firestore/src/include/firebase/firestore/event_listener.h
473472
${FIREBASE_SOURCE_DIR}/firestore/src/include/firebase/firestore/field_path.h
474473
${FIREBASE_SOURCE_DIR}/firestore/src/include/firebase/firestore/field_value.h
475474
${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
@@ -101,12 +101,8 @@ void ExpectAllMethodsAreNoOps(DocumentReference* ptr) {
101101

102102
EXPECT_TRUE(ptr->Delete() == FailedFuture<void>());
103103

104-
#if defined(FIREBASE_USE_STD_FUNCTION)
105104
ptr->AddSnapshotListener(
106105
[](const DocumentSnapshot&, Error, const std::string&) {});
107-
#else
108-
ptr->AddSnapshotListener(nullptr);
109-
#endif
110106
}
111107

112108
void ExpectAllMethodsAreNoOps(DocumentSnapshot* ptr) {
@@ -217,12 +213,8 @@ void ExpectAllMethodsAreNoOps(Query* ptr) {
217213

218214
EXPECT_TRUE(ptr->Get() == FailedFuture<QuerySnapshot>());
219215

220-
#if defined(FIREBASE_USE_STD_FUNCTION)
221216
ptr->AddSnapshotListener(
222217
[](const QuerySnapshot&, Error, const std::string&) {});
223-
#else
224-
ptr->AddSnapshotListener(nullptr);
225-
#endif
226218
}
227219

228220
void ExpectAllMethodsAreNoOps(QuerySnapshot* ptr) {
@@ -360,7 +352,6 @@ TEST_F(CleanupTest, FieldValueIsBlankAfterCleanup) {
360352
// after cleanup. Thus, there is no case where a user could be accessing
361353
// a "blank" Firestore instance.
362354

363-
#if defined(FIREBASE_USE_STD_FUNCTION)
364355
TEST_F(CleanupTest, ListenerRegistrationIsBlankAfterCleanup) {
365356
{
366357
ListenerRegistration default_constructed;
@@ -375,7 +366,6 @@ TEST_F(CleanupTest, ListenerRegistrationIsBlankAfterCleanup) {
375366
SCOPED_TRACE("ListenerRegistration.AfterCleanup");
376367
ExpectAllMethodsAreNoOps(&reg);
377368
}
378-
#endif
379369

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

firestore/integration_test_internal/src/firestore_integration_test.h

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -57,15 +57,15 @@ class EventAccumulator;
5757
// An EventListener class for writing tests. This listener counts the number of
5858
// events as well as keeps track of the last result.
5959
template <typename T>
60-
class TestEventListener : public EventListener<T> {
60+
class TestEventListener {
6161
public:
6262
explicit TestEventListener(std::string name) : name_(std::move(name)) {}
6363

64-
~TestEventListener() override {}
64+
virtual ~TestEventListener() {}
6565

66-
void OnEvent(const T& value,
67-
Error error_code,
68-
const std::string& error_message) override {
66+
virtual void OnEvent(const T& value,
67+
Error error_code,
68+
const std::string& error_message) {
6969
if (print_debug_info_) {
7070
std::cout << "TestEventListener got: ";
7171
if (error_code == Error::kErrorOk) {
@@ -110,20 +110,14 @@ class TestEventListener : public EventListener<T> {
110110
return last_results_[last_results_.size() - 1 - i];
111111
}
112112

113-
// Hides the STLPort-related quirk that `AddSnapshotListener` has different
114-
// signatures depending on whether `std::function` is available.
115113
template <typename U>
116114
ListenerRegistration AttachTo(
117115
U* ref, MetadataChanges metadata_changes = MetadataChanges::kExclude) {
118-
#if defined(FIREBASE_USE_STD_FUNCTION)
119116
return ref->AddSnapshotListener(
120117
metadata_changes, [this](const T& result, Error error_code,
121118
const std::string& error_message) {
122119
OnEvent(result, error_code, error_message);
123120
});
124-
#else
125-
return ref->AddSnapshotListener(metadata_changes, this);
126-
#endif
127121
}
128122

129123
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
@@ -671,26 +671,10 @@ TEST_F(FirestoreIntegrationTest,
671671
EXPECT_EQ(1, test_data.GetEventCount());
672672
test_data.ClearEvents();
673673

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

679-
#else
680-
class SyncEventListener : public EventListener<void> {
681-
public:
682-
explicit SyncEventListener(TestData& test_data) : test_data_(test_data) {}
683-
684-
void OnEvent(Error) override { test_data_.AddEvent("snapshots-in-sync"); }
685-
686-
private:
687-
TestData& test_data_;
688-
};
689-
SyncEventListener sync_listener{test_data};
690-
ListenerRegistration sync_registration =
691-
TestFirestore()->AddSnapshotsInSyncListener(sync_listener);
692-
#endif // defined(FIREBASE_USE_STD_FUNCTION)
693-
694678
Await(document.Set(MapFieldValue{{"foo", FieldValue::Double(3.0)}}));
695679
// Wait for the snapshots-in-sync listener to fire afterwards.
696680
test_data.WaitForEventCount("snapshots-in-sync", 2);
@@ -737,7 +721,6 @@ TEST_F(FirestoreIntegrationTest, TestQueriesAreValidatedOnClient) {
737721
// The test harness will generate Java JUnit test regardless whether this is
738722
// inside a #if or not. So we move #if inside instead of enclose the whole case.
739723
TEST_F(FirestoreIntegrationTest, TestListenCanBeCalledMultipleTimes) {
740-
#if defined(FIREBASE_USE_STD_FUNCTION)
741724
class TestData {
742725
public:
743726
void SetDocumentSnapshot(const DocumentSnapshot& document_snapshot) {
@@ -781,7 +764,6 @@ TEST_F(FirestoreIntegrationTest, TestListenCanBeCalledMultipleTimes) {
781764

782765
EXPECT_THAT(test_data.WaitForDocumentSnapshot().GetData(),
783766
ContainerEq(MapFieldValue{{"foo", FieldValue::String("bar")}}));
784-
#endif // defined(FIREBASE_USE_STD_FUNCTION)
785767
}
786768

787769
TEST_F(FirestoreIntegrationTest, TestDocumentSnapshotEventsNonExistent) {

firestore/integration_test_internal/src/includes_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ class IncludesTest : public testing::Test {
2020

2121
namespace {
2222

23-
struct TestListener : EventListener<int> {
24-
void OnEvent(const int&, Error, const std::string&) override {}
23+
struct TestListener {
24+
void OnEvent(const int&, Error, const std::string&) {}
2525
};
2626

2727
struct TestTransactionFunction : TransactionFunction {

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
@@ -248,31 +248,26 @@ TEST_F(ServerTimestampTest,
248248
}
249249

250250
TEST_F(ServerTimestampTest, TestServerTimestampsWorkViaTransactionSet) {
251-
#if defined(FIREBASE_USE_STD_FUNCTION)
252251
Await(TestFirestore()->RunTransaction(
253252
[this](Transaction& transaction, std::string&) -> Error {
254253
transaction.Set(doc_, set_data_);
255254
return Error::kErrorOk;
256255
}));
257256
VerifyTimestampsAreResolved(accumulator_.AwaitRemoteEvent());
258-
#endif // defined(FIREBASE_USE_STD_FUNCTION)
259257
}
260258

261259
TEST_F(ServerTimestampTest, TestServerTimestampsWorkViaTransactionUpdate) {
262-
#if defined(FIREBASE_USE_STD_FUNCTION)
263260
WriteInitialData();
264261
Await(TestFirestore()->RunTransaction(
265262
[this](Transaction& transaction, std::string&) -> Error {
266263
transaction.Update(doc_, update_data_);
267264
return Error::kErrorOk;
268265
}));
269266
VerifyTimestampsAreResolved(accumulator_.AwaitRemoteEvent());
270-
#endif // defined(FIREBASE_USE_STD_FUNCTION)
271267
}
272268

273269
TEST_F(ServerTimestampTest,
274270
TestServerTimestampsFailViaTransactionUpdateOnNonexistentDocument) {
275-
#if defined(FIREBASE_USE_STD_FUNCTION)
276271
Future<void> future = TestFirestore()->RunTransaction(
277272
[this](Transaction& transaction, std::string&) -> Error {
278273
transaction.Update(doc_, update_data_);
@@ -281,7 +276,6 @@ TEST_F(ServerTimestampTest,
281276
Await(future);
282277
EXPECT_EQ(FutureStatus::kFutureStatusComplete, future.status());
283278
EXPECT_EQ(Error::kErrorNotFound, future.error());
284-
#endif // defined(FIREBASE_USE_STD_FUNCTION)
285279
}
286280

287281
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
@@ -26,8 +26,6 @@ namespace firestore {
2626

2727
using TransactionExtraTest = FirestoreIntegrationTest;
2828

29-
#if defined(FIREBASE_USE_STD_FUNCTION)
30-
3129
TEST_F(TransactionExtraTest,
3230
TestRetriesWhenDocumentThatWasReadWithoutBeingWrittenChanges) {
3331
DocumentReference doc1 = TestFirestore()->Collection("counter").Document();
@@ -105,7 +103,5 @@ TEST_F(TransactionExtraTest, TestReadingADocTwiceWithDifferentVersions) {
105103
DocumentSnapshot snapshot = ReadDocument(doc);
106104
}
107105

108-
#endif // defined(FIREBASE_USE_STD_FUNCTION)
109-
110106
} // namespace firestore
111107
} // namespace firebase

firestore/integration_test_internal/src/transaction_test.cc

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

4040
class TransactionTest : public FirestoreIntegrationTest {
4141
protected:
42-
#if defined(FIREBASE_USE_STD_FUNCTION)
4342
// We occasionally get transient error like "Could not reach Cloud Firestore
4443
// backend. Backend didn't respond within 10 seconds". Transaction requires
4544
// online and thus will not retry. So we do the retry in the testcase.
@@ -90,7 +89,6 @@ class TransactionTest : public FirestoreIntegrationTest {
9089
FAIL() << "Unexpected error code: " << error;
9190
}
9291
}
93-
#endif // defined(FIREBASE_USE_STD_FUNCTION)
9492
};
9593

9694
class TestTransactionFunction : public TransactionFunction {
@@ -127,8 +125,6 @@ TEST_F(TransactionTest, TestGetNonexistentDocumentThenCreatePortableVersion) {
127125
snapshot.Get(transaction.key()));
128126
}
129127

130-
#if defined(FIREBASE_USE_STD_FUNCTION)
131-
132128
class TransactionStage {
133129
public:
134130
TransactionStage(
@@ -737,7 +733,5 @@ TEST_F(TransactionTest, TestCancellationOnError) {
737733
EXPECT_FALSE(snapshot.exists());
738734
}
739735

740-
#endif // defined(FIREBASE_USE_STD_FUNCTION)
741-
742736
} // namespace firestore
743737
} // namespace firebase

0 commit comments

Comments
 (0)