Skip to content

Format Firestore integration test code with clang-format #476

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ void PrintTo(const Global<T>& object, std::ostream* os) {
* jni::Local<jni::String> 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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,12 @@ class PromiseTest : public FirestoreAndroidIntegrationTest {
// latter specialization provides access to the "result" specified to
// `CompleteWith`.
template <typename PublicType, typename InternalType>
class TestCompletionBase : public Promise<PublicType, InternalType,
class TestCompletionBase : public Promise<PublicType,
InternalType,
PromiseTest::AsyncFn>::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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,9 @@ class EventAccumulator;
template <typename T>
class TestEventListener : public EventListener<T> {
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,
Expand Down Expand Up @@ -137,9 +135,7 @@ class TestEventListener : public EventListener<T> {
}

// 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`.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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_;
Expand All @@ -346,18 +336,11 @@ class FirestoreIntegrationTest : public testing::Test {
public:
FirestoreInfo() = default;
FirestoreInfo(const std::string& name, UniquePtr<Firestore>&& 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_;
Expand Down
10 changes: 3 additions & 7 deletions firestore/integration_test_internal/src/firestore_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -671,8 +671,7 @@ TEST_F(FirestoreIntegrationTest,
class SnapshotTestEventListener : public TestEventListener<DocumentSnapshot> {
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,
Expand Down Expand Up @@ -700,12 +699,9 @@ TEST_F(FirestoreIntegrationTest,
#else
class SyncEventListener : public EventListener<void> {
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_;
Expand Down
21 changes: 6 additions & 15 deletions firestore/integration_test_internal/src/transaction_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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_;
Expand All @@ -145,12 +140,9 @@ class TransactionStage {
TransactionStage(
std::string tag,
std::function<void(Transaction*, const DocumentReference&)> 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 {
Expand Down Expand Up @@ -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 <typename... Args>
TransactionTester& Run(Args... args) {
Expand Down
15 changes: 4 additions & 11 deletions firestore/integration_test_internal/src/util/event_accumulator.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,9 @@ namespace firestore {
template <typename T>
class EventAccumulator {
public:
EventAccumulator() : listener_("EventAccumulator") {
}
EventAccumulator() : listener_("EventAccumulator") {}

TestEventListener<T>* listener() {
return &listener_;
}
TestEventListener<T>* listener() { return &listener_; }

std::vector<T> Await(int num_events) {
int old_num_events = num_events_consumed_;
Expand Down Expand Up @@ -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<T> listener_;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<void>{status=" << ToEnumeratorName(future_status)
<< " error=" << firestore::ToFirestoreErrorCodeName(error);
Expand Down
6 changes: 4 additions & 2 deletions firestore/integration_test_internal/src/validation_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down