Skip to content

Commit 3803777

Browse files
authored
Format Firestore integration test code with clang-format (#476)
1 parent ce5aa57 commit 3803777

File tree

9 files changed

+37
-69
lines changed

9 files changed

+37
-69
lines changed

firestore/integration_test_internal/src/android/firestore_integration_test_android.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,8 @@ void PrintTo(const Global<T>& object, std::ostream* os) {
4949
* jni::Local<jni::String> object2 = env.NewStringUtf("string");
5050
* EXPECT_THAT(object1, JavaEq(object2));
5151
*/
52-
MATCHER_P(JavaEq, object,
52+
MATCHER_P(JavaEq,
53+
object,
5354
std::string("compares ") + (negation ? "unequal" : "equal") +
5455
" using .equals() to a " + ToDebugString(object)) {
5556
jni::Env env;

firestore/integration_test_internal/src/android/promise_android_test.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,12 @@ class PromiseTest : public FirestoreAndroidIntegrationTest {
101101
// latter specialization provides access to the "result" specified to
102102
// `CompleteWith`.
103103
template <typename PublicType, typename InternalType>
104-
class TestCompletionBase : public Promise<PublicType, InternalType,
104+
class TestCompletionBase : public Promise<PublicType,
105+
InternalType,
105106
PromiseTest::AsyncFn>::Completion {
106107
public:
107-
void CompleteWith(Error error_code, const char* error_message,
108+
void CompleteWith(Error error_code,
109+
const char* error_message,
108110
PublicType* result) override {
109111
MutexLock lock(mutex_);
110112
FIREBASE_ASSERT(invocation_count_ == 0);

firestore/integration_test_internal/src/firestore_integration_test.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -308,9 +308,7 @@ std::string FirestoreIntegrationTest::DescribeFailedFuture(
308308
std::to_string(future.error()) + "): " + future.error_message();
309309
}
310310

311-
bool ProcessEvents(int msec) {
312-
return app_framework::ProcessEvents(msec);
313-
}
311+
bool ProcessEvents(int msec) { return app_framework::ProcessEvents(msec); }
314312

315313
} // namespace firestore
316314
} // namespace firebase

firestore/integration_test_internal/src/firestore_integration_test.h

Lines changed: 10 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,9 @@ class EventAccumulator;
5757
template <typename T>
5858
class TestEventListener : public EventListener<T> {
5959
public:
60-
explicit TestEventListener(std::string name) : name_(std::move(name)) {
61-
}
60+
explicit TestEventListener(std::string name) : name_(std::move(name)) {}
6261

63-
~TestEventListener() override {
64-
}
62+
~TestEventListener() override {}
6563

6664
void OnEvent(const T& value,
6765
Error error_code,
@@ -137,9 +135,7 @@ class TestEventListener : public EventListener<T> {
137135
}
138136

139137
// Set this to true to print more details for each arrived event for debug.
140-
void set_print_debug_info(bool value) {
141-
print_debug_info_ = value;
142-
}
138+
void set_print_debug_info(bool value) { print_debug_info_ = value; }
143139

144140
// Copies events from the internal buffer, starting from `start`, up to but
145141
// not including `end`.
@@ -183,9 +179,7 @@ class FirestoreIntegrationTest : public testing::Test {
183179
FirestoreIntegrationTest& operator=(FirestoreIntegrationTest&&) = delete;
184180

185181
protected:
186-
App* app() {
187-
return TestFirestore()->app();
188-
}
182+
App* app() { return TestFirestore()->app(); }
189183

190184
// Returns a Firestore instance for an app with the given name.
191185
// If this method is invoked again with the same `name`, then the same pointer
@@ -326,13 +320,9 @@ class FirestoreIntegrationTest : public testing::Test {
326320

327321
static std::string DescribeFailedFuture(const FutureBase& future);
328322

329-
void DisableNetwork() {
330-
Await(TestFirestore()->DisableNetwork());
331-
}
323+
void DisableNetwork() { Await(TestFirestore()->DisableNetwork()); }
332324

333-
void EnableNetwork() {
334-
Await(TestFirestore()->EnableNetwork());
335-
}
325+
void EnableNetwork() { Await(TestFirestore()->EnableNetwork()); }
336326

337327
static FirestoreInternal* GetFirestoreInternal(Firestore* firestore) {
338328
return firestore->internal_;
@@ -346,18 +336,11 @@ class FirestoreIntegrationTest : public testing::Test {
346336
public:
347337
FirestoreInfo() = default;
348338
FirestoreInfo(const std::string& name, UniquePtr<Firestore>&& firestore)
349-
: name_(name), firestore_(Move(firestore)) {
350-
}
339+
: name_(name), firestore_(Move(firestore)) {}
351340

352-
const std::string& name() const {
353-
return name_;
354-
}
355-
Firestore* firestore() const {
356-
return firestore_.get();
357-
}
358-
void ReleaseFirestore() {
359-
firestore_.release();
360-
}
341+
const std::string& name() const { return name_; }
342+
Firestore* firestore() const { return firestore_.get(); }
343+
void ReleaseFirestore() { firestore_.release(); }
361344

362345
private:
363346
std::string name_;

firestore/integration_test_internal/src/firestore_test.cc

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -671,8 +671,7 @@ TEST_F(FirestoreIntegrationTest,
671671
class SnapshotTestEventListener : public TestEventListener<DocumentSnapshot> {
672672
public:
673673
SnapshotTestEventListener(std::string name, TestData& test_data)
674-
: TestEventListener(std::move(name)), test_data_(test_data) {
675-
}
674+
: TestEventListener(std::move(name)), test_data_(test_data) {}
676675

677676
void OnEvent(const DocumentSnapshot& value,
678677
Error error_code,
@@ -700,12 +699,9 @@ TEST_F(FirestoreIntegrationTest,
700699
#else
701700
class SyncEventListener : public EventListener<void> {
702701
public:
703-
explicit SyncEventListener(TestData& test_data) : test_data_(test_data) {
704-
}
702+
explicit SyncEventListener(TestData& test_data) : test_data_(test_data) {}
705703

706-
void OnEvent(Error) override {
707-
test_data_.AddEvent("snapshots-in-sync");
708-
}
704+
void OnEvent(Error) override { test_data_.AddEvent("snapshots-in-sync"); }
709705

710706
private:
711707
TestData& test_data_;

firestore/integration_test_internal/src/transaction_test.cc

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ class TransactionTest : public FirestoreIntegrationTest {
101101

102102
class TestTransactionFunction : public TransactionFunction {
103103
public:
104-
TestTransactionFunction(DocumentReference doc) : doc_(doc) {
105-
}
104+
TestTransactionFunction(DocumentReference doc) : doc_(doc) {}
106105

107106
Error Apply(Transaction& transaction, std::string& error_message) override {
108107
Error error = Error::kErrorUnknown;
@@ -113,12 +112,8 @@ class TestTransactionFunction : public TransactionFunction {
113112
return error;
114113
}
115114

116-
std::string key() {
117-
return key_;
118-
}
119-
std::string value() {
120-
return value_;
121-
}
115+
std::string key() { return key_; }
116+
std::string value() { return value_; }
122117

123118
private:
124119
DocumentReference doc_;
@@ -145,12 +140,9 @@ class TransactionStage {
145140
TransactionStage(
146141
std::string tag,
147142
std::function<void(Transaction*, const DocumentReference&)> func)
148-
: tag_(std::move(tag)), func_(std::move(func)) {
149-
}
143+
: tag_(std::move(tag)), func_(std::move(func)) {}
150144

151-
const std::string& tag() const {
152-
return tag_;
153-
}
145+
const std::string& tag() const { return tag_; }
154146

155147
void operator()(Transaction* transaction,
156148
const DocumentReference& doc) const {
@@ -221,8 +213,7 @@ const auto get = new TransactionStage(
221213
*/
222214
class TransactionTester {
223215
public:
224-
explicit TransactionTester(Firestore* db) : db_(db) {
225-
}
216+
explicit TransactionTester(Firestore* db) : db_(db) {}
226217

227218
template <typename... Args>
228219
TransactionTester& Run(Args... args) {

firestore/integration_test_internal/src/util/event_accumulator.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,9 @@ namespace firestore {
1010
template <typename T>
1111
class EventAccumulator {
1212
public:
13-
EventAccumulator() : listener_("EventAccumulator") {
14-
}
13+
EventAccumulator() : listener_("EventAccumulator") {}
1514

16-
TestEventListener<T>* listener() {
17-
return &listener_;
18-
}
15+
TestEventListener<T>* listener() { return &listener_; }
1916

2017
std::vector<T> Await(int num_events) {
2118
int old_num_events = num_events_consumed_;
@@ -91,18 +88,14 @@ class EventAccumulator {
9188
return event;
9289
}
9390

94-
void FailOnNextEvent() {
95-
listener_.FailOnNextEvent();
96-
}
91+
void FailOnNextEvent() { listener_.FailOnNextEvent(); }
9792

9893
private:
9994
bool HasPendingWrites(T event) {
10095
return event.metadata().has_pending_writes();
10196
}
10297

103-
bool IsFromCache(T event) {
104-
return event.metadata().is_from_cache();
105-
}
98+
bool IsFromCache(T event) { return event.metadata().is_from_cache(); }
10699

107100
TestEventListener<T> listener_;
108101

firestore/integration_test_internal/src/util/future_test_util.cc

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ namespace firebase {
99

1010
namespace {
1111

12-
void PrintTo(std::ostream* os, FutureStatus future_status, int error,
12+
void PrintTo(std::ostream* os,
13+
FutureStatus future_status,
14+
int error,
1315
const char* error_message = nullptr) {
1416
*os << "Future<void>{status=" << ToEnumeratorName(future_status)
1517
<< " error=" << firestore::ToFirestoreErrorCodeName(error);

firestore/integration_test_internal/src/validation_test.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,10 @@ class ValidationTest : public FirestoreIntegrationTest {
7474
* Performs a write using each set and/or update API and makes sure it fails
7575
* with the expected reason.
7676
*/
77-
void ExpectWriteError(const MapFieldValue& data, const std::string& reason,
78-
bool include_sets, bool include_updates) {
77+
void ExpectWriteError(const MapFieldValue& data,
78+
const std::string& reason,
79+
bool include_sets,
80+
bool include_updates) {
7981
DocumentReference document = Document();
8082

8183
if (include_sets) {

0 commit comments

Comments
 (0)