Skip to content

Commit 04b7555

Browse files
authored
Get rid of util and testutil namespace aliases (#8917)
1 parent fa6dae2 commit 04b7555

18 files changed

+105
-109
lines changed

Firestore/Example/Tests/API/FIRFieldPathTests.mm

+4-4
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "Firestore/core/src/model/field_path.h"
2626
#include "Firestore/core/test/unit/testutil/testutil.h"
2727

28-
namespace testutil = firebase::firestore::testutil;
28+
using firebase::firestore::testutil::Field;
2929

3030
NS_ASSUME_NONNULL_BEGIN
3131

@@ -35,9 +35,9 @@ @interface FIRFieldPathTests : XCTestCase
3535
@implementation FIRFieldPathTests
3636

3737
- (void)testEquals {
38-
FIRFieldPath *foo = [[FIRFieldPath alloc] initPrivate:testutil::Field("foo.ooo.oooo")];
39-
FIRFieldPath *fooDup = [[FIRFieldPath alloc] initPrivate:testutil::Field("foo.ooo.oooo")];
40-
FIRFieldPath *bar = [[FIRFieldPath alloc] initPrivate:testutil::Field("baa.aaa.aaar")];
38+
FIRFieldPath *foo = [[FIRFieldPath alloc] initPrivate:Field("foo.ooo.oooo")];
39+
FIRFieldPath *fooDup = [[FIRFieldPath alloc] initPrivate:Field("foo.ooo.oooo")];
40+
FIRFieldPath *bar = [[FIRFieldPath alloc] initPrivate:Field("baa.aaa.aaar")];
4141
XCTAssertEqualObjects(foo, fooDup);
4242
XCTAssertNotEqualObjects(foo, bar);
4343

Firestore/Example/Tests/API/FIRFirestoreTests.mm

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424
#include "Firestore/core/test/unit/testutil/app_testing.h"
2525

26-
namespace testutil = firebase::firestore::testutil;
26+
using firebase::firestore::testutil::AppForUnitTesting;
2727

2828
@interface FIRFirestoreTests : XCTestCase
2929
@end
@@ -32,7 +32,7 @@ @implementation FIRFirestoreTests
3232

3333
- (void)testDeleteApp {
3434
// Ensure the app is set appropriately.
35-
FIRApp *app = testutil::AppForUnitTesting();
35+
FIRApp *app = AppForUnitTesting();
3636
NSString *appName = app.name;
3737
FIROptions *options = app.options;
3838

@@ -66,7 +66,7 @@ - (void)testDeleteApp {
6666

6767
- (void)testSetEmulatorSettingsSetsHost {
6868
// Ensure the app is set appropriately.
69-
FIRApp *app = testutil::AppForUnitTesting();
69+
FIRApp *app = AppForUnitTesting();
7070

7171
FIRFirestore *firestore = [FIRFirestore firestoreForApp:app];
7272

Firestore/Example/Tests/API/FIRQuerySnapshotTests.mm

+4-7
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@
3737
#include "Firestore/core/src/util/string_apple.h"
3838
#include "Firestore/core/test/unit/testutil/testutil.h"
3939

40-
namespace testutil = firebase::firestore::testutil;
41-
4240
using firebase::firestore::api::DocumentChange;
4341
using firebase::firestore::api::DocumentSnapshot;
4442
using firebase::firestore::api::Firestore;
@@ -49,11 +47,10 @@
4947
using firebase::firestore::model::DocumentComparator;
5048
using firebase::firestore::model::DocumentKeySet;
5149
using firebase::firestore::model::DocumentSet;
52-
53-
using testutil::Doc;
54-
using testutil::DocSet;
55-
using testutil::Map;
56-
using testutil::Query;
50+
using firebase::firestore::testutil::Doc;
51+
using firebase::firestore::testutil::DocSet;
52+
using firebase::firestore::testutil::Map;
53+
using firebase::firestore::testutil::Query;
5754

5855
NS_ASSUME_NONNULL_BEGIN
5956

Firestore/Example/Tests/API/FSTAPIHelpers.mm

+12-12
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@
4242
#include "Firestore/core/src/util/string_apple.h"
4343
#include "Firestore/core/test/unit/testutil/testutil.h"
4444

45-
namespace testutil = firebase::firestore::testutil;
46-
namespace util = firebase::firestore::util;
4745
using firebase::firestore::api::SnapshotMetadata;
4846
using firebase::firestore::core::DocumentViewChange;
4947
using firebase::firestore::core::ViewSnapshot;
@@ -55,9 +53,11 @@
5553
using firebase::firestore::model::DocumentSet;
5654
using firebase::firestore::model::MutableDocument;
5755
using firebase::firestore::nanopb::Message;
58-
59-
using testutil::Doc;
60-
using testutil::Query;
56+
using firebase::firestore::testutil::Doc;
57+
using firebase::firestore::testutil::Key;
58+
using firebase::firestore::testutil::Query;
59+
using firebase::firestore::testutil::Resource;
60+
using firebase::firestore::util::StringFormat;
6161

6262
NS_ASSUME_NONNULL_BEGIN
6363

@@ -95,19 +95,19 @@
9595
if (hasMutations) doc->SetHasLocalMutations();
9696
}
9797
return [[FIRDocumentSnapshot alloc] initWithFirestore:FSTTestFirestore()
98-
documentKey:testutil::Key(path)
98+
documentKey:Key(path)
9999
document:doc
100100
fromCache:fromCache
101101
hasPendingWrites:hasMutations];
102102
}
103103

104104
FIRCollectionReference *FSTTestCollectionRef(const char *path) {
105-
return [[FIRCollectionReference alloc] initWithPath:testutil::Resource(path)
105+
return [[FIRCollectionReference alloc] initWithPath:Resource(path)
106106
firestore:FSTTestFirestore().wrapped];
107107
}
108108

109109
FIRDocumentReference *FSTTestDocRef(const char *path) {
110-
return [[FIRDocumentReference alloc] initWithPath:testutil::Resource(path)
110+
return [[FIRDocumentReference alloc] initWithPath:Resource(path)
111111
firestore:FSTTestFirestore().wrapped];
112112
}
113113

@@ -125,10 +125,10 @@
125125
DocumentKeySet mutatedKeys;
126126
for (NSString *key in oldDocs) {
127127
Message<google_firestore_v1_Value> value = [reader parsedQueryValue:oldDocs[key]];
128-
std::string documentKey = util::StringFormat("%s/%s", path, key);
128+
std::string documentKey = StringFormat("%s/%s", path, key);
129129
MutableDocument doc = Doc(documentKey, 1, std::move(value));
130130
if (hasPendingWrites) {
131-
mutatedKeys = mutatedKeys.insert(testutil::Key(documentKey));
131+
mutatedKeys = mutatedKeys.insert(Key(documentKey));
132132
doc.SetHasLocalMutations();
133133
}
134134
oldDocuments = oldDocuments.insert(doc);
@@ -138,11 +138,11 @@
138138
std::vector<DocumentViewChange> documentChanges;
139139
for (NSString *key in docsToAdd) {
140140
Message<google_firestore_v1_Value> value = [reader parsedQueryValue:docsToAdd[key]];
141-
std::string documentKey = util::StringFormat("%s/%s", path, key);
141+
std::string documentKey = StringFormat("%s/%s", path, key);
142142
MutableDocument doc = Doc(documentKey, 1, std::move(value));
143143
documentChanges.emplace_back(doc, DocumentViewChange::Type::Added);
144144
if (hasPendingWrites) {
145-
mutatedKeys = mutatedKeys.insert(testutil::Key(documentKey));
145+
mutatedKeys = mutatedKeys.insert(Key(documentKey));
146146
doc.SetHasLocalMutations();
147147
}
148148
newDocuments = newDocuments.insert(doc);

Firestore/Example/Tests/API/FSTUserDataReaderTests.mm

+2-2
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
#include "Firestore/core/src/nanopb/nanopb_util.h"
3434
#include "Firestore/core/test/unit/testutil/testutil.h"
3535

36-
namespace util = firebase::firestore::util;
3736
namespace nanopb = firebase::firestore::nanopb;
3837
using firebase::Timestamp;
3938
using firebase::firestore::GeoPoint;
@@ -62,6 +61,7 @@
6261
using firebase::firestore::testutil::Map;
6362
using firebase::firestore::testutil::Value;
6463
using firebase::firestore::testutil::WrapObject;
64+
using firebase::firestore::util::MakeString;
6565

6666
@interface FSTUserDataReaderTests : XCTestCase
6767
@end
@@ -131,7 +131,7 @@ - (void)testConvertsStrings {
131131
for (id value in values) {
132132
Message<google_firestore_v1_Value> wrapped = FSTTestFieldValue(value);
133133
XCTAssertEqual(GetTypeOrder(*wrapped), TypeOrder::kString);
134-
XCTAssertEqual(nanopb::MakeString(wrapped->string_value), util::MakeString(value));
134+
XCTAssertEqual(nanopb::MakeString(wrapped->string_value), MakeString(value));
135135
}
136136
}
137137

Firestore/Example/Tests/Integration/API/FIRBundlesTests.mm

+11-10
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
#include "Firestore/core/src/util/string_apple.h"
2727
#include "Firestore/core/test/unit/testutil/bundle_builder.h"
2828

29-
namespace testutil = firebase::firestore::testutil;
30-
namespace util = firebase::firestore::util;
29+
using firebase::firestore::testutil::CreateBundle;
30+
using firebase::firestore::util::MakeString;
31+
using firebase::firestore::util::MakeNSString;
3132

3233
@interface FIRBundlesTests : FSTIntegrationTestCase
3334
@end
@@ -67,11 +68,11 @@ - (void)verifyErrorProgress:(FIRLoadBundleTaskProgress*)progress {
6768
}
6869

6970
- (std::string)defaultBundle {
70-
return testutil::CreateBundle(util::MakeString([FSTIntegrationTestCase projectID]));
71+
return CreateBundle(MakeString([FSTIntegrationTestCase projectID]));
7172
}
7273

7374
- (std::string)bundleForProject:(NSString*)projectID {
74-
return testutil::CreateBundle(util::MakeString(projectID));
75+
return CreateBundle(MakeString(projectID));
7576
}
7677

7778
- (void)verifyQueryResults {
@@ -115,7 +116,7 @@ - (void)testLoadWithDocumentsThatAreAlreadyPulledFromBackend {
115116
__block FIRLoadBundleTaskProgress* result;
116117
XCTestExpectation* expectation = [self expectationWithDescription:@"loading complete"];
117118
FIRLoadBundleTask* task =
118-
[self.db loadBundle:[util::MakeNSString(bundle) dataUsingEncoding:NSUTF8StringEncoding]
119+
[self.db loadBundle:[MakeNSString(bundle) dataUsingEncoding:NSUTF8StringEncoding]
119120
completion:^(FIRLoadBundleTaskProgress* progress, NSError* error) {
120121
result = progress;
121122
XCTAssertNil(error);
@@ -147,7 +148,7 @@ - (void)testLoadDocumentsWithProgressUpdates {
147148
__block FIRLoadBundleTaskProgress* result;
148149
XCTestExpectation* expectation = [self expectationWithDescription:@"loading complete"];
149150
FIRLoadBundleTask* task =
150-
[self.db loadBundle:[util::MakeNSString(bundle) dataUsingEncoding:NSUTF8StringEncoding]
151+
[self.db loadBundle:[MakeNSString(bundle) dataUsingEncoding:NSUTF8StringEncoding]
151152
completion:^(FIRLoadBundleTaskProgress* progress, NSError* error) {
152153
result = progress;
153154
XCTAssertNil(error);
@@ -171,14 +172,14 @@ - (void)testLoadDocumentsWithProgressUpdates {
171172

172173
- (void)testLoadForASecondTimeSkips {
173174
auto bundle = [self defaultBundle];
174-
[self.db loadBundle:[util::MakeNSString(bundle) dataUsingEncoding:NSUTF8StringEncoding]];
175+
[self.db loadBundle:[MakeNSString(bundle) dataUsingEncoding:NSUTF8StringEncoding]];
175176

176177
// Load for a second time
177178
NSMutableArray* progresses = [[NSMutableArray alloc] init];
178179
__block FIRLoadBundleTaskProgress* result;
179180
XCTestExpectation* expectation = [self expectationWithDescription:@"loading complete"];
180181
FIRLoadBundleTask* task =
181-
[self.db loadBundle:[util::MakeNSString(bundle) dataUsingEncoding:NSUTF8StringEncoding]
182+
[self.db loadBundle:[MakeNSString(bundle) dataUsingEncoding:NSUTF8StringEncoding]
182183
completion:^(FIRLoadBundleTaskProgress* progress, NSError* error) {
183184
result = progress;
184185
XCTAssertNil(error);
@@ -205,7 +206,7 @@ - (void)testLoadedDocumentsShouldNotBeGarbageCollectedRightAway {
205206
auto bundle = [self defaultBundle];
206207
__block FIRLoadBundleTaskProgress* result;
207208
XCTestExpectation* expectation = [self expectationWithDescription:@"loading complete"];
208-
[self.db loadBundle:[util::MakeNSString(bundle) dataUsingEncoding:NSUTF8StringEncoding]
209+
[self.db loadBundle:[MakeNSString(bundle) dataUsingEncoding:NSUTF8StringEncoding]
209210
completion:^(FIRLoadBundleTaskProgress* progress, NSError* error) {
210211
result = progress;
211212
XCTAssertNil(error);
@@ -229,7 +230,7 @@ - (void)testLoadBundlesFromOtherProjectFails {
229230
XCTestExpectation* expectation = [self expectationWithDescription:@"loading complete"];
230231
auto bundle = [self bundleForProject:@"OtherProject"];
231232
FIRLoadBundleTask* task =
232-
[self.db loadBundle:[util::MakeNSString(bundle) dataUsingEncoding:NSUTF8StringEncoding]
233+
[self.db loadBundle:[MakeNSString(bundle) dataUsingEncoding:NSUTF8StringEncoding]
233234
completion:^(FIRLoadBundleTaskProgress* progress, NSError* error) {
234235
result = progress;
235236
XCTAssertNotNil(error);

Firestore/Example/Tests/Integration/API/FIRDatabaseTests.mm

+6-7
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@
2727
#include "Firestore/core/src/core/firestore_client.h"
2828
#include "Firestore/core/test/unit/testutil/app_testing.h"
2929

30-
namespace testutil = firebase::firestore::testutil;
31-
30+
using firebase::firestore::testutil::AppForUnitTesting;
3231
using firebase::firestore::util::MakeString;
3332
using firebase::firestore::util::TimerId;
3433

@@ -1473,7 +1472,7 @@ - (void)testClearPersistenceWhileRunningFails {
14731472
}
14741473

14751474
- (void)testRestartFirestoreLeadsToNewInstance {
1476-
FIRApp *app = testutil::AppForUnitTesting(MakeString([FSTIntegrationTestCase projectID]));
1475+
FIRApp *app = AppForUnitTesting(MakeString([FSTIntegrationTestCase projectID]));
14771476
FIRFirestore *firestore = [FIRFirestore firestoreForApp:app];
14781477
FIRFirestore *sameInstance = [FIRFirestore firestoreForApp:app];
14791478
firestore.settings = [FSTIntegrationTestCase settings];
@@ -1498,7 +1497,7 @@ - (void)testRestartFirestoreLeadsToNewInstance {
14981497
}
14991498

15001499
- (void)testAppDeleteLeadsToFirestoreTermination {
1501-
FIRApp *app = testutil::AppForUnitTesting(MakeString([FSTIntegrationTestCase projectID]));
1500+
FIRApp *app = AppForUnitTesting(MakeString([FSTIntegrationTestCase projectID]));
15021501
FIRFirestore *firestore = [FIRFirestore firestoreForApp:app];
15031502
firestore.settings = [FSTIntegrationTestCase settings];
15041503
NSDictionary<NSString *, id> *data =
@@ -1512,7 +1511,7 @@ - (void)testAppDeleteLeadsToFirestoreTermination {
15121511

15131512
// Ensures b/172958106 doesn't regress.
15141513
- (void)testDeleteAppWorksWhenLastReferenceToFirestoreIsInListener {
1515-
FIRApp *app = testutil::AppForUnitTesting(MakeString([FSTIntegrationTestCase projectID]));
1514+
FIRApp *app = AppForUnitTesting(MakeString([FSTIntegrationTestCase projectID]));
15161515
FIRFirestore *firestore = [FIRFirestore firestoreForApp:app];
15171516

15181517
FIRDocumentReference *doc = [firestore documentWithPath:@"abc/123"];
@@ -1531,7 +1530,7 @@ - (void)testDeleteAppWorksWhenLastReferenceToFirestoreIsInListener {
15311530
}
15321531

15331532
- (void)testTerminateCanBeCalledMultipleTimes {
1534-
FIRApp *app = testutil::AppForUnitTesting(MakeString([FSTIntegrationTestCase projectID]));
1533+
FIRApp *app = AppForUnitTesting(MakeString([FSTIntegrationTestCase projectID]));
15351534
FIRFirestore *firestore = [FIRFirestore firestoreForApp:app];
15361535

15371536
[firestore terminateWithCompletion:[self completionForExpectationWithName:@"Terminate1"]];
@@ -1548,7 +1547,7 @@ - (void)testTerminateCanBeCalledMultipleTimes {
15481547
}
15491548

15501549
- (void)testCanRemoveListenerAfterTermination {
1551-
FIRApp *app = testutil::AppForUnitTesting(MakeString([FSTIntegrationTestCase projectID]));
1550+
FIRApp *app = AppForUnitTesting(MakeString([FSTIntegrationTestCase projectID]));
15521551
FIRFirestore *firestore = [FIRFirestore firestoreForApp:app];
15531552
firestore.settings = [FSTIntegrationTestCase settings];
15541553

Firestore/Example/Tests/Integration/API/FIRValidationTests.mm

+4-3
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@
2929

3030
#include "Firestore/core/test/unit/testutil/app_testing.h"
3131

32-
namespace testutil = firebase::firestore::testutil;
32+
using firebase::firestore::testutil::AppForUnitTesting;
33+
using firebase::firestore::testutil::OptionsForUnitTesting;
3334

3435
// We have tests for passing nil when nil is not supposed to be allowed. So suppress the warnings.
3536
#pragma clang diagnostic ignored "-Wnonnull"
@@ -76,9 +77,9 @@ - (void)testNilFIRAppFails {
7677
}
7778

7879
- (void)testNilProjectIDFails {
79-
FIROptions *options = testutil::OptionsForUnitTesting("ignored");
80+
FIROptions *options = OptionsForUnitTesting("ignored");
8081
options.projectID = nil;
81-
FIRApp *app = testutil::AppForUnitTesting(options);
82+
FIRApp *app = AppForUnitTesting(options);
8283
FSTAssertThrows([FIRFirestore firestoreForApp:app],
8384
@"FIROptions.projectID must be set to a valid project ID.");
8485
}

Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.mm

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@
2828
#include "Firestore/core/src/util/sanitizers.h"
2929
#include "Firestore/core/src/util/string_apple.h"
3030

31-
namespace util = firebase::firestore::util;
3231
using firebase::firestore::util::CreateAutoId;
32+
using firebase::firestore::util::MakeNSString;
3333

3434
NS_ASSUME_NONNULL_BEGIN
3535

@@ -334,7 +334,7 @@ - (void)testCanWriteVeryLargeBatches {
334334
NSString *kb = [@"" stringByPaddingToLength:1000 withString:@"a" startingAtIndex:0];
335335
NSMutableDictionary<NSString *, id> *values = [NSMutableDictionary dictionary];
336336
for (int i = 0; i < 1000; i++) {
337-
values[util::MakeNSString(CreateAutoId())] = kb;
337+
values[MakeNSString(CreateAutoId())] = kb;
338338
}
339339

340340
FIRDocumentReference *doc = [self documentRef];

Firestore/Example/Tests/Integration/FSTDatastoreTests.mm

+8-8
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,6 @@
5454
#include "Firestore/core/test/unit/testutil/testutil.h"
5555
#include "absl/memory/memory.h"
5656

57-
namespace util = firebase::firestore::util;
58-
namespace testutil = firebase::firestore::testutil;
59-
6057
using firebase::Timestamp;
6158
using firebase::firestore::core::DatabaseInfo;
6259
using firebase::firestore::credentials::EmptyAppCheckCredentialsProvider;
@@ -83,8 +80,11 @@
8380
using firebase::firestore::remote::RemoteEvent;
8481
using firebase::firestore::remote::RemoteStore;
8582
using firebase::firestore::remote::RemoteStoreCallback;
83+
using firebase::firestore::testutil::AsyncQueueForTesting;
8684
using firebase::firestore::testutil::Map;
85+
using firebase::firestore::testutil::SetMutation;
8786
using firebase::firestore::util::AsyncQueue;
87+
using firebase::firestore::util::MakeString;
8888
using firebase::firestore::util::Status;
8989

9090
NS_ASSUME_NONNULL_BEGIN
@@ -237,15 +237,15 @@ - (void)setUp {
237237
NSString *projectID = [FSTIntegrationTestCase projectID];
238238
FIRFirestoreSettings *settings = [FSTIntegrationTestCase settings];
239239
if (!settings.sslEnabled) {
240-
GrpcConnection::UseInsecureChannel(util::MakeString(settings.host));
240+
GrpcConnection::UseInsecureChannel(MakeString(settings.host));
241241
}
242242

243-
DatabaseId database_id(util::MakeString(projectID));
243+
DatabaseId database_id(MakeString(projectID));
244244

245245
_databaseInfo =
246-
DatabaseInfo(database_id, "test-key", util::MakeString(settings.host), settings.sslEnabled);
246+
DatabaseInfo(database_id, "test-key", MakeString(settings.host), settings.sslEnabled);
247247

248-
_testWorkerQueue = testutil::AsyncQueueForTesting();
248+
_testWorkerQueue = AsyncQueueForTesting();
249249
_connectivityMonitor = CreateNoOpConnectivityMonitor();
250250
_firebaseMetadataProvider = CreateFirebaseMetadataProviderNoOp();
251251
_datastore = std::make_shared<Datastore>(
@@ -292,7 +292,7 @@ - (void)testStreamingWrite {
292292

293293
_remoteStore->set_sync_engine(&capture);
294294

295-
auto mutation = testutil::SetMutation("rooms/eros", Map("name", "Eros"));
295+
auto mutation = SetMutation("rooms/eros", Map("name", "Eros"));
296296
MutationBatch batch = MutationBatch(23, Timestamp::Now(), {}, {mutation});
297297
_testWorkerQueue->Enqueue([=] {
298298
_remoteStore->AddToWritePipeline(batch);

0 commit comments

Comments
 (0)