From e527412a1cffa9e6840c310032ff3e353fab79ba Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Sat, 29 Dec 2018 08:07:57 -0800 Subject: [PATCH 1/5] Travis to Xcode 10.1 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 8450fd94e24..13fd1f2c86f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ os: osx -osx_image: xcode10 +osx_image: xcode10.1 language: objective-c cache: - bundler From 44f1c305c71a11f225707af7e3064d88d78fefb7 Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Sat, 29 Dec 2018 08:25:35 -0800 Subject: [PATCH 2/5] Update to clang-format 8 --- .../Tests/FIRAnalyticsConfigurationTest.m | 8 +- Example/Core/Tests/FIRAppTest.m | 148 ++++++++-------- Example/Core/Tests/FIROptionsTest.m | 64 +++---- .../FDLBuilderTestAppObjCEarlGreyTests.m | 5 +- .../Tests/FDLURLComponentsTests.m | 5 +- Example/DynamicLinks/Tests/UtilitiesTests.m | 22 ++- Example/Shared/FIRSampleAppUtilities.m | 22 +-- .../Integration/FIRStorageIntegrationTests.m | 4 +- .../Tests/Unit/FIRStorageComponentTests.m | 8 +- .../Tests/Unit/FIRStorageTestHelpers.m | 4 +- Example/Storage/Tests/Unit/FIRStorageTests.m | 4 +- .../Unit/FIRStorageTokenAuthorizerTests.m | 10 +- Firebase/Core/FIRApp.m | 35 ++-- Firebase/Core/FIROptions.m | 9 +- .../FDLURLComponents/FDLURLComponents.m | 5 +- .../FIRDLDefaultRetrievalProcessV2.m | 9 +- Firebase/DynamicLinks/FIRDynamicLink.m | 11 +- .../DynamicLinks/FIRDynamicLinkNetworking.m | 5 +- .../DynamicLinks/FIRDynamicLinks+FirstParty.h | 5 +- Firebase/DynamicLinks/FIRDynamicLinks.m | 51 +++--- .../DynamicLinks/Utilities/FDLUtilities.m | 8 +- .../Banner/FIDBannerViewController.m | 4 +- .../FIRIAMDefaultDisplayImpl.m | 4 +- .../ImageOnly/FIDImageOnlyViewController.m | 4 +- .../Modal/FIDModalViewController.m | 20 +-- Firebase/Storage/FIRStorage.m | 5 +- Firebase/Storage/FIRStorageComponent.m | 4 +- Firebase/Storage/FIRStorageDownloadTask.m | 4 +- Firebase/Storage/FIRStorageErrors.m | 9 +- .../Storage/FIRStorageGetDownloadURLTask.m | 4 +- Firebase/Storage/FIRStoragePath.m | 7 +- Firebase/Storage/FIRStorageReference.m | 16 +- Firebase/Storage/FIRStorageUploadTask.m | 4 +- .../FuzzingTargets/FSTFuzzTestFieldPath.mm | 5 +- .../Example/Tests/API/FIRFirestoreTests.mm | 5 +- .../Tests/API/FIRQuerySnapshotTests.mm | 16 +- Firestore/Example/Tests/API/FIRQueryTests.mm | 15 +- .../Tests/API/FIRSnapshotMetadataTests.mm | 16 +- .../Tests/Core/FSTQueryListenerTests.mm | 42 +++-- Firestore/Example/Tests/Core/FSTQueryTests.mm | 71 +++----- Firestore/Example/Tests/Core/FSTViewTests.mm | 164 +++++++++--------- .../Integration/API/FIRArrayTransformTests.mm | 48 ++--- .../Tests/Integration/API/FIRCursorTests.mm | 50 ++---- .../Tests/Integration/API/FIRDatabaseTests.mm | 67 +++---- .../Tests/Integration/API/FIRFieldsTests.mm | 3 +- .../Tests/Integration/API/FIRQueryTests.mm | 65 +++---- .../API/FIRServerTimestampTests.mm | 48 ++--- .../Integration/API/FIRValidationTests.mm | 149 ++++++---------- .../Integration/API/FIRWriteBatchTests.mm | 24 +-- .../Tests/Integration/FSTSmokeTests.mm | 4 +- .../Tests/Integration/FSTTransactionTests.mm | 5 +- .../Local/FSTLRUGarbageCollectorTests.mm | 4 +- .../Tests/Local/FSTLevelDBTransactionTests.mm | 17 +- .../Tests/Local/FSTLocalSerializerTests.mm | 11 +- .../Example/Tests/Local/FSTLocalStoreTests.mm | 8 +- .../Tests/Local/FSTMutationQueueTests.mm | 57 ++---- .../Tests/Local/FSTPersistenceTestHelpers.mm | 6 +- .../Example/Tests/Local/FSTQueryCacheTests.mm | 12 +- .../Example/Tests/Model/FSTDocumentTests.mm | 52 +++--- .../Example/Tests/Model/FSTFieldValueTests.mm | 71 +++----- .../Example/Tests/Model/FSTMutationTests.mm | 60 ++++--- .../Tests/Remote/FSTSerializerBetaTests.mm | 27 +-- .../Tests/Remote/FSTWatchChangeTests.mm | 4 +- .../Example/Tests/SpecTests/FSTSpecTests.mm | 25 ++- .../SpecTests/FSTSyncEngineTestDriver.mm | 15 +- Firestore/Example/Tests/Util/FSTHelpers.mm | 4 +- .../Tests/Util/FSTIntegrationTestCase.mm | 9 +- .../Source/API/FIRCollectionReference.mm | 7 +- Firestore/Source/API/FIRDocumentReference.mm | 25 ++- Firestore/Source/API/FIRDocumentSnapshot.mm | 13 +- Firestore/Source/API/FIRFirestore.mm | 16 +- Firestore/Source/API/FIRGeoPoint.mm | 14 +- Firestore/Source/API/FIRQuery.mm | 84 +++++---- Firestore/Source/API/FSTFirestoreComponent.mm | 4 +- Firestore/Source/API/FSTUserDataConverter.mm | 15 +- Firestore/Source/Core/FSTQuery.mm | 6 +- Firestore/Source/Core/FSTSyncEngine.mm | 8 +- Firestore/Source/Core/FSTViewSnapshot.mm | 22 +-- .../Source/Local/FSTLRUGarbageCollector.mm | 4 +- Firestore/Source/Local/FSTLevelDB.mm | 4 +- .../Source/Local/FSTLevelDBMutationQueue.mm | 20 +-- Firestore/Source/Local/FSTLocalSerializer.mm | 4 +- Firestore/Source/Local/FSTLocalStore.mm | 13 +- Firestore/Source/Model/FSTDocument.mm | 4 +- Firestore/Source/Public/FIRFirestore.h | 6 +- Firestore/Source/Remote/FSTDatastore.mm | 5 +- Firestore/Source/Remote/FSTSerializerBeta.mm | 5 +- .../firestore/local/leveldb_query_cache.mm | 13 +- .../local/leveldb_remote_document_cache.mm | 4 +- .../firebase/firestore/model/field_value.cc | 6 +- .../firestore/remote/remote_objc_bridge.mm | 12 +- .../firebase_credentials_provider_test.mm | 12 +- .../firestore/remote/datastore_test.mm | 13 +- .../IntegrationTests/FIRIntegrationTests.m | 69 ++++---- Functions/Example/Tests/FIRFunctionsTests.m | 5 +- Functions/FirebaseFunctions/FIRFunctions.m | 4 +- .../GULAppDelegateSwizzler.m | 12 +- .../Example/Tests/Network/GULNetworkTest.m | 40 ++--- .../Reachability/GULReachabilityCheckerTest.m | 4 +- .../Swizzler/GULAppDelegateSwizzlerTest.m | 14 +- .../Swizzler/GULRuntimeStateHelperTests.m | 5 +- .../Example/Tests/Swizzler/GULSwizzlerTest.m | 35 ++-- GoogleUtilities/Logger/GULLogger.m | 10 +- GoogleUtilities/MethodSwizzler/GULSwizzler.m | 8 +- GoogleUtilities/Network/GULNetwork.m | 17 +- .../Network/GULNetworkURLSession.m | 10 +- .../SwizzlerTestHelpers/GULProxy.m | 4 +- scripts/style.sh | 5 +- 108 files changed, 1027 insertions(+), 1260 deletions(-) diff --git a/Example/Core/Tests/FIRAnalyticsConfigurationTest.m b/Example/Core/Tests/FIRAnalyticsConfigurationTest.m index 8cf9da4677b..43babb0f544 100644 --- a/Example/Core/Tests/FIRAnalyticsConfigurationTest.m +++ b/Example/Core/Tests/FIRAnalyticsConfigurationTest.m @@ -99,9 +99,7 @@ - (void)testSettingAnalyticsCollectionEnabled { [self.observerMock setExpectationOrderMatters:YES]; [[self.observerMock expect] notificationWithName:notificationName object:config - userInfo:@{ - notificationName : @YES - }]; + userInfo:@{notificationName : @YES}]; // Test setting to enabled. [config setAnalyticsCollectionEnabled:YES]; @@ -109,9 +107,7 @@ - (void)testSettingAnalyticsCollectionEnabled { // Expect the second notification. [[self.observerMock expect] notificationWithName:notificationName object:config - userInfo:@{ - notificationName : @NO - }]; + userInfo:@{notificationName : @NO}]; // Test setting to disabled. [config setAnalyticsCollectionEnabled:NO]; diff --git a/Example/Core/Tests/FIRAppTest.m b/Example/Core/Tests/FIRAppTest.m index 7f3ccb97241..c144d6f438b 100644 --- a/Example/Core/Tests/FIRAppTest.m +++ b/Example/Core/Tests/FIRAppTest.m @@ -78,8 +78,8 @@ - (void)tearDown { } - (void)testConfigure { - NSDictionary *expectedUserInfo = - [self expectedUserInfoWithAppName:kFIRDefaultAppName isDefaultApp:YES]; + NSDictionary *expectedUserInfo = [self expectedUserInfoWithAppName:kFIRDefaultAppName + isDefaultApp:YES]; [self expectNotificationForObserver:self.observerMock notificationName:kFIRAppReadyToConfigureSDKNotification object:[FIRApp class] @@ -108,16 +108,16 @@ - (void)testConfigureWithOptions { #pragma clang diagnostic pop XCTAssertTrue([FIRApp allApps].count == 0); - NSDictionary *expectedUserInfo = - [self expectedUserInfoWithAppName:kFIRDefaultAppName isDefaultApp:YES]; + NSDictionary *expectedUserInfo = [self expectedUserInfoWithAppName:kFIRDefaultAppName + isDefaultApp:YES]; [self expectNotificationForObserver:self.observerMock notificationName:kFIRAppReadyToConfigureSDKNotification object:[FIRApp class] userInfo:expectedUserInfo]; // Use a valid instance of options. - FIROptions *options = - [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; + FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID + GCMSenderID:kGCMSenderID]; options.clientID = kClientID; XCTAssertNoThrow([FIRApp configureWithOptions:options]); OCMVerifyAll(self.observerMock); @@ -133,8 +133,8 @@ - (void)testConfigureWithOptions { } - (void)testConfigureWithNameAndOptions { - FIROptions *options = - [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; + FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID + GCMSenderID:kGCMSenderID]; options.clientID = kClientID; #pragma clang diagnostic push @@ -145,8 +145,8 @@ - (void)testConfigureWithNameAndOptions { XCTAssertThrows([FIRApp configureWithName:@"" options:options]); XCTAssertTrue([FIRApp allApps].count == 0); - NSDictionary *expectedUserInfo = - [self expectedUserInfoWithAppName:kFIRTestAppName1 isDefaultApp:NO]; + NSDictionary *expectedUserInfo = [self expectedUserInfoWithAppName:kFIRTestAppName1 + isDefaultApp:NO]; [self expectNotificationForObserver:self.observerMock notificationName:kFIRAppReadyToConfigureSDKNotification object:[FIRApp class] @@ -165,8 +165,8 @@ - (void)testConfigureWithNameAndOptions { } - (void)testConfigureWithMultipleApps { - FIROptions *options1 = - [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; + FIROptions *options1 = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID + GCMSenderID:kGCMSenderID]; options1.deepLinkURLScheme = kDeepLinkURLScheme; // Set up notification center observer for verifying notifications. @@ -174,8 +174,8 @@ - (void)testConfigureWithMultipleApps { name:kFIRAppReadyToConfigureSDKNotification object:[FIRApp class]]; - NSDictionary *expectedUserInfo1 = - [self expectedUserInfoWithAppName:kFIRTestAppName1 isDefaultApp:NO]; + NSDictionary *expectedUserInfo1 = [self expectedUserInfoWithAppName:kFIRTestAppName1 + isDefaultApp:NO]; [[self.observerMock expect] notificationWithName:kFIRAppReadyToConfigureSDKNotification object:[FIRApp class] userInfo:expectedUserInfo1]; @@ -183,13 +183,13 @@ - (void)testConfigureWithMultipleApps { XCTAssertTrue([FIRApp allApps].count == 1); // Configure a different app with valid customized options. - FIROptions *options2 = - [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; + FIROptions *options2 = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID + GCMSenderID:kGCMSenderID]; options2.bundleID = kBundleID; options2.APIKey = kCustomizedAPIKey; - NSDictionary *expectedUserInfo2 = - [self expectedUserInfoWithAppName:kFIRTestAppName2 isDefaultApp:NO]; + NSDictionary *expectedUserInfo2 = [self expectedUserInfoWithAppName:kFIRTestAppName2 + isDefaultApp:NO]; [[self.observerMock expect] notificationWithName:kFIRAppReadyToConfigureSDKNotification object:[FIRApp class] userInfo:expectedUserInfo2]; @@ -235,8 +235,8 @@ - (void)testAppNamed { - (void)testDeleteApp { NSString *name = NSStringFromSelector(_cmd); - FIROptions *options = - [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; + FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID + GCMSenderID:kGCMSenderID]; [FIRApp configureWithName:name options:options]; FIRApp *app = [FIRApp appNamed:name]; XCTAssertNotNil(app); @@ -269,8 +269,8 @@ - (void)testErrorForSubspecConfigurationFailure { } - (void)testOptionsLocking { - FIROptions *options = - [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; + FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID + GCMSenderID:kGCMSenderID]; options.projectID = kProjectID; options.databaseURL = kDatabaseURL; @@ -418,14 +418,14 @@ - (void)testAppIDFormatInvalid { XCTAssertFalse([FIRApp validateAppIDFormat:@"01:1337:ios:deadbeef" withVersion:kGoodVersionV1]); XCTAssertFalse([FIRApp validateAppIDFormat:@"10:1337:ios:deadbeef" withVersion:kGoodVersionV1]); XCTAssertFalse([FIRApp validateAppIDFormat:@"11:1337:ios:deadbeef" withVersion:kGoodVersionV1]); - XCTAssertFalse( - [FIRApp validateAppIDFormat:@"21:1337:ios:5e18052ab54fbfec" withVersion:kGoodVersionV2]); - XCTAssertFalse( - [FIRApp validateAppIDFormat:@"22:1337:ios:5e18052ab54fbfec" withVersion:kGoodVersionV2]); - XCTAssertFalse( - [FIRApp validateAppIDFormat:@"02:1337:ios:5e18052ab54fbfec" withVersion:kGoodVersionV2]); - XCTAssertFalse( - [FIRApp validateAppIDFormat:@"20:1337:ios:5e18052ab54fbfec" withVersion:kGoodVersionV2]); + XCTAssertFalse([FIRApp validateAppIDFormat:@"21:1337:ios:5e18052ab54fbfec" + withVersion:kGoodVersionV2]); + XCTAssertFalse([FIRApp validateAppIDFormat:@"22:1337:ios:5e18052ab54fbfec" + withVersion:kGoodVersionV2]); + XCTAssertFalse([FIRApp validateAppIDFormat:@"02:1337:ios:5e18052ab54fbfec" + withVersion:kGoodVersionV2]); + XCTAssertFalse([FIRApp validateAppIDFormat:@"20:1337:ios:5e18052ab54fbfec" + withVersion:kGoodVersionV2]); // Extra fields. XCTAssertFalse([FIRApp validateAppIDFormat:@"ab:1:1337:ios:deadbeef" withVersion:kGoodVersionV1]); @@ -466,31 +466,31 @@ - (void)testAppIDFingerprintInvalid { XCTAssertFalse([FIRApp validateAppIDFingerprint:kGoodAppIDV1 withVersion:kGoodAppIDV1]); // Versions digits that may make a partial match. - XCTAssertFalse( - [FIRApp validateAppIDFingerprint:@"01:1337:ios:deadbeef" withVersion:kGoodVersionV1]); - XCTAssertFalse( - [FIRApp validateAppIDFingerprint:@"10:1337:ios:deadbeef" withVersion:kGoodVersionV1]); - XCTAssertFalse( - [FIRApp validateAppIDFingerprint:@"11:1337:ios:deadbeef" withVersion:kGoodVersionV1]); - XCTAssertFalse( - [FIRApp validateAppIDFingerprint:@"21:1337:ios:5e18052ab54fbfec" withVersion:kGoodVersionV2]); - XCTAssertFalse( - [FIRApp validateAppIDFingerprint:@"22:1337:ios:5e18052ab54fbfec" withVersion:kGoodVersionV2]); - XCTAssertFalse( - [FIRApp validateAppIDFingerprint:@"02:1337:ios:5e18052ab54fbfec" withVersion:kGoodVersionV2]); - XCTAssertFalse( - [FIRApp validateAppIDFingerprint:@"20:1337:ios:5e18052ab54fbfec" withVersion:kGoodVersionV2]); + XCTAssertFalse([FIRApp validateAppIDFingerprint:@"01:1337:ios:deadbeef" + withVersion:kGoodVersionV1]); + XCTAssertFalse([FIRApp validateAppIDFingerprint:@"10:1337:ios:deadbeef" + withVersion:kGoodVersionV1]); + XCTAssertFalse([FIRApp validateAppIDFingerprint:@"11:1337:ios:deadbeef" + withVersion:kGoodVersionV1]); + XCTAssertFalse([FIRApp validateAppIDFingerprint:@"21:1337:ios:5e18052ab54fbfec" + withVersion:kGoodVersionV2]); + XCTAssertFalse([FIRApp validateAppIDFingerprint:@"22:1337:ios:5e18052ab54fbfec" + withVersion:kGoodVersionV2]); + XCTAssertFalse([FIRApp validateAppIDFingerprint:@"02:1337:ios:5e18052ab54fbfec" + withVersion:kGoodVersionV2]); + XCTAssertFalse([FIRApp validateAppIDFingerprint:@"20:1337:ios:5e18052ab54fbfec" + withVersion:kGoodVersionV2]); // Extra fields. - XCTAssertFalse( - [FIRApp validateAppIDFingerprint:@"ab:1:1337:ios:deadbeef" withVersion:kGoodVersionV1]); - XCTAssertFalse( - [FIRApp validateAppIDFingerprint:@"1:ab:1337:ios:deadbeef" withVersion:kGoodVersionV1]); - XCTAssertFalse( - [FIRApp validateAppIDFingerprint:@"1:1337:ab:ios:deadbeef" withVersion:kGoodVersionV1]); - XCTAssertFalse( - [FIRApp validateAppIDFingerprint:@"1:1337:ios:ab:deadbeef" withVersion:kGoodVersionV1]); - XCTAssertFalse( - [FIRApp validateAppIDFingerprint:@"1:1337:ios:deadbeef:ab" withVersion:kGoodVersionV1]); + XCTAssertFalse([FIRApp validateAppIDFingerprint:@"ab:1:1337:ios:deadbeef" + withVersion:kGoodVersionV1]); + XCTAssertFalse([FIRApp validateAppIDFingerprint:@"1:ab:1337:ios:deadbeef" + withVersion:kGoodVersionV1]); + XCTAssertFalse([FIRApp validateAppIDFingerprint:@"1:1337:ab:ios:deadbeef" + withVersion:kGoodVersionV1]); + XCTAssertFalse([FIRApp validateAppIDFingerprint:@"1:1337:ios:ab:deadbeef" + withVersion:kGoodVersionV1]); + XCTAssertFalse([FIRApp validateAppIDFingerprint:@"1:1337:ios:deadbeef:ab" + withVersion:kGoodVersionV1]); } #pragma mark - Automatic Data Collection Tests @@ -498,8 +498,8 @@ - (void)testAppIDFingerprintInvalid { - (void)testGlobalDataCollectionNoFlags { // Test: No flags set. NSString *name = NSStringFromSelector(_cmd); - FIROptions *options = - [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; + FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID + GCMSenderID:kGCMSenderID]; FIRApp *app = [[FIRApp alloc] initInstanceWithName:name options:options]; OCMStub([self.appClassMock readDataCollectionSwitchFromPlist]).andReturn(nil); OCMStub([self.appClassMock readDataCollectionSwitchFromUserDefaultsForApp:OCMOCK_ANY]) @@ -511,8 +511,8 @@ - (void)testGlobalDataCollectionNoFlags { - (void)testGlobalDataCollectionPlistSetEnabled { // Test: Plist set to enabled, no override. NSString *name = NSStringFromSelector(_cmd); - FIROptions *options = - [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; + FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID + GCMSenderID:kGCMSenderID]; FIRApp *app = [[FIRApp alloc] initInstanceWithName:name options:options]; OCMStub([self.appClassMock readDataCollectionSwitchFromPlist]).andReturn(@YES); OCMStub([self.appClassMock readDataCollectionSwitchFromUserDefaultsForApp:OCMOCK_ANY]) @@ -524,8 +524,8 @@ - (void)testGlobalDataCollectionPlistSetEnabled { - (void)testGlobalDataCollectionPlistSetDisabled { // Test: Plist set to disabled, no override. NSString *name = NSStringFromSelector(_cmd); - FIROptions *options = - [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; + FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID + GCMSenderID:kGCMSenderID]; FIRApp *app = [[FIRApp alloc] initInstanceWithName:name options:options]; OCMStub([self.appClassMock readDataCollectionSwitchFromPlist]).andReturn(@NO); OCMStub([self.appClassMock readDataCollectionSwitchFromUserDefaultsForApp:OCMOCK_ANY]) @@ -537,8 +537,8 @@ - (void)testGlobalDataCollectionPlistSetDisabled { - (void)testGlobalDataCollectionUserSpecifiedEnabled { // Test: User specified as enabled, no plist value. NSString *name = NSStringFromSelector(_cmd); - FIROptions *options = - [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; + FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID + GCMSenderID:kGCMSenderID]; FIRApp *app = [[FIRApp alloc] initInstanceWithName:name options:options]; OCMStub([self.appClassMock readDataCollectionSwitchFromPlist]).andReturn(nil); OCMStub([self.appClassMock readDataCollectionSwitchFromUserDefaultsForApp:OCMOCK_ANY]) @@ -550,8 +550,8 @@ - (void)testGlobalDataCollectionUserSpecifiedEnabled { - (void)testGlobalDataCollectionUserSpecifiedDisabled { // Test: User specified as disabled, no plist value. NSString *name = NSStringFromSelector(_cmd); - FIROptions *options = - [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; + FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID + GCMSenderID:kGCMSenderID]; FIRApp *app = [[FIRApp alloc] initInstanceWithName:name options:options]; OCMStub([self.appClassMock readDataCollectionSwitchFromPlist]).andReturn(nil); OCMStub([self.appClassMock readDataCollectionSwitchFromUserDefaultsForApp:OCMOCK_ANY]) @@ -563,8 +563,8 @@ - (void)testGlobalDataCollectionUserSpecifiedDisabled { - (void)testGlobalDataCollectionUserOverriddenEnabled { // Test: User specified as enabled, with plist set as disabled. NSString *name = NSStringFromSelector(_cmd); - FIROptions *options = - [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; + FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID + GCMSenderID:kGCMSenderID]; FIRApp *app = [[FIRApp alloc] initInstanceWithName:name options:options]; OCMStub([self.appClassMock readDataCollectionSwitchFromPlist]).andReturn(@NO); OCMStub([self.appClassMock readDataCollectionSwitchFromUserDefaultsForApp:OCMOCK_ANY]) @@ -576,8 +576,8 @@ - (void)testGlobalDataCollectionUserOverriddenEnabled { - (void)testGlobalDataCollectionUserOverriddenDisabled { // Test: User specified as disabled, with plist set as enabled. NSString *name = NSStringFromSelector(_cmd); - FIROptions *options = - [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; + FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID + GCMSenderID:kGCMSenderID]; FIRApp *app = [[FIRApp alloc] initInstanceWithName:name options:options]; OCMStub([self.appClassMock readDataCollectionSwitchFromPlist]).andReturn(@YES); OCMStub([self.appClassMock readDataCollectionSwitchFromUserDefaultsForApp:OCMOCK_ANY]) @@ -589,8 +589,8 @@ - (void)testGlobalDataCollectionUserOverriddenDisabled { - (void)testGlobalDataCollectionWriteToDefaults { id defaultsMock = OCMPartialMock([NSUserDefaults standardUserDefaults]); NSString *name = NSStringFromSelector(_cmd); - FIROptions *options = - [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; + FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID + GCMSenderID:kGCMSenderID]; [FIRApp configureWithName:name options:options]; FIRApp *app = [FIRApp appNamed:name]; app.dataCollectionDefaultEnabled = YES; @@ -607,8 +607,8 @@ - (void)testGlobalDataCollectionWriteToDefaults { - (void)testGlobalDataCollectionClearedAfterDelete { // Configure and disable data collection for the default FIRApp. NSString *name = NSStringFromSelector(_cmd); - FIROptions *options = - [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; + FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID + GCMSenderID:kGCMSenderID]; [FIRApp configureWithName:name options:options]; FIRApp *app = [FIRApp appNamed:name]; app.dataCollectionDefaultEnabled = NO; @@ -631,8 +631,8 @@ - (void)testGlobalDataCollectionClearedAfterDelete { } - (void)testGlobalDataCollectionNoDiagnosticsSent { - FIROptions *options = - [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; + FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID + GCMSenderID:kGCMSenderID]; FIRApp *app = [[FIRApp alloc] initInstanceWithName:NSStringFromSelector(_cmd) options:options]; app.dataCollectionDefaultEnabled = NO; diff --git a/Example/Core/Tests/FIROptionsTest.m b/Example/Core/Tests/FIROptionsTest.m index 382ac49231f..3c078d93a43 100644 --- a/Example/Core/Tests/FIROptionsTest.m +++ b/Example/Core/Tests/FIROptionsTest.m @@ -82,8 +82,8 @@ - (void)testDefaultOptions { } - (void)testInitCustomizedOptions { - FIROptions *options = - [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; + FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID + GCMSenderID:kGCMSenderID]; options.APIKey = kAPIKey; options.bundleID = kBundleID; options.clientID = kClientID; @@ -98,8 +98,8 @@ - (void)testInitCustomizedOptions { } - (void)testInitWithContentsOfFile { - NSString *filePath = - [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" ofType:@"plist"]; + NSString *filePath = [[NSBundle mainBundle] pathForResource:@"GoogleService-Info" + ofType:@"plist"]; FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:filePath]; [self assertOptionsMatchDefaults:options andProjectID:YES]; XCTAssertNil(options.deepLinkURLScheme); @@ -136,8 +136,8 @@ - (void)assertOptionsMatchDefaults:(FIROptions *)options andProjectID:(BOOL)matc - (void)testCopyingProperties { NSMutableString *mutableString; - FIROptions *options = - [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; + FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID + GCMSenderID:kGCMSenderID]; mutableString = [[NSMutableString alloc] initWithString:@"1"]; options.APIKey = mutableString; [mutableString appendString:@"2"]; @@ -208,8 +208,8 @@ - (void)testCopyWithZone { XCTAssertEqualObjects(newOptions.deepLinkURLScheme, kDeepLinkURLScheme); // customized options - FIROptions *customizedOptions = - [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; + FIROptions *customizedOptions = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID + GCMSenderID:kGCMSenderID]; customizedOptions.deepLinkURLScheme = kDeepLinkURLScheme; FIROptions *copyCustomizedOptions = [customizedOptions copy]; [copyCustomizedOptions setDeepLinkURLScheme:kNewDeepLinkURLScheme]; @@ -466,20 +466,16 @@ - (void)testAnalyticsCollectionGlobalSwitchOverrideToDisable { OCMStub([appMock isDataCollectionDefaultEnabled]).andReturn(YES); // Test the three Analytics flags that override to disable Analytics collection. - FIROptions *collectionEnabledOptions = [[FIROptions alloc] initInternalWithOptionsDictionary:@{ - kFIRIsAnalyticsCollectionEnabled : @NO - }]; + FIROptions *collectionEnabledOptions = [[FIROptions alloc] + initInternalWithOptionsDictionary:@{kFIRIsAnalyticsCollectionEnabled : @NO}]; XCTAssertFalse(collectionEnabledOptions.isAnalyticsCollectionEnabled); - FIROptions *collectionDeactivatedOptions = - [[FIROptions alloc] initInternalWithOptionsDictionary:@{ - kFIRIsAnalyticsCollectionDeactivated : @YES - }]; + FIROptions *collectionDeactivatedOptions = [[FIROptions alloc] + initInternalWithOptionsDictionary:@{kFIRIsAnalyticsCollectionDeactivated : @YES}]; XCTAssertFalse(collectionDeactivatedOptions.isAnalyticsCollectionEnabled); - FIROptions *measurementEnabledOptions = [[FIROptions alloc] initInternalWithOptionsDictionary:@{ - kFIRIsMeasurementEnabled : @NO - }]; + FIROptions *measurementEnabledOptions = + [[FIROptions alloc] initInternalWithOptionsDictionary:@{kFIRIsMeasurementEnabled : @NO}]; XCTAssertFalse(measurementEnabledOptions.isAnalyticsCollectionEnabled); } @@ -491,14 +487,12 @@ - (void)testAnalyticsCollectionGlobalSwitchOverrideToEnable { OCMStub([appMock isDataCollectionDefaultEnabled]).andReturn(NO); // Test the two Analytics flags that can override and enable collection. - FIROptions *collectionEnabledOptions = [[FIROptions alloc] initInternalWithOptionsDictionary:@{ - kFIRIsAnalyticsCollectionEnabled : @YES - }]; + FIROptions *collectionEnabledOptions = [[FIROptions alloc] + initInternalWithOptionsDictionary:@{kFIRIsAnalyticsCollectionEnabled : @YES}]; XCTAssertTrue(collectionEnabledOptions.isAnalyticsCollectionEnabled); - FIROptions *measurementEnabledOptions = [[FIROptions alloc] initInternalWithOptionsDictionary:@{ - kFIRIsMeasurementEnabled : @YES - }]; + FIROptions *measurementEnabledOptions = + [[FIROptions alloc] initInternalWithOptionsDictionary:@{kFIRIsMeasurementEnabled : @YES}]; XCTAssertTrue(measurementEnabledOptions.isAnalyticsCollectionEnabled); } @@ -534,31 +528,27 @@ - (void)testAnalyticsCollectionExplicitlySet { // Test the old measurement flag. options = [[FIROptions alloc] initInternalWithOptionsDictionary:@{}]; - analyticsOptions = [options analyticsOptionsDictionaryWithInfoDictionary:@{ - kFIRIsMeasurementEnabled : @YES - }]; + analyticsOptions = + [options analyticsOptionsDictionaryWithInfoDictionary:@{kFIRIsMeasurementEnabled : @YES}]; XCTAssertTrue([options isAnalyticsCollectionExpicitlySet]); options = [[FIROptions alloc] initInternalWithOptionsDictionary:@{}]; - analyticsOptions = [options analyticsOptionsDictionaryWithInfoDictionary:@{ - kFIRIsMeasurementEnabled : @NO - }]; + analyticsOptions = + [options analyticsOptionsDictionaryWithInfoDictionary:@{kFIRIsMeasurementEnabled : @NO}]; XCTAssertTrue([options isAnalyticsCollectionExpicitlySet]); // For good measure, a combination of all 3 (even if they conflict). optionsDictionary = - @{kFIRIsAnalyticsCollectionDeactivated : @YES, - kFIRIsAnalyticsCollectionEnabled : @YES}; + @{kFIRIsAnalyticsCollectionDeactivated : @YES, kFIRIsAnalyticsCollectionEnabled : @YES}; options = [[FIROptions alloc] initInternalWithOptionsDictionary:optionsDictionary]; - analyticsOptions = [options analyticsOptionsDictionaryWithInfoDictionary:@{ - kFIRIsMeasurementEnabled : @NO - }]; + analyticsOptions = + [options analyticsOptionsDictionaryWithInfoDictionary:@{kFIRIsMeasurementEnabled : @NO}]; XCTAssertTrue([options isAnalyticsCollectionExpicitlySet]); } - (void)testModifyingOptionsThrows { - FIROptions *options = - [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID GCMSenderID:kGCMSenderID]; + FIROptions *options = [[FIROptions alloc] initWithGoogleAppID:kGoogleAppID + GCMSenderID:kGCMSenderID]; options.editingLocked = YES; // Modification to every property should result in an exception. diff --git a/Example/DynamicLinks/FDLBuilderTestAppObjCTests/FDLBuilderTestAppObjCEarlGreyTests.m b/Example/DynamicLinks/FDLBuilderTestAppObjCTests/FDLBuilderTestAppObjCEarlGreyTests.m index 04ed308f8a1..f117b3682f0 100644 --- a/Example/DynamicLinks/FDLBuilderTestAppObjCTests/FDLBuilderTestAppObjCEarlGreyTests.m +++ b/Example/DynamicLinks/FDLBuilderTestAppObjCTests/FDLBuilderTestAppObjCEarlGreyTests.m @@ -33,8 +33,9 @@ @implementation FDLBuilderTestAppObjCEarlGreyTests - (void)testOpenFDLFromAppGeneratedLink { // On first launch, a null FDL Received alert is displayed (by design); in // this case, we need to dismiss it in order to proceed - BOOL hasFirstInstallAlertDisplayed = - [self confirmPresenceOfFDLAlertWithURL:@"(null)" matchType:@"0" minimumAppVersion:@"(null)"]; + BOOL hasFirstInstallAlertDisplayed = [self confirmPresenceOfFDLAlertWithURL:@"(null)" + matchType:@"0" + minimumAppVersion:@"(null)"]; if (hasFirstInstallAlertDisplayed) { [[EarlGrey selectElementWithMatcher:[GREYMatchers matcherForText:@"Dismiss"]] performAction:grey_tap()]; diff --git a/Example/DynamicLinks/Tests/FDLURLComponentsTests.m b/Example/DynamicLinks/Tests/FDLURLComponentsTests.m index 80e29827a96..dee0874c6f5 100644 --- a/Example/DynamicLinks/Tests/FDLURLComponentsTests.m +++ b/Example/DynamicLinks/Tests/FDLURLComponentsTests.m @@ -104,8 +104,9 @@ - (void)testAnalyticsParamsDictionaryRepresentationReturnsCorrectDictionaryEmpty } - (void)testAnalyticsParamsFactoryWithParamsReturnsInstanceOfCorrectClass { - id returnValue = - [FIRDynamicLinkGoogleAnalyticsParameters parametersWithSource:@"s" medium:@"m" campaign:@"c"]; + id returnValue = [FIRDynamicLinkGoogleAnalyticsParameters parametersWithSource:@"s" + medium:@"m" + campaign:@"c"]; XCTAssertTrue([returnValue isKindOfClass:[FIRDynamicLinkGoogleAnalyticsParameters class]]); } diff --git a/Example/DynamicLinks/Tests/UtilitiesTests.m b/Example/DynamicLinks/Tests/UtilitiesTests.m index 80a9d59057d..fab36239f8a 100644 --- a/Example/DynamicLinks/Tests/UtilitiesTests.m +++ b/Example/DynamicLinks/Tests/UtilitiesTests.m @@ -29,10 +29,9 @@ - (void)testFDLCookieRetrievalURLCreatesCorrectURL { static NSString *const kCustomScheme = @"customscheme"; static NSString *const kBundleID = @"com.My.Bundle.ID"; - NSString *expectedURLString = [NSString stringWithFormat: - @"https://goo.gl/app/_/deeplink?fdl_ios_" - "bundle_id=%@&fdl_ios_url_scheme=%@", - kBundleID, kCustomScheme]; + NSString *expectedURLString = [NSString stringWithFormat:@"https://goo.gl/app/_/deeplink?fdl_ios_" + "bundle_id=%@&fdl_ios_url_scheme=%@", + kBundleID, kCustomScheme]; NSURL *url = FIRDLCookieRetrievalURL(kCustomScheme, kBundleID); @@ -149,20 +148,19 @@ - (void)testDeepLinkURLWithInviteIDDeepLinkStringWeakMatchEndpointCreatesExpecte NSString *matchType = @"unique"; NSString *expectedURLString = - [NSString stringWithFormat: - @"%@://google/link/?utm_campaign=%@" - @"&deep_link_id=%@&utm_medium=%@&invitation_weakMatchEndpoint=%@" - @"&utm_source=%@&invitation_id=%@&match_type=%@", - kURLScheme, utmCampaign, encodedDeepLinkString, utmMedium, weakMatchEndpoint, - utmSource, inviteID, matchType]; + [NSString stringWithFormat:@"%@://google/link/?utm_campaign=%@" + @"&deep_link_id=%@&utm_medium=%@&invitation_weakMatchEndpoint=%@" + @"&utm_source=%@&invitation_id=%@&match_type=%@", + kURLScheme, utmCampaign, encodedDeepLinkString, utmMedium, + weakMatchEndpoint, utmSource, inviteID, matchType]; NSURLComponents *expectedURLComponents = [NSURLComponents componentsWithString:expectedURLString]; NSURL *actualURL = FIRDLDeepLinkURLWithInviteID(inviteID, deepLinkString, utmSource, utmMedium, utmCampaign, NO, weakMatchEndpoint, nil, kURLScheme, nil); - NSURLComponents *actualURLComponents = - [NSURLComponents componentsWithURL:actualURL resolvingAgainstBaseURL:NO]; + NSURLComponents *actualURLComponents = [NSURLComponents componentsWithURL:actualURL + resolvingAgainstBaseURL:NO]; // Since the parameters are not guaranteed to be in any specific order, we must compare // arrays of properties of the URLs rather than the URLs themselves. diff --git a/Example/Shared/FIRSampleAppUtilities.m b/Example/Shared/FIRSampleAppUtilities.m index d161cb99346..80ef2e1fc47 100644 --- a/Example/Shared/FIRSampleAppUtilities.m +++ b/Example/Shared/FIRSampleAppUtilities.m @@ -26,13 +26,12 @@ NSString *const kGithubRepoURLString = @"https://github.com/firebase/firebase-ios-sdk/"; // Alert contents NSString *const kInvalidPlistAlertTitle = @"GoogleService-Info.plist"; -NSString *const kInvalidPlistAlertMessage = - @"This sample app needs to be updated with a valid " - @"GoogleService-Info.plist file in order to configure " - @"Firebase.\n\n" - @"Please update the app with a valid plist file, " - @"following the instructions in the Firebase Github " - @"repository at: %@"; +NSString *const kInvalidPlistAlertMessage = @"This sample app needs to be updated with a valid " + @"GoogleService-Info.plist file in order to configure " + @"Firebase.\n\n" + @"Please update the app with a valid plist file, " + @"following the instructions in the Firebase Github " + @"repository at: %@"; @implementation FIRSampleAppUtilities @@ -52,8 +51,8 @@ + (BOOL)containsRealServiceInfoPlistInBundle:(NSBundle *)bundle { return NO; } - NSString *plistFilePath = - [bundle pathForResource:kServiceInfoFileName ofType:kServiceInfoFileType]; + NSString *plistFilePath = [bundle pathForResource:kServiceInfoFileName + ofType:kServiceInfoFileType]; if (!plistFilePath.length) { return NO; } @@ -91,8 +90,9 @@ + (void)presentAlertForInvalidServiceInfoPlistFromViewController: }]; [alertController addAction:viewReadmeAction]; - UIAlertAction *cancelAction = - [UIAlertAction actionWithTitle:@"Close" style:UIAlertActionStyleCancel handler:nil]; + UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"Close" + style:UIAlertActionStyleCancel + handler:nil]; [alertController addAction:cancelAction]; [viewController presentViewController:alertController animated:YES completion:nil]; diff --git a/Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m b/Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m index d16a95ead67..1374a05d2ab 100644 --- a/Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m +++ b/Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m @@ -69,8 +69,8 @@ - (void)setUp { XCTestExpectation *expectation = [self expectationWithDescription:@"setup"]; FIRStorageReference *ref = [[FIRStorage storage].reference child:@"ios/public/1mb"]; - NSData *data = [NSData - dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"1mb" ofType:@"dat"]]; + NSData *data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"1mb" + ofType:@"dat"]]; XCTAssertNotNil(data, "Could not load bundled file"); [ref putData:data metadata:nil diff --git a/Example/Storage/Tests/Unit/FIRStorageComponentTests.m b/Example/Storage/Tests/Unit/FIRStorageComponentTests.m index 7ce4b72f790..5f2c7d57811 100644 --- a/Example/Storage/Tests/Unit/FIRStorageComponentTests.m +++ b/Example/Storage/Tests/Unit/FIRStorageComponentTests.m @@ -64,8 +64,8 @@ - (void)testMultipleComponentInstancesCreated { // App isn't used in any of this, so a simple class mock works for simplicity. id app = OCMClassMock([FIRApp class]); NSMutableSet *registrants = [NSMutableSet setWithObject:[FIRStorageComponent class]]; - FIRComponentContainer *container = - [[FIRComponentContainer alloc] initWithApp:app registrants:registrants]; + FIRComponentContainer *container = [[FIRComponentContainer alloc] initWithApp:app + registrants:registrants]; id provider1 = FIR_COMPONENT(FIRStorageMultiBucketProvider, container); XCTAssertNotNil(provider1); @@ -84,8 +84,8 @@ - (void)testMultipleStorageInstancesCreated { // implementation. id app = [self appMockWithOptions]; NSMutableSet *registrants = [NSMutableSet setWithObject:[FIRStorageComponent class]]; - FIRComponentContainer *container = - [[FIRComponentContainer alloc] initWithApp:app registrants:registrants]; + FIRComponentContainer *container = [[FIRComponentContainer alloc] initWithApp:app + registrants:registrants]; id provider = FIR_COMPONENT(FIRStorageMultiBucketProvider, container); XCTAssertNotNil(provider); diff --git a/Example/Storage/Tests/Unit/FIRStorageTestHelpers.m b/Example/Storage/Tests/Unit/FIRStorageTestHelpers.m index 673afbfe18e..2b2f4c664df 100644 --- a/Example/Storage/Tests/Unit/FIRStorageTestHelpers.m +++ b/Example/Storage/Tests/Unit/FIRStorageTestHelpers.m @@ -45,8 +45,8 @@ + (FIRApp *)mockedApp { // correct contents. id app = OCMClassMock([FIRApp class]); NSMutableSet *registrants = [NSMutableSet setWithObject:[FIRStorageComponent class]]; - FIRComponentContainer *container = - [[FIRComponentContainer alloc] initWithApp:app registrants:registrants]; + FIRComponentContainer *container = [[FIRComponentContainer alloc] initWithApp:app + registrants:registrants]; OCMStub([app container]).andReturn(container); return app; } diff --git a/Example/Storage/Tests/Unit/FIRStorageTests.m b/Example/Storage/Tests/Unit/FIRStorageTests.m index 50df557f77f..93e4ead1427 100644 --- a/Example/Storage/Tests/Unit/FIRStorageTests.m +++ b/Example/Storage/Tests/Unit/FIRStorageTests.m @@ -57,8 +57,8 @@ - (void)testBucketNotEnforced { } - (void)testBucketEnforced { - FIRStorage *storage = - [FIRStorage storageForApp:self.app URL:@"gs://benwu-test1.storage.firebase.com"]; + FIRStorage *storage = [FIRStorage storageForApp:self.app + URL:@"gs://benwu-test1.storage.firebase.com"]; [storage referenceForURL:@"gs://benwu-test1.storage.firebase.com/child"]; storage = [FIRStorage storageForApp:self.app URL:@"gs://benwu-test1.storage.firebase.com/"]; [storage referenceForURL:@"gs://benwu-test1.storage.firebase.com/child"]; diff --git a/Example/Storage/Tests/Unit/FIRStorageTokenAuthorizerTests.m b/Example/Storage/Tests/Unit/FIRStorageTokenAuthorizerTests.m index bfe6e72712e..d538ad20967 100644 --- a/Example/Storage/Tests/Unit/FIRStorageTokenAuthorizerTests.m +++ b/Example/Storage/Tests/Unit/FIRStorageTokenAuthorizerTests.m @@ -32,8 +32,9 @@ - (void)setUp { self.fetcher = [GTMSessionFetcher fetcherWithRequest:fetchRequest]; GTMSessionFetcherService *fetcherService = [[GTMSessionFetcherService alloc] init]; - FIRAuthInteropFake *auth = - [[FIRAuthInteropFake alloc] initWithToken:kFIRStorageTestAuthToken userID:nil error:nil]; + FIRAuthInteropFake *auth = [[FIRAuthInteropFake alloc] initWithToken:kFIRStorageTestAuthToken + userID:nil + error:nil]; self.fetcher.authorizer = [[FIRStorageTokenAuthorizer alloc] initWithGoogleAppID:@"dummyAppID" fetcherService:fetcherService authProvider:auth]; @@ -78,8 +79,9 @@ - (void)testUnsuccessfulAuth { NSError *authError = [NSError errorWithDomain:FIRStorageErrorDomain code:FIRStorageErrorCodeUnauthenticated userInfo:nil]; - FIRAuthInteropFake *failedAuth = - [[FIRAuthInteropFake alloc] initWithToken:nil userID:nil error:authError]; + FIRAuthInteropFake *failedAuth = [[FIRAuthInteropFake alloc] initWithToken:nil + userID:nil + error:authError]; GTMSessionFetcherService *fetcherService = [[GTMSessionFetcherService alloc] init]; self.fetcher.authorizer = [[FIRStorageTokenAuthorizer alloc] initWithGoogleAppID:@"dummyAppID" fetcherService:fetcherService diff --git a/Firebase/Core/FIRApp.m b/Firebase/Core/FIRApp.m index 82f9832132f..799db26f5c8 100644 --- a/Firebase/Core/FIRApp.m +++ b/Firebase/Core/FIRApp.m @@ -117,11 +117,10 @@ + (void)configure { } [NSException raise:kFirebaseCoreErrorDomain - format: - @"`[FIRApp configure];` (`FirebaseApp.configure()` in Swift) could not find " - @"a valid GoogleService-Info.plist in your project. Please download one " - @"from %@.", - kPlistURL]; + format:@"`[FIRApp configure];` (`FirebaseApp.configure()` in Swift) could not find " + @"a valid GoogleService-Info.plist in your project. Please download one " + @"from %@.", + kPlistURL]; } [FIRApp configureWithOptions:options]; #if TARGET_OS_OSX || TARGET_OS_TV @@ -162,9 +161,8 @@ + (void)configureWithName:(NSString *)name options:(FIROptions *)options { if (!((character >= 'a' && character <= 'z') || (character >= 'A' && character <= 'Z') || (character >= '0' && character <= '9') || character == '_' || character == '-')) { [NSException raise:kFirebaseCoreErrorDomain - format: - @"App name should only contain Letters, " - @"Numbers, Underscores, and Dashes."]; + format:@"App name should only contain Letters, " + @"Numbers, Underscores, and Dashes."]; } } @@ -263,9 +261,8 @@ + (void)addAppToAppDictionary:(FIRApp *)app { sAllApps[app.name] = app; } else { [NSException raise:kFirebaseCoreErrorDomain - format: - @"Configuration fails. It may be caused by an invalid GOOGLE_APP_ID in " - @"GoogleService-Info.plist or set in the customized options."]; + format:@"Configuration fails. It may be caused by an invalid GOOGLE_APP_ID in " + @"GoogleService-Info.plist or set in the customized options."]; } } @@ -496,10 +493,9 @@ + (void)registerInternalLibrary:(nonnull Class)library if (![(Class)library conformsToProtocol:@protocol(FIRLibrary)] || ![(Class)library respondsToSelector:@selector(componentsToRegister)]) { [NSException raise:NSInvalidArgumentException - format: - @"Class %@ attempted to register components, but it does not conform to " - @"`FIRLibrary or provide a `componentsToRegister:` method.", - library]; + format:@"Class %@ attempted to register components, but it does not conform to " + @"`FIRLibrary or provide a `componentsToRegister:` method.", + library]; } [FIRComponentContainer registerAsComponentRegistrant:library]; @@ -529,8 +525,8 @@ - (void)checkExpectedBundleID { NSString *expectedBundleID = [self expectedBundleID]; // The checking is only done when the bundle ID is provided in the serviceInfo dictionary for // backward compatibility. - if (expectedBundleID != nil && - ![FIRBundleUtil hasBundleIdentifier:expectedBundleID inBundles:bundles]) { + if (expectedBundleID != nil && ![FIRBundleUtil hasBundleIdentifier:expectedBundleID + inBundles:bundles]) { FIRLogError(kFIRLoggerCore, @"I-COR000008", @"The project's Bundle ID is inconsistent with " @"either the Bundle ID in '%@.%@', or the Bundle ID in the options if you are " @@ -640,8 +636,9 @@ + (BOOL)validateAppIDFormat:(NSString *)appID withVersion:(NSString *)version { } NSString *const pattern = @"^\\d+:ios:[a-f0-9]+$"; - NSRegularExpression *regex = - [NSRegularExpression regularExpressionWithPattern:pattern options:0 error:NULL]; + NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern:pattern + options:0 + error:NULL]; if (!regex) { return NO; } diff --git a/Firebase/Core/FIROptions.m b/Firebase/Core/FIROptions.m index fe708514be6..d23f816846b 100644 --- a/Firebase/Core/FIROptions.m +++ b/Firebase/Core/FIROptions.m @@ -40,11 +40,10 @@ NSString *const kFIRIsSignInEnabled = @"IS_SIGNIN_ENABLED"; // Library version ID. -NSString *const kFIRLibraryVersionID = - @"5" // Major version (one or more digits) - @"01" // Minor version (exactly 2 digits) - @"10" // Build number (exactly 2 digits) - @"000"; // Fixed "000" +NSString *const kFIRLibraryVersionID = @"5" // Major version (one or more digits) + @"01" // Minor version (exactly 2 digits) + @"10" // Build number (exactly 2 digits) + @"000"; // Fixed "000" // Plist file name. NSString *const kServiceInfoFileName = @"GoogleService-Info"; // Plist file type. diff --git a/Firebase/DynamicLinks/FDLURLComponents/FDLURLComponents.m b/Firebase/DynamicLinks/FDLURLComponents/FDLURLComponents.m index 5b200bf9397..5b7cf853777 100644 --- a/Firebase/DynamicLinks/FDLURLComponents/FDLURLComponents.m +++ b/Firebase/DynamicLinks/FDLURLComponents/FDLURLComponents.m @@ -512,8 +512,9 @@ + (void)shortenURL:(NSURL *)url } NSURLRequest *request = [self shorteningRequestForLongURL:url options:options]; if (!request) { - NSError *error = - [NSError errorWithDomain:kFirebaseDurableDeepLinkErrorDomain code:0 userInfo:nil]; + NSError *error = [NSError errorWithDomain:kFirebaseDurableDeepLinkErrorDomain + code:0 + userInfo:nil]; completion(nil, nil, error); return; } diff --git a/Firebase/DynamicLinks/FIRDLDefaultRetrievalProcessV2.m b/Firebase/DynamicLinks/FIRDLDefaultRetrievalProcessV2.m index efdd51fcc8a..12b70a652cd 100644 --- a/Firebase/DynamicLinks/FIRDLDefaultRetrievalProcessV2.m +++ b/Firebase/DynamicLinks/FIRDLDefaultRetrievalProcessV2.m @@ -309,11 +309,10 @@ - (void)fetchLocaleFromWebView { if (_jsExecutor) { return; } - NSString *jsString = - @"window.generateFingerprint=function(){try{var " - @"languageCode=navigator.languages?navigator.languages[0]:navigator." - @"language;return languageCode;}catch(b){return" - "}};"; + NSString *jsString = @"window.generateFingerprint=function(){try{var " + @"languageCode=navigator.languages?navigator.languages[0]:navigator." + @"language;return languageCode;}catch(b){return" + "}};"; _jsExecutor = [[FIRDLJavaScriptExecutor alloc] initWithDelegate:self script:jsString]; } diff --git a/Firebase/DynamicLinks/FIRDynamicLink.m b/Firebase/DynamicLinks/FIRDynamicLink.m index 9c9b063c9e8..cbe2e23d973 100644 --- a/Firebase/DynamicLinks/FIRDynamicLink.m +++ b/Firebase/DynamicLinks/FIRDynamicLink.m @@ -21,12 +21,11 @@ @implementation FIRDynamicLink - (NSString *)description { - return [NSString stringWithFormat: - @"<%@: %p, url [%@], match type: %@, minimumAppVersion: %@, " - "match message: %@>", - NSStringFromClass([self class]), self, self.url, - [[self class] stringWithMatchType:_matchType], - self.minimumAppVersion ?: @"N/A", self.matchMessage]; + return [NSString stringWithFormat:@"<%@: %p, url [%@], match type: %@, minimumAppVersion: %@, " + "match message: %@>", + NSStringFromClass([self class]), self, self.url, + [[self class] stringWithMatchType:_matchType], + self.minimumAppVersion ?: @"N/A", self.matchMessage]; } - (instancetype)initWithParametersDictionary:(NSDictionary *)parameters { diff --git a/Firebase/DynamicLinks/FIRDynamicLinkNetworking.m b/Firebase/DynamicLinks/FIRDynamicLinkNetworking.m index 4c7b9125f58..cbd99f51545 100644 --- a/Firebase/DynamicLinks/FIRDynamicLinkNetworking.m +++ b/Firebase/DynamicLinks/FIRDynamicLinkNetworking.m @@ -193,8 +193,9 @@ - (void)retrievePendingDynamicLinkWithIOSVersion:(NSString *)IOSVersion FIRDLNetworkingParserBlock responseParserBlock = ^NSDictionary *_Nullable( NSString *requestURLString, NSData *data, NSString **matchMessagePtr, NSError **errorPtr) { NSError *serializationError; - NSDictionary *result = - [NSJSONSerialization JSONObjectWithData:data options:0 error:&serializationError]; + NSDictionary *result = [NSJSONSerialization JSONObjectWithData:data + options:0 + error:&serializationError]; if (serializationError) { *errorPtr = serializationError; diff --git a/Firebase/DynamicLinks/FIRDynamicLinks+FirstParty.h b/Firebase/DynamicLinks/FIRDynamicLinks+FirstParty.h index 8b255b5c10b..b450733cf87 100644 --- a/Firebase/DynamicLinks/FIRDynamicLinks+FirstParty.h +++ b/Firebase/DynamicLinks/FIRDynamicLinks+FirstParty.h @@ -96,9 +96,8 @@ NS_ASSUME_NONNULL_BEGIN * @abstract Method for compatibility with old interface of the GINDurableDeepLinkService */ - (BOOL)shouldHandleDeepLinkFromCustomSchemeURL:(NSURL *)url - DEPRECATED_MSG_ATTRIBUTE( - "Use [FIRDynamicLinks shouldHandleDynamicLinkFromCustomSchemeURL:]" - " instead."); + DEPRECATED_MSG_ATTRIBUTE("Use [FIRDynamicLinks shouldHandleDynamicLinkFromCustomSchemeURL:]" + " instead."); @end diff --git a/Firebase/DynamicLinks/FIRDynamicLinks.m b/Firebase/DynamicLinks/FIRDynamicLinks.m index 681c461a5d0..9734441a2df 100644 --- a/Firebase/DynamicLinks/FIRDynamicLinks.m +++ b/Firebase/DynamicLinks/FIRDynamicLinks.m @@ -40,8 +40,7 @@ #import "DynamicLinks/Utilities/FDLUtilities.h" #ifndef FIRDynamicLinks_VERSION -#error \ - "FIRDynamicLinks_VERSION is not defined: add -DFIRDynamicLinks_VERSION=... to the build \ +#error "FIRDynamicLinks_VERSION is not defined: add -DFIRDynamicLinks_VERSION=... to the build \ invocation" #endif @@ -120,8 +119,8 @@ + (void)load { + (nonnull NSArray *)componentsToRegister { // Product requirement is enforced by CocoaPod. Not technical requirement for analytics. - FIRDependency *analyticsDep = - [FIRDependency dependencyWithProtocol:@protocol(FIRAnalyticsInterop) isRequired:NO]; + FIRDependency *analyticsDep = [FIRDependency dependencyWithProtocol:@protocol(FIRAnalyticsInterop) + isRequired:NO]; FIRComponentCreationBlock creationBlock = ^id _Nullable(FIRComponentContainer *container, BOOL *isCacheable) { // Ensure it's cached so it returns the same instance every time dynamicLinks is called. @@ -577,8 +576,9 @@ + (NSString *)diagnosticAnalyzeEntitlements { stringByAppendingPathComponent:@"embedded.mobileprovision"]; NSError *error; - NSMutableData *profileData = - [NSMutableData dataWithContentsOfFile:embeddedMobileprovisionFilePath options:0 error:&error]; + NSMutableData *profileData = [NSMutableData dataWithContentsOfFile:embeddedMobileprovisionFilePath + options:0 + error:&error]; if (!profileData.length || error) { return @"\tSKIPPED: Not able to read entitlements (embedded.mobileprovision).\n"; @@ -669,21 +669,20 @@ + (NSString *)performDiagnosticsIncludingHeaderFooter:(BOOL)includingHeaderFoote #if TARGET_IPHONE_SIMULATOR // check is Simulator and print WARNING that Universal Links is not supported on Simulator - [diagnosticString appendString: - @"WARNING: iOS Simulator does not support Universal Links. Firebase " - @"Dynamic Links SDK functionality will be limited. Some FDL " - @"features may be missing or will not work correctly.\n"]; + [diagnosticString + appendString:@"WARNING: iOS Simulator does not support Universal Links. Firebase " + @"Dynamic Links SDK functionality will be limited. Some FDL " + @"features may be missing or will not work correctly.\n"]; #endif // TARGET_IPHONE_SIMULATOR id applicationDelegate = [UIApplication sharedApplication].delegate; if (![applicationDelegate respondsToSelector:@selector(application:openURL:options:)]) { detectedErrorsCnt++; - [diagnosticString appendFormat: - @"ERROR: UIApplication delegate %@ does not implements selector " - @"%@. FDL depends on this implementation to retrieve pending " - @"dynamic link.\n", - applicationDelegate, - NSStringFromSelector(@selector(application:openURL:options:))]; + [diagnosticString appendFormat:@"ERROR: UIApplication delegate %@ does not implements selector " + @"%@. FDL depends on this implementation to retrieve pending " + @"dynamic link.\n", + applicationDelegate, + NSStringFromSelector(@selector(application:openURL:options:))]; } // check that Info.plist has custom URL scheme and the scheme is the same as bundleID or @@ -705,16 +704,14 @@ + (NSString *)performDiagnosticsIncludingHeaderFooter:(BOOL)includingHeaderFoote } if (!URLSchemeFoundInPlist) { detectedErrorsCnt++; - [diagnosticString appendFormat: - @"ERROR: Specified custom URL scheme is %@ but Info.plist do " - @"not contain such scheme in " - "CFBundleURLTypes key.\n", - URLScheme]; + [diagnosticString appendFormat:@"ERROR: Specified custom URL scheme is %@ but Info.plist do " + @"not contain such scheme in " + "CFBundleURLTypes key.\n", + URLScheme]; } else { - [diagnosticString appendFormat: - @"\tSpecified custom URL scheme is %@ and Info.plist contains " - @"such scheme in CFBundleURLTypes key.\n", - URLScheme]; + [diagnosticString appendFormat:@"\tSpecified custom URL scheme is %@ and Info.plist contains " + @"such scheme in CFBundleURLTypes key.\n", + URLScheme]; } #if !TARGET_IPHONE_SIMULATOR @@ -745,8 +742,8 @@ + (void)performDiagnosticsWithCompletion:(void (^_Nullable)(NSString *diagnostic BOOL hasErrors))completionHandler; { NSInteger detectedErrorsCnt = 0; - NSString *diagnosticString = - [self performDiagnosticsIncludingHeaderFooter:YES detectedErrors:&detectedErrorsCnt]; + NSString *diagnosticString = [self performDiagnosticsIncludingHeaderFooter:YES + detectedErrors:&detectedErrorsCnt]; if (completionHandler) { completionHandler(diagnosticString, detectedErrorsCnt > 0); } else { diff --git a/Firebase/DynamicLinks/Utilities/FDLUtilities.m b/Firebase/DynamicLinks/Utilities/FDLUtilities.m index 5ded3c42d84..fdc781fea0e 100644 --- a/Firebase/DynamicLinks/Utilities/FDLUtilities.m +++ b/Firebase/DynamicLinks/Utilities/FDLUtilities.m @@ -44,10 +44,10 @@ components.path = @"/app/_/deeplink"; NSMutableArray *queryItems = [NSMutableArray array]; - [queryItems - addObject:[NSURLQueryItem queryItemWithName:kFDLBundleIDQueryParameterName value:bundleID]]; - [queryItems - addObject:[NSURLQueryItem queryItemWithName:kFDLURLSchemeQueryParameterName value:urlScheme]]; + [queryItems addObject:[NSURLQueryItem queryItemWithName:kFDLBundleIDQueryParameterName + value:bundleID]]; + [queryItems addObject:[NSURLQueryItem queryItemWithName:kFDLURLSchemeQueryParameterName + value:urlScheme]]; [components setQueryItems:queryItems]; return [components URL]; diff --git a/Firebase/InAppMessagingDisplay/Banner/FIDBannerViewController.m b/Firebase/InAppMessagingDisplay/Banner/FIDBannerViewController.m index 6f242ffb3c9..511f7dff694 100644 --- a/Firebase/InAppMessagingDisplay/Banner/FIDBannerViewController.m +++ b/Firebase/InAppMessagingDisplay/Banner/FIDBannerViewController.m @@ -67,8 +67,8 @@ @implementation FIDBannerViewController displayDelegate: (id)displayDelegate timeFetcher:(id)timeFetcher { - UIStoryboard *storyboard = - [UIStoryboard storyboardWithName:@"FIRInAppMessageDisplayStoryboard" bundle:resourceBundle]; + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"FIRInAppMessageDisplayStoryboard" + bundle:resourceBundle]; if (storyboard == nil) { FIRLogError(kFIRLoggerInAppMessagingDisplay, @"I-FID300002", diff --git a/Firebase/InAppMessagingDisplay/FIRIAMDefaultDisplayImpl.m b/Firebase/InAppMessagingDisplay/FIRIAMDefaultDisplayImpl.m index c8dbbae7a70..cf8005f755f 100644 --- a/Firebase/InAppMessagingDisplay/FIRIAMDefaultDisplayImpl.m +++ b/Firebase/InAppMessagingDisplay/FIRIAMDefaultDisplayImpl.m @@ -55,8 +55,8 @@ + (NSBundle *)getViewResourceBundle { // sourced NSBundle *containingBundle = [NSBundle mainBundle]; // This is assuming the display resource bundle is contained in the main bundle - NSURL *bundleURL = - [containingBundle URLForResource:@"InAppMessagingDisplayResources" withExtension:@"bundle"]; + NSURL *bundleURL = [containingBundle URLForResource:@"InAppMessagingDisplayResources" + withExtension:@"bundle"]; resourceBundle = [NSBundle bundleWithURL:bundleURL]; if (resourceBundle == nil) { diff --git a/Firebase/InAppMessagingDisplay/ImageOnly/FIDImageOnlyViewController.m b/Firebase/InAppMessagingDisplay/ImageOnly/FIDImageOnlyViewController.m index be6ec28444f..c395f5a0d19 100644 --- a/Firebase/InAppMessagingDisplay/ImageOnly/FIDImageOnlyViewController.m +++ b/Firebase/InAppMessagingDisplay/ImageOnly/FIDImageOnlyViewController.m @@ -37,8 +37,8 @@ @implementation FIDImageOnlyViewController displayDelegate: (id)displayDelegate timeFetcher:(id)timeFetcher { - UIStoryboard *storyboard = - [UIStoryboard storyboardWithName:@"FIRInAppMessageDisplayStoryboard" bundle:resourceBundle]; + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"FIRInAppMessageDisplayStoryboard" + bundle:resourceBundle]; if (storyboard == nil) { FIRLogError(kFIRLoggerInAppMessagingDisplay, @"I-FID300002", diff --git a/Firebase/InAppMessagingDisplay/Modal/FIDModalViewController.m b/Firebase/InAppMessagingDisplay/Modal/FIDModalViewController.m index d8d0e9f2bcf..8e31910c0e1 100644 --- a/Firebase/InAppMessagingDisplay/Modal/FIDModalViewController.m +++ b/Firebase/InAppMessagingDisplay/Modal/FIDModalViewController.m @@ -76,8 +76,8 @@ @implementation FIDModalViewController displayDelegate: (id)displayDelegate timeFetcher:(id)timeFetcher { - UIStoryboard *storyboard = - [UIStoryboard storyboardWithName:@"FIRInAppMessageDisplayStoryboard" bundle:resourceBundle]; + UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"FIRInAppMessageDisplayStoryboard" + bundle:resourceBundle]; if (storyboard == nil) { FIRLogError(kFIRLoggerInAppMessagingDisplay, @"I-FID300001", @@ -183,12 +183,12 @@ - (struct TitleBodyButtonHeightInfo)estimateTextBtnColumnHeightWithDisplayWidth: withMaxColumnHeight:(CGFloat)maxHeight { struct TitleBodyButtonHeightInfo resultHeightInfo; - CGFloat titleFitHeight = - [self determineTextAreaViewFitHeightForView:self.titleLabel withWidth:displayWidth]; - CGFloat bodyFitHeight = - self.modalDisplayMessage.bodyText.length == 0 - ? 0 - : [self determineTextAreaViewFitHeightForView:self.bodyTextView withWidth:displayWidth]; + CGFloat titleFitHeight = [self determineTextAreaViewFitHeightForView:self.titleLabel + withWidth:displayWidth]; + CGFloat bodyFitHeight = self.modalDisplayMessage.bodyText.length == 0 + ? 0 + : [self determineTextAreaViewFitHeightForView:self.bodyTextView + withWidth:displayWidth]; CGFloat bodyFitHeightWithPadding = self.modalDisplayMessage.bodyText.length == 0 ? 0 @@ -291,8 +291,8 @@ - (void)layoutFineTuneInPortraitMode { heightCalcReference - heights.totaColumnlHeight - self.imageTopToTitleBottomInPortraitMode.constant); - CGSize imageDisplaySize = - [self fitImageInRegionSize:imageAvailableSpace withImageSize:image.size]; + CGSize imageDisplaySize = [self fitImageInRegionSize:imageAvailableSpace + withImageSize:image.size]; FIRLogDebug(kFIRLoggerInAppMessagingDisplay, @"I-FID300005", @"Given actual image size %@ and available image display size %@, the actual" diff --git a/Firebase/Storage/FIRStorage.m b/Firebase/Storage/FIRStorage.m index 82dcbfa4da4..ff9ac2beb74 100644 --- a/Firebase/Storage/FIRStorage.m +++ b/Firebase/Storage/FIRStorage.m @@ -161,8 +161,9 @@ - (instancetype)initWithApp:(FIRApp *)app #pragma mark - NSObject overrides - (instancetype)copyWithZone:(NSZone *)zone { - FIRStorage *storage = - [[[self class] allocWithZone:zone] initWithApp:_app bucket:_storageBucket auth:_auth]; + FIRStorage *storage = [[[self class] allocWithZone:zone] initWithApp:_app + bucket:_storageBucket + auth:_auth]; storage.callbackQueue = _callbackQueue; return storage; } diff --git a/Firebase/Storage/FIRStorageComponent.m b/Firebase/Storage/FIRStorageComponent.m index 8e9770e5bde..79d3d3fc954 100644 --- a/Firebase/Storage/FIRStorageComponent.m +++ b/Firebase/Storage/FIRStorageComponent.m @@ -60,8 +60,8 @@ + (void)load { #pragma mark - FIRComponentRegistrant + (nonnull NSArray *)componentsToRegister { - FIRDependency *authDep = - [FIRDependency dependencyWithProtocol:@protocol(FIRAuthInterop) isRequired:NO]; + FIRDependency *authDep = [FIRDependency dependencyWithProtocol:@protocol(FIRAuthInterop) + isRequired:NO]; FIRComponentCreationBlock creationBlock = ^id _Nullable(FIRComponentContainer *container, BOOL *isCacheable) { return [[FIRStorageComponent alloc] initWithApp:container.app]; diff --git a/Firebase/Storage/FIRStorageDownloadTask.m b/Firebase/Storage/FIRStorageDownloadTask.m index 0752df73538..c7b7f9ae7ff 100644 --- a/Firebase/Storage/FIRStorageDownloadTask.m +++ b/Firebase/Storage/FIRStorageDownloadTask.m @@ -59,8 +59,8 @@ - (void)enqueueWithData:(nullable NSData *)resumeData { NSMutableURLRequest *request = [strongSelf.baseRequest mutableCopy]; request.HTTPMethod = @"GET"; request.timeoutInterval = strongSelf.reference.storage.maxDownloadRetryTime; - NSURLComponents *components = - [NSURLComponents componentsWithURL:request.URL resolvingAgainstBaseURL:NO]; + NSURLComponents *components = [NSURLComponents componentsWithURL:request.URL + resolvingAgainstBaseURL:NO]; [components setQuery:@"alt=media"]; request.URL = components.URL; diff --git a/Firebase/Storage/FIRStorageErrors.m b/Firebase/Storage/FIRStorageErrors.m index 651bfd12d94..ea1fa96be9a 100644 --- a/Firebase/Storage/FIRStorageErrors.m +++ b/Firebase/Storage/FIRStorageErrors.m @@ -72,9 +72,8 @@ + (NSError *)errorWithCode:(FIRStorageErrorCode)code } case FIRStorageErrorCodeUnauthenticated: - errorMessage = - @"User is not authenticated, please authenticate using Firebase " - @"Authentication and try again."; + errorMessage = @"User is not authenticated, please authenticate using Firebase " + @"Authentication and try again."; break; case FIRStorageErrorCodeUnauthorized: { @@ -158,8 +157,8 @@ + (nullable NSError *)errorWithServerError:(nullable NSError *)error // Turn raw response into a string NSData *responseData = errorDictionary[@"data"]; if (responseData) { - NSString *errorString = - [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding]; + NSString *errorString = [[NSString alloc] initWithData:responseData + encoding:NSUTF8StringEncoding]; errorDictionary[kFIRStorageResponseBody] = errorString ?: @"No Response from Server."; } diff --git a/Firebase/Storage/FIRStorageGetDownloadURLTask.m b/Firebase/Storage/FIRStorageGetDownloadURLTask.m index f5f7a7ad382..944603f8eb7 100644 --- a/Firebase/Storage/FIRStorageGetDownloadURLTask.m +++ b/Firebase/Storage/FIRStorageGetDownloadURLTask.m @@ -57,8 +57,8 @@ + (NSURL *)downloadURLFromMetadataDictionary:(NSDictionary *)dictionary { // The backend can return an arbitrary number of download tokens, but we only expose the first // token via the download URL. NSURLQueryItem *altItem = [[NSURLQueryItem alloc] initWithName:@"alt" value:@"media"]; - NSURLQueryItem *tokenItem = - [[NSURLQueryItem alloc] initWithName:@"token" value:downloadTokenArray[0]]; + NSURLQueryItem *tokenItem = [[NSURLQueryItem alloc] initWithName:@"token" + value:downloadTokenArray[0]]; components.queryItems = @[ altItem, tokenItem ]; return [components URL]; diff --git a/Firebase/Storage/FIRStoragePath.m b/Firebase/Storage/FIRStoragePath.m index aa7f1305037..04a52bce5a0 100644 --- a/Firebase/Storage/FIRStoragePath.m +++ b/Firebase/Storage/FIRStoragePath.m @@ -74,10 +74,9 @@ + (nullable FIRStoragePath *)pathFromHTTPURL:(NSString *)aURLString { if (bucketName.length == 0) { [NSException raise:NSInternalInconsistencyException - format: - @"URL must be in the form of " - @"http[s]://firebasestorage.googleapis.com/v0/b//o/[?token=signed_url_params]"]; + format:@"URL must be in the form of " + @"http[s]://firebasestorage.googleapis.com/v0/b//o/[?token=signed_url_params]"]; return nil; } diff --git a/Firebase/Storage/FIRStorageReference.m b/Firebase/Storage/FIRStorageReference.m index 99f00992473..78c9dc64dee 100644 --- a/Firebase/Storage/FIRStorageReference.m +++ b/Firebase/Storage/FIRStorageReference.m @@ -57,8 +57,8 @@ - (instancetype)initWithStorage:(FIRStorage *)storage path:(FIRStoragePath *)pat #pragma mark - NSObject overrides - (instancetype)copyWithZone:(NSZone *)zone { - FIRStorageReference *copiedReference = - [[[self class] allocWithZone:zone] initWithStorage:_storage path:_path]; + FIRStorageReference *copiedReference = [[[self class] allocWithZone:zone] initWithStorage:_storage + path:_path]; return copiedReference; } @@ -121,8 +121,8 @@ - (NSString *)name { - (FIRStorageReference *)root { FIRStoragePath *rootPath = [_path root]; - FIRStorageReference *rootReference = - [[FIRStorageReference alloc] initWithStorage:_storage path:rootPath]; + FIRStorageReference *rootReference = [[FIRStorageReference alloc] initWithStorage:_storage + path:rootPath]; return rootReference; } @@ -132,15 +132,15 @@ - (nullable FIRStorageReference *)parent { return nil; } - FIRStorageReference *parentReference = - [[FIRStorageReference alloc] initWithStorage:_storage path:parentPath]; + FIRStorageReference *parentReference = [[FIRStorageReference alloc] initWithStorage:_storage + path:parentPath]; return parentReference; } - (FIRStorageReference *)child:(NSString *)path { FIRStoragePath *childPath = [_path child:path]; - FIRStorageReference *childReference = - [[FIRStorageReference alloc] initWithStorage:_storage path:childPath]; + FIRStorageReference *childReference = [[FIRStorageReference alloc] initWithStorage:_storage + path:childPath]; return childReference; } diff --git a/Firebase/Storage/FIRStorageUploadTask.m b/Firebase/Storage/FIRStorageUploadTask.m index 8c299e79edc..0324974a52f 100644 --- a/Firebase/Storage/FIRStorageUploadTask.m +++ b/Firebase/Storage/FIRStorageUploadTask.m @@ -92,8 +92,8 @@ - (void)enqueue { [NSString stringWithFormat:@"%zu", (unsigned long)[bodyData length]]; [request setValue:contentLengthString forHTTPHeaderField:@"Content-Length"]; - NSURLComponents *components = - [NSURLComponents componentsWithURL:request.URL resolvingAgainstBaseURL:NO]; + NSURLComponents *components = [NSURLComponents componentsWithURL:request.URL + resolvingAgainstBaseURL:NO]; if ([components.host isEqual:kGCSHost]) { [components setPercentEncodedPath:[@"/upload" stringByAppendingString:components.path]]; diff --git a/Firestore/Example/FuzzTests/FuzzingTargets/FSTFuzzTestFieldPath.mm b/Firestore/Example/FuzzTests/FuzzingTargets/FSTFuzzTestFieldPath.mm index 38bf4f15935..8420ed59206 100644 --- a/Firestore/Example/FuzzTests/FuzzingTargets/FSTFuzzTestFieldPath.mm +++ b/Firestore/Example/FuzzTests/FuzzingTargets/FSTFuzzTestFieldPath.mm @@ -65,8 +65,9 @@ int FuzzTestFieldPath(const uint8_t *data, size_t size) { // Try to parse the bytes as a string array and use it for initialization. // NSJSONReadingMutableContainers specifies that arrays and dictionaries are // created as mutable objects. Returns nil if there is a parsing error. - NSArray *str_arr3 = - [NSJSONSerialization JSONObjectWithData:d options:NSJSONReadingMutableContainers error:nil]; + NSArray *str_arr3 = [NSJSONSerialization JSONObjectWithData:d + options:NSJSONReadingMutableContainers + error:nil]; NSMutableArray *mutable_array = [[NSMutableArray alloc] initWithArray:str_arr3]; if (str_arr3) { for (int i = 0; i < str_arr3.count; ++i) { diff --git a/Firestore/Example/Tests/API/FIRFirestoreTests.mm b/Firestore/Example/Tests/API/FIRFirestoreTests.mm index 7cb49b72d7c..dbe7f9a2c77 100644 --- a/Firestore/Example/Tests/API/FIRFirestoreTests.mm +++ b/Firestore/Example/Tests/API/FIRFirestoreTests.mm @@ -42,9 +42,8 @@ - (void)testDeleteApp { XCTAssertEqualObjects(firestore, [FIRFirestore firestoreForApp:app]); XCTestExpectation *defaultAppDeletedExpectation = - [self expectationWithDescription: - @"Deleting the default app should invalidate the default " - @"Firestore instance."]; + [self expectationWithDescription:@"Deleting the default app should invalidate the default " + @"Firestore instance."]; [app deleteApp:^(BOOL success) { // Recreate the FIRApp with the same name, fetch a new Firestore instance and make sure it's // different than the other one. diff --git a/Firestore/Example/Tests/API/FIRQuerySnapshotTests.mm b/Firestore/Example/Tests/API/FIRQuerySnapshotTests.mm index 27ad8b3770b..1a8e716926a 100644 --- a/Firestore/Example/Tests/API/FIRQuerySnapshotTests.mm +++ b/Firestore/Example/Tests/API/FIRQuerySnapshotTests.mm @@ -52,12 +52,12 @@ @implementation FIRQuerySnapshotTests - (void)testEquals { FIRQuerySnapshot *foo = FSTTestQuerySnapshot("foo", @{}, @{@"a" : @{@"a" : @1}}, YES, NO); FIRQuerySnapshot *fooDup = FSTTestQuerySnapshot("foo", @{}, @{@"a" : @{@"a" : @1}}, YES, NO); - FIRQuerySnapshot *differentPath = FSTTestQuerySnapshot("bar", @{}, - @{@"a" : @{@"a" : @1}}, YES, NO); - FIRQuerySnapshot *differentDoc = FSTTestQuerySnapshot("foo", - @{@"a" : @{@"b" : @1}}, @{}, YES, NO); - FIRQuerySnapshot *noPendingWrites = FSTTestQuerySnapshot("foo", @{}, - @{@"a" : @{@"a" : @1}}, NO, NO); + FIRQuerySnapshot *differentPath = + FSTTestQuerySnapshot("bar", @{}, @{@"a" : @{@"a" : @1}}, YES, NO); + FIRQuerySnapshot *differentDoc = + FSTTestQuerySnapshot("foo", @{@"a" : @{@"b" : @1}}, @{}, YES, NO); + FIRQuerySnapshot *noPendingWrites = + FSTTestQuerySnapshot("foo", @{}, @{@"a" : @{@"a" : @1}}, NO, NO); FIRQuerySnapshot *fromCache = FSTTestQuerySnapshot("foo", @{}, @{@"a" : @{@"a" : @1}}, YES, YES); XCTAssertEqualObjects(foo, fooDup); XCTAssertNotEqualObjects(foo, differentPath); @@ -96,8 +96,8 @@ - (void)testIncludeMetadataChanges { mutatedKeys:DocumentKeySet {} syncStateChanged:YES excludesMetadataChanges:NO]; - FIRSnapshotMetadata *metadata = - [FIRSnapshotMetadata snapshotMetadataWithPendingWrites:NO fromCache:NO]; + FIRSnapshotMetadata *metadata = [FIRSnapshotMetadata snapshotMetadataWithPendingWrites:NO + fromCache:NO]; FIRQuerySnapshot *snapshot = [FIRQuerySnapshot snapshotWithFirestore:firestore originalQuery:query snapshot:viewSnapshot diff --git a/Firestore/Example/Tests/API/FIRQueryTests.mm b/Firestore/Example/Tests/API/FIRQueryTests.mm index c02c92c5e88..60c213e6cb2 100644 --- a/Firestore/Example/Tests/API/FIRQueryTests.mm +++ b/Firestore/Example/Tests/API/FIRQueryTests.mm @@ -55,16 +55,15 @@ - (void)testFilteringWithPredicate { FIRQuery *query = [FIRQuery referenceWithQuery:FSTTestQuery("foo") firestore:firestore]; FIRQuery *query1 = [query queryWhereField:@"f" isLessThanOrEqualTo:@1]; FIRQuery *query2 = [query queryFilteredUsingPredicate:[NSPredicate predicateWithFormat:@"f<=1"]]; - FIRQuery *query3 = - [[query queryWhereField:@"f1" isLessThan:@2] queryWhereField:@"f2" isEqualTo:@3]; + FIRQuery *query3 = [[query queryWhereField:@"f1" isLessThan:@2] queryWhereField:@"f2" + isEqualTo:@3]; FIRQuery *query4 = [query queryFilteredUsingPredicate:[NSPredicate predicateWithFormat:@"f1<2 && f2==3"]]; - FIRQuery *query5 = - [[[[[query queryWhereField:@"f1" isLessThan:@2] queryWhereField:@"f2" isEqualTo:@3] - queryWhereField:@"f1" - isLessThanOrEqualTo:@"four"] queryWhereField:@"f1" - isGreaterThanOrEqualTo:@"five"] queryWhereField:@"f1" - isGreaterThan:@6]; + FIRQuery *query5 = [[[[[query queryWhereField:@"f1" isLessThan:@2] queryWhereField:@"f2" + isEqualTo:@3] + queryWhereField:@"f1" + isLessThanOrEqualTo:@"four"] queryWhereField:@"f1" + isGreaterThanOrEqualTo:@"five"] queryWhereField:@"f1" isGreaterThan:@6]; FIRQuery *query6 = [query queryFilteredUsingPredicate: [NSPredicate predicateWithFormat:@"f1<2 && f2==3 && f1<='four' && f1>='five' && f1>6"]]; diff --git a/Firestore/Example/Tests/API/FIRSnapshotMetadataTests.mm b/Firestore/Example/Tests/API/FIRSnapshotMetadataTests.mm index a4d321b40d2..f705aa76284 100644 --- a/Firestore/Example/Tests/API/FIRSnapshotMetadataTests.mm +++ b/Firestore/Example/Tests/API/FIRSnapshotMetadataTests.mm @@ -28,14 +28,14 @@ @interface FIRSnapshotMetadataTests : XCTestCase @implementation FIRSnapshotMetadataTests - (void)testEquals { - FIRSnapshotMetadata *foo = - [FIRSnapshotMetadata snapshotMetadataWithPendingWrites:YES fromCache:YES]; - FIRSnapshotMetadata *fooDup = - [FIRSnapshotMetadata snapshotMetadataWithPendingWrites:YES fromCache:YES]; - FIRSnapshotMetadata *bar = - [FIRSnapshotMetadata snapshotMetadataWithPendingWrites:YES fromCache:NO]; - FIRSnapshotMetadata *baz = - [FIRSnapshotMetadata snapshotMetadataWithPendingWrites:NO fromCache:YES]; + FIRSnapshotMetadata *foo = [FIRSnapshotMetadata snapshotMetadataWithPendingWrites:YES + fromCache:YES]; + FIRSnapshotMetadata *fooDup = [FIRSnapshotMetadata snapshotMetadataWithPendingWrites:YES + fromCache:YES]; + FIRSnapshotMetadata *bar = [FIRSnapshotMetadata snapshotMetadataWithPendingWrites:YES + fromCache:NO]; + FIRSnapshotMetadata *baz = [FIRSnapshotMetadata snapshotMetadataWithPendingWrites:NO + fromCache:YES]; XCTAssertEqualObjects(foo, fooDup); XCTAssertNotEqualObjects(foo, bar); XCTAssertNotEqualObjects(foo, baz); diff --git a/Firestore/Example/Tests/Core/FSTQueryListenerTests.mm b/Firestore/Example/Tests/Core/FSTQueryListenerTests.mm index ed2aa0bd1db..60bac8108f8 100644 --- a/Firestore/Example/Tests/Core/FSTQueryListenerTests.mm +++ b/Firestore/Example/Tests/Core/FSTQueryListenerTests.mm @@ -77,8 +77,9 @@ - (void)testRaisesCollectionEvents { FSTDocument *doc2prime = FSTTestDoc("rooms/Hades", 3, @{@"name" : @"Hades", @"owner" : @"Jonny"}, FSTDocumentStateSynced); - FSTQueryListener *listener = - [self listenToQuery:query options:_includeMetadataChanges accumulatingSnapshots:accum]; + FSTQueryListener *listener = [self listenToQuery:query + options:_includeMetadataChanges + accumulatingSnapshots:accum]; FSTQueryListener *otherListener = [self listenToQuery:query accumulatingSnapshots:otherAccum]; FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:DocumentKeySet{}]; @@ -123,8 +124,9 @@ - (void)testRaisesErrorEvent { [accum addObject:error]; }]; - NSError *testError = - [NSError errorWithDomain:@"com.google.firestore.test" code:42 userInfo:@{@"some" : @"info"}]; + NSError *testError = [NSError errorWithDomain:@"com.google.firestore.test" + code:42 + userInfo:@{@"some" : @"info"}]; [listener queryDidError:testError]; XCTAssertEqualObjects(accum, @[ testError ]); @@ -134,8 +136,9 @@ - (void)testRaisesEventForEmptyCollectionAfterSync { NSMutableArray *accum = [NSMutableArray array]; FSTQuery *query = FSTTestQuery("rooms"); - FSTQueryListener *listener = - [self listenToQuery:query options:_includeMetadataChanges accumulatingSnapshots:accum]; + FSTQueryListener *listener = [self listenToQuery:query + options:_includeMetadataChanges + accumulatingSnapshots:accum]; FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:DocumentKeySet{}]; FSTViewSnapshot *snap1 = FSTTestApplyChanges(view, @[], nil); @@ -193,10 +196,11 @@ - (void)testDoesNotRaiseEventsForMetadataChangesUnlessSpecified { FSTDocument *doc1 = FSTTestDoc("rooms/Eros", 1, @{@"name" : @"Eros"}, FSTDocumentStateSynced); FSTDocument *doc2 = FSTTestDoc("rooms/Hades", 2, @{@"name" : @"Hades"}, FSTDocumentStateSynced); - FSTQueryListener *filteredListener = - [self listenToQuery:query accumulatingSnapshots:filteredAccum]; - FSTQueryListener *fullListener = - [self listenToQuery:query options:_includeMetadataChanges accumulatingSnapshots:fullAccum]; + FSTQueryListener *filteredListener = [self listenToQuery:query + accumulatingSnapshots:filteredAccum]; + FSTQueryListener *fullListener = [self listenToQuery:query + options:_includeMetadataChanges + accumulatingSnapshots:fullAccum]; FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:DocumentKeySet{}]; FSTViewSnapshot *snap1 = FSTTestApplyChanges(view, @[ doc1 ], nil); @@ -236,10 +240,11 @@ - (void)testRaisesDocumentMetadataEventsOnlyWhenSpecified { includeDocumentMetadataChanges:YES waitForSyncWhenOnline:NO]; - FSTQueryListener *filteredListener = - [self listenToQuery:query accumulatingSnapshots:filteredAccum]; - FSTQueryListener *fullListener = - [self listenToQuery:query options:options accumulatingSnapshots:fullAccum]; + FSTQueryListener *filteredListener = [self listenToQuery:query + accumulatingSnapshots:filteredAccum]; + FSTQueryListener *fullListener = [self listenToQuery:query + options:options + accumulatingSnapshots:fullAccum]; FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:DocumentKeySet{}]; FSTViewSnapshot *snap1 = FSTTestApplyChanges(view, @[ doc1, doc2 ], nil); @@ -292,8 +297,9 @@ - (void)testRaisesQueryMetadataEventsOnlyWhenHasPendingWritesOnTheQueryChanges { FSTListenOptions *options = [[FSTListenOptions alloc] initWithIncludeQueryMetadataChanges:YES includeDocumentMetadataChanges:NO waitForSyncWhenOnline:NO]; - FSTQueryListener *fullListener = - [self listenToQuery:query options:options accumulatingSnapshots:fullAccum]; + FSTQueryListener *fullListener = [self listenToQuery:query + options:options + accumulatingSnapshots:fullAccum]; FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:DocumentKeySet{}]; FSTViewSnapshot *snap1 = FSTTestApplyChanges(view, @[ doc1, doc2 ], nil); @@ -332,8 +338,8 @@ - (void)testMetadataOnlyDocumentChangesAreFilteredOutWhenIncludeDocumentMetadata FSTTestDoc("rooms/Eros", 1, @{@"name" : @"Eros"}, FSTDocumentStateSynced); FSTDocument *doc3 = FSTTestDoc("rooms/Other", 3, @{@"name" : @"Other"}, FSTDocumentStateSynced); - FSTQueryListener *filteredListener = - [self listenToQuery:query accumulatingSnapshots:filteredAccum]; + FSTQueryListener *filteredListener = [self listenToQuery:query + accumulatingSnapshots:filteredAccum]; FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:DocumentKeySet{}]; FSTViewSnapshot *snap1 = FSTTestApplyChanges(view, @[ doc1, doc2 ], nil); diff --git a/Firestore/Example/Tests/Core/FSTQueryTests.mm b/Firestore/Example/Tests/Core/FSTQueryTests.mm index 7e08d34581d..f917cd67742 100644 --- a/Firestore/Example/Tests/Core/FSTQueryTests.mm +++ b/Firestore/Example/Tests/Core/FSTQueryTests.mm @@ -173,44 +173,32 @@ - (void)testArrayContainsFilter { // array without element (and make sure it doesn't match in a nested field or a different field). doc = FSTTestDoc( "collection/1", 0, - @{@"array" : @[ @41, @"42", - @{@"a" : @42, - @"b" : @[ @42 ]} ], - @"different" : @[ @42 ]}, + @{@"array" : @[ @41, @"42", @{@"a" : @42, @"b" : @[ @42 ]} ], @"different" : @[ @42 ]}, FSTDocumentStateSynced); XCTAssertFalse([query matchesDocument:doc]); // array with element. - doc = FSTTestDoc("collection/1", 0, - @{@"array" : @[ @1, @"2", @42, - @{@"a" : @1} ]}, + doc = FSTTestDoc("collection/1", 0, @{@"array" : @[ @1, @"2", @42, @{@"a" : @1} ]}, FSTDocumentStateSynced); XCTAssertTrue([query matchesDocument:doc]); } - (void)testArrayContainsFilterWithObjectValue { // Search for arrays containing the object { a: [42] } - FSTQuery *query = - [FSTTestQuery("collection") queryByAddingFilter:FSTTestFilter("array", @"array_contains", - @{@"a" : @[ @42 ]})]; + FSTQuery *query = [FSTTestQuery("collection") + queryByAddingFilter:FSTTestFilter("array", @"array_contains", @{@"a" : @[ @42 ]})]; // array without element. FSTDocument *doc = FSTTestDoc("collection/1", 0, @{ @"array" : @[ - @{@"a" : @42}, - @{@"a" : @[ @42, @43 ]}, - @{@"b" : @[ @42 ]}, - @{@"a" : @[ @42 ], - @"b" : @42} + @{@"a" : @42}, @{@"a" : @[ @42, @43 ]}, @{@"b" : @[ @42 ]}, @{@"a" : @[ @42 ], @"b" : @42} ] }, FSTDocumentStateSynced); XCTAssertFalse([query matchesDocument:doc]); // array with element. - doc = FSTTestDoc("collection/1", 0, - @{@"array" : @[ @1, @"2", @42, - @{@"a" : @[ @42 ]} ]}, + doc = FSTTestDoc("collection/1", 0, @{@"array" : @[ @1, @"2", @42, @{@"a" : @[ @42 ]} ]}, FSTDocumentStateSynced); XCTAssertTrue([query matchesDocument:doc]); } @@ -257,14 +245,14 @@ - (void)testDoesNotMatchComplexObjectsForFilters { FSTDocument *doc1 = FSTTestDoc("collection/1", 0, @{@"sort" : @2}, FSTDocumentStateSynced); FSTDocument *doc2 = FSTTestDoc("collection/2", 0, @{@"sort" : @[]}, FSTDocumentStateSynced); FSTDocument *doc3 = FSTTestDoc("collection/3", 0, @{@"sort" : @[ @1 ]}, FSTDocumentStateSynced); - FSTDocument *doc4 = FSTTestDoc("collection/4", 0, - @{@"sort" : @{@"foo" : @2}}, FSTDocumentStateSynced); - FSTDocument *doc5 = FSTTestDoc("collection/5", 0, - @{@"sort" : @{@"foo" : @"bar"}}, FSTDocumentStateSynced); - FSTDocument *doc6 = FSTTestDoc("collection/6", 0, - @{@"sort" : @{}}, FSTDocumentStateSynced); // no sort field - FSTDocument *doc7 = FSTTestDoc("collection/7", 0, - @{@"sort" : @[ @3, @1 ]}, FSTDocumentStateSynced); + FSTDocument *doc4 = + FSTTestDoc("collection/4", 0, @{@"sort" : @{@"foo" : @2}}, FSTDocumentStateSynced); + FSTDocument *doc5 = + FSTTestDoc("collection/5", 0, @{@"sort" : @{@"foo" : @"bar"}}, FSTDocumentStateSynced); + FSTDocument *doc6 = + FSTTestDoc("collection/6", 0, @{@"sort" : @{}}, FSTDocumentStateSynced); // no sort field + FSTDocument *doc7 = + FSTTestDoc("collection/7", 0, @{@"sort" : @[ @3, @1 ]}, FSTDocumentStateSynced); XCTAssertTrue([query1 matchesDocument:doc1]); XCTAssertFalse([query1 matchesDocument:doc2]); @@ -291,10 +279,10 @@ - (void)testDoesntRemoveComplexObjectsWithOrderBy { FSTDocument *doc1 = FSTTestDoc("collection/1", 0, @{@"sort" : @2}, FSTDocumentStateSynced); FSTDocument *doc2 = FSTTestDoc("collection/2", 0, @{@"sort" : @[]}, FSTDocumentStateSynced); FSTDocument *doc3 = FSTTestDoc("collection/3", 0, @{@"sort" : @[ @1 ]}, FSTDocumentStateSynced); - FSTDocument *doc4 = FSTTestDoc("collection/4", 0, - @{@"sort" : @{@"foo" : @2}}, FSTDocumentStateSynced); - FSTDocument *doc5 = FSTTestDoc("collection/5", 0, - @{@"sort" : @{@"foo" : @"bar"}}, FSTDocumentStateSynced); + FSTDocument *doc4 = + FSTTestDoc("collection/4", 0, @{@"sort" : @{@"foo" : @2}}, FSTDocumentStateSynced); + FSTDocument *doc5 = + FSTTestDoc("collection/5", 0, @{@"sort" : @{@"foo" : @"bar"}}, FSTDocumentStateSynced); FSTDocument *doc6 = FSTTestDoc("collection/6", 0, @{}, FSTDocumentStateSynced); XCTAssertTrue([query1 matchesDocument:doc1]); @@ -307,8 +295,8 @@ - (void)testDoesntRemoveComplexObjectsWithOrderBy { - (void)testFiltersBasedOnArrayValue { FSTQuery *baseQuery = FSTTestQuery("collection"); - FSTDocument *doc1 = FSTTestDoc("collection/doc", 0, - @{@"tags" : @[ @"foo", @1, @YES ]}, FSTDocumentStateSynced); + FSTDocument *doc1 = + FSTTestDoc("collection/doc", 0, @{@"tags" : @[ @"foo", @1, @YES ]}, FSTDocumentStateSynced); NSArray *matchingFilters = @[ FSTTestFilter("tags", @"==", @[ @"foo", @1, @YES ]) ]; @@ -329,22 +317,13 @@ - (void)testFiltersBasedOnArrayValue { - (void)testFiltersBasedOnObjectValue { FSTQuery *baseQuery = FSTTestQuery("collection"); - FSTDocument *doc1 = - FSTTestDoc("collection/doc", 0, - @{@"tags" : @{@"foo" : @"foo", @"a" : @0, @"b" : @YES, @"c" : @(NAN)}}, - FSTDocumentStateSynced); + FSTDocument *doc1 = FSTTestDoc( + "collection/doc", 0, @{@"tags" : @{@"foo" : @"foo", @"a" : @0, @"b" : @YES, @"c" : @(NAN)}}, + FSTDocumentStateSynced); NSArray *matchingFilters = @[ - FSTTestFilter("tags", @"==", - @{@"foo" : @"foo", - @"a" : @0, - @"b" : @YES, - @"c" : @(NAN)}), - FSTTestFilter("tags", @"==", - @{@"b" : @YES, - @"a" : @0, - @"foo" : @"foo", - @"c" : @(NAN)}), + FSTTestFilter("tags", @"==", @{@"foo" : @"foo", @"a" : @0, @"b" : @YES, @"c" : @(NAN)}), + FSTTestFilter("tags", @"==", @{@"b" : @YES, @"a" : @0, @"foo" : @"foo", @"c" : @(NAN)}), FSTTestFilter("tags.foo", @"==", @"foo") ]; diff --git a/Firestore/Example/Tests/Core/FSTViewTests.mm b/Firestore/Example/Tests/Core/FSTViewTests.mm index 770028ffaeb..759d7940669 100644 --- a/Firestore/Example/Tests/Core/FSTViewTests.mm +++ b/Firestore/Example/Tests/Core/FSTViewTests.mm @@ -143,16 +143,16 @@ - (void)testFiltersDocumentsBasedOnQueryWithFilter { query = [query queryByAddingFilter:filter]; FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:DocumentKeySet{}]; - FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/1", 0, - @{@"sort" : @1}, FSTDocumentStateSynced); - FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/2", 0, - @{@"sort" : @2}, FSTDocumentStateSynced); - FSTDocument *doc3 = FSTTestDoc("rooms/eros/messages/3", 0, - @{@"sort" : @3}, FSTDocumentStateSynced); + FSTDocument *doc1 = + FSTTestDoc("rooms/eros/messages/1", 0, @{@"sort" : @1}, FSTDocumentStateSynced); + FSTDocument *doc2 = + FSTTestDoc("rooms/eros/messages/2", 0, @{@"sort" : @2}, FSTDocumentStateSynced); + FSTDocument *doc3 = + FSTTestDoc("rooms/eros/messages/3", 0, @{@"sort" : @3}, FSTDocumentStateSynced); FSTDocument *doc4 = FSTTestDoc("rooms/eros/messages/4", 0, @{}, FSTDocumentStateSynced); // no sort, no match - FSTDocument *doc5 = FSTTestDoc("rooms/eros/messages/5", 0, - @{@"sort" : @1}, FSTDocumentStateSynced); + FSTDocument *doc5 = + FSTTestDoc("rooms/eros/messages/5", 0, @{@"sort" : @1}, FSTDocumentStateSynced); FSTViewSnapshot *snapshot = FSTTestApplyChanges(view, @[ doc1, doc2, doc3, doc4, doc5 ], nil); @@ -180,12 +180,12 @@ - (void)testUpdatesDocumentsBasedOnQueryWithFilter { query = [query queryByAddingFilter:filter]; FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:DocumentKeySet{}]; - FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/1", 0, - @{@"sort" : @1}, FSTDocumentStateSynced); - FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/2", 0, - @{@"sort" : @3}, FSTDocumentStateSynced); - FSTDocument *doc3 = FSTTestDoc("rooms/eros/messages/3", 0, - @{@"sort" : @2}, FSTDocumentStateSynced); + FSTDocument *doc1 = + FSTTestDoc("rooms/eros/messages/1", 0, @{@"sort" : @1}, FSTDocumentStateSynced); + FSTDocument *doc2 = + FSTTestDoc("rooms/eros/messages/2", 0, @{@"sort" : @3}, FSTDocumentStateSynced); + FSTDocument *doc3 = + FSTTestDoc("rooms/eros/messages/3", 0, @{@"sort" : @2}, FSTDocumentStateSynced); FSTDocument *doc4 = FSTTestDoc("rooms/eros/messages/4", 0, @{}, FSTDocumentStateSynced); FSTViewSnapshot *snapshot = FSTTestApplyChanges(view, @[ doc1, doc2, doc3, doc4 ], nil); @@ -194,12 +194,12 @@ - (void)testUpdatesDocumentsBasedOnQueryWithFilter { XCTAssertEqualObjects(snapshot.documents.arrayValue, (@[ doc1, doc3 ])); - FSTDocument *newDoc2 = FSTTestDoc("rooms/eros/messages/2", 1, - @{@"sort" : @2}, FSTDocumentStateSynced); - FSTDocument *newDoc3 = FSTTestDoc("rooms/eros/messages/3", 1, - @{@"sort" : @3}, FSTDocumentStateSynced); - FSTDocument *newDoc4 = FSTTestDoc("rooms/eros/messages/4", 1, - @{@"sort" : @0}, FSTDocumentStateSynced); + FSTDocument *newDoc2 = + FSTTestDoc("rooms/eros/messages/2", 1, @{@"sort" : @2}, FSTDocumentStateSynced); + FSTDocument *newDoc3 = + FSTTestDoc("rooms/eros/messages/3", 1, @{@"sort" : @3}, FSTDocumentStateSynced); + FSTDocument *newDoc4 = + FSTTestDoc("rooms/eros/messages/4", 1, @{@"sort" : @0}, FSTDocumentStateSynced); snapshot = FSTTestApplyChanges(view, @[ newDoc2, newDoc3, newDoc4 ], nil); @@ -258,14 +258,14 @@ - (void)testDoesntReportChangesForDocumentBeyondLimitOfQuery { query = [query queryBySettingLimit:2]; FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:DocumentKeySet{}]; - FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/1", 0, - @{@"num" : @1}, FSTDocumentStateSynced); - FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/2", 0, - @{@"num" : @2}, FSTDocumentStateSynced); - FSTDocument *doc3 = FSTTestDoc("rooms/eros/messages/3", 0, - @{@"num" : @3}, FSTDocumentStateSynced); - FSTDocument *doc4 = FSTTestDoc("rooms/eros/messages/4", 0, - @{@"num" : @4}, FSTDocumentStateSynced); + FSTDocument *doc1 = + FSTTestDoc("rooms/eros/messages/1", 0, @{@"num" : @1}, FSTDocumentStateSynced); + FSTDocument *doc2 = + FSTTestDoc("rooms/eros/messages/2", 0, @{@"num" : @2}, FSTDocumentStateSynced); + FSTDocument *doc3 = + FSTTestDoc("rooms/eros/messages/3", 0, @{@"num" : @3}, FSTDocumentStateSynced); + FSTDocument *doc4 = + FSTTestDoc("rooms/eros/messages/4", 0, @{@"num" : @4}, FSTDocumentStateSynced); // initial state FSTTestApplyChanges(view, @[ doc1, doc2 ], nil); @@ -315,15 +315,15 @@ - (void)testKeepsTrackOfLimboDocuments { change = [view applyChangesToDocuments:[view computeChangesWithDocuments:FSTTestDocUpdates(@[])] targetChange:FSTTestTargetChangeMarkCurrent()]; - XCTAssertEqualObjects( - change.limboChanges, - @[ [FSTLimboDocumentChange changeWithType:FSTLimboDocumentChangeTypeAdded key:doc1.key] ]); + XCTAssertEqualObjects(change.limboChanges, + @[ [FSTLimboDocumentChange changeWithType:FSTLimboDocumentChangeTypeAdded + key:doc1.key] ]); change = [view applyChangesToDocuments:[view computeChangesWithDocuments:FSTTestDocUpdates(@[])] targetChange:FSTTestTargetChangeAckDocuments({doc1.key})]; - XCTAssertEqualObjects( - change.limboChanges, - @[ [FSTLimboDocumentChange changeWithType:FSTLimboDocumentChangeTypeRemoved key:doc1.key] ]); + XCTAssertEqualObjects(change.limboChanges, + @[ [FSTLimboDocumentChange changeWithType:FSTLimboDocumentChangeTypeRemoved + key:doc1.key] ]); change = [view applyChangesToDocuments:[view computeChangesWithDocuments:FSTTestDocUpdates(@[ doc2 ])] @@ -332,16 +332,16 @@ - (void)testKeepsTrackOfLimboDocuments { change = [view applyChangesToDocuments:[view computeChangesWithDocuments:FSTTestDocUpdates(@[ doc3 ])]]; - XCTAssertEqualObjects( - change.limboChanges, - @[ [FSTLimboDocumentChange changeWithType:FSTLimboDocumentChangeTypeAdded key:doc3.key] ]); + XCTAssertEqualObjects(change.limboChanges, + @[ [FSTLimboDocumentChange changeWithType:FSTLimboDocumentChangeTypeAdded + key:doc3.key] ]); change = [view applyChangesToDocuments:[view computeChangesWithDocuments:FSTTestDocUpdates(@[ FSTTestDeletedDoc("rooms/eros/messages/2", 1, NO) ])]]; // remove - XCTAssertEqualObjects( - change.limboChanges, - @[ [FSTLimboDocumentChange changeWithType:FSTLimboDocumentChangeTypeRemoved key:doc3.key] ]); + XCTAssertEqualObjects(change.limboChanges, + @[ [FSTLimboDocumentChange changeWithType:FSTLimboDocumentChangeTypeRemoved + key:doc3.key] ]); } - (void)testResumingQueryCreatesNoLimbos { @@ -352,12 +352,12 @@ - (void)testResumingQueryCreatesNoLimbos { // Unlike other cases, here the view is initialized with a set of previously synced documents // which happens when listening to a previously listened-to query. - FSTView *view = - [[FSTView alloc] initWithQuery:query remoteDocuments:DocumentKeySet{doc1.key, doc2.key}]; + FSTView *view = [[FSTView alloc] initWithQuery:query + remoteDocuments:DocumentKeySet{doc1.key, doc2.key}]; FSTViewDocumentChanges *changes = [view computeChangesWithDocuments:FSTTestDocUpdates(@[])]; - FSTViewChange *change = - [view applyChangesToDocuments:changes targetChange:FSTTestTargetChangeMarkCurrent()]; + FSTViewChange *change = [view applyChangesToDocuments:changes + targetChange:FSTTestTargetChangeMarkCurrent()]; XCTAssertEqualObjects(change.limboChanges, @[]); } @@ -402,12 +402,12 @@ - (void)testReturnsNeedsRefillOnReorderInLimitQuery { [query queryByAddingSortOrder:[FSTSortOrder sortOrderWithFieldPath:testutil::Field("order") ascending:YES]]; query = [query queryBySettingLimit:2]; - FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/0", 0, - @{@"order" : @1}, FSTDocumentStateSynced); - FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/1", 0, - @{@"order" : @2}, FSTDocumentStateSynced); - FSTDocument *doc3 = FSTTestDoc("rooms/eros/messages/2", 0, - @{@"order" : @3}, FSTDocumentStateSynced); + FSTDocument *doc1 = + FSTTestDoc("rooms/eros/messages/0", 0, @{@"order" : @1}, FSTDocumentStateSynced); + FSTDocument *doc2 = + FSTTestDoc("rooms/eros/messages/1", 0, @{@"order" : @2}, FSTDocumentStateSynced); + FSTDocument *doc3 = + FSTTestDoc("rooms/eros/messages/2", 0, @{@"order" : @3}, FSTDocumentStateSynced); FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:DocumentKeySet{}]; // Start with a full view. @@ -439,16 +439,16 @@ - (void)testDoesntNeedRefillOnReorderWithinLimit { [query queryByAddingSortOrder:[FSTSortOrder sortOrderWithFieldPath:testutil::Field("order") ascending:YES]]; query = [query queryBySettingLimit:3]; - FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/0", 0, - @{@"order" : @1}, FSTDocumentStateSynced); - FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/1", 0, - @{@"order" : @2}, FSTDocumentStateSynced); - FSTDocument *doc3 = FSTTestDoc("rooms/eros/messages/2", 0, - @{@"order" : @3}, FSTDocumentStateSynced); - FSTDocument *doc4 = FSTTestDoc("rooms/eros/messages/3", 0, - @{@"order" : @4}, FSTDocumentStateSynced); - FSTDocument *doc5 = FSTTestDoc("rooms/eros/messages/4", 0, - @{@"order" : @5}, FSTDocumentStateSynced); + FSTDocument *doc1 = + FSTTestDoc("rooms/eros/messages/0", 0, @{@"order" : @1}, FSTDocumentStateSynced); + FSTDocument *doc2 = + FSTTestDoc("rooms/eros/messages/1", 0, @{@"order" : @2}, FSTDocumentStateSynced); + FSTDocument *doc3 = + FSTTestDoc("rooms/eros/messages/2", 0, @{@"order" : @3}, FSTDocumentStateSynced); + FSTDocument *doc4 = + FSTTestDoc("rooms/eros/messages/3", 0, @{@"order" : @4}, FSTDocumentStateSynced); + FSTDocument *doc5 = + FSTTestDoc("rooms/eros/messages/4", 0, @{@"order" : @5}, FSTDocumentStateSynced); FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:DocumentKeySet{}]; // Start with a full view. @@ -474,16 +474,16 @@ - (void)testDoesntNeedRefillOnReorderAfterLimitQuery { [query queryByAddingSortOrder:[FSTSortOrder sortOrderWithFieldPath:testutil::Field("order") ascending:YES]]; query = [query queryBySettingLimit:3]; - FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/0", 0, - @{@"order" : @1}, FSTDocumentStateSynced); - FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/1", 0, - @{@"order" : @2}, FSTDocumentStateSynced); - FSTDocument *doc3 = FSTTestDoc("rooms/eros/messages/2", 0, - @{@"order" : @3}, FSTDocumentStateSynced); - FSTDocument *doc4 = FSTTestDoc("rooms/eros/messages/3", 0, - @{@"order" : @4}, FSTDocumentStateSynced); - FSTDocument *doc5 = FSTTestDoc("rooms/eros/messages/4", 0, - @{@"order" : @5}, FSTDocumentStateSynced); + FSTDocument *doc1 = + FSTTestDoc("rooms/eros/messages/0", 0, @{@"order" : @1}, FSTDocumentStateSynced); + FSTDocument *doc2 = + FSTTestDoc("rooms/eros/messages/1", 0, @{@"order" : @2}, FSTDocumentStateSynced); + FSTDocument *doc3 = + FSTTestDoc("rooms/eros/messages/2", 0, @{@"order" : @3}, FSTDocumentStateSynced); + FSTDocument *doc4 = + FSTTestDoc("rooms/eros/messages/3", 0, @{@"order" : @4}, FSTDocumentStateSynced); + FSTDocument *doc5 = + FSTTestDoc("rooms/eros/messages/4", 0, @{@"order" : @5}, FSTDocumentStateSynced); FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:DocumentKeySet{}]; // Start with a full view. @@ -665,18 +665,18 @@ - (void)testSuppressesWriteAcknowledgementIfWatchHasNotCaughtUp { // up. FSTQuery *query = [self queryForMessages]; - FSTDocument *doc1 = FSTTestDoc("rooms/eros/messages/1", 1, - @{@"time" : @1}, FSTDocumentStateLocalMutations); - FSTDocument *doc1Committed = FSTTestDoc("rooms/eros/messages/1", 2, - @{@"time" : @2}, FSTDocumentStateCommittedMutations); - FSTDocument *doc1Acknowledged = FSTTestDoc("rooms/eros/messages/1", 2, - @{@"time" : @2}, FSTDocumentStateSynced); - FSTDocument *doc2 = FSTTestDoc("rooms/eros/messages/2", 1, - @{@"time" : @1}, FSTDocumentStateLocalMutations); - FSTDocument *doc2Modified = FSTTestDoc("rooms/eros/messages/2", 2, - @{@"time" : @3}, FSTDocumentStateLocalMutations); - FSTDocument *doc2Acknowledged = FSTTestDoc("rooms/eros/messages/2", 2, - @{@"time" : @3}, FSTDocumentStateSynced); + FSTDocument *doc1 = + FSTTestDoc("rooms/eros/messages/1", 1, @{@"time" : @1}, FSTDocumentStateLocalMutations); + FSTDocument *doc1Committed = + FSTTestDoc("rooms/eros/messages/1", 2, @{@"time" : @2}, FSTDocumentStateCommittedMutations); + FSTDocument *doc1Acknowledged = + FSTTestDoc("rooms/eros/messages/1", 2, @{@"time" : @2}, FSTDocumentStateSynced); + FSTDocument *doc2 = + FSTTestDoc("rooms/eros/messages/2", 1, @{@"time" : @1}, FSTDocumentStateLocalMutations); + FSTDocument *doc2Modified = + FSTTestDoc("rooms/eros/messages/2", 2, @{@"time" : @3}, FSTDocumentStateLocalMutations); + FSTDocument *doc2Acknowledged = + FSTTestDoc("rooms/eros/messages/2", 2, @{@"time" : @3}, FSTDocumentStateSynced); FSTView *view = [[FSTView alloc] initWithQuery:query remoteDocuments:DocumentKeySet{}]; FSTViewDocumentChanges *changes = [view computeChangesWithDocuments:FSTTestDocUpdates(@[ doc1, doc2 ])]; diff --git a/Firestore/Example/Tests/Integration/API/FIRArrayTransformTests.mm b/Firestore/Example/Tests/Integration/API/FIRArrayTransformTests.mm index 0867a373941..6fd4046ddaa 100644 --- a/Firestore/Example/Tests/Integration/API/FIRArrayTransformTests.mm +++ b/Firestore/Example/Tests/Integration/API/FIRArrayTransformTests.mm @@ -75,9 +75,7 @@ - (void)writeInitialData:(NSDictionary *)data { - (void)testCreateDocumentWithArrayUnion { [self writeDocumentRef:_docRef - data:@{ - @"array" : [FIRFieldValue fieldValueForArrayUnion:@[ @1, @2 ]] - }]; + data:@{@"array" : [FIRFieldValue fieldValueForArrayUnion:@[ @1, @2 ]]}]; id expected = @{@"array" : @[ @1, @2 ]}; XCTAssertEqualObjects([_accumulator awaitLocalEvent].data, expected); XCTAssertEqualObjects([_accumulator awaitRemoteEvent].data, expected); @@ -87,9 +85,7 @@ - (void)testAppendToArrayViaUpdate { [self writeInitialData:@{@"array" : @[ @1, @3 ]}]; [self updateDocumentRef:_docRef - data:@{ - @"array" : [FIRFieldValue fieldValueForArrayUnion:@[ @2, @1, @4 ]] - }]; + data:@{@"array" : [FIRFieldValue fieldValueForArrayUnion:@[ @2, @1, @4 ]]}]; id expected = @{@"array" : @[ @1, @3, @2, @4 ]}; XCTAssertEqualObjects([_accumulator awaitLocalEvent].data, expected); @@ -100,9 +96,7 @@ - (void)testAppendToArrayViaMergeSet { [self writeInitialData:@{@"array" : @[ @1, @3 ]}]; [self mergeDocumentRef:_docRef - data:@{ - @"array" : [FIRFieldValue fieldValueForArrayUnion:@[ @2, @1, @4 ]] - }]; + data:@{@"array" : [FIRFieldValue fieldValueForArrayUnion:@[ @2, @1, @4 ]]}]; id expected = @{@"array" : @[ @1, @3, @2, @4 ]}; XCTAssertEqualObjects([_accumulator awaitLocalEvent].data, expected); @@ -127,9 +121,7 @@ - (void)testRemoveFromArrayViaUpdate { [self writeInitialData:@{@"array" : @[ @1, @3, @1, @3 ]}]; [self updateDocumentRef:_docRef - data:@{ - @"array" : [FIRFieldValue fieldValueForArrayRemove:@[ @1, @4 ]] - }]; + data:@{@"array" : [FIRFieldValue fieldValueForArrayRemove:@[ @1, @4 ]]}]; id expected = @{@"array" : @[ @3, @3 ]}; XCTAssertEqualObjects([_accumulator awaitLocalEvent].data, expected); @@ -140,9 +132,7 @@ - (void)testRemoveFromArrayViaMergeSet { [self writeInitialData:@{@"array" : @[ @1, @3, @1, @3 ]}]; [self mergeDocumentRef:_docRef - data:@{ - @"array" : [FIRFieldValue fieldValueForArrayRemove:@[ @1, @4 ]] - }]; + data:@{@"array" : [FIRFieldValue fieldValueForArrayRemove:@[ @1, @4 ]]}]; id expected = @{@"array" : @[ @3, @3 ]}; XCTAssertEqualObjects([_accumulator awaitLocalEvent].data, expected); @@ -203,9 +193,7 @@ - (FIRDocumentSnapshot *_Nullable)getFromCache { - (void)testServerApplicationOfSetWithNoCachedBaseDoc { [self writeDocumentRef:_docRef - data:@{ - @"array" : [FIRFieldValue fieldValueForArrayUnion:@[ @1, @2 ]] - }]; + data:@{@"array" : [FIRFieldValue fieldValueForArrayUnion:@[ @1, @2 ]]}]; id expected = @{@"array" : @[ @1, @2 ]}; XCTAssertEqualObjects([self getFromCache].data, expected); } @@ -213,14 +201,10 @@ - (void)testServerApplicationOfSetWithNoCachedBaseDoc { - (void)testServerApplicationOfUpdateWithNoCachedBaseDoc { // Write an initial document out-of-band so it's not in our cache [self writeDocumentRef:[[self firestore] documentWithPath:_docRef.path] - data:@{ - @"array" : @[ @42 ] - }]; + data:@{@"array" : @[ @42 ]}]; [self updateDocumentRef:_docRef - data:@{ - @"array" : [FIRFieldValue fieldValueForArrayUnion:@[ @1, @2 ]] - }]; + data:@{@"array" : [FIRFieldValue fieldValueForArrayUnion:@[ @1, @2 ]]}]; // Nothing should be cached since it was an update and we had no base doc. XCTAssertNil([self getFromCache]); @@ -229,14 +213,10 @@ - (void)testServerApplicationOfUpdateWithNoCachedBaseDoc { - (void)testServerApplicationOfMergeSetWithNoCachedBaseDoc { // Write an initial document out-of-band so it's not in our cache [self writeDocumentRef:[[self firestore] documentWithPath:_docRef.path] - data:@{ - @"array" : @[ @42 ] - }]; + data:@{@"array" : @[ @42 ]}]; [self mergeDocumentRef:_docRef - data:@{ - @"array" : [FIRFieldValue fieldValueForArrayUnion:@[ @1, @2 ]] - }]; + data:@{@"array" : [FIRFieldValue fieldValueForArrayUnion:@[ @1, @2 ]]}]; // Document will be cached but we'll be missing 42. id expected = @{@"array" : @[ @1, @2 ]}; @@ -248,9 +228,7 @@ - (void)testServerApplicationOfArrayUnionUpdateWithCachedBaseDoc { [self writeDocumentRef:_docRef data:@{@"array" : @[ @42 ]}]; [self updateDocumentRef:_docRef - data:@{ - @"array" : [FIRFieldValue fieldValueForArrayUnion:@[ @1, @2 ]] - }]; + data:@{@"array" : [FIRFieldValue fieldValueForArrayUnion:@[ @1, @2 ]]}]; // Should have merged the update with the cached doc. id expected = @{@"array" : @[ @42, @1, @2 ]}; @@ -262,9 +240,7 @@ - (void)testServerApplicationOfArrayRemoveUpdateWithCachedBaseDoc { [self writeDocumentRef:_docRef data:@{@"array" : @[ @42, @1, @2 ]}]; [self updateDocumentRef:_docRef - data:@{ - @"array" : [FIRFieldValue fieldValueForArrayRemove:@[ @1, @2 ]] - }]; + data:@{@"array" : [FIRFieldValue fieldValueForArrayRemove:@[ @1, @2 ]]}]; // Should have merged the update with the cached doc. id expected = @{@"array" : @[ @42 ]}; diff --git a/Firestore/Example/Tests/Integration/API/FIRCursorTests.mm b/Firestore/Example/Tests/Integration/API/FIRCursorTests.mm index baf09077e76..4302d793cf7 100644 --- a/Firestore/Example/Tests/Integration/API/FIRCursorTests.mm +++ b/Firestore/Example/Tests/Integration/API/FIRCursorTests.mm @@ -71,21 +71,13 @@ - (void)testCanBeCreatedFromDocuments { XCTAssertTrue(snapshot.exists); FIRQuerySnapshot *querySnapshot = [self readDocumentSetForRef:[query queryStartingAtDocument:snapshot]]; - XCTAssertEqualObjects(FIRQuerySnapshotGetData(querySnapshot), (@[ - @{@"v" : @"c", - @"sort" : @2.0}, - @{@"v" : @"d", - @"sort" : @2.0} - ])); + XCTAssertEqualObjects(FIRQuerySnapshotGetData(querySnapshot), + (@[ @{@"v" : @"c", @"sort" : @2.0}, @{@"v" : @"d", @"sort" : @2.0} ])); querySnapshot = [self readDocumentSetForRef:[query queryEndingBeforeDocument:snapshot]]; XCTAssertEqualObjects(FIRQuerySnapshotGetData(querySnapshot), (@[ - @{@"v" : @"e", - @"sort" : @0.0}, - @{@"v" : @"a", - @"sort" : @1.0}, - @{@"v" : @"b", - @"sort" : @2.0} + @{@"v" : @"e", @"sort" : @0.0}, @{@"v" : @"a", @"sort" : @1.0}, + @{@"v" : @"b", @"sort" : @2.0} ])); } @@ -103,21 +95,13 @@ - (void)testCanBeCreatedFromValues { FIRQuerySnapshot *querySnapshot = [self readDocumentSetForRef:[query queryStartingAtValues:@[ @2.0 ]]]; XCTAssertEqualObjects(FIRQuerySnapshotGetData(querySnapshot), (@[ - @{@"v" : @"b", - @"sort" : @2.0}, - @{@"v" : @"c", - @"sort" : @2.0}, - @{@"v" : @"d", - @"sort" : @2.0} + @{@"v" : @"b", @"sort" : @2.0}, @{@"v" : @"c", @"sort" : @2.0}, + @{@"v" : @"d", @"sort" : @2.0} ])); querySnapshot = [self readDocumentSetForRef:[query queryEndingBeforeValues:@[ @2.0 ]]]; - XCTAssertEqualObjects(FIRQuerySnapshotGetData(querySnapshot), (@[ - @{@"v" : @"e", - @"sort" : @0.0}, - @{@"v" : @"a", - @"sort" : @1.0} - ])); + XCTAssertEqualObjects(FIRQuerySnapshotGetData(querySnapshot), + (@[ @{@"v" : @"e", @"sort" : @0.0}, @{@"v" : @"a", @"sort" : @1.0} ])); } - (void)testCanBeCreatedUsingDocumentId { @@ -178,14 +162,8 @@ - (void)testCanBeUsedInDescendingQueries { FIRQuerySnapshot *snapshot = [self readDocumentSetForRef:[query queryStartingAtValues:@[ @2.0 ]]]; XCTAssertEqualObjects(FIRQuerySnapshotGetData(snapshot), (@[ - @{@"v" : @"c", - @"sort" : @2.0}, - @{@"v" : @"b", - @"sort" : @2.0}, - @{@"v" : @"a", - @"sort" : @1.0}, - @{@"v" : @"e", - @"sort" : @0.0} + @{@"v" : @"c", @"sort" : @2.0}, @{@"v" : @"b", @"sort" : @2.0}, + @{@"v" : @"a", @"sort" : @1.0}, @{@"v" : @"e", @"sort" : @0.0} ])); snapshot = [self readDocumentSetForRef:[query queryEndingBeforeValues:@[ @2.0 ]]]; @@ -256,14 +234,14 @@ - (void)testTimestampsAreTruncatedToMicroseconds { // Because Timestamp should have been truncated to microseconds, the microsecond timestamp // should be considered equal to the nanosecond one. - querySnapshot = - [self readDocumentSetForRef:[testCollection queryWhereField:@"timestamp" isEqualTo:micros]]; + querySnapshot = [self readDocumentSetForRef:[testCollection queryWhereField:@"timestamp" + isEqualTo:micros]]; XCTAssertEqualObjects(FIRQuerySnapshotGetIDs(querySnapshot), (@[ @"a" ])); // The truncation is just to the microseconds, however, so the millisecond timestamp should be // treated as different and thus the query should return no results. - querySnapshot = - [self readDocumentSetForRef:[testCollection queryWhereField:@"timestamp" isEqualTo:millis]]; + querySnapshot = [self readDocumentSetForRef:[testCollection queryWhereField:@"timestamp" + isEqualTo:millis]]; XCTAssertEqualObjects(FIRQuerySnapshotGetIDs(querySnapshot), (@[])); } diff --git a/Firestore/Example/Tests/Integration/API/FIRDatabaseTests.mm b/Firestore/Example/Tests/Integration/API/FIRDatabaseTests.mm index 487dc04ac8b..6782563908e 100644 --- a/Firestore/Example/Tests/Integration/API/FIRDatabaseTests.mm +++ b/Firestore/Example/Tests/Integration/API/FIRDatabaseTests.mm @@ -33,13 +33,11 @@ @implementation FIRDatabaseTests - (void)testCanUpdateAnExistingDocument { FIRDocumentReference *doc = [self.db documentWithPath:@"rooms/eros"]; NSDictionary *initialData = - @{@"desc" : @"Description", - @"owner" : @{@"name" : @"Jonny", @"email" : @"abc@xyz.com"}}; + @{@"desc" : @"Description", @"owner" : @{@"name" : @"Jonny", @"email" : @"abc@xyz.com"}}; NSDictionary *updateData = @{@"desc" : @"NewDescription", @"owner.email" : @"new@xyz.com"}; NSDictionary *finalData = - @{@"desc" : @"NewDescription", - @"owner" : @{@"name" : @"Jonny", @"email" : @"new@xyz.com"}}; + @{@"desc" : @"NewDescription", @"owner" : @{@"name" : @"Jonny", @"email" : @"new@xyz.com"}}; [self writeDocumentRef:doc data:initialData]; @@ -62,8 +60,8 @@ - (void)testCanUpdateAnUnknownDocument { [self writeDocumentRef:writerRef data:@{@"a" : @"a"}]; [self updateDocumentRef:readerRef data:@{@"b" : @"b"}]; - FIRDocumentSnapshot *writerSnap = - [self readDocumentForRef:writerRef source:FIRFirestoreSourceCache]; + FIRDocumentSnapshot *writerSnap = [self readDocumentForRef:writerRef + source:FIRFirestoreSourceCache]; XCTAssertTrue(writerSnap.exists); XCTestExpectation *expectation = @@ -85,13 +83,11 @@ - (void)testCanUpdateAnUnknownDocument { - (void)testCanDeleteAFieldWithAnUpdate { FIRDocumentReference *doc = [self.db documentWithPath:@"rooms/eros"]; NSDictionary *initialData = - @{@"desc" : @"Description", - @"owner" : @{@"name" : @"Jonny", @"email" : @"abc@xyz.com"}}; + @{@"desc" : @"Description", @"owner" : @{@"name" : @"Jonny", @"email" : @"abc@xyz.com"}}; NSDictionary *updateData = @{@"owner.email" : [FIRFieldValue fieldValueForDelete]}; NSDictionary *finalData = - @{@"desc" : @"Description", - @"owner" : @{@"name" : @"Jonny"}}; + @{@"desc" : @"Description", @"owner" : @{@"name" : @"Jonny"}}; [self writeDocumentRef:doc data:initialData]; [self updateDocumentRef:doc data:updateData]; @@ -139,8 +135,7 @@ - (void)testCanOverwriteDataAnExistingDocumentUsingSet { FIRDocumentReference *doc = [[self.db collectionWithPath:@"rooms"] documentWithAutoID]; NSDictionary *initialData = - @{@"desc" : @"Description", - @"owner" : @{@"name" : @"Jonny", @"email" : @"abc@xyz.com"}}; + @{@"desc" : @"Description", @"owner" : @{@"name" : @"Jonny", @"email" : @"abc@xyz.com"}}; NSDictionary *udpateData = @{@"desc" : @"NewDescription"}; [self writeDocumentRef:doc data:initialData]; @@ -154,11 +149,9 @@ - (void)testCanMergeDataWithAnExistingDocumentUsingSet { FIRDocumentReference *doc = [[self.db collectionWithPath:@"rooms"] documentWithAutoID]; NSDictionary *initialData = - @{@"desc" : @"Description", - @"owner.data" : @{@"name" : @"Jonny", @"email" : @"abc@xyz.com"}}; + @{@"desc" : @"Description", @"owner.data" : @{@"name" : @"Jonny", @"email" : @"abc@xyz.com"}}; NSDictionary *mergeData = - @{@"updated" : @YES, - @"owner.data" : @{@"name" : @"Sebastian"}}; + @{@"updated" : @YES, @"owner.data" : @{@"name" : @"Sebastian"}}; NSDictionary *finalData = @{ @"desc" : @"Description", @"updated" : @YES, @@ -243,9 +236,7 @@ - (void)testCanDeleteFieldUsingMerge { FIRDocumentReference *doc = [[self.db collectionWithPath:@"rooms"] documentWithAutoID]; NSDictionary *initialData = - @{@"untouched" : @YES, - @"foo" : @"bar", - @"nested" : @{@"untouched" : @YES, @"foo" : @"bar"}}; + @{@"untouched" : @YES, @"foo" : @"bar", @"nested" : @{@"untouched" : @YES, @"foo" : @"bar"}}; NSDictionary *mergeData = @{ @"foo" : [FIRFieldValue fieldValueForDelete], @"nested" : @{@"foo" : [FIRFieldValue fieldValueForDelete]} @@ -290,9 +281,7 @@ - (void)testCanDeleteFieldUsingMergeFields { } }; NSDictionary *finalData = - @{@"untouched" : @YES, - @"inner" : @{}, - @"nested" : @{@"untouched" : @YES}}; + @{@"untouched" : @YES, @"inner" : @{}, @"nested" : @{@"untouched" : @YES}}; [self writeDocumentRef:doc data:initialData]; @@ -316,9 +305,7 @@ - (void)testCanSetServerTimestampsUsingMergeFields { FIRDocumentReference *doc = [[self.db collectionWithPath:@"rooms"] documentWithAutoID]; NSDictionary *initialData = - @{@"untouched" : @YES, - @"foo" : @"bar", - @"nested" : @{@"untouched" : @YES, @"foo" : @"bar"}}; + @{@"untouched" : @YES, @"foo" : @"bar", @"nested" : @{@"untouched" : @YES, @"foo" : @"bar"}}; NSDictionary *mergeData = @{ @"foo" : [FIRFieldValue fieldValueForServerTimestamp], @"inner" : @{@"foo" : [FIRFieldValue fieldValueForServerTimestamp]}, @@ -356,9 +343,7 @@ - (void)testMergeReplacesArrays { @"mapInArray" : @[ @{@"data" : @"old"} ] }; NSDictionary *mergeData = - @{@"data" : @"new", - @"topLevel" : @[ @"new" ], - @"mapInArray" : @[ @{@"data" : @"new"} ]}; + @{@"data" : @"new", @"topLevel" : @[ @"new" ], @"mapInArray" : @[ @{@"data" : @"new"} ]}; NSDictionary *finalData = @{ @"untouched" : @YES, @"data" : @"new", @@ -396,8 +381,7 @@ - (void)testCanSetASubsetOfFieldsUsingMask { FIRDocumentReference *doc = [[self.db collectionWithPath:@"rooms"] documentWithAutoID]; NSDictionary *initialData = - @{@"desc" : @"Description", - @"owner" : @{@"name" : @"Jonny", @"email" : @"abc@xyz.com"}}; + @{@"desc" : @"Description", @"owner" : @{@"name" : @"Jonny", @"email" : @"abc@xyz.com"}}; NSDictionary *finalData = @{@"desc" : @"Description", @"owner" : @"Sebastian"}; @@ -423,8 +407,7 @@ - (void)testDoesNotApplyFieldDeleteOutsideOfMask { FIRDocumentReference *doc = [[self.db collectionWithPath:@"rooms"] documentWithAutoID]; NSDictionary *initialData = - @{@"desc" : @"Description", - @"owner" : @{@"name" : @"Jonny", @"email" : @"abc@xyz.com"}}; + @{@"desc" : @"Description", @"owner" : @{@"name" : @"Jonny", @"email" : @"abc@xyz.com"}}; NSDictionary *finalData = @{@"desc" : @"Description", @"owner" : @"Sebastian"}; @@ -450,8 +433,7 @@ - (void)testDoesNotApplyFieldTransformOutsideOfMask { FIRDocumentReference *doc = [[self.db collectionWithPath:@"rooms"] documentWithAutoID]; NSDictionary *initialData = - @{@"desc" : @"Description", - @"owner" : @{@"name" : @"Jonny", @"email" : @"abc@xyz.com"}}; + @{@"desc" : @"Description", @"owner" : @{@"name" : @"Jonny", @"email" : @"abc@xyz.com"}}; NSDictionary *finalData = @{@"desc" : @"Description", @"owner" : @"Sebastian"}; @@ -477,8 +459,7 @@ - (void)testCanSetEmptyFieldMask { FIRDocumentReference *doc = [[self.db collectionWithPath:@"rooms"] documentWithAutoID]; NSDictionary *initialData = - @{@"desc" : @"Description", - @"owner" : @{@"name" : @"Jonny", @"email" : @"abc@xyz.com"}}; + @{@"desc" : @"Description", @"owner" : @{@"name" : @"Jonny", @"email" : @"abc@xyz.com"}}; NSDictionary *finalData = initialData; @@ -504,12 +485,10 @@ - (void)testCanSpecifyFieldsMultipleTimesInFieldMask { FIRDocumentReference *doc = [[self.db collectionWithPath:@"rooms"] documentWithAutoID]; NSDictionary *initialData = - @{@"desc" : @"Description", - @"owner" : @{@"name" : @"Jonny", @"email" : @"abc@xyz.com"}}; + @{@"desc" : @"Description", @"owner" : @{@"name" : @"Jonny", @"email" : @"abc@xyz.com"}}; NSDictionary *finalData = - @{@"desc" : @"Description", - @"owner" : @{@"name" : @"Sebastian", @"email" : @"new@xyz.com"}}; + @{@"desc" : @"Description", @"owner" : @{@"name" : @"Sebastian", @"email" : @"new@xyz.com"}}; [self writeDocumentRef:doc data:initialData]; @@ -521,10 +500,10 @@ - (void)testCanSpecifyFieldsMultipleTimesInFieldMask { @"owner" : @{@"name" : @"Sebastian", @"email" : @"new@xyz.com"} } mergeFields:@[ @"owner.name", @"owner", @"owner" ] - completion:^(NSError *error) { - XCTAssertNil(error); - [completed fulfill]; - }]; + completion:^(NSError *error) { + XCTAssertNil(error); + [completed fulfill]; + }]; [self awaitExpectations]; diff --git a/Firestore/Example/Tests/Integration/API/FIRFieldsTests.mm b/Firestore/Example/Tests/Integration/API/FIRFieldsTests.mm index b4c40969e4b..4d1657a44cb 100644 --- a/Firestore/Example/Tests/Integration/API/FIRFieldsTests.mm +++ b/Firestore/Example/Tests/Integration/API/FIRFieldsTests.mm @@ -228,8 +228,7 @@ - (void)testFieldsWithSpecialCharsCanBeUsedInOrderBy { - (FIRDocumentSnapshot *)snapshotWithTimestamps:(FIRTimestamp *)timestamp { FIRDocumentReference *doc = [self documentRef]; NSDictionary *data = - @{@"timestamp" : timestamp, - @"nested" : @{@"timestamp2" : timestamp}}; + @{@"timestamp" : timestamp, @"nested" : @{@"timestamp2" : timestamp}}; [self writeDocumentRef:doc data:data]; return [self readDocumentForRef:doc]; } diff --git a/Firestore/Example/Tests/Integration/API/FIRQueryTests.mm b/Firestore/Example/Tests/Integration/API/FIRQueryTests.mm index 83127b550b5..da20d92ea26 100644 --- a/Firestore/Example/Tests/Integration/API/FIRQueryTests.mm +++ b/Firestore/Example/Tests/Integration/API/FIRQueryTests.mm @@ -47,15 +47,11 @@ - (void)testLimitQueriesWithDescendingSortOrder { }]; FIRQuerySnapshot *snapshot = - [self readDocumentSetForRef:[[collRef queryOrderedByField:@"sort" descending:YES] - queryLimitedTo:2]]; + [self readDocumentSetForRef:[[collRef queryOrderedByField:@"sort" + descending:YES] queryLimitedTo:2]]; - XCTAssertEqualObjects(FIRQuerySnapshotGetData(snapshot), (@[ - @{@"k" : @"d", - @"sort" : @2}, - @{@"k" : @"c", - @"sort" : @1} - ])); + XCTAssertEqualObjects(FIRQuerySnapshotGetData(snapshot), + (@[ @{@"k" : @"d", @"sort" : @2}, @{@"k" : @"c", @"sort" : @1} ])); } - (void)testKeyOrderIsDescendingForDescendingInequality { @@ -69,9 +65,9 @@ - (void)testKeyOrderIsDescendingForDescendingInequality { @"g" : @{@"foo" : @66.0}, }]; FIRQuerySnapshot *snapshot = - [self readDocumentSetForRef:[[collRef queryWhereField:@"foo" isGreaterThan:@21] - queryOrderedByField:@"foo" - descending:YES]]; + [self readDocumentSetForRef:[[collRef queryWhereField:@"foo" + isGreaterThan:@21] queryOrderedByField:@"foo" + descending:YES]]; XCTAssertEqualObjects(FIRQuerySnapshotGetIDs(snapshot), (@[ @"g", @"f", @"c", @"b", @"a" ])); } @@ -83,25 +79,20 @@ - (void)testUnaryFilterQueries { }]; FIRQuerySnapshot *results = - [self readDocumentSetForRef:[[collRef queryWhereField:@"null" isEqualTo:[NSNull null]] - queryWhereField:@"nan" - isEqualTo:@(NAN)]]; + [self readDocumentSetForRef:[[collRef queryWhereField:@"null" + isEqualTo:[NSNull null]] queryWhereField:@"nan" + isEqualTo:@(NAN)]]; - XCTAssertEqualObjects(FIRQuerySnapshotGetData(results), (@[ - @{@"null" : [NSNull null], - @"nan" : @(NAN)} - ])); + XCTAssertEqualObjects(FIRQuerySnapshotGetData(results), + (@[ @{@"null" : [NSNull null], @"nan" : @(NAN)} ])); } - (void)testQueryWithFieldPaths { - FIRCollectionReference *collRef = [self collectionRefWithDocuments:@{ - @"a" : @{@"a" : @1}, - @"b" : @{@"a" : @2}, - @"c" : @{@"a" : @3} - }]; + FIRCollectionReference *collRef = [self + collectionRefWithDocuments:@{@"a" : @{@"a" : @1}, @"b" : @{@"a" : @2}, @"c" : @{@"a" : @3}}]; - FIRQuery *query = - [collRef queryWhereFieldPath:[[FIRFieldPath alloc] initWithFields:@[ @"a" ]] isLessThan:@3]; + FIRQuery *query = [collRef queryWhereFieldPath:[[FIRFieldPath alloc] initWithFields:@[ @"a" ]] + isLessThan:@3]; query = [query queryOrderedByFieldPath:[[FIRFieldPath alloc] initWithFields:@[ @"a" ]] descending:YES]; @@ -111,11 +102,8 @@ - (void)testQueryWithFieldPaths { } - (void)testQueryWithPredicate { - FIRCollectionReference *collRef = [self collectionRefWithDocuments:@{ - @"a" : @{@"a" : @1}, - @"b" : @{@"a" : @2}, - @"c" : @{@"a" : @3} - }]; + FIRCollectionReference *collRef = [self + collectionRefWithDocuments:@{@"a" : @{@"a" : @1}, @"b" : @{@"a" : @2}, @"c" : @{@"a" : @3}}]; NSPredicate *predicate = [NSPredicate predicateWithFormat:@"a < 3"]; FIRQuery *query = [collRef queryFilteredUsingPredicate:predicate]; @@ -133,8 +121,8 @@ - (void)testFilterOnInfinity { @"b" : @{@"inf" : @(-INFINITY)} }]; - FIRQuerySnapshot *results = - [self readDocumentSetForRef:[collRef queryWhereField:@"inf" isEqualTo:@(INFINITY)]]; + FIRQuerySnapshot *results = [self readDocumentSetForRef:[collRef queryWhereField:@"inf" + isEqualTo:@(INFINITY)]]; XCTAssertEqualObjects(FIRQuerySnapshotGetData(results), (@[ @{@"inf" : @(INFINITY)} ])); } @@ -289,20 +277,17 @@ - (void)testArrayContainsQueries { NSDictionary *testDocs = @{ @"a" : @{@"array" : @[ @42 ]}, @"b" : @{@"array" : @[ @"a", @42, @"c" ]}, - @"c" : @{@"array" : @[ @41.999, @"42", - @{@"a" : @[ @42 ]} ]}, + @"c" : @{@"array" : @[ @41.999, @"42", @{@"a" : @[ @42 ]} ]}, @"d" : @{@"array" : @[ @42 ], @"array2" : @[ @"bingo" ]} }; FIRCollectionReference *collection = [self collectionRefWithDocuments:testDocs]; // Search for 42 - FIRQuerySnapshot *snapshot = - [self readDocumentSetForRef:[collection queryWhereField:@"array" arrayContains:@42]]; + FIRQuerySnapshot *snapshot = [self readDocumentSetForRef:[collection queryWhereField:@"array" + arrayContains:@42]]; XCTAssertEqualObjects(FIRQuerySnapshotGetData(snapshot), (@[ - @{@"array" : @[ @42 ]}, - @{@"array" : @[ @"a", @42, @"c" ]}, - @{@"array" : @[ @42 ], - @"array2" : @[ @"bingo" ]} + @{@"array" : @[ @42 ]}, @{@"array" : @[ @"a", @42, @"c" ]}, + @{@"array" : @[ @42 ], @"array2" : @[ @"bingo" ]} ])); // NOTE: The backend doesn't currently support null, NaN, objects, or arrays, so there isn't much diff --git a/Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.mm b/Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.mm index 4698bcdfd71..860c8aac9ee 100644 --- a/Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.mm +++ b/Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.mm @@ -97,8 +97,8 @@ - (void)verifyTimestampsAreNullInSnapshot:(FIRDocumentSnapshot *)snapshot { /** Verifies a snapshot containing _setData but with a local estimate for the timestamps. */ - (void)verifyTimestampsAreEstimatedInSnapshot:(FIRDocumentSnapshot *)snapshot { - id timestamp = - [snapshot valueForField:@"when" serverTimestampBehavior:FIRServerTimestampBehaviorEstimate]; + id timestamp = [snapshot valueForField:@"when" + serverTimestampBehavior:FIRServerTimestampBehaviorEstimate]; XCTAssertTrue([timestamp isKindOfClass:[FIRTimestamp class]]); XCTAssertEqualObjects( [snapshot dataWithServerTimestampBehavior:FIRServerTimestampBehaviorEstimate], @@ -190,20 +190,20 @@ - (void)testServerTimestampsWithPreviousValueOfDifferentType { [_docRef updateData:@{@"a" : [FIRFieldValue fieldValueForServerTimestamp]}]; FIRDocumentSnapshot *localSnapshot = [_accumulator awaitLocalEvent]; XCTAssertEqualObjects([localSnapshot valueForField:@"a"], [NSNull null]); - XCTAssertEqualObjects( - [localSnapshot valueForField:@"a" serverTimestampBehavior:FIRServerTimestampBehaviorPrevious], - @42); - XCTAssertTrue( - [[localSnapshot valueForField:@"a" serverTimestampBehavior:FIRServerTimestampBehaviorEstimate] - isKindOfClass:[FIRTimestamp class]]); + XCTAssertEqualObjects([localSnapshot valueForField:@"a" + serverTimestampBehavior:FIRServerTimestampBehaviorPrevious], + @42); + XCTAssertTrue([[localSnapshot valueForField:@"a" + serverTimestampBehavior:FIRServerTimestampBehaviorEstimate] + isKindOfClass:[FIRTimestamp class]]); FIRDocumentSnapshot *remoteSnapshot = [_accumulator awaitRemoteEvent]; XCTAssertTrue([[remoteSnapshot valueForField:@"a"] isKindOfClass:[FIRTimestamp class]]); - XCTAssertTrue([ - [remoteSnapshot valueForField:@"a" serverTimestampBehavior:FIRServerTimestampBehaviorPrevious] + XCTAssertTrue([[remoteSnapshot valueForField:@"a" + serverTimestampBehavior:FIRServerTimestampBehaviorPrevious] isKindOfClass:[FIRTimestamp class]]); - XCTAssertTrue([ - [remoteSnapshot valueForField:@"a" serverTimestampBehavior:FIRServerTimestampBehaviorEstimate] + XCTAssertTrue([[remoteSnapshot valueForField:@"a" + serverTimestampBehavior:FIRServerTimestampBehaviorEstimate] isKindOfClass:[FIRTimestamp class]]); } @@ -216,15 +216,15 @@ - (void)testServerTimestampsWithConsecutiveUpdates { [_docRef updateData:@{@"a" : [FIRFieldValue fieldValueForServerTimestamp]}]; FIRDocumentSnapshot *localSnapshot = [_accumulator awaitLocalEvent]; - XCTAssertEqualObjects( - [localSnapshot valueForField:@"a" serverTimestampBehavior:FIRServerTimestampBehaviorPrevious], - @42); + XCTAssertEqualObjects([localSnapshot valueForField:@"a" + serverTimestampBehavior:FIRServerTimestampBehaviorPrevious], + @42); [_docRef updateData:@{@"a" : [FIRFieldValue fieldValueForServerTimestamp]}]; localSnapshot = [_accumulator awaitLocalEvent]; - XCTAssertEqualObjects( - [localSnapshot valueForField:@"a" serverTimestampBehavior:FIRServerTimestampBehaviorPrevious], - @42); + XCTAssertEqualObjects([localSnapshot valueForField:@"a" + serverTimestampBehavior:FIRServerTimestampBehaviorPrevious], + @42); [self enableNetwork]; @@ -241,9 +241,9 @@ - (void)testServerTimestampsPreviousValueFromLocalMutation { [_docRef updateData:@{@"a" : [FIRFieldValue fieldValueForServerTimestamp]}]; FIRDocumentSnapshot *localSnapshot = [_accumulator awaitLocalEvent]; - XCTAssertEqualObjects( - [localSnapshot valueForField:@"a" serverTimestampBehavior:FIRServerTimestampBehaviorPrevious], - @42); + XCTAssertEqualObjects([localSnapshot valueForField:@"a" + serverTimestampBehavior:FIRServerTimestampBehaviorPrevious], + @42); [_docRef updateData:@{@"a" : @1337}]; localSnapshot = [_accumulator awaitLocalEvent]; @@ -251,9 +251,9 @@ - (void)testServerTimestampsPreviousValueFromLocalMutation { [_docRef updateData:@{@"a" : [FIRFieldValue fieldValueForServerTimestamp]}]; localSnapshot = [_accumulator awaitLocalEvent]; - XCTAssertEqualObjects( - [localSnapshot valueForField:@"a" serverTimestampBehavior:FIRServerTimestampBehaviorPrevious], - @1337); + XCTAssertEqualObjects([localSnapshot valueForField:@"a" + serverTimestampBehavior:FIRServerTimestampBehaviorPrevious], + @1337); [self enableNetwork]; diff --git a/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm b/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm index e5a6284d68d..b3a72f43ae7 100644 --- a/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm +++ b/Firestore/Example/Tests/Integration/API/FIRValidationTests.mm @@ -99,9 +99,8 @@ - (void)testWrongLengthCollectionPathsFail { NSArray *badAbsolutePaths = @[ @"foo/bar", @"foo/bar/baz/quu" ]; NSArray *badRelativePaths = @[ @"", @"baz/quu" ]; NSArray *badPathLengths = @[ @2, @4 ]; - NSString *errorFormat = - @"Invalid collection reference. Collection references must have an odd " - @"number of segments, but %@ has %@"; + NSString *errorFormat = @"Invalid collection reference. Collection references must have an odd " + @"number of segments, but %@ has %@"; for (NSUInteger i = 0; i < badAbsolutePaths.count; i++) { NSString *error = [NSString stringWithFormat:errorFormat, badAbsolutePaths[i], badPathLengths[i]]; @@ -122,9 +121,8 @@ - (void)testWrongLengthDocumentPathsFail { NSArray *badAbsolutePaths = @[ @"foo", @"foo/bar/baz" ]; NSArray *badRelativePaths = @[ @"", @"bar/baz" ]; NSArray *badPathLengths = @[ @1, @3 ]; - NSString *errorFormat = - @"Invalid document reference. Document references must have an even " - @"number of segments, but %@ has %@"; + NSString *errorFormat = @"Invalid document reference. Document references must have an even " + @"number of segments, but %@ has %@"; for (NSUInteger i = 0; i < badAbsolutePaths.count; i++) { NSString *error = [NSString stringWithFormat:errorFormat, badAbsolutePaths[i], badPathLengths[i]]; @@ -164,9 +162,7 @@ - (void)testWritesWithNonDictionaryValuesFail { } - (void)testWritesWithDirectlyNestedArraysFail { - [self expectWrite:@{ - @"nested-array" : @[ @1, @[ @2 ] ] - } + [self expectWrite:@{@"nested-array" : @[ @1, @[ @2 ] ]} toFailWithReason:@"Nested arrays are not supported"]; } @@ -185,11 +181,11 @@ - (void)testWritesWithIndirectlyNestedArraysSucceed { [self awaitExpectations]; expectation = [self expectationWithDescription:@"batch.setData"]; - [[[ref.firestore batch] setData:data forDocument:ref] - commitWithCompletion:^(NSError *_Nullable error) { - XCTAssertNil(error); - [expectation fulfill]; - }]; + [[[ref.firestore batch] setData:data + forDocument:ref] commitWithCompletion:^(NSError *_Nullable error) { + XCTAssertNil(error); + [expectation fulfill]; + }]; [self awaitExpectations]; expectation = [self expectationWithDescription:@"updateData"]; @@ -201,11 +197,11 @@ - (void)testWritesWithIndirectlyNestedArraysSucceed { [self awaitExpectations]; expectation = [self expectationWithDescription:@"batch.updateData"]; - [[[ref.firestore batch] updateData:data forDocument:ref] - commitWithCompletion:^(NSError *_Nullable error) { - XCTAssertNil(error); - [expectation fulfill]; - }]; + [[[ref.firestore batch] updateData:data + forDocument:ref] commitWithCompletion:^(NSError *_Nullable error) { + XCTAssertNil(error); + [expectation fulfill]; + }]; [self awaitExpectations]; XCTestExpectation *transactionDone = [self expectationWithDescription:@"transaction done"]; @@ -225,9 +221,7 @@ - (void)testWritesWithIndirectlyNestedArraysSucceed { } - (void)testWritesWithInvalidTypesFail { - [self expectWrite:@{ - @"foo" : @{@"bar" : self} - } + [self expectWrite:@{@"foo" : @{@"bar" : self}} toFailWithReason:@"Unsupported type: FIRValidationTests (found in field foo.bar)"]; } @@ -251,50 +245,34 @@ - (void)testWritesWithReferencesToADifferentDatabaseFail { } - (void)testWritesWithReservedFieldsFail { - [self expectWrite:@{ - @"__baz__" : @1 - } + [self expectWrite:@{@"__baz__" : @1} toFailWithReason:@"Document fields cannot begin and end with __ (found in field __baz__)"]; - [self expectWrite:@{ - @"foo" : @{@"__baz__" : @1} - } + [self expectWrite:@{@"foo" : @{@"__baz__" : @1}} toFailWithReason: @"Document fields cannot begin and end with __ (found in field foo.__baz__)"]; - [self expectWrite:@{ - @"__baz__" : @{@"foo" : @1} - } + [self expectWrite:@{@"__baz__" : @{@"foo" : @1}} toFailWithReason:@"Document fields cannot begin and end with __ (found in field __baz__)"]; - [self expectUpdate:@{ - @"foo.__baz__" : @1 - } + [self expectUpdate:@{@"foo.__baz__" : @1} toFailWithReason: @"Document fields cannot begin and end with __ (found in field foo.__baz__)"]; - [self expectUpdate:@{ - @"__baz__.foo" : @1 - } + [self expectUpdate:@{@"__baz__.foo" : @1} toFailWithReason: @"Document fields cannot begin and end with __ (found in field __baz__.foo)"]; - [self expectUpdate:@{ - @1 : @1 - } + [self expectUpdate:@{@1 : @1} toFailWithReason:@"Dictionary keys in updateData: must be NSStrings or FIRFieldPaths."]; } - (void)testSetsWithFieldValueDeleteFail { [self expectSet:@{@"foo" : [FIRFieldValue fieldValueForDelete]} - toFailWithReason: - @"FieldValue.delete() can only be used with updateData() and setData() with " - @"merge:true (found in field foo)"]; + toFailWithReason:@"FieldValue.delete() can only be used with updateData() and setData() with " + @"merge:true (found in field foo)"]; } - (void)testUpdatesWithNestedFieldValueDeleteFail { - [self expectUpdate:@{ - @"foo" : @{@"bar" : [FIRFieldValue fieldValueForDelete]} - } - toFailWithReason: - @"FieldValue.delete() can only appear at the top level of your update data " - "(found in field foo.bar)"]; + [self expectUpdate:@{@"foo" : @{@"bar" : [FIRFieldValue fieldValueForDelete]}} + toFailWithReason:@"FieldValue.delete() can only appear at the top level of your update data " + "(found in field foo.bar)"]; } - (void)testBatchWritesWithIncorrectReferencesFail { @@ -347,10 +325,9 @@ - (void)testFieldPathsWithEmptySegmentsFail { for (NSString *fieldPath in badFieldPaths) { NSString *reason = - [NSString stringWithFormat: - @"Invalid field path (%@). Paths must not be empty, begin with " - @"'.', end with '.', or contain '..'", - fieldPath]; + [NSString stringWithFormat:@"Invalid field path (%@). Paths must not be empty, begin with " + @"'.', end with '.', or contain '..'", + fieldPath]; [self expectFieldPath:fieldPath toFailWithReason:reason]; } } @@ -371,44 +348,34 @@ - (void)testFieldPathsWithInvalidSegmentsFail { - (void)testArrayTransformsInQueriesFail { FSTAssertThrows( - [[self collectionRef] queryWhereField:@"test" - isEqualTo:@{ - @"test" : [FIRFieldValue fieldValueForArrayUnion:@[ @1 ]] - }], + [[self collectionRef] + queryWhereField:@"test" + isEqualTo:@{@"test" : [FIRFieldValue fieldValueForArrayUnion:@[ @1 ]]}], @"FieldValue.arrayUnion() can only be used with updateData() and setData() (found in field " "test)"); FSTAssertThrows( - [[self collectionRef] queryWhereField:@"test" - isEqualTo:@{ - @"test" : [FIRFieldValue fieldValueForArrayRemove:@[ @1 ]] - }], + [[self collectionRef] + queryWhereField:@"test" + isEqualTo:@{@"test" : [FIRFieldValue fieldValueForArrayRemove:@[ @1 ]]}], @"FieldValue.arrayRemove() can only be used with updateData() and setData() (found in field " @"test)"); } - (void)testInvalidArrayTransformElementFails { - [self expectWrite:@{ - @"foo" : [FIRFieldValue fieldValueForArrayUnion:@[ @1, self ]] - } + [self expectWrite:@{@"foo" : [FIRFieldValue fieldValueForArrayUnion:@[ @1, self ]]} toFailWithReason:@"Unsupported type: FIRValidationTests"]; - [self expectWrite:@{ - @"foo" : [FIRFieldValue fieldValueForArrayRemove:@[ @1, self ]] - } + [self expectWrite:@{@"foo" : [FIRFieldValue fieldValueForArrayRemove:@[ @1, self ]]} toFailWithReason:@"Unsupported type: FIRValidationTests"]; } - (void)testArraysInArrayTransformsFail { // This would result in a directly nested array which is not supported. - [self expectWrite:@{ - @"foo" : [FIRFieldValue fieldValueForArrayUnion:@[ @1, @[ @"nested" ] ]] - } + [self expectWrite:@{@"foo" : [FIRFieldValue fieldValueForArrayUnion:@[ @1, @[ @"nested" ] ]]} toFailWithReason:@"Nested arrays are not supported"]; - [self expectWrite:@{ - @"foo" : [FIRFieldValue fieldValueForArrayRemove:@[ @1, @[ @"nested" ] ]] - } + [self expectWrite:@{@"foo" : [FIRFieldValue fieldValueForArrayRemove:@[ @1, @[ @"nested" ] ]]} toFailWithReason:@"Nested arrays are not supported"]; } @@ -438,17 +405,15 @@ - (void)testNonEqualityQueriesOnNullOrNaNFail { } - (void)testQueryCannotBeCreatedFromDocumentsMissingSortValues { - FIRCollectionReference *testCollection = [self collectionRefWithDocuments:@{ - @"f" : @{@"v" : @"f", @"nosort" : @1.0} - }]; + FIRCollectionReference *testCollection = + [self collectionRefWithDocuments:@{@"f" : @{@"v" : @"f", @"nosort" : @1.0}}]; FIRQuery *query = [testCollection queryOrderedByField:@"sort"]; FIRDocumentSnapshot *snapshot = [self readDocumentForRef:[testCollection documentWithPath:@"f"]]; XCTAssertTrue(snapshot.exists); - NSString *reason = - @"Invalid query. You are trying to start or end a query using a document for " - "which the field 'sort' (used as the order by) does not exist."; + NSString *reason = @"Invalid query. You are trying to start or end a query using a document for " + "which the field 'sort' (used as the order by) does not exist."; FSTAssertThrows([query queryStartingAtDocument:snapshot], reason); FSTAssertThrows([query queryStartingAfterDocument:snapshot], reason); FSTAssertThrows([query queryEndingBeforeDocument:snapshot], reason); @@ -459,9 +424,8 @@ - (void)testQueryBoundMustNotHaveMoreComponentsThanSortOrders { FIRCollectionReference *testCollection = [self collectionRef]; FIRQuery *query = [testCollection queryOrderedByField:@"foo"]; - NSString *reason = - @"Invalid query. You are trying to start or end a query using more values " - "than were specified in the order by."; + NSString *reason = @"Invalid query. You are trying to start or end a query using more values " + "than were specified in the order by."; // More elements than order by FSTAssertThrows(([query queryStartingAtValues:@[ @1, @2 ]]), reason); FSTAssertThrows(([[query queryOrderedByField:@"bar"] queryStartingAtValues:@[ @1, @2, @3 ]]), @@ -491,20 +455,17 @@ - (void)testQueryMustNotSpecifyStartingOrEndingPointAfterOrder { - (void)testQueriesFilteredByDocumentIDMustUseStringsOrDocumentReferences { FIRCollectionReference *collection = [self collectionRef]; - NSString *reason = - @"Invalid query. When querying by document ID you must provide a valid " - "document ID, but it was an empty string."; + NSString *reason = @"Invalid query. When querying by document ID you must provide a valid " + "document ID, but it was an empty string."; FSTAssertThrows([collection queryWhereFieldPath:[FIRFieldPath documentID] isEqualTo:@""], reason); - reason = - @"Invalid query. When querying by document ID you must provide a valid document ID, " - "but 'foo/bar/baz' contains a '/' character."; + reason = @"Invalid query. When querying by document ID you must provide a valid document ID, " + "but 'foo/bar/baz' contains a '/' character."; FSTAssertThrows( [collection queryWhereFieldPath:[FIRFieldPath documentID] isEqualTo:@"foo/bar/baz"], reason); - reason = - @"Invalid query. When querying by document ID you must provide a valid string or " - "DocumentReference, but it was of type: __NSCFNumber"; + reason = @"Invalid query. When querying by document ID you must provide a valid string or " + "DocumentReference, but it was of type: __NSCFNumber"; FSTAssertThrows([collection queryWhereFieldPath:[FIRFieldPath documentID] isEqualTo:@1], reason); reason = @@ -560,9 +521,9 @@ - (void)testQueryInequalityFieldMustMatchFirstOrderByField { - (void)testQueryMustNotHaveMultipleArrayContainsFilters { FIRCollectionReference *coll = [self.db collectionWithPath:@"collection"]; - FSTAssertThrows( - [[coll queryWhereField:@"foo" arrayContains:@1] queryWhereField:@"foo" arrayContains:@2], - @"Invalid Query. Queries only support a single arrayContains filter."); + FSTAssertThrows([[coll queryWhereField:@"foo" arrayContains:@1] queryWhereField:@"foo" + arrayContains:@2], + @"Invalid Query. Queries only support a single arrayContains filter."); } #pragma mark - GeoPoint Validation diff --git a/Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.mm b/Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.mm index 7f2f98520a8..472b8ac565e 100644 --- a/Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.mm +++ b/Firestore/Example/Tests/Integration/API/FIRWriteBatchTests.mm @@ -91,10 +91,7 @@ - (void)testSetDocumentWithMerge { FIRDocumentSnapshot *snapshot = [self readDocumentForRef:doc]; XCTAssertTrue(snapshot.exists); XCTAssertEqualObjects(snapshot.data, - ( - @{@"a" : @"b", - @"c" : @"d", - @"nested" : @{@"a" : @"b", @"c" : @"d"}})); + (@{@"a" : @"b", @"c" : @"d", @"nested" : @{@"a" : @"b", @"c" : @"d"}})); } - (void)testUpdateDocuments { @@ -251,10 +248,7 @@ - (void)testCanWriteTheSameDocumentMultipleTimes { FIRWriteBatch *batch = [doc.firestore batch]; [batch deleteDocument:doc]; [batch setData:@{@"a" : @1, @"b" : @1, @"when" : @"when"} forDocument:doc]; - [batch updateData:@{ - @"b" : @2, - @"when" : [FIRFieldValue fieldValueForServerTimestamp] - } + [batch updateData:@{@"b" : @2, @"when" : [FIRFieldValue fieldValueForServerTimestamp]} forDocument:doc]; [batch commitWithCompletion:^(NSError *_Nullable error) { XCTAssertNil(error); @@ -296,17 +290,11 @@ - (void)testUpdateNestedFields { XCTestExpectation *expectation = [self expectationWithDescription:@"testUpdateNestedFields"]; FIRWriteBatch *batch = [doc.firestore batch]; - [batch setData:@{ - @"a" : @{@"b" : @"old"}, - @"c" : @{@"d" : @"old"}, - @"e" : @{@"f" : @"old"} - } + [batch setData:@{@"a" : @{@"b" : @"old"}, @"c" : @{@"d" : @"old"}, @"e" : @{@"f" : @"old"}} + forDocument:doc]; + [batch + updateData:@{@"a.b" : @"new", [[FIRFieldPath alloc] initWithFields:@[ @"c", @"d" ]] : @"new"} forDocument:doc]; - [batch updateData:@{ - @"a.b" : @"new", - [[FIRFieldPath alloc] initWithFields:@[ @"c", @"d" ]] : @"new" - } - forDocument:doc]; [batch commitWithCompletion:^(NSError *_Nullable error) { XCTAssertNil(error); [doc getDocumentWithCompletion:^(FIRDocumentSnapshot *snapshot, NSError *error) { diff --git a/Firestore/Example/Tests/Integration/FSTSmokeTests.mm b/Firestore/Example/Tests/Integration/FSTSmokeTests.mm index cb726b86ad5..4b4920f013a 100644 --- a/Firestore/Example/Tests/Integration/FSTSmokeTests.mm +++ b/Firestore/Example/Tests/Integration/FSTSmokeTests.mm @@ -115,8 +115,8 @@ - (void)xtestQueryByFieldAndUseOrderBy { FIRCollectionReference *coll = [self collectionRefWithDocuments:testDocs]; - FIRQuery *query = - [[coll queryWhereField:@"filter" isEqualTo:@YES] queryOrderedByField:@"sort" descending:YES]; + FIRQuery *query = [[coll queryWhereField:@"filter" isEqualTo:@YES] queryOrderedByField:@"sort" + descending:YES]; FIRQuerySnapshot *result = [self readDocumentSetForRef:query]; XCTAssertEqualObjects(FIRQuerySnapshotGetData(result), (@[ testDocs[@"2"], testDocs[@"3"], testDocs[@"1"] ])); diff --git a/Firestore/Example/Tests/Integration/FSTTransactionTests.mm b/Firestore/Example/Tests/Integration/FSTTransactionTests.mm index d69bfca24ac..e5634113d56 100644 --- a/Firestore/Example/Tests/Integration/FSTTransactionTests.mm +++ b/Firestore/Example/Tests/Integration/FSTTransactionTests.mm @@ -221,10 +221,7 @@ - (void)testSetDocumentWithMerge { FIRDocumentSnapshot *snapshot = [self readDocumentForRef:doc]; XCTAssertEqualObjects(snapshot.data, - ( - @{@"a" : @"b", - @"c" : @"d", - @"nested" : @{@"a" : @"b", @"c" : @"d"}})); + (@{@"a" : @"b", @"c" : @"d", @"nested" : @{@"a" : @"b", @"c" : @"d"}})); } - (void)testCannotUpdateNonExistentDocument { diff --git a/Firestore/Example/Tests/Local/FSTLRUGarbageCollectorTests.mm b/Firestore/Example/Tests/Local/FSTLRUGarbageCollectorTests.mm index adae5d01003..727244a9636 100644 --- a/Firestore/Example/Tests/Local/FSTLRUGarbageCollectorTests.mm +++ b/Firestore/Example/Tests/Local/FSTLRUGarbageCollectorTests.mm @@ -388,8 +388,8 @@ - (void)testRemoveQueriesUpThroughSequenceNumber { } // GC up through 20th query, which is 20%. // Expect to have GC'd 10 targets, since every other target is live - int removed = - [self removeQueriesThroughSequenceNumber:20 + _initialSequenceNumber liveQueries:liveQueries]; + int removed = [self removeQueriesThroughSequenceNumber:20 + _initialSequenceNumber + liveQueries:liveQueries]; XCTAssertEqual(10, removed); // Make sure we removed the even targets with targetID <= 20. _persistence.run("verify remaining targets are > 20 or odd", [&]() { diff --git a/Firestore/Example/Tests/Local/FSTLevelDBTransactionTests.mm b/Firestore/Example/Tests/Local/FSTLevelDBTransactionTests.mm index debf9a43e6f..3cae1e234ca 100644 --- a/Firestore/Example/Tests/Local/FSTLevelDBTransactionTests.mm +++ b/Firestore/Example/Tests/Local/FSTLevelDBTransactionTests.mm @@ -206,8 +206,9 @@ - (void)testProtobufSupport { std::string value; Status status = transaction.Get("theKey", &value); - NSData *result = - [[NSData alloc] initWithBytesNoCopy:(void *)value.data() length:value.size() freeWhenDone:NO]; + NSData *result = [[NSData alloc] initWithBytesNoCopy:(void *)value.data() + length:value.size() + freeWhenDone:NO]; NSError *error; FSTPBTarget *parsed = [FSTPBTarget parseFromData:result error:&error]; XCTAssertNil(error); @@ -292,17 +293,15 @@ - (void)testToString { transaction.Put(key, message); description = transaction.ToString(); - XCTAssertEqual(description, - ""); + XCTAssertEqual(description, ""); std::string key2 = LevelDbMutationKey::Key("user1", 43); transaction.Delete(key2); description = transaction.ToString(); - XCTAssertEqual(description, - ""); + XCTAssertEqual(description, ""); } @end diff --git a/Firestore/Example/Tests/Local/FSTLocalSerializerTests.mm b/Firestore/Example/Tests/Local/FSTLocalSerializerTests.mm index 99d5600273a..538f6c61e86 100644 --- a/Firestore/Example/Tests/Local/FSTLocalSerializerTests.mm +++ b/Firestore/Example/Tests/Local/FSTLocalSerializerTests.mm @@ -80,12 +80,11 @@ - (void)setUp { - (void)testEncodesMutationBatch { FSTMutation *set = FSTTestSetMutation(@"foo/bar", @{@"a" : @"b", @"num" : @1}); - FSTMutation *patch = [[FSTPatchMutation alloc] initWithKey:FSTTestDocKey(@"bar/baz") - fieldMask:FieldMask{testutil::Field("a")} - value:FSTTestObjectValue( - @{@"a" : @"b", - @"num" : @1}) - precondition:Precondition::Exists(true)]; + FSTMutation *patch = + [[FSTPatchMutation alloc] initWithKey:FSTTestDocKey(@"bar/baz") + fieldMask:FieldMask{testutil::Field("a")} + value:FSTTestObjectValue(@{@"a" : @"b", @"num" : @1}) + precondition:Precondition::Exists(true)]; FSTMutation *del = FSTTestDeleteMutation(@"baz/quux"); FIRTimestamp *writeTime = [FIRTimestamp timestamp]; FSTMutationBatch *model = [[FSTMutationBatch alloc] initWithBatchID:42 diff --git a/Firestore/Example/Tests/Local/FSTLocalStoreTests.mm b/Firestore/Example/Tests/Local/FSTLocalStoreTests.mm index 3caa80bf6ef..98635767d38 100644 --- a/Firestore/Example/Tests/Local/FSTLocalStoreTests.mm +++ b/Firestore/Example/Tests/Local/FSTLocalStoreTests.mm @@ -84,8 +84,8 @@ - (void)setUp { id persistence = [self persistence]; self.localStorePersistence = persistence; - self.localStore = - [[FSTLocalStore alloc] initWithPersistence:persistence initialUser:User::Unauthenticated()]; + self.localStore = [[FSTLocalStore alloc] initWithPersistence:persistence + initialUser:User::Unauthenticated()]; [self.localStore start]; _batches = [NSMutableArray array]; @@ -141,8 +141,8 @@ - (void)acknowledgeMutationWithVersion:(FSTTestSnapshotVersion)documentVersion { [self.batches removeObjectAtIndex:0]; XCTAssertEqual(batch.mutations.count, 1, @"Acknowledging more than one mutation not supported."); SnapshotVersion version = testutil::Version(documentVersion); - FSTMutationResult *mutationResult = - [[FSTMutationResult alloc] initWithVersion:version transformResults:nil]; + FSTMutationResult *mutationResult = [[FSTMutationResult alloc] initWithVersion:version + transformResults:nil]; FSTMutationBatchResult *result = [FSTMutationBatchResult resultWithBatch:batch commitVersion:version mutationResults:@[ mutationResult ] diff --git a/Firestore/Example/Tests/Local/FSTMutationQueueTests.mm b/Firestore/Example/Tests/Local/FSTMutationQueueTests.mm index dec5ef8c2bb..aa6e61733ea 100644 --- a/Firestore/Example/Tests/Local/FSTMutationQueueTests.mm +++ b/Firestore/Example/Tests/Local/FSTMutationQueueTests.mm @@ -213,18 +213,10 @@ - (void)testAllMutationBatchesAffectingDocumentKey { self.persistence.run("testAllMutationBatchesAffectingDocumentKey", [&]() { NSArray *mutations = @[ - FSTTestSetMutation(@"foi/bar", - @{@"a" : @1}), - FSTTestSetMutation(@"foo/bar", - @{@"a" : @1}), - FSTTestPatchMutation("foo/bar", - @{@"b" : @1}, {}), - FSTTestSetMutation(@"foo/bar/suffix/key", - @{@"a" : @1}), - FSTTestSetMutation(@"foo/baz", - @{@"a" : @1}), - FSTTestSetMutation(@"food/bar", - @{@"a" : @1}) + FSTTestSetMutation(@"foi/bar", @{@"a" : @1}), FSTTestSetMutation(@"foo/bar", @{@"a" : @1}), + FSTTestPatchMutation("foo/bar", @{@"b" : @1}, {}), + FSTTestSetMutation(@"foo/bar/suffix/key", @{@"a" : @1}), + FSTTestSetMutation(@"foo/baz", @{@"a" : @1}), FSTTestSetMutation(@"food/bar", @{@"a" : @1}) ]; // Store all the mutations. @@ -249,18 +241,10 @@ - (void)testAllMutationBatchesAffectingDocumentKeys { self.persistence.run("testAllMutationBatchesAffectingDocumentKey", [&]() { NSArray *mutations = @[ - FSTTestSetMutation(@"fob/bar", - @{@"a" : @1}), - FSTTestSetMutation(@"foo/bar", - @{@"a" : @1}), - FSTTestPatchMutation("foo/bar", - @{@"b" : @1}, {}), - FSTTestSetMutation(@"foo/bar/suffix/key", - @{@"a" : @1}), - FSTTestSetMutation(@"foo/baz", - @{@"a" : @1}), - FSTTestSetMutation(@"food/bar", - @{@"a" : @1}) + FSTTestSetMutation(@"fob/bar", @{@"a" : @1}), FSTTestSetMutation(@"foo/bar", @{@"a" : @1}), + FSTTestPatchMutation("foo/bar", @{@"b" : @1}, {}), + FSTTestSetMutation(@"foo/bar/suffix/key", @{@"a" : @1}), + FSTTestSetMutation(@"foo/baz", @{@"a" : @1}), FSTTestSetMutation(@"food/bar", @{@"a" : @1}) ]; // Store all the mutations. @@ -290,10 +274,8 @@ - (void)testAllMutationBatchesAffectingDocumentKeys_handlesOverlap { self.persistence.run("testAllMutationBatchesAffectingDocumentKeys_handlesOverlap", [&]() { NSArray *group1 = @[ - FSTTestSetMutation(@"foo/bar", - @{@"a" : @1}), - FSTTestSetMutation(@"foo/baz", - @{@"a" : @1}), + FSTTestSetMutation(@"foo/bar", @{@"a" : @1}), + FSTTestSetMutation(@"foo/baz", @{@"a" : @1}), ]; FSTMutationBatch *batch1 = [self.mutationQueue addMutationBatchWithWriteTime:[FIRTimestamp timestamp] @@ -303,8 +285,7 @@ - (void)testAllMutationBatchesAffectingDocumentKeys_handlesOverlap { [self.mutationQueue addMutationBatchWithWriteTime:[FIRTimestamp timestamp] mutations:group2]; NSArray *group3 = @[ - FSTTestSetMutation(@"foo/bar", - @{@"b" : @1}), + FSTTestSetMutation(@"foo/bar", @{@"b" : @1}), ]; FSTMutationBatch *batch3 = [self.mutationQueue addMutationBatchWithWriteTime:[FIRTimestamp timestamp] @@ -328,18 +309,10 @@ - (void)testAllMutationBatchesAffectingQuery { self.persistence.run("testAllMutationBatchesAffectingQuery", [&]() { NSArray *mutations = @[ - FSTTestSetMutation(@"fob/bar", - @{@"a" : @1}), - FSTTestSetMutation(@"foo/bar", - @{@"a" : @1}), - FSTTestPatchMutation("foo/bar", - @{@"b" : @1}, {}), - FSTTestSetMutation(@"foo/bar/suffix/key", - @{@"a" : @1}), - FSTTestSetMutation(@"foo/baz", - @{@"a" : @1}), - FSTTestSetMutation(@"food/bar", - @{@"a" : @1}) + FSTTestSetMutation(@"fob/bar", @{@"a" : @1}), FSTTestSetMutation(@"foo/bar", @{@"a" : @1}), + FSTTestPatchMutation("foo/bar", @{@"b" : @1}, {}), + FSTTestSetMutation(@"foo/bar/suffix/key", @{@"a" : @1}), + FSTTestSetMutation(@"foo/baz", @{@"a" : @1}), FSTTestSetMutation(@"food/bar", @{@"a" : @1}) ]; // Store all the mutations. diff --git a/Firestore/Example/Tests/Local/FSTPersistenceTestHelpers.mm b/Firestore/Example/Tests/Local/FSTPersistenceTestHelpers.mm index dcbef0d9427..1c5bdbbfb2a 100644 --- a/Firestore/Example/Tests/Local/FSTPersistenceTestHelpers.mm +++ b/Firestore/Example/Tests/Local/FSTPersistenceTestHelpers.mm @@ -69,8 +69,10 @@ + (FSTLevelDB *)levelDBPersistenceWithDir:(Path)dir { + (FSTLevelDB *)levelDBPersistenceWithDir:(Path)dir lruParams:(LruParams)params { FSTLocalSerializer *serializer = [self localSerializer]; FSTLevelDB *ldb; - util::Status status = - [FSTLevelDB dbWithDirectory:std::move(dir) serializer:serializer lruParams:params ptr:&ldb]; + util::Status status = [FSTLevelDB dbWithDirectory:std::move(dir) + serializer:serializer + lruParams:params + ptr:&ldb]; if (!status.ok()) { [NSException raise:NSInternalInconsistencyException format:@"Failed to open DB: %s", status.ToString().c_str()]; diff --git a/Firestore/Example/Tests/Local/FSTQueryCacheTests.mm b/Firestore/Example/Tests/Local/FSTQueryCacheTests.mm index cea556a0c66..2e0082aa29d 100644 --- a/Firestore/Example/Tests/Local/FSTQueryCacheTests.mm +++ b/Firestore/Example/Tests/Local/FSTQueryCacheTests.mm @@ -128,12 +128,16 @@ - (void)testSetQueryToNewValue { if ([self isTestBaseClass]) return; self.persistence.run("testSetQueryToNewValue", [&]() { - FSTQueryData *queryData1 = - [self queryDataWithQuery:_queryRooms targetID:1 listenSequenceNumber:10 version:1]; + FSTQueryData *queryData1 = [self queryDataWithQuery:_queryRooms + targetID:1 + listenSequenceNumber:10 + version:1]; self.queryCache->AddTarget(queryData1); - FSTQueryData *queryData2 = - [self queryDataWithQuery:_queryRooms targetID:1 listenSequenceNumber:10 version:2]; + FSTQueryData *queryData2 = [self queryDataWithQuery:_queryRooms + targetID:1 + listenSequenceNumber:10 + version:2]; self.queryCache->AddTarget(queryData2); FSTQueryData *result = self.queryCache->GetTarget(_queryRooms); diff --git a/Firestore/Example/Tests/Model/FSTDocumentTests.mm b/Firestore/Example/Tests/Model/FSTDocumentTests.mm index be919d8b08a..ae8db452d95 100644 --- a/Firestore/Example/Tests/Model/FSTDocumentTests.mm +++ b/Firestore/Example/Tests/Model/FSTDocumentTests.mm @@ -40,8 +40,10 @@ - (void)testConstructor { DocumentKey key = testutil::Key("messages/first"); SnapshotVersion version = testutil::Version(1); FSTObjectValue *data = FSTTestObjectValue(@{@"a" : @1}); - FSTDocument *doc = - [FSTDocument documentWithData:data key:key version:version state:FSTDocumentStateSynced]; + FSTDocument *doc = [FSTDocument documentWithData:data + key:key + version:version + state:FSTDocumentStateSynced]; XCTAssertEqual(doc.key, FSTTestDocKey(@"messages/first")); XCTAssertEqual(doc.version, version); @@ -56,8 +58,10 @@ - (void)testExtractsFields { @"desc" : @"Discuss all the project related stuff", @"owner" : @{@"name" : @"Jonny", @"title" : @"scallywag"} }); - FSTDocument *doc = - [FSTDocument documentWithData:data key:key version:version state:FSTDocumentStateSynced]; + FSTDocument *doc = [FSTDocument documentWithData:data + key:key + version:version + state:FSTDocumentStateSynced]; XCTAssertEqualObjects([doc fieldForPath:testutil::Field("desc")], [FSTStringValue stringValue:@"Discuss all the project related stuff"]); @@ -66,31 +70,21 @@ - (void)testExtractsFields { } - (void)testIsEqual { - XCTAssertEqualObjects(FSTTestDoc("messages/first", 1, - @{@"a" : @1}, FSTDocumentStateSynced), - FSTTestDoc("messages/first", 1, - @{@"a" : @1}, FSTDocumentStateSynced)); - XCTAssertNotEqualObjects(FSTTestDoc("messages/first", 1, - @{@"a" : @1}, FSTDocumentStateSynced), - FSTTestDoc("messages/first", 1, - @{@"b" : @1}, FSTDocumentStateSynced)); - XCTAssertNotEqualObjects(FSTTestDoc("messages/first", 1, - @{@"a" : @1}, FSTDocumentStateSynced), - FSTTestDoc("messages/second", 1, - @{@"b" : @1}, FSTDocumentStateSynced)); - XCTAssertNotEqualObjects(FSTTestDoc("messages/first", 1, - @{@"a" : @1}, FSTDocumentStateSynced), - FSTTestDoc("messages/first", 2, - @{@"a" : @1}, FSTDocumentStateSynced)); - XCTAssertNotEqualObjects(FSTTestDoc("messages/first", 1, - @{@"a" : @1}, FSTDocumentStateSynced), - FSTTestDoc("messages/first", 1, - @{@"a" : @1}, FSTDocumentStateLocalMutations)); - - XCTAssertEqualObjects(FSTTestDoc("messages/first", 1, - @{@"a" : @1}, FSTDocumentStateLocalMutations), - FSTTestDoc("messages/first", 1, - @{@"a" : @1}, FSTDocumentStateLocalMutations)); + XCTAssertEqualObjects(FSTTestDoc("messages/first", 1, @{@"a" : @1}, FSTDocumentStateSynced), + FSTTestDoc("messages/first", 1, @{@"a" : @1}, FSTDocumentStateSynced)); + XCTAssertNotEqualObjects(FSTTestDoc("messages/first", 1, @{@"a" : @1}, FSTDocumentStateSynced), + FSTTestDoc("messages/first", 1, @{@"b" : @1}, FSTDocumentStateSynced)); + XCTAssertNotEqualObjects(FSTTestDoc("messages/first", 1, @{@"a" : @1}, FSTDocumentStateSynced), + FSTTestDoc("messages/second", 1, @{@"b" : @1}, FSTDocumentStateSynced)); + XCTAssertNotEqualObjects(FSTTestDoc("messages/first", 1, @{@"a" : @1}, FSTDocumentStateSynced), + FSTTestDoc("messages/first", 2, @{@"a" : @1}, FSTDocumentStateSynced)); + XCTAssertNotEqualObjects( + FSTTestDoc("messages/first", 1, @{@"a" : @1}, FSTDocumentStateSynced), + FSTTestDoc("messages/first", 1, @{@"a" : @1}, FSTDocumentStateLocalMutations)); + + XCTAssertEqualObjects( + FSTTestDoc("messages/first", 1, @{@"a" : @1}, FSTDocumentStateLocalMutations), + FSTTestDoc("messages/first", 1, @{@"a" : @1}, FSTDocumentStateLocalMutations)); } @end diff --git a/Firestore/Example/Tests/Model/FSTFieldValueTests.mm b/Firestore/Example/Tests/Model/FSTFieldValueTests.mm index c522464ab2a..7fb501d83f1 100644 --- a/Firestore/Example/Tests/Model/FSTFieldValueTests.mm +++ b/Firestore/Example/Tests/Model/FSTFieldValueTests.mm @@ -54,8 +54,8 @@ } else if ([value isKindOfClass:[FSTDocumentKeyReference class]]) { // We directly convert these here so that the databaseIDs can be different. FSTDocumentKeyReference *reference = (FSTDocumentKeyReference *)value; - wrappedValue = - [FSTReferenceValue referenceValue:reference.key databaseID:reference.databaseID]; + wrappedValue = [FSTReferenceValue referenceValue:reference.key + databaseID:reference.databaseID]; } else { wrappedValue = FSTTestFieldValue(value); } @@ -269,11 +269,8 @@ - (void)testWrapsEmptyObjects { } - (void)testWrapsSimpleObjects { - FSTObjectValue *actual = FSTTestObjectValue( - @{@"a" : @"foo", - @"b" : @(1L), - @"c" : @YES, - @"d" : [NSNull null]}); + FSTObjectValue *actual = + FSTTestObjectValue(@{@"a" : @"foo", @"b" : @(1L), @"c" : @YES, @"d" : [NSNull null]}); FSTObjectValue *expected = [[FSTObjectValue alloc] initWithDictionary:@{ @"a" : [FSTStringValue stringValue:@"foo"], @"b" : [FSTIntegerValue integerValue:1LL], @@ -311,8 +308,8 @@ - (void)testExtractsFields { - (void)testOverwritesExistingFields { FSTObjectValue *old = FSTTestObjectValue(@{@"a" : @"old"}); - FSTObjectValue *mod = - [old objectBySettingValue:FSTTestFieldValue(@"mod") forPath:testutil::Field("a")]; + FSTObjectValue *mod = [old objectBySettingValue:FSTTestFieldValue(@"mod") + forPath:testutil::Field("a")]; // Should return a new object, leaving the old one unmodified. XCTAssertNotEqual(old, mod); @@ -322,8 +319,8 @@ - (void)testOverwritesExistingFields { - (void)testAddsNewFields { FSTObjectValue *empty = [FSTObjectValue objectValue]; - FSTObjectValue *mod = - [empty objectBySettingValue:FSTTestFieldValue(@"mod") forPath:testutil::Field("a")]; + FSTObjectValue *mod = [empty objectBySettingValue:FSTTestFieldValue(@"mod") + forPath:testutil::Field("a")]; XCTAssertNotEqual(empty, mod); XCTAssertEqualObjects(empty, FSTTestFieldValue(@{})); XCTAssertEqualObjects(mod, FSTTestFieldValue(@{@"a" : @"mod"})); @@ -337,19 +334,18 @@ - (void)testAddsNewFields { - (void)testImplicitlyCreatesObjects { FSTObjectValue *old = FSTTestObjectValue(@{@"a" : @"old"}); - FSTObjectValue *mod = - [old objectBySettingValue:FSTTestFieldValue(@"mod") forPath:testutil::Field("b.c.d")]; + FSTObjectValue *mod = [old objectBySettingValue:FSTTestFieldValue(@"mod") + forPath:testutil::Field("b.c.d")]; XCTAssertNotEqual(old, mod); XCTAssertEqualObjects(old, FSTTestFieldValue(@{@"a" : @"old"})); - XCTAssertEqualObjects(mod, FSTTestFieldValue( - @{@"a" : @"old", - @"b" : @{@"c" : @{@"d" : @"mod"}}})); + XCTAssertEqualObjects(mod, + FSTTestFieldValue(@{@"a" : @"old", @"b" : @{@"c" : @{@"d" : @"mod"}}})); } - (void)testCanOverwritePrimitivesWithObjects { FSTObjectValue *old = FSTTestObjectValue(@{@"a" : @{@"b" : @"old"}}); - FSTObjectValue *mod = - [old objectBySettingValue:FSTTestFieldValue(@{@"b" : @"mod"}) forPath:testutil::Field("a")]; + FSTObjectValue *mod = [old objectBySettingValue:FSTTestFieldValue(@{@"b" : @"mod"}) + forPath:testutil::Field("a")]; XCTAssertNotEqual(old, mod); XCTAssertEqualObjects(old, FSTTestFieldValue(@{@"a" : @{@"b" : @"old"}})); XCTAssertEqualObjects(mod, FSTTestFieldValue(@{@"a" : @{@"b" : @"mod"}})); @@ -357,8 +353,8 @@ - (void)testCanOverwritePrimitivesWithObjects { - (void)testAddsToNestedObjects { FSTObjectValue *old = FSTTestObjectValue(@{@"a" : @{@"b" : @"old"}}); - FSTObjectValue *mod = - [old objectBySettingValue:FSTTestFieldValue(@"mod") forPath:testutil::Field("a.c")]; + FSTObjectValue *mod = [old objectBySettingValue:FSTTestFieldValue(@"mod") + forPath:testutil::Field("a.c")]; XCTAssertNotEqual(old, mod); XCTAssertEqualObjects(old, FSTTestFieldValue(@{@"a" : @{@"b" : @"old"}})); XCTAssertEqualObjects(mod, FSTTestFieldValue(@{@"a" : @{@"b" : @"old", @"c" : @"mod"}})); @@ -396,8 +392,8 @@ - (void)testDeletesNestedKeys { FSTObjectValue *old = FSTTestObjectValue(@{@"a" : @{@"b" : @1, @"c" : @{@"d" : @2, @"e" : @3}}}); FSTObjectValue *mod = [old objectByDeletingPath:testutil::Field("a.c.d")]; XCTAssertNotEqual(old, mod); - XCTAssertEqualObjects(old, FSTTestFieldValue( - @{@"a" : @{@"b" : @1, @"c" : @{@"d" : @2, @"e" : @3}}})); + XCTAssertEqualObjects(old, + FSTTestFieldValue(@{@"a" : @{@"b" : @1, @"c" : @{@"d" : @2, @"e" : @3}}})); XCTAssertEqualObjects(mod, FSTTestFieldValue(@{@"a" : @{@"b" : @1, @"c" : @{@"e" : @3}}})); old = mod; @@ -470,21 +466,10 @@ - (void)testValueEquality { @[ FSTTestFieldValue(@[ @"foo", @"bar" ]), FSTTestFieldValue(@[ @"foo", @"bar" ]) ], @[ FSTTestFieldValue(@[ @"foo", @"bar", @"baz" ]) ], @[ FSTTestFieldValue(@[ @"foo" ]) ], @[ - FSTTestFieldValue( - @{@"bar" : @1, - @"foo" : @2}), - FSTTestFieldValue( - @{@"foo" : @2, - @"bar" : @1}) + FSTTestFieldValue(@{@"bar" : @1, @"foo" : @2}), FSTTestFieldValue(@{@"foo" : @2, @"bar" : @1}) ], - @[ FSTTestFieldValue( - @{@"bar" : @2, - @"foo" : @1}) ], - @[ FSTTestFieldValue( - @{@"bar" : @1, - @"foo" : @1}) ], - @[ FSTTestFieldValue( - @{@"foo" : @1}) ] + @[ FSTTestFieldValue(@{@"bar" : @2, @"foo" : @1}) ], + @[ FSTTestFieldValue(@{@"bar" : @1, @"foo" : @1}) ], @[ FSTTestFieldValue(@{@"foo" : @1}) ] ]; FSTAssertEqualityGroups(groups); @@ -542,19 +527,7 @@ - (void)testValueOrdering { @[ @[ @"foo", @"0" ] ], // Objects - @[ - @{@"bar" : @0} - ], - @[ - @{@"bar" : @0, - @"foo" : @1} - ], - @[ - @{@"foo" : @1} - ], - @[ - @{@"foo" : @2} - ], + @[ @{@"bar" : @0} ], @[ @{@"bar" : @0, @"foo" : @1} ], @[ @{@"foo" : @1} ], @[ @{@"foo" : @2} ], @[ @{@"foo" : @"0"} ] ]; diff --git a/Firestore/Example/Tests/Model/FSTMutationTests.mm b/Firestore/Example/Tests/Model/FSTMutationTests.mm index 878668fe817..3ee31a5ed78 100644 --- a/Firestore/Example/Tests/Model/FSTMutationTests.mm +++ b/Firestore/Example/Tests/Model/FSTMutationTests.mm @@ -60,8 +60,9 @@ - (void)testAppliesSetsToDocuments { FSTDocument *baseDoc = FSTTestDoc("collection/key", 0, docData, FSTDocumentStateSynced); FSTMutation *set = FSTTestSetMutation(@"collection/key", @{@"bar" : @"bar-value"}); - FSTMaybeDocument *setDoc = - [set applyToLocalDocument:baseDoc baseDocument:baseDoc localWriteTime:_timestamp]; + FSTMaybeDocument *setDoc = [set applyToLocalDocument:baseDoc + baseDocument:baseDoc + localWriteTime:_timestamp]; NSDictionary *expectedData = @{@"bar" : @"bar-value"}; XCTAssertEqualObjects( @@ -73,8 +74,9 @@ - (void)testAppliesPatchesToDocuments { FSTDocument *baseDoc = FSTTestDoc("collection/key", 0, docData, FSTDocumentStateSynced); FSTMutation *patch = FSTTestPatchMutation("collection/key", @{@"foo.bar" : @"new-bar-value"}, {}); - FSTMaybeDocument *patchedDoc = - [patch applyToLocalDocument:baseDoc baseDocument:baseDoc localWriteTime:_timestamp]; + FSTMaybeDocument *patchedDoc = [patch applyToLocalDocument:baseDoc + baseDocument:baseDoc + localWriteTime:_timestamp]; NSDictionary *expectedData = @{@"foo" : @{@"bar" : @"new-bar-value"}, @"baz" : @"baz-value"}; XCTAssertEqualObjects( @@ -90,8 +92,9 @@ - (void)testDeletesValuesFromTheFieldMask { fieldMask:{testutil::Field("foo.bar")} value:[FSTObjectValue objectValue] precondition:Precondition::None()]; - FSTMaybeDocument *patchedDoc = - [patch applyToLocalDocument:baseDoc baseDocument:baseDoc localWriteTime:_timestamp]; + FSTMaybeDocument *patchedDoc = [patch applyToLocalDocument:baseDoc + baseDocument:baseDoc + localWriteTime:_timestamp]; NSDictionary *expectedData = @{@"foo" : @{@"baz" : @"baz-value"}}; XCTAssertEqualObjects( @@ -103,8 +106,9 @@ - (void)testPatchesPrimitiveValue { FSTDocument *baseDoc = FSTTestDoc("collection/key", 0, docData, FSTDocumentStateSynced); FSTMutation *patch = FSTTestPatchMutation("collection/key", @{@"foo.bar" : @"new-bar-value"}, {}); - FSTMaybeDocument *patchedDoc = - [patch applyToLocalDocument:baseDoc baseDocument:baseDoc localWriteTime:_timestamp]; + FSTMaybeDocument *patchedDoc = [patch applyToLocalDocument:baseDoc + baseDocument:baseDoc + localWriteTime:_timestamp]; NSDictionary *expectedData = @{@"foo" : @{@"bar" : @"new-bar-value"}, @"baz" : @"baz-value"}; XCTAssertEqualObjects( @@ -114,8 +118,9 @@ - (void)testPatchesPrimitiveValue { - (void)testPatchingDeletedDocumentsDoesNothing { FSTMaybeDocument *baseDoc = FSTTestDeletedDoc("collection/key", 0, NO); FSTMutation *patch = FSTTestPatchMutation("collection/key", @{@"foo" : @"bar"}, {}); - FSTMaybeDocument *patchedDoc = - [patch applyToLocalDocument:baseDoc baseDocument:baseDoc localWriteTime:_timestamp]; + FSTMaybeDocument *patchedDoc = [patch applyToLocalDocument:baseDoc + baseDocument:baseDoc + localWriteTime:_timestamp]; XCTAssertEqualObjects(patchedDoc, baseDoc); } @@ -125,13 +130,13 @@ - (void)testAppliesLocalServerTimestampTransformToDocuments { FSTMutation *transform = FSTTestTransformMutation( @"collection/key", @{@"foo.bar" : [FIRFieldValue fieldValueForServerTimestamp]}); - FSTMaybeDocument *transformedDoc = - [transform applyToLocalDocument:baseDoc baseDocument:baseDoc localWriteTime:_timestamp]; + FSTMaybeDocument *transformedDoc = [transform applyToLocalDocument:baseDoc + baseDocument:baseDoc + localWriteTime:_timestamp]; // Server timestamps aren't parsed, so we manually insert it. - FSTObjectValue *expectedData = FSTTestObjectValue( - @{@"foo" : @{@"bar" : @""}, - @"baz" : @"baz-value"}); + FSTObjectValue *expectedData = + FSTTestObjectValue(@{@"foo" : @{@"bar" : @""}, @"baz" : @"baz-value"}); expectedData = [expectedData objectBySettingValue:[FSTServerTimestampValue serverTimestampValueWithLocalWriteTime:_timestamp @@ -152,8 +157,7 @@ - (void)testCreateArrayUnionTransform { FSTTransformMutation *transform = FSTTestTransformMutation(@"collection/key", @{ @"foo" : [FIRFieldValue fieldValueForArrayUnion:@[ @"tag" ]], @"bar.baz" : - [FIRFieldValue fieldValueForArrayUnion:@[ @YES, - @{@"nested" : @{@"a" : @[ @1, @2 ]}} ]] + [FIRFieldValue fieldValueForArrayUnion:@[ @YES, @{@"nested" : @{@"a" : @[ @1, @2 ]}} ]] }); XCTAssertEqual(transform.fieldTransforms.size(), 2); @@ -301,8 +305,9 @@ - (void)transformBaseDoc:(NSDictionary *)baseData FSTMutation *transform = FSTTestTransformMutation(@"collection/key", transformData); - FSTMaybeDocument *transformedDoc = - [transform applyToLocalDocument:baseDoc baseDocument:baseDoc localWriteTime:_timestamp]; + FSTMaybeDocument *transformedDoc = [transform applyToLocalDocument:baseDoc + baseDocument:baseDoc + localWriteTime:_timestamp]; FSTDocument *expectedDoc = [FSTDocument documentWithData:FSTTestObjectValue(expectedData) key:FSTTestDocKey(@"collection/key") @@ -323,8 +328,8 @@ - (void)testAppliesServerAckedServerTimestampTransformToDocuments { initWithVersion:testutil::Version(1) transformResults:@[ [FSTTimestampValue timestampValue:_timestamp] ]]; - FSTMaybeDocument *transformedDoc = - [transform applyToRemoteDocument:baseDoc mutationResult:mutationResult]; + FSTMaybeDocument *transformedDoc = [transform applyToRemoteDocument:baseDoc + mutationResult:mutationResult]; NSDictionary *expectedData = @{@"foo" : @{@"bar" : _timestamp.dateValue}, @"baz" : @"baz-value"}; XCTAssertEqualObjects(transformedDoc, FSTTestDoc("collection/key", 1, expectedData, @@ -345,8 +350,8 @@ - (void)testAppliesServerAckedArrayTransformsToDocuments { initWithVersion:testutil::Version(1) transformResults:@[ [FSTNullValue nullValue], [FSTNullValue nullValue] ]]; - FSTMaybeDocument *transformedDoc = - [transform applyToRemoteDocument:baseDoc mutationResult:mutationResult]; + FSTMaybeDocument *transformedDoc = [transform applyToRemoteDocument:baseDoc + mutationResult:mutationResult]; NSDictionary *expectedData = @{@"array_1" : @[ @1, @2, @3 ], @"array_2" : @[ @"b" ]}; XCTAssertEqualObjects(transformedDoc, FSTTestDoc("collection/key", 1, expectedData, @@ -358,8 +363,9 @@ - (void)testDeleteDeletes { FSTDocument *baseDoc = FSTTestDoc("collection/key", 0, docData, FSTDocumentStateSynced); FSTMutation *mutation = FSTTestDeleteMutation(@"collection/key"); - FSTMaybeDocument *result = - [mutation applyToLocalDocument:baseDoc baseDocument:baseDoc localWriteTime:_timestamp]; + FSTMaybeDocument *result = [mutation applyToLocalDocument:baseDoc + baseDocument:baseDoc + localWriteTime:_timestamp]; XCTAssertEqualObjects(result, FSTTestDeletedDoc("collection/key", 0, NO)); } @@ -384,8 +390,8 @@ - (void)testPatchWithMutationResult { FSTMutation *patch = FSTTestPatchMutation("collection/key", @{@"foo" : @"new-bar"}, {}); FSTMutationResult *mutationResult = [[FSTMutationResult alloc] initWithVersion:testutil::Version(4) transformResults:nil]; - FSTMaybeDocument *patchedDoc = - [patch applyToRemoteDocument:baseDoc mutationResult:mutationResult]; + FSTMaybeDocument *patchedDoc = [patch applyToRemoteDocument:baseDoc + mutationResult:mutationResult]; NSDictionary *expectedData = @{@"foo" : @"new-bar"}; XCTAssertEqualObjects(patchedDoc, FSTTestDoc("collection/key", 4, expectedData, diff --git a/Firestore/Example/Tests/Remote/FSTSerializerBetaTests.mm b/Firestore/Example/Tests/Remote/FSTSerializerBetaTests.mm index 131a1df4e10..c957f196129 100644 --- a/Firestore/Example/Tests/Remote/FSTSerializerBetaTests.mm +++ b/Firestore/Example/Tests/Remote/FSTSerializerBetaTests.mm @@ -287,8 +287,7 @@ - (void)testEncodesNestedObjects { @"i" : @1, @"n" : [NSNull null], @"s" : @"foo", - @"a" : @[ @2, @"bar", - @{@"b" : @NO} ], + @"a" : @[ @2, @"bar", @{@"b" : @NO} ], @"o" : @{ @"d" : @100, @"nested" : @{@"e" : @(LLONG_MIN)}, @@ -346,12 +345,8 @@ - (void)testEncodesSetMutation { } - (void)testEncodesPatchMutation { - FSTPatchMutation *mutation = - FSTTestPatchMutation("docs/1", - @{@"a" : @"b", - @"num" : @1, - @"some.de\\\\ep.th\\ing'" : @2}, - {}); + FSTPatchMutation *mutation = FSTTestPatchMutation( + "docs/1", @{@"a" : @"b", @"num" : @1, @"some.de\\\\ep.th\\ing'" : @2}, {}); GCFSWrite *proto = [GCFSWrite message]; proto.update = [self.serializer encodedDocumentWithFields:mutation.value key:mutation.key]; proto.updateMask = [self.serializer encodedFieldMask:mutation.fieldMask]; @@ -386,9 +381,7 @@ - (void)testEncodesServerTimestampTransformMutation { - (void)testEncodesArrayTransformMutations { FSTTransformMutation *mutation = FSTTestTransformMutation(@"docs/1", @{ @"a" : [FIRFieldValue fieldValueForArrayUnion:@[ @"a", @2 ]], - @"bar.baz" : [FIRFieldValue fieldValueForArrayRemove:@[ - @{@"x" : @1} - ]] + @"bar.baz" : [FIRFieldValue fieldValueForArrayRemove:@[ @{@"x" : @1} ]] }); GCFSWrite *proto = [GCFSWrite message]; proto.transform = [GCFSDocumentTransform message]; @@ -418,9 +411,7 @@ - (void)testEncodesArrayTransformMutations { - (void)testEncodesSetMutationWithPrecondition { FSTSetMutation *mutation = [[FSTSetMutation alloc] initWithKey:FSTTestDocKey(@"foo/bar") - value:FSTTestObjectValue( - @{@"a" : @"b", - @"num" : @1}) + value:FSTTestObjectValue(@{@"a" : @"b", @"num" : @1}) precondition:Precondition::UpdateTime(testutil::Version(4))]; GCFSWrite *proto = [GCFSWrite message]; proto.update = [self.serializer encodedDocumentWithFields:mutation.value key:mutation.key]; @@ -444,8 +435,8 @@ - (void)testDecodesMutationResult { proto.updateTime = [self.serializer encodedTimestamp:updateVersion.timestamp()]; [proto.transformResultsArray addObject:[self.serializer encodedString:@"result"]]; - FSTMutationResult *result = - [self.serializer decodedMutationResult:proto commitVersion:commitVersion]; + FSTMutationResult *result = [self.serializer decodedMutationResult:proto + commitVersion:commitVersion]; XCTAssertEqual(result.version, updateVersion); XCTAssertEqualObjects(result.transformResults, @[ [FSTStringValue stringValue:@"result"] ]); @@ -455,8 +446,8 @@ - (void)testDecodesDeleteMutationResult { GCFSWriteResult *proto = [GCFSWriteResult message]; SnapshotVersion commitVersion = testutil::Version(4000); - FSTMutationResult *result = - [self.serializer decodedMutationResult:proto commitVersion:commitVersion]; + FSTMutationResult *result = [self.serializer decodedMutationResult:proto + commitVersion:commitVersion]; XCTAssertEqual(result.version, commitVersion); XCTAssertEqual(result.transformResults.count, 0); diff --git a/Firestore/Example/Tests/Remote/FSTWatchChangeTests.mm b/Firestore/Example/Tests/Remote/FSTWatchChangeTests.mm index 99017ffb354..a00eba6d711 100644 --- a/Firestore/Example/Tests/Remote/FSTWatchChangeTests.mm +++ b/Firestore/Example/Tests/Remote/FSTWatchChangeTests.mm @@ -46,8 +46,8 @@ - (void)testDocumentChange { - (void)testExistenceFilterChange { FSTExistenceFilter *filter = [FSTExistenceFilter filterWithCount:7]; - FSTExistenceFilterWatchChange *change = - [FSTExistenceFilterWatchChange changeWithFilter:filter targetID:5]; + FSTExistenceFilterWatchChange *change = [FSTExistenceFilterWatchChange changeWithFilter:filter + targetID:5]; XCTAssertEqual(change.filter.count, 7); XCTAssertEqual(change.targetID, 5); } diff --git a/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm b/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm index acbb31c6b41..827051029af 100644 --- a/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm +++ b/Firestore/Example/Tests/SpecTests/FSTSpecTests.mm @@ -357,8 +357,8 @@ - (void)doWriteAck:(NSDictionary *)spec { @"'keepInQueue=true' is not supported on iOS and should only be set in " @"multi-client tests"); - FSTMutationResult *mutationResult = - [[FSTMutationResult alloc] initWithVersion:version transformResults:nil]; + FSTMutationResult *mutationResult = [[FSTMutationResult alloc] initWithVersion:version + transformResults:nil]; [self.driver receiveWriteAckWithVersion:version mutationResults:@[ mutationResult ]]; } @@ -479,9 +479,8 @@ - (void)doStep:(NSDictionary *)step { } else if (step[@"restart"]) { [self doRestart]; } else if (step[@"applyClientState"]) { - XCTFail( - @"'applyClientState' is not supported on iOS and should only be used in multi-client " - @"tests"); + XCTFail(@"'applyClientState' is not supported on iOS and should only be used in multi-client " + @"tests"); } else { XCTFail(@"Unknown step: %@", step); } @@ -497,23 +496,23 @@ - (void)validateEvent:(FSTQueryEvent *)actual matches:(NSDictionary *)expected { NSMutableArray *expectedChanges = [NSMutableArray array]; NSMutableArray *removed = expected[@"removed"]; for (NSDictionary *changeSpec in removed) { - [expectedChanges - addObject:[self parseChange:changeSpec ofType:FSTDocumentViewChangeTypeRemoved]]; + [expectedChanges addObject:[self parseChange:changeSpec + ofType:FSTDocumentViewChangeTypeRemoved]]; } NSMutableArray *added = expected[@"added"]; for (NSDictionary *changeSpec in added) { - [expectedChanges - addObject:[self parseChange:changeSpec ofType:FSTDocumentViewChangeTypeAdded]]; + [expectedChanges addObject:[self parseChange:changeSpec + ofType:FSTDocumentViewChangeTypeAdded]]; } NSMutableArray *modified = expected[@"modified"]; for (NSDictionary *changeSpec in modified) { - [expectedChanges - addObject:[self parseChange:changeSpec ofType:FSTDocumentViewChangeTypeModified]]; + [expectedChanges addObject:[self parseChange:changeSpec + ofType:FSTDocumentViewChangeTypeModified]]; } NSMutableArray *metadata = expected[@"metadata"]; for (NSDictionary *changeSpec in metadata) { - [expectedChanges - addObject:[self parseChange:changeSpec ofType:FSTDocumentViewChangeTypeMetadata]]; + [expectedChanges addObject:[self parseChange:changeSpec + ofType:FSTDocumentViewChangeTypeMetadata]]; } XCTAssertEqualObjects(actual.viewSnapshot.documentChanges, expectedChanges); diff --git a/Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm b/Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm index 70d3307290c..451bc7adf87 100644 --- a/Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm +++ b/Firestore/Example/Tests/SpecTests/FSTSyncEngineTestDriver.mm @@ -212,9 +212,8 @@ - (void)start { - (void)validateUsage { // We could relax this if we found a reason to. - HARD_ASSERT(self.events.count == 0, - "You must clear all pending events by calling" - " capturedEventsSinceLastCall before calling shutdown."); + HARD_ASSERT(self.events.count == 0, "You must clear all pending events by calling" + " capturedEventsSinceLastCall before calling shutdown."); } - (void)shutdown { @@ -285,8 +284,9 @@ - (FSTOutstandingWrite *)receiveWriteAckWithVersion:(const SnapshotVersion &)com - (FSTOutstandingWrite *)receiveWriteError:(int)errorCode userInfo:(NSDictionary *)userInfo keepInQueue:(BOOL)keepInQueue { - NSError *error = - [NSError errorWithDomain:FIRFirestoreErrorDomain code:errorCode userInfo:userInfo]; + NSError *error = [NSError errorWithDomain:FIRFirestoreErrorDomain + code:errorCode + userInfo:userInfo]; FSTOutstandingWrite *write = [self currentOutstandingWrites].firstObject; [self validateNextWriteSent:write.write]; @@ -380,8 +380,9 @@ - (void)receiveWatchChange:(FSTWatchChange *)change } - (void)receiveWatchStreamError:(int)errorCode userInfo:(NSDictionary *)userInfo { - NSError *error = - [NSError errorWithDomain:FIRFirestoreErrorDomain code:errorCode userInfo:userInfo]; + NSError *error = [NSError errorWithDomain:FIRFirestoreErrorDomain + code:errorCode + userInfo:userInfo]; _workerQueue->EnqueueBlocking([&] { [self.datastore failWatchStreamWithError:error]; diff --git a/Firestore/Example/Tests/Util/FSTHelpers.mm b/Firestore/Example/Tests/Util/FSTHelpers.mm index b9e6ca08050..3dffe0a592b 100644 --- a/Firestore/Example/Tests/Util/FSTHelpers.mm +++ b/Firestore/Example/Tests/Util/FSTHelpers.mm @@ -280,8 +280,8 @@ NSComparator FSTTestDocComparator(const absl::string_view fieldPath) { } FSTDeleteMutation *FSTTestDeleteMutation(NSString *path) { - return - [[FSTDeleteMutation alloc] initWithKey:FSTTestDocKey(path) precondition:Precondition::None()]; + return [[FSTDeleteMutation alloc] initWithKey:FSTTestDocKey(path) + precondition:Precondition::None()]; } MaybeDocumentMap FSTTestDocUpdates(NSArray *docs) { diff --git a/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm b/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm index 0d42a11bf19..1d123caf1d3 100644 --- a/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm +++ b/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm @@ -154,11 +154,10 @@ + (void)setUpDefaults { [[[NSFileManager defaultManager] attributesOfItemAtPath:certsPath error:nil] fileSize]; if (fileSize == 0) { - NSLog( - @"Please set up a GoogleServices-Info.plist for Firestore in Firestore/Example/App using " - "instructions at . " - "Alternatively, if you're a Googler with a Hexa preproduction environment, run " - "setup_integration_tests.py to properly configure testing SSL certificates."); + NSLog(@"Please set up a GoogleServices-Info.plist for Firestore in Firestore/Example/App using " + "instructions at . " + "Alternatively, if you're a Googler with a Hexa preproduction environment, run " + "setup_integration_tests.py to properly configure testing SSL certificates."); } GrpcConnection::UseTestCertificate(util::MakeString(defaultSettings.host), Path::FromNSString(certsPath), "test_cert_2"); diff --git a/Firestore/Source/API/FIRCollectionReference.mm b/Firestore/Source/API/FIRCollectionReference.mm index c5327c6525c..76f441359eb 100644 --- a/Firestore/Source/API/FIRCollectionReference.mm +++ b/Firestore/Source/API/FIRCollectionReference.mm @@ -56,10 +56,9 @@ @implementation FIRCollectionReference - (instancetype)initWithPath:(const ResourcePath &)path firestore:(FIRFirestore *)firestore { if (path.size() % 2 != 1) { - FSTThrowInvalidArgument( - @"Invalid collection reference. Collection references must have an odd " - "number of segments, but %s has %zu", - path.CanonicalString().c_str(), path.size()); + FSTThrowInvalidArgument(@"Invalid collection reference. Collection references must have an odd " + "number of segments, but %s has %zu", + path.CanonicalString().c_str(), path.size()); } self = [super initWithQuery:[FSTQuery queryWithPath:path] firestore:firestore]; return self; diff --git a/Firestore/Source/API/FIRDocumentReference.mm b/Firestore/Source/API/FIRDocumentReference.mm index f8f350a6278..0222843c718 100644 --- a/Firestore/Source/API/FIRDocumentReference.mm +++ b/Firestore/Source/API/FIRDocumentReference.mm @@ -99,8 +99,8 @@ - (NSString *)documentID { } - (FIRCollectionReference *)parent { - return - [FIRCollectionReference referenceWithPath:self.key.path().PopLast() firestore:self.firestore]; + return [FIRCollectionReference referenceWithPath:self.key.path().PopLast() + firestore:self.firestore]; } - (NSString *)path { @@ -137,9 +137,9 @@ - (void)setData:(NSDictionary *)documentData - (void)setData:(NSDictionary *)documentData merge:(BOOL)merge completion:(nullable void (^)(NSError *_Nullable error))completion { - ParsedSetData parsed = - merge ? [self.firestore.dataConverter parsedMergeData:documentData fieldMask:nil] - : [self.firestore.dataConverter parsedSetData:documentData]; + ParsedSetData parsed = merge ? [self.firestore.dataConverter parsedMergeData:documentData + fieldMask:nil] + : [self.firestore.dataConverter parsedSetData:documentData]; return [self.firestore.client writeMutations:std::move(parsed).ToMutations(self.key, Precondition::None()) completion:completion]; @@ -148,8 +148,8 @@ - (void)setData:(NSDictionary *)documentData - (void)setData:(NSDictionary *)documentData mergeFields:(NSArray *)mergeFields completion:(nullable void (^)(NSError *_Nullable error))completion { - ParsedSetData parsed = - [self.firestore.dataConverter parsedMergeData:documentData fieldMask:mergeFields]; + ParsedSetData parsed = [self.firestore.dataConverter parsedMergeData:documentData + fieldMask:mergeFields]; return [self.firestore.client writeMutations:std::move(parsed).ToMutations(self.key, Precondition::None()) completion:completion]; @@ -172,8 +172,8 @@ - (void)deleteDocument { } - (void)deleteDocumentWithCompletion:(nullable void (^)(NSError *_Nullable error))completion { - FSTDeleteMutation *mutation = - [[FSTDeleteMutation alloc] initWithKey:self.key precondition:Precondition::None()]; + FSTDeleteMutation *mutation = [[FSTDeleteMutation alloc] initWithKey:self.key + precondition:Precondition::None()]; return [self.firestore.client writeMutations:@[ mutation ] completion:completion]; } @@ -312,10 +312,9 @@ @implementation FIRDocumentReference (Internal) + (instancetype)referenceWithPath:(const ResourcePath &)path firestore:(FIRFirestore *)firestore { if (path.size() % 2 != 0) { - FSTThrowInvalidArgument( - @"Invalid document reference. Document references must have an even " - "number of segments, but %s has %zu", - path.CanonicalString().c_str(), path.size()); + FSTThrowInvalidArgument(@"Invalid document reference. Document references must have an even " + "number of segments, but %s has %zu", + path.CanonicalString().c_str(), path.size()); } return [FIRDocumentReference referenceWithKey:DocumentKey{path} firestore:firestore]; } diff --git a/Firestore/Source/API/FIRDocumentSnapshot.mm b/Firestore/Source/API/FIRDocumentSnapshot.mm index 18f8747b330..8ae3bd70d07 100644 --- a/Firestore/Source/API/FIRDocumentSnapshot.mm +++ b/Firestore/Source/API/FIRDocumentSnapshot.mm @@ -220,13 +220,12 @@ - (id)convertedValue:(FSTFieldValue *)value options:(FSTFieldValueOptions *)opti const DatabaseId *database = self.firestore.databaseID; if (*refDatabase != *database) { // TODO(b/32073923): Log this as a proper warning. - NSLog( - @"WARNING: Document %@ contains a document reference within a different database " - "(%s/%s) which is not supported. It will be treated as a reference within the " - "current database (%s/%s) instead.", - self.reference.path, refDatabase->project_id().c_str(), - refDatabase->database_id().c_str(), database->project_id().c_str(), - database->database_id().c_str()); + NSLog(@"WARNING: Document %@ contains a document reference within a different database " + "(%s/%s) which is not supported. It will be treated as a reference within the " + "current database (%s/%s) instead.", + self.reference.path, refDatabase->project_id().c_str(), + refDatabase->database_id().c_str(), database->project_id().c_str(), + database->database_id().c_str()); } DocumentKey key = [[ref valueWithOptions:options] key]; return [FIRDocumentReference referenceWithKey:key firestore:self.firestore]; diff --git a/Firestore/Source/API/FIRFirestore.mm b/Firestore/Source/API/FIRFirestore.mm index a98c03cb2a9..f1f5ffd4879 100644 --- a/Firestore/Source/API/FIRFirestore.mm +++ b/Firestore/Source/API/FIRFirestore.mm @@ -149,15 +149,13 @@ + (instancetype)firestoreForApp:(FIRApp *)app { // TODO(b/62410906): make this public + (instancetype)firestoreForApp:(FIRApp *)app database:(NSString *)database { if (!app) { - FSTThrowInvalidArgument( - @"FirebaseApp instance may not be nil. Use FirebaseApp.app() if you'd " - "like to use the default FirebaseApp instance."); + FSTThrowInvalidArgument(@"FirebaseApp instance may not be nil. Use FirebaseApp.app() if you'd " + "like to use the default FirebaseApp instance."); } if (!database) { - FSTThrowInvalidArgument( - @"database identifier may not be nil. Use '%s' if you want the default " - "database", - DatabaseId::kDefault); + FSTThrowInvalidArgument(@"database identifier may not be nil. Use '%s' if you want the default " + "database", + DatabaseId::kDefault); } id provider = @@ -182,8 +180,8 @@ - (instancetype)initWithProjectID:(std::string)projectID return input; } }; - _dataConverter = - [[FSTUserDataConverter alloc] initWithDatabaseID:&_databaseID preConverter:block]; + _dataConverter = [[FSTUserDataConverter alloc] initWithDatabaseID:&_databaseID + preConverter:block]; _persistenceKey = persistenceKey; _credentialsProvider = std::move(credentialsProvider); _workerQueue = std::move(workerQueue); diff --git a/Firestore/Source/API/FIRGeoPoint.mm b/Firestore/Source/API/FIRGeoPoint.mm index 8d896330279..cfd70fb5507 100644 --- a/Firestore/Source/API/FIRGeoPoint.mm +++ b/Firestore/Source/API/FIRGeoPoint.mm @@ -31,16 +31,14 @@ @implementation FIRGeoPoint - (instancetype)initWithLatitude:(double)latitude longitude:(double)longitude { if (self = [super init]) { if (latitude < -90 || latitude > 90 || !isfinite(latitude)) { - FSTThrowInvalidArgument( - @"GeoPoint requires a latitude value in the range of [-90, 90], " - "but was %f", - latitude); + FSTThrowInvalidArgument(@"GeoPoint requires a latitude value in the range of [-90, 90], " + "but was %f", + latitude); } if (longitude < -180 || longitude > 180 || !isfinite(longitude)) { - FSTThrowInvalidArgument( - @"GeoPoint requires a longitude value in the range of [-180, 180], " - "but was %f", - longitude); + FSTThrowInvalidArgument(@"GeoPoint requires a longitude value in the range of [-180, 180], " + "but was %f", + longitude); } _latitude = latitude; diff --git a/Firestore/Source/API/FIRQuery.mm b/Firestore/Source/API/FIRQuery.mm index b0811bf385e..e4d2f7066cd 100644 --- a/Firestore/Source/API/FIRQuery.mm +++ b/Firestore/Source/API/FIRQuery.mm @@ -143,8 +143,8 @@ - (void)getDocumentsWithSource:(FIRFirestoreSource)source } }; - listenerRegistration = - [self addSnapshotListenerInternalWithOptions:listenOptions listener:listener]; + listenerRegistration = [self addSnapshotListenerInternalWithOptions:listenOptions + listener:listener]; dispatch_semaphore_signal(registered); } @@ -228,8 +228,9 @@ - (FIRQuery *)queryWhereFieldPath:(FIRFieldPath *)path isLessThanOrEqualTo:(id)v } - (FIRQuery *)queryWhereField:(NSString *)field isGreaterThan:(id)value { - return - [self queryWithFilterOperator:FSTRelationFilterOperatorGreaterThan field:field value:value]; + return [self queryWithFilterOperator:FSTRelationFilterOperatorGreaterThan + field:field + value:value]; } - (FIRQuery *)queryWhereFieldPath:(FIRFieldPath *)path isGreaterThan:(id)value { @@ -239,8 +240,9 @@ - (FIRQuery *)queryWhereFieldPath:(FIRFieldPath *)path isGreaterThan:(id)value { } - (FIRQuery *)queryWhereField:(NSString *)field arrayContains:(id)value { - return - [self queryWithFilterOperator:FSTRelationFilterOperatorArrayContains field:field value:value]; + return [self queryWithFilterOperator:FSTRelationFilterOperatorArrayContains + field:field + value:value]; } - (FIRQuery *)queryWhereFieldPath:(FIRFieldPath *)path arrayContains:(id)value { @@ -338,21 +340,19 @@ - (FIRQuery *)queryFilteredUsingPredicate:(NSPredicate *)predicate { predicateWithBlock:^BOOL(id obj, NSDictionary *bindings) { return true; }] class]]) { - FSTThrowInvalidArgument( - @"Invalid query. Block-based predicates are not " - "supported. Please use predicateWithFormat to " - "create predicates instead."); + FSTThrowInvalidArgument(@"Invalid query. Block-based predicates are not " + "supported. Please use predicateWithFormat to " + "create predicates instead."); } else { - FSTThrowInvalidArgument( - @"Invalid query. Expect comparison or compound of " - "comparison predicate. Please use " - "predicateWithFormat to create predicates."); + FSTThrowInvalidArgument(@"Invalid query. Expect comparison or compound of " + "comparison predicate. Please use " + "predicateWithFormat to create predicates."); } } - (FIRQuery *)queryOrderedByField:(NSString *)field { - return - [self queryOrderedByFieldPath:[FIRFieldPath pathWithDotSeparatedString:field] descending:NO]; + return [self queryOrderedByFieldPath:[FIRFieldPath pathWithDotSeparatedString:field] + descending:NO]; } - (FIRQuery *)queryOrderedByFieldPath:(FIRFieldPath *)fieldPath { @@ -376,8 +376,8 @@ - (FIRQuery *)queryOrderedByFieldPath:(FIRFieldPath *)fieldPath descending:(BOOL @"InvalidQueryException", @"Invalid query. You must not specify an ending point before specifying the order by."); } - FSTSortOrder *sortOrder = - [FSTSortOrder sortOrderWithFieldPath:fieldPath.internalValue ascending:!descending]; + FSTSortOrder *sortOrder = [FSTSortOrder sortOrderWithFieldPath:fieldPath.internalValue + ascending:!descending]; return [FIRQuery referenceWithQuery:[self.query queryByAddingSortOrder:sortOrder] firestore:self.firestore]; } @@ -416,26 +416,26 @@ - (FIRQuery *)queryStartingAfterValues:(NSArray *)fieldValues { - (FIRQuery *)queryEndingBeforeDocument:(FIRDocumentSnapshot *)snapshot { FSTBound *bound = [self boundFromSnapshot:snapshot isBefore:YES]; - return - [FIRQuery referenceWithQuery:[self.query queryByAddingEndAt:bound] firestore:self.firestore]; + return [FIRQuery referenceWithQuery:[self.query queryByAddingEndAt:bound] + firestore:self.firestore]; } - (FIRQuery *)queryEndingBeforeValues:(NSArray *)fieldValues { FSTBound *bound = [self boundFromFieldValues:fieldValues isBefore:YES]; - return - [FIRQuery referenceWithQuery:[self.query queryByAddingEndAt:bound] firestore:self.firestore]; + return [FIRQuery referenceWithQuery:[self.query queryByAddingEndAt:bound] + firestore:self.firestore]; } - (FIRQuery *)queryEndingAtDocument:(FIRDocumentSnapshot *)snapshot { FSTBound *bound = [self boundFromSnapshot:snapshot isBefore:NO]; - return - [FIRQuery referenceWithQuery:[self.query queryByAddingEndAt:bound] firestore:self.firestore]; + return [FIRQuery referenceWithQuery:[self.query queryByAddingEndAt:bound] + firestore:self.firestore]; } - (FIRQuery *)queryEndingAtValues:(NSArray *)fieldValues { FSTBound *bound = [self boundFromFieldValues:fieldValues isBefore:NO]; - return - [FIRQuery referenceWithQuery:[self.query queryByAddingEndAt:bound] firestore:self.firestore]; + return [FIRQuery referenceWithQuery:[self.query queryByAddingEndAt:bound] + firestore:self.firestore]; } #pragma mark - Private Methods @@ -462,33 +462,31 @@ - (FIRQuery *)queryWithFilterOperator:(FSTRelationFilterOperator)filterOperator if ([value isKindOfClass:[NSString class]]) { NSString *documentKey = (NSString *)value; if ([documentKey containsString:@"/"]) { - FSTThrowInvalidArgument( - @"Invalid query. When querying by document ID you must provide " - "a valid document ID, but '%@' contains a '/' character.", - documentKey); + FSTThrowInvalidArgument(@"Invalid query. When querying by document ID you must provide " + "a valid document ID, but '%@' contains a '/' character.", + documentKey); } else if (documentKey.length == 0) { - FSTThrowInvalidArgument( - @"Invalid query. When querying by document ID you must provide " - "a valid document ID, but it was an empty string."); + FSTThrowInvalidArgument(@"Invalid query. When querying by document ID you must provide " + "a valid document ID, but it was an empty string."); } ResourcePath path = self.query.path.Append([documentKey UTF8String]); - fieldValue = - [FSTReferenceValue referenceValue:DocumentKey{path} databaseID:self.firestore.databaseID]; + fieldValue = [FSTReferenceValue referenceValue:DocumentKey{path} + databaseID:self.firestore.databaseID]; } else if ([value isKindOfClass:[FIRDocumentReference class]]) { FIRDocumentReference *ref = (FIRDocumentReference *)value; fieldValue = [FSTReferenceValue referenceValue:ref.key databaseID:self.firestore.databaseID]; } else { - FSTThrowInvalidArgument( - @"Invalid query. When querying by document ID you must provide a " - "valid string or DocumentReference, but it was of type: %@", - NSStringFromClass([value class])); + FSTThrowInvalidArgument(@"Invalid query. When querying by document ID you must provide a " + "valid string or DocumentReference, but it was of type: %@", + NSStringFromClass([value class])); } } else { fieldValue = [self.firestore.dataConverter parsedQueryValue:value]; } - FSTFilter *filter = - [FSTFilter filterWithField:fieldPath filterOperator:filterOperator value:fieldValue]; + FSTFilter *filter = [FSTFilter filterWithField:fieldPath + filterOperator:filterOperator + value:fieldValue]; if ([filter isKindOfClass:[FSTRelationFilter class]]) { [self validateNewRelationFilter:(FSTRelationFilter *)filter]; @@ -612,8 +610,8 @@ - (FSTBound *)boundFromFieldValues:(NSArray *)fieldValues isBefore:(BOOL)isB @"Invalid query. Document ID '%@' contains a slash.", documentID); } const DocumentKey key{self.query.path.Append([documentID UTF8String])}; - [components - addObject:[FSTReferenceValue referenceValue:key databaseID:self.firestore.databaseID]]; + [components addObject:[FSTReferenceValue referenceValue:key + databaseID:self.firestore.databaseID]]; } else { FSTFieldValue *fieldValue = [self.firestore.dataConverter parsedQueryValue:rawValue]; [components addObject:fieldValue]; diff --git a/Firestore/Source/API/FSTFirestoreComponent.mm b/Firestore/Source/API/FSTFirestoreComponent.mm index 875347b46a3..4791c121442 100644 --- a/Firestore/Source/API/FSTFirestoreComponent.mm +++ b/Firestore/Source/API/FSTFirestoreComponent.mm @@ -127,8 +127,8 @@ + (void)load { #pragma mark - Interoperability + (NSArray *)componentsToRegister { - FIRDependency *auth = - [FIRDependency dependencyWithProtocol:@protocol(FIRAuthInterop) isRequired:NO]; + FIRDependency *auth = [FIRDependency dependencyWithProtocol:@protocol(FIRAuthInterop) + isRequired:NO]; FIRComponent *firestoreProvider = [FIRComponent componentWithProtocol:@protocol(FSTFirestoreMultiDBProvider) instantiationTiming:FIRInstantiationTimingLazy diff --git a/Firestore/Source/API/FSTUserDataConverter.mm b/Firestore/Source/API/FSTUserDataConverter.mm index fd75a8f6279..ddad25014a5 100644 --- a/Firestore/Source/API/FSTUserDataConverter.mm +++ b/Firestore/Source/API/FSTUserDataConverter.mm @@ -126,8 +126,8 @@ - (ParsedSetData)parsedMergeData:(id)input fieldMask:(nullable NSArray *)fie ParseAccumulator accumulator{UserDataSource::MergeSet}; - FSTObjectValue *updateData = - (FSTObjectValue *)[self parseData:input context:accumulator.RootContext()]; + FSTObjectValue *updateData = (FSTObjectValue *)[self parseData:input + context:accumulator.RootContext()]; if (fieldMask) { std::vector validatedFieldPaths; @@ -190,8 +190,8 @@ - (ParsedUpdateData)parsedUpdateData:(id)input { // Add it to the field mask, but don't add anything to updateData. context.AddToFieldMask(std::move(path)); } else { - FSTFieldValue *_Nullable parsedValue = - [self parseData:value context:context.ChildContext(path)]; + FSTFieldValue *_Nullable parsedValue = [self parseData:value + context:context.ChildContext(path)]; if (parsedValue) { context.AddToFieldMask(path); updateData = [updateData objectBySettingValue:parsedValue forPath:path]; @@ -312,10 +312,9 @@ - (void)parseSentinelFieldValue:(FIRFieldValue *)fieldValue context:(ParseContex } else if (context.data_source() == UserDataSource::Update) { HARD_ASSERT(context.path()->size() > 0, "FieldValue.delete() at the top level should have already been handled."); - FSTThrowInvalidArgument( - @"FieldValue.delete() can only appear at the top level of your " - "update data%s", - context.FieldDescription().c_str()); + FSTThrowInvalidArgument(@"FieldValue.delete() can only appear at the top level of your " + "update data%s", + context.FieldDescription().c_str()); } else { // We shouldn't encounter delete sentinels for queries or non-merge setData calls. FSTThrowInvalidArgument( diff --git a/Firestore/Source/Core/FSTQuery.mm b/Firestore/Source/Core/FSTQuery.mm index f5f3e971652..76598d9c0d5 100644 --- a/Firestore/Source/Core/FSTQuery.mm +++ b/Firestore/Source/Core/FSTQuery.mm @@ -623,8 +623,8 @@ - (NSArray *)sortOrders { // it to be a valid query. Note that the default inequality field and key ordering is // ascending. if (inequalityField->IsKeyFieldPath()) { - self.memoizedSortOrders = - @[ [FSTSortOrder sortOrderWithFieldPath:FieldPath::KeyFieldPath() ascending:YES] ]; + self.memoizedSortOrders = @[ [FSTSortOrder sortOrderWithFieldPath:FieldPath::KeyFieldPath() + ascending:YES] ]; } else { self.memoizedSortOrders = @[ [FSTSortOrder sortOrderWithFieldPath:*inequalityField ascending:YES], @@ -666,7 +666,7 @@ - (instancetype)queryByAddingFilter:(FSTFilter *)filter { const FieldPath *newInequalityField = nullptr; if ([filter isKindOfClass:[FSTRelationFilter class]] && - [((FSTRelationFilter *)filter)isInequality]) { + [((FSTRelationFilter *)filter) isInequality]) { newInequalityField = &filter.field; } const FieldPath *queryInequalityField = [self inequalityFilterField]; diff --git a/Firestore/Source/Core/FSTSyncEngine.mm b/Firestore/Source/Core/FSTSyncEngine.mm index c5ac31f0cbf..41340b93521 100644 --- a/Firestore/Source/Core/FSTSyncEngine.mm +++ b/Firestore/Source/Core/FSTSyncEngine.mm @@ -218,8 +218,8 @@ - (FSTViewSnapshot *)initializeViewAndComputeSnapshotForQueryData:(FSTQueryData DocumentMap docs = [self.localStore executeQuery:queryData.query]; DocumentKeySet remoteKeys = [self.localStore remoteDocumentKeysForTarget:queryData.targetID]; - FSTView *view = - [[FSTView alloc] initWithQuery:queryData.query remoteDocuments:std::move(remoteKeys)]; + FSTView *view = [[FSTView alloc] initWithQuery:queryData.query + remoteDocuments:std::move(remoteKeys)]; FSTViewDocumentChanges *viewDocChanges = [view computeChangesWithDocuments:docs.underlying_map()]; FSTViewChange *viewChange = [view applyChangesToDocuments:viewDocChanges]; HARD_ASSERT(viewChange.limboChanges.count == 0, @@ -506,8 +506,8 @@ - (void)emitNewSnapshotsAndNotifyLocalStoreWithChanges:(const MaybeDocumentMap & targetChange = it->second; } } - FSTViewChange *viewChange = - [queryView.view applyChangesToDocuments:viewDocChanges targetChange:targetChange]; + FSTViewChange *viewChange = [queryView.view applyChangesToDocuments:viewDocChanges + targetChange:targetChange]; [self updateTrackedLimboDocumentsWithChanges:viewChange.limboChanges targetID:queryView.targetID]; diff --git a/Firestore/Source/Core/FSTViewSnapshot.mm b/Firestore/Source/Core/FSTViewSnapshot.mm index 655d8459546..7b356c4d4bf 100644 --- a/Firestore/Source/Core/FSTViewSnapshot.mm +++ b/Firestore/Source/Core/FSTViewSnapshot.mm @@ -117,8 +117,8 @@ - (void)addChange:(FSTDocumentViewChange *)change { } else if (change.type == FSTDocumentViewChangeTypeMetadata && oldChange.type != FSTDocumentViewChangeTypeRemoved) { - FSTDocumentViewChange *newChange = - [FSTDocumentViewChange changeWithDocument:change.document type:oldChange.type]; + FSTDocumentViewChange *newChange = [FSTDocumentViewChange changeWithDocument:change.document + type:oldChange.type]; _changeMap = _changeMap.insert(key, newChange); } else if (change.type == FSTDocumentViewChangeTypeModified && @@ -224,15 +224,15 @@ - (BOOL)hasPendingWrites { } - (NSString *)description { - return - [NSString stringWithFormat: - @"", - self.query, self.documents, self.oldDocuments, self.documentChanges, - (self.fromCache ? @"YES" : @"NO"), static_cast(self.mutatedKeys.size()), - (self.syncStateChanged ? @"YES" : @"NO"), - (self.excludesMetadataChanges ? @"YES" : @"NO")]; + return [NSString + stringWithFormat:@"", + self.query, self.documents, self.oldDocuments, self.documentChanges, + (self.fromCache ? @"YES" : @"NO"), + static_cast(self.mutatedKeys.size()), + (self.syncStateChanged ? @"YES" : @"NO"), + (self.excludesMetadataChanges ? @"YES" : @"NO")]; } - (BOOL)isEqual:(id)object { diff --git a/Firestore/Source/Local/FSTLRUGarbageCollector.mm b/Firestore/Source/Local/FSTLRUGarbageCollector.mm index 3f2ba121004..7994c160131 100644 --- a/Firestore/Source/Local/FSTLRUGarbageCollector.mm +++ b/Firestore/Source/Local/FSTLRUGarbageCollector.mm @@ -123,8 +123,8 @@ - (LruResults)runGCWithLiveTargets:(NSDictionary *)l ListenSequenceNumber upperBound = [self sequenceNumberForQueryCount:sequenceNumbers]; Timestamp foundUpperBound = Timestamp::Now(); - int numTargetsRemoved = - [self removeQueriesUpThroughSequenceNumber:upperBound liveQueries:liveTargets]; + int numTargetsRemoved = [self removeQueriesUpThroughSequenceNumber:upperBound + liveQueries:liveTargets]; Timestamp removedTargets = Timestamp::Now(); int numDocumentsRemoved = [self removeOrphanedDocumentsThroughSequenceNumber:upperBound]; diff --git a/Firestore/Source/Local/FSTLevelDB.mm b/Firestore/Source/Local/FSTLevelDB.mm index 9fcec701b83..eea2f4b3d9f 100644 --- a/Firestore/Source/Local/FSTLevelDB.mm +++ b/Firestore/Source/Local/FSTLevelDB.mm @@ -341,8 +341,8 @@ - (instancetype)initWithLevelDB:(std::unique_ptr)db _serializer = serializer; _queryCache = absl::make_unique(self, _serializer); _documentCache = absl::make_unique(self, _serializer); - _referenceDelegate = - [[FSTLevelDBLRUDelegate alloc] initWithPersistence:self lruParams:lruParams]; + _referenceDelegate = [[FSTLevelDBLRUDelegate alloc] initWithPersistence:self + lruParams:lruParams]; _transactionRunner.SetBackingPersistence(self); _users = std::move(users); // TODO(gsoltis): set up a leveldb transaction for these operations. diff --git a/Firestore/Source/Local/FSTLevelDBMutationQueue.mm b/Firestore/Source/Local/FSTLevelDBMutationQueue.mm index f28ba386051..2463514335f 100644 --- a/Firestore/Source/Local/FSTLevelDBMutationQueue.mm +++ b/Firestore/Source/Local/FSTLevelDBMutationQueue.mm @@ -364,10 +364,10 @@ - (nullable FSTMutationBatch *)nextMutationBatchAfterBatchID:(BatchId)batchID { std::string mutationKey = LevelDbMutationKey::Key(_userID, rowKey.batch_id()); mutationIterator->Seek(mutationKey); if (!mutationIterator->Valid() || mutationIterator->key() != mutationKey) { - HARD_FAIL( - "Dangling document-mutation reference found: " - "%s points to %s; seeking there found %s", - DescribeKey(indexIterator), DescribeKey(mutationKey), DescribeKey(mutationIterator)); + HARD_FAIL("Dangling document-mutation reference found: " + "%s points to %s; seeking there found %s", + DescribeKey(indexIterator), DescribeKey(mutationKey), + DescribeKey(mutationIterator)); } [result addObject:[self decodedMutationBatch:mutationIterator->value()]]; @@ -474,10 +474,9 @@ - (nullable FSTMutationBatch *)nextMutationBatchAfterBatchID:(BatchId)batchID { std::string mutationKey = LevelDbMutationKey::Key(_userID, batchID); mutationIterator->Seek(mutationKey); if (!mutationIterator->Valid() || mutationIterator->key() != mutationKey) { - HARD_FAIL( - "Dangling document-mutation reference found: " - "Missing batch %s; seeking there found %s", - DescribeKey(mutationKey), DescribeKey(mutationIterator)); + HARD_FAIL("Dangling document-mutation reference found: " + "Missing batch %s; seeking there found %s", + DescribeKey(mutationKey), DescribeKey(mutationIterator)); } [result addObject:[self decodedMutationBatch:mutationIterator->value()]]; @@ -558,8 +557,9 @@ - (void)performConsistencyCheck { /** Parses the MutationQueue metadata from the given LevelDB row contents. */ - (FSTPBMutationQueue *)parsedMetadata:(Slice)slice { - NSData *data = - [[NSData alloc] initWithBytesNoCopy:(void *)slice.data() length:slice.size() freeWhenDone:NO]; + NSData *data = [[NSData alloc] initWithBytesNoCopy:(void *)slice.data() + length:slice.size() + freeWhenDone:NO]; NSError *error; FSTPBMutationQueue *proto = [FSTPBMutationQueue parseFromData:data error:&error]; diff --git a/Firestore/Source/Local/FSTLocalSerializer.mm b/Firestore/Source/Local/FSTLocalSerializer.mm index 3b9a34f52ae..5ad70e43c47 100644 --- a/Firestore/Source/Local/FSTLocalSerializer.mm +++ b/Firestore/Source/Local/FSTLocalSerializer.mm @@ -87,8 +87,8 @@ - (FSTPBMaybeDocument *)encodedMaybeDocument:(FSTMaybeDocument *)document { - (FSTMaybeDocument *)decodedMaybeDocument:(FSTPBMaybeDocument *)proto { switch (proto.documentTypeOneOfCase) { case FSTPBMaybeDocument_DocumentType_OneOfCase_Document: - return - [self decodedDocument:proto.document withCommittedMutations:proto.hasCommittedMutations]; + return [self decodedDocument:proto.document + withCommittedMutations:proto.hasCommittedMutations]; case FSTPBMaybeDocument_DocumentType_OneOfCase_NoDocument: return [self decodedDeletedDocument:proto.noDocument diff --git a/Firestore/Source/Local/FSTLocalStore.mm b/Firestore/Source/Local/FSTLocalStore.mm index 129b7c1b2be..90e4cd2f45a 100644 --- a/Firestore/Source/Local/FSTLocalStore.mm +++ b/Firestore/Source/Local/FSTLocalStore.mm @@ -163,8 +163,8 @@ - (MaybeDocumentMap)userDidChange:(const User &)user { - (FSTLocalWriteResult *)locallyWriteMutations:(NSArray *)mutations { return self.persistence.run("Locally write mutations", [&]() -> FSTLocalWriteResult * { FIRTimestamp *localWriteTime = [FIRTimestamp timestamp]; - FSTMutationBatch *batch = - [self.mutationQueue addMutationBatchWithWriteTime:localWriteTime mutations:mutations]; + FSTMutationBatch *batch = [self.mutationQueue addMutationBatchWithWriteTime:localWriteTime + mutations:mutations]; DocumentKeySet keys = [batch keys]; MaybeDocumentMap changedDocuments = [self.localDocuments documentsForKeys:keys]; return [FSTLocalWriteResult resultForBatchID:batch.batchID changes:std::move(changedDocuments)]; @@ -292,11 +292,10 @@ - (MaybeDocumentMap)applyRemoteEvent:(FSTRemoteEvent *)remoteEvent { _remoteDocumentCache->Add(doc); changedDocs = changedDocs.insert(key, doc); } else { - LOG_DEBUG( - "FSTLocalStore Ignoring outdated watch update for %s. " - "Current version: %s Watch version: %s", - key.ToString(), existingDoc.version.timestamp().ToString(), - doc.version.timestamp().ToString()); + LOG_DEBUG("FSTLocalStore Ignoring outdated watch update for %s. " + "Current version: %s Watch version: %s", + key.ToString(), existingDoc.version.timestamp().ToString(), + doc.version.timestamp().ToString()); } // If this was a limbo resolution, make sure we mark when it was accessed. diff --git a/Firestore/Source/Model/FSTDocument.mm b/Firestore/Source/Model/FSTDocument.mm index aaa3964865b..40f5666f641 100644 --- a/Firestore/Source/Model/FSTDocument.mm +++ b/Firestore/Source/Model/FSTDocument.mm @@ -180,8 +180,8 @@ @implementation FSTDeletedDocument { + (instancetype)documentWithKey:(DocumentKey)key version:(SnapshotVersion)version hasCommittedMutations:(BOOL)committedMutations { - FSTDeletedDocument *deletedDocument = - [[FSTDeletedDocument alloc] initWithKey:std::move(key) version:std::move(version)]; + FSTDeletedDocument *deletedDocument = [[FSTDeletedDocument alloc] initWithKey:std::move(key) + version:std::move(version)]; if (deletedDocument) { deletedDocument->_hasCommittedMutations = committedMutations; diff --git a/Firestore/Source/Public/FIRFirestore.h b/Firestore/Source/Public/FIRFirestore.h index 5e2b40fbd8e..f2c914398ee 100644 --- a/Firestore/Source/Public/FIRFirestore.h +++ b/Firestore/Source/Public/FIRFirestore.h @@ -136,9 +136,9 @@ NS_SWIFT_NAME(Firestore) #pragma mark - Logging /** Enables or disables logging from the Firestore client. */ -+ (void)enableLogging:(BOOL)logging DEPRECATED_MSG_ATTRIBUTE( - "Use FirebaseConfiguration.shared.setLoggerLevel(.debug) to enable " - "logging."); ++ (void)enableLogging:(BOOL)logging + DEPRECATED_MSG_ATTRIBUTE("Use FirebaseConfiguration.shared.setLoggerLevel(.debug) to enable " + "logging."); #pragma mark - Network diff --git a/Firestore/Source/Remote/FSTDatastore.mm b/Firestore/Source/Remote/FSTDatastore.mm index 2bf686ec1bd..06ee2f56ee9 100644 --- a/Firestore/Source/Remote/FSTDatastore.mm +++ b/Firestore/Source/Remote/FSTDatastore.mm @@ -128,8 +128,9 @@ + (NSError *)firestoreErrorForError:(NSError *)error { } else if ([error.domain isEqualToString:kGRPCErrorDomain]) { HARD_ASSERT(error.code >= grpc::CANCELLED && error.code <= grpc::UNAUTHENTICATED, "Unknown GRPC error code: %s", error.code); - return - [NSError errorWithDomain:FIRFirestoreErrorDomain code:error.code userInfo:error.userInfo]; + return [NSError errorWithDomain:FIRFirestoreErrorDomain + code:error.code + userInfo:error.userInfo]; } else { return [NSError errorWithDomain:FIRFirestoreErrorDomain code:FIRFirestoreErrorCodeUnknown diff --git a/Firestore/Source/Remote/FSTSerializerBeta.mm b/Firestore/Source/Remote/FSTSerializerBeta.mm index 65192fd6812..f6167a20094 100644 --- a/Firestore/Source/Remote/FSTSerializerBeta.mm +++ b/Firestore/Source/Remote/FSTSerializerBeta.mm @@ -1169,8 +1169,9 @@ - (FSTDocumentWatchChange *)decodedDocumentDelete:(GCFSDocumentDelete *)change { const DocumentKey key = [self decodedDocumentKey:change.document]; // Note that version might be unset in which case we use SnapshotVersion::None() SnapshotVersion version = [self decodedVersion:change.readTime]; - FSTMaybeDocument *document = - [FSTDeletedDocument documentWithKey:key version:version hasCommittedMutations:NO]; + FSTMaybeDocument *document = [FSTDeletedDocument documentWithKey:key + version:version + hasCommittedMutations:NO]; NSArray *removedTargetIds = [self decodedIntegerArray:change.removedTargetIdsArray]; diff --git a/Firestore/core/src/firebase/firestore/local/leveldb_query_cache.mm b/Firestore/core/src/firebase/firestore/local/leveldb_query_cache.mm index 454c2b625c7..bec5725e3e5 100644 --- a/Firestore/core/src/firebase/firestore/local/leveldb_query_cache.mm +++ b/Firestore/core/src/firebase/firestore/local/leveldb_query_cache.mm @@ -58,8 +58,8 @@ freeWhenDone:NO]; NSError* error; - FSTPBTargetGlobal* proto = - [FSTPBTargetGlobal parseFromData:data error:&error]; + FSTPBTargetGlobal* proto = [FSTPBTargetGlobal parseFromData:data + error:&error]; if (!proto) { HARD_FAIL("FSTPBTargetGlobal failed to parse: %s", error); } @@ -153,11 +153,10 @@ std::string target_key = LevelDbTargetKey::Key(row_key.target_id()); target_iterator->Seek(target_key); if (!target_iterator->Valid() || target_iterator->key() != target_key) { - HARD_FAIL( - "Dangling query-target reference found: " - "%s points to %s; seeking there found %s", - DescribeKey(index_iterator), DescribeKey(target_key), - DescribeKey(target_iterator)); + HARD_FAIL("Dangling query-target reference found: " + "%s points to %s; seeking there found %s", + DescribeKey(index_iterator), DescribeKey(target_key), + DescribeKey(target_iterator)); } // Finally after finding a potential match, check that the query is actually diff --git a/Firestore/core/src/firebase/firestore/local/leveldb_remote_document_cache.mm b/Firestore/core/src/firebase/firestore/local/leveldb_remote_document_cache.mm index 1a8bbeaecc6..b30aa705c90 100644 --- a/Firestore/core/src/firebase/firestore/local/leveldb_remote_document_cache.mm +++ b/Firestore/core/src/firebase/firestore/local/leveldb_remote_document_cache.mm @@ -120,8 +120,8 @@ freeWhenDone:NO]; NSError* error; - FSTPBMaybeDocument* proto = - [FSTPBMaybeDocument parseFromData:data error:&error]; + FSTPBMaybeDocument* proto = [FSTPBMaybeDocument parseFromData:data + error:&error]; if (!proto) { HARD_FAIL("FSTPBMaybeDocument failed to parse: %s", error); } diff --git a/Firestore/core/src/firebase/firestore/model/field_value.cc b/Firestore/core/src/firebase/firestore/model/field_value.cc index f21aa9b11f5..16309a92722 100644 --- a/Firestore/core/src/firebase/firestore/model/field_value.cc +++ b/Firestore/core/src/firebase/firestore/model/field_value.cc @@ -466,7 +466,8 @@ void FieldValue::SwitchTo(const Type type) { case Type::Object: object_value_.internal_value.~map(); break; - default: {} // The other types where there is nothing to worry about. + default: { + } // The other types where there is nothing to worry about. } tag_ = type; // Must call constructor explicitly for any non-POD type to initialize. @@ -497,7 +498,8 @@ void FieldValue::SwitchTo(const Type type) { case Type::Object: new (&object_value_) ObjectValue{}; break; - default: {} // The other types where there is nothing to worry about. + default: { + } // The other types where there is nothing to worry about. } } diff --git a/Firestore/core/src/firebase/firestore/remote/remote_objc_bridge.mm b/Firestore/core/src/firebase/firestore/remote/remote_objc_bridge.mm index 062c003904c..5d5bebf8447 100644 --- a/Firestore/core/src/firebase/firestore/remote/remote_objc_bridge.mm +++ b/Firestore/core/src/firebase/firestore/remote/remote_objc_bridge.mm @@ -100,12 +100,12 @@ } } - std::string error_description = StringFormat( - "Unable to parse response from the server.\n" - "Underlying error: %s\n" - "Expected class: %s\n" - "Received value: %s\n", - error, [Proto class], ToHexString(message)); + std::string error_description = + StringFormat("Unable to parse response from the server.\n" + "Underlying error: %s\n" + "Expected class: %s\n" + "Received value: %s\n", + error, [Proto class], ToHexString(message)); *out_status = {FirestoreErrorCode::Internal, error_description}; return nil; diff --git a/Firestore/core/test/firebase/firestore/auth/firebase_credentials_provider_test.mm b/Firestore/core/test/firebase/firestore/auth/firebase_credentials_provider_test.mm index 6df629b8629..807845b6f1d 100644 --- a/Firestore/core/test/firebase/firestore/auth/firebase_credentials_provider_test.mm +++ b/Firestore/core/test/firebase/firestore/auth/firebase_credentials_provider_test.mm @@ -112,8 +112,8 @@ - (void)getTokenForcingRefresh:(BOOL)forceRefresh TEST(FirebaseCredentialsProviderTest, GetToken) { FIRApp* app = testutil::AppForUnitTesting(); - FSTAuthFake* auth = - [[FSTAuthFake alloc] initWithToken:@"token for fake uid" uid:@"fake uid"]; + FSTAuthFake* auth = [[FSTAuthFake alloc] initWithToken:@"token for fake uid" + uid:@"fake uid"]; FirebaseCredentialsProvider credentials_provider(app, auth); credentials_provider.GetToken([](util::StatusOr result) { EXPECT_TRUE(result.ok()); @@ -127,8 +127,8 @@ - (void)getTokenForcingRefresh:(BOOL)forceRefresh TEST(FirebaseCredentialsProviderTest, SetListener) { FIRApp* app = testutil::AppForUnitTesting(); - FSTAuthFake* auth = - [[FSTAuthFake alloc] initWithToken:@"default token" uid:@"fake uid"]; + FSTAuthFake* auth = [[FSTAuthFake alloc] initWithToken:@"default token" + uid:@"fake uid"]; FirebaseCredentialsProvider credentials_provider(app, auth); credentials_provider.SetCredentialChangeListener([](User user) { EXPECT_EQ("fake uid", user.uid()); @@ -140,8 +140,8 @@ - (void)getTokenForcingRefresh:(BOOL)forceRefresh TEST(FirebaseCredentialsProviderTest, InvalidateToken) { FIRApp* app = testutil::AppForUnitTesting(); - FSTAuthFake* auth = - [[FSTAuthFake alloc] initWithToken:@"token for fake uid" uid:@"fake uid"]; + FSTAuthFake* auth = [[FSTAuthFake alloc] initWithToken:@"token for fake uid" + uid:@"fake uid"]; FirebaseCredentialsProvider credentials_provider(app, auth); credentials_provider.InvalidateToken(); credentials_provider.GetToken([&auth](util::StatusOr result) { diff --git a/Firestore/core/test/firebase/firestore/remote/datastore_test.mm b/Firestore/core/test/firebase/firestore/remote/datastore_test.mm index ee6a18b268f..34d14441a11 100644 --- a/Firestore/core/test/firebase/firestore/remote/datastore_test.mm +++ b/Firestore/core/test/firebase/firestore/remote/datastore_test.mm @@ -161,13 +161,12 @@ void ForceFinishAnyTypeOrder( {"x-google-service", "service 2"}, // Duplicate names are allowed }; std::string result = Datastore::GetWhitelistedHeadersAsString(headers); - EXPECT_EQ(result, - "date: date value\n" - "x-google-backends: backend value\n" - "x-google-gfe-request-trace: request trace\n" - "x-google-netmon-label: netmon label\n" - "x-google-service: service 1\n" - "x-google-service: service 2\n"); + EXPECT_EQ(result, "date: date value\n" + "x-google-backends: backend value\n" + "x-google-gfe-request-trace: request trace\n" + "x-google-netmon-label: netmon label\n" + "x-google-service: service 1\n" + "x-google-service: service 2\n"); } // Normal operation diff --git a/Functions/Example/IntegrationTests/FIRIntegrationTests.m b/Functions/Example/IntegrationTests/FIRIntegrationTests.m index 4f8b750052b..ce7e1215484 100644 --- a/Functions/Example/IntegrationTests/FIRIntegrationTests.m +++ b/Functions/Example/IntegrationTests/FIRIntegrationTests.m @@ -90,11 +90,11 @@ - (void)testToken { XCTestExpectation *expectation = [[XCTestExpectation alloc] init]; FIRHTTPSCallable *function = [functions HTTPSCallableWithName:@"tokenTest"]; [function callWithObject:@{} - completion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) { - XCTAssertNil(error); - XCTAssertEqualObjects(@{}, result.data); - [expectation fulfill]; - }]; + completion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) { + XCTAssertNil(error); + XCTAssertEqualObjects(@{}, result.data); + [expectation fulfill]; + }]; [self waitForExpectations:@[ expectation ] timeout:10]; } @@ -102,11 +102,11 @@ - (void)testInstanceID { XCTestExpectation *expectation = [[XCTestExpectation alloc] init]; FIRHTTPSCallable *function = [_functions HTTPSCallableWithName:@"instanceIdTest"]; [function callWithObject:@{} - completion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) { - XCTAssertNil(error); - XCTAssertEqualObjects(@{}, result.data); - [expectation fulfill]; - }]; + completion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) { + XCTAssertNil(error); + XCTAssertEqualObjects(@{}, result.data); + [expectation fulfill]; + }]; [self waitForExpectations:@[ expectation ] timeout:10]; } @@ -148,11 +148,11 @@ - (void)testUnhandledError { XCTestExpectation *expectation = [[XCTestExpectation alloc] init]; FIRHTTPSCallable *function = [_functions HTTPSCallableWithName:@"unhandledErrorTest"]; [function callWithObject:@{} - completion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) { - XCTAssertNotNil(error); - XCTAssertEqual(FIRFunctionsErrorCodeInternal, error.code); - [expectation fulfill]; - }]; + completion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) { + XCTAssertNotNil(error); + XCTAssertEqual(FIRFunctionsErrorCodeInternal, error.code); + [expectation fulfill]; + }]; [self waitForExpectations:@[ expectation ] timeout:10]; } @@ -160,26 +160,27 @@ - (void)testUnknownError { XCTestExpectation *expectation = [[XCTestExpectation alloc] init]; FIRHTTPSCallable *function = [_functions HTTPSCallableWithName:@"unknownErrorTest"]; [function callWithObject:@{} - completion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) { - XCTAssertNotNil(error); - XCTAssertEqual(FIRFunctionsErrorCodeInternal, error.code); - [expectation fulfill]; - }]; + completion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) { + XCTAssertNotNil(error); + XCTAssertEqual(FIRFunctionsErrorCodeInternal, error.code); + [expectation fulfill]; + }]; [self waitForExpectations:@[ expectation ] timeout:10]; } - (void)testExplicitError { XCTestExpectation *expectation = [[XCTestExpectation alloc] init]; FIRHTTPSCallable *function = [_functions HTTPSCallableWithName:@"explicitErrorTest"]; - [function callWithObject:@{} - completion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) { - XCTAssertNotNil(error); - XCTAssertEqual(FIRFunctionsErrorCodeOutOfRange, error.code); - XCTAssertEqualObjects(@"explicit nope", error.userInfo[NSLocalizedDescriptionKey]); - NSDictionary *expectedDetails = @{@"start" : @10, @"end" : @20, @"long" : @30L}; - XCTAssertEqualObjects(expectedDetails, error.userInfo[FIRFunctionsErrorDetailsKey]); - [expectation fulfill]; - }]; + [function + callWithObject:@{} + completion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) { + XCTAssertNotNil(error); + XCTAssertEqual(FIRFunctionsErrorCodeOutOfRange, error.code); + XCTAssertEqualObjects(@"explicit nope", error.userInfo[NSLocalizedDescriptionKey]); + NSDictionary *expectedDetails = @{@"start" : @10, @"end" : @20, @"long" : @30L}; + XCTAssertEqualObjects(expectedDetails, error.userInfo[FIRFunctionsErrorDetailsKey]); + [expectation fulfill]; + }]; [self waitForExpectations:@[ expectation ] timeout:10]; } @@ -187,11 +188,11 @@ - (void)testHttpError { XCTestExpectation *expectation = [[XCTestExpectation alloc] init]; FIRHTTPSCallable *function = [_functions HTTPSCallableWithName:@"httpErrorTest"]; [function callWithObject:@{} - completion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) { - XCTAssertNotNil(error); - XCTAssertEqual(FIRFunctionsErrorCodeInvalidArgument, error.code); - [expectation fulfill]; - }]; + completion:^(FIRHTTPSCallableResult *_Nullable result, NSError *_Nullable error) { + XCTAssertNotNil(error); + XCTAssertEqual(FIRFunctionsErrorCodeInvalidArgument, error.code); + [expectation fulfill]; + }]; [self waitForExpectations:@[ expectation ] timeout:10]; } diff --git a/Functions/Example/Tests/FIRFunctionsTests.m b/Functions/Example/Tests/FIRFunctionsTests.m index 954a0015002..875a8171942 100644 --- a/Functions/Example/Tests/FIRFunctionsTests.m +++ b/Functions/Example/Tests/FIRFunctionsTests.m @@ -31,8 +31,9 @@ - (void)tearDown { } - (void)testURLWithName { - FIRFunctions *functions = - [[FIRFunctions alloc] initWithProjectID:@"my-project" region:@"my-region" auth:nil]; + FIRFunctions *functions = [[FIRFunctions alloc] initWithProjectID:@"my-project" + region:@"my-region" + auth:nil]; NSString *url = [functions URLWithName:@"my-endpoint"]; XCTAssertEqualObjects(@"https://my-region-my-project.cloudfunctions.net/my-endpoint", url); } diff --git a/Functions/FirebaseFunctions/FIRFunctions.m b/Functions/FirebaseFunctions/FIRFunctions.m index 9342db52e93..115ebc88539 100644 --- a/Functions/FirebaseFunctions/FIRFunctions.m +++ b/Functions/FirebaseFunctions/FIRFunctions.m @@ -85,8 +85,8 @@ + (void)load { *isCacheable = YES; return [self functionsForApp:container.app]; }; - FIRDependency *auth = - [FIRDependency dependencyWithProtocol:@protocol(FIRAuthInterop) isRequired:NO]; + FIRDependency *auth = [FIRDependency dependencyWithProtocol:@protocol(FIRAuthInterop) + isRequired:NO]; FIRComponent *internalProvider = [FIRComponent componentWithProtocol:@protocol(FIRFunctionsInstanceProvider) instantiationTiming:FIRInstantiationTimingLazy diff --git a/GoogleUtilities/AppDelegateSwizzler/GULAppDelegateSwizzler.m b/GoogleUtilities/AppDelegateSwizzler/GULAppDelegateSwizzler.m index 59f400dcc6c..bb71991b0e7 100644 --- a/GoogleUtilities/AppDelegateSwizzler/GULAppDelegateSwizzler.m +++ b/GoogleUtilities/AppDelegateSwizzler/GULAppDelegateSwizzler.m @@ -335,8 +335,8 @@ + (void)createSubclassWithObject:(id)anObject { NSValue *continueUserActivityIMPPointer = [NSValue valueWithPointer:continueUserActivityIMP]; // For application:openURL:sourceApplication:annotation: - SEL openURLSourceApplicationAnnotationSEL = - @selector(application:openURL:sourceApplication:annotation:); + SEL openURLSourceApplicationAnnotationSEL = @selector(application: + openURL:sourceApplication:annotation:); [GULAppDelegateSwizzler addInstanceMethodWithSelector:openURLSourceApplicationAnnotationSEL fromClass:[GULAppDelegateSwizzler class] toClass:appDelegateSubClass]; @@ -348,8 +348,8 @@ + (void)createSubclassWithObject:(id)anObject { [NSValue valueWithPointer:openURLSourceApplicationAnnotationIMP]; // For application:handleEventsForBackgroundURLSession:completionHandler: - SEL handleEventsForBackgroundURLSessionSEL = - @selector(application:handleEventsForBackgroundURLSession:completionHandler:); + SEL handleEventsForBackgroundURLSessionSEL = @selector(application: + handleEventsForBackgroundURLSession:completionHandler:); [GULAppDelegateSwizzler addInstanceMethodWithSelector:handleEventsForBackgroundURLSessionSEL fromClass:[GULAppDelegateSwizzler class] toClass:appDelegateSubClass]; @@ -602,8 +602,8 @@ - (void)application:(UIApplication *)application [handleBackgroundSessionPointer pointerValue]; // Notify interceptors. - SEL methodSelector = - @selector(application:handleEventsForBackgroundURLSession:completionHandler:); + SEL methodSelector = @selector(application: + handleEventsForBackgroundURLSession:completionHandler:); [GULAppDelegateSwizzler notifyInterceptorsWithMethodSelector:methodSelector callback:^(id interceptor) { diff --git a/GoogleUtilities/Example/Tests/Network/GULNetworkTest.m b/GoogleUtilities/Example/Tests/Network/GULNetworkTest.m index 4d315037cf4..0fb973bf4df 100644 --- a/GoogleUtilities/Example/Tests/Network/GULNetworkTest.m +++ b/GoogleUtilities/Example/Tests/Network/GULNetworkTest.m @@ -93,8 +93,8 @@ - (void)testReachability { XCTAssertNotNil(reachability); id reachabilityMock = OCMPartialMock(reachability); - [[[reachabilityMock stub] andCall:@selector(reachabilityStatus) onObject:self] - reachabilityStatus]; + [[[reachabilityMock stub] andCall:@selector(reachabilityStatus) + onObject:self] reachabilityStatus]; // Fake scenario with connectivity. _fakeNetworkIsReachable = YES; @@ -504,8 +504,8 @@ - (void)testSessionNetworkAsync_GET_foreground { usingBackgroundSession:NO completionHandler:^(NSHTTPURLResponse *response, NSData *data, NSError *error) { XCTAssertNotNil(data); - NSString *responseBody = - [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + NSString *responseBody = [[NSString alloc] initWithData:data + encoding:NSUTF8StringEncoding]; XCTAssertEqualObjects(responseBody, @"Hello, World!"); XCTAssertNil(error); XCTAssertFalse(self->_network.hasUploadInProgress, "There must be no pending request"); @@ -601,8 +601,8 @@ - (void)testNilQueueNSURLSession_GET_foreground { usingBackgroundSession:NO completionHandler:^(NSHTTPURLResponse *response, NSData *data, NSError *error) { XCTAssertNotNil(data); - NSString *responseBody = - [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + NSString *responseBody = [[NSString alloc] initWithData:data + encoding:NSUTF8StringEncoding]; XCTAssertEqualObjects(responseBody, @"Hello, World!"); XCTAssertNil(error); XCTAssertFalse(self->_network.hasUploadInProgress, "There must be no pending request"); @@ -631,8 +631,8 @@ - (void)testHasRequestPendingNSURLSession_GET_foreground { usingBackgroundSession:NO completionHandler:^(NSHTTPURLResponse *response, NSData *data, NSError *error) { XCTAssertNotNil(data); - NSString *responseBody = - [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + NSString *responseBody = [[NSString alloc] initWithData:data + encoding:NSUTF8StringEncoding]; XCTAssertEqualObjects(responseBody, @"Hello, World!"); XCTAssertNil(error); XCTAssertFalse(self->_network.hasUploadInProgress, @@ -665,8 +665,8 @@ - (void)testHeaders_foreground { usingBackgroundSession:NO completionHandler:^(NSHTTPURLResponse *response, NSData *data, NSError *error) { XCTAssertNotNil(data); - NSString *responseBody = - [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + NSString *responseBody = [[NSString alloc] initWithData:data + encoding:NSUTF8StringEncoding]; XCTAssertEqualObjects(responseBody, @"Hello, World!"); XCTAssertNil(error); @@ -700,8 +700,8 @@ - (void)testSessionNetworkAsync_GET_background { usingBackgroundSession:YES completionHandler:^(NSHTTPURLResponse *response, NSData *data, NSError *error) { XCTAssertNotNil(data); - NSString *responseBody = - [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + NSString *responseBody = [[NSString alloc] initWithData:data + encoding:NSUTF8StringEncoding]; XCTAssertEqualObjects(responseBody, @"Hello, World!"); XCTAssertNil(error); XCTAssertFalse(self->_network.hasUploadInProgress, "There must be no pending request"); @@ -797,8 +797,8 @@ - (void)testNilQueueNSURLSession_GET_background { usingBackgroundSession:YES completionHandler:^(NSHTTPURLResponse *response, NSData *data, NSError *error) { XCTAssertNotNil(data); - NSString *responseBody = - [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + NSString *responseBody = [[NSString alloc] initWithData:data + encoding:NSUTF8StringEncoding]; XCTAssertEqualObjects(responseBody, @"Hello, World!"); XCTAssertNil(error); XCTAssertFalse(self->_network.hasUploadInProgress, "There must be no pending request"); @@ -827,8 +827,8 @@ - (void)testHasRequestPendingNSURLSession_GET_background { usingBackgroundSession:YES completionHandler:^(NSHTTPURLResponse *response, NSData *data, NSError *error) { XCTAssertNotNil(data); - NSString *responseBody = - [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + NSString *responseBody = [[NSString alloc] initWithData:data + encoding:NSUTF8StringEncoding]; XCTAssertEqualObjects(responseBody, @"Hello, World!"); XCTAssertNil(error); XCTAssertFalse(self->_network.hasUploadInProgress, @@ -861,8 +861,8 @@ - (void)testHeaders_background { usingBackgroundSession:YES completionHandler:^(NSHTTPURLResponse *response, NSData *data, NSError *error) { XCTAssertNotNil(data); - NSString *responseBody = - [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; + NSString *responseBody = [[NSString alloc] initWithData:data + encoding:NSUTF8StringEncoding]; XCTAssertEqualObjects(responseBody, @"Hello, World!"); XCTAssertNil(error); @@ -953,8 +953,8 @@ - (void)verifyRequest { // Test whether the request is compressed correctly. NSData *requestBody = [_request body]; NSData *decompressedRequestData = [NSData gul_dataByInflatingGzippedData:requestBody error:NULL]; - NSString *requestString = - [[NSString alloc] initWithData:decompressedRequestData encoding:NSUTF8StringEncoding]; + NSString *requestString = [[NSString alloc] initWithData:decompressedRequestData + encoding:NSUTF8StringEncoding]; XCTAssertEqualObjects(requestString, @"Google", @"Request is not compressed correctly."); // The request has to be a POST. diff --git a/GoogleUtilities/Example/Tests/Reachability/GULReachabilityCheckerTest.m b/GoogleUtilities/Example/Tests/Reachability/GULReachabilityCheckerTest.m index da9fbf13fbc..07cf2750d28 100644 --- a/GoogleUtilities/Example/Tests/Reachability/GULReachabilityCheckerTest.m +++ b/GoogleUtilities/Example/Tests/Reachability/GULReachabilityCheckerTest.m @@ -58,8 +58,8 @@ - (void)releaseReachability:(const void *)reachability; static SCNetworkReachabilityRef ReachabilityCreateWithName(CFAllocatorRef allocator, const char *hostname) { - return (SCNetworkReachabilityRef) - [FakeReachabilityTest createReachabilityWithAllocator:allocator withName:hostname]; + return (SCNetworkReachabilityRef)[FakeReachabilityTest createReachabilityWithAllocator:allocator + withName:hostname]; } static Boolean ReachabilitySetCallback(SCNetworkReachabilityRef reachability, diff --git a/GoogleUtilities/Example/Tests/Swizzler/GULAppDelegateSwizzlerTest.m b/GoogleUtilities/Example/Tests/Swizzler/GULAppDelegateSwizzlerTest.m index e9fa793be9d..4eb1cbc9cdf 100644 --- a/GoogleUtilities/Example/Tests/Swizzler/GULAppDelegateSwizzlerTest.m +++ b/GoogleUtilities/Example/Tests/Swizzler/GULAppDelegateSwizzlerTest.m @@ -98,8 +98,8 @@ + (void)load { gRespondsToOpenURLHandler_iOS9 = [self instancesRespondToSelector:@selector(application:openURL:options:)]; gRespondsToHandleBackgroundSession = - [self instancesRespondToSelector:@selector - (application:handleEventsForBackgroundURLSession:completionHandler:)]; + [self instancesRespondToSelector:@selector(application: + handleEventsForBackgroundURLSession:completionHandler:)]; gRespondsToContinueUserActivity = [self instancesRespondToSelector:@selector(application:continueUserActivity:restorationHandler:)]; #pragma clang diagnostic pop @@ -236,12 +236,12 @@ - (void)testProxyAppDelegate { // After being proxied, it should be able to respond to the required method selector. XCTAssertTrue([realAppDelegate respondsToSelector:@selector(application:openURL:sourceApplication:annotation:)]); - XCTAssertTrue([realAppDelegate - respondsToSelector:@selector(application:continueUserActivity:restorationHandler:)]); + XCTAssertTrue([realAppDelegate respondsToSelector:@selector(application: + continueUserActivity:restorationHandler:)]); XCTAssertTrue([realAppDelegate respondsToSelector:@selector(application:openURL:options:)]); - XCTAssertTrue( - [realAppDelegate respondsToSelector:@selector - (application:handleEventsForBackgroundURLSession:completionHandler:)]); + XCTAssertTrue([realAppDelegate + respondsToSelector:@selector(application: + handleEventsForBackgroundURLSession:completionHandler:)]); // Make sure that the class has changed. XCTAssertNotEqualObjects([realAppDelegate class], realAppDelegateClassBefore); diff --git a/GoogleUtilities/Example/Tests/Swizzler/GULRuntimeStateHelperTests.m b/GoogleUtilities/Example/Tests/Swizzler/GULRuntimeStateHelperTests.m index 9edc6410bd1..6d5ae6bab70 100644 --- a/GoogleUtilities/Example/Tests/Swizzler/GULRuntimeStateHelperTests.m +++ b/GoogleUtilities/Example/Tests/Swizzler/GULRuntimeStateHelperTests.m @@ -72,9 +72,8 @@ - (void)testDiffBetweenFirstSnapshotSecondSnapshot { } } } - XCTAssertTrue(found, - @"One of the classdiffs should contain the address of the original IMP of " - "the method that was modified above"); + XCTAssertTrue(found, @"One of the classdiffs should contain the address of the original IMP of " + "the method that was modified above"); } #pragma mark - Helper methods diff --git a/GoogleUtilities/Example/Tests/Swizzler/GULSwizzlerTest.m b/GoogleUtilities/Example/Tests/Swizzler/GULSwizzlerTest.m index e4cd2888f61..ea3017d00d8 100644 --- a/GoogleUtilities/Example/Tests/Swizzler/GULSwizzlerTest.m +++ b/GoogleUtilities/Example/Tests/Swizzler/GULSwizzlerTest.m @@ -90,10 +90,12 @@ - (void)testOriginalImpInstanceMethod { - (void)testCurrentImplementationReturnsDifferentIMPsForClassAndInstanceMethod { Class aClass = [NSObject class]; SEL aSelector = @selector(description); - IMP descriptionClassIMP = - [GULSwizzler currentImplementationForClass:aClass selector:aSelector isClassSelector:NO]; - IMP descriptionInstanceIMP = - [GULSwizzler currentImplementationForClass:aClass selector:aSelector isClassSelector:YES]; + IMP descriptionClassIMP = [GULSwizzler currentImplementationForClass:aClass + selector:aSelector + isClassSelector:NO]; + IMP descriptionInstanceIMP = [GULSwizzler currentImplementationForClass:aClass + selector:aSelector + isClassSelector:YES]; XCTAssertNotEqual(descriptionClassIMP, descriptionInstanceIMP); } @@ -103,10 +105,12 @@ - (void)testCurrentImplementationReturnsDifferentIMPsForClassAndInstanceMethod { - (void)testCurrentImplementationReturnsSameIMPsWhenNotSwizzledBetweenInvocations { Class aClass = [NSObject class]; SEL aSelector = @selector(description); - IMP descriptionClassIMPOne = - [GULSwizzler currentImplementationForClass:aClass selector:aSelector isClassSelector:NO]; - IMP descriptionClassIMPTwo = - [GULSwizzler currentImplementationForClass:aClass selector:aSelector isClassSelector:NO]; + IMP descriptionClassIMPOne = [GULSwizzler currentImplementationForClass:aClass + selector:aSelector + isClassSelector:NO]; + IMP descriptionClassIMPTwo = [GULSwizzler currentImplementationForClass:aClass + selector:aSelector + isClassSelector:NO]; XCTAssertEqual(descriptionClassIMPOne, descriptionClassIMPTwo); } @@ -116,8 +120,9 @@ - (void)testCurrentImplementationReturnsSameIMPsWhenNotSwizzledBetweenInvocation - (void)testCurrentImplementationReturnsDifferentIMPsWhenSwizzledBetweenInvocations { Class aClass = [NSObject class]; SEL aSelector = @selector(description); - IMP originalIMP = - [GULSwizzler currentImplementationForClass:aClass selector:aSelector isClassSelector:NO]; + IMP originalIMP = [GULSwizzler currentImplementationForClass:aClass + selector:aSelector + isClassSelector:NO]; NSString * (^newImplementation)(id) = ^NSString *(id _self) { return @"nonsense"; }; @@ -125,8 +130,9 @@ - (void)testCurrentImplementationReturnsDifferentIMPsWhenSwizzledBetweenInvocati selector:aSelector isClassSelector:NO withBlock:newImplementation]; - IMP newIMP = - [GULSwizzler currentImplementationForClass:aClass selector:aSelector isClassSelector:NO]; + IMP newIMP = [GULSwizzler currentImplementationForClass:aClass + selector:aSelector + isClassSelector:NO]; XCTAssertNotEqual(newIMP, originalIMP); [GULSwizzler unswizzleClass:aClass selector:aSelector isClassSelector:NO]; } @@ -136,8 +142,9 @@ - (void)testOriginalImpCallThrough { SEL selector = @selector(description); Class aClass = [NSObject class]; id newDescription = ^NSString *(id object) { - IMP originalImp = - [GULSwizzler originalImplementationForClass:aClass selector:selector isClassSelector:NO]; + IMP originalImp = [GULSwizzler originalImplementationForClass:aClass + selector:selector + isClassSelector:NO]; NSString *originalDescription = GUL_INVOKE_ORIGINAL_IMP0(object, selector, NSString *, originalImp); diff --git a/GoogleUtilities/Logger/GULLogger.m b/GoogleUtilities/Logger/GULLogger.m index 4feb77a537c..495e5830bb0 100644 --- a/GoogleUtilities/Logger/GULLogger.m +++ b/GoogleUtilities/Logger/GULLogger.m @@ -72,8 +72,9 @@ void GULLoggerInitializeASL(void) { dispatch_set_target_queue(sGULClientQueue, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0)); #ifdef DEBUG - sMessageCodeRegex = - [NSRegularExpression regularExpressionWithPattern:kMessageCodePattern options:0 error:NULL]; + sMessageCodeRegex = [NSRegularExpression regularExpressionWithPattern:kMessageCodePattern + options:0 + error:NULL]; #endif }); } @@ -155,8 +156,9 @@ void GULLogBasic(GULLoggerLevel level, #ifdef DEBUG NSCAssert(messageCode.length == 11, @"Incorrect message code length."); NSRange messageCodeRange = NSMakeRange(0, messageCode.length); - NSUInteger numberOfMatches = - [sMessageCodeRegex numberOfMatchesInString:messageCode options:0 range:messageCodeRange]; + NSUInteger numberOfMatches = [sMessageCodeRegex numberOfMatchesInString:messageCode + options:0 + range:messageCodeRange]; NSCAssert(numberOfMatches == 1, @"Incorrect message code format."); #endif NSString *logMsg = [[NSString alloc] initWithFormat:message arguments:args_ptr]; diff --git a/GoogleUtilities/MethodSwizzler/GULSwizzler.m b/GoogleUtilities/MethodSwizzler/GULSwizzler.m index 9839124dd3f..e58df96888b 100644 --- a/GoogleUtilities/MethodSwizzler/GULSwizzler.m +++ b/GoogleUtilities/MethodSwizzler/GULSwizzler.m @@ -98,8 +98,8 @@ + (void)unswizzleClass:(Class)aClass selector:(SEL)selector isClassSelector:(BOO method = class_getInstanceMethod(aClass, selector); } NSAssert(method, @"Couldn't find the method you're unswizzling in the runtime."); - IMP originalImp = - [[GULSwizzlingCache sharedInstance] cachedIMPForClass:resolvedClass withSelector:selector]; + IMP originalImp = [[GULSwizzlingCache sharedInstance] cachedIMPForClass:resolvedClass + withSelector:selector]; NSAssert(originalImp, @"This class/selector combination hasn't been swizzled"); IMP currentImp = method_setImplementation(method, originalImp); BOOL didRemoveBlock = imp_removeBlock(currentImp); @@ -120,8 +120,8 @@ + (nullable IMP)originalImplementationForClass:(Class)aClass __block IMP originalImp = nil; dispatch_sync(GetGULSwizzlingQueue(), ^{ Class resolvedClass = isClassSelector ? object_getClass(aClass) : aClass; - originalImp = - [[GULSwizzlingCache sharedInstance] cachedIMPForClass:resolvedClass withSelector:selector]; + originalImp = [[GULSwizzlingCache sharedInstance] cachedIMPForClass:resolvedClass + withSelector:selector]; NSAssert(originalImp, @"The IMP for this class/selector combo doesn't exist (%@, %@).", NSStringFromClass(resolvedClass), NSStringFromSelector(selector)); }); diff --git a/GoogleUtilities/Network/GULNetwork.m b/GoogleUtilities/Network/GULNetwork.m index 233500b5cd0..c3227278b8b 100644 --- a/GoogleUtilities/Network/GULNetwork.m +++ b/GoogleUtilities/Network/GULNetwork.m @@ -257,12 +257,12 @@ - (void)setLoggerDelegate:(id)loggerDelegate { // Explicitly check whether the delegate responds to the methods because conformsToProtocol does // not work correctly even though the delegate does respond to the methods. if (!loggerDelegate || - ![loggerDelegate - respondsToSelector:@selector(GULNetwork_logWithLevel:messageCode:message:contexts:)] || - ![loggerDelegate - respondsToSelector:@selector(GULNetwork_logWithLevel:messageCode:message:context:)] || - ! - [loggerDelegate respondsToSelector:@selector(GULNetwork_logWithLevel:messageCode:message:)]) { + ![loggerDelegate respondsToSelector:@selector(GULNetwork_logWithLevel: + messageCode:message:contexts:)] || + ![loggerDelegate respondsToSelector:@selector(GULNetwork_logWithLevel: + messageCode:message:context:)] || + ![loggerDelegate respondsToSelector:@selector(GULNetwork_logWithLevel: + messageCode:message:)]) { GULLogError(kGULLoggerNetwork, NO, [NSString stringWithFormat:@"I-NET%06ld", (long)kGULNetworkMessageCodeNetwork002], @"Cannot set the network logger delegate: delegate does not conform to the network " @@ -279,8 +279,9 @@ - (void)handleErrorWithCode:(NSInteger)code queue:(dispatch_queue_t)queue withHandler:(GULNetworkCompletionHandler)handler { NSDictionary *userInfo = @{kGULNetworkErrorContext : @"Failed to create network request"}; - NSError *error = - [[NSError alloc] initWithDomain:kGULNetworkErrorDomain code:code userInfo:userInfo]; + NSError *error = [[NSError alloc] initWithDomain:kGULNetworkErrorDomain + code:code + userInfo:userInfo]; [self GULNetwork_logWithLevel:kGULNetworkLogLevelWarning messageCode:kGULNetworkMessageCodeNetwork002 message:@"Failed to create network request. Code, error" diff --git a/GoogleUtilities/Network/GULNetworkURLSession.m b/GoogleUtilities/Network/GULNetworkURLSession.m index 257290cc7b1..416a7360195 100644 --- a/GoogleUtilities/Network/GULNetworkURLSession.m +++ b/GoogleUtilities/Network/GULNetworkURLSession.m @@ -413,9 +413,8 @@ - (void)addSystemCompletionHandler:(GULNetworkSystemCompletionHandler)handler [_loggerDelegate GULNetwork_logWithLevel:kGULNetworkLogLevelError messageCode:kGULNetworkMessageCodeURLSession010 - message: - @"Cannot store system completion handler with empty network " - "session identifier"]; + message:@"Cannot store system completion handler with empty network " + "session identifier"]; return; } @@ -517,8 +516,9 @@ - (void)maybeRemoveTempFilesAtURL:(NSURL *)folderURL expiringTime:(NSTimeInterva NSTimeInterval now = [NSDate date].timeIntervalSince1970; for (NSURL *tempFile in directoryContent) { NSDate *creationDate; - BOOL getCreationDate = - [tempFile getResourceValue:&creationDate forKey:NSURLCreationDateKey error:NULL]; + BOOL getCreationDate = [tempFile getResourceValue:&creationDate + forKey:NSURLCreationDateKey + error:NULL]; if (!getCreationDate) { continue; } diff --git a/GoogleUtilities/SwizzlerTestHelpers/GULProxy.m b/GoogleUtilities/SwizzlerTestHelpers/GULProxy.m index 7f9ea9f8e56..d9bd693181f 100644 --- a/GoogleUtilities/SwizzlerTestHelpers/GULProxy.m +++ b/GoogleUtilities/SwizzlerTestHelpers/GULProxy.m @@ -64,11 +64,11 @@ - (Class)superclass { return [_delegateObject superclass]; } -- (Class) class { +- (Class)class { return [_delegateObject class]; } - - (BOOL)isKindOfClass : (Class)aClass { +- (BOOL)isKindOfClass:(Class)aClass { return [_delegateObject isKindOfClass:aClass]; } diff --git a/scripts/style.sh b/scripts/style.sh index b464097b266..aaaac8b0ff6 100755 --- a/scripts/style.sh +++ b/scripts/style.sh @@ -39,8 +39,7 @@ version="${version/ (*)/}" version="${version/.*/}" case "$version" in - 6 | 7) - # Allow an older clang-format to accommodate Travis version skew. + 8) ;; google3-trunk) echo "Please use a publicly released clang-format; a recent LLVM release" @@ -49,7 +48,7 @@ case "$version" in exit 1 ;; *) - echo "Please upgrade to clang-format version 7." + echo "Please upgrade to clang-format version 8." echo "If it's installed via homebrew you can run: brew upgrade clang-format" exit 1 ;; From eecad6cf534c4d2d56eb0a4ffc22f8cda1697f86 Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Sat, 29 Dec 2018 09:19:35 -0800 Subject: [PATCH 3/5] Update clang-format homebrew link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d414a4cdde1..651e18eb8ef 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Travis will verify that any code changes are done in a style compliant way. Inst `clang-format` and `swiftformat`. This command will get the right `clang-format` version: -`brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/0743d748ba8b41eec074a0a787dc80219142c525/Formula/clang-format.rb` +`brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/c435aae81df87d826eed0158ffdbfa872a7cb1b7/Formula/clang-format.rb` ### Running Unit Tests From 3da5773e0e6b092e8e9db4e78f51e407319990e7 Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Sat, 29 Dec 2018 10:40:08 -0800 Subject: [PATCH 4/5] Work around space in filename style.sh issue --- .../GoogleUtilities.xcodeproj/project.pbxproj | 32 ++++++------ .../GULUserDefaultsTests.m | 51 +++++++++---------- scripts/style.sh | 2 + 3 files changed, 43 insertions(+), 42 deletions(-) rename GoogleUtilities/Example/Tests/{User Defaults => UserDefaults}/GULUserDefaultsTests.m (95%) diff --git a/GoogleUtilities/Example/GoogleUtilities.xcodeproj/project.pbxproj b/GoogleUtilities/Example/GoogleUtilities.xcodeproj/project.pbxproj index 8307b1c52d1..754333d6676 100644 --- a/GoogleUtilities/Example/GoogleUtilities.xcodeproj/project.pbxproj +++ b/GoogleUtilities/Example/GoogleUtilities.xcodeproj/project.pbxproj @@ -14,6 +14,9 @@ 6003F5B1195388D20070C39A /* Foundation.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F58D195388D20070C39A /* Foundation.framework */; }; 6003F5B2195388D20070C39A /* UIKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 6003F591195388D20070C39A /* UIKit.framework */; }; DE5CF98E20F686310063FFDD /* GULAppEnvironmentUtilTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DE5CF98C20F686290063FFDD /* GULAppEnvironmentUtilTest.m */; }; + DE84BBC421D7EC900048A176 /* GULUserDefaultsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE84BBC321D7EC900048A176 /* GULUserDefaultsTests.m */; }; + DE84BBC521D7EC900048A176 /* GULUserDefaultsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE84BBC321D7EC900048A176 /* GULUserDefaultsTests.m */; }; + DE84BBC621D7EC900048A176 /* GULUserDefaultsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = DE84BBC321D7EC900048A176 /* GULUserDefaultsTests.m */; }; DEC977D720F68C3300014E20 /* GULReachabilityCheckerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DEC977D320F68C3300014E20 /* GULReachabilityCheckerTest.m */; }; DEC977D820F68C3300014E20 /* GULMutableDictionaryTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DEC977D520F68C3300014E20 /* GULMutableDictionaryTest.m */; }; DEC977D920F68C3300014E20 /* GULNetworkTest.m in Sources */ = {isa = PBXBuildFile; fileRef = DEC977D620F68C3300014E20 /* GULNetworkTest.m */; }; @@ -46,9 +49,6 @@ DEC9788720F6E1E000014E20 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = DEC9788020F6E1DF00014E20 /* Main.storyboard */; }; DEC9788820F6E1E000014E20 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = DEC9788120F6E1DF00014E20 /* main.m */; }; DEC9788920F6E1E000014E20 /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = DEC9788220F6E1DF00014E20 /* AppDelegate.m */; }; - ED18C2A0213EDB98009F633D /* GULUserDefaultsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = ED18C29F213EDB98009F633D /* GULUserDefaultsTests.m */; }; - ED18C2A1213EDB98009F633D /* GULUserDefaultsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = ED18C29F213EDB98009F633D /* GULUserDefaultsTests.m */; }; - ED18C2A2213EDB98009F633D /* GULUserDefaultsTests.m in Sources */ = {isa = PBXBuildFile; fileRef = ED18C29F213EDB98009F633D /* GULUserDefaultsTests.m */; }; EFBE67FA2101401100E756A7 /* GULSwizzlerTest.m in Sources */ = {isa = PBXBuildFile; fileRef = EFBE67F02101401100E756A7 /* GULSwizzlerTest.m */; }; EFBE67FB2101401100E756A7 /* GULSwizzlingCacheTest.m in Sources */ = {isa = PBXBuildFile; fileRef = EFBE67F12101401100E756A7 /* GULSwizzlingCacheTest.m */; }; EFBE67FC2101401100E756A7 /* GULRuntimeClassDiffTests.m in Sources */ = {isa = PBXBuildFile; fileRef = EFBE67F22101401100E756A7 /* GULRuntimeClassDiffTests.m */; }; @@ -94,6 +94,7 @@ 6003F5B7195388D20070C39A /* Tests-Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = "Tests-Info.plist"; sourceTree = ""; }; 7BEA793625C8DE7C8EC60006 /* GoogleUtilities.podspec */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text; name = GoogleUtilities.podspec; path = ../GoogleUtilities.podspec; sourceTree = ""; }; DE5CF98C20F686290063FFDD /* GULAppEnvironmentUtilTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GULAppEnvironmentUtilTest.m; sourceTree = ""; }; + DE84BBC321D7EC900048A176 /* GULUserDefaultsTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GULUserDefaultsTests.m; sourceTree = ""; }; DEC977D320F68C3300014E20 /* GULReachabilityCheckerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GULReachabilityCheckerTest.m; sourceTree = ""; }; DEC977D520F68C3300014E20 /* GULMutableDictionaryTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GULMutableDictionaryTest.m; sourceTree = ""; }; DEC977D620F68C3300014E20 /* GULNetworkTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GULNetworkTest.m; sourceTree = ""; }; @@ -129,7 +130,6 @@ DEC9788320F6E1DF00014E20 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; DEC9788420F6E1DF00014E20 /* ViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ViewController.h; sourceTree = ""; }; E0A8D570636E99E7C3396DF8 /* README.md */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = net.daringfireball.markdown; name = README.md; path = ../README.md; sourceTree = ""; }; - ED18C29F213EDB98009F633D /* GULUserDefaultsTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = GULUserDefaultsTests.m; sourceTree = ""; }; EFBE67F02101401100E756A7 /* GULSwizzlerTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GULSwizzlerTest.m; sourceTree = ""; }; EFBE67F12101401100E756A7 /* GULSwizzlingCacheTest.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GULSwizzlingCacheTest.m; sourceTree = ""; }; EFBE67F22101401100E756A7 /* GULRuntimeClassDiffTests.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GULRuntimeClassDiffTests.m; sourceTree = ""; }; @@ -235,7 +235,7 @@ 6003F5B5195388D20070C39A /* Tests */ = { isa = PBXGroup; children = ( - ED18C29E213ED7B9009F633D /* User Defaults */, + DE84BBC221D7EC900048A176 /* UserDefaults */, EFBE67EF2101401100E756A7 /* Swizzler */, DEC977DE20F6A7A700014E20 /* Logger */, DEC977D420F68C3300014E20 /* Network */, @@ -272,6 +272,14 @@ path = Environment; sourceTree = ""; }; + DE84BBC221D7EC900048A176 /* UserDefaults */ = { + isa = PBXGroup; + children = ( + DE84BBC321D7EC900048A176 /* GULUserDefaultsTests.m */, + ); + path = UserDefaults; + sourceTree = ""; + }; DEC977D220F68C3300014E20 /* Reachability */ = { isa = PBXGroup; children = ( @@ -352,14 +360,6 @@ path = tvOS; sourceTree = ""; }; - ED18C29E213ED7B9009F633D /* User Defaults */ = { - isa = PBXGroup; - children = ( - ED18C29F213EDB98009F633D /* GULUserDefaultsTests.m */, - ); - path = "User Defaults"; - sourceTree = ""; - }; EFBE67EF2101401100E756A7 /* Swizzler */ = { isa = PBXGroup; children = ( @@ -610,8 +610,8 @@ EFBE67FF2101401100E756A7 /* GULRuntimeDiffTests.m in Sources */, DEC977DD20F68FE100014E20 /* GTMHTTPServer.m in Sources */, EFBE68022101401100E756A7 /* GULRuntimeSnapshotTests.m in Sources */, - ED18C2A0213EDB98009F633D /* GULUserDefaultsTests.m in Sources */, EFBE68002101401100E756A7 /* GULSwizzlerInheritedMethodsSwizzlingTest.m in Sources */, + DE84BBC421D7EC900048A176 /* GULUserDefaultsTests.m in Sources */, EFBE68012101401100E756A7 /* GULRuntimeStateHelperTests.m in Sources */, DEC977D820F68C3300014E20 /* GULMutableDictionaryTest.m in Sources */, DEC977E120F6A7C100014E20 /* GULLoggerTest.m in Sources */, @@ -643,7 +643,7 @@ DEC9781920F6D38500014E20 /* GULAppEnvironmentUtilTest.m in Sources */, DEC9781A20F6D38800014E20 /* GULReachabilityCheckerTest.m in Sources */, DEC9781820F6D37400014E20 /* GULLoggerTest.m in Sources */, - ED18C2A1213EDB98009F633D /* GULUserDefaultsTests.m in Sources */, + DE84BBC521D7EC900048A176 /* GULUserDefaultsTests.m in Sources */, DEC9781D20F6D39900014E20 /* GTMHTTPServer.m in Sources */, DEC9781B20F6D39500014E20 /* GULMutableDictionaryTest.m in Sources */, DEC9781C20F6D39500014E20 /* GULNetworkTest.m in Sources */, @@ -667,7 +667,7 @@ DEC9786920F6D66300014E20 /* GTMHTTPServer.m in Sources */, DEC9786B20F6D66300014E20 /* GULNetworkTest.m in Sources */, DEC9786A20F6D66300014E20 /* GULMutableDictionaryTest.m in Sources */, - ED18C2A2213EDB98009F633D /* GULUserDefaultsTests.m in Sources */, + DE84BBC621D7EC900048A176 /* GULUserDefaultsTests.m in Sources */, DEC9786C20F6D66700014E20 /* GULReachabilityCheckerTest.m in Sources */, DEC9786820F6D65B00014E20 /* GULLoggerTest.m in Sources */, DEC9786D20F6D66B00014E20 /* GULAppEnvironmentUtilTest.m in Sources */, diff --git a/GoogleUtilities/Example/Tests/User Defaults/GULUserDefaultsTests.m b/GoogleUtilities/Example/Tests/UserDefaults/GULUserDefaultsTests.m similarity index 95% rename from GoogleUtilities/Example/Tests/User Defaults/GULUserDefaultsTests.m rename to GoogleUtilities/Example/Tests/UserDefaults/GULUserDefaultsTests.m index e38d2741695..2b957307813 100644 --- a/GoogleUtilities/Example/Tests/User Defaults/GULUserDefaultsTests.m +++ b/GoogleUtilities/Example/Tests/UserDefaults/GULUserDefaultsTests.m @@ -83,7 +83,7 @@ - (void)testNewUserDefaultsWithStandardUserDefaults { XCTAssertEqualObjects([userDefaults objectForKey:key3], array); NSString *key4 = @"DictionaryKey"; - NSDictionary *dictionary = @{ @"testing" : @"Hi there!" }; + NSDictionary *dictionary = @{@"testing" : @"Hi there!"}; [newUserDefaults setObject:dictionary forKey:key4]; XCTAssertEqualObjects([newUserDefaults objectForKey:key4], dictionary); XCTAssertEqualObjects([newUserDefaults dictionaryForKey:key4], dictionary); @@ -115,8 +115,8 @@ - (void)testNewUserDefaultsWithStandardUserDefaults { XCTAssertNotNil([userDefaults objectForKey:key7]); XCTAssertEqualWithAccuracy([testDate timeIntervalSinceDate:[newUserDefaults objectForKey:key7]], 0.0, sEpsilon); - XCTAssertEqualWithAccuracy([testDate timeIntervalSinceDate:[userDefaults objectForKey:key7]], - 0.0, sEpsilon); + XCTAssertEqualWithAccuracy([testDate timeIntervalSinceDate:[userDefaults objectForKey:key7]], 0.0, + sEpsilon); NSString *key8 = @"FloatKey"; [newUserDefaults setFloat:0.99 forKey:key8]; @@ -146,7 +146,7 @@ - (void)testNewUserDefaultsWithStandardUserDefaults { XCTAssertEqualObjects([newUserDefaults arrayForKey:key3], array2); XCTAssertEqualObjects([userDefaults objectForKey:key3], array2); - NSDictionary *dictionary2 = @{ @"testing 2" : @3 }; + NSDictionary *dictionary2 = @{@"testing 2" : @3}; [newUserDefaults setObject:dictionary2 forKey:key4]; XCTAssertEqualObjects([newUserDefaults objectForKey:key4], dictionary2); XCTAssertEqualObjects([newUserDefaults dictionaryForKey:key4], dictionary2); @@ -202,7 +202,7 @@ - (void)testNSUserDefaultsWithNewUserDefaults { XCTAssertEqualObjects([userDefaults objectForKey:key3], array); NSString *key4 = @"DictionaryKey"; - NSDictionary *dictionary = @{ @"testing" : @"Hi there!" }; + NSDictionary *dictionary = @{@"testing" : @"Hi there!"}; [userDefaults setObject:dictionary forKey:key4]; XCTAssertEqualObjects([newUserDefaults objectForKey:key4], dictionary); XCTAssertEqualObjects([newUserDefaults dictionaryForKey:key4], dictionary); @@ -234,8 +234,8 @@ - (void)testNSUserDefaultsWithNewUserDefaults { XCTAssertNotNil([userDefaults objectForKey:key7]); XCTAssertEqualWithAccuracy([testDate timeIntervalSinceDate:[newUserDefaults objectForKey:key7]], 0.0, sEpsilon); - XCTAssertEqualWithAccuracy([testDate timeIntervalSinceDate:[userDefaults objectForKey:key7]], - 0.0, sEpsilon); + XCTAssertEqualWithAccuracy([testDate timeIntervalSinceDate:[userDefaults objectForKey:key7]], 0.0, + sEpsilon); NSString *key8 = @"FloatKey"; [userDefaults setFloat:0.99 forKey:key8]; @@ -265,7 +265,7 @@ - (void)testNSUserDefaultsWithNewUserDefaults { XCTAssertEqualObjects([newUserDefaults arrayForKey:key3], array2); XCTAssertEqualObjects([userDefaults objectForKey:key3], array2); - NSDictionary *dictionary2 = @{ @"testing 2" : @3 }; + NSDictionary *dictionary2 = @{@"testing 2" : @3}; [userDefaults setObject:dictionary2 forKey:key4]; XCTAssertEqualObjects([newUserDefaults objectForKey:key4], dictionary2); XCTAssertEqualObjects([newUserDefaults dictionaryForKey:key4], dictionary2); @@ -322,7 +322,7 @@ - (void)testNewSharedUserDefaultsWithStandardUserDefaults { XCTAssertEqualObjects([userDefaults objectForKey:key3], array); NSString *key4 = @"DictionaryKey"; - NSDictionary *dictionary = @{ @"testing" : @"Hi there!" }; + NSDictionary *dictionary = @{@"testing" : @"Hi there!"}; [userDefaults setObject:dictionary forKey:key4]; XCTAssertEqualObjects([newUserDefaults objectForKey:key4], dictionary); XCTAssertEqualObjects([newUserDefaults dictionaryForKey:key4], dictionary); @@ -354,8 +354,8 @@ - (void)testNewSharedUserDefaultsWithStandardUserDefaults { XCTAssertNotNil([userDefaults objectForKey:key7]); XCTAssertEqualWithAccuracy([testDate timeIntervalSinceDate:[newUserDefaults objectForKey:key7]], 0.0, sEpsilon); - XCTAssertEqualWithAccuracy([testDate timeIntervalSinceDate:[userDefaults objectForKey:key7]], - 0.0, sEpsilon); + XCTAssertEqualWithAccuracy([testDate timeIntervalSinceDate:[userDefaults objectForKey:key7]], 0.0, + sEpsilon); // Remove all of the objects from the normal NSUserDefaults. The values from the new user // defaults must also be cleared! @@ -380,7 +380,7 @@ - (void)testNewSharedUserDefaultsWithStandardUserDefaults { XCTAssertEqualObjects([newUserDefaults arrayForKey:key3], array2); XCTAssertEqualObjects([userDefaults objectForKey:key3], array2); - NSDictionary *dictionary2 = @{ @"testing 2" : @3 }; + NSDictionary *dictionary2 = @{@"testing 2" : @3}; [userDefaults setObject:dictionary2 forKey:key4]; XCTAssertEqualObjects([newUserDefaults objectForKey:key4], dictionary2); XCTAssertEqualObjects([userDefaults objectForKey:key4], dictionary2); @@ -413,10 +413,10 @@ - (void)testUserDefaultNotifications { }; id observer = - [[NSNotificationCenter defaultCenter] addObserverForName:NSUserDefaultsDidChangeNotification - object:nil - queue:nil - usingBlock:callBlock]; + [[NSNotificationCenter defaultCenter] addObserverForName:NSUserDefaultsDidChangeNotification + object:nil + queue:nil + usingBlock:callBlock]; NSString *suiteName = @"test_suite_notification"; GULUserDefaults *newUserDefaults = [[GULUserDefaults alloc] initWithSuiteName:suiteName]; [newUserDefaults setObject:@"134" forKey:@"test-another"]; @@ -453,7 +453,8 @@ - (void)testSynchronizeToDisk { [newUserDefaults setObject:@"134" forKey:@"test-another"]; [newUserDefaults synchronize]; - XCTAssertTrue([fileManager fileExistsAtPath:filePath], @"The user defaults file was not synchronized to disk."); + XCTAssertTrue([fileManager fileExistsAtPath:filePath], + @"The user defaults file was not synchronized to disk."); // Now get the file directly from disk. XCTAssertTrue([fileManager fileExistsAtPath:filePath]); @@ -564,7 +565,7 @@ - (void)testNewUserDefaultsThreadSafeAddingObjects { XCTestExpectation *expectation = [self expectationForPredicate:dictionarySize evaluatedWithObject:dictionary handler:nil]; - [self waitForExpectations:@[expectation] timeout:kGULTestCaseTimeoutInterval]; + [self waitForExpectations:@[ expectation ] timeout:kGULTestCaseTimeoutInterval]; for (int i = 0; i < itemCount; i++) { NSString *key = [NSString stringWithFormat:@"%d", i]; @@ -608,7 +609,7 @@ - (void)testNewUserDefaultsRemovingObjects { XCTestExpectation *expectation = [self expectationForPredicate:emptyDictionary evaluatedWithObject:dictionary handler:nil]; - [self waitForExpectations:@[expectation] timeout:kGULTestCaseTimeoutInterval]; + [self waitForExpectations:@[ expectation ] timeout:kGULTestCaseTimeoutInterval]; for (int i = 0; i < itemCount; i++) { NSString *key = [NSString stringWithFormat:@"%d", i]; @@ -649,7 +650,7 @@ - (void)testNewUserDefaultsRemovingSomeObjects { XCTestExpectation *expectation = [self expectationForPredicate:dictionarySize evaluatedWithObject:dictionary handler:nil]; - [self waitForExpectations:@[expectation] timeout:kGULTestCaseTimeoutInterval]; + [self waitForExpectations:@[ expectation ] timeout:kGULTestCaseTimeoutInterval]; // Check the remaining of the user defaults. for (int i = 0; i < itemCount; i++) { @@ -691,7 +692,7 @@ - (void)testBothUserDefaultsThreadSafeAddingObjects { XCTestExpectation *expectation = [self expectationForPredicate:dictionarySize evaluatedWithObject:dictionary handler:nil]; - [self waitForExpectations:@[expectation] timeout:kGULTestCaseTimeoutInterval]; + [self waitForExpectations:@[ expectation ] timeout:kGULTestCaseTimeoutInterval]; for (int i = 0; i < itemCount; i++) { NSString *key = [NSString stringWithFormat:@"%d", i]; @@ -739,7 +740,7 @@ - (void)testBothUserDefaultsRemovingSomeObjects { XCTestExpectation *expectation = [self expectationForPredicate:dictionarySize evaluatedWithObject:dictionary handler:nil]; - [self waitForExpectations:@[expectation] timeout:kGULTestCaseTimeoutInterval]; + [self waitForExpectations:@[ expectation ] timeout:kGULTestCaseTimeoutInterval]; // Check the remaining of the user defaults. for (int i = 0; i < itemCount; i++) { @@ -828,10 +829,8 @@ - (NSString *)filePathForPreferencesName:(NSString *)preferencesName { XCTFail(@"Library directory not found - NSSearchPath results are empty."); } NSArray *components = @[ - paths.lastObject, - @"Preferences", - [preferencesName stringByAppendingPathExtension:@"plist"] - ]; + paths.lastObject, @"Preferences", [preferencesName stringByAppendingPathExtension:@"plist"] + ]; return [NSString pathWithComponents:components]; } diff --git a/scripts/style.sh b/scripts/style.sh index aaaac8b0ff6..c8103beb213 100755 --- a/scripts/style.sh +++ b/scripts/style.sh @@ -104,6 +104,8 @@ else clang_options+=(-i) fi +#TODO(#2223) - Find a way to handle spaces in filenames + files=$( ( if [[ $# -gt 0 ]]; then From e35b4c7d6ba9a7c41bb83e9118d2a7b474ed1c15 Mon Sep 17 00:00:00 2001 From: Paul Beusterien Date: Sat, 29 Dec 2018 10:52:04 -0800 Subject: [PATCH 5/5] We want stable/2018-08-24 not stable/2018-10-04 to match travis --- Firestore/core/src/firebase/firestore/model/field_value.cc | 6 ++---- README.md | 2 +- scripts/style.sh | 3 ++- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Firestore/core/src/firebase/firestore/model/field_value.cc b/Firestore/core/src/firebase/firestore/model/field_value.cc index 16309a92722..f21aa9b11f5 100644 --- a/Firestore/core/src/firebase/firestore/model/field_value.cc +++ b/Firestore/core/src/firebase/firestore/model/field_value.cc @@ -466,8 +466,7 @@ void FieldValue::SwitchTo(const Type type) { case Type::Object: object_value_.internal_value.~map(); break; - default: { - } // The other types where there is nothing to worry about. + default: {} // The other types where there is nothing to worry about. } tag_ = type; // Must call constructor explicitly for any non-POD type to initialize. @@ -498,8 +497,7 @@ void FieldValue::SwitchTo(const Type type) { case Type::Object: new (&object_value_) ObjectValue{}; break; - default: { - } // The other types where there is nothing to worry about. + default: {} // The other types where there is nothing to worry about. } } diff --git a/README.md b/README.md index 651e18eb8ef..bfaceebc6c4 100644 --- a/README.md +++ b/README.md @@ -90,7 +90,7 @@ Travis will verify that any code changes are done in a style compliant way. Inst `clang-format` and `swiftformat`. This command will get the right `clang-format` version: -`brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/c435aae81df87d826eed0158ffdbfa872a7cb1b7/Formula/clang-format.rb` +`brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/773cb75d360b58f32048f5964038d09825a507c8/Formula/clang-format.rb` ### Running Unit Tests diff --git a/scripts/style.sh b/scripts/style.sh index c8103beb213..f816bb7500f 100755 --- a/scripts/style.sh +++ b/scripts/style.sh @@ -49,7 +49,8 @@ case "$version" in ;; *) echo "Please upgrade to clang-format version 8." - echo "If it's installed via homebrew you can run: brew upgrade clang-format" + echo "If it's installed via homebrew you can run:" + echo "brew install https://raw.githubusercontent.com/Homebrew/homebrew-core/773cb75d360b58f32048f5964038d09825a507c8/Formula/clang-format.rb" exit 1 ;; esac