From a1e5e1d85eb001e81e884f28e03cc161e7e38fa4 Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Wed, 16 Jun 2021 11:41:04 -0400 Subject: [PATCH 1/2] Format Firestore integration test code --- .../integration_test/src/integration_test.cc | 8 +++++-- .../src/android/cancellation_token_source.cc | 4 +++- .../firestore_integration_test_android.cc | 3 ++- .../firestore_integration_test_android.h | 7 ++++-- .../src/android/promise_android_test.cc | 21 +++++++++++----- .../src/array_transform_test.cc | 8 +++++-- .../src/includes_test.cc | 7 ++++-- .../src/integration_test.cc | 8 +++++-- .../src/jni/declaration_test.cc | 4 +++- .../src/jni/env_test.cc | 11 ++++++--- .../src/jni/object_test.cc | 3 ++- .../src/jni/ownership_test.cc | 7 ++++-- .../src/numeric_transforms_test.cc | 4 +++- .../src/sanity_test.cc | 8 +++++-- .../src/server_timestamp_test.cc | 7 ++++-- .../src/util/future_test_util.cc | 4 +++- .../src/util/integration_test_util.cc | 4 +++- .../src/validation_test.cc | 24 ++++++++++++------- 18 files changed, 102 insertions(+), 40 deletions(-) diff --git a/firestore/integration_test/src/integration_test.cc b/firestore/integration_test/src/integration_test.cc index b62edbe5bf..2500000ef5 100644 --- a/firestore/integration_test/src/integration_test.cc +++ b/firestore/integration_test/src/integration_test.cc @@ -140,7 +140,9 @@ class FirebaseFirestoreBasicTest : public FirebaseTest { firebase::App* FirebaseFirestoreBasicTest::shared_app_; firebase::auth::Auth* FirebaseFirestoreBasicTest::shared_auth_; -void FirebaseFirestoreBasicTest::SetUpTestSuite() { InitializeAppAndAuth(); } +void FirebaseFirestoreBasicTest::SetUpTestSuite() { + InitializeAppAndAuth(); +} void FirebaseFirestoreBasicTest::InitializeAppAndAuth() { LogDebug("Initialize Firebase App."); @@ -182,7 +184,9 @@ void FirebaseFirestoreBasicTest::InitializeAppAndAuth() { SignIn(); } -void FirebaseFirestoreBasicTest::TearDownTestSuite() { TerminateAppAndAuth(); } +void FirebaseFirestoreBasicTest::TearDownTestSuite() { + TerminateAppAndAuth(); +} void FirebaseFirestoreBasicTest::TerminateAppAndAuth() { if (shared_auth_) { diff --git a/firestore/integration_test_internal/src/android/cancellation_token_source.cc b/firestore/integration_test_internal/src/android/cancellation_token_source.cc index edfeecabba..d6210826bd 100644 --- a/firestore/integration_test_internal/src/android/cancellation_token_source.cc +++ b/firestore/integration_test_internal/src/android/cancellation_token_source.cc @@ -34,7 +34,9 @@ Local CancellationTokenSource::GetToken(Env& env) { return env.Call(*this, kGetToken); } -void CancellationTokenSource::Cancel(Env& env) { env.Call(*this, kCancel); } +void CancellationTokenSource::Cancel(Env& env) { + env.Call(*this, kCancel); +} } // namespace firestore } // namespace firebase diff --git a/firestore/integration_test_internal/src/android/firestore_integration_test_android.cc b/firestore/integration_test_internal/src/android/firestore_integration_test_android.cc index bae2f206ef..8daf6b3d71 100644 --- a/firestore/integration_test_internal/src/android/firestore_integration_test_android.cc +++ b/firestore/integration_test_internal/src/android/firestore_integration_test_android.cc @@ -41,7 +41,8 @@ Constructor kExceptionConstructor("(Ljava/lang/String;)V"); } // namespace FirestoreAndroidIntegrationTest::FirestoreAndroidIntegrationTest() - : loader_(app()) {} + : loader_(app()) { +} void FirestoreAndroidIntegrationTest::SetUp() { FirestoreIntegrationTest::SetUp(); diff --git a/firestore/integration_test_internal/src/android/firestore_integration_test_android.h b/firestore/integration_test_internal/src/android/firestore_integration_test_android.h index 10ee990031..81a6246601 100644 --- a/firestore/integration_test_internal/src/android/firestore_integration_test_android.h +++ b/firestore/integration_test_internal/src/android/firestore_integration_test_android.h @@ -49,7 +49,8 @@ void PrintTo(const Global& object, std::ostream* os) { * jni::Local object2 = env.NewStringUtf("string"); * EXPECT_THAT(object1, JavaEq(object2)); */ -MATCHER_P(JavaEq, object, +MATCHER_P(JavaEq, + object, std::string("compares ") + (negation ? "unequal" : "equal") + " using .equals() to a " + ToDebugString(object)) { jni::Env env; @@ -66,7 +67,9 @@ class FirestoreAndroidIntegrationTest : public FirestoreIntegrationTest { void SetUp() override; void TearDown() noexcept(false) override; - jni::Loader& loader() { return loader_; } + jni::Loader& loader() { + return loader_; + } /** Creates and returns a new Java `Exception` object with a message. */ jni::Local CreateException(jni::Env& env, diff --git a/firestore/integration_test_internal/src/android/promise_android_test.cc b/firestore/integration_test_internal/src/android/promise_android_test.cc index 452e1c8b6d..9835837c22 100644 --- a/firestore/integration_test_internal/src/android/promise_android_test.cc +++ b/firestore/integration_test_internal/src/android/promise_android_test.cc @@ -41,7 +41,8 @@ namespace { class PromiseTest : public FirestoreAndroidIntegrationTest { public: - PromiseTest() : promises_(GetFirestoreInternal(TestFirestore())) {} + PromiseTest() : promises_(GetFirestoreInternal(TestFirestore())) { + } void SetUp() override { FirestoreAndroidIntegrationTest::SetUp(); @@ -59,7 +60,9 @@ class PromiseTest : public FirestoreAndroidIntegrationTest { }; protected: - PromiseFactory& promises() { return promises_; } + PromiseFactory& promises() { + return promises_; + } jni::Local GetTask() { jni::Env env = GetEnv(); @@ -82,7 +85,9 @@ class PromiseTest : public FirestoreAndroidIntegrationTest { cancellation_token_source_.Cancel(env); } - static jni::Env GetEnv() { return jni::Env(app_framework::GetJniEnv()); } + static jni::Env GetEnv() { + return jni::Env(app_framework::GetJniEnv()); + } private: PromiseFactory promises_; @@ -101,10 +106,12 @@ class PromiseTest : public FirestoreAndroidIntegrationTest { // latter specialization provides access to the "result" specified to // `CompleteWith`. template -class TestCompletionBase : public Promise::Completion { public: - void CompleteWith(Error error_code, const char* error_message, + void CompleteWith(Error error_code, + const char* error_message, PublicType* result) override { MutexLock lock(mutex_); FIREBASE_ASSERT(invocation_count_ == 0); @@ -211,7 +218,9 @@ class TestVoidCompletion : public TestCompletionBase { } protected: - void HandleResult(void* result) override { result_ = result; } + void HandleResult(void* result) override { + result_ = result; + } private: void* result_; diff --git a/firestore/integration_test_internal/src/array_transform_test.cc b/firestore/integration_test_internal/src/array_transform_test.cc index a45beb826f..6925a29c55 100644 --- a/firestore/integration_test_internal/src/array_transform_test.cc +++ b/firestore/integration_test_internal/src/array_transform_test.cc @@ -28,7 +28,9 @@ class ArrayTransformTest : public FirestoreIntegrationTest { EXPECT_FALSE(snapshot.exists()); } - void TearDown() override { registration_.Remove(); } + void TearDown() override { + registration_.Remove(); + } void WriteInitialData(const MapFieldValue& data) { Await(document_.Set(data)); @@ -49,7 +51,9 @@ class ArrayTransformTest : public FirestoreIntegrationTest { class ArrayTransformServerApplicationTest : public FirestoreIntegrationTest { protected: - void SetUp() override { document_ = Document(); } + void SetUp() override { + document_ = Document(); + } DocumentReference document_; }; diff --git a/firestore/integration_test_internal/src/includes_test.cc b/firestore/integration_test_internal/src/includes_test.cc index b246829e60..f95e03997b 100644 --- a/firestore/integration_test_internal/src/includes_test.cc +++ b/firestore/integration_test_internal/src/includes_test.cc @@ -19,11 +19,14 @@ class IncludesTest : public testing::Test { namespace { struct TestListener : EventListener { - void OnEvent(const int&, Error, const std::string&) override {} + void OnEvent(const int&, Error, const std::string&) override { + } }; struct TestTransactionFunction : TransactionFunction { - Error Apply(Transaction&, std::string&) override { return Error::kErrorOk; } + Error Apply(Transaction&, std::string&) override { + return Error::kErrorOk; + } }; } // namespace diff --git a/firestore/integration_test_internal/src/integration_test.cc b/firestore/integration_test_internal/src/integration_test.cc index b62edbe5bf..2500000ef5 100644 --- a/firestore/integration_test_internal/src/integration_test.cc +++ b/firestore/integration_test_internal/src/integration_test.cc @@ -140,7 +140,9 @@ class FirebaseFirestoreBasicTest : public FirebaseTest { firebase::App* FirebaseFirestoreBasicTest::shared_app_; firebase::auth::Auth* FirebaseFirestoreBasicTest::shared_auth_; -void FirebaseFirestoreBasicTest::SetUpTestSuite() { InitializeAppAndAuth(); } +void FirebaseFirestoreBasicTest::SetUpTestSuite() { + InitializeAppAndAuth(); +} void FirebaseFirestoreBasicTest::InitializeAppAndAuth() { LogDebug("Initialize Firebase App."); @@ -182,7 +184,9 @@ void FirebaseFirestoreBasicTest::InitializeAppAndAuth() { SignIn(); } -void FirebaseFirestoreBasicTest::TearDownTestSuite() { TerminateAppAndAuth(); } +void FirebaseFirestoreBasicTest::TearDownTestSuite() { + TerminateAppAndAuth(); +} void FirebaseFirestoreBasicTest::TerminateAppAndAuth() { if (shared_auth_) { diff --git a/firestore/integration_test_internal/src/jni/declaration_test.cc b/firestore/integration_test_internal/src/jni/declaration_test.cc index d3f538b7b4..3f3ac0a9eb 100644 --- a/firestore/integration_test_internal/src/jni/declaration_test.cc +++ b/firestore/integration_test_internal/src/jni/declaration_test.cc @@ -29,7 +29,9 @@ Constructor kNewInteger("(I)V"); class DeclarationTest : public FirestoreIntegrationTest { public: - DeclarationTest() : loader_(app()) { loader_.LoadClass(kString); } + DeclarationTest() : loader_(app()) { + loader_.LoadClass(kString); + } protected: Loader loader_; diff --git a/firestore/integration_test_internal/src/jni/env_test.cc b/firestore/integration_test_internal/src/jni/env_test.cc index c0eeebc919..a6973a44f6 100644 --- a/firestore/integration_test_internal/src/jni/env_test.cc +++ b/firestore/integration_test_internal/src/jni/env_test.cc @@ -15,7 +15,8 @@ namespace jni { class EnvTest : public FirestoreIntegrationTest { public: - EnvTest() : env_(MakeUnique(GetEnv())) {} + EnvTest() : env_(MakeUnique(GetEnv())) { + } ~EnvTest() override { // Ensure that after the test is done that any pending exception is cleared @@ -23,7 +24,9 @@ class EnvTest : public FirestoreIntegrationTest { env_->ExceptionClear(); } - Env& env() const { return *env_; } + Env& env() const { + return *env_; + } protected: // Env is declared as having a `noexcept(false)` destructor, which causes the @@ -37,7 +40,9 @@ class EnvTest : public FirestoreIntegrationTest { TEST_F(EnvTest, ToolchainSupportsThrowingFromDestructors) { class ThrowsInDestructor { public: - ~ThrowsInDestructor() noexcept(false) { throw std::exception(); } + ~ThrowsInDestructor() noexcept(false) { + throw std::exception(); + } }; try { diff --git a/firestore/integration_test_internal/src/jni/object_test.cc b/firestore/integration_test_internal/src/jni/object_test.cc index 5b9716dfa9..7861cdbb86 100644 --- a/firestore/integration_test_internal/src/jni/object_test.cc +++ b/firestore/integration_test_internal/src/jni/object_test.cc @@ -12,7 +12,8 @@ namespace jni { class ObjectTest : public FirestoreIntegrationTest { public: - ObjectTest() : env_(app()->GetJNIEnv()) {} + ObjectTest() : env_(app()->GetJNIEnv()) { + } protected: JNIEnv* env_ = nullptr; diff --git a/firestore/integration_test_internal/src/jni/ownership_test.cc b/firestore/integration_test_internal/src/jni/ownership_test.cc index 170832bf67..289e2ecd01 100644 --- a/firestore/integration_test_internal/src/jni/ownership_test.cc +++ b/firestore/integration_test_internal/src/jni/ownership_test.cc @@ -189,9 +189,12 @@ RefTracker* RefTracker::instance_ = nullptr; class OwnershipTest : public FirestoreIntegrationTest { public: - OwnershipTest() : env_(GetEnv()) {} + OwnershipTest() : env_(GetEnv()) { + } - ~OwnershipTest() override { refs_.ExpectLiveIsExactly(); } + ~OwnershipTest() override { + refs_.ExpectLiveIsExactly(); + } protected: JNIEnv* env_ = nullptr; diff --git a/firestore/integration_test_internal/src/numeric_transforms_test.cc b/firestore/integration_test_internal/src/numeric_transforms_test.cc index a5bea3264a..69882222e7 100644 --- a/firestore/integration_test_internal/src/numeric_transforms_test.cc +++ b/firestore/integration_test_internal/src/numeric_transforms_test.cc @@ -74,7 +74,9 @@ class NumericTransformsTest : public FirestoreIntegrationTest { EXPECT_FALSE(initial_snapshot.exists()); } - ~NumericTransformsTest() override { listener_.Remove(); } + ~NumericTransformsTest() override { + listener_.Remove(); + } protected: /** Writes values and waits for the corresponding snapshot. */ diff --git a/firestore/integration_test_internal/src/sanity_test.cc b/firestore/integration_test_internal/src/sanity_test.cc index 0b84756ec9..a92ff1348f 100644 --- a/firestore/integration_test_internal/src/sanity_test.cc +++ b/firestore/integration_test_internal/src/sanity_test.cc @@ -16,8 +16,12 @@ class SanityTest : public testing::Test { protected: - void SetUp() override { printf("==== SetUp ====\n"); } - void TearDown() override { printf("==== TearDown ====\n"); } + void SetUp() override { + printf("==== SetUp ====\n"); + } + void TearDown() override { + printf("==== TearDown ====\n"); + } }; // So far, Android native method cannot be inside namespace. So this has to be diff --git a/firestore/integration_test_internal/src/server_timestamp_test.cc b/firestore/integration_test_internal/src/server_timestamp_test.cc index c18f68c8e6..bdc554a971 100644 --- a/firestore/integration_test_internal/src/server_timestamp_test.cc +++ b/firestore/integration_test_internal/src/server_timestamp_test.cc @@ -20,7 +20,8 @@ using ServerTimestampBehavior = DocumentSnapshot::ServerTimestampBehavior; class ServerTimestampTest : public FirestoreIntegrationTest { public: - ~ServerTimestampTest() override {} + ~ServerTimestampTest() override { + } protected: void SetUp() override { @@ -33,7 +34,9 @@ class ServerTimestampTest : public FirestoreIntegrationTest { EXPECT_FALSE(initial_snapshot.exists()); } - void TearDown() override { listener_registration_.Remove(); } + void TearDown() override { + listener_registration_.Remove(); + } /** Returns the expected data, with the specified timestamp substituted in. */ MapFieldValue ExpectedDataWithTimestamp(const FieldValue& timestamp) { diff --git a/firestore/integration_test_internal/src/util/future_test_util.cc b/firestore/integration_test_internal/src/util/future_test_util.cc index 94653034a4..23b7721843 100644 --- a/firestore/integration_test_internal/src/util/future_test_util.cc +++ b/firestore/integration_test_internal/src/util/future_test_util.cc @@ -9,7 +9,9 @@ namespace firebase { namespace { -void PrintTo(std::ostream* os, FutureStatus future_status, int error, +void PrintTo(std::ostream* os, + FutureStatus future_status, + int error, const char* error_message = nullptr) { *os << "Future{status=" << ToEnumeratorName(future_status) << " error=" << firestore::ToFirestoreErrorCodeName(error); diff --git a/firestore/integration_test_internal/src/util/integration_test_util.cc b/firestore/integration_test_internal/src/util/integration_test_util.cc index e471cc69ce..814ab5608f 100644 --- a/firestore/integration_test_internal/src/util/integration_test_util.cc +++ b/firestore/integration_test_internal/src/util/integration_test_util.cc @@ -50,7 +50,9 @@ App* GetApp(const char* name) { } } -App* GetApp() { return GetApp(nullptr); } +App* GetApp() { + return GetApp(nullptr); +} FirestoreInternal* CreateTestFirestoreInternal(App* app) { return TestFriend::CreateTestFirestoreInternal(app); diff --git a/firestore/integration_test_internal/src/validation_test.cc b/firestore/integration_test_internal/src/validation_test.cc index d04c1a7e78..3ddc59deec 100644 --- a/firestore/integration_test_internal/src/validation_test.cc +++ b/firestore/integration_test_internal/src/validation_test.cc @@ -74,8 +74,10 @@ class ValidationTest : public FirestoreIntegrationTest { * Performs a write using each set and/or update API and makes sure it fails * with the expected reason. */ - void ExpectWriteError(const MapFieldValue& data, const std::string& reason, - bool include_sets, bool include_updates) { + void ExpectWriteError(const MapFieldValue& data, + const std::string& reason, + bool include_sets, + bool include_updates) { DocumentReference document = Document(); if (include_sets) { @@ -162,7 +164,8 @@ class ValidationTest : public FirestoreIntegrationTest { #if defined(__ANDROID__) // PORT_NOTE: Does not apply to C++ as host parameter is passed by value. -TEST_F(ValidationTest, FirestoreSettingsNullHostFails) {} +TEST_F(ValidationTest, FirestoreSettingsNullHostFails) { +} TEST_F(ValidationTest, ChangingSettingsAfterUseFails) { DocumentReference reference = Document(); @@ -197,7 +200,8 @@ TEST_F(ValidationTest, DisableSslWithoutSettingHostFails) { } // PORT_NOTE: Does not apply to C++ as host parameter is passed by value. -TEST_F(ValidationTest, FirestoreGetInstanceWithNullAppFails) {} +TEST_F(ValidationTest, FirestoreGetInstanceWithNullAppFails) { +} TEST_F(ValidationTest, FirestoreGetInstanceWithNonNullAppReturnsNonNullInstance) { @@ -305,7 +309,8 @@ TEST_F(ValidationTest, DocumentPathsMustBeEvenLength) { } // PORT_NOTE: Does not apply to C++ which is strong-typed. -TEST_F(ValidationTest, WritesMustBeMapsOrPOJOs) {} +TEST_F(ValidationTest, WritesMustBeMapsOrPOJOs) { +} TEST_F(ValidationTest, WritesMustNotContainDirectlyNestedLists) { SCOPED_TRACE("WritesMustNotContainDirectlyNestedLists"); @@ -349,7 +354,8 @@ TEST_F(ValidationTest, WritesMayContainIndirectlyNestedLists) { } // TODO(zxu): There is no way to create Firestore with different project id yet. -TEST_F(ValidationTest, WritesMustNotContainReferencesToADifferentDatabase) {} +TEST_F(ValidationTest, WritesMustNotContainReferencesToADifferentDatabase) { +} TEST_F(ValidationTest, WritesMustNotContainReservedFieldNames) { SCOPED_TRACE("WritesMustNotContainReservedFieldNames"); @@ -412,7 +418,8 @@ TEST_F(ValidationTest, BatchWritesRequireCorrectDocumentReferences) { } } -TEST_F(ValidationTest, TransactionsRequireCorrectDocumentReferences) {} +TEST_F(ValidationTest, TransactionsRequireCorrectDocumentReferences) { +} #endif // defined(__ANDROID__) @@ -509,7 +516,8 @@ TEST_F(ValidationTest, ArrayTransformsFailInQueries) { } // PORT_NOTE: Does not apply to C++ which is strong-typed. -TEST_F(ValidationTest, ArrayTransformsRejectInvalidElements) {} +TEST_F(ValidationTest, ArrayTransformsRejectInvalidElements) { +} TEST_F(ValidationTest, ArrayTransformsRejectArrays) { DocumentReference document = Document(); From 22c260bade16bb43f905ae24a1ccf23c6a836dde Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Thu, 17 Jun 2021 10:43:48 -0400 Subject: [PATCH 2/2] Re-run format_code.py since .clang_format was changed in #477 --- .../integration_test/src/integration_test.cc | 8 +--- .../src/android/cancellation_token_source.cc | 4 +- .../firestore_integration_test_android.cc | 3 +- .../firestore_integration_test_android.h | 4 +- .../src/android/promise_android_test.cc | 15 ++------ .../src/array_transform_test.cc | 8 +--- .../src/firestore_integration_test.cc | 4 +- .../src/firestore_integration_test.h | 37 +++++-------------- .../src/firestore_test.cc | 10 ++--- .../src/includes_test.cc | 7 +--- .../src/integration_test.cc | 8 +--- .../src/jni/declaration_test.cc | 4 +- .../src/jni/env_test.cc | 11 ++---- .../src/jni/object_test.cc | 3 +- .../src/jni/ownership_test.cc | 7 +--- .../src/numeric_transforms_test.cc | 4 +- .../src/sanity_test.cc | 8 +--- .../src/server_timestamp_test.cc | 7 +--- .../src/transaction_test.cc | 21 +++-------- .../src/util/event_accumulator.h | 15 ++------ .../src/util/integration_test_util.cc | 4 +- .../src/validation_test.cc | 18 +++------ 22 files changed, 58 insertions(+), 152 deletions(-) diff --git a/firestore/integration_test/src/integration_test.cc b/firestore/integration_test/src/integration_test.cc index 2500000ef5..b62edbe5bf 100644 --- a/firestore/integration_test/src/integration_test.cc +++ b/firestore/integration_test/src/integration_test.cc @@ -140,9 +140,7 @@ class FirebaseFirestoreBasicTest : public FirebaseTest { firebase::App* FirebaseFirestoreBasicTest::shared_app_; firebase::auth::Auth* FirebaseFirestoreBasicTest::shared_auth_; -void FirebaseFirestoreBasicTest::SetUpTestSuite() { - InitializeAppAndAuth(); -} +void FirebaseFirestoreBasicTest::SetUpTestSuite() { InitializeAppAndAuth(); } void FirebaseFirestoreBasicTest::InitializeAppAndAuth() { LogDebug("Initialize Firebase App."); @@ -184,9 +182,7 @@ void FirebaseFirestoreBasicTest::InitializeAppAndAuth() { SignIn(); } -void FirebaseFirestoreBasicTest::TearDownTestSuite() { - TerminateAppAndAuth(); -} +void FirebaseFirestoreBasicTest::TearDownTestSuite() { TerminateAppAndAuth(); } void FirebaseFirestoreBasicTest::TerminateAppAndAuth() { if (shared_auth_) { diff --git a/firestore/integration_test_internal/src/android/cancellation_token_source.cc b/firestore/integration_test_internal/src/android/cancellation_token_source.cc index d6210826bd..edfeecabba 100644 --- a/firestore/integration_test_internal/src/android/cancellation_token_source.cc +++ b/firestore/integration_test_internal/src/android/cancellation_token_source.cc @@ -34,9 +34,7 @@ Local CancellationTokenSource::GetToken(Env& env) { return env.Call(*this, kGetToken); } -void CancellationTokenSource::Cancel(Env& env) { - env.Call(*this, kCancel); -} +void CancellationTokenSource::Cancel(Env& env) { env.Call(*this, kCancel); } } // namespace firestore } // namespace firebase diff --git a/firestore/integration_test_internal/src/android/firestore_integration_test_android.cc b/firestore/integration_test_internal/src/android/firestore_integration_test_android.cc index 8daf6b3d71..bae2f206ef 100644 --- a/firestore/integration_test_internal/src/android/firestore_integration_test_android.cc +++ b/firestore/integration_test_internal/src/android/firestore_integration_test_android.cc @@ -41,8 +41,7 @@ Constructor kExceptionConstructor("(Ljava/lang/String;)V"); } // namespace FirestoreAndroidIntegrationTest::FirestoreAndroidIntegrationTest() - : loader_(app()) { -} + : loader_(app()) {} void FirestoreAndroidIntegrationTest::SetUp() { FirestoreIntegrationTest::SetUp(); diff --git a/firestore/integration_test_internal/src/android/firestore_integration_test_android.h b/firestore/integration_test_internal/src/android/firestore_integration_test_android.h index 81a6246601..91d3f7a85f 100644 --- a/firestore/integration_test_internal/src/android/firestore_integration_test_android.h +++ b/firestore/integration_test_internal/src/android/firestore_integration_test_android.h @@ -67,9 +67,7 @@ class FirestoreAndroidIntegrationTest : public FirestoreIntegrationTest { void SetUp() override; void TearDown() noexcept(false) override; - jni::Loader& loader() { - return loader_; - } + jni::Loader& loader() { return loader_; } /** Creates and returns a new Java `Exception` object with a message. */ jni::Local CreateException(jni::Env& env, diff --git a/firestore/integration_test_internal/src/android/promise_android_test.cc b/firestore/integration_test_internal/src/android/promise_android_test.cc index 9835837c22..1e9ac52728 100644 --- a/firestore/integration_test_internal/src/android/promise_android_test.cc +++ b/firestore/integration_test_internal/src/android/promise_android_test.cc @@ -41,8 +41,7 @@ namespace { class PromiseTest : public FirestoreAndroidIntegrationTest { public: - PromiseTest() : promises_(GetFirestoreInternal(TestFirestore())) { - } + PromiseTest() : promises_(GetFirestoreInternal(TestFirestore())) {} void SetUp() override { FirestoreAndroidIntegrationTest::SetUp(); @@ -60,9 +59,7 @@ class PromiseTest : public FirestoreAndroidIntegrationTest { }; protected: - PromiseFactory& promises() { - return promises_; - } + PromiseFactory& promises() { return promises_; } jni::Local GetTask() { jni::Env env = GetEnv(); @@ -85,9 +82,7 @@ class PromiseTest : public FirestoreAndroidIntegrationTest { cancellation_token_source_.Cancel(env); } - static jni::Env GetEnv() { - return jni::Env(app_framework::GetJniEnv()); - } + static jni::Env GetEnv() { return jni::Env(app_framework::GetJniEnv()); } private: PromiseFactory promises_; @@ -218,9 +213,7 @@ class TestVoidCompletion : public TestCompletionBase { } protected: - void HandleResult(void* result) override { - result_ = result; - } + void HandleResult(void* result) override { result_ = result; } private: void* result_; diff --git a/firestore/integration_test_internal/src/array_transform_test.cc b/firestore/integration_test_internal/src/array_transform_test.cc index 6925a29c55..a45beb826f 100644 --- a/firestore/integration_test_internal/src/array_transform_test.cc +++ b/firestore/integration_test_internal/src/array_transform_test.cc @@ -28,9 +28,7 @@ class ArrayTransformTest : public FirestoreIntegrationTest { EXPECT_FALSE(snapshot.exists()); } - void TearDown() override { - registration_.Remove(); - } + void TearDown() override { registration_.Remove(); } void WriteInitialData(const MapFieldValue& data) { Await(document_.Set(data)); @@ -51,9 +49,7 @@ class ArrayTransformTest : public FirestoreIntegrationTest { class ArrayTransformServerApplicationTest : public FirestoreIntegrationTest { protected: - void SetUp() override { - document_ = Document(); - } + void SetUp() override { document_ = Document(); } DocumentReference document_; }; diff --git a/firestore/integration_test_internal/src/firestore_integration_test.cc b/firestore/integration_test_internal/src/firestore_integration_test.cc index 3ed35e6ee9..ec56570def 100644 --- a/firestore/integration_test_internal/src/firestore_integration_test.cc +++ b/firestore/integration_test_internal/src/firestore_integration_test.cc @@ -308,9 +308,7 @@ std::string FirestoreIntegrationTest::DescribeFailedFuture( std::to_string(future.error()) + "): " + future.error_message(); } -bool ProcessEvents(int msec) { - return app_framework::ProcessEvents(msec); -} +bool ProcessEvents(int msec) { return app_framework::ProcessEvents(msec); } } // namespace firestore } // namespace firebase diff --git a/firestore/integration_test_internal/src/firestore_integration_test.h b/firestore/integration_test_internal/src/firestore_integration_test.h index d60eac8fd2..b801f80202 100644 --- a/firestore/integration_test_internal/src/firestore_integration_test.h +++ b/firestore/integration_test_internal/src/firestore_integration_test.h @@ -57,11 +57,9 @@ class EventAccumulator; template class TestEventListener : public EventListener { public: - explicit TestEventListener(std::string name) : name_(std::move(name)) { - } + explicit TestEventListener(std::string name) : name_(std::move(name)) {} - ~TestEventListener() override { - } + ~TestEventListener() override {} void OnEvent(const T& value, Error error_code, @@ -137,9 +135,7 @@ class TestEventListener : public EventListener { } // Set this to true to print more details for each arrived event for debug. - void set_print_debug_info(bool value) { - print_debug_info_ = value; - } + void set_print_debug_info(bool value) { print_debug_info_ = value; } // Copies events from the internal buffer, starting from `start`, up to but // not including `end`. @@ -183,9 +179,7 @@ class FirestoreIntegrationTest : public testing::Test { FirestoreIntegrationTest& operator=(FirestoreIntegrationTest&&) = delete; protected: - App* app() { - return TestFirestore()->app(); - } + App* app() { return TestFirestore()->app(); } // Returns a Firestore instance for an app with the given name. // If this method is invoked again with the same `name`, then the same pointer @@ -326,13 +320,9 @@ class FirestoreIntegrationTest : public testing::Test { static std::string DescribeFailedFuture(const FutureBase& future); - void DisableNetwork() { - Await(TestFirestore()->DisableNetwork()); - } + void DisableNetwork() { Await(TestFirestore()->DisableNetwork()); } - void EnableNetwork() { - Await(TestFirestore()->EnableNetwork()); - } + void EnableNetwork() { Await(TestFirestore()->EnableNetwork()); } static FirestoreInternal* GetFirestoreInternal(Firestore* firestore) { return firestore->internal_; @@ -346,18 +336,11 @@ class FirestoreIntegrationTest : public testing::Test { public: FirestoreInfo() = default; FirestoreInfo(const std::string& name, UniquePtr&& firestore) - : name_(name), firestore_(Move(firestore)) { - } + : name_(name), firestore_(Move(firestore)) {} - const std::string& name() const { - return name_; - } - Firestore* firestore() const { - return firestore_.get(); - } - void ReleaseFirestore() { - firestore_.release(); - } + const std::string& name() const { return name_; } + Firestore* firestore() const { return firestore_.get(); } + void ReleaseFirestore() { firestore_.release(); } private: std::string name_; diff --git a/firestore/integration_test_internal/src/firestore_test.cc b/firestore/integration_test_internal/src/firestore_test.cc index 1b40b3ce88..fb07fd1942 100644 --- a/firestore/integration_test_internal/src/firestore_test.cc +++ b/firestore/integration_test_internal/src/firestore_test.cc @@ -671,8 +671,7 @@ TEST_F(FirestoreIntegrationTest, class SnapshotTestEventListener : public TestEventListener { public: SnapshotTestEventListener(std::string name, TestData& test_data) - : TestEventListener(std::move(name)), test_data_(test_data) { - } + : TestEventListener(std::move(name)), test_data_(test_data) {} void OnEvent(const DocumentSnapshot& value, Error error_code, @@ -700,12 +699,9 @@ TEST_F(FirestoreIntegrationTest, #else class SyncEventListener : public EventListener { public: - explicit SyncEventListener(TestData& test_data) : test_data_(test_data) { - } + explicit SyncEventListener(TestData& test_data) : test_data_(test_data) {} - void OnEvent(Error) override { - test_data_.AddEvent("snapshots-in-sync"); - } + void OnEvent(Error) override { test_data_.AddEvent("snapshots-in-sync"); } private: TestData& test_data_; diff --git a/firestore/integration_test_internal/src/includes_test.cc b/firestore/integration_test_internal/src/includes_test.cc index f95e03997b..b246829e60 100644 --- a/firestore/integration_test_internal/src/includes_test.cc +++ b/firestore/integration_test_internal/src/includes_test.cc @@ -19,14 +19,11 @@ class IncludesTest : public testing::Test { namespace { struct TestListener : EventListener { - void OnEvent(const int&, Error, const std::string&) override { - } + void OnEvent(const int&, Error, const std::string&) override {} }; struct TestTransactionFunction : TransactionFunction { - Error Apply(Transaction&, std::string&) override { - return Error::kErrorOk; - } + Error Apply(Transaction&, std::string&) override { return Error::kErrorOk; } }; } // namespace diff --git a/firestore/integration_test_internal/src/integration_test.cc b/firestore/integration_test_internal/src/integration_test.cc index 2500000ef5..b62edbe5bf 100644 --- a/firestore/integration_test_internal/src/integration_test.cc +++ b/firestore/integration_test_internal/src/integration_test.cc @@ -140,9 +140,7 @@ class FirebaseFirestoreBasicTest : public FirebaseTest { firebase::App* FirebaseFirestoreBasicTest::shared_app_; firebase::auth::Auth* FirebaseFirestoreBasicTest::shared_auth_; -void FirebaseFirestoreBasicTest::SetUpTestSuite() { - InitializeAppAndAuth(); -} +void FirebaseFirestoreBasicTest::SetUpTestSuite() { InitializeAppAndAuth(); } void FirebaseFirestoreBasicTest::InitializeAppAndAuth() { LogDebug("Initialize Firebase App."); @@ -184,9 +182,7 @@ void FirebaseFirestoreBasicTest::InitializeAppAndAuth() { SignIn(); } -void FirebaseFirestoreBasicTest::TearDownTestSuite() { - TerminateAppAndAuth(); -} +void FirebaseFirestoreBasicTest::TearDownTestSuite() { TerminateAppAndAuth(); } void FirebaseFirestoreBasicTest::TerminateAppAndAuth() { if (shared_auth_) { diff --git a/firestore/integration_test_internal/src/jni/declaration_test.cc b/firestore/integration_test_internal/src/jni/declaration_test.cc index 3f3ac0a9eb..d3f538b7b4 100644 --- a/firestore/integration_test_internal/src/jni/declaration_test.cc +++ b/firestore/integration_test_internal/src/jni/declaration_test.cc @@ -29,9 +29,7 @@ Constructor kNewInteger("(I)V"); class DeclarationTest : public FirestoreIntegrationTest { public: - DeclarationTest() : loader_(app()) { - loader_.LoadClass(kString); - } + DeclarationTest() : loader_(app()) { loader_.LoadClass(kString); } protected: Loader loader_; diff --git a/firestore/integration_test_internal/src/jni/env_test.cc b/firestore/integration_test_internal/src/jni/env_test.cc index a6973a44f6..c0eeebc919 100644 --- a/firestore/integration_test_internal/src/jni/env_test.cc +++ b/firestore/integration_test_internal/src/jni/env_test.cc @@ -15,8 +15,7 @@ namespace jni { class EnvTest : public FirestoreIntegrationTest { public: - EnvTest() : env_(MakeUnique(GetEnv())) { - } + EnvTest() : env_(MakeUnique(GetEnv())) {} ~EnvTest() override { // Ensure that after the test is done that any pending exception is cleared @@ -24,9 +23,7 @@ class EnvTest : public FirestoreIntegrationTest { env_->ExceptionClear(); } - Env& env() const { - return *env_; - } + Env& env() const { return *env_; } protected: // Env is declared as having a `noexcept(false)` destructor, which causes the @@ -40,9 +37,7 @@ class EnvTest : public FirestoreIntegrationTest { TEST_F(EnvTest, ToolchainSupportsThrowingFromDestructors) { class ThrowsInDestructor { public: - ~ThrowsInDestructor() noexcept(false) { - throw std::exception(); - } + ~ThrowsInDestructor() noexcept(false) { throw std::exception(); } }; try { diff --git a/firestore/integration_test_internal/src/jni/object_test.cc b/firestore/integration_test_internal/src/jni/object_test.cc index 7861cdbb86..5b9716dfa9 100644 --- a/firestore/integration_test_internal/src/jni/object_test.cc +++ b/firestore/integration_test_internal/src/jni/object_test.cc @@ -12,8 +12,7 @@ namespace jni { class ObjectTest : public FirestoreIntegrationTest { public: - ObjectTest() : env_(app()->GetJNIEnv()) { - } + ObjectTest() : env_(app()->GetJNIEnv()) {} protected: JNIEnv* env_ = nullptr; diff --git a/firestore/integration_test_internal/src/jni/ownership_test.cc b/firestore/integration_test_internal/src/jni/ownership_test.cc index 289e2ecd01..170832bf67 100644 --- a/firestore/integration_test_internal/src/jni/ownership_test.cc +++ b/firestore/integration_test_internal/src/jni/ownership_test.cc @@ -189,12 +189,9 @@ RefTracker* RefTracker::instance_ = nullptr; class OwnershipTest : public FirestoreIntegrationTest { public: - OwnershipTest() : env_(GetEnv()) { - } + OwnershipTest() : env_(GetEnv()) {} - ~OwnershipTest() override { - refs_.ExpectLiveIsExactly(); - } + ~OwnershipTest() override { refs_.ExpectLiveIsExactly(); } protected: JNIEnv* env_ = nullptr; diff --git a/firestore/integration_test_internal/src/numeric_transforms_test.cc b/firestore/integration_test_internal/src/numeric_transforms_test.cc index 69882222e7..a5bea3264a 100644 --- a/firestore/integration_test_internal/src/numeric_transforms_test.cc +++ b/firestore/integration_test_internal/src/numeric_transforms_test.cc @@ -74,9 +74,7 @@ class NumericTransformsTest : public FirestoreIntegrationTest { EXPECT_FALSE(initial_snapshot.exists()); } - ~NumericTransformsTest() override { - listener_.Remove(); - } + ~NumericTransformsTest() override { listener_.Remove(); } protected: /** Writes values and waits for the corresponding snapshot. */ diff --git a/firestore/integration_test_internal/src/sanity_test.cc b/firestore/integration_test_internal/src/sanity_test.cc index a92ff1348f..0b84756ec9 100644 --- a/firestore/integration_test_internal/src/sanity_test.cc +++ b/firestore/integration_test_internal/src/sanity_test.cc @@ -16,12 +16,8 @@ class SanityTest : public testing::Test { protected: - void SetUp() override { - printf("==== SetUp ====\n"); - } - void TearDown() override { - printf("==== TearDown ====\n"); - } + void SetUp() override { printf("==== SetUp ====\n"); } + void TearDown() override { printf("==== TearDown ====\n"); } }; // So far, Android native method cannot be inside namespace. So this has to be diff --git a/firestore/integration_test_internal/src/server_timestamp_test.cc b/firestore/integration_test_internal/src/server_timestamp_test.cc index bdc554a971..c18f68c8e6 100644 --- a/firestore/integration_test_internal/src/server_timestamp_test.cc +++ b/firestore/integration_test_internal/src/server_timestamp_test.cc @@ -20,8 +20,7 @@ using ServerTimestampBehavior = DocumentSnapshot::ServerTimestampBehavior; class ServerTimestampTest : public FirestoreIntegrationTest { public: - ~ServerTimestampTest() override { - } + ~ServerTimestampTest() override {} protected: void SetUp() override { @@ -34,9 +33,7 @@ class ServerTimestampTest : public FirestoreIntegrationTest { EXPECT_FALSE(initial_snapshot.exists()); } - void TearDown() override { - listener_registration_.Remove(); - } + void TearDown() override { listener_registration_.Remove(); } /** Returns the expected data, with the specified timestamp substituted in. */ MapFieldValue ExpectedDataWithTimestamp(const FieldValue& timestamp) { diff --git a/firestore/integration_test_internal/src/transaction_test.cc b/firestore/integration_test_internal/src/transaction_test.cc index f507b68e85..3f5033aa89 100644 --- a/firestore/integration_test_internal/src/transaction_test.cc +++ b/firestore/integration_test_internal/src/transaction_test.cc @@ -101,8 +101,7 @@ class TransactionTest : public FirestoreIntegrationTest { class TestTransactionFunction : public TransactionFunction { public: - TestTransactionFunction(DocumentReference doc) : doc_(doc) { - } + TestTransactionFunction(DocumentReference doc) : doc_(doc) {} Error Apply(Transaction& transaction, std::string& error_message) override { Error error = Error::kErrorUnknown; @@ -113,12 +112,8 @@ class TestTransactionFunction : public TransactionFunction { return error; } - std::string key() { - return key_; - } - std::string value() { - return value_; - } + std::string key() { return key_; } + std::string value() { return value_; } private: DocumentReference doc_; @@ -145,12 +140,9 @@ class TransactionStage { TransactionStage( std::string tag, std::function func) - : tag_(std::move(tag)), func_(std::move(func)) { - } + : tag_(std::move(tag)), func_(std::move(func)) {} - const std::string& tag() const { - return tag_; - } + const std::string& tag() const { return tag_; } void operator()(Transaction* transaction, const DocumentReference& doc) const { @@ -221,8 +213,7 @@ const auto get = new TransactionStage( */ class TransactionTester { public: - explicit TransactionTester(Firestore* db) : db_(db) { - } + explicit TransactionTester(Firestore* db) : db_(db) {} template TransactionTester& Run(Args... args) { diff --git a/firestore/integration_test_internal/src/util/event_accumulator.h b/firestore/integration_test_internal/src/util/event_accumulator.h index 3277eb311d..64b444a547 100644 --- a/firestore/integration_test_internal/src/util/event_accumulator.h +++ b/firestore/integration_test_internal/src/util/event_accumulator.h @@ -10,12 +10,9 @@ namespace firestore { template class EventAccumulator { public: - EventAccumulator() : listener_("EventAccumulator") { - } + EventAccumulator() : listener_("EventAccumulator") {} - TestEventListener* listener() { - return &listener_; - } + TestEventListener* listener() { return &listener_; } std::vector Await(int num_events) { int old_num_events = num_events_consumed_; @@ -91,18 +88,14 @@ class EventAccumulator { return event; } - void FailOnNextEvent() { - listener_.FailOnNextEvent(); - } + void FailOnNextEvent() { listener_.FailOnNextEvent(); } private: bool HasPendingWrites(T event) { return event.metadata().has_pending_writes(); } - bool IsFromCache(T event) { - return event.metadata().is_from_cache(); - } + bool IsFromCache(T event) { return event.metadata().is_from_cache(); } TestEventListener listener_; diff --git a/firestore/integration_test_internal/src/util/integration_test_util.cc b/firestore/integration_test_internal/src/util/integration_test_util.cc index 814ab5608f..e471cc69ce 100644 --- a/firestore/integration_test_internal/src/util/integration_test_util.cc +++ b/firestore/integration_test_internal/src/util/integration_test_util.cc @@ -50,9 +50,7 @@ App* GetApp(const char* name) { } } -App* GetApp() { - return GetApp(nullptr); -} +App* GetApp() { return GetApp(nullptr); } FirestoreInternal* CreateTestFirestoreInternal(App* app) { return TestFriend::CreateTestFirestoreInternal(app); diff --git a/firestore/integration_test_internal/src/validation_test.cc b/firestore/integration_test_internal/src/validation_test.cc index 3ddc59deec..a88209363b 100644 --- a/firestore/integration_test_internal/src/validation_test.cc +++ b/firestore/integration_test_internal/src/validation_test.cc @@ -164,8 +164,7 @@ class ValidationTest : public FirestoreIntegrationTest { #if defined(__ANDROID__) // PORT_NOTE: Does not apply to C++ as host parameter is passed by value. -TEST_F(ValidationTest, FirestoreSettingsNullHostFails) { -} +TEST_F(ValidationTest, FirestoreSettingsNullHostFails) {} TEST_F(ValidationTest, ChangingSettingsAfterUseFails) { DocumentReference reference = Document(); @@ -200,8 +199,7 @@ TEST_F(ValidationTest, DisableSslWithoutSettingHostFails) { } // PORT_NOTE: Does not apply to C++ as host parameter is passed by value. -TEST_F(ValidationTest, FirestoreGetInstanceWithNullAppFails) { -} +TEST_F(ValidationTest, FirestoreGetInstanceWithNullAppFails) {} TEST_F(ValidationTest, FirestoreGetInstanceWithNonNullAppReturnsNonNullInstance) { @@ -309,8 +307,7 @@ TEST_F(ValidationTest, DocumentPathsMustBeEvenLength) { } // PORT_NOTE: Does not apply to C++ which is strong-typed. -TEST_F(ValidationTest, WritesMustBeMapsOrPOJOs) { -} +TEST_F(ValidationTest, WritesMustBeMapsOrPOJOs) {} TEST_F(ValidationTest, WritesMustNotContainDirectlyNestedLists) { SCOPED_TRACE("WritesMustNotContainDirectlyNestedLists"); @@ -354,8 +351,7 @@ TEST_F(ValidationTest, WritesMayContainIndirectlyNestedLists) { } // TODO(zxu): There is no way to create Firestore with different project id yet. -TEST_F(ValidationTest, WritesMustNotContainReferencesToADifferentDatabase) { -} +TEST_F(ValidationTest, WritesMustNotContainReferencesToADifferentDatabase) {} TEST_F(ValidationTest, WritesMustNotContainReservedFieldNames) { SCOPED_TRACE("WritesMustNotContainReservedFieldNames"); @@ -418,8 +414,7 @@ TEST_F(ValidationTest, BatchWritesRequireCorrectDocumentReferences) { } } -TEST_F(ValidationTest, TransactionsRequireCorrectDocumentReferences) { -} +TEST_F(ValidationTest, TransactionsRequireCorrectDocumentReferences) {} #endif // defined(__ANDROID__) @@ -516,8 +511,7 @@ TEST_F(ValidationTest, ArrayTransformsFailInQueries) { } // PORT_NOTE: Does not apply to C++ which is strong-typed. -TEST_F(ValidationTest, ArrayTransformsRejectInvalidElements) { -} +TEST_F(ValidationTest, ArrayTransformsRejectInvalidElements) {} TEST_F(ValidationTest, ArrayTransformsRejectArrays) { DocumentReference document = Document();