aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--Example/Storage/App/iOS/FIRAppDelegate.h2
-rw-r--r--Example/Storage/App/iOS/FIRAppDelegate.m45
-rw-r--r--Example/Storage/App/iOS/FIRViewController.m14
-rw-r--r--Example/Storage/App/iOS/main.m9
-rw-r--r--Example/Storage/App/macOS/FIRAppDelegate.h2
-rw-r--r--Example/Storage/App/macOS/FIRAppDelegate.m6
-rw-r--r--Example/Storage/App/macOS/FIRViewController.h2
-rw-r--r--Example/Storage/App/macOS/FIRViewController.m10
-rw-r--r--Example/Storage/App/macOS/main.m4
-rw-r--r--Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m652
-rw-r--r--Example/Storage/Tests/Unit/FIRStorageDeleteTests.m56
-rw-r--r--Example/Storage/Tests/Unit/FIRStorageGetMetadataTests.m11
-rw-r--r--Example/Storage/Tests/Unit/FIRStorageMetadataTests.m26
-rw-r--r--Example/Storage/Tests/Unit/FIRStorageTestHelpers.m11
-rw-r--r--Example/Storage/Tests/Unit/FIRStorageTests.m21
-rw-r--r--Example/Storage/Tests/Unit/FIRStorageTokenAuthorizerTests.m124
-rw-r--r--Example/Storage/Tests/Unit/FIRStorageUpdateMetadataTests.m35
-rw-r--r--Example/Storage/Tests/Unit/FIRStorageUtilsTests.m8
-rw-r--r--Firebase/Storage/FIRStorage.m10
-rw-r--r--Firebase/Storage/FIRStorageConstants.m8
-rw-r--r--Firebase/Storage/FIRStorageDeleteTask.m4
-rw-r--r--Firebase/Storage/FIRStorageDownloadTask.m14
-rw-r--r--Firebase/Storage/FIRStorageErrors.m3
-rw-r--r--Firebase/Storage/FIRStorageGetMetadataTask.m2
-rw-r--r--Firebase/Storage/FIRStorageMetadata.m2
-rw-r--r--Firebase/Storage/FIRStorageObservableTask.m16
-rw-r--r--Firebase/Storage/FIRStoragePath.m7
-rw-r--r--Firebase/Storage/FIRStorageReference.m30
-rw-r--r--Firebase/Storage/FIRStorageTask.m5
-rw-r--r--Firebase/Storage/FIRStorageTaskSnapshot.m15
-rw-r--r--Firebase/Storage/FIRStorageUpdateMetadataTask.m6
-rw-r--r--Firebase/Storage/FIRStorageUploadTask.m36
-rw-r--r--Firebase/Storage/Private/FIRStorageDeleteTask.h2
-rw-r--r--Firebase/Storage/Private/FIRStorageGetMetadataTask.h2
-rw-r--r--Firebase/Storage/Private/FIRStorageTokenAuthorizer.h2
-rw-r--r--Firebase/Storage/Private/FIRStorageUpdateMetadataTask.h2
-rw-r--r--Firebase/Storage/Public/FIRStorage.h3
-rw-r--r--Firebase/Storage/Public/FIRStorageDownloadTask.h2
-rw-r--r--Firebase/Storage/Public/FIRStorageMetadata.h6
-rw-r--r--Firebase/Storage/Public/FIRStorageReference.h31
-rw-r--r--Firebase/Storage/Public/FIRStorageSwiftNameSupport.h2
-rw-r--r--Firebase/Storage/Public/FIRStorageTask.h2
-rw-r--r--Firebase/Storage/Public/FIRStorageUploadTask.h2
-rw-r--r--Firestore/Example/Tests/SpecTests/FSTMockDatastore.h6
-rw-r--r--Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm9
-rwxr-xr-xscripts/style.sh1
46 files changed, 637 insertions, 631 deletions
diff --git a/Example/Storage/App/iOS/FIRAppDelegate.h b/Example/Storage/App/iOS/FIRAppDelegate.h
index e3fba8f..1eb5040 100644
--- a/Example/Storage/App/iOS/FIRAppDelegate.h
+++ b/Example/Storage/App/iOS/FIRAppDelegate.h
@@ -18,6 +18,6 @@
@interface FIRAppDelegate : UIResponder <UIApplicationDelegate>
-@property (strong, nonatomic) UIWindow *window;
+@property(strong, nonatomic) UIWindow *window;
@end
diff --git a/Example/Storage/App/iOS/FIRAppDelegate.m b/Example/Storage/App/iOS/FIRAppDelegate.m
index 0ecfdea..9568d06 100644
--- a/Example/Storage/App/iOS/FIRAppDelegate.m
+++ b/Example/Storage/App/iOS/FIRAppDelegate.m
@@ -16,37 +16,40 @@
@implementation FIRAppDelegate
-- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
-{
- // Override point for customization after application launch.
- return YES;
+- (BOOL)application:(UIApplication *)application
+ didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
+ // Override point for customization after application launch.
+ return YES;
}
-- (void)applicationWillResignActive:(UIApplication *)application
-{
- // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
- // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
+- (void)applicationWillResignActive:(UIApplication *)application {
+ // Sent when the application is about to move from active to inactive state. This can occur for
+ // certain types of temporary interruptions (such as an incoming phone call or SMS message) or
+ // when the user quits the application and it begins the transition to the background state. Use
+ // this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates.
+ // Games should use this method to pause the game.
}
-- (void)applicationDidEnterBackground:(UIApplication *)application
-{
- // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
- // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
+- (void)applicationDidEnterBackground:(UIApplication *)application {
+ // Use this method to release shared resources, save user data, invalidate timers, and store
+ // enough application state information to restore your application to its current state in case
+ // it is terminated later. If your application supports background execution, this method is
+ // called instead of applicationWillTerminate: when the user quits.
}
-- (void)applicationWillEnterForeground:(UIApplication *)application
-{
- // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
+- (void)applicationWillEnterForeground:(UIApplication *)application {
+ // Called as part of the transition from the background to the inactive state; here you can undo
+ // many of the changes made on entering the background.
}
-- (void)applicationDidBecomeActive:(UIApplication *)application
-{
- // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
+- (void)applicationDidBecomeActive:(UIApplication *)application {
+ // Restart any tasks that were paused (or not yet started) while the application was inactive. If
+ // the application was previously in the background, optionally refresh the user interface.
}
-- (void)applicationWillTerminate:(UIApplication *)application
-{
- // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
+- (void)applicationWillTerminate:(UIApplication *)application {
+ // Called when the application is about to terminate. Save data if appropriate. See also
+ // applicationDidEnterBackground:.
}
@end
diff --git a/Example/Storage/App/iOS/FIRViewController.m b/Example/Storage/App/iOS/FIRViewController.m
index 901accf..027aabf 100644
--- a/Example/Storage/App/iOS/FIRViewController.m
+++ b/Example/Storage/App/iOS/FIRViewController.m
@@ -20,16 +20,14 @@
@implementation FIRViewController
-- (void)viewDidLoad
-{
- [super viewDidLoad];
- // Do any additional setup after loading the view, typically from a nib.
+- (void)viewDidLoad {
+ [super viewDidLoad];
+ // Do any additional setup after loading the view, typically from a nib.
}
-- (void)didReceiveMemoryWarning
-{
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
+- (void)didReceiveMemoryWarning {
+ [super didReceiveMemoryWarning];
+ // Dispose of any resources that can be recreated.
}
@end
diff --git a/Example/Storage/App/iOS/main.m b/Example/Storage/App/iOS/main.m
index 03b5c12..39c05a5 100644
--- a/Example/Storage/App/iOS/main.m
+++ b/Example/Storage/App/iOS/main.m
@@ -15,9 +15,8 @@
@import UIKit;
#import "FIRAppDelegate.h"
-int main(int argc, char * argv[])
-{
- @autoreleasepool {
- return UIApplicationMain(argc, argv, nil, NSStringFromClass([FIRAppDelegate class]));
- }
+int main(int argc, char* argv[]) {
+ @autoreleasepool {
+ return UIApplicationMain(argc, argv, nil, NSStringFromClass([FIRAppDelegate class]));
+ }
}
diff --git a/Example/Storage/App/macOS/FIRAppDelegate.h b/Example/Storage/App/macOS/FIRAppDelegate.h
index e637ef9..96400bd 100644
--- a/Example/Storage/App/macOS/FIRAppDelegate.h
+++ b/Example/Storage/App/macOS/FIRAppDelegate.h
@@ -18,6 +18,4 @@
@interface FIRAppDelegate : NSObject <NSApplicationDelegate>
-
@end
-
diff --git a/Example/Storage/App/macOS/FIRAppDelegate.m b/Example/Storage/App/macOS/FIRAppDelegate.m
index 9a363a6..1eb675e 100644
--- a/Example/Storage/App/macOS/FIRAppDelegate.m
+++ b/Example/Storage/App/macOS/FIRAppDelegate.m
@@ -23,13 +23,11 @@
@implementation FIRAppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
- // Insert code here to initialize your application
+ // Insert code here to initialize your application
}
-
- (void)applicationWillTerminate:(NSNotification *)aNotification {
- // Insert code here to tear down your application
+ // Insert code here to tear down your application
}
-
@end
diff --git a/Example/Storage/App/macOS/FIRViewController.h b/Example/Storage/App/macOS/FIRViewController.h
index efee5d5..72497a3 100644
--- a/Example/Storage/App/macOS/FIRViewController.h
+++ b/Example/Storage/App/macOS/FIRViewController.h
@@ -18,6 +18,4 @@
@interface FIRViewController : NSViewController
-
@end
-
diff --git a/Example/Storage/App/macOS/FIRViewController.m b/Example/Storage/App/macOS/FIRViewController.m
index 08c5bb5..616257f 100644
--- a/Example/Storage/App/macOS/FIRViewController.m
+++ b/Example/Storage/App/macOS/FIRViewController.m
@@ -19,17 +19,15 @@
@implementation FIRViewController
- (void)viewDidLoad {
- [super viewDidLoad];
+ [super viewDidLoad];
- // Do any additional setup after loading the view.
+ // Do any additional setup after loading the view.
}
-
- (void)setRepresentedObject:(id)representedObject {
- [super setRepresentedObject:representedObject];
+ [super setRepresentedObject:representedObject];
- // Update the view, if already loaded.
+ // Update the view, if already loaded.
}
-
@end
diff --git a/Example/Storage/App/macOS/main.m b/Example/Storage/App/macOS/main.m
index e8858a6..45ed70f 100644
--- a/Example/Storage/App/macOS/main.m
+++ b/Example/Storage/App/macOS/main.m
@@ -16,6 +16,6 @@
#import <Cocoa/Cocoa.h>
-int main(int argc, const char * argv[]) {
- return NSApplicationMain(argc, argv);
+int main(int argc, const char* argv[]) {
+ return NSApplicationMain(argc, argv);
}
diff --git a/Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m b/Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m
index 0e07d97..8c7f972 100644
--- a/Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m
+++ b/Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m
@@ -12,8 +12,8 @@
// See the License for the specific language governing permissions and
// limitations under the License.
-#import <math.h>
#import <XCTest/XCTest.h>
+#import <math.h>
#import "FirebaseStorage.h"
@@ -56,427 +56,428 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
@implementation FIRStorageIntegrationTests
-
+ (void)setUp {
- [FIRApp configure];
+ [FIRApp configure];
}
- (void)setUp {
- [super setUp];
+ [super setUp];
- self.app = [FIRApp defaultApp];
- self.storage = [FIRStorage storageForApp:self.app];
+ self.app = [FIRApp defaultApp];
+ self.storage = [FIRStorage storageForApp:self.app];
- static dispatch_once_t once;
- dispatch_once(&once, ^{
- XCTestExpectation *expectation = [self expectationWithDescription:@"setup"];
+ static dispatch_once_t once;
+ dispatch_once(&once, ^{
+ XCTestExpectation *expectation = [self expectationWithDescription:@"setup"];
- FIRStorageReference *ref = [[FIRStorage storage].reference child:@"ios/public/1mb"];
- NSData *data = [NSData dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"1mb" ofType:@"dat"]];
- XCTAssertNotNil(data, "Could not load bundled file");
- [ref putData:data metadata:nil completion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertNil(error);
- [expectation fulfill];
+ FIRStorageReference *ref = [[FIRStorage storage].reference child:@"ios/public/1mb"];
+ NSData *data = [NSData
+ dataWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"1mb" ofType:@"dat"]];
+ XCTAssertNotNil(data, "Could not load bundled file");
+ [ref putData:data
+ metadata:nil
+ completion:^(FIRStorageMetadata *metadata, NSError *error) {
+ XCTAssertNil(error);
+ [expectation fulfill];
}];
- [self waitForExpectations];
- });
+ [self waitForExpectations];
+ });
}
- (void)tearDown {
- self.app = nil;
- self.storage = nil;
+ self.app = nil;
+ self.storage = nil;
- [super tearDown];
+ [super tearDown];
}
- (void)testName {
- NSString *aGSURI = [NSString stringWithFormat:@"gs://%@.appspot.com/path/to", [[FIRApp defaultApp] options].projectID];
- FIRStorageReference *ref = [self.storage referenceForURL:aGSURI];
- XCTAssertEqualObjects(ref.description, aGSURI);
+ NSString *aGSURI = [NSString
+ stringWithFormat:@"gs://%@.appspot.com/path/to", [[FIRApp defaultApp] options].projectID];
+ FIRStorageReference *ref = [self.storage referenceForURL:aGSURI];
+ XCTAssertEqualObjects(ref.description, aGSURI);
}
- (void)testUnauthenticatedGetMetadata {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedGetMetadata"];
- FIRStorageReference *ref = [self.storage.reference child:@"ios/public/1mb"];
+ FIRStorageReference *ref = [self.storage.reference child:@"ios/public/1mb"];
- [ref metadataWithCompletion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertNotNil(metadata, "Metadata should not be nil");
- XCTAssertNil(error, "Error should be nil");
- [expectation fulfill];
- }];
+ [ref metadataWithCompletion:^(FIRStorageMetadata *metadata, NSError *error) {
+ XCTAssertNotNil(metadata, "Metadata should not be nil");
+ XCTAssertNil(error, "Error should be nil");
+ [expectation fulfill];
+ }];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testUnauthenticatedUpdateMetadata {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedUpdateMetadata"];
- FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/1mb"];
-
- FIRStorageMetadata *meta = [[FIRStorageMetadata alloc] init];
- [meta setContentType:@"lol/custom"];
- [meta setCustomMetadata:@{
- @"lol" : @"custom metadata is neat",
- @"ちかてつ" : @"🚇",
- @"shinkansen" : @"新幹線"
- }];
-
- [ref updateMetadata:meta
- completion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertEqualObjects(meta.contentType, metadata.contentType);
- XCTAssertEqualObjects(meta.customMetadata[@"lol"],
- metadata.customMetadata[@"lol"]);
- XCTAssertEqualObjects(meta.customMetadata[@"ちかてつ"],
- metadata.customMetadata[@"ちかてつ"]);
- XCTAssertEqualObjects(meta.customMetadata[@"shinkansen"],
- metadata.customMetadata[@"shinkansen"]);
- XCTAssertNil(error, "Error should be nil");
- [expectation fulfill];
- }];
+ FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/1mb"];
+
+ FIRStorageMetadata *meta = [[FIRStorageMetadata alloc] init];
+ [meta setContentType:@"lol/custom"];
+ [meta setCustomMetadata:@{
+ @"lol" : @"custom metadata is neat",
+ @"ちかてつ" : @"🚇",
+ @"shinkansen" : @"新幹線"
+ }];
+
+ [ref updateMetadata:meta
+ completion:^(FIRStorageMetadata *metadata, NSError *error) {
+ XCTAssertEqualObjects(meta.contentType, metadata.contentType);
+ XCTAssertEqualObjects(meta.customMetadata[@"lol"], metadata.customMetadata[@"lol"]);
+ XCTAssertEqualObjects(meta.customMetadata[@"ちかてつ"],
+ metadata.customMetadata[@"ちかてつ"]);
+ XCTAssertEqualObjects(meta.customMetadata[@"shinkansen"],
+ metadata.customMetadata[@"shinkansen"]);
+ XCTAssertNil(error, "Error should be nil");
+ [expectation fulfill];
+ }];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testUnauthenticatedDelete {
- XCTestExpectation *expectation = [self expectationWithDescription:@"testUnauthenticatedDelete"];
+ XCTestExpectation *expectation = [self expectationWithDescription:@"testUnauthenticatedDelete"];
- FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/fileToDelete"];
+ FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/fileToDelete"];
- NSData *data = [@"Delete me!!!!!!!" dataUsingEncoding:NSUTF8StringEncoding];
+ NSData *data = [@"Delete me!!!!!!!" dataUsingEncoding:NSUTF8StringEncoding];
- [ref putData:data
+ [ref putData:data
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertNotNil(metadata, "Metadata should not be nil");
+ XCTAssertNotNil(metadata, "Metadata should not be nil");
+ XCTAssertNil(error, "Error should be nil");
+ [ref deleteWithCompletion:^(NSError *error) {
XCTAssertNil(error, "Error should be nil");
- [ref deleteWithCompletion:^(NSError *error) {
- XCTAssertNil(error, "Error should be nil");
- [expectation fulfill];
- }];
+ [expectation fulfill];
+ }];
}];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testDeleteWithNilCompletion {
- XCTestExpectation *expectation = [self expectationWithDescription:@"testDeleteWithNilCompletion"];
+ XCTestExpectation *expectation = [self expectationWithDescription:@"testDeleteWithNilCompletion"];
- FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/fileToDelete"];
+ FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/fileToDelete"];
- NSData *data = [@"Delete me!!!!!!!" dataUsingEncoding:NSUTF8StringEncoding];
+ NSData *data = [@"Delete me!!!!!!!" dataUsingEncoding:NSUTF8StringEncoding];
- [ref putData:data
+ [ref putData:data
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertNotNil(metadata, "Metadata should not be nil");
- XCTAssertNil(error, "Error should be nil");
- [ref deleteWithCompletion:nil];
- [expectation fulfill];
+ XCTAssertNotNil(metadata, "Metadata should not be nil");
+ XCTAssertNil(error, "Error should be nil");
+ [ref deleteWithCompletion:nil];
+ [expectation fulfill];
}];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testUnauthenticatedSimplePutData {
- XCTestExpectation *expectation =
- [self expectationWithDescription:@"testUnauthenticatedSimplePutData"];
- FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/testBytesUpload"];
+ XCTestExpectation *expectation =
+ [self expectationWithDescription:@"testUnauthenticatedSimplePutData"];
+ FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/testBytesUpload"];
- NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
+ NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
- [ref putData:data
+ [ref putData:data
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertNotNil(metadata, "Metadata should not be nil");
- XCTAssertNil(error, "Error should be nil");
- [expectation fulfill];
+ XCTAssertNotNil(metadata, "Metadata should not be nil");
+ XCTAssertNil(error, "Error should be nil");
+ [expectation fulfill];
}];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testUnauthenticatedSimplePutEmptyData {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimplePutEmptyData"];
- FIRStorageReference *ref =
+ FIRStorageReference *ref =
[self.storage referenceWithPath:@"ios/public/testUnauthenticatedSimplePutEmptyData"];
- NSData *data = [[NSData alloc] init];
+ NSData *data = [[NSData alloc] init];
- [ref putData:data
+ [ref putData:data
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertNotNil(metadata, "Metadata should not be nil");
- XCTAssertNil(error, "Error should be nil");
- [expectation fulfill];
+ XCTAssertNotNil(metadata, "Metadata should not be nil");
+ XCTAssertNil(error, "Error should be nil");
+ [expectation fulfill];
}];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testUnauthenticatedSimplePutDataUnauthorized {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimplePutDataUnauthorized"];
- FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/private/secretfile.txt"];
+ FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/private/secretfile.txt"];
- NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
+ NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
- [ref putData:data
+ [ref putData:data
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertNil(metadata, "Metadata should be nil");
- XCTAssertNotNil(error, "Error should not be nil");
- XCTAssertEqual(error.code, FIRStorageErrorCodeUnauthorized);
- [expectation fulfill];
+ XCTAssertNil(metadata, "Metadata should be nil");
+ XCTAssertNotNil(error, "Error should not be nil");
+ XCTAssertEqual(error.code, FIRStorageErrorCodeUnauthorized);
+ [expectation fulfill];
}];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testUnauthenticatedSimplePutFile {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimplePutFile"];
- FIRStorageReference *ref =
+ FIRStorageReference *ref =
[self.storage referenceWithPath:@"ios/public/testUnauthenticatedSimplePutFile"];
- NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
- NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
- NSURL *fileURL =
- [[tmpDirURL URLByAppendingPathComponent:@"hello"] URLByAppendingPathExtension:@"txt"];
- [data writeToURL:fileURL atomically:YES];
-
- FIRStorageUploadTask *task = [ref putFile:fileURL
- metadata:nil
- completion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertNotNil(metadata, "Metadata should not be nil");
- XCTAssertNil(error, "Error should be nil");
- }];
-
- __block long uploadedBytes = -1;
-
- [task observeStatus:FIRStorageTaskStatusSuccess
- handler:^(FIRStorageTaskSnapshot *snapshot) {
- XCTAssertEqualObjects([snapshot description], @"<State: Success>");
- [expectation fulfill];
- }];
-
- [task observeStatus:FIRStorageTaskStatusProgress
- handler:^(FIRStorageTaskSnapshot *_Nonnull snapshot) {
- XCTAssertTrue([[snapshot description] containsString:@"State: Progress"] ||
- [[snapshot description] containsString:@"State: Resume"]);
- NSProgress *progress = snapshot.progress;
- XCTAssertGreaterThanOrEqual(progress.completedUnitCount, uploadedBytes);
- uploadedBytes = progress.completedUnitCount;
- }];
+ NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
+ NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
+ NSURL *fileURL =
+ [[tmpDirURL URLByAppendingPathComponent:@"hello"] URLByAppendingPathExtension:@"txt"];
+ [data writeToURL:fileURL atomically:YES];
- [self waitForExpectations];
+ FIRStorageUploadTask *task = [ref putFile:fileURL
+ metadata:nil
+ completion:^(FIRStorageMetadata *metadata, NSError *error) {
+ XCTAssertNotNil(metadata, "Metadata should not be nil");
+ XCTAssertNil(error, "Error should be nil");
+ }];
+
+ __block long uploadedBytes = -1;
+
+ [task observeStatus:FIRStorageTaskStatusSuccess
+ handler:^(FIRStorageTaskSnapshot *snapshot) {
+ XCTAssertEqualObjects([snapshot description], @"<State: Success>");
+ [expectation fulfill];
+ }];
+
+ [task observeStatus:FIRStorageTaskStatusProgress
+ handler:^(FIRStorageTaskSnapshot *_Nonnull snapshot) {
+ XCTAssertTrue([[snapshot description] containsString:@"State: Progress"] ||
+ [[snapshot description] containsString:@"State: Resume"]);
+ NSProgress *progress = snapshot.progress;
+ XCTAssertGreaterThanOrEqual(progress.completedUnitCount, uploadedBytes);
+ uploadedBytes = progress.completedUnitCount;
+ }];
+
+ [self waitForExpectations];
}
- (void)testPutFileWithSpecialCharacters {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testPutFileWithSpecialCharacters"];
- NSString *fileName = @"hello&+@_ .txt";
- FIRStorageReference *ref =
- [self.storage referenceWithPath:[@"ios/public/" stringByAppendingString:fileName]];
+ NSString *fileName = @"hello&+@_ .txt";
+ FIRStorageReference *ref =
+ [self.storage referenceWithPath:[@"ios/public/" stringByAppendingString:fileName]];
- NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
- NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
- NSURL *fileURL = [tmpDirURL URLByAppendingPathComponent:fileName];
- [data writeToURL:fileURL atomically:YES];
+ NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
+ NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
+ NSURL *fileURL = [tmpDirURL URLByAppendingPathComponent:fileName];
+ [data writeToURL:fileURL atomically:YES];
- [ref putFile:fileURL
+ [ref putFile:fileURL
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
+ XCTAssertNotNil(metadata, "Metadata should not be nil");
+ XCTAssertNil(error, "Error should be nil");
+ XCTAssertEqualObjects(fileName, metadata.name);
+ FIRStorageReference *download =
+ [self.storage referenceWithPath:[@"ios/public/" stringByAppendingString:fileName]];
+ [download metadataWithCompletion:^(FIRStorageMetadata *metadata, NSError *error) {
XCTAssertNotNil(metadata, "Metadata should not be nil");
XCTAssertNil(error, "Error should be nil");
XCTAssertEqualObjects(fileName, metadata.name);
- FIRStorageReference *download =
- [self.storage referenceWithPath:[@"ios/public/" stringByAppendingString:fileName]];
- [download metadataWithCompletion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertNotNil(metadata, "Metadata should not be nil");
- XCTAssertNil(error, "Error should be nil");
- XCTAssertEqualObjects(fileName, metadata.name);
- [expectation fulfill];
- }];
+ [expectation fulfill];
+ }];
}];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testUnauthenticatedSimplePutDataNoMetadata {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimplePutDataNoMetadata"];
- FIRStorageReference *ref =
+ FIRStorageReference *ref =
[self.storage referenceWithPath:@"ios/public/testUnauthenticatedSimplePutDataNoMetadata"];
- NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
+ NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
- [ref putData:data
+ [ref putData:data
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertNotNil(metadata, "Metadata should not be nil");
- XCTAssertNil(error, "Error should be nil");
- [expectation fulfill];
+ XCTAssertNotNil(metadata, "Metadata should not be nil");
+ XCTAssertNil(error, "Error should be nil");
+ [expectation fulfill];
}];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testUnauthenticatedSimplePutFileNoMetadata {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimplePutFileNoMetadata"];
- FIRStorageReference *ref =
+ FIRStorageReference *ref =
[self.storage referenceWithPath:@"ios/public/testUnauthenticatedSimplePutFileNoMetadata"];
- NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
- NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
- NSURL *fileURL =
- [[tmpDirURL URLByAppendingPathComponent:@"hello"] URLByAppendingPathExtension:@"txt"];
- [data writeToURL:fileURL atomically:YES];
+ NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
+ NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
+ NSURL *fileURL =
+ [[tmpDirURL URLByAppendingPathComponent:@"hello"] URLByAppendingPathExtension:@"txt"];
+ [data writeToURL:fileURL atomically:YES];
- [ref putFile:fileURL
+ [ref putFile:fileURL
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
- XCTAssertNotNil(metadata, "Metadata should not be nil");
- XCTAssertNil(error, "Error should be nil");
- [expectation fulfill];
+ XCTAssertNotNil(metadata, "Metadata should not be nil");
+ XCTAssertNil(error, "Error should be nil");
+ [expectation fulfill];
}];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testUnauthenticatedSimpleGetData {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimpleGetData"];
- FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/1mb"];
+ FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/1mb"];
- [ref dataWithMaxSize:1 * 1024 * 1024
- completion:^(NSData *data, NSError *error) {
- XCTAssertNotNil(data, "Data should not be nil");
- XCTAssertNil(error, "Error should be nil");
- [expectation fulfill];
- }];
+ [ref dataWithMaxSize:1 * 1024 * 1024
+ completion:^(NSData *data, NSError *error) {
+ XCTAssertNotNil(data, "Data should not be nil");
+ XCTAssertNil(error, "Error should be nil");
+ [expectation fulfill];
+ }];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testUnauthenticatedSimpleGetDataTooSmall {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimpleGetDataTooSmall"];
- FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/1mb"];
+ FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/1mb"];
- /// Only allow 1kB size, which is smaller than our file
- [ref dataWithMaxSize:1 * 1024
- completion:^(NSData *data, NSError *error) {
- XCTAssertEqual(data, nil);
- XCTAssertEqual(error.code, FIRStorageErrorCodeDownloadSizeExceeded);
- [expectation fulfill];
- }];
+ /// Only allow 1kB size, which is smaller than our file
+ [ref dataWithMaxSize:1 * 1024
+ completion:^(NSData *data, NSError *error) {
+ XCTAssertEqual(data, nil);
+ XCTAssertEqual(error.code, FIRStorageErrorCodeDownloadSizeExceeded);
+ [expectation fulfill];
+ }];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testUnauthenticatedSimpleGetFile {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimpleGetData"];
- FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/helloworld"];
+ FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/helloworld"];
- NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
- NSURL *fileURL =
+ NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
+ NSURL *fileURL =
[[tmpDirURL URLByAppendingPathComponent:@"hello"] URLByAppendingPathExtension:@"txt"];
- [ref putData:[@"Hello World" dataUsingEncoding:NSUTF8StringEncoding] metadata:nil
- completion:^(FIRStorageMetadata *metadata, NSError *error)
- {
+ [ref putData:[@"Hello World" dataUsingEncoding:NSUTF8StringEncoding]
+ metadata:nil
+ completion:^(FIRStorageMetadata *metadata, NSError *error) {
FIRStorageDownloadTask *task = [ref writeToFile:fileURL];
[task observeStatus:FIRStorageTaskStatusSuccess
handler:^(FIRStorageTaskSnapshot *snapshot) {
- NSString *data = [NSString stringWithContentsOfURL:fileURL
- encoding:NSUTF8StringEncoding
- error:NULL];
- NSString *expectedData = @"Hello World";
- XCTAssertEqualObjects(data, expectedData);
- XCTAssertEqualObjects([snapshot description], @"<State: Success>");
- [expectation fulfill];
+ NSString *data = [NSString stringWithContentsOfURL:fileURL
+ encoding:NSUTF8StringEncoding
+ error:NULL];
+ NSString *expectedData = @"Hello World";
+ XCTAssertEqualObjects(data, expectedData);
+ XCTAssertEqualObjects([snapshot description], @"<State: Success>");
+ [expectation fulfill];
}];
[task observeStatus:FIRStorageTaskStatusProgress
handler:^(FIRStorageTaskSnapshot *_Nonnull snapshot) {
- NSProgress *progress = snapshot.progress;
- NSLog(@"%lld of %lld", progress.completedUnitCount, progress.totalUnitCount);
+ NSProgress *progress = snapshot.progress;
+ NSLog(@"%lld of %lld", progress.completedUnitCount, progress.totalUnitCount);
}];
[task observeStatus:FIRStorageTaskStatusFailure
handler:^(FIRStorageTaskSnapshot *snapshot) {
- XCTAssertNil(snapshot.error);
- [expectation fulfill];
+ XCTAssertNil(snapshot.error);
+ [expectation fulfill];
}];
- }];
+ }];
- [self waitForExpectations];
+ [self waitForExpectations];
}
- (void)testCancelDownload {
- XCTestExpectation *expectation =
- [self expectationWithDescription:@"testCancelDownload"];
+ XCTestExpectation *expectation = [self expectationWithDescription:@"testCancelDownload"];
- FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/1mb"];
+ FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/1mb"];
- NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
- NSURL *fileURL =
- [[tmpDirURL URLByAppendingPathComponent:@"hello"] URLByAppendingPathExtension:@"dat"];
+ NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
+ NSURL *fileURL =
+ [[tmpDirURL URLByAppendingPathComponent:@"hello"] URLByAppendingPathExtension:@"dat"];
- FIRStorageDownloadTask *task = [ref writeToFile:fileURL];
+ FIRStorageDownloadTask *task = [ref writeToFile:fileURL];
- [task observeStatus:FIRStorageTaskStatusFailure
- handler:^(FIRStorageTaskSnapshot *snapshot) {
- XCTAssertTrue([[snapshot description] containsString:@"State: Failed"]);
- [expectation fulfill];
- }];
+ [task observeStatus:FIRStorageTaskStatusFailure
+ handler:^(FIRStorageTaskSnapshot *snapshot) {
+ XCTAssertTrue([[snapshot description] containsString:@"State: Failed"]);
+ [expectation fulfill];
+ }];
- [task observeStatus:FIRStorageTaskStatusProgress
- handler:^(FIRStorageTaskSnapshot *_Nonnull snapshot) {
- [task cancel];
- }];
+ [task observeStatus:FIRStorageTaskStatusProgress
+ handler:^(FIRStorageTaskSnapshot *_Nonnull snapshot) {
+ [task cancel];
+ }];
- [self waitForExpectations];
+ [self waitForExpectations];
}
-- (void)assertMetadata:(FIRStorageMetadata *) actualMetadata
- contentType:(NSString *) expectedContentType
- customMetadata:(NSDictionary *) expectedCustomMetadata {
+- (void)assertMetadata:(FIRStorageMetadata *)actualMetadata
+ contentType:(NSString *)expectedContentType
+ customMetadata:(NSDictionary *)expectedCustomMetadata {
XCTAssertEqualObjects(actualMetadata.cacheControl, @"cache-control");
XCTAssertEqualObjects(actualMetadata.contentDisposition, @"content-disposition");
XCTAssertEqualObjects(actualMetadata.contentEncoding, @"gzip");
XCTAssertEqualObjects(actualMetadata.contentLanguage, @"de");
XCTAssertEqualObjects(actualMetadata.contentType, expectedContentType);
- for (NSString* key in expectedCustomMetadata) {
+ for (NSString *key in expectedCustomMetadata) {
XCTAssertEqualObjects([actualMetadata.customMetadata objectForKey:key],
[expectedCustomMetadata objectForKey:key]);
}
}
-- (void)assertMetadataNil:(FIRStorageMetadata *) actualMetadata {
- XCTAssertNil(actualMetadata.cacheControl);
- XCTAssertNil(actualMetadata.contentDisposition);
- XCTAssertEqualObjects(actualMetadata.contentEncoding, @"identity");
- XCTAssertNil(actualMetadata.contentLanguage);
- XCTAssertNil(actualMetadata.contentType);
- XCTAssertNil([actualMetadata.customMetadata objectForKey:@"a"]);
- XCTAssertNil([actualMetadata.customMetadata objectForKey:@"c"]);
- XCTAssertNil([actualMetadata.customMetadata objectForKey:@"f"]);
+- (void)assertMetadataNil:(FIRStorageMetadata *)actualMetadata {
+ XCTAssertNil(actualMetadata.cacheControl);
+ XCTAssertNil(actualMetadata.contentDisposition);
+ XCTAssertEqualObjects(actualMetadata.contentEncoding, @"identity");
+ XCTAssertNil(actualMetadata.contentLanguage);
+ XCTAssertNil(actualMetadata.contentType);
+ XCTAssertNil([actualMetadata.customMetadata objectForKey:@"a"]);
+ XCTAssertNil([actualMetadata.customMetadata objectForKey:@"c"]);
+ XCTAssertNil([actualMetadata.customMetadata objectForKey:@"f"]);
}
- (void)testUpdateMetadata {
@@ -493,100 +494,107 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
metadata.contentType = @"content-type-a";
metadata.customMetadata = @{@"a" : @"b"};
- [ref updateMetadata:metadata completion:^(FIRStorageMetadata *updatedMetadata, NSError *error) {
- XCTAssertNil(error);
- [self assertMetadata:updatedMetadata contentType:@"content-type-a" customMetadata:@{@"a" : @"b"}];
-
- // Update a subset of the metadata using the existing object.
- FIRStorageMetadata *metadata = updatedMetadata;
- metadata.contentType = @"content-type-b";
- metadata.customMetadata = @{@"a" : @"b", @"c" : @"d"};
-
- [ref updateMetadata:metadata completion:^(FIRStorageMetadata *updatedMetadata, NSError *error) {
- XCTAssertNil(error);
- [self assertMetadata:updatedMetadata contentType:@"content-type-b" customMetadata: @{@"a" : @"b", @"c" : @"d"}];
-
- // Clear all metadata.
- FIRStorageMetadata *metadata = updatedMetadata;
- metadata.cacheControl = nil;
- metadata.contentDisposition = nil;
- metadata.contentEncoding = nil;
- metadata.contentLanguage = nil;
- metadata.contentType = nil;
- metadata.customMetadata = [NSDictionary dictionary];
-
- [ref updateMetadata:metadata completion:^(FIRStorageMetadata *updatedMetadata, NSError *error) {
- XCTAssertNil(error);
- [self assertMetadataNil:updatedMetadata];
- [expectation fulfill];
- }];
- }];
- }];
+ [ref updateMetadata:metadata
+ completion:^(FIRStorageMetadata *updatedMetadata, NSError *error) {
+ XCTAssertNil(error);
+ [self assertMetadata:updatedMetadata
+ contentType:@"content-type-a"
+ customMetadata:@{@"a" : @"b"}];
+
+ // Update a subset of the metadata using the existing object.
+ FIRStorageMetadata *metadata = updatedMetadata;
+ metadata.contentType = @"content-type-b";
+ metadata.customMetadata = @{@"a" : @"b", @"c" : @"d"};
+
+ [ref updateMetadata:metadata
+ completion:^(FIRStorageMetadata *updatedMetadata, NSError *error) {
+ XCTAssertNil(error);
+ [self assertMetadata:updatedMetadata
+ contentType:@"content-type-b"
+ customMetadata:@{@"a" : @"b", @"c" : @"d"}];
+
+ // Clear all metadata.
+ FIRStorageMetadata *metadata = updatedMetadata;
+ metadata.cacheControl = nil;
+ metadata.contentDisposition = nil;
+ metadata.contentEncoding = nil;
+ metadata.contentLanguage = nil;
+ metadata.contentType = nil;
+ metadata.customMetadata = [NSDictionary dictionary];
+
+ [ref updateMetadata:metadata
+ completion:^(FIRStorageMetadata *updatedMetadata, NSError *error) {
+ XCTAssertNil(error);
+ [self assertMetadataNil:updatedMetadata];
+ [expectation fulfill];
+ }];
+ }];
+ }];
[self waitForExpectations];
}
- (void)testUnauthenticatedResumeGetFile {
- XCTestExpectation *expectation =
+ XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedResumeGetFile"];
- FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/1mb"];
-
- NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
- NSURL *fileURL =
- [[tmpDirURL URLByAppendingPathComponent:@"hello"] URLByAppendingPathExtension:@"txt"];
-
- __block long resumeAtBytes = 256 * 1024;
- __block long downloadedBytes = 0;
- __block double computationResult = 0;
-
- FIRStorageDownloadTask *task = [ref writeToFile:fileURL];
-
- [task observeStatus:FIRStorageTaskStatusSuccess
- handler:^(FIRStorageTaskSnapshot *snapshot) {
- XCTAssertEqualObjects([snapshot description], @"<State: Success>");
- [expectation fulfill];
- }];
-
- [task observeStatus:FIRStorageTaskStatusProgress
- handler:^(FIRStorageTaskSnapshot *_Nonnull snapshot) {
- XCTAssertTrue([[snapshot description] containsString:@"State: Progress"] ||
- [[snapshot description] containsString:@"State: Resume"]);
- NSProgress *progress = snapshot.progress;
- XCTAssertGreaterThanOrEqual(progress.completedUnitCount, downloadedBytes);
- downloadedBytes = progress.completedUnitCount;
- if (progress.completedUnitCount > resumeAtBytes) {
- // Making sure the main run loop is busy.
- for (int i = 0; i < 500; ++i) {
- dispatch_async(dispatch_get_main_queue(), ^ {
- computationResult = sqrt(INT_MAX - i);
- });
- }
- NSLog(@"Pausing");
- [task pause];
- resumeAtBytes = INT_MAX;
- }
- }];
-
- [task observeStatus:FIRStorageTaskStatusPause
- handler:^(FIRStorageTaskSnapshot *snapshot) {
- XCTAssertEqualObjects([snapshot description], @"<State: Paused>");
- NSLog(@"Resuming");
- [task resume];
- }];
+ FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/1mb"];
- [self waitForExpectations];
- XCTAssertEqual(INT_MAX, resumeAtBytes);
- XCTAssertEqualWithAccuracy(sqrt(INT_MAX - 499), computationResult, 0.1);
+ NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
+ NSURL *fileURL =
+ [[tmpDirURL URLByAppendingPathComponent:@"hello"] URLByAppendingPathExtension:@"txt"];
+
+ __block long resumeAtBytes = 256 * 1024;
+ __block long downloadedBytes = 0;
+ __block double computationResult = 0;
+
+ FIRStorageDownloadTask *task = [ref writeToFile:fileURL];
+
+ [task observeStatus:FIRStorageTaskStatusSuccess
+ handler:^(FIRStorageTaskSnapshot *snapshot) {
+ XCTAssertEqualObjects([snapshot description], @"<State: Success>");
+ [expectation fulfill];
+ }];
+
+ [task observeStatus:FIRStorageTaskStatusProgress
+ handler:^(FIRStorageTaskSnapshot *_Nonnull snapshot) {
+ XCTAssertTrue([[snapshot description] containsString:@"State: Progress"] ||
+ [[snapshot description] containsString:@"State: Resume"]);
+ NSProgress *progress = snapshot.progress;
+ XCTAssertGreaterThanOrEqual(progress.completedUnitCount, downloadedBytes);
+ downloadedBytes = progress.completedUnitCount;
+ if (progress.completedUnitCount > resumeAtBytes) {
+ // Making sure the main run loop is busy.
+ for (int i = 0; i < 500; ++i) {
+ dispatch_async(dispatch_get_main_queue(), ^{
+ computationResult = sqrt(INT_MAX - i);
+ });
+ }
+ NSLog(@"Pausing");
+ [task pause];
+ resumeAtBytes = INT_MAX;
+ }
+ }];
+
+ [task observeStatus:FIRStorageTaskStatusPause
+ handler:^(FIRStorageTaskSnapshot *snapshot) {
+ XCTAssertEqualObjects([snapshot description], @"<State: Paused>");
+ NSLog(@"Resuming");
+ [task resume];
+ }];
+
+ [self waitForExpectations];
+ XCTAssertEqual(INT_MAX, resumeAtBytes);
+ XCTAssertEqualWithAccuracy(sqrt(INT_MAX - 499), computationResult, 0.1);
}
- (void)waitForExpectations {
- [self waitForExpectationsWithTimeout:kFIRStorageIntegrationTestTimeout
- handler:^(NSError *_Nullable error) {
- if (error) {
- NSLog(@"%@", error);
- }
- }];
+ [self waitForExpectationsWithTimeout:kFIRStorageIntegrationTestTimeout
+ handler:^(NSError *_Nullable error) {
+ if (error) {
+ NSLog(@"%@", error);
+ }
+ }];
}
@end
diff --git a/Example/Storage/Tests/Unit/FIRStorageDeleteTests.m b/Example/Storage/Tests/Unit/FIRStorageDeleteTests.m
index 42a3b1a..4311ab3 100644
--- a/Example/Storage/Tests/Unit/FIRStorageDeleteTests.m
+++ b/Example/Storage/Tests/Unit/FIRStorageDeleteTests.m
@@ -29,7 +29,7 @@
- (void)setUp {
[super setUp];
- NSDictionary *metadataDict = @{ @"bucket" : @"bucket", @"name" : @"path/to/object" };
+ NSDictionary *metadataDict = @{@"bucket" : @"bucket", @"name" : @"path/to/object"};
self.metadata = [[FIRStorageMetadata alloc] initWithDictionary:metadataDict];
id mockOptions = OCMClassMock([FIROptions class]);
@@ -64,11 +64,10 @@
XCTAssertEqualObjects(fetcher.request.URL, [FIRStorageTestHelpers objectURL]);
#pragma clang diagnostic pop
XCTAssertEqualObjects(fetcher.request.HTTPMethod, @"DELETE");
- NSHTTPURLResponse *httpResponse =
- [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
- statusCode:200
- HTTPVersion:kHTTPVersion
- headerFields:nil];
+ NSHTTPURLResponse *httpResponse = [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
+ statusCode:200
+ HTTPVersion:kHTTPVersion
+ headerFields:nil];
response(httpResponse, nil, nil);
};
@@ -108,14 +107,13 @@
self.fetcherService.testBlock = [FIRStorageTestHelpers unauthenticatedBlock];
FIRStoragePath *path = [FIRStorageTestHelpers objectPath];
FIRStorageReference *ref = [[FIRStorageReference alloc] initWithStorage:self.storage path:path];
- FIRStorageDeleteTask *task =
- [[FIRStorageDeleteTask alloc] initWithReference:ref
- fetcherService:self.fetcherService
- completion:^(NSError *error) {
- XCTAssertEqual(error.code,
- FIRStorageErrorCodeUnauthenticated);
- [expectation fulfill];
- }];
+ FIRStorageDeleteTask *task = [[FIRStorageDeleteTask alloc]
+ initWithReference:ref
+ fetcherService:self.fetcherService
+ completion:^(NSError *error) {
+ XCTAssertEqual(error.code, FIRStorageErrorCodeUnauthenticated);
+ [expectation fulfill];
+ }];
[task enqueue];
[FIRStorageTestHelpers waitForExpectation:self];
@@ -128,14 +126,13 @@
self.fetcherService.testBlock = [FIRStorageTestHelpers unauthorizedBlock];
FIRStoragePath *path = [FIRStorageTestHelpers objectPath];
FIRStorageReference *ref = [[FIRStorageReference alloc] initWithStorage:self.storage path:path];
- FIRStorageDeleteTask *task =
- [[FIRStorageDeleteTask alloc] initWithReference:ref
- fetcherService:self.fetcherService
- completion:^(NSError *error) {
- XCTAssertEqual(error.code,
- FIRStorageErrorCodeUnauthorized);
- [expectation fulfill];
- }];
+ FIRStorageDeleteTask *task = [[FIRStorageDeleteTask alloc]
+ initWithReference:ref
+ fetcherService:self.fetcherService
+ completion:^(NSError *error) {
+ XCTAssertEqual(error.code, FIRStorageErrorCodeUnauthorized);
+ [expectation fulfill];
+ }];
[task enqueue];
[FIRStorageTestHelpers waitForExpectation:self];
@@ -148,14 +145,13 @@
self.fetcherService.testBlock = [FIRStorageTestHelpers notFoundBlock];
FIRStoragePath *path = [FIRStorageTestHelpers notFoundPath];
FIRStorageReference *ref = [[FIRStorageReference alloc] initWithStorage:self.storage path:path];
- FIRStorageDeleteTask *task =
- [[FIRStorageDeleteTask alloc] initWithReference:ref
- fetcherService:self.fetcherService
- completion:^(NSError *error) {
- XCTAssertEqual(error.code,
- FIRStorageErrorCodeObjectNotFound);
- [expectation fulfill];
- }];
+ FIRStorageDeleteTask *task = [[FIRStorageDeleteTask alloc]
+ initWithReference:ref
+ fetcherService:self.fetcherService
+ completion:^(NSError *error) {
+ XCTAssertEqual(error.code, FIRStorageErrorCodeObjectNotFound);
+ [expectation fulfill];
+ }];
[task enqueue];
[FIRStorageTestHelpers waitForExpectation:self];
diff --git a/Example/Storage/Tests/Unit/FIRStorageGetMetadataTests.m b/Example/Storage/Tests/Unit/FIRStorageGetMetadataTests.m
index 72a057d..1f19b00 100644
--- a/Example/Storage/Tests/Unit/FIRStorageGetMetadataTests.m
+++ b/Example/Storage/Tests/Unit/FIRStorageGetMetadataTests.m
@@ -29,7 +29,7 @@
- (void)setUp {
[super setUp];
- NSDictionary *metadataDict = @{ @"bucket" : @"bucket", @"name" : @"path/to/object" };
+ NSDictionary *metadataDict = @{@"bucket" : @"bucket", @"name" : @"path/to/object"};
self.metadata = [[FIRStorageMetadata alloc] initWithDictionary:metadataDict];
id mockOptions = OCMClassMock([FIROptions class]);
@@ -64,11 +64,10 @@
XCTAssertEqualObjects(fetcher.request.URL, [FIRStorageTestHelpers objectURL]);
#pragma clang diagnostic pop
XCTAssertEqualObjects(fetcher.request.HTTPMethod, @"GET");
- NSHTTPURLResponse *httpResponse =
- [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
- statusCode:200
- HTTPVersion:kHTTPVersion
- headerFields:nil];
+ NSHTTPURLResponse *httpResponse = [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
+ statusCode:200
+ HTTPVersion:kHTTPVersion
+ headerFields:nil];
response(httpResponse, nil, nil);
};
diff --git a/Example/Storage/Tests/Unit/FIRStorageMetadataTests.m b/Example/Storage/Tests/Unit/FIRStorageMetadataTests.m
index e750bdf..d6a73e7 100644
--- a/Example/Storage/Tests/Unit/FIRStorageMetadataTests.m
+++ b/Example/Storage/Tests/Unit/FIRStorageMetadataTests.m
@@ -263,16 +263,16 @@
}
- (void)testUpdatedMetadataWithEmptyUpdate {
- NSDictionary *oldMetadata = @{
- kFIRStorageMetadataContentLanguage : @"old",
- kFIRStorageMetadataCustomMetadata : @{@"foo" : @"old", @"bar" : @"old"}
- };
- FIRStorageMetadata *metadata = [[FIRStorageMetadata alloc] initWithDictionary:oldMetadata];
+ NSDictionary *oldMetadata = @{
+ kFIRStorageMetadataContentLanguage : @"old",
+ kFIRStorageMetadataCustomMetadata : @{@"foo" : @"old", @"bar" : @"old"}
+ };
+ FIRStorageMetadata *metadata = [[FIRStorageMetadata alloc] initWithDictionary:oldMetadata];
- NSDictionary *update = [metadata updatedMetadata];
+ NSDictionary *update = [metadata updatedMetadata];
- NSDictionary *expectedUpdate = @{ kFIRStorageMetadataCustomMetadata : @{} };
- XCTAssertEqualObjects(update, expectedUpdate);
+ NSDictionary *expectedUpdate = @{ kFIRStorageMetadataCustomMetadata : @{} };
+ XCTAssertEqualObjects(update, expectedUpdate);
}
- (void)testUpdatedMetadataWithDelete {
@@ -305,31 +305,31 @@
}
- (void)testZuluTimeOffset {
- NSDictionary *metaDict = @{ kFIRStorageMetadataTimeCreated : @"1992-08-07T17:22:53.108Z" };
+ NSDictionary *metaDict = @{kFIRStorageMetadataTimeCreated : @"1992-08-07T17:22:53.108Z"};
FIRStorageMetadata *metadata = [[FIRStorageMetadata alloc] initWithDictionary:metaDict];
XCTAssertNotNil(metadata.timeCreated);
}
- (void)testZuluZeroTimeOffset {
- NSDictionary *metaDict = @{ kFIRStorageMetadataTimeCreated : @"1992-08-07T17:22:53.108+0000" };
+ NSDictionary *metaDict = @{kFIRStorageMetadataTimeCreated : @"1992-08-07T17:22:53.108+0000"};
FIRStorageMetadata *metadata = [[FIRStorageMetadata alloc] initWithDictionary:metaDict];
XCTAssertNotNil(metadata.timeCreated);
}
- (void)testGoogleStandardTimeOffset {
- NSDictionary *metaDict = @{ kFIRStorageMetadataTimeCreated : @"1992-08-07T17:22:53.108-0700" };
+ NSDictionary *metaDict = @{kFIRStorageMetadataTimeCreated : @"1992-08-07T17:22:53.108-0700"};
FIRStorageMetadata *metadata = [[FIRStorageMetadata alloc] initWithDictionary:metaDict];
XCTAssertNotNil(metadata.timeCreated);
}
- (void)testUnspecifiedTimeOffset {
- NSDictionary *metaDict = @{ kFIRStorageMetadataTimeCreated : @"1992-08-07T17:22:53.108-0000" };
+ NSDictionary *metaDict = @{kFIRStorageMetadataTimeCreated : @"1992-08-07T17:22:53.108-0000"};
FIRStorageMetadata *metadata = [[FIRStorageMetadata alloc] initWithDictionary:metaDict];
XCTAssertNotNil(metadata.timeCreated);
}
- (void)testNoTimeOffset {
- NSDictionary *metaDict = @{ kFIRStorageMetadataTimeCreated : @"1992-08-07T17:22:53.108" };
+ NSDictionary *metaDict = @{kFIRStorageMetadataTimeCreated : @"1992-08-07T17:22:53.108"};
FIRStorageMetadata *metadata = [[FIRStorageMetadata alloc] initWithDictionary:metaDict];
XCTAssertNil(metadata.timeCreated);
}
diff --git a/Example/Storage/Tests/Unit/FIRStorageTestHelpers.m b/Example/Storage/Tests/Unit/FIRStorageTestHelpers.m
index fef67ef..2039f22 100644
--- a/Example/Storage/Tests/Unit/FIRStorageTestHelpers.m
+++ b/Example/Storage/Tests/Unit/FIRStorageTestHelpers.m
@@ -97,16 +97,15 @@ NSString *const kFIRStorageAppName = @"app";
+ (GTMSessionFetcherTestBlock)blockForData:(nullable NSData *)data statusCode:(NSInteger)code {
GTMSessionFetcherTestBlock block =
^(GTMSessionFetcher *fetcher, GTMSessionFetcherTestResponse response) {
- NSHTTPURLResponse *httpResponse =
- [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
- statusCode:code
- HTTPVersion:kHTTPVersion
- headerFields:nil];
+ NSHTTPURLResponse *httpResponse = [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
+ statusCode:code
+ HTTPVersion:kHTTPVersion
+ headerFields:nil];
NSError *error;
if (code >= 400) {
NSDictionary *userInfo;
if (data) {
- userInfo = @{ @"data" : data };
+ userInfo = @{@"data" : data};
}
error = [NSError errorWithDomain:kGoogleHTTPErrorDomain code:code userInfo:userInfo];
}
diff --git a/Example/Storage/Tests/Unit/FIRStorageTests.m b/Example/Storage/Tests/Unit/FIRStorageTests.m
index 1b45295..503ac94 100644
--- a/Example/Storage/Tests/Unit/FIRStorageTests.m
+++ b/Example/Storage/Tests/Unit/FIRStorageTests.m
@@ -43,7 +43,7 @@
}
- (void)testBucketNotEnforced {
- FIROptions * mockOptions = OCMClassMock([FIROptions class]);
+ FIROptions *mockOptions = OCMClassMock([FIROptions class]);
OCMStub([mockOptions storageBucket]).andReturn(@"");
FIRApp *app = OCMClassMock([FIRApp class]);
OCMStub([app name]).andReturn(kFIRStorageAppName);
@@ -55,40 +55,39 @@
}
- (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"];
XCTAssertThrows([storage referenceForURL:@"gs://benwu-test2.storage.firebase.com/child"]);
}
-- (void) testInitWithCustomUrl {
+- (void)testInitWithCustomUrl {
FIRStorage *storage = [FIRStorage storageForApp:self.app URL:@"gs://foo-bar.appspot.com"];
XCTAssertEqualObjects(@"gs://foo-bar.appspot.com/", [[storage reference] description]);
storage = [FIRStorage storageForApp:self.app URL:@"gs://foo-bar.appspot.com/"];
XCTAssertEqualObjects(@"gs://foo-bar.appspot.com/", [[storage reference] description]);
}
-- (void) testInitWithWrongScheme {
+- (void)testInitWithWrongScheme {
XCTAssertThrows([FIRStorage storageForApp:self.app URL:@"http://foo-bar.appspot.com"]);
}
-- (void) testInitWithNoScheme {
+- (void)testInitWithNoScheme {
XCTAssertThrows([FIRStorage storageForApp:self.app URL:@"foo-bar.appspot.com"]);
}
-- (void) testInitWithNilURL {
+- (void)testInitWithNilURL {
XCTAssertThrows([FIRStorage storageForApp:self.app URL:nil]);
}
-- (void) testInitWithPath {
+- (void)testInitWithPath {
XCTAssertThrows([FIRStorage storageForApp:self.app URL:@"gs://foo-bar.appspot.com/child"]);
}
-- (void) testInitWithDefaultAndCustomUrl {
- FIRStorage *customInstance = [FIRStorage storageForApp:self.app
- URL:@"gs://foo-bar.appspot.com"];
+- (void)testInitWithDefaultAndCustomUrl {
+ FIRStorage *customInstance = [FIRStorage storageForApp:self.app URL:@"gs://foo-bar.appspot.com"];
FIRStorage *defaultInstance = [FIRStorage storageForApp:self.app];
XCTAssertEqualObjects(@"gs://foo-bar.appspot.com/", [[customInstance reference] description]);
XCTAssertEqualObjects(@"gs://bucket/", [[defaultInstance reference] description]);
diff --git a/Example/Storage/Tests/Unit/FIRStorageTokenAuthorizerTests.m b/Example/Storage/Tests/Unit/FIRStorageTokenAuthorizerTests.m
index bc60fb4..26627b5 100644
--- a/Example/Storage/Tests/Unit/FIRStorageTokenAuthorizerTests.m
+++ b/Example/Storage/Tests/Unit/FIRStorageTokenAuthorizerTests.m
@@ -56,23 +56,22 @@
#pragma clang diagnostic ignored "-Warc-retain-cycles"
XCTAssertTrue([self.fetcher.authorizer isAuthorizedRequest:fetcher.request]);
#pragma clang diagnostic pop
- NSHTTPURLResponse *httpResponse =
- [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
- statusCode:200
- HTTPVersion:kHTTPVersion
- headerFields:nil];
+ NSHTTPURLResponse *httpResponse = [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
+ statusCode:200
+ HTTPVersion:kHTTPVersion
+ headerFields:nil];
response(httpResponse, nil, nil);
};
- [self.fetcher beginFetchWithCompletionHandler:^(NSData *_Nullable data,
- NSError *_Nullable error) {
- NSDictionary<NSString *, NSString *> *headers = self.fetcher.request.allHTTPHeaderFields;
- NSString *authHeader = [headers objectForKey:@"Authorization"];
- NSString *firebaseToken =
- [NSString stringWithFormat:kFIRStorageAuthTokenFormat, kFIRStorageTestAuthToken];
- XCTAssertEqualObjects(authHeader, firebaseToken);
- [expectation fulfill];
- }];
+ [self.fetcher
+ beginFetchWithCompletionHandler:^(NSData *_Nullable data, NSError *_Nullable error) {
+ NSDictionary<NSString *, NSString *> *headers = self.fetcher.request.allHTTPHeaderFields;
+ NSString *authHeader = [headers objectForKey:@"Authorization"];
+ NSString *firebaseToken =
+ [NSString stringWithFormat:kFIRStorageAuthTokenFormat, kFIRStorageTestAuthToken];
+ XCTAssertEqualObjects(authHeader, firebaseToken);
+ [expectation fulfill];
+ }];
[FIRStorageTestHelpers waitForExpectation:self];
}
@@ -98,23 +97,22 @@
#pragma clang diagnostic ignored "-Warc-retain-cycles"
XCTAssertEqual([self.fetcher.authorizer isAuthorizedRequest:fetcher.request], NO);
#pragma cland diagnostic pop
- NSHTTPURLResponse *httpResponse =
- [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
- statusCode:401
- HTTPVersion:kHTTPVersion
- headerFields:nil];
+ NSHTTPURLResponse *httpResponse = [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
+ statusCode:401
+ HTTPVersion:kHTTPVersion
+ headerFields:nil];
response(httpResponse, nil, authError);
};
- [self.fetcher beginFetchWithCompletionHandler:^(NSData *_Nullable data,
- NSError *_Nullable error) {
- NSDictionary<NSString *, NSString *> *headers = self.fetcher.request.allHTTPHeaderFields;
- NSString *authHeader = [headers objectForKey:@"Authorization"];
- XCTAssertNil(authHeader);
- XCTAssertEqualObjects(error.domain, FIRStorageErrorDomain);
- XCTAssertEqual(error.code, FIRStorageErrorCodeUnauthenticated);
- [expectation fulfill];
- }];
+ [self.fetcher
+ beginFetchWithCompletionHandler:^(NSData *_Nullable data, NSError *_Nullable error) {
+ NSDictionary<NSString *, NSString *> *headers = self.fetcher.request.allHTTPHeaderFields;
+ NSString *authHeader = [headers objectForKey:@"Authorization"];
+ XCTAssertNil(authHeader);
+ XCTAssertEqualObjects(error.domain, FIRStorageErrorDomain);
+ XCTAssertEqual(error.code, FIRStorageErrorCodeUnauthenticated);
+ [expectation fulfill];
+ }];
[FIRStorageTestHelpers waitForExpectation:self];
}
@@ -134,22 +132,21 @@
#pragma clang diagnostic ignored "-Warc-retain-cycles"
XCTAssertFalse([self.fetcher.authorizer isAuthorizedRequest:fetcher.request]);
#pragma cland diagnostic pop
- NSHTTPURLResponse *httpResponse =
- [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
- statusCode:200
- HTTPVersion:kHTTPVersion
- headerFields:nil];
+ NSHTTPURLResponse *httpResponse = [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
+ statusCode:200
+ HTTPVersion:kHTTPVersion
+ headerFields:nil];
response(httpResponse, nil, nil);
};
- [self.fetcher beginFetchWithCompletionHandler:^(NSData *_Nullable data,
- NSError *_Nullable error) {
- NSDictionary<NSString *, NSString *> *headers = self.fetcher.request.allHTTPHeaderFields;
- NSString *authHeader = [headers objectForKey:@"Authorization"];
- XCTAssertNil(authHeader);
- XCTAssertNil(error);
- [expectation fulfill];
- }];
+ [self.fetcher
+ beginFetchWithCompletionHandler:^(NSData *_Nullable data, NSError *_Nullable error) {
+ NSDictionary<NSString *, NSString *> *headers = self.fetcher.request.allHTTPHeaderFields;
+ NSString *authHeader = [headers objectForKey:@"Authorization"];
+ XCTAssertNil(authHeader);
+ XCTAssertNil(error);
+ [expectation fulfill];
+ }];
[FIRStorageTestHelpers waitForExpectation:self];
}
@@ -159,11 +156,10 @@
self.fetcher.testBlock = ^(GTMSessionFetcher *fetcher, GTMSessionFetcherTestResponse response) {
XCTAssertFalse([fetcher.authorizer isAuthorizingRequest:fetcher.request]);
- NSHTTPURLResponse *httpResponse =
- [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
- statusCode:200
- HTTPVersion:kHTTPVersion
- headerFields:nil];
+ NSHTTPURLResponse *httpResponse = [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
+ statusCode:200
+ HTTPVersion:kHTTPVersion
+ headerFields:nil];
response(httpResponse, nil, nil);
};
@@ -183,23 +179,22 @@
// will still result in successful authentication
[fetcher.authorizer stopAuthorization];
[fetcher.authorizer stopAuthorizationForRequest:fetcher.request];
- NSHTTPURLResponse *httpResponse =
- [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
- statusCode:200
- HTTPVersion:kHTTPVersion
- headerFields:nil];
+ NSHTTPURLResponse *httpResponse = [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
+ statusCode:200
+ HTTPVersion:kHTTPVersion
+ headerFields:nil];
response(httpResponse, nil, nil);
};
- [self.fetcher beginFetchWithCompletionHandler:^(NSData *_Nullable data,
- NSError *_Nullable error) {
- NSDictionary<NSString *, NSString *> *headers = self.fetcher.request.allHTTPHeaderFields;
- NSString *authHeader = [headers objectForKey:@"Authorization"];
- NSString *firebaseToken =
- [NSString stringWithFormat:kFIRStorageAuthTokenFormat, kFIRStorageTestAuthToken];
- XCTAssertEqualObjects(authHeader, firebaseToken);
- [expectation fulfill];
- }];
+ [self.fetcher
+ beginFetchWithCompletionHandler:^(NSData *_Nullable data, NSError *_Nullable error) {
+ NSDictionary<NSString *, NSString *> *headers = self.fetcher.request.allHTTPHeaderFields;
+ NSString *authHeader = [headers objectForKey:@"Authorization"];
+ NSString *firebaseToken =
+ [NSString stringWithFormat:kFIRStorageAuthTokenFormat, kFIRStorageTestAuthToken];
+ XCTAssertEqualObjects(authHeader, firebaseToken);
+ [expectation fulfill];
+ }];
[FIRStorageTestHelpers waitForExpectation:self];
}
@@ -209,11 +204,10 @@
self.fetcher.testBlock = ^(GTMSessionFetcher *fetcher, GTMSessionFetcherTestResponse response) {
XCTAssertNil([fetcher.authorizer userEmail]);
- NSHTTPURLResponse *httpResponse =
- [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
- statusCode:200
- HTTPVersion:kHTTPVersion
- headerFields:nil];
+ NSHTTPURLResponse *httpResponse = [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
+ statusCode:200
+ HTTPVersion:kHTTPVersion
+ headerFields:nil];
response(httpResponse, nil, nil);
};
diff --git a/Example/Storage/Tests/Unit/FIRStorageUpdateMetadataTests.m b/Example/Storage/Tests/Unit/FIRStorageUpdateMetadataTests.m
index d2d2950..62ac6a5 100644
--- a/Example/Storage/Tests/Unit/FIRStorageUpdateMetadataTests.m
+++ b/Example/Storage/Tests/Unit/FIRStorageUpdateMetadataTests.m
@@ -30,7 +30,7 @@
- (void)setUp {
[super setUp];
- NSDictionary *metadataDict = @{ @"bucket" : @"bucket", @"name" : @"path/to/object" };
+ NSDictionary *metadataDict = @{@"bucket" : @"bucket", @"name" : @"path/to/object"};
self.metadata = [[FIRStorageMetadata alloc] initWithDictionary:metadataDict];
id mockOptions = OCMClassMock([FIROptions class]);
@@ -58,26 +58,25 @@
- (void)testFetcherConfiguration {
XCTestExpectation *expectation = [self expectationWithDescription:@"testSuccessfulFetch"];
- self.fetcherService.testBlock = ^(GTMSessionFetcher *fetcher,
- GTMSessionFetcherTestResponse response) {
+ self.fetcherService.testBlock =
+ ^(GTMSessionFetcher *fetcher, GTMSessionFetcherTestResponse response) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-retain-cycles"
- XCTAssertEqualObjects(fetcher.request.URL, [FIRStorageTestHelpers objectURL]);
- XCTAssertEqualObjects(fetcher.request.HTTPMethod, @"PATCH");
- NSData *bodyData = [NSData frs_dataFromJSONDictionary:[self.metadata updatedMetadata]];
- XCTAssertEqualObjects(fetcher.request.HTTPBody, bodyData);
- NSDictionary *HTTPHeaders = fetcher.request.allHTTPHeaderFields;
- XCTAssertEqualObjects(HTTPHeaders[@"Content-Type"], @"application/json; charset=UTF-8");
- XCTAssertEqualObjects(HTTPHeaders[@"Content-Length"], [@(bodyData.length) stringValue]);
+ XCTAssertEqualObjects(fetcher.request.URL, [FIRStorageTestHelpers objectURL]);
+ XCTAssertEqualObjects(fetcher.request.HTTPMethod, @"PATCH");
+ NSData *bodyData = [NSData frs_dataFromJSONDictionary:[self.metadata updatedMetadata]];
+ XCTAssertEqualObjects(fetcher.request.HTTPBody, bodyData);
+ NSDictionary *HTTPHeaders = fetcher.request.allHTTPHeaderFields;
+ XCTAssertEqualObjects(HTTPHeaders[@"Content-Type"], @"application/json; charset=UTF-8");
+ XCTAssertEqualObjects(HTTPHeaders[@"Content-Length"], [@(bodyData.length) stringValue]);
#pragma clang diagnostic pop
- NSHTTPURLResponse *httpResponse =
- [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
- statusCode:200
- HTTPVersion:kHTTPVersion
- headerFields:nil];
- response(httpResponse, nil, nil);
- self.fetcherService.testBlock = nil;
- };
+ NSHTTPURLResponse *httpResponse = [[NSHTTPURLResponse alloc] initWithURL:fetcher.request.URL
+ statusCode:200
+ HTTPVersion:kHTTPVersion
+ headerFields:nil];
+ response(httpResponse, nil, nil);
+ self.fetcherService.testBlock = nil;
+ };
FIRStoragePath *path = [FIRStorageTestHelpers objectPath];
FIRStorageReference *ref = [[FIRStorageReference alloc] initWithStorage:self.storage path:path];
diff --git a/Example/Storage/Tests/Unit/FIRStorageUtilsTests.m b/Example/Storage/Tests/Unit/FIRStorageUtilsTests.m
index 8bf4c7e..7e4a046 100644
--- a/Example/Storage/Tests/Unit/FIRStorageUtilsTests.m
+++ b/Example/Storage/Tests/Unit/FIRStorageUtilsTests.m
@@ -43,7 +43,7 @@
NSString *JSONString = @"{\"hello\" : \"world\"}";
NSData *JSONData = [JSONString dataUsingEncoding:NSUTF8StringEncoding];
NSDictionary *JSONDictionary = [NSDictionary frs_dictionaryFromJSONData:JSONData];
- NSDictionary *expectedDictionary = @{ @"hello" : @"world" };
+ NSDictionary *expectedDictionary = @{@"hello" : @"world"};
XCTAssertEqualObjects(JSONDictionary, expectedDictionary);
}
@@ -60,7 +60,7 @@
}
- (void)testParseGoodDictToData {
- NSDictionary *JSONDictionary = @{ @"hello" : @"world" };
+ NSDictionary *JSONDictionary = @{@"hello" : @"world"};
NSData *expectedData = [NSData frs_dataFromJSONDictionary:JSONDictionary];
NSString *JSONString = [[NSString alloc] initWithData:expectedData encoding:NSUTF8StringEncoding];
NSString *expectedString = @"{\"hello\":\"world\"}";
@@ -85,13 +85,13 @@
}
- (void)testSingleItemToQueryString {
- NSDictionary *params = @{ @"foo" : @"bar" };
+ NSDictionary *params = @{@"foo" : @"bar"};
NSString *queryString = [FIRStorageUtils queryStringForDictionary:params];
XCTAssertEqualObjects(queryString, @"foo=bar");
}
- (void)testMultiItemDictToQueryString {
- NSDictionary *params = @{ @"foo" : @"bar", @"baz" : @"qux" };
+ NSDictionary *params = @{@"foo" : @"bar", @"baz" : @"qux"};
NSString *queryString = [FIRStorageUtils queryStringForDictionary:params];
XCTAssertEqualObjects(queryString, @"foo=bar&baz=qux");
}
diff --git a/Firebase/Storage/FIRStorage.m b/Firebase/Storage/FIRStorage.m
index dd11391..21657bc 100644
--- a/Firebase/Storage/FIRStorage.m
+++ b/Firebase/Storage/FIRStorage.m
@@ -38,8 +38,7 @@ static GTMSessionFetcherRetryBlock _retryWhenOffline;
+ (void)initialize {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
- _retryWhenOffline = ^(BOOL suggestedWillRetry,
- NSError * GTM_NULLABLE_TYPE error,
+ _retryWhenOffline = ^(BOOL suggestedWillRetry, NSError *GTM_NULLABLE_TYPE error,
GTMSessionFetcherRetryResponse response) {
bool shouldRetry = suggestedWillRetry;
// GTMSessionFetcher does not consider being offline a retryable error, but we do, so we
@@ -84,11 +83,12 @@ static GTMSessionFetcherRetryBlock _retryWhenOffline;
}
+ (instancetype)storageForApp:(FIRApp *)app {
- NSString* url;
+ NSString *url;
if (app.options.storageBucket) {
- url = [app.options.storageBucket isEqualToString:@""] ? @""
- : [@"gs://" stringByAppendingString:app.options.storageBucket];
+ url = [app.options.storageBucket isEqualToString:@""]
+ ? @""
+ : [@"gs://" stringByAppendingString:app.options.storageBucket];
}
return [self storageForApp:app URL:url];
diff --git a/Firebase/Storage/FIRStorageConstants.m b/Firebase/Storage/FIRStorageConstants.m
index aa3da1b..2018b42 100644
--- a/Firebase/Storage/FIRStorageConstants.m
+++ b/Firebase/Storage/FIRStorageConstants.m
@@ -40,8 +40,10 @@ NSString *const kFIRStorageResponseBody = @"ResponseBody";
NSString *const FIRStorageErrorDomain = @"FIRStorageErrorDomain";
NSString *const kFIRStorageInvalidDataFormat = @"Invalid data returned from the server: %@";
-NSString *const kFIRStorageInvalidObserverStatus = @"Invalid observer status requested, use one "
- @"of: FIRStorageTaskStatusPause, Resume, Progress, " @"Complete, or Failure";
+NSString *const kFIRStorageInvalidObserverStatus =
+ @"Invalid observer status requested, use one "
+ @"of: FIRStorageTaskStatusPause, Resume, Progress, "
+ @"Complete, or Failure";
/**
* String constants mapping GCS Object#resource mappings to metadata fields.
@@ -80,4 +82,4 @@ NSString *const kFIRStorageBundleIdentifier = @"com.google.firebase.storage";
#define STR(x) STR_EXPAND(x)
#define STR_EXPAND(x) #x
const unsigned char *const FIRStorageVersionString =
- (const unsigned char *const) STR(FIRStorage_VERSION);
+ (const unsigned char *const)STR(FIRStorage_VERSION);
diff --git a/Firebase/Storage/FIRStorageDeleteTask.m b/Firebase/Storage/FIRStorageDeleteTask.m
index 825bd51..738d8a5 100644
--- a/Firebase/Storage/FIRStorageDeleteTask.m
+++ b/Firebase/Storage/FIRStorageDeleteTask.m
@@ -24,7 +24,7 @@
@synthesize fetcher = _fetcher;
@synthesize fetcherCompletion = _fetcherCompletion;
-- (void) dealloc {
+- (void)dealloc {
[_fetcher stopFetching];
}
@@ -64,7 +64,7 @@
};
#pragma clang diangostic pop
- __weak FIRStorageDeleteTask* weakSelf = self;
+ __weak FIRStorageDeleteTask *weakSelf = self;
[fetcher beginFetchWithCompletionHandler:^(NSData *_Nullable data, NSError *_Nullable error) {
weakSelf.fetcherCompletion(data, error);
}];
diff --git a/Firebase/Storage/FIRStorageDownloadTask.m b/Firebase/Storage/FIRStorageDownloadTask.m
index 783ac68..c410f05 100644
--- a/Firebase/Storage/FIRStorageDownloadTask.m
+++ b/Firebase/Storage/FIRStorageDownloadTask.m
@@ -36,7 +36,7 @@
return self;
}
-- (void) dealloc {
+- (void)dealloc {
[_fetcher stopFetching];
}
@@ -45,7 +45,8 @@
}
- (void)enqueueWithData:(nullable NSData *)resumeData {
- NSAssert([NSThread isMainThread], @"Download attempting to execute on non main queue! Please "
+ NSAssert([NSThread isMainThread],
+ @"Download attempting to execute on non main queue! Please "
@"only execute this method on the main queue.");
self.state = FIRStorageTaskStateQueueing;
NSMutableURLRequest *request = [self.baseRequest mutableCopy];
@@ -146,7 +147,8 @@
}
- (void)cancelWithError:(NSError *)error {
- NSAssert([NSThread isMainThread], @"Cancel attempting to execute on non main queue! Please only "
+ NSAssert([NSThread isMainThread],
+ @"Cancel attempting to execute on non main queue! Please only "
@"execute this method on the main queue.");
self.state = FIRStorageTaskStateCancelled;
[self.fetcher stopFetching];
@@ -155,7 +157,8 @@
}
- (void)pause {
- NSAssert([NSThread isMainThread], @"Pause attempting to execute on non main queue! Please only "
+ NSAssert([NSThread isMainThread],
+ @"Pause attempting to execute on non main queue! Please only "
@"execute this method on the main queue.");
self.state = FIRStorageTaskStatePausing;
[self.fetcher stopFetching];
@@ -167,7 +170,8 @@
}
- (void)resume {
- NSAssert([NSThread isMainThread], @"Resume attempting to execute on non main queue! Please only "
+ NSAssert([NSThread isMainThread],
+ @"Resume attempting to execute on non main queue! Please only "
@"execute this method on the main queue.");
self.state = FIRStorageTaskStateResuming;
FIRStorageTaskSnapshot *snapshot = self.snapshot;
diff --git a/Firebase/Storage/FIRStorageErrors.m b/Firebase/Storage/FIRStorageErrors.m
index 49a5ffa..92c0536 100644
--- a/Firebase/Storage/FIRStorageErrors.m
+++ b/Firebase/Storage/FIRStorageErrors.m
@@ -72,7 +72,8 @@
}
case FIRStorageErrorCodeUnauthenticated:
- errorMessage = @"User is not authenticated, please authenticate using Firebase "
+ errorMessage =
+ @"User is not authenticated, please authenticate using Firebase "
@"Authentication and try again.";
break;
diff --git a/Firebase/Storage/FIRStorageGetMetadataTask.m b/Firebase/Storage/FIRStorageGetMetadataTask.m
index fe0844d..78d8a16 100644
--- a/Firebase/Storage/FIRStorageGetMetadataTask.m
+++ b/Firebase/Storage/FIRStorageGetMetadataTask.m
@@ -39,7 +39,7 @@
return self;
}
-- (void) dealloc {
+- (void)dealloc {
[_fetcher stopFetching];
}
diff --git a/Firebase/Storage/FIRStorageMetadata.m b/Firebase/Storage/FIRStorageMetadata.m
index c4ff5a8..d2b8277 100644
--- a/Firebase/Storage/FIRStorageMetadata.m
+++ b/Firebase/Storage/FIRStorageMetadata.m
@@ -209,7 +209,7 @@
+ (void)removeMatchingMetadata:(NSMutableDictionary *)metadata
oldMetadata:(NSDictionary *)oldMetadata {
- for (NSString* metadataKey in [oldMetadata allKeys]) {
+ for (NSString *metadataKey in [oldMetadata allKeys]) {
id oldValue = [oldMetadata objectForKey:metadataKey];
id newValue = [metadata objectForKey:metadataKey];
diff --git a/Firebase/Storage/FIRStorageObservableTask.m b/Firebase/Storage/FIRStorageObservableTask.m
index bac5924..58455f6 100644
--- a/Firebase/Storage/FIRStorageObservableTask.m
+++ b/Firebase/Storage/FIRStorageObservableTask.m
@@ -203,14 +203,14 @@
@synchronized(self) {
handlersCopy = [handlers copy];
} // @synchronized(self)
- [handlersCopy enumerateKeysAndObjectsUsingBlock:^(NSString *_Nonnull key,
- FIRStorageVoidSnapshot _Nonnull handler,
- BOOL *_Nonnull stop) {
-
- dispatch_async(callbackQueue, ^{
- handler(snapshot);
- });
- }];
+ [handlersCopy
+ enumerateKeysAndObjectsUsingBlock:^(
+ NSString *_Nonnull key, FIRStorageVoidSnapshot _Nonnull handler, BOOL *_Nonnull stop) {
+
+ dispatch_async(callbackQueue, ^{
+ handler(snapshot);
+ });
+ }];
}
@end
diff --git a/Firebase/Storage/FIRStoragePath.m b/Firebase/Storage/FIRStoragePath.m
index 7188ab6..aa7f130 100644
--- a/Firebase/Storage/FIRStoragePath.m
+++ b/Firebase/Storage/FIRStoragePath.m
@@ -74,9 +74,10 @@
if (bucketName.length == 0) {
[NSException raise:NSInternalInconsistencyException
- format:@"URL must be in the form of "
- @"http[s]://firebasestorage.googleapis.com/v0/b/<bucket>/o/<path/to/"
- @"object>[?token=signed_url_params]"];
+ format:
+ @"URL must be in the form of "
+ @"http[s]://firebasestorage.googleapis.com/v0/b/<bucket>/o/<path/to/"
+ @"object>[?token=signed_url_params]"];
return nil;
}
diff --git a/Firebase/Storage/FIRStorageReference.m b/Firebase/Storage/FIRStorageReference.m
index 6e8105c..2a4e0c2 100644
--- a/Firebase/Storage/FIRStorageReference.m
+++ b/Firebase/Storage/FIRStorageReference.m
@@ -266,21 +266,21 @@
completion(nil, snapshot.error);
});
}];
- [task observeStatus:FIRStorageTaskStatusProgress
- handler:^(FIRStorageTaskSnapshot *_Nonnull snapshot) {
- FIRStorageDownloadTask *task = snapshot.task;
- if (task.progress.totalUnitCount > size ||
- task.progress.completedUnitCount > size) {
- NSDictionary *infoDictionary = @{
- @"totalSize" : @(task.progress.totalUnitCount),
- @"maxAllowedSize" : @(size)
- };
- NSError *error =
- [FIRStorageErrors errorWithCode:FIRStorageErrorCodeDownloadSizeExceeded
- infoDictionary:infoDictionary];
- [task cancelWithError:error];
- }
- }];
+ [task
+ observeStatus:FIRStorageTaskStatusProgress
+ handler:^(FIRStorageTaskSnapshot *_Nonnull snapshot) {
+ FIRStorageDownloadTask *task = snapshot.task;
+ if (task.progress.totalUnitCount > size || task.progress.completedUnitCount > size) {
+ NSDictionary *infoDictionary = @{
+ @"totalSize" : @(task.progress.totalUnitCount),
+ @"maxAllowedSize" : @(size)
+ };
+ NSError *error =
+ [FIRStorageErrors errorWithCode:FIRStorageErrorCodeDownloadSizeExceeded
+ infoDictionary:infoDictionary];
+ [task cancelWithError:error];
+ }
+ }];
[task enqueue];
return task;
}
diff --git a/Firebase/Storage/FIRStorageTask.m b/Firebase/Storage/FIRStorageTask.m
index 3c1cf6f..0305a39 100644
--- a/Firebase/Storage/FIRStorageTask.m
+++ b/Firebase/Storage/FIRStorageTask.m
@@ -15,12 +15,12 @@
#import "FIRStorageTask.h"
#import "FIRStorage.h"
-#import "FIRStorage_Private.h"
#import "FIRStorageReference.h"
#import "FIRStorageReference_Private.h"
#import "FIRStorageTaskSnapshot.h"
#import "FIRStorageTaskSnapshot_Private.h"
#import "FIRStorageTask_Private.h"
+#import "FIRStorage_Private.h"
#import "GTMSessionFetcherService.h"
@@ -48,8 +48,7 @@
- (FIRStorageTaskSnapshot *)snapshot {
@synchronized(self) {
- NSProgress *progress =
- [NSProgress progressWithTotalUnitCount:self.progress.totalUnitCount];
+ NSProgress *progress = [NSProgress progressWithTotalUnitCount:self.progress.totalUnitCount];
progress.completedUnitCount = self.progress.completedUnitCount;
FIRStorageTaskSnapshot *snapshot =
[[FIRStorageTaskSnapshot alloc] initWithTask:self
diff --git a/Firebase/Storage/FIRStorageTaskSnapshot.m b/Firebase/Storage/FIRStorageTaskSnapshot.m
index 050d05c..c964993 100644
--- a/Firebase/Storage/FIRStorageTaskSnapshot.m
+++ b/Firebase/Storage/FIRStorageTaskSnapshot.m
@@ -67,20 +67,19 @@
return self;
}
-
--(NSString *)description {
+- (NSString *)description {
switch (_status) {
- case FIRStorageTaskStatusResume:
+ case FIRStorageTaskStatusResume:
return @"<State: Resume>";
- case FIRStorageTaskStatusProgress:
+ case FIRStorageTaskStatusProgress:
return [NSString stringWithFormat:@"<State: Progress, Progress: %@>", _progress];
- case FIRStorageTaskStatusPause:
+ case FIRStorageTaskStatusPause:
return @"<State: Paused>";
- case FIRStorageTaskStatusSuccess:
+ case FIRStorageTaskStatusSuccess:
return @"<State: Success>";
- case FIRStorageTaskStatusFailure:
+ case FIRStorageTaskStatusFailure:
return [NSString stringWithFormat:@"<State: Failed, Error: %@>", _error];
- default:
+ default:
return @"<State: Unknown>";
};
}
diff --git a/Firebase/Storage/FIRStorageUpdateMetadataTask.m b/Firebase/Storage/FIRStorageUpdateMetadataTask.m
index 642ebcd..cf1bf93 100644
--- a/Firebase/Storage/FIRStorageUpdateMetadataTask.m
+++ b/Firebase/Storage/FIRStorageUpdateMetadataTask.m
@@ -39,7 +39,7 @@
return self;
}
-- (void) dealloc {
+- (void)dealloc {
[_fetcher stopFetching];
}
@@ -63,7 +63,7 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-retain-cycles"
- _fetcherCompletion =^(NSData *data, NSError *error) {
+ _fetcherCompletion = ^(NSData *data, NSError *error) {
if (error) {
if (!self.error) {
self.error = [FIRStorageErrors errorWithServerError:error reference:self.reference];
@@ -80,7 +80,7 @@
FIRStorageMetadata *metadata =
[[FIRStorageMetadata alloc] initWithDictionary:responseDictionary];
[metadata setType:FIRStorageMetadataTypeFile];
- if (callback){
+ if (callback) {
callback(metadata, nil);
}
} else {
diff --git a/Firebase/Storage/FIRStorageUploadTask.m b/Firebase/Storage/FIRStorageUploadTask.m
index dd3b329..0df0bf4 100644
--- a/Firebase/Storage/FIRStorageUploadTask.m
+++ b/Firebase/Storage/FIRStorageUploadTask.m
@@ -63,12 +63,13 @@
return self;
}
-- (void) dealloc {
+- (void)dealloc {
[_uploadFetcher stopFetching];
}
- (void)enqueue {
- NSAssert([NSThread isMainThread], @"Upload attempting to execute on non main queue! Please only "
+ NSAssert([NSThread isMainThread],
+ @"Upload attempting to execute on non main queue! Please only "
@"execute this method on the main queue.");
self.state = FIRStorageTaskStateQueueing;
@@ -78,8 +79,8 @@
NSData *bodyData = [NSData frs_dataFromJSONDictionary:[_uploadMetadata dictionaryRepresentation]];
request.HTTPBody = bodyData;
[request setValue:@"application/json; charset=UTF-8" forHTTPHeaderField:@"Content-Type"];
- NSString *contentLengthString = [NSString stringWithFormat:@"%zu",
- (unsigned long)[bodyData length]];
+ NSString *contentLengthString =
+ [NSString stringWithFormat:@"%zu", (unsigned long)[bodyData length]];
[request setValue:contentLengthString forHTTPHeaderField:@"Content-Length"];
NSURLComponents *components =
@@ -89,7 +90,7 @@
[components setPercentEncodedPath:[@"/upload" stringByAppendingString:components.path]];
}
- NSDictionary *queryParams = @{ @"uploadType" : @"resumable", @"name" : self.uploadMetadata.path };
+ NSDictionary *queryParams = @{@"uploadType" : @"resumable", @"name" : self.uploadMetadata.path};
[components setPercentEncodedQuery:[FIRStorageUtils queryStringForDictionary:queryParams]];
request.URL = components.URL;
@@ -109,7 +110,7 @@
uploadFetcher.maxRetryInterval = self.reference.storage.maxUploadRetryTime;
- __weak FIRStorageUploadTask* weakSelf = self;
+ __weak FIRStorageUploadTask *weakSelf = self;
[uploadFetcher setSendProgressBlock:^(int64_t bytesSent, int64_t totalBytesSent,
int64_t totalBytesExpectedToSend) {
@@ -128,8 +129,7 @@
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-retain-cycles"
- _fetcherCompletion = ^(NSData *_Nullable data,
- NSError *_Nullable error) {
+ _fetcherCompletion = ^(NSData *_Nullable data, NSError *_Nullable error) {
// Fire last progress updates
[self fireHandlersForStatus:FIRStorageTaskStatusProgress snapshot:self.snapshot];
@@ -161,8 +161,7 @@
if (invalidDataString.length > 0) {
dict = @{NSLocalizedFailureReasonErrorKey : invalidDataString};
}
- self.error =
- [FIRStorageErrors errorWithCode:FIRStorageErrorCodeUnknown infoDictionary:dict];
+ self.error = [FIRStorageErrors errorWithCode:FIRStorageErrorCodeUnknown infoDictionary:dict];
}
[self fireHandlersForStatus:FIRStorageTaskStatusSuccess snapshot:self.snapshot];
@@ -171,16 +170,17 @@
};
#pragma clang diagnostic pop
- [_uploadFetcher beginFetchWithCompletionHandler:^(NSData *_Nullable data,
- NSError *_Nullable error) {
- weakSelf.fetcherCompletion(data, error);
- }];
+ [_uploadFetcher
+ beginFetchWithCompletionHandler:^(NSData *_Nullable data, NSError *_Nullable error) {
+ weakSelf.fetcherCompletion(data, error);
+ }];
}
#pragma mark - Upload Management
- (void)cancel {
- NSAssert([NSThread isMainThread], @"Cancel attempting to execute on non main queue! Please only "
+ NSAssert([NSThread isMainThread],
+ @"Cancel attempting to execute on non main queue! Please only "
@"execute this method on the main queue.");
self.state = FIRStorageTaskStateCancelled;
[_uploadFetcher stopFetching];
@@ -192,7 +192,8 @@
}
- (void)pause {
- NSAssert([NSThread isMainThread], @"Pause attempting to execute on non main queue! Please only "
+ NSAssert([NSThread isMainThread],
+ @"Pause attempting to execute on non main queue! Please only "
@"execute this method on the main queue.");
self.state = FIRStorageTaskStatePaused;
[_uploadFetcher pauseFetching];
@@ -203,7 +204,8 @@
}
- (void)resume {
- NSAssert([NSThread isMainThread], @"Resume attempting to execute on non main queue! Please only "
+ NSAssert([NSThread isMainThread],
+ @"Resume attempting to execute on non main queue! Please only "
@"execute this method on the main queue.");
self.state = FIRStorageTaskStateResuming;
[_uploadFetcher resumeFetching];
diff --git a/Firebase/Storage/Private/FIRStorageDeleteTask.h b/Firebase/Storage/Private/FIRStorageDeleteTask.h
index c97fd27..4c93de2 100644
--- a/Firebase/Storage/Private/FIRStorageDeleteTask.h
+++ b/Firebase/Storage/Private/FIRStorageDeleteTask.h
@@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Task which provides the ability to delete an object in Firebase Storage.
*/
-@interface FIRStorageDeleteTask : FIRStorageTask<FIRStorageTaskManagement>
+@interface FIRStorageDeleteTask : FIRStorageTask <FIRStorageTaskManagement>
- (instancetype)initWithReference:(FIRStorageReference *)reference
fetcherService:(GTMSessionFetcherService *)service
diff --git a/Firebase/Storage/Private/FIRStorageGetMetadataTask.h b/Firebase/Storage/Private/FIRStorageGetMetadataTask.h
index 5f1dc8f..e5ba37e 100644
--- a/Firebase/Storage/Private/FIRStorageGetMetadataTask.h
+++ b/Firebase/Storage/Private/FIRStorageGetMetadataTask.h
@@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Task which provides the ability to get metadata on an object in Firebase Storage.
*/
-@interface FIRStorageGetMetadataTask : FIRStorageTask<FIRStorageTaskManagement>
+@interface FIRStorageGetMetadataTask : FIRStorageTask <FIRStorageTaskManagement>
- (instancetype)initWithReference:(FIRStorageReference *)reference
fetcherService:(GTMSessionFetcherService *)service
diff --git a/Firebase/Storage/Private/FIRStorageTokenAuthorizer.h b/Firebase/Storage/Private/FIRStorageTokenAuthorizer.h
index 78a8218..00bf141 100644
--- a/Firebase/Storage/Private/FIRStorageTokenAuthorizer.h
+++ b/Firebase/Storage/Private/FIRStorageTokenAuthorizer.h
@@ -27,7 +27,7 @@ NS_ASSUME_NONNULL_BEGIN
* If no authentication provider exists or no token is found, no token is added
* and the request is passed.
*/
-@interface FIRStorageTokenAuthorizer : NSObject<GTMFetcherAuthorizationProtocol>
+@interface FIRStorageTokenAuthorizer : NSObject <GTMFetcherAuthorizationProtocol>
/**
* Initializes the token authorizer with an instance of FIRApp.
diff --git a/Firebase/Storage/Private/FIRStorageUpdateMetadataTask.h b/Firebase/Storage/Private/FIRStorageUpdateMetadataTask.h
index 2fcefdd..46bd65a 100644
--- a/Firebase/Storage/Private/FIRStorageUpdateMetadataTask.h
+++ b/Firebase/Storage/Private/FIRStorageUpdateMetadataTask.h
@@ -23,7 +23,7 @@ NS_ASSUME_NONNULL_BEGIN
/**
* Task which provides the ability update the metadata on an object in Firebase Storage.
*/
-@interface FIRStorageUpdateMetadataTask : FIRStorageTask<FIRStorageTaskManagement>
+@interface FIRStorageUpdateMetadataTask : FIRStorageTask <FIRStorageTaskManagement>
- (instancetype)initWithReference:(FIRStorageReference *)reference
fetcherService:(GTMSessionFetcherService *)service
diff --git a/Firebase/Storage/Public/FIRStorage.h b/Firebase/Storage/Public/FIRStorage.h
index 3b37a0e..112b1c6 100644
--- a/Firebase/Storage/Public/FIRStorage.h
+++ b/Firebase/Storage/Public/FIRStorage.h
@@ -68,8 +68,7 @@ FIR_SWIFT_NAME(Storage)
* @param url The gs:// url to your Firebase Storage Bucket.
* @return the FIRStorage instance, initialized with the custom FIRApp.
*/
-+ (instancetype)storageForApp:(FIRApp *)app
- URL:(NSString *)url FIR_SWIFT_NAME(storage(app:url:));
++ (instancetype)storageForApp:(FIRApp *)app URL:(NSString *)url FIR_SWIFT_NAME(storage(app:url:));
/**
* The Firebase App associated with this Firebase Storage instance.
diff --git a/Firebase/Storage/Public/FIRStorageDownloadTask.h b/Firebase/Storage/Public/FIRStorageDownloadTask.h
index 252b910..f9d3e76 100644
--- a/Firebase/Storage/Public/FIRStorageDownloadTask.h
+++ b/Firebase/Storage/Public/FIRStorageDownloadTask.h
@@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
* Currently all uploads must be initiated and managed on the main queue.
*/
FIR_SWIFT_NAME(StorageDownloadTask)
-@interface FIRStorageDownloadTask : FIRStorageObservableTask<FIRStorageTaskManagement>
+@interface FIRStorageDownloadTask : FIRStorageObservableTask <FIRStorageTaskManagement>
@end
diff --git a/Firebase/Storage/Public/FIRStorageMetadata.h b/Firebase/Storage/Public/FIRStorageMetadata.h
index 8d844f7..61d95ca 100644
--- a/Firebase/Storage/Public/FIRStorageMetadata.h
+++ b/Firebase/Storage/Public/FIRStorageMetadata.h
@@ -30,7 +30,7 @@ NS_ASSUME_NONNULL_BEGIN
* @see https://cloud.google.com/storage/docs/json_api/v1/objects#resource
*/
FIR_SWIFT_NAME(StorageMetadata)
-@interface FIRStorageMetadata : NSObject<NSCopying>
+@interface FIRStorageMetadata : NSObject <NSCopying>
/**
* The name of the bucket containing this object.
@@ -118,14 +118,14 @@ FIR_SWIFT_NAME(StorageMetadata)
* Creates an instanece of FIRStorageMetadata from the contents of a dictionary.
* @return An instance of FIRStorageMetadata that represents the contents of a dictionary.
*/
-- (nullable instancetype)initWithDictionary:(NSDictionary <NSString *, id>*)dictionary
+- (nullable instancetype)initWithDictionary:(NSDictionary<NSString *, id> *)dictionary
NS_DESIGNATED_INITIALIZER;
/**
* Creates an NSDictionary from the contents of the metadata.
* @return An NSDictionary that represents the contents of the metadata.
*/
-- (NSDictionary <NSString *, id>*)dictionaryRepresentation;
+- (NSDictionary<NSString *, id> *)dictionaryRepresentation;
/**
* Determines if the current metadata represents a "file".
diff --git a/Firebase/Storage/Public/FIRStorageReference.h b/Firebase/Storage/Public/FIRStorageReference.h
index 0b85267..a85c738 100644
--- a/Firebase/Storage/Public/FIRStorageReference.h
+++ b/Firebase/Storage/Public/FIRStorageReference.h
@@ -110,9 +110,11 @@ FIR_SWIFT_NAME(StorageReference)
* about the object being uploaded.
* @return An instance of FIRStorageUploadTask, which can be used to monitor or manage the upload.
*/
+// clang-format off
- (FIRStorageUploadTask *)putData:(NSData *)uploadData
metadata:(nullable FIRStorageMetadata *)metadata
- FIR_SWIFT_NAME(putData(_:metadata:));
+FIR_SWIFT_NAME(putData(_:metadata:));
+// clang-format on
/**
* Asynchronously uploads data to the currently specified FIRStorageReference.
@@ -124,11 +126,13 @@ FIR_SWIFT_NAME(StorageReference)
* or an error on failure.
* @return An instance of FIRStorageUploadTask, which can be used to monitor or manage the upload.
*/
+// clang-format off
- (FIRStorageUploadTask *)putData:(NSData *)uploadData
metadata:(nullable FIRStorageMetadata *)metadata
completion:(nullable void (^)(FIRStorageMetadata *_Nullable metadata,
NSError *_Nullable error))completion
- FIR_SWIFT_NAME(putData(_:metadata:completion:));
+ FIR_SWIFT_NAME(putData(_:metadata:completion:));
+// clang-format on
/**
* Asynchronously uploads a file to the currently specified FIRStorageReference,
@@ -145,8 +149,11 @@ FIR_SWIFT_NAME(StorageReference)
* about the object being uploaded.
* @return An instance of FIRStorageUploadTask, which can be used to monitor or manage the upload.
*/
-- (FIRStorageUploadTask *)putFile:(NSURL *)fileURL metadata:(nullable FIRStorageMetadata *)metadata
- FIR_SWIFT_NAME(putFile(from:metadata:));
+// clang-format off
+- (FIRStorageUploadTask *)putFile:(NSURL *)fileURL
+ metadata:(nullable FIRStorageMetadata *)metadata
+ FIR_SWIFT_NAME(putFile(from:metadata:));
+// clang-format on
/**
* Asynchronously uploads a file to the currently specified FIRStorageReference.
@@ -157,11 +164,13 @@ FIR_SWIFT_NAME(StorageReference)
* or an error on failure.
* @return An instance of FIRStorageUploadTask, which can be used to monitor or manage the upload.
*/
+// clang-format off
- (FIRStorageUploadTask *)putFile:(NSURL *)fileURL
metadata:(nullable FIRStorageMetadata *)metadata
completion:(nullable void (^)(FIRStorageMetadata *_Nullable metadata,
NSError *_Nullable error))completion
- FIR_SWIFT_NAME(putFile(from:metadata:completion:));
+ FIR_SWIFT_NAME(putFile(from:metadata:completion:));
+// clang-format on
#pragma mark - Downloads
@@ -175,10 +184,12 @@ FIR_SWIFT_NAME(StorageReference)
* or an error on failure.
* @return An FIRStorageDownloadTask that can be used to monitor or manage the download.
*/
+// clang-format off
- (FIRStorageDownloadTask *)dataWithMaxSize:(int64_t)size
completion:(void (^)(NSData *_Nullable data,
NSError *_Nullable error))completion
- FIR_SWIFT_NAME(getData(maxSize:completion:));
+ FIR_SWIFT_NAME(getData(maxSize:completion:));
+// clang-format on
/**
* Asynchronously retrieves a long lived download URL with a revokable token.
@@ -216,8 +227,8 @@ FIR_SWIFT_NAME(StorageReference)
* @param completion A completion block which returns the object metadata on success,
* or an error on failure.
*/
-- (void)metadataWithCompletion:(void (^)(FIRStorageMetadata *_Nullable metadata,
- NSError *_Nullable error))completion
+- (void)metadataWithCompletion:
+ (void (^)(FIRStorageMetadata *_Nullable metadata, NSError *_Nullable error))completion
FIR_SWIFT_NAME(getMetadata(completion:));
/**
@@ -226,10 +237,12 @@ FIR_SWIFT_NAME(StorageReference)
* @param completion A completion block which returns the FIRStorageMetadata on success,
* or an error on failure.
*/
+// clang-format off
- (void)updateMetadata:(FIRStorageMetadata *)metadata
completion:(nullable void (^)(FIRStorageMetadata *_Nullable metadata,
NSError *_Nullable error))completion
- FIR_SWIFT_NAME(updateMetadata(_:completion:));
+FIR_SWIFT_NAME(updateMetadata(_:completion:));
+// clang-format on
#pragma mark - Delete
diff --git a/Firebase/Storage/Public/FIRStorageSwiftNameSupport.h b/Firebase/Storage/Public/FIRStorageSwiftNameSupport.h
index 55e1bcc..216c047 100644
--- a/Firebase/Storage/Public/FIRStorageSwiftNameSupport.h
+++ b/Firebase/Storage/Public/FIRStorageSwiftNameSupport.h
@@ -24,6 +24,6 @@
#define FIR_SWIFT_NAME(X) NS_SWIFT_NAME(X)
#else
#define FIR_SWIFT_NAME(X) // Intentionally blank.
-#endif // #ifdef __IPHONE_9_3
+#endif // #ifdef __IPHONE_9_3
#endif // FIR_SWIFT_NAME
diff --git a/Firebase/Storage/Public/FIRStorageTask.h b/Firebase/Storage/Public/FIRStorageTask.h
index 0428220..b49363c 100644
--- a/Firebase/Storage/Public/FIRStorageTask.h
+++ b/Firebase/Storage/Public/FIRStorageTask.h
@@ -47,7 +47,7 @@ FIR_SWIFT_NAME(StorageTask)
* operations.
*/
FIR_SWIFT_NAME(StorageTaskManagement)
-@protocol FIRStorageTaskManagement<NSObject>
+@protocol FIRStorageTaskManagement <NSObject>
@required
/**
diff --git a/Firebase/Storage/Public/FIRStorageUploadTask.h b/Firebase/Storage/Public/FIRStorageUploadTask.h
index cdf1d29..cf9bde8 100644
--- a/Firebase/Storage/Public/FIRStorageUploadTask.h
+++ b/Firebase/Storage/Public/FIRStorageUploadTask.h
@@ -32,7 +32,7 @@ NS_ASSUME_NONNULL_BEGIN
* Currently all uploads must be initiated and managed on the main queue.
*/
FIR_SWIFT_NAME(StorageUploadTask)
-@interface FIRStorageUploadTask : FIRStorageObservableTask<FIRStorageTaskManagement>
+@interface FIRStorageUploadTask : FIRStorageObservableTask <FIRStorageTaskManagement>
@end
diff --git a/Firestore/Example/Tests/SpecTests/FSTMockDatastore.h b/Firestore/Example/Tests/SpecTests/FSTMockDatastore.h
index 7ad0d18..f091a53 100644
--- a/Firestore/Example/Tests/SpecTests/FSTMockDatastore.h
+++ b/Firestore/Example/Tests/SpecTests/FSTMockDatastore.h
@@ -22,10 +22,12 @@ NS_ASSUME_NONNULL_BEGIN
@interface FSTMockDatastore : FSTDatastore
-/** A count of the total number of requests sent to the watch stream since the beginning of the test case. */
+/** A count of the total number of requests sent to the watch stream since the beginning of the test
+ * case. */
@property(nonatomic) int watchStreamRequestCount;
-/** A count of the total number of requests sent to the write stream since the beginning of the test case. */
+/** A count of the total number of requests sent to the write stream since the beginning of the test
+ * case. */
@property(nonatomic) int writeStreamRequestCount;
+ (instancetype)mockDatastoreWithWorkerDispatchQueue:(FSTDispatchQueue *)workerDispatchQueue;
diff --git a/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm b/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm
index 92e4dc2..4bfdb41 100644
--- a/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm
+++ b/Firestore/Example/Tests/Util/FSTIntegrationTestCase.mm
@@ -16,8 +16,8 @@
#import "FSTIntegrationTestCase.h"
-#import <Firestore/Firestore-umbrella.h>
#import <FirebaseCommunity/FIRLogger.h>
+#import <Firestore/Firestore-umbrella.h>
#import <GRPCClient/GRPCCall+ChannelArg.h>
#import <GRPCClient/GRPCCall+Tests.h>
@@ -297,8 +297,8 @@ NS_ASSUME_NONNULL_BEGIN
}
}
-extern "C"
-NSArray<NSDictionary<NSString *, id> *> *FIRQuerySnapshotGetData(FIRQuerySnapshot *docs) {
+extern "C" NSArray<NSDictionary<NSString *, id> *> *FIRQuerySnapshotGetData(
+ FIRQuerySnapshot *docs) {
NSMutableArray<NSDictionary<NSString *, id> *> *result = [NSMutableArray array];
for (FIRDocumentSnapshot *doc in docs.documents) {
[result addObject:doc.data];
@@ -306,8 +306,7 @@ NSArray<NSDictionary<NSString *, id> *> *FIRQuerySnapshotGetData(FIRQuerySnapsho
return result;
}
-extern "C"
-NSArray<NSString *> *FIRQuerySnapshotGetIDs(FIRQuerySnapshot *docs) {
+extern "C" NSArray<NSString *> *FIRQuerySnapshotGetIDs(FIRQuerySnapshot *docs) {
NSMutableArray<NSString *> *result = [NSMutableArray array];
for (FIRDocumentSnapshot *doc in docs.documents) {
[result addObject:doc.documentID];
diff --git a/scripts/style.sh b/scripts/style.sh
index 0c19f45..9ebb775 100755
--- a/scripts/style.sh
+++ b/scripts/style.sh
@@ -18,7 +18,6 @@ find . \
-name 'Database' -prune -o \
-name 'FirebaseCommunity.h' -prune -o \
-name 'Messaging' -prune -o \
- -name 'Storage' -prune -o \
-name 'Pods' -prune -o \
\( -name '*.[mh]' -o -name '*.mm' \) \
-not -name '*.pbobjc.*' \