aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Paul Beusterien <paulbeusterien@google.com>2017-06-30 10:47:37 -0700
committerGravatar VinayGuthal <vinayg@qhode.com>2017-06-30 13:47:37 -0400
commitddbfd4cc666f5227ab0e1f5a98c8a499ccbb32d1 (patch)
tree9c2ec4e15b6741f413d66f428c45f0278219d728
parent925f4c8b7558373172dd9410b7844637afaa2424 (diff)
Add travis trailing whitespace check (#116)
* Add travis trailing whitespace check * Remove trailing white space
-rw-r--r--.gitignore2
-rw-r--r--.travis.yml1
-rw-r--r--AuthSamples/README.md2
-rw-r--r--Example/Database/Tests/Helpers/FEventTester.m4
-rw-r--r--Example/Database/Tests/Helpers/FTestBase.m10
-rw-r--r--Example/Database/Tests/Helpers/FTestHelpers.m20
-rw-r--r--Example/Database/Tests/Helpers/SenTest+FWaiter.m4
-rw-r--r--Example/Database/Tests/Integration/FConnectionTest.m8
-rw-r--r--Example/Database/Tests/Integration/FData.m210
-rw-r--r--Example/Database/Tests/Integration/FDotInfo.m6
-rw-r--r--Example/Database/Tests/Integration/FEventTests.m158
-rw-r--r--Example/Database/Tests/Integration/FIRDatabaseQueryTests.m678
-rw-r--r--Example/Database/Tests/Integration/FIRDatabaseTests.m2
-rw-r--r--Example/Database/Tests/Integration/FOrder.m110
-rw-r--r--Example/Database/Tests/Integration/FOrderByTests.m12
-rw-r--r--Example/Database/Tests/Integration/FPersist.m12
-rw-r--r--Example/Database/Tests/Integration/FRealtime.m2
-rw-r--r--Example/Database/Tests/Integration/FTransactionTest.m24
-rw-r--r--Example/Database/Tests/Unit/FIRDataSnapshotTests.m78
-rw-r--r--Example/Database/Tests/Unit/FLevelDBStorageEngineTests.m4
-rw-r--r--Example/Database/Tests/Unit/FPathTests.m4
-rw-r--r--Example/Database/Tests/Unit/FTreeSortedDictionaryTests.m108
-rw-r--r--Example/Database/Tests/third_party/Base64.m40
-rw-r--r--Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m152
-rw-r--r--Firebase/Auth/Source/Public/FIRPhoneAuthProvider.h2
-rw-r--r--Firebase/Database/Api/FIRDatabaseQuery.m4
-rw-r--r--Firebase/Database/Core/FPersistentConnection.m14
-rw-r--r--Firebase/Database/Core/FRepo.h2
-rw-r--r--Firebase/Database/Core/FRepo.m4
-rw-r--r--Firebase/Database/Core/Utilities/FPath.m4
-rw-r--r--Firebase/Database/Core/Utilities/FTree.m4
-rw-r--r--Firebase/Database/FImmutableSortedDictionary/FImmutableSortedDictionary/FLLRBEmptyNode.m2
-rw-r--r--Firebase/Database/FImmutableSortedDictionary/FImmutableSortedDictionary/FLLRBValueNode.m22
-rw-r--r--Firebase/Database/FImmutableSortedDictionary/FImmutableSortedDictionary/FTreeSortedDictionaryEnumerator.m2
-rw-r--r--Firebase/Database/FViewProcessor.m2
-rw-r--r--Firebase/Database/Public/FIRDataSnapshot.h6
-rw-r--r--Firebase/Database/Public/FIRDatabase.h4
-rw-r--r--Firebase/Database/Public/FIRDatabaseReference.h38
-rw-r--r--Firebase/Database/Realtime/FConnection.m16
-rw-r--r--Firebase/Database/Realtime/FWebSocketConnection.m30
-rw-r--r--Firebase/Database/Snapshot/FChildrenNode.m4
-rw-r--r--Firebase/Database/Snapshot/FSnapshotUtilities.m4
-rw-r--r--Firebase/Database/Utilities/FAtomicNumber.m4
-rw-r--r--Firebase/Database/Utilities/FNextPushId.m14
-rw-r--r--Firebase/Database/Utilities/FUtilities.m8
-rw-r--r--Firebase/Database/Utilities/FValidation.m2
-rw-r--r--Firebase/Database/third_party/SocketRocket/FSRWebSocket.h4
-rw-r--r--Firebase/Database/third_party/SocketRocket/FSRWebSocket.m352
-rw-r--r--Firebase/Database/third_party/SocketRocket/fbase64.c56
-rw-r--r--Firebase/Database/third_party/SocketRocket/fbase64.h2
-rw-r--r--Firebase/Storage/FIRStorageDeleteTask.m4
-rw-r--r--Firebase/Storage/FIRStorageGetMetadataTask.m2
-rw-r--r--Firebase/Storage/FIRStorageUpdateMetadataTask.m2
-rw-r--r--Firebase/Storage/FIRStorageUploadTask.m6
-rw-r--r--PULL_REQUEST_TEMPLATE.md8
-rw-r--r--README.md20
56 files changed, 1150 insertions, 1149 deletions
diff --git a/.gitignore b/.gitignore
index ecfb480..cd52375 100644
--- a/.gitignore
+++ b/.gitignore
@@ -42,7 +42,7 @@ Carthage
# Since Firebase is building libraries, not apps, we should not check in Pods.
# Pods are only used in the Examples and tests and doing a 'pod install' better
# matches our customers' environments.
-#
+#
# Note: if you ignore the Pods directory, make sure to uncomment
# `pod install` in .travis.yml
#
diff --git a/.travis.yml b/.travis.yml
index f740dce..271105f 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -12,5 +12,6 @@ before_install:
- pod install --project-directory=Example --repo-update
script:
+ - "! git grep ' $'" # Fail on trailing whitespace
- ./test.sh
- pod lib lint FirebaseCommunity.podspec --verbose | tail -40
diff --git a/AuthSamples/README.md b/AuthSamples/README.md
index f98902e..66c21e1 100644
--- a/AuthSamples/README.md
+++ b/AuthSamples/README.md
@@ -22,7 +22,7 @@ You'll need valid `GoogleService-Info.plist` files for those samples. To get you
#### GoogleService-Info_multi.plist files
-This feature is for advanced testing.
+This feature is for advanced testing.
1. The developer would need to get a GoogleService-Info.plist from a different iOS client (which can be in a different Firebase project)
2. Save this plist file as GoogleService-Info_multi.plist in [Sample/GoogleService-Info_multi.plist](Sample/GoogleService-Info_multi.plist). This enables testing that FirebaseAuth continues to work after switching the Firebase App in the runtime.
diff --git a/Example/Database/Tests/Helpers/FEventTester.m b/Example/Database/Tests/Helpers/FEventTester.m
index fa7c081..8c7bd19 100644
--- a/Example/Database/Tests/Helpers/FEventTester.m
+++ b/Example/Database/Tests/Helpers/FEventTester.m
@@ -90,7 +90,7 @@
FIRDatabaseHandle movedHandle = [path observeEventType:FIRDataEventTypeChildMoved withBlock:[self makeEventCallback:FIRDataEventTypeChildMoved]];
FIRDatabaseHandle changedHandle = [path observeEventType:FIRDataEventTypeChildChanged withBlock:[self makeEventCallback:FIRDataEventTypeChildChanged]];
FIRDatabaseHandle valueHandle = [path observeEventType:FIRDataEventTypeValue withBlock:[self makeEventCallback:FIRDataEventTypeValue]];
-
+
fbt_void_void cb = ^() {
[path removeObserverWithHandle:removedHandle];
[path removeObserverWithHandle:addedHandle];
@@ -137,7 +137,7 @@
}
- (fbt_void_datasnapshot) makeEventCallback:(FIRDataEventType)type {
-
+
fbt_void_datasnapshot cb = ^(FIRDataSnapshot * snap) {
FIRDatabaseReference * ref = snap.ref;
diff --git a/Example/Database/Tests/Helpers/FTestBase.m b/Example/Database/Tests/Helpers/FTestBase.m
index f55c73b..1cfe7ad 100644
--- a/Example/Database/Tests/Helpers/FTestBase.m
+++ b/Example/Database/Tests/Helpers/FTestBase.m
@@ -30,11 +30,11 @@
[FIRApp configure];
});
}
-
+
- (void)setUp
{
[super setUp];
-
+
[FIRDatabase setLoggingEnabled:YES];
_databaseURL = [[FIRApp defaultApp] options].databaseURL;
@@ -49,13 +49,13 @@
fn(snap);
done = YES;
}];
-
+
NSTimeInterval timeTaken = [self waitUntil:^BOOL{
return done;
} timeout:kFirebaseTestWaitUntilTimeout];
-
+
NSLog(@"snapWaiter:withBlock: timeTaken:%f", timeTaken);
-
+
XCTAssertTrue(done, @"Properly finished.");
}
diff --git a/Example/Database/Tests/Helpers/FTestHelpers.m b/Example/Database/Tests/Helpers/FTestHelpers.m
index 8ffdc7d..bfbb9e1 100644
--- a/Example/Database/Tests/Helpers/FTestHelpers.m
+++ b/Example/Database/Tests/Helpers/FTestHelpers.m
@@ -28,17 +28,17 @@
NSDate *timeoutDate = [NSDate dateWithTimeIntervalSinceNow:seconds];
NSTimeInterval timeoutTime = [timeoutDate timeIntervalSinceReferenceDate];
NSTimeInterval currentTime;
-
+
for (currentTime = [NSDate timeIntervalSinceReferenceDate];
!predicate() && currentTime < timeoutTime;
currentTime = [NSDate timeIntervalSinceReferenceDate]) {
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.25]];
}
-
+
NSTimeInterval finish = [NSDate timeIntervalSinceReferenceDate];
-
+
NSAssert(currentTime <= timeoutTime, @"Timed out");
-
+
return (finish - start);
}
@@ -54,9 +54,9 @@
});
NSMutableArray *refs = (persistence) ? persistenceRefs : noPersistenceRefs;
-
+
id<FAuthTokenProvider> authTokenProvider = [FAuthTokenProvider authTokenProviderForApp:[FIRApp defaultApp]];
-
+
while (num > refs.count) {
NSString *sessionIdentifier = [NSString stringWithFormat:@"test-config-%@persistence-%lu", (persistence) ? @"" : @"no-", refs.count];
FIRDatabaseConfig *config = [[FIRDatabaseConfig alloc] initWithSessionIdentifier:sessionIdentifier authTokenProvider:authTokenProvider];
@@ -64,7 +64,7 @@
FIRDatabaseReference * ref = [[FIRDatabaseReference alloc] initWithConfig:config];
[refs addObject:ref];
}
-
+
NSMutableArray* results = [[NSMutableArray alloc] init];
NSString* name = nil;
for (int i = 0; i < num; ++i) {
@@ -90,11 +90,11 @@
+ (FTupleFirebase *) getRandomNodePair {
NSArray* refs = [self getRandomNodes:2 persistence:YES];
-
+
FTupleFirebase* tuple = [[FTupleFirebase alloc] init];
tuple.one = [refs objectAtIndex:0];
tuple.two = [refs objectAtIndex:1];
-
+
return tuple;
}
@@ -114,7 +114,7 @@
triple.one = [refs objectAtIndex:0];
triple.two = [refs objectAtIndex:1];
triple.three = [refs objectAtIndex:2];
-
+
return triple;
}
diff --git a/Example/Database/Tests/Helpers/SenTest+FWaiter.m b/Example/Database/Tests/Helpers/SenTest+FWaiter.m
index 4c5c854..a573fb9 100644
--- a/Example/Database/Tests/Helpers/SenTest+FWaiter.m
+++ b/Example/Database/Tests/Helpers/SenTest+FWaiter.m
@@ -36,13 +36,13 @@
NSDate *timeoutDate = [NSDate dateWithTimeIntervalSinceNow:seconds];
NSTimeInterval timeoutTime = [timeoutDate timeIntervalSinceReferenceDate];
NSTimeInterval currentTime;
-
+
for (currentTime = [NSDate timeIntervalSinceReferenceDate];
!predicate() && currentTime < timeoutTime;
currentTime = [NSDate timeIntervalSinceReferenceDate]) {
[[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.25]];
}
-
+
NSTimeInterval finish = [NSDate timeIntervalSinceReferenceDate];
if (currentTime > timeoutTime) {
if (desc != nil) {
diff --git a/Example/Database/Tests/Integration/FConnectionTest.m b/Example/Database/Tests/Integration/FConnectionTest.m
index e72f6e4..c658e8e 100644
--- a/Example/Database/Tests/Integration/FConnectionTest.m
+++ b/Example/Database/Tests/Integration/FConnectionTest.m
@@ -53,9 +53,9 @@
FRepoInfo *info = [[FRepoInfo alloc] initWithHost:host isSecure:YES withNamespace:@"default"];
FConnection *conn = [[FConnection alloc] initWith:info andDispatchQueue:[FIRDatabaseQuery sharedQueue] lastSessionID:nil];
FTestConnectionDelegate *delegate = [[FTestConnectionDelegate alloc] init];
-
+
__block BOOL done = NO;
-
+
delegate.onDisconnect = ^(FDisconnectReason reason) {
if (reason == DISCONNECT_REASON_SERVER_RESET) {
// It is very likely that the first connection attempt sends us a redirect to the project's designated server.
@@ -68,10 +68,10 @@
NSAssert([sessionID length] != 0, @"sessionID must have length > 0");
done = YES;
};
-
+
conn.delegate = delegate;
[conn open];
-
+
WAIT_FOR(done);
}
@end
diff --git a/Example/Database/Tests/Integration/FData.m b/Example/Database/Tests/Integration/FData.m
index 390522c..08b0586 100644
--- a/Example/Database/Tests/Integration/FData.m
+++ b/Example/Database/Tests/Integration/FData.m
@@ -49,7 +49,7 @@
- (void) testWriteAndReadData {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
[node setValue:@42];
-
+
[self snapWaiter:node withBlock:^(FIRDataSnapshot *snapshot) {
XCTAssertEqualObjects(@42, [snapshot value], @"Properly saw correct value");
}];
@@ -75,9 +75,9 @@
- (void) testValReturnsCompoundObjectWithChildren {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
-
+
[node setValue:@{@"foo": @{@"bar": @5}}];
-
+
[self snapWaiter:node withBlock:^(FIRDataSnapshot *snapshot) {
XCTAssertEqualObjects([[[snapshot value] objectForKey:@"foo"] objectForKey:@"bar"], @5, @"Properly saw compound object");
}];
@@ -98,16 +98,16 @@
FIRDatabaseReference * writeNode = tuple.one;
FIRDatabaseReference * readNode = tuple.two;
-
+
__block BOOL done = NO;
-
+
[[[[writeNode child:@"a"] child:@"b"] child:@"c"] setValue:@1];
[[[[writeNode child:@"a"] child:@"d"] child:@"e"] setValue:@2];
[[[[writeNode child:@"a"] child:@"d"] child:@"f"] setValue:@3];
[[writeNode child:@"g"] setValue:@4 withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) { done = YES; }];
-
+
[self waitUntil:^BOOL{ return done; }];
-
+
[super snapWaiter:readNode withBlock:^(FIRDataSnapshot *s) {
XCTAssertEqualObjects([[[[s childSnapshotForPath:@"a"] childSnapshotForPath:@"b"] childSnapshotForPath:@"c"] value], @1, @"Proper child value");
XCTAssertEqualObjects([[[[s childSnapshotForPath:@"a"] childSnapshotForPath:@"d"] childSnapshotForPath:@"e"] value], @2, @"Proper child value");
@@ -234,7 +234,7 @@
[[node repo] interrupt]; // Going offline ensures that local events get queued up before server events
FEventTester* et = [[FEventTester alloc] initFrom:self];
[et addLookingFor:lookingFor];
-
+
[[node child:@"a/aa"] setValue:@1];
[[node child:@"a"] setValue:@{@"aa": @2}];
[[node child:@"a"] setValue:@{@"aa": @3}];
@@ -498,7 +498,7 @@
- (void) testWriteCompoundObjectAndGetItBack {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
-
+
NSDictionary* data = @{
@"a": @{@"aa": @5,
@"ab": @3},
@@ -511,19 +511,19 @@
@NO,
@"dude"]
};
-
+
__block FIRDataSnapshot *snap = nil;
[node observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
snap = snapshot;
}];
-
+
__block BOOL done = NO;
[node setValue:data withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) { done = YES; }];
-
+
[self waitUntil:^BOOL{
return done;
}];
-
+
[self snapWaiter:node withBlock:^(FIRDataSnapshot *snapshot) {
XCTAssertTrue([[[[snapshot value] objectForKey:@"c"] objectAtIndex:3] boolValue], @"Got proper boolean");
}];
@@ -531,7 +531,7 @@
- (void) testCanPassValueToPush {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
-
+
FIRDatabaseReference * pushA = [node childByAutoId];
[pushA setValue:@5];
@@ -541,7 +541,7 @@
FIRDatabaseReference * pushB = [node childByAutoId];
[pushB setValue:@{@"a": @5, @"b": @6}];
-
+
[self snapWaiter:pushB withBlock:^(FIRDataSnapshot *snapshot) {
XCTAssertEqualObjects(@5, [[snapshot value] objectForKey:@"a"], @"Got proper value");
XCTAssertEqualObjects(@6, [[snapshot value] objectForKey:@"b"], @"Got proper value");
@@ -556,7 +556,7 @@
__block BOOL setDone = NO;
__block BOOL removeDone = NO;
__block BOOL readDone = NO;
-
+
[node setValue:@42 withCompletionBlock:^(NSError* error, FIRDatabaseReference * ref) {
setDone = YES;
}];
@@ -579,22 +579,22 @@
[self waitUntil:^BOOL{
return readDone && removeDone;
- }];
+ }];
}
- (void) testRemoveCallbackIsHitForNodesThatAreAlreadyRemoved {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
-
+
__block int removes = 0;
-
+
[node removeValueWithCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
removes = removes + 1;
}];
-
+
[node removeValueWithCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
removes = removes + 1;
}];
-
+
[self waitUntil:^BOOL{
return removes == 2;
}];
@@ -622,35 +622,35 @@
FIRDatabaseReference * writeNode = tuple.one;
FIRDatabaseReference * readNode = tuple.two;
FIRDatabaseReference * readNodeB = tuple.three;
-
+
__block BOOL initialReadDone = NO;
[readNode observeSingleEventOfType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
XCTAssertTrue([[snapshot value] isEqual:[NSNull null]], @"First callback is null");
initialReadDone = YES;
}];
-
+
[self waitUntil:^BOOL{
return initialReadDone;
}];
-
+
__block BOOL writeDone = NO;
-
+
[writeNode setValue:@42 withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
writeDone = YES;
}];
-
+
[self waitUntil:^BOOL{
return writeDone;
}];
-
+
__block BOOL readDone = NO;
[readNodeB observeSingleEventOfType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
XCTAssertEqualObjects(@42, [snapshot value], @"Proper second read");
readDone = YES;
}];
-
+
[self waitUntil:^BOOL{
return readDone;
}];
@@ -660,13 +660,13 @@
- (void) testSetAndThenListenForValueEventsAreCorrect {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
-
+
__block BOOL setDone = NO;
-
+
[node setValue:@"moo" withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
setDone = YES;
}];
-
+
__block int calls = 0;
[node observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
@@ -674,7 +674,7 @@
XCTAssertTrue(calls == 1, @"Only called once");
XCTAssertEqualObjects([snapshot value], @"moo", @"Proper snapshot value");
}];
-
+
[self waitUntil:^BOOL{
return setDone && calls == 1;
}];
@@ -682,9 +682,9 @@
- (void) testHasChildrenWorksCorrectly {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
-
+
[node setValue:@{@"one" : @42, @"two": @{@"a": @5}, @"three": @{@"a": @5, @"b": @6}}];
-
+
__block BOOL removedTwo = NO;
__block BOOL done = NO;
@@ -703,7 +703,7 @@
done = YES;
}
}];
-
+
[self waitUntil:^BOOL{
return done;
}];
@@ -711,9 +711,9 @@
- (void) testNumChildrenWorksCorrectly {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
-
+
[node setValue:@{@"one" : @42, @"two": @{@"a": @5}, @"three": @{@"a": @5, @"b": @6}}];
-
+
__block BOOL removedTwo = NO;
__block BOOL done = NO;
@@ -734,7 +734,7 @@
done = YES;
}
}];
-
+
[self waitUntil:^BOOL{
return done;
}];
@@ -745,51 +745,51 @@
FTupleFirebase* tuple = [FTestHelpers getRandomNodePairWithoutPersistence];
FIRDatabaseReference * writeNode = tuple.one;
FIRDatabaseReference * readNode = tuple.two;
-
+
__block BOOL done = NO;
-
+
NSDictionary* compound = @{@"a": @5, @"b": @6};
NSNumber* number = @76;
-
+
[writeNode setValue:compound];
-
+
[self snapWaiter:writeNode withBlock:^(FIRDataSnapshot *snapshot) {
XCTAssertTrue([snapshot hasChildren], @"Has children");
XCTAssertEqualObjects(@5, [[snapshot childSnapshotForPath:@"a"] value], @"First child");
XCTAssertEqualObjects(@6, [[snapshot childSnapshotForPath:@"b"] value], @"First child");
done = YES;
}];
-
+
[self waitUntil:^BOOL{
return done;
}];
-
+
done = NO;
-
+
[self snapWaiter:readNode withBlock:^(FIRDataSnapshot *snapshot) {
XCTAssertTrue([snapshot hasChildren], @"has children");
XCTAssertEqualObjects(@5, [[snapshot childSnapshotForPath:@"a"] value], @"First child");
XCTAssertEqualObjects(@6, [[snapshot childSnapshotForPath:@"b"] value], @"First child");
done = YES;
}];
-
+
[self waitUntil:^BOOL{
return done;
}];
-
+
done = NO;
-
+
[writeNode setValue:number withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
done = YES;
}];
-
+
[self waitUntil:^BOOL{
return done;
}];
-
+
done = NO;
-
+
[self snapWaiter:readNode withBlock:^(FIRDataSnapshot *snapshot) {
XCTAssertFalse([snapshot hasChildren], @"No more children");
XCTAssertEqualObjects(number, [snapshot value], @"Proper non compound value");
@@ -799,30 +799,30 @@
[self waitUntil:^BOOL{
return done;
}];
-
+
done = NO;
-
+
[writeNode setValue:compound withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
done = YES;
}];
-
+
[self waitUntil:^BOOL{
return done;
}];
-
+
done = NO;
-
+
[self snapWaiter:readNode withBlock:^(FIRDataSnapshot *snapshot) {
XCTAssertTrue([snapshot hasChildren], @"Has children");
XCTAssertEqualObjects(@5, [[snapshot childSnapshotForPath:@"a"] value], @"First child");
XCTAssertEqualObjects(@6, [[snapshot childSnapshotForPath:@"b"] value], @"First child");
done = YES;
}];
-
+
[self waitUntil:^BOOL{
return done;
}];
-
+
XCTAssertTrue(done, @"Properly finished");
}
@@ -1421,7 +1421,7 @@
- (void) testSettingInvalidObjectsThrow {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
XCTAssertThrows([ref setValue:[NSDate date]], @"Should throw");
NSDictionary *data = @{@"invalid":@"data", @".sv":@"timestamp"};
@@ -1451,7 +1451,7 @@
- (void) testSettingNull {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
XCTAssertNoThrow([ref setValue:nil], @"Should not throw");
XCTAssertNoThrow([ref setValue:[NSNull null]], @"Should not throw");
}
@@ -1470,7 +1470,7 @@
- (void) testRemoveFromOnMobileGraffitiBugAtAngelHack {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
-
+
__block BOOL done = NO;
[node observeEventType:FIRDataEventTypeChildAdded withBlock:^(FIRDataSnapshot *snapshot) {
@@ -1478,53 +1478,53 @@
done = YES;
}];
}];
-
+
[[node childByAutoId] setValue:@"moo"];
-
+
[self waitUntil:^BOOL{
return done;
}];
-
+
XCTAssertTrue(done, @"Properly finished");
}
- (void) testSetANodeWithAQuotedKey {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
-
+
__block BOOL done = NO;
__block FIRDataSnapshot * snap;
[node observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
snap = snapshot;
}];
-
+
[node setValue:@{@"\"herp\"": @1234} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
done = YES;
XCTAssertEqualObjects(@1234, [[snap childSnapshotForPath:@"\"herp\""] value], @"Got it back");
}];
-
+
[self waitUntil:^BOOL{
return done;
}];
-
+
XCTAssertTrue(done, @"Properly finished");
}
- (void) testSetANodeWithASingleQuoteKey {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
-
+
__block BOOL done = NO;
__block FIRDataSnapshot * snap;
[node observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
snap = snapshot;
}];
-
+
[node setValue:@{@"\"": @1234} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
done = YES;
XCTAssertEqualObjects(@1234, [[snap childSnapshotForPath:@"\""] value], @"Got it back");
}];
-
+
[self waitUntil:^BOOL{
return done;
}];
@@ -1534,18 +1534,18 @@
- (void) testEmptyChildGetValueEventBeforeParent {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
-
+
NSArray* lookingFor = @[
[[FTupleEventTypeString alloc] initWithFirebase:[node child:@"a/aa/aaa"] withEvent:FIRDataEventTypeValue withString:nil],
[[FTupleEventTypeString alloc] initWithFirebase:[node child:@"a/aa"] withEvent:FIRDataEventTypeValue withString:nil],
[[FTupleEventTypeString alloc] initWithFirebase:[node child:@"a"] withEvent:FIRDataEventTypeValue withString:nil],
];
-
+
FEventTester* et = [[FEventTester alloc] initFrom:self];
[et addLookingFor:lookingFor];
-
+
[node setValue:@{@"b": @5}];
-
+
[et wait];
}
@@ -1909,14 +1909,14 @@
FTupleFirebase* refs = [FTestHelpers getRandomNodePair];
FIRDatabaseReference * reader = refs.one;
FIRDatabaseReference * writer = refs.two;
-
+
__block FIRDataSnapshot * localSnap = nil;
__block BOOL ready = NO;
[writer observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
localSnap = snapshot;
}];
-
+
[writer setValue:@{@"a": @{@"aa": @1, @"ab": @2}}];
[writer updateChildValues:@{@"a/aa": @10,
@".priority": @3.0,
@@ -1925,7 +1925,7 @@
withCompletionBlock:^(NSError* error, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
@@ -1937,7 +1937,7 @@
XCTAssertTrue([result isEqualToDictionary:expected], @"Should get new value");
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
NSDictionary* result = [localSnap value];
NSDictionary* expected = @{@"a": @{@"aa": @10, @"ab": @20}};
@@ -2165,7 +2165,7 @@
snap = nil;
[ref setValue:toSet];
-
+
[self waitUntil:^BOOL{
return snap != nil;
}];
@@ -2306,14 +2306,14 @@
@".priority": [FIRServerValue timestamp]
}
};
-
+
__block BOOL done = NO;
[writer setValue:data andPriority:[FIRServerValue timestamp] withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) { done = YES; }];
-
+
[self waitUntil:^BOOL{
return done;
}];
-
+
[self snapWaiter:reader withBlock:^(FIRDataSnapshot *snapshot) {
NSDictionary* value = [snapshot value];
NSNumber* now = [NSNumber numberWithDouble:round([[NSDate date] timeIntervalSince1970]*1000)];
@@ -2359,7 +2359,7 @@
FTupleFirebase* refs = [FTestHelpers getRandomNodePair];
FIRDatabaseReference * writer = refs.one;
FIRDatabaseReference * reader = refs.two;
-
+
__block FIRDataSnapshot *snap = nil;
__block BOOL done = NO;
[reader observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
@@ -2368,14 +2368,14 @@
done = YES;
}
}];
-
+
[[writer child:@"a/b/c"] setValue:@1];
[[writer child:@"a"] updateChildValues:@{ @"b": @{ @"c": [FIRServerValue timestamp], @"d":@1 } }];
[self waitUntil:^BOOL{
return done;
}];
-
+
NSNumber* now = [NSNumber numberWithDouble:round([[NSDate date] timeIntervalSince1970]*1000)];
NSNumber* timestamp = [[snap childSnapshotForPath:@"a/b/c"] value];
XCTAssertTrue([[[snap childSnapshotForPath:@"a/b/c"] value] isKindOfClass:[NSNumber class]], @"Should get back number");
@@ -2392,19 +2392,19 @@
@".priority": [FIRServerValue timestamp]
}
};
-
+
__block FIRDataSnapshot *snap = nil;
[node observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
snap = snapshot;
}];
-
+
__block BOOL done = NO;
[node setValue:data andPriority:[FIRServerValue timestamp] withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) { done = YES; }];
-
+
[self waitUntil:^BOOL{
return done;
}];
-
+
[self snapWaiter:node withBlock:^(FIRDataSnapshot *snapshot) {
NSDictionary* value = [snapshot value];
NSNumber* now = [NSNumber numberWithDouble:round([[NSDate date] timeIntervalSince1970]*1000)];
@@ -2419,20 +2419,20 @@
- (void) testServerValuesSetPriorityLocalEvents {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
-
+
__block FIRDataSnapshot *snap = nil;
[node observeEventType:FIRDataEventTypeChildMoved withBlock:^(FIRDataSnapshot *snapshot) {
snap = snapshot;
}];
__block BOOL done = NO;
-
+
[[node child:@"a"] setValue:@1 andPriority:nil];
[[node child:@"b"] setValue:@1 andPriority:@1];
[[node child:@"a"] setPriority:[FIRServerValue timestamp] withCompletionBlock:^(NSError* error, FIRDatabaseReference * ref) {
done = YES;
}];
-
+
[self waitUntil:^BOOL{
return done;
}];
@@ -2445,7 +2445,7 @@
- (void) testServerValuesUpdateLocalEvents {
FIRDatabaseReference * node1 = [FTestHelpers getRandomNode];
-
+
__block FIRDataSnapshot *snap1 = nil;
[node1 observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
snap1 = snapshot;
@@ -2460,11 +2460,11 @@
[currentData setValue:[FIRServerValue timestamp]];
return [FIRTransactionResult successWithValue:currentData];
}];
-
+
[self waitUntil:^BOOL{
return snap1 != nil && snap2 != nil && [snap1 value] != nil && [snap2 value] != nil;
}];
-
+
NSNumber* now = [NSNumber numberWithDouble:round([[NSDate date] timeIntervalSince1970]*1000)];
NSNumber* timestamp1 = [snap1 value];
@@ -2478,19 +2478,19 @@
- (void) testServerValuesTransactionLocalEvents {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
-
+
__block FIRDataSnapshot *snap = nil;
[node observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
snap = snapshot;
}];
-
+
[[node child:@"a/b/c"] setValue:@1];
[[node child:@"a"] updateChildValues:@{ @"b": @{ @"c": [FIRServerValue timestamp], @"d":@1 } }];
-
+
[self waitUntil:^BOOL{
return snap != nil && [[snap childSnapshotForPath:@"a/b/d"] value] != nil;
}];
-
+
NSNumber* now = [NSNumber numberWithDouble:round([[NSDate date] timeIntervalSince1970]*1000)];
NSNumber* timestamp = [[snap childSnapshotForPath:@"a/b/c"] value];
XCTAssertTrue([[[snap childSnapshotForPath:@"a/b/c"] value] isKindOfClass:[NSNumber class]], @"Should get back number");
@@ -2499,7 +2499,7 @@
- (void) testUpdateAfterChildSet {
FIRDatabaseReference *node = [FTestHelpers getRandomNode];
-
+
__block BOOL done = NO;
__weak FIRDatabaseReference *weakRef = node;
[node setValue:@{@"a": @"a"} withCompletionBlock:^(NSError *error, FIRDatabaseReference *ref) {
@@ -2508,12 +2508,12 @@
done = YES;
}
}];
-
+
[[weakRef child:@"b"] setValue:@"b"];
-
+
[weakRef updateChildValues:@{@"c" : @"c"}];
}];
-
+
[self waitUntil:^BOOL{
return done;
}];
@@ -2555,7 +2555,7 @@
];
[self waitUntil:^BOOL{ return done; }];
-
+
// cleanup
[FRepoManager interrupt:cfg];
[FRepoManager disposeRepos:cfg];
diff --git a/Example/Database/Tests/Integration/FDotInfo.m b/Example/Database/Tests/Integration/FDotInfo.m
index 0245dc5..60869ce 100644
--- a/Example/Database/Tests/Integration/FDotInfo.m
+++ b/Example/Database/Tests/Integration/FDotInfo.m
@@ -105,10 +105,10 @@
- (void) testManualConnectionManagement {
FIRDatabaseConfig *cfg = [FIRDatabaseConfig configForName:@"test-config"];
FIRDatabaseConfig *altCfg = [FIRDatabaseConfig configForName:@"alt-config"];
-
+
FIRDatabaseReference * ref = [[FIRDatabaseReference alloc] initWithConfig:cfg];
FIRDatabaseReference * refAlt = [[FIRDatabaseReference alloc] initWithConfig:altCfg];
-
+
// Wait until we're connected to both Firebases
__block BOOL ready = NO;
[[ref child:@".info/connected"] observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
@@ -116,7 +116,7 @@
}];
[self waitUntil:^{ return ready; }];
[[ref child:@".info/connected"] removeAllObservers];
-
+
ready = NO;
[[refAlt child:@".info/connected"] observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
ready = [[snapshot value] boolValue];
diff --git a/Example/Database/Tests/Integration/FEventTests.m b/Example/Database/Tests/Integration/FEventTests.m
index cbd7f31..3dd28de 100644
--- a/Example/Database/Tests/Integration/FEventTests.m
+++ b/Example/Database/Tests/Integration/FEventTests.m
@@ -29,15 +29,15 @@
}
- (void) testWriteLeafExpectValueChanged {
-
+
FTupleFirebase* tuple = [FTestHelpers getRandomNodePair];
FIRDatabaseReference * writeNode = tuple.one;
FIRDatabaseReference * readNode = tuple.two;
-
+
__block BOOL done = NO;
[writeNode setValue:@1234 withCompletionBlock:^(NSError* error, FIRDatabaseReference * ref) { done = YES; }];
[self waitUntil:^BOOL{ return done; }];
-
+
[super snapWaiter:readNode withBlock:^(FIRDataSnapshot *s) {
XCTAssertEqualObjects([s value], @1234, @"Proper value in snapshot");
}];
@@ -50,83 +50,83 @@
[super snapWaiter:writeNode withBlock:^(FIRDataSnapshot *s) {
XCTAssertEqualObjects([s value], @42, @"Proper value in snapshot");
}];
-
+
}
- (void) testWriteLeafNodeThenExpectChildAddedEventThenValueEvent {
-
+
FIRDatabaseReference * writeNode = [FTestHelpers getRandomNode];
-
+
[[writeNode child:@"foo"] setValue:@878787];
-
+
NSArray* lookingFor = @[
[[FTupleEventTypeString alloc] initWithFirebase:writeNode withEvent:FIRDataEventTypeChildAdded withString:@"foo"],
[[FTupleEventTypeString alloc] initWithFirebase:writeNode withEvent:FIRDataEventTypeValue withString:nil],
];
-
+
FEventTester* et = [[FEventTester alloc] initFrom:self];
[et addLookingFor:lookingFor];
[et wait];
-
+
[super snapWaiter:writeNode withBlock:^(FIRDataSnapshot *s) {
XCTAssertEqualObjects([[s childSnapshotForPath:@"foo"] value], @878787, @"Got proper value");
}];
-
+
}
- (void) testSetMultipleEventListenersOnSameNode {
-
+
FTupleFirebase* tuple = [FTestHelpers getRandomNodePair];
FIRDatabaseReference * writeNode = tuple.one;
FIRDatabaseReference * readNode = tuple.two;
[writeNode setValue:@42];
-
+
// two write nodes
FEventTester* et = [[FEventTester alloc] initFrom:self];
[et addLookingFor:@[[[FTupleEventTypeString alloc] initWithFirebase:writeNode withEvent:FIRDataEventTypeValue withString:nil] ]];
[et wait];
-
+
et = [[FEventTester alloc] initFrom:self];
[et addLookingFor:@[[[FTupleEventTypeString alloc] initWithFirebase:writeNode withEvent:FIRDataEventTypeValue withString:nil] ]];
[et wait];
-
+
// two read nodes
et = [[FEventTester alloc] initFrom:self];
[et addLookingFor:@[[[FTupleEventTypeString alloc] initWithFirebase:readNode withEvent:FIRDataEventTypeValue withString:nil] ]];
[et wait];
-
+
et = [[FEventTester alloc] initFrom:self];
[et addLookingFor:@[[[FTupleEventTypeString alloc] initWithFirebase:readNode withEvent:FIRDataEventTypeValue withString:nil] ]];
[et wait];
-
+
}
- (void) testUnsubscribeEventsAndConfirmThatEventsNoLongerFire {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
__block int numValueCB = 0;
-
+
FIRDatabaseHandle handle = [node observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *s) {
numValueCB = numValueCB + 1;
}];
-
+
// Set
for(int i = 0; i < 3; i++) {
[node setValue:[NSNumber numberWithInt:i]];
}
-
+
// bye
[node removeObserverWithHandle:handle];
-
+
// set again
for(int i = 10; i < 15; i++) {
[node setValue:[NSNumber numberWithInt:i]];
}
-
+
for(int i = 20; i < 25; i++) {
[node setValue:[NSNumber numberWithInt:i]];
}
-
+
// Should just be 3
[self waitUntil:^BOOL{
return numValueCB == 3;
@@ -142,27 +142,27 @@
[writeNode setValue:@{@"a": @10, @"b": @20} withCompletionBlock:^(NSError* error, FIRDatabaseReference * ref) {
done = YES;
}];
-
+
[self waitUntil:^BOOL{ return done; }];
NSArray* lookingForW = @[
[[FTupleEventTypeString alloc] initWithFirebase:[writeNode child:@"a"] withEvent:FIRDataEventTypeValue withString:nil],
[[FTupleEventTypeString alloc] initWithFirebase:[writeNode child:@"b"] withEvent:FIRDataEventTypeValue withString:nil],
];
-
+
NSArray* lookingForR = @[
[[FTupleEventTypeString alloc] initWithFirebase:[readNode child:@"a"] withEvent:FIRDataEventTypeValue withString:nil],
[[FTupleEventTypeString alloc] initWithFirebase:[readNode child:@"b"] withEvent:FIRDataEventTypeValue withString:nil],
];
-
+
FEventTester* etW = [[FEventTester alloc] initFrom:self];
[etW addLookingFor:lookingForW];
[etW wait];
-
+
FEventTester* etR = [[FEventTester alloc] initFrom:self];
[etR addLookingFor:lookingForR];
[etR wait];
-
+
// Modify compound but just change one of them
lookingForW = @[[[FTupleEventTypeString alloc] initWithFirebase:[writeNode child:@"b"] withEvent:FIRDataEventTypeValue withString:nil] ];
@@ -170,29 +170,29 @@
[etW addLookingFor:lookingForW];
[etR addLookingFor:lookingForR];
-
- [writeNode setValue:@{@"a": @10, @"b": @30}];
-
+
+ [writeNode setValue:@{@"a": @10, @"b": @30}];
+
[etW wait];
[etR wait];
}
-
+
- (void) testValueEventIsFiredForEmptyNode {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
-
+
__block BOOL valueFired = NO;
[node observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *s) {
XCTAssertTrue([[s value] isEqual:[NSNull null]], @"Value is properly nil");
valueFired = YES;
}];
-
+
[self waitUntil:^BOOL{
return valueFired;
}];
}
-
+
- (void) testCorrectEventsRaisedWhenLeafTurnsIntoInternalNode {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
NSMutableString* eventString = [[NSMutableString alloc] init];
@@ -209,69 +209,69 @@
[node observeEventType:FIRDataEventTypeChildAdded withBlock:^(FIRDataSnapshot *s) {
[eventString appendFormat:@", child_added %@", [s key]];
}];
-
+
[node setValue:@42];
[node setValue:@{@"a": @2}];
[node setValue:@84];
__block BOOL done = NO;
[node setValue:nil withCompletionBlock:^(NSError* error, FIRDatabaseReference * ref) { done = YES; }];
[self waitUntil:^BOOL{ return done; }];
-
+
XCTAssertEqualObjects(@", value 42, child_added a, got children, value 84, value <null>", eventString, @"Proper order seen");
}
- (void) testRegisteringCallbackMultipleTimesAndUnregistering {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
__block int changes = 0;
-
+
fbt_void_datasnapshot cb = ^(FIRDataSnapshot *snapshot) { changes = changes + 1; };
-
+
FIRDatabaseHandle handle1 = [node observeEventType:FIRDataEventTypeValue withBlock:cb];
FIRDatabaseHandle handle2 = [node observeEventType:FIRDataEventTypeValue withBlock:cb];
FIRDatabaseHandle handle3 = [node observeEventType:FIRDataEventTypeValue withBlock:cb];
-
+
__block BOOL done = NO;
[node setValue:@42 withCompletionBlock:^(NSError* error, FIRDatabaseReference * ref) { done = YES; }];
[self waitUntil:^BOOL{ return done; }];
done = NO;
-
+
XCTAssertTrue(changes == 3, @"Saw 3 callback events %d", changes);
[node removeObserverWithHandle:handle1];
[node setValue:@84 withCompletionBlock:^(NSError* error, FIRDatabaseReference * ref) { done = YES; }];
[self waitUntil:^BOOL{ return done; }];
done = NO;
-
+
XCTAssertTrue(changes == 5, @"Saw 5 callback events %d", changes);
[node removeObserverWithHandle:handle2];
[node setValue:@168 withCompletionBlock:^(NSError* error, FIRDatabaseReference * ref) { done = YES; }];
[self waitUntil:^BOOL{ return done; }];
done = NO;
-
+
XCTAssertTrue(changes == 6, @"Saw 6 callback events %d", changes);
-
+
[node removeObserverWithHandle:handle3];
[node setValue:@376 withCompletionBlock:^(NSError* error, FIRDatabaseReference * ref) { done = YES; }];
[self waitUntil:^BOOL{ return done; }];
done = NO;
-
+
XCTAssertTrue(changes == 6, @"Saw 6 callback events %d", changes);
-
+
NSLog(@"callbacks: %d", changes);
-
+
}
- (void) testUnregisteringTheSameCallbackTooManyTimesDoesNothing {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
-
+
fbt_void_datasnapshot cb = ^(FIRDataSnapshot *snapshot) { };
-
+
FIRDatabaseHandle handle1 = [node observeEventType:FIRDataEventTypeValue withBlock:cb];
[node removeObserverWithHandle:handle1];
[node removeObserverWithHandle:handle1];
-
+
XCTAssertTrue(YES, @"Properly reached end of test without throwing errors.");
}
@@ -284,24 +284,24 @@
firstCall = NO;
XCTAssertEqualObjects(@42, [snapshot value], @"Properly saw node value");
}];
-
+
[path setValue:@42];
[path setValue:@84];
-
+
__block BOOL done = NO;
-
+
[path setValue:nil withCompletionBlock:^(NSError* error, FIRDatabaseReference * ref) { done = YES; }];
[self waitUntil:^BOOL{ return done; }];
}
- (void) testOnceChildAddedFiresExaclyOnce {
__block int badCount = 0;
-
+
// for(int i = 0; i < 100; i++) {
FIRDatabaseReference * path = [FTestHelpers getRandomNode];
__block BOOL firstCall = YES;
-
+
__block BOOL done = NO;
@@ -319,18 +319,18 @@
}];
-
+
[[path child:@"foo"] setValue:@42];
[[path child:@"bar"] setValue:@84]; // XXX FIXME sometimes this event fires first
[[path child:@"foo"] setValue:@168];
-
-
+
+
// [path setValue:nil withCompletionBlock:^(BOOL status) { done = YES; }];
[self waitUntil:^BOOL{ return done; }];
-
-
+
+
// }
-
+
NSLog(@"BADCOUNT: %d", badCount);
}
@@ -351,10 +351,10 @@
XCTFail(@"Callback got called more than once.");
}
}];
-
+
[path setValue:@42];
[path setValue:@84];
-
+
[self waitUntil:^BOOL{ return done; }];
}
@@ -368,11 +368,11 @@
XCTAssertEqualObjects(@84, [snapshot value], @"Properly saw node value");
XCTAssertEqualObjects(@"bar", [snapshot key], @"Properly saw the first node");
}];
-
+
[path setValue:@{@"foo": @42, @"bar": @84}];
-
+
__block BOOL done = NO;
-
+
[path setValue:nil withCompletionBlock:^(NSError* error, FIRDatabaseReference * ref) { done = YES; }];
[self waitUntil:^BOOL{ return done; }];
}
@@ -387,7 +387,7 @@
XCTAssertTrue([[snapshot value] isEqual:[NSNull null]], @"Properly saw nil child node");
done = YES;
}];
-
+
[self waitUntil:^BOOL{ return done; }];
}
@@ -400,7 +400,7 @@
[node observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
parentDone = YES;
}];
-
+
[self waitUntil:^BOOL{
return parentDone;
}];
@@ -409,19 +409,19 @@
XCTAssertTrue([[snapshot value] isEqual:[NSNull null]], @"Child is properly nil");
done = YES;
}];
-
+
// This test really isn't in the same spirit as the JS test; we can't currently make sure that the test fires right away since the ON and callback are async
-
+
[self waitUntil:^BOOL{
return done;
}];
-
+
XCTAssertTrue(done, @"Done fired.");
}
- (void) testEventsAreRaisedChildRemovedChildAddedChildMoved {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
-
+
NSMutableArray* events = [[NSMutableArray alloc] init];
[node observeEventType:FIRDataEventTypeChildAdded withBlock:^(FIRDataSnapshot *snap) {
@@ -435,9 +435,9 @@
[node observeEventType:FIRDataEventTypeChildMoved withBlock:^(FIRDataSnapshot *snap) {
[events addObject:[NSString stringWithFormat:@"moved %@", [snap key]]];
}];
-
+
__block BOOL done = NO;
-
+
[node setValue:@{
@"a": @{@".value": @1, @".priority": @0 },
@"b": @{@".value": @1, @".priority": @1 },
@@ -448,15 +448,15 @@
} withCompletionBlock:^(NSError* error, FIRDatabaseReference * ref) {
done = YES;
}];
-
+
[self waitUntil:^BOOL{
return done;
}];
-
+
[events removeAllObjects];
-
+
done = NO;
-
+
[node setValue:@{
@"a": @{@".value": @1, @".priority": @5 },
@"aa": @{@".value": @1, @".priority": @0 },
@@ -469,11 +469,11 @@
done = YES;
}
];
-
+
[self waitUntil:^BOOL{
return done;
}];
-
+
XCTAssertEqualObjects(@"removed c, removed f, added aa, added bb, moved a, moved e", [events componentsJoinedByString:@", "], @"Got expected results");
}
diff --git a/Example/Database/Tests/Integration/FIRDatabaseQueryTests.m b/Example/Database/Tests/Integration/FIRDatabaseQueryTests.m
index a5bff5a..ff4b5dc 100644
--- a/Example/Database/Tests/Integration/FIRDatabaseQueryTests.m
+++ b/Example/Database/Tests/Integration/FIRDatabaseQueryTests.m
@@ -23,7 +23,7 @@
- (void) testCanCreateBasicQueries {
// Just make sure none of these throw anything
-
+
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
[ref queryLimitedToFirst:10];
@@ -143,7 +143,7 @@
- (void) testInvalidKeys {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
NSArray* badKeys = @[ @".test", @"test.", @"fo$o", @"[what", @"ever]", @"ha#sh", @"/thing", @"th/ing", @"thing/"];
-
+
for (NSString* badKey in badKeys) {
XCTAssertThrows([[ref queryOrderedByPriority] queryStartingAtValue:nil childKey:badKey], @"Setting bad key");
XCTAssertThrows([[ref queryOrderedByPriority] queryEndingAtValue:nil childKey:badKey], @"Setting bad key");
@@ -152,7 +152,7 @@
- (void) testOffCanBeCalledOnDefault {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
__block BOOL called = NO;
FIRDatabaseQuery * query = [ref queryLimitedToLast:5];
[query observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
@@ -162,32 +162,32 @@
called = YES;
}
}];
-
+
[ref setValue:@{@"a": @5, @"b": @6}];
-
+
[self waitUntil:^BOOL{
return called;
}];
-
+
called = NO;
-
+
[ref removeAllObservers];
-
+
__block BOOL complete = NO;
[ref setValue:@{@"a": @6, @"b": @7} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
complete = YES;
}];
-
+
[self waitUntil:^BOOL{
return complete;
}];
-
+
XCTAssertFalse(called, @"Should not have been called again");
}
- (void) testOffCanBeCalledOnHandle {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
__block BOOL called = NO;
FIRDatabaseQuery * query = [ref queryLimitedToLast:5];
FIRDatabaseHandle handle = [query observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
@@ -197,32 +197,32 @@
called = YES;
}
}];
-
+
[ref setValue:@{@"a": @5, @"b": @6}];
-
+
[self waitUntil:^BOOL{
return called;
}];
-
+
called = NO;
-
+
[ref removeObserverWithHandle:handle];
-
+
__block BOOL complete = NO;
[ref setValue:@{@"a": @6, @"b": @7} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
complete = YES;
}];
-
+
[self waitUntil:^BOOL{
return complete;
}];
-
+
XCTAssertFalse(called, @"Should not have been called again");
}
- (void) testOffCanBeCalledOnSpecificQuery {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
__block BOOL called = NO;
FIRDatabaseQuery * query = [ref queryLimitedToLast:5];
FIRDatabaseHandle handle = [query observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
@@ -232,26 +232,26 @@
called = YES;
}
}];
-
+
[ref setValue:@{@"a": @5, @"b": @6}];
-
+
[self waitUntil:^BOOL{
return called;
}];
-
+
called = NO;
-
+
[query removeObserverWithHandle:handle];
-
+
__block BOOL complete = NO;
[ref setValue:@{@"a": @6, @"b": @7} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
complete = YES;
}];
-
+
[self waitUntil:^BOOL{
return complete;
}];
-
+
XCTAssertFalse(called, @"Should not have been called again");
}
@@ -267,7 +267,7 @@
- (void) testOffCanBeCalledWithoutHandle {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
__block BOOL called1 = NO;
__block BOOL called2 = NO;
FIRDatabaseQuery * query = [ref queryLimitedToLast:5];
@@ -277,51 +277,51 @@
[query observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
called2 = YES;
}];
-
+
[ref setValue:@{@"a": @5, @"b": @6}];
-
+
[self waitUntil:^BOOL{
return called1 && called2;
}];
-
+
called1 = NO;
called2 = NO;
-
+
[ref removeAllObservers];
-
+
__block BOOL complete = NO;
[ref setValue:@{@"a": @6, @"b": @7} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
complete = YES;
}];
-
+
[self waitUntil:^BOOL{
return complete;
}];
-
+
XCTAssertFalse(called1 || called2, @"Should not have called either callback");
}
- (void) testEnsureOnly5ItemsAreKept {
__block FIRDataSnapshot * snap = nil;
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
FIRDatabaseQuery * query = [ref queryLimitedToLast:5];
__block int count = 0;
[query observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
snap = snapshot;
count++;
}];
-
+
[ref setValue:nil];
for (int i = 0; i < 10; ++i) {
[[ref childByAutoId] setValue:[NSNumber numberWithInt:i]];
}
-
+
[self waitUntil:^BOOL{
// The initial set triggers the callback, so we need to wait for 11 events
return count == 11;
}];
-
+
count = 5;
for (FIRDataSnapshot * snapshot in snap.children) {
NSNumber* num = [snapshot value];
@@ -329,26 +329,26 @@
XCTAssertTrue([num isEqualToNumber:current], @"Expect children in order");
count++;
}
-
+
XCTAssertTrue(count == 10, @"Expected 5 children");
}
- (void) testOnlyLast5SentFromServer {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
__block int count = 0;
-
+
[ref setValue:nil];
-
+
for (int i = 0; i < 10; ++i) {
[[ref childByAutoId] setValue:[NSNumber numberWithInt:i] withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
count++;
}];
}
-
+
[self waitUntil:^BOOL{
return count == 10;
}];
-
+
FIRDatabaseQuery * query = [ref queryLimitedToLast:5];
count = 5;
[query observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
@@ -359,7 +359,7 @@
count++;
}
}];
-
+
[self waitUntil:^BOOL{
return count == 10;
}];
@@ -374,17 +374,17 @@
[expectations addQuery:[[[ref queryOrderedByPriority] queryEndingAtValue:nil] queryLimitedToLast:2] withExpectation:@{@"b": @2, @"c": @3}];
[expectations addQuery:[[[ref queryOrderedByPriority] queryEndingAtValue:nil] queryLimitedToLast:3] withExpectation:@{@"a": @1, @"b": @2, @"c": @3}];
[expectations addQuery:[[[ref queryOrderedByPriority] queryEndingAtValue:nil] queryLimitedToLast:4] withExpectation:@{@"a": @1, @"b": @2, @"c": @3}];
-
-
+
+
__block BOOL ready = NO;
[ref setValue:@{@"a": @1, @"b": @2, @"c": @3} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
[expectations validate];
}
@@ -397,51 +397,51 @@
[expectations addQuery:[[[ref queryOrderedByPriority] queryStartingAtValue:nil childKey:@"b"] queryLimitedToFirst:1] withExpectation:@{@"b": @2}];
[expectations addQuery:[[[ref queryOrderedByPriority] queryStartingAtValue:nil childKey:@"b"] queryLimitedToFirst:2] withExpectation:@{@"b": @2, @"c": @3}];
[expectations addQuery:[[[ref queryOrderedByPriority] queryStartingAtValue:nil childKey:@"b"] queryLimitedToFirst:3] withExpectation:@{@"b": @2, @"c": @3}];
-
-
+
+
__block BOOL ready = NO;
[ref setValue:@{@"a": @1, @"b": @2, @"c": @3} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
[expectations validate];
}
- (void) testLimitsAndStartAtWithServerData {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
__block BOOL ready = NO;
[ref setValue:@{@"a": @1, @"b": @2, @"c": @3} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
FTestExpectations* expectations = [[FTestExpectations alloc] initFrom:self];
[expectations addQuery:[[[ref queryOrderedByPriority] queryStartingAtValue:nil] queryLimitedToFirst:1] withExpectation:@{@"a": @1}];
-
+
/*params = [[FQueryParams alloc] init];
params = [params setStartPriority:nil andName:@"c"];
params = [params limitTo:1];
[expectations addQuery:[ref queryWithParams:params] withExpectation:@{@"c": @3}];
-
+
params = [[FQueryParams alloc] init];
params = [params setStartPriority:nil andName:@"b"];
params = [params limitTo:1];
[expectations addQuery:[ref queryWithParams:params] withExpectation:@{@"b": @2}];
-
+
params = [[FQueryParams alloc] init];
params = [params setStartPriority:nil andName:@"b"];
params = [params limitTo:2];
[expectations addQuery:[ref queryWithParams:params] withExpectation:@{@"b": @2, @"c": @3}];
-
+
params = [[FQueryParams alloc] init];
params = [params setStartPriority:nil andName:@"b"];
params = [params limitTo:3];
@@ -456,7 +456,7 @@
- (void) testChildEventsAreFiredWhenLimitIsHit {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
NSMutableArray* added = [[NSMutableArray alloc] init];
NSMutableArray* removed = [[NSMutableArray alloc] init];
[[ref queryLimitedToLast:2] observeEventType:FIRDataEventTypeChildAdded withBlock:^(FIRDataSnapshot *snapshot) {
@@ -467,30 +467,30 @@
[removed addObject:[snapshot key]];
}];
-
+
__block BOOL ready = NO;
[ref setValue:@{@"a": @1, @"b": @2, @"c": @3} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
XCTAssertTrue([removed count] == 0, @"Nothing should be removed from our window");
NSArray* expected = @[@"b", @"c"];
XCTAssertTrue([added isEqualToArray:expected], @"Should have two items");
-
+
[added removeAllObjects];
ready = NO;
[[ref child:@"d"] setValue:@4 withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
expected = @[@"b"];
XCTAssertTrue([removed isEqualToArray:expected], @"Expected to remove b");
expected = @[@"d"];
@@ -500,16 +500,16 @@
- (void) testChildEventsAreFiredWhenLimitIsHitWithServerData {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
__block BOOL ready = NO;
[ref setValue:@{@"a": @1, @"b": @2, @"c": @3} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
NSMutableArray* added = [[NSMutableArray alloc] init];
NSMutableArray* removed = [[NSMutableArray alloc] init];
FIRDatabaseQuery * query = [ref queryLimitedToLast:2];
@@ -521,25 +521,25 @@
[removed addObject:[snapshot key]];
}];
-
+
[self waitUntil:^BOOL{
return [added count] == 2;
}];
-
+
XCTAssertTrue([removed count] == 0, @"Nothing should be removed from our window");
NSArray* expected = @[@"b", @"c"];
XCTAssertTrue([added isEqualToArray:expected], @"Should have two items");
-
+
[added removeAllObjects];
ready = NO;
[[ref child:@"d"] setValue:@4 withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
expected = @[@"b"];
XCTAssertTrue([removed isEqualToArray:expected], @"Expected to remove b");
expected = @[@"d"];
@@ -562,30 +562,30 @@
[removed addObject:[snapshot key]];
}];
-
+
__block BOOL ready = NO;
[ref setValue:@{@"a": @1, @"b": @2, @"c": @3} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
XCTAssertTrue([removed count] == 0, @"Nothing should be removed from our window");
NSArray* expected = @[@"a", @"b"];
XCTAssertTrue([added isEqualToArray:expected], @"Should have two items");
-
+
[added removeAllObjects];
ready = NO;
[[ref child:@"aa"] setValue:@4 withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
expected = @[@"b"];
XCTAssertTrue([removed isEqualToArray:expected], @"Expected to remove b");
expected = @[@"aa"];
@@ -595,12 +595,12 @@
- (void) testChildEventsAreFiredWhenLimitIsHitWithStartAndServerData {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
__block BOOL ready = NO;
[ref setValue:@{@"a": @1, @"b": @2, @"c": @3} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
@@ -616,25 +616,25 @@
[removed addObject:[snapshot key]];
}];
-
+
[self waitUntil:^BOOL{
return [added count] == 2;
}];
-
+
XCTAssertTrue([removed count] == 0, @"Nothing should be removed from our window");
NSArray* expected = @[@"a", @"b"];
XCTAssertTrue([added isEqualToArray:expected], @"Should have two items");
-
+
[added removeAllObjects];
ready = NO;
[[ref child:@"aa"] setValue:@4 withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
expected = @[@"b"];
XCTAssertTrue([removed isEqualToArray:expected], @"Expected to remove b");
expected = @[@"aa"];
@@ -655,30 +655,30 @@
[removed addObject:[snapshot key]];
}];
-
+
__block BOOL ready = NO;
[ref setValue:@{@"c": @3} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready && [added count] >= 1;
}];
-
+
XCTAssertTrue([removed count] == 0, @"Nothing should be removed from our window");
NSArray* expected = @[@"c"];
XCTAssertTrue([added isEqualToArray:expected], @"Should have one item");
-
+
[added removeAllObjects];
ready = NO;
[[ref child:@"b"] setValue:@4 withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
XCTAssertTrue([removed count] == 0, @"Expected to remove nothing");
expected = @[@"b"];
XCTAssertTrue([added isEqualToArray:expected], @"Expected to add b");
@@ -687,12 +687,12 @@
- (void) testStartAndLimitWithIncompleteWindowAndServerData {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
__block BOOL ready = NO;
[ref setValue:@{@"c": @3} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
@@ -709,25 +709,25 @@
[removed addObject:[snapshot key]];
}];
-
+
[self waitUntil:^BOOL{
return [added count] == 1;
}];
-
+
XCTAssertTrue([removed count] == 0, @"Nothing should be removed from our window");
NSArray* expected = @[@"c"];
XCTAssertTrue([added isEqualToArray:expected], @"Should have one item");
-
+
[added removeAllObjects];
ready = NO;
[[ref child:@"b"] setValue:@4 withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
XCTAssertTrue([removed count] == 0, @"Expected to remove nothing");
expected = @[@"b"];
XCTAssertTrue([added isEqualToArray:expected], @"Expected to add b");
@@ -738,7 +738,7 @@
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
FIRDatabaseQuery * query = [ref queryLimitedToLast:2];
-
+
NSMutableArray* added = [[NSMutableArray alloc] init];
NSMutableArray* removed = [[NSMutableArray alloc] init];
[query observeEventType:FIRDataEventTypeChildAdded withBlock:^(FIRDataSnapshot *snapshot) {
@@ -748,26 +748,26 @@
[removed addObject:[snapshot key]];
}];
-
+
__block BOOL ready = NO;
[ref setValue:@{@"a": @1, @"b": @2, @"c": @3} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready && [added count] >= 1;
}];
-
+
XCTAssertTrue([removed count] == 0, @"Nothing should be removed from our window");
NSArray* expected = @[@"b", @"c"];
XCTAssertTrue([added isEqualToArray:expected], @"Should have one item");
-
+
[added removeAllObjects];
ready = NO;
[[ref child:@"b"] removeValueWithCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
@@ -781,18 +781,18 @@
-(void) testChildEventsAreFiredWhenItemDeletedAtServer {
FIRDatabaseReference * ref = [FTestHelpers getRandomNodeWithoutPersistence];
-
+
__block BOOL ready = NO;
[ref setValue:@{@"a": @1, @"b": @2, @"c": @3} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
FIRDatabaseQuery * query = [ref queryLimitedToLast:2];
-
+
NSMutableArray* added = [[NSMutableArray alloc] init];
NSMutableArray* removed = [[NSMutableArray alloc] init];
[query observeEventType:FIRDataEventTypeChildAdded withBlock:^(FIRDataSnapshot *snapshot) {
@@ -803,21 +803,21 @@
[removed addObject:[snapshot key]];
}];
-
+
[self waitUntil:^BOOL{
return [added count] == 2;
}];
-
+
XCTAssertTrue([removed count] == 0, @"Nothing should be removed from our window");
NSArray* expected = @[@"b", @"c"];
XCTAssertTrue([added isEqualToArray:expected], @"Should have two items");
-
+
[added removeAllObjects];
ready = NO;
[[ref child:@"b"] removeValueWithCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
@@ -840,26 +840,26 @@
[removed addObject:[snapshot key]];
}];
-
+
__block BOOL ready = NO;
[ref setValue:@{@"b": @2, @"c": @3} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready && [added count] >= 1;
}];
-
+
XCTAssertTrue([removed count] == 0, @"Nothing should be removed from our window");
NSArray* expected = @[@"b", @"c"];
XCTAssertTrue([added isEqualToArray:expected], @"Should have one item");
-
+
[added removeAllObjects];
ready = NO;
[[ref child:@"b"] removeValueWithCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
@@ -872,18 +872,18 @@
-(void) testRemoveFiredWhenItemDeletedAtServer {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
__block BOOL ready = NO;
[ref setValue:@{@"b": @2, @"c": @3} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
FIRDatabaseQuery * query = [ref queryLimitedToLast:2];
-
+
NSMutableArray* added = [[NSMutableArray alloc] init];
NSMutableArray* removed = [[NSMutableArray alloc] init];
[query observeEventType:FIRDataEventTypeChildAdded withBlock:^(FIRDataSnapshot *snapshot) {
@@ -894,21 +894,21 @@
[removed addObject:[snapshot key]];
}];
-
+
[self waitUntil:^BOOL{
return [added count] == 2;
}];
-
+
XCTAssertTrue([removed count] == 0, @"Nothing should be removed from our window");
NSArray* expected = @[@"b", @"c"];
XCTAssertTrue([added isEqualToArray:expected], @"Should have two items");
-
+
[added removeAllObjects];
ready = NO;
[[ref child:@"b"] removeValueWithCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
@@ -922,15 +922,15 @@
- (void) testStartAtPriorityAndEndAtPriorityWork {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
FTestExpectations* expectations = [[FTestExpectations alloc] initFrom:self];
-
+
[expectations addQuery:[[[ref queryOrderedByPriority] queryStartingAtValue:@"w"] queryEndingAtValue:@"y"] withExpectation:@{@"b": @2, @"c": @3, @"d": @4}];
[expectations addQuery:[[[ref queryOrderedByPriority] queryStartingAtValue:@"w"] queryEndingAtValue:@"w"] withExpectation:@{@"d": @4}];
-
+
__block id nullSnap = @"dummy";
[[[[ref queryOrderedByPriority] queryStartingAtValue:@"a"] queryEndingAtValue:@"c"] observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
nullSnap = [snapshot value];
}];
-
+
[ref setValue:@{
@"a": @{@".value": @1, @".priority": @"z"},
@"b": @{@".value": @2, @".priority": @"y"},
@@ -939,13 +939,13 @@
}];
WAIT_FOR(expectations.isReady && [nullSnap isEqual:[NSNull null]]);
-
+
[expectations validate];
}
- (void) testStartAtPriorityAndEndAtPriorityWorkWithServerData {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
__block BOOL ready = NO;
[ref setValue:@{
@"a": @{@".value": @1, @".priority": @"z"},
@@ -957,19 +957,19 @@
}];
WAIT_FOR(ready);
-
+
FTestExpectations* expectations = [[FTestExpectations alloc] initFrom:self];
-
+
[expectations addQuery:[[[ref queryOrderedByPriority] queryStartingAtValue:@"w"] queryEndingAtValue:@"y"] withExpectation:@{@"b": @2, @"c": @3, @"d": @4}];
[expectations addQuery:[[[ref queryOrderedByPriority] queryStartingAtValue:@"w"] queryEndingAtValue:@"w"] withExpectation:@{@"d": @4}];
-
+
__block id nullSnap = @"dummy";
[[[[ref queryOrderedByPriority] queryStartingAtValue:@"a"] queryEndingAtValue:@"c"] observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
nullSnap = [snapshot value];
}];
-
+
WAIT_FOR(expectations.isReady && [nullSnap isEqual:[NSNull null]]);
-
+
[expectations validate];
}
@@ -985,16 +985,16 @@
query = [[[ref queryOrderedByPriority] queryStartingAtValue:@1 childKey:@"c"] queryEndingAtValue:@2];
[expectations addQuery:query withExpectation:@{@"c": @3, @"d": @4}];
-
+
[ref setValue:@{
@"a": @{@".value": @1, @".priority": @1},
@"b": @{@".value": @2, @".priority": @1},
@"c": @{@".value": @3, @".priority": @2},
@"d": @{@".value": @4, @".priority": @2}
}];
-
+
WAIT_FOR(expectations.isReady);
-
+
[expectations validate];
}
@@ -1009,9 +1009,9 @@
} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
WAIT_FOR(ready);
-
+
FTestExpectations* expectations = [[FTestExpectations alloc] initFrom:self];
FIRDatabaseQuery * query = [[[ref queryOrderedByPriority] queryStartingAtValue:@1 childKey:@"a"] queryEndingAtValue:@2 childKey:@"d"];
@@ -1022,9 +1022,9 @@
query = [[[ref queryOrderedByPriority] queryStartingAtValue:@1 childKey:@"c"] queryEndingAtValue:@2];
[expectations addQuery:query withExpectation:@{@"c": @3, @"d": @4}];
-
+
WAIT_FOR(expectations.isReady);
-
+
[expectations validate];
}
@@ -1040,16 +1040,16 @@
query = [[[ref queryOrderedByPriority] queryStartingAtValue:@1 childKey:@"e"] queryEndingAtValue:@2];
[expectations addQuery:query withExpectation:@{@"a": @1, @"b": @2}];
-
+
[ref setValue:@{
@"c": @{@".value": @3, @".priority": @1},
@"d": @{@".value": @4, @".priority": @1},
@"a": @{@".value": @1, @".priority": @2},
@"b": @{@".value": @2, @".priority": @2}
}];
-
+
WAIT_FOR(expectations.isReady);
-
+
[expectations validate];
}
@@ -1064,9 +1064,9 @@
} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
WAIT_FOR(ready);
-
+
FTestExpectations* expectations = [[FTestExpectations alloc] initFrom:self];
FIRDatabaseQuery * query = [[[ref queryOrderedByPriority] queryStartingAtValue:@1 childKey:@"c"] queryEndingAtValue:@2 childKey:@"b"];
@@ -1077,9 +1077,9 @@
query = [[[ref queryOrderedByPriority] queryStartingAtValue:@1 childKey:@"e"] queryEndingAtValue:@2];
[expectations addQuery:query withExpectation:@{@"a": @1, @"b": @2}];
-
+
WAIT_FOR(expectations.isReady);
-
+
[expectations validate];
}
@@ -1190,7 +1190,7 @@
- (void) testPrevNameWorks {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
NSMutableArray* added = [[NSMutableArray alloc] init];
[[ref queryLimitedToLast:2] observeEventType:FIRDataEventTypeChildAdded andPreviousSiblingKeyWithBlock:^(FIRDataSnapshot *snapshot, NSString *prevName) {
@@ -1202,31 +1202,31 @@
}
}];
-
+
[[ref child:@"a"] setValue:@1];
[self waitUntil:^BOOL{
NSArray* expected = @[@"a", @"null"];
return [added isEqualToArray:expected];
}];
-
+
[added removeAllObjects];
-
+
[[ref child:@"c"] setValue:@3];
[self waitUntil:^BOOL{
NSArray* expected = @[@"c", @"a"];
return [added isEqualToArray:expected];
}];
-
+
[added removeAllObjects];
-
+
[[ref child:@"b"] setValue:@2];
[self waitUntil:^BOOL{
NSArray* expected = @[@"b", @"null"];
return [added isEqualToArray:expected];
}];
-
+
[added removeAllObjects];
-
+
[[ref child:@"d"] setValue:@3];
[self waitUntil:^BOOL{
NSArray* expected = @[@"d", @"c"];
@@ -1238,7 +1238,7 @@
- (void) testPrevNameWorksWithMoves {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
NSMutableArray* moved = [[NSMutableArray alloc] init];
[[ref queryLimitedToLast:2] observeEventType:FIRDataEventTypeChildMoved andPreviousSiblingKeyWithBlock:^(FIRDataSnapshot *snapshot, NSString *prevName) {
@@ -1249,56 +1249,56 @@
[moved addObject:@"null"];
}
}];
-
+
[ref setValue:@{
@"a": @{@".value": @"a", @".priority": @10},
@"b": @{@".value": @"b", @".priority": @20},
@"c": @{@".value": @"c", @".priority": @30},
@"d": @{@".value": @"d", @".priority": @40}
}];
-
+
__block BOOL ready = NO;
[[ref child:@"c"] setPriority:@50 withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
NSArray* expected = @[@"c", @"d"];
XCTAssertTrue([moved isEqualToArray:expected], @"Expected changed node and prevChild");
-
+
[moved removeAllObjects];
ready = NO;
[[ref child:@"c"] setPriority:@35 withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
expected = @[@"c", @"null"];
XCTAssertTrue([moved isEqualToArray:expected], @"Expected changed node and prevChild");
-
+
[moved removeAllObjects];
ready = NO;
[[ref child:@"b"] setPriority:@33 withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
expected = @[];
XCTAssertTrue([moved isEqualToArray:expected], @"Expected changed node and prevChild to be empty");
}
- (void) testLocalEvents {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
NSMutableArray* events = [[NSMutableArray alloc] init];
[[ref queryLimitedToLast:2] observeEventType:FIRDataEventTypeChildAdded withBlock:^(FIRDataSnapshot *snapshot) {
NSString *eventString = [NSString stringWithFormat:@"%@ added", [snapshot value]];
@@ -1309,7 +1309,7 @@
NSString *eventString = [NSString stringWithFormat:@"%@ removed", [snapshot value]];
[events addObject:eventString];
}];
-
+
__block BOOL ready = NO;
for (int i = 0; i < 5; ++i) {
[[ref childByAutoId] setValue:[NSNumber numberWithInt:i] withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
@@ -1318,11 +1318,11 @@
}
}];
}
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
NSArray* expected = @[@"0 added", @"1 added", @"0 removed", @"2 added", @"1 removed", @"3 added", @"2 removed", @"4 added"];
XCTAssertTrue([events isEqualToArray:expected], @"Expecting window to stay at two nodes");
}
@@ -1331,7 +1331,7 @@
FTupleFirebase* pair = [FTestHelpers getRandomNodePair];
FIRDatabaseReference * writer = pair.one;
FIRDatabaseReference * reader = pair.two;
-
+
NSMutableArray* events = [[NSMutableArray alloc] init];
[[reader queryLimitedToLast:2] observeEventType:FIRDataEventTypeChildAdded withBlock:^(FIRDataSnapshot *snapshot) {
@@ -1343,11 +1343,11 @@
NSString *oldEventString = [NSString stringWithFormat:@"%@ added", [snapshot value]];
[events removeObject:oldEventString];
}];
-
+
for (int i = 0; i < 5; ++i) {
[[writer childByAutoId] setValue:[NSNumber numberWithInt:i]];
}
-
+
NSArray* expected = @[@"3 added", @"4 added"];
[self waitUntil:^BOOL{
return [events isEqualToArray:expected];
@@ -1356,12 +1356,12 @@
- (void) testLimitOnEmptyNodeFiresValue {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
__block BOOL ready = NO;
[[ref queryLimitedToLast:1] observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
@@ -1369,7 +1369,7 @@
- (void) testFilteringToNullPriorities {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
// Note: cannot set nil in a dictionary, just leave out priority
[ref setValue:@{
@"a": @0,
@@ -1378,7 +1378,7 @@
@"d": @{@".priority": @3, @".value": @3},
@"e": @{@".priority": @"hi", @".value": @4}
}];
-
+
__block BOOL ready = NO;
[[[[ref queryOrderedByPriority] queryStartingAtValue:nil] queryEndingAtValue:nil] observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
NSDictionary *expected = @{@"a" : @0, @"b" : @1};
@@ -1386,7 +1386,7 @@
XCTAssertTrue([val isEqualToDictionary:expected], @"Expected only null priority keys");
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
@@ -1394,7 +1394,7 @@
- (void) testNullPrioritiesIncludedInEndAt {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
// Note: cannot set nil in a dictionary, just leave out priority
[ref setValue:@{
@"a": @0,
@@ -1403,7 +1403,7 @@
@"d": @{@".priority": @3, @".value": @3},
@"e": @{@".priority": @"hi", @".value": @4}
}];
-
+
__block BOOL ready = NO;
[[[ref queryOrderedByPriority] queryEndingAtValue:@2] observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
NSDictionary *expected = @{@"a" : @0, @"b" : @1, @"c" : @2};
@@ -1411,7 +1411,7 @@
XCTAssertTrue([val isEqualToDictionary:expected], @"Expected up to priority 2");
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
@@ -1462,7 +1462,7 @@
XCTAssertTrue([expected isEqualToSet:listens], @"Expected child listener");
ready = YES;
});
-
+
[self waitUntil:^BOOL{
return ready;
}];
@@ -1476,7 +1476,7 @@
XCTAssertTrue([expected isEqualToSet:listens], @"Expected parent listener");
ready = YES;
});
-
+
[self waitUntil:^BOOL{
return ready;
}];
@@ -1489,11 +1489,11 @@
XCTAssertTrue([expected isEqualToSet:listens], @"Child listener should be back");
ready = YES;
});
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
[[ref child:@"a"] removeAllObservers];
ready = NO;
dispatch_async([FIRDatabaseQuery sharedQueue], ^{
@@ -1501,10 +1501,10 @@
XCTAssertTrue(listens.count == 0, @"No more listeners");
ready = YES;
});
-
+
[self waitUntil:^BOOL{
return ready;
- }];
+ }];
}
- (void) testDedupeListensOnGrandchild {
@@ -1520,7 +1520,7 @@
[ref observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
}];
-
+
dispatch_async([FIRDatabaseQuery sharedQueue], ^{
listens = [self dumpListensForRef:ref];
NSSet* expected = [self expectDefaultListenerAtPath:[FPath empty]];
@@ -1565,7 +1565,7 @@
XCTAssertTrue([expected isEqualToSet:listens], @"Expected grandchild");
ready = YES;
});
-
+
[self waitUntil:^BOOL{
return ready;
}];
@@ -1582,7 +1582,7 @@
XCTAssertTrue([expected isEqualToSet:listens], @"Expected two grandchildren");
ready = YES;
});
-
+
[self waitUntil:^BOOL{
return ready;
}];
@@ -1596,11 +1596,11 @@
XCTAssertTrue([expected isEqualToSet:listens], @"Expected parent listener to override");
ready = YES;
});
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
[ref removeAllObservers];
ready = NO;
dispatch_async([FIRDatabaseQuery sharedQueue], ^{
@@ -1612,11 +1612,11 @@
XCTAssertTrue([expected isEqualToSet:listens], @"Expected grandchild listeners to return");
ready = YES;
});
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
[[ref child:@"a/aa"] removeAllObservers];
ready = NO;
dispatch_async([FIRDatabaseQuery sharedQueue], ^{
@@ -1625,11 +1625,11 @@
XCTAssertTrue([expected isEqualToSet:listens], @"Expected one listener");
ready = YES;
});
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
[[ref child:@"a/bb"] removeAllObservers];
ready = NO;
dispatch_async([FIRDatabaseQuery sharedQueue], ^{
@@ -1637,7 +1637,7 @@
XCTAssertTrue(listens.count == 0, @"No more listeners");
ready = YES;
});
-
+
[self waitUntil:^BOOL{
return ready;
}];
@@ -1647,7 +1647,7 @@
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
__block NSSet* listens = [self dumpListensForRef:ref];
XCTAssertTrue(listens.count == 0, @"No Listens yet");
-
+
__block BOOL ready = NO;
FIRDatabaseQuery * aLim1 = [[ref child:@"a"] queryLimitedToLast:1];
FIRDatabaseHandle handle1 = [aLim1 observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
@@ -1660,11 +1660,11 @@
XCTAssertTrue([expected isEqualToSet:listens], @"Single query");
ready = YES;
});
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
ready = NO;
FIRDatabaseQuery * rootLim1 = [ref queryLimitedToLast:1];
FIRDatabaseHandle handle2 = [rootLim1 observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
@@ -1680,11 +1680,11 @@
XCTAssertTrue([expected isEqualToSet:listens], @"Two queries");
ready = YES;
});
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
ready = NO;
FIRDatabaseQuery * aLim5 = [[ref child:@"a"] queryLimitedToLast:5];
FIRDatabaseHandle handle3 = [aLim5 observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
@@ -1694,7 +1694,7 @@
FQueryParams* expectedParams1 = [[FQueryParams alloc] init];
expectedParams1 = [expectedParams1 limitTo:1];
NSSet* rootExpected = [self expectParams:expectedParams1 atPath:[FPath empty]];
-
+
FQueryParams* expectedParams2 = [[FQueryParams alloc] init];
expectedParams2 = [expectedParams2 limitTo:5];
NSSet* childExpected = [self expectParamssetValue:[NSSet setWithObjects:expectedParams1, expectedParams2, nil] atPath:[FPath pathWithString:@"/a"]];
@@ -1703,11 +1703,11 @@
XCTAssertTrue([expected isEqualToSet:listens], @"Three queries");
ready = YES;
});
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
[ref removeObserverWithHandle:handle2];
ready = NO;
dispatch_async([FIRDatabaseQuery sharedQueue], ^{
@@ -1720,11 +1720,11 @@
XCTAssertTrue([expected isEqualToSet:listens], @"Two queries");
ready = YES;
});
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
[aLim1 removeObserverWithHandle:handle1];
[aLim5 removeObserverWithHandle:handle3];
ready = NO;
@@ -1733,7 +1733,7 @@
XCTAssertTrue(listens.count == 0, @"No more listeners");
ready = YES;
});
-
+
[self waitUntil:^BOOL{
return ready;
}];
@@ -1743,7 +1743,7 @@
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
__block NSSet* listens = [self dumpListensForRef:ref];
XCTAssertTrue(listens.count == 0, @"No Listens yet");
-
+
__block BOOL ready = NO;
FIRDatabaseQuery * aLim1 = [[ref child:@"a"] queryLimitedToLast:1];
FIRDatabaseHandle handle1 = [aLim1 observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
@@ -1756,11 +1756,11 @@
XCTAssertTrue([expected isEqualToSet:listens], @"Single query");
ready = YES;
});
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
ready = NO;
FIRDatabaseQuery * bLim1 = [[ref child:@"b"] queryLimitedToLast:1];
FIRDatabaseHandle handle2 = [bLim1 observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
@@ -1776,11 +1776,11 @@
XCTAssertTrue([expected isEqualToSet:listens], @"Two queries");
ready = YES;
});
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
ready = NO;
FIRDatabaseHandle handle3 = [ref observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
}];
@@ -1790,11 +1790,11 @@
XCTAssertTrue([expected isEqualToSet:listens], @"Parent should override");
ready = YES;
});
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
// remove in slightly random order
[aLim1 removeObserverWithHandle:handle1];
ready = NO;
@@ -1804,11 +1804,11 @@
XCTAssertTrue([expected isEqualToSet:listens], @"Parent should override");
ready = YES;
});
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
[ref removeObserverWithHandle:handle3];
ready = NO;
dispatch_async([FIRDatabaseQuery sharedQueue], ^{
@@ -1819,11 +1819,11 @@
XCTAssertTrue([expected isEqualToSet:listens], @"Single query");
ready = YES;
});
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
ready = NO;
[bLim1 removeObserverWithHandle:handle2];
dispatch_async([FIRDatabaseQuery sharedQueue], ^{
@@ -1831,7 +1831,7 @@
XCTAssertTrue(listens.count == 0, @"No more listeners");
ready = YES;
});
-
+
[self waitUntil:^BOOL{
return ready;
}];
@@ -1839,13 +1839,13 @@
-(void) testLimitWithMixOfNullAndNonNullPriorities {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
NSMutableArray* children = [[NSMutableArray alloc] init];
[[ref queryLimitedToLast:5] observeEventType:FIRDataEventTypeChildAdded withBlock:^(FIRDataSnapshot *snapshot) {
[children addObject:[snapshot key]];
}];
-
+
__block BOOL ready = NO;
NSDictionary* toSet = @{
@"Vikrum": @{@".priority": @1000, @"score": @1000, @"name": @"Vikrum"},
@@ -1855,23 +1855,23 @@
@"Sally": @{@".priority": @-7, @"score": @-7, @"name": @"Sally"},
@"Fred": @{@"score": @0, @"name": @"Fred"}
};
-
+
[ref setValue:toSet withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
NSArray* expected = @[@"Sally", @"James", @"Andrew", @"Mike", @"Vikrum"];
XCTAssertTrue([children isEqualToArray:expected], @"Null priority should be left out");
-
+
}
-(void) testLimitWithMixOfNullAndNonNullPrioritiesOnServerData {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
__block BOOL ready = NO;
NSDictionary* toSet = @{
@"Vikrum": @{@".priority": @1000, @"score": @1000, @"name": @"Vikrum"},
@@ -1881,15 +1881,15 @@
@"Sally": @{@".priority": @-7, @"score": @-7, @"name": @"Sally"},
@"Fred": @{@"score": @0, @"name": @"Fred"}
};
-
+
[ref setValue:toSet withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
__block int count = 0;
NSMutableArray* children = [[NSMutableArray alloc] init];
@@ -1897,15 +1897,15 @@
[children addObject:[snapshot key]];
count++;
}];
-
+
[self waitUntil:^BOOL{
return count == 5;
}];
-
-
+
+
NSArray* expected = @[@"Sally", @"James", @"Andrew", @"Mike", @"Vikrum"];
XCTAssertTrue([children isEqualToArray:expected], @"Null priority should be left out");
-
+
}
// Skipping context tests. Context is not implemented on iOS
@@ -1915,9 +1915,9 @@
just the modified children? Not sure.
- (void) testHandleUpdateThatDeletesEntireWindow {
Firebase* ref = [FTestHelpers getRandomNode];
-
+
NSMutableArray* snaps = [[NSMutableArray alloc] init];
-
+
[[ref queryLimitedToLast:2] observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
id val = [snapshot value];
if (val == nil) {
@@ -1926,25 +1926,25 @@
[snaps addObject:val];
}
}];
-
+
NSDictionary* toSet = @{
@"a": @{@".priority": @1, @".value": @1},
@"b": @{@".priority": @2, @".value": @2},
@"c": @{@".priority": @3, @".value": @3}
};
-
+
[ref setValue:toSet];
-
+
__block BOOL ready = NO;
toSet = @{@"b": [NSNull null], @"c": [NSNull null]};
[ref updateChildValues:toSet withCompletionBlock:^(NSError* err, Firebase* ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
NSArray* expected = @[@{@"b": @2, @"c": @3}, [NSNull null], @{@"a": @1}];
STAssertTrue([snaps isEqualToArray:expected], @"Expected %@ to equal %@", snaps, expected);
}
@@ -1952,41 +1952,41 @@
- (void) testHandlesAnOutOfViewQueryOnAChild {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
__block NSDictionary* parent = nil;
[[ref queryLimitedToLast:1] observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
parent = [snapshot value];
}];
-
+
__block NSNumber* child = nil;
[[ref child:@"a"] observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
child = [snapshot value];
}];
-
+
__block BOOL ready = NO;
NSDictionary* toSet = @{@"a": @1, @"b": @2};
[ref setValue:toSet withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
NSDictionary* parentExpected = @{@"b": @2};
NSNumber* childExpected = [NSNumber numberWithInt:1];
XCTAssertTrue([parent isEqualToDictionary:parentExpected], @"Expected last element");
XCTAssertTrue([child isEqualToNumber:childExpected], @"Expected value of a");
-
+
ready = NO;
[ref updateChildValues:@{@"c": @3} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
parentExpected = @{@"c": @3};
XCTAssertTrue([parent isEqualToDictionary:parentExpected], @"Expected last element");
XCTAssertTrue([child isEqualToNumber:childExpected], @"Expected value of a");
@@ -1994,50 +1994,50 @@
- (void) testHandlesAChildQueryGoingOutOfViewOfTheParent {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
__block NSDictionary* parent = nil;
[[ref queryLimitedToLast:1] observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
parent = [snapshot value];
}];
-
+
__block NSNumber* child = nil;
[[ref child:@"a"] observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
child = [snapshot value];
}];
-
+
__block BOOL ready = NO;
NSDictionary* toSet = @{@"a": @1};
[ref setValue:toSet withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
WAIT_FOR(ready);
-
+
NSDictionary* parentExpected = @{@"a": @1};
NSNumber* childExpected = [NSNumber numberWithInt:1];
XCTAssertTrue([parent isEqualToDictionary:parentExpected], @"Expected last element");
XCTAssertTrue([child isEqualToNumber:childExpected], @"Expected value of a");
-
+
ready = NO;
[[ref child:@"b"] setValue:@2 withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
WAIT_FOR(ready);
-
+
parentExpected = @{@"b": @2};
XCTAssertTrue([parent isEqualToDictionary:parentExpected], @"Expected last element");
XCTAssertTrue([child isEqualToNumber:childExpected], @"Expected value of a");
-
+
ready = NO;
[[ref child:@"b"] removeValueWithCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
parentExpected = @{@"a": @1};
XCTAssertTrue([parent isEqualToDictionary:parentExpected], @"Expected last element");
XCTAssertTrue([child isEqualToNumber:childExpected], @"Expected value of a");
@@ -2045,7 +2045,7 @@
- (void) testHandlesDivergingViews {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
__block NSDictionary* cVal = nil;
FIRDatabaseQuery * query = [[[ref queryOrderedByPriority] queryEndingAtValue:nil childKey:@"c"] queryLimitedToLast:1];
[query observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
@@ -2063,24 +2063,24 @@
[ref setValue:toSet withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
NSDictionary* expected = @{@"c": @3};
XCTAssertTrue([cVal isEqualToDictionary:expected], @"should be c");
XCTAssertTrue([dVal isEqualToDictionary:expected], @"should be c");
-
+
ready = NO;
[[ref child:@"d"] setValue:@4 withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
XCTAssertTrue([cVal isEqualToDictionary:expected], @"should be c");
expected = @{@"d": @4};
XCTAssertTrue([dVal isEqualToDictionary:expected], @"should be d");
@@ -2088,7 +2088,7 @@
- (void) testHandlesRemovingAQueriedElement {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
__block NSNumber* val = nil;
[[ref queryLimitedToLast:1] observeEventType:FIRDataEventTypeChildAdded withBlock:^(FIRDataSnapshot *snapshot) {
id newVal = [snapshot value];
@@ -2096,27 +2096,27 @@
val = [snapshot value];
}
}];
-
+
__block BOOL ready = NO;
[ref setValue:@{@"a": @1, @"b": @2} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
XCTAssertTrue([val isEqualToNumber:@2], @"Expected last element in window");
-
+
ready = NO;
[[ref child:@"b"] removeValueWithCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
XCTAssertTrue([val isEqualToNumber:@1], @"Should now be the next element in the window");
}
@@ -2131,16 +2131,16 @@
val = [snapshot value];
}
}];
-
+
__block BOOL ready = NO;
[ref setValue:@{@"a": @1, @"b": @2} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
XCTAssertTrue([val isEqualToNumber:@1], @"Expected first element in window");
}
@@ -2156,50 +2156,50 @@
val = [snapshot value];
}
}];
-
+
__block BOOL ready = NO;
[ref setValue:@{@"a": @1, @"b": @2} withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
XCTAssertTrue([val isEqualToNumber:@1], @"Expected first element in window");
-
+
ready = NO;
[[ref child:@"a"] removeValueWithCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
XCTAssertTrue([val isEqualToNumber:@2], @"Expected next element in window");
}
// See case 1169
- (void) testStartAtWithTwoArgumentsWorks {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
__block BOOL ready = NO;
NSMutableArray* children = [[NSMutableArray alloc] init];
-
+
NSDictionary* toSet = @{
@"Walker": @{@"name": @"Walker", @"score": @20, @".priority": @20},
@"Michael": @{@"name": @"Michael", @"score": @100, @".priority": @100}
};
-
+
[ref setValue:toSet withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
ready = NO;
FIRDatabaseQuery * query = [[[ref queryOrderedByPriority] queryStartingAtValue:@20 childKey:@"Walker"] queryLimitedToFirst:2];
[query observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
@@ -2209,32 +2209,32 @@
}
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
NSArray* expected = @[@"Walker", @"Michael"];
XCTAssertTrue([children isEqualToArray:expected], @"Expected both children");
}
- (void) testHandlesMultipleQueriesOnSameNode {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
__block BOOL ready = NO;
-
+
NSDictionary* toSet = @{
@"a": @1, @"b": @2, @"c": @3, @"d": @4, @"e": @5, @"f": @6
};
-
+
[ref setValue:toSet withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
ready = NO;
__block BOOL called = NO;
[[ref queryLimitedToLast:2] observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
@@ -2243,11 +2243,11 @@
called = YES;
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
ready = NO;
__block NSDictionary* snap = nil;
// now do nested once calls
@@ -2258,95 +2258,95 @@
ready = YES;
}];
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
NSDictionary* expected = @{@"f": @6};
XCTAssertTrue([snap isEqualToDictionary:expected], @"Expected the correct data");
}
- (void) testHandlesOnceCalledOnNodeWithDefaultListener {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
__block BOOL ready = NO;
-
+
NSDictionary* toSet = @{
@"a": @1, @"b": @2, @"c": @3, @"d": @4, @"e": @5, @"f": @6
};
-
+
[ref setValue:toSet withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
ready = NO;
[ref observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
// we got the initial data
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
ready = NO;
-
+
__block NSNumber* snap = nil;
[[ref queryLimitedToLast:1] observeSingleEventOfType:FIRDataEventTypeChildAdded withBlock:^(FIRDataSnapshot *snapshot) {
snap = [snapshot value];
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
XCTAssertTrue([snap isEqualToNumber:@6], @"Got once response");
}
- (void) testHandlesOnceCalledOnNodeWithDefaultListenerAndNonCompleteLimit {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
__block BOOL ready = NO;
-
+
NSDictionary* toSet = @{@"a": @1, @"b": @2, @"c": @3};
-
+
[ref setValue:toSet withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
ready = NO;
// do first listen
[ref observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
ready = NO;
-
+
__block NSDictionary* snap = nil;
[[ref queryLimitedToLast:5] observeSingleEventOfType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
snap = [snapshot value];
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
NSDictionary* expected = @{@"a": @1, @"b": @2, @"c": @3};
XCTAssertTrue([snap isEqualToDictionary:expected], @"Got once response");
}
@@ -2355,19 +2355,19 @@
FTupleFirebase* tuple = [FTestHelpers getRandomNodePair];
FIRDatabaseReference * writer = tuple.one;
FIRDatabaseReference * reader = tuple.two;
-
+
__block BOOL ready = NO;
-
+
NSDictionary* toSet = @{@"a": @"a", @"b": @"b", @"c": @"c", @"d": @"d", @"e": @"e"};
-
+
[writer setValue:toSet withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
ready = YES;
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
-
+
ready = NO;
__block int count = 0;
@@ -2386,7 +2386,7 @@
ready = YES;
}
}];
-
+
[self waitUntil:^BOOL{
return ready;
}];
@@ -2394,7 +2394,7 @@
- (void) testEndingAtNameReturnsCorrectChildren {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
NSDictionary* toSet = @{
@"a": @"a",
@"b": @"b",
@@ -2633,9 +2633,9 @@
- (void) testItemsPulledIntoLimitCorrectly {
FIRDatabaseReference *ref = [FTestHelpers getRandomNode];
-
+
NSMutableArray* snaps = [[NSMutableArray alloc] init];
-
+
// Just so everything is cached locally.
[ref observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
@@ -2645,20 +2645,20 @@
id val = [snapshot value];
[snaps addObject:val];
}];
-
+
[ref setValue:@{
@"a": @{@".value": @1, @".priority": @1},
@"b": @{@".value": @2, @".priority": @2},
@"c": @{@".value": @3, @".priority": @3}
}];
-
+
__block BOOL ready = NO;
[[ref child:@"b"] setValue:[NSNull null] withCompletionBlock:^(NSError *error, FIRDatabaseReference *ref) {
ready = YES;
}];
WAIT_FOR(ready);
-
+
NSArray* expected = @[@{@"b": @2, @"c": @3}, @{@"a": @1, @"c": @3}];
XCTAssertEqualObjects(snaps, expected, @"Incorrect snapshots.");
}
@@ -2753,23 +2753,23 @@
// one-time listener. Event removal code path wasn't removing the listener because it stopped as soon as it
// found the default view. This left the zombie one-time listener and check failed on the second attempt to
// create a listener for the same path (asana#61028598952586).
-
+
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
__block BOOL done = NO;
-
+
[[ref child:@"child"] setValue:@{@"name": @"John"}];
[[[ref queryOrderedByChild:@"name"] queryEqualToValue:@"John"] observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
done = YES;
}];
WAIT_FOR(done);
-
+
done = NO;
[[[ref child:@"child"] child:@"favoriteToy"] observeSingleEventOfType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
done = YES;
}];
WAIT_FOR(done);
-
+
done = NO;
[[[ref child:@"child"] child:@"favoriteToy"] observeSingleEventOfType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *snapshot) {
done = YES;
diff --git a/Example/Database/Tests/Integration/FIRDatabaseTests.m b/Example/Database/Tests/Integration/FIRDatabaseTests.m
index 8a5742d..d0d0909 100644
--- a/Example/Database/Tests/Integration/FIRDatabaseTests.m
+++ b/Example/Database/Tests/Integration/FIRDatabaseTests.m
@@ -168,7 +168,7 @@ static const NSInteger kFErrorCodeWriteCanceled = 3;
[self waitForEvents:ref];
XCTAssertEqual(engine.userWrites.count, (NSUInteger)0);
XCTAssertEqualObjects(order, (@[@"1", @"2", @"3", @"4"]));
-
+
[database goOnline];
}
diff --git a/Example/Database/Tests/Integration/FOrder.m b/Example/Database/Tests/Integration/FOrder.m
index e8c628b..0935f9a 100644
--- a/Example/Database/Tests/Integration/FOrder.m
+++ b/Example/Database/Tests/Integration/FOrder.m
@@ -29,7 +29,7 @@
for(int i = 0; i < 10; i++) {
[[node childByAutoId] setValue:[NSNumber numberWithInt:i]];
}
-
+
[super snapWaiter:node withBlock:^(FIRDataSnapshot * snapshot) {
int expected = 0;
for (FIRDataSnapshot * child in snapshot.children) {
@@ -44,15 +44,15 @@
- (void) testPushEnumerateManyPathsWriteAndCheckOrder {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
NSMutableArray* paths = [[NSMutableArray alloc] init];
-
+
for(int i = 0; i < 20; i++) {
[paths addObject:[node childByAutoId]];
}
-
+
for(int i = 0; i < 20; i++) {
[(FIRDatabaseReference *)[paths objectAtIndex:i] setValue:[NSNumber numberWithInt:i]];
}
-
+
[super snapWaiter:node withBlock:^(FIRDataSnapshot *snap) {
int expected = 0;
for (FIRDataSnapshot * child in snap.children) {
@@ -65,22 +65,22 @@
}
- (void) testPushDataReconnectReadBackAndVerifyOrder {
-
+
FTupleFirebase* tuple = [FTestHelpers getRandomNodePair];
-
+
__block int expected = 0;
__block int nodesSet = 0;
FIRDatabaseReference * node = tuple.one;
for(int i = 0; i < 10; i++) {
[[node childByAutoId] setValue:[NSNumber numberWithInt:i] withCompletionBlock:^(NSError* err, FIRDatabaseReference * ref) {
nodesSet++;
- }];
+ }];
}
-
+
[self waitUntil:^BOOL{
return nodesSet == 10;
}];
-
+
__block BOOL done = NO;
[super snapWaiter:node withBlock:^(FIRDataSnapshot *snap) {
expected = 0;
@@ -92,15 +92,15 @@
}
done = YES;
}];
-
+
[self waitUntil:^BOOL{
return done;
}];
-
+
done = NO;
-
+
XCTAssertTrue(nodesSet == 10, @"All of the nodes have been set");
-
+
[super snapWaiter:tuple.two withBlock:^(FIRDataSnapshot *snap) {
expected = 0;
for (FIRDataSnapshot * child in snap.children) {
@@ -115,7 +115,7 @@
- (void) testPushDataWithPrioritiesReconnectReadBackAndVerifyOrder {
FTupleFirebase* tuple = [FTestHelpers getRandomNodePair];
-
+
__block int expected = 0;
__block int nodesSet = 0;
FIRDatabaseReference * node = tuple.one;
@@ -124,17 +124,17 @@
nodesSet = nodesSet + 1;
}];
}
-
+
[super snapWaiter:node withBlock:^(FIRDataSnapshot *snap) {
expected = 9;
-
+
for (FIRDataSnapshot * child in snap.children) {
XCTAssertEqualObjects([child value], [NSNumber numberWithInt:expected], @"Expected child value as per priority");
expected = expected - 1;
}
XCTAssertTrue(expected == -1, @"Saw the expected number of children");
}];
-
+
[self waitUntil:^BOOL{
return nodesSet == 10;
}];
@@ -153,7 +153,7 @@
- (void) testPushDataWithExponentialPrioritiesReconnectReadBackAndVerifyOrder {
FTupleFirebase* tuple = [FTestHelpers getRandomNodePair];
-
+
__block int expected = 0;
__block int nodesSet = 0;
FIRDatabaseReference * node = tuple.one;
@@ -162,19 +162,19 @@
nodesSet = nodesSet + 1;
}];
}
-
+
[super snapWaiter:node withBlock:^(FIRDataSnapshot *snap) {
expected = 9;
-
+
for (FIRDataSnapshot * child in snap.children) {
XCTAssertEqualObjects([child value], [NSNumber numberWithInt:expected], @"Expected child value as per priority");
expected = expected - 1;
}
XCTAssertTrue(expected == -1, @"Saw the expected number of children");
}];
-
+
WAIT_FOR(nodesSet == 10);
-
+
[super snapWaiter:tuple.two withBlock:^(FIRDataSnapshot *snap) {
expected = 9;
for (FIRDataSnapshot * child in snap.children) {
@@ -189,15 +189,15 @@
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
[node child:@"foo"];
[[node child:@"bar"] setValue:@"test"];
-
+
__block int items = 0;
[super snapWaiter:node withBlock:^(FIRDataSnapshot *snap) {
-
+
for (FIRDataSnapshot * child in snap.children) {
items = items + 1;
XCTAssertEqualObjects([child key], @"bar", @"Saw the child which had a value set and not the empty one");
}
-
+
XCTAssertTrue(items == 1, @"Saw only the one that was actually set.");
}];
}
@@ -235,7 +235,7 @@
- (void) testCanResetPriorityToNull {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
-
+
[[node child:@"a"] setValue:@"a" andPriority:@1];
[[node child:@"b"] setValue:@"b" andPriority:@2];
@@ -275,15 +275,15 @@
- (void) testInsertingANodeUnderALeafPreservesItsPriority {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
-
+
__block FIRDataSnapshot * snap;
[node observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *s) {
snap = s;
}];
-
+
[node setValue:@"a" andPriority:@10];
[[node child:@"deeper"] setValue:@"deeper"];
-
+
[self waitUntil:^BOOL{
id result = [snap value];
NSDictionary* expected = @{@"deeper": @"deeper"};
@@ -317,16 +317,16 @@
@"alpha40", @"zed",
@"num40", @500
];
-
+
__block int setsCompleted = 0;
-
+
for (int i = 0; i < [nodeAndPriorities count]; i++) {
FIRDatabaseReference * n = [tuple.one child:[nodeAndPriorities objectAtIndex:i++]];
[n setValue:@1 andPriority:[nodeAndPriorities objectAtIndex:i] withCompletionBlock:^(NSError* error, FIRDatabaseReference * ref) {
setsCompleted = setsCompleted + 1;
}];
}
-
+
NSString* expected = @"noPriorityA, noPriorityB, noPriorityC, num10, num20, num30, num40, num41, num42, num50, num60, num70, num80, alpha10, alpha20, alpha30, alpha40, alpha41, alpha42, ";
[super snapWaiter:tuple.one withBlock:^(FIRDataSnapshot *snap) {
@@ -337,22 +337,22 @@
XCTAssertTrue([expected isEqualToString:output], @"Proper order");
}];
-
+
WAIT_FOR(setsCompleted == [nodeAndPriorities count] / 2);
-
+
[super snapWaiter:tuple.two withBlock:^(FIRDataSnapshot *snap) {
NSMutableString* output = [[NSMutableString alloc] init];
for (FIRDataSnapshot * n in snap.children) {
[output appendFormat:@"%@, ", [n key]];
}
-
+
XCTAssertTrue([expected isEqualToString:output], @"Proper order");
}];
}
- (void) testVerifyOrderOfIntegerNames {
FIRDatabaseReference * ref = [FTestHelpers getRandomNode];
-
+
NSArray* keys = @[
@"foo",
@"bar",
@@ -365,31 +365,31 @@
@"003",
@"9"
];
-
+
__block int setsCompleted = 0;
-
+
for (int i = 0; i < [keys count]; i++) {
FIRDatabaseReference * n = [ref child:[keys objectAtIndex:i]];
[n setValue:@1 withCompletionBlock:^(NSError* error, FIRDatabaseReference * ref) {
setsCompleted = setsCompleted + 1;
}];
}
-
+
NSString* expected = @"0, 3, 03, 003, 5, 9, 20, 100, bar, foo, ";
-
+
[super snapWaiter:ref withBlock:^(FIRDataSnapshot *snap) {
NSMutableString* output = [[NSMutableString alloc] init];
for (FIRDataSnapshot * n in snap.children) {
[output appendFormat:@"%@, ", [n key]];
}
-
+
XCTAssertTrue([expected isEqualToString:output], @"Proper order");
}];
}
- (void) testPrevNameIsCorrectOnChildAddedEvent {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
-
+
[node setValue:@{@"a": @1, @"b": @2, @"c": @3}];
@@ -406,15 +406,15 @@
}];
XCTAssertTrue([added isEqualToString:@"a (null), b a, c b, "], @"Proper order and prevname");
-
+
}
- (void) testPrevNameIsCorrectWhenAddingNewNodes {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
-
+
[node setValue:@{@"b": @2, @"c": @3, @"d": @4}];
-
+
NSMutableString* added = [[NSMutableString alloc] init];
__block int count = 0;
@@ -426,9 +426,9 @@
[self waitUntil:^BOOL{
return count == 3;
}];
-
+
XCTAssertTrue([added isEqualToString:@"b (null), c b, d c, "], @"Proper order and prevname");
-
+
[added setString:@""];
[[node child:@"a"] setValue:@1];
[self waitUntil:^BOOL{
@@ -608,36 +608,36 @@
- (void) testCanSetAValueWithPriZero {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
-
+
__block FIRDataSnapshot * snap = nil;
[node observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *s) {
snap = s;
}];
-
+
[node setValue:@"test" andPriority:@0];
-
+
[self waitUntil:^BOOL{
return snap != nil;
}];
-
+
XCTAssertEqualObjects([snap value], @"test", @"Proper value");
XCTAssertEqualObjects([snap priority], @0, @"Proper value");
}
- (void) testCanSetObjectWithPriZero {
FIRDatabaseReference * node = [FTestHelpers getRandomNode];
-
+
__block FIRDataSnapshot * snap = nil;
[node observeEventType:FIRDataEventTypeValue withBlock:^(FIRDataSnapshot *s) {
snap = s;
}];
-
+
[node setValue:@{@"x": @"test", @"y": @7} andPriority:@0];
-
+
[self waitUntil:^BOOL{
return snap != nil;
}];
-
+
XCTAssertEqualObjects([[snap value] objectForKey:@"x"], @"test", @"Proper value");
XCTAssertEqualObjects([[snap value] objectForKey:@"y"], @7, @"Proper value");
XCTAssertEqualObjects([snap priority], @0, @"Proper value");
diff --git a/Example/Database/Tests/Integration/FOrderByTests.m b/Example/Database/Tests/Integration/FOrderByTests.m
index aea6b47..0017e53 100644
--- a/Example/Database/Tests/Integration/FOrderByTests.m
+++ b/Example/Database/Tests/Integration/FOrderByTests.m
@@ -24,7 +24,7 @@
- (void) testCanDefineAndUseAnIndex {
__block FIRDatabaseReference *ref = [FTestHelpers getRandomNode];
-
+
NSArray *users = @[
@{@"name": @"Andrew", @"nuggets": @35},
@{@"name": @"Rob", @"nuggets": @40},
@@ -539,8 +539,8 @@
FTupleFirebase *refs = [FTestHelpers getRandomNodePair];
FIRDatabaseReference *writer = refs.one;
FIRDatabaseReference *reader = refs.two;
-
-
+
+
NSDictionary *initial = @{@"a": @{@"data": @"foo",
@"idx": @YES},
@"b": @{@"data": @"bar",
@@ -548,7 +548,7 @@
@"c": @{@"data": @"baz",
@"idx": @NO}};
[self waitForCompletionOf:writer setValue:initial];
-
+
FIRDatabaseQuery *query = [[reader queryOrderedByChild:@"idx"] queryEqualToValue:@YES];
NSDictionary* expected = @{@"a": @{@"data": @"foo",
@@ -557,12 +557,12 @@
@"idx": @YES}};
[self waitForExportValueOf:query toBe:expected];
-
+
NSDictionary *update = @{@"a/idx": @NO,
@"b/data": @"blah",
@"c/idx": @YES};
[self waitForCompletionOf:writer updateChildValues:update];
-
+
expected = @{@"b": @{@"data": @"blah",
@"idx": @YES},
@"c": @{@"data": @"baz",
diff --git a/Example/Database/Tests/Integration/FPersist.m b/Example/Database/Tests/Integration/FPersist.m
index 2326e08..9f8bf56 100644
--- a/Example/Database/Tests/Integration/FPersist.m
+++ b/Example/Database/Tests/Integration/FPersist.m
@@ -307,30 +307,30 @@
- (void)testDeltaSyncWorksWithUnfilteredQuery {
FIRDatabaseReference *writerRef = [FTestHelpers getRandomNode];
FDevice *device = [[FDevice alloc] initOnlineWithUrl:[writerRef description] ];
-
+
// List must be large enough to trigger delta sync.
NSMutableDictionary *longList = [[NSMutableDictionary alloc] init];
for(NSInteger i = 0; i < 50; i++) {
NSString *key = [[writerRef childByAutoId] key];
longList[key] = @{ @"order": @1, @"text": @"This is an awesome message!" };
}
-
+
[writerRef setValue:longList];
-
+
[device do:^(FIRDatabaseReference *ref) {
// Cache this location.
[self waitForValueOf:[ref queryOrderedByChild:@"order"] toBe:longList];
XCTAssertEqual(ref.repo.dataUpdateCount, 1L, @"Should have gotten one update.");
}];
[device restartOffline];
-
+
// Add a new child while the device is offline.
FIRDatabaseReference *newChildRef = [writerRef childByAutoId];
NSDictionary *newChild = @{ @"order": @50, @"text": @"This is a new appended child!" };
-
+
[self waitForCompletionOf:newChildRef setValue:newChild];
longList[[newChildRef key]] = newChild;
-
+
[device goOnline];
[device do:^(FIRDatabaseReference *ref) {
// Wait for updated value with new child.
diff --git a/Example/Database/Tests/Integration/FRealtime.m b/Example/Database/Tests/Integration/FRealtime.m
index e554bfe..5c7d186 100644
--- a/Example/Database/Tests/Integration/FRealtime.m
+++ b/Example/Database/Tests/Integration/FRealtime.m
@@ -57,7 +57,7 @@
FRepoInfo* repoInfo2 = [[FRepoInfo alloc] initWithHost:host2 isSecure:YES withNamespace:host2];
XCTAssertTrue([repoInfo2.host isEqualToString:host2], @"Got correct host");
XCTAssertTrue([repoInfo2.internalHost isEqualToString:host2], @"Got correct host");
-
+
repoInfo2.internalHost = internalHost2;
XCTAssertTrue([repoInfo2.internalHost isEqualToString:internalHost2], @"Got correct host");
diff --git a/Example/Database/Tests/Integration/FTransactionTest.m b/Example/Database/Tests/Integration/FTransactionTest.m
index b78615b..abaea94 100644
--- a/Example/Database/Tests/Integration/FTransactionTest.m
+++ b/Example/Database/Tests/Integration/FTransactionTest.m
@@ -955,7 +955,7 @@
FTupleFirebase* refs = [FTestHelpers getRandomNodePair];
FIRDatabaseReference * ref1 = refs.one;
FIRDatabaseReference * ref2 = refs.two;
-
+
__block BOOL done = NO;
[[ref1 child:@"y"] setValue:@"test" withCompletionBlock:^(NSError *error, FIRDatabaseReference * ref) {
[ref2 runTransactionBlock:^FIRTransactionResult *(FIRMutableData *currentData) {
@@ -973,7 +973,7 @@
}
}];
}];
-
+
[self waitUntil:^BOOL{
return done;
}];
@@ -993,7 +993,7 @@
done = YES;
}];
}];
-
+
[self waitUntil:^BOOL{
return done;
}];
@@ -1092,7 +1092,7 @@
FIRDatabaseReference * writer = refs.one;
FIRDatabaseReference * reader = refs.two;
__block int done = 0;
-
+
NSMutableArray* readSnaps = [[NSMutableArray alloc] init];
NSMutableArray* writeSnaps = [[NSMutableArray alloc] init];
@@ -1113,20 +1113,20 @@
}
}
}];
-
+
[writer runTransactionBlock:^FIRTransactionResult *(FIRMutableData *currentData) {
[currentData setValue:[FIRServerValue timestamp]];
[currentData setPriority:[FIRServerValue timestamp]];
return [FIRTransactionResult successWithValue:currentData];
} andCompletionBlock:^(NSError *error, BOOL committed, FIRDataSnapshot *snapshot) {}];
-
+
[self waitUntil:^BOOL{
return done == 2;
}];
-
+
XCTAssertEqual((unsigned long)[readSnaps count], (unsigned long)1, @"Should have received one snapshot on reader");
XCTAssertEqual((unsigned long)[writeSnaps count], (unsigned long)2, @"Should have received two snapshots on writer");
-
+
FIRDataSnapshot * firstReadSnap = [readSnaps objectAtIndex:0];
FIRDataSnapshot * firstWriteSnap = [writeSnaps objectAtIndex:0];
FIRDataSnapshot * secondWriteSnap = [writeSnaps objectAtIndex:1];
@@ -1151,7 +1151,7 @@
[[ref queryLimitedToFirst:1] observeEventType:FIRDataEventTypeChildAdded andPreviousSiblingKeyWithBlock:^(FIRDataSnapshot *snapshot, NSString *prevName) {
} withCancelBlock:^(NSError *error) {
}];
-
+
[[ref child:@"a"] runTransactionBlock:^FIRTransactionResult *(FIRMutableData *currentData) {
return [FIRTransactionResult successWithValue:currentData];
} andCompletionBlock:^(NSError *error, BOOL committed, FIRDataSnapshot *snapshot) {
@@ -1161,7 +1161,7 @@
done = YES;
}];
}];
-
+
WAIT_FOR(done);
}
@@ -1206,7 +1206,7 @@
XCTAssertEqualObjects([snapshot value], @"it was null!", @"Transaction value should match remote null set");
done = YES;
}];
-
+
WAIT_FOR(done);
}
@@ -1249,7 +1249,7 @@
XCTAssertEqualObjects([snapshot value], @"it was null!", @"Transaction value should match remote null set");
done = YES;
}];
-
+
WAIT_FOR(done);
}
diff --git a/Example/Database/Tests/Unit/FIRDataSnapshotTests.m b/Example/Database/Tests/Unit/FIRDataSnapshotTests.m
index 2a442df..df950e2 100644
--- a/Example/Database/Tests/Unit/FIRDataSnapshotTests.m
+++ b/Example/Database/Tests/Unit/FIRDataSnapshotTests.m
@@ -34,14 +34,14 @@
- (void)setUp
{
[super setUp];
-
+
// Set-up code here.
}
- (void)tearDown
{
// Tear-down code here.
-
+
[super tearDown];
}
@@ -62,13 +62,13 @@
XCTAssertEqualObjects(x.val, @5, @"Values are the same");
XCTAssertEqualObjects(x.getPriority, [FSnapshotUtilities nodeFrom:@42], @"Priority is the same");
XCTAssertTrue([x isLeafNode], @"Node is a leaf");
-
+
x = [[FLeafNode alloc] initWithValue:@"test"];
XCTAssertEqualObjects(x.value, @"test", @"Check if leaf node is holding onto a string value");
-
+
x = [[FLeafNode alloc] initWithValue:[NSNumber numberWithBool:YES]];
XCTAssertTrue([x.value boolValue], @"Check if leaf node is holding onto a YES boolean");
-
+
x = [[FLeafNode alloc] initWithValue:[NSNumber numberWithBool:NO]];
XCTAssertFalse([x.value boolValue], @"Check if leaf node is holding onto a NO boolean");
}
@@ -76,11 +76,11 @@
- (void) testUpdatingPriorityWithoutChangingOld {
FLeafNode* x = [[FLeafNode alloc] initWithValue:@"test" withPriority:[FSnapshotUtilities nodeFrom:[NSNumber numberWithInt:42]]];
FLeafNode* y = [x updatePriority:[FSnapshotUtilities nodeFrom:[NSNumber numberWithInt:187]]];
-
+
// old node is the same
XCTAssertEqualObjects(x.value, @"test", @"Values of old node are the same");
XCTAssertEqualObjects(x.getPriority, [FSnapshotUtilities nodeFrom:[NSNumber numberWithInt:42]], @"Priority of old node is the same.");
-
+
// new node has the new priority but the old value
XCTAssertEqualObjects(y.value, @"test", @"Values of old node are the same");
XCTAssertEqualObjects(y.getPriority, [FSnapshotUtilities nodeFrom:[NSNumber numberWithInt:187]], @"Priority of new node is update");
@@ -89,10 +89,10 @@
- (void) testUpdateImmediateChildReturnsANewChildrenNode {
FLeafNode* x = [[FLeafNode alloc] initWithValue:@"test" withPriority:[FSnapshotUtilities nodeFrom:[NSNumber numberWithInt:42]]];
FChildrenNode* y = [x updateImmediateChild:@"test" withNewChild:[[FLeafNode alloc] initWithValue:@"foo"]];
-
+
XCTAssertFalse([y isLeafNode], @"New node is no longer a leaf");
XCTAssertEqualObjects(y.getPriority, [FSnapshotUtilities nodeFrom:[NSNumber numberWithInt:42]], @"Priority of new node is update");
-
+
XCTAssertEqualObjects([[y getImmediateChild:@"test"] val], @"foo", @"Child node has the correct value");
}
@@ -130,7 +130,7 @@
FChildrenNode* x = [[FChildrenNode alloc] initWithChildren:children];
FLeafNode* newValue = [[FLeafNode alloc] initWithValue:@"new value"];
FChildrenNode* y = [x updateImmediateChild:@"test" withNewChild:newValue];
-
+
XCTAssertEqualObjects(x.children, children, @"Original object stays the same");
XCTAssertEqualObjects([y.children objectForKey:@"test"], newValue, @"New internal node with the proper new value");
XCTAssertEqualObjects([[y.children objectForKey:@"test"] val], @"new value", @"Check the payload");
@@ -149,10 +149,10 @@
- (void) testObjectTypes {
XCTAssertEqualObjects(@"string", [FUtilities getJavascriptType:@""], @"Check string type");
XCTAssertEqualObjects(@"string", [FUtilities getJavascriptType:@"moo"], @"Check string type");
-
+
XCTAssertEqualObjects(@"boolean", [FUtilities getJavascriptType:@YES], @"Check boolean type");
XCTAssertEqualObjects(@"boolean", [FUtilities getJavascriptType:@NO], @"Check boolean type");
-
+
XCTAssertEqualObjects(@"number", [FUtilities getJavascriptType:@5], @"Check number type");
XCTAssertEqualObjects(@"number", [FUtilities getJavascriptType:@5.5], @"Check number type");
XCTAssertEqualObjects(@"number", [FUtilities getJavascriptType:@0], @"Check number type");
@@ -161,12 +161,12 @@
XCTAssertEqualObjects(@"number", [FUtilities getJavascriptType:@-2.11], @"Check number type");
}
-- (void) testNodeHashWorksCorrectly {
+- (void) testNodeHashWorksCorrectly {
id<FNode> node = [FSnapshotUtilities nodeFrom:@{ @"intNode" : @4,
@"doubleNode" : @4.5623,
@"stringNode" : @"hey guys",
@"boolNode" : @YES }];
-
+
XCTAssertEqualObjects(@"eVih19a6ZDz3NL32uVBtg9KSgQY=", [[node getImmediateChild:@"intNode"] dataHash], @"Check integer node");
XCTAssertEqualObjects(@"vf1CL0tIRwXXunHcG/irRECk3lY=", [[node getImmediateChild:@"doubleNode"] dataHash], @"Check double node");
XCTAssertEqualObjects(@"CUNLXWpCVoJE6z7z1vE57lGaKAU=", [[node getImmediateChild:@"stringNode"] dataHash], @"Check string node");
@@ -178,13 +178,13 @@
id<FNode> node = [FSnapshotUtilities nodeFrom:@{
@"root": @{ @"c": @{@".value": @99, @".priority": @"abc"}, @".priority" : @"def" }
}];
-
+
XCTAssertEqualObjects(@"Fm6tzN4CVEu5WxFDZUdTtqbTVaA=", [node dataHash], @"Check compound node");
}
- (void) testGetPredecessorChild {
id<FNode> node = [FSnapshotUtilities nodeFrom:@{@"d": @YES, @"a": @YES, @"g": @YES, @"c": @YES, @"e": @YES}];
-
+
XCTAssertNil([node predecessorChildKey:@"a"],
@"Check the first one sorted properly");
XCTAssertEqualObjects([node predecessorChildKey:@"c"],
@@ -206,13 +206,13 @@
}
- (void) testDataSnapshotHasChildrenWorks {
-
+
FIRDataSnapshot * snap = [self snapshotFor:@{}];
XCTAssertFalse([snap hasChildren], @"Empty dict has no children");
-
+
snap = [self snapshotFor:@5];
XCTAssertFalse([snap hasChildren], @"Leaf node has no children");
-
+
snap = [self snapshotFor:@{@"x": @5}];
XCTAssertTrue([snap hasChildren], @"Properly has children");
}
@@ -220,10 +220,10 @@
- (void) testDataSnapshotValWorks {
FIRDataSnapshot * snap = [self snapshotFor:@5];
XCTAssertEqualObjects([snap value], @5, @"Leaf node values are correct");
-
+
snap = [self snapshotFor:@{}];
XCTAssertTrue([snap value] == [NSNull null], @"Snapshot value is properly null");
-
+
NSDictionary* dict = @{
@"x": @5,
@"y": @{
@@ -232,18 +232,18 @@
@"yc": @{ @"yca" : @3}
}
};
-
+
snap = [self snapshotFor:dict];
XCTAssertTrue([dict isEqualToDictionary:[snap value]], @"Check if the dictionaries are the same");
}
- (void) testDataSnapshotChildWorks {
FIRDataSnapshot * snap = [self snapshotFor:@{@"x": @5, @"y": @{@"yy": @3, @"yz": @4}}];
-
+
XCTAssertEqualObjects([[snap childSnapshotForPath:@"x"] value], @5, @"Check x");
NSDictionary* dict = @{@"yy": @3, @"yz": @4};
XCTAssertTrue([[[snap childSnapshotForPath:@"y"] value] isEqualToDictionary:dict], @"Check y");
-
+
XCTAssertEqualObjects([[[snap childSnapshotForPath:@"y"] childSnapshotForPath:@"yy"] value], @3, @"Check y/yy");
XCTAssertEqualObjects([[snap childSnapshotForPath:@"y/yz"] value], @4, @"Check y/yz");
XCTAssertTrue([[snap childSnapshotForPath:@"z"] value] == [NSNull null], @"Check nonexistent z");
@@ -256,7 +256,7 @@
XCTAssertTrue([snap hasChild:@"x"], @"Has child");
XCTAssertTrue([snap hasChild:@"y/yy"], @"Has child");
-
+
XCTAssertFalse([snap hasChild:@"dinosaur dinosaucer"], @"No child");
XCTAssertFalse([[snap childSnapshotForPath:@"x"] hasChild:@"anything"], @"No child");
XCTAssertFalse([snap hasChild:@"x/anything/at/all"], @"No child");
@@ -264,25 +264,25 @@
- (void) testDataSnapshotNameWorks {
FIRDataSnapshot * snap = [self snapshotFor:@{@"a": @{@"b": @{@"c": @5}}}];
-
+
XCTAssertEqualObjects([[snap childSnapshotForPath:@"a"] key], @"a", @"Check child key");
XCTAssertEqualObjects([[snap childSnapshotForPath:@"a/b/c"] key], @"c", @"Check child key");
XCTAssertEqualObjects([[snap childSnapshotForPath:@"/a/b/c"] key], @"c", @"Check child key");
XCTAssertEqualObjects([[snap childSnapshotForPath:@"/a/b/c/"] key], @"c", @"Check child key");
- XCTAssertEqualObjects([[snap childSnapshotForPath:@"////a///b////c///"] key], @"c", @"Check child key");
+ XCTAssertEqualObjects([[snap childSnapshotForPath:@"////a///b////c///"] key], @"c", @"Check child key");
XCTAssertEqualObjects([[snap childSnapshotForPath:@"////"] key], [snap key], @"Check root key");
-
+
XCTAssertEqualObjects([[snap childSnapshotForPath:@"/z/q/r/v////m"] key], @"m", @"Should also work for nonexistent paths");
}
- (void) testDataSnapshotForEachWithNoPriorities {
FIRDataSnapshot * snap = [self snapshotFor:@{@"a": @1, @"z": @26, @"m": @13, @"n": @14, @"c": @3, @"b": @2, @"e": @5}];
-
+
NSMutableString* out = [[NSMutableString alloc] init];
for (FIRDataSnapshot * child in snap.children) {
[out appendFormat:@"%@:%@:", [child key], [child value] ];
}
-
+
XCTAssertTrue([out isEqualToString:@"a:1:b:2:c:3:e:5:m:13:n:14:z:26:"], @"Proper order");
}
@@ -296,12 +296,12 @@
@"b": @{@".value" : @2, @".priority": @25},
@"e": @{@".value" : @5, @".priority": @22},
}];
-
+
NSMutableString* out = [[NSMutableString alloc] init];
for (FIRDataSnapshot * child in snap.children) {
[out appendFormat:@"%@:%@:", [child key], [child value] ];
}
-
+
XCTAssertTrue([out isEqualToString:@"z:26:n:14:m:13:e:5:c:3:b:2:a:1:"], @"Proper order");
}
@@ -315,12 +315,12 @@
@"b": @{@".value" : @2, @".priority": @"25"},
@"e": @{@".value" : @5, @".priority": @"22"},
}];
-
+
NSMutableString* out = [[NSMutableString alloc] init];
for (FIRDataSnapshot * child in snap.children) {
[out appendFormat:@"%@:%@:", [child key], [child value] ];
}
-
+
XCTAssertTrue([out isEqualToString:@"z:26:n:14:m:13:e:5:c:3:b:2:a:1:"], @"Proper order");
}
@@ -334,14 +334,14 @@
@"b": @{@".value" : @2, @".priority": @"sixth"},
@"e": @{@".value" : @5, @".priority": @"seventh"},
}];
-
+
NSMutableString* output = [[NSMutableString alloc] init];
NSMutableArray* priorities = [[NSMutableArray alloc] init];
for (FIRDataSnapshot * child in snap.children) {
[output appendFormat:@"%@:%@:", child.key, child.value];
[priorities addObject:child.priority];
}
-
+
XCTAssertTrue([output isEqualToString:@"c:3:a:1:n:14:z:26:e:5:b:2:m:13:"], @"Proper order");
NSArray* expected = @[@"fifth", @"first", @"fourth", @"second", @"seventh", @"sixth", @"third"];
XCTAssertTrue([priorities isEqualToArray:expected], @"Correct priorities");
@@ -371,14 +371,14 @@
@"alpha40": @{@".value": @1, @".priority": @"zed" },
@"num40": @{@".value": @1, @".priority": @500 }
}];
-
+
NSMutableString* out = [[NSMutableString alloc] init];
for (FIRDataSnapshot * child in snap.children) {
[out appendFormat:@"%@, ", [child key]];
}
-
+
NSString* expected = @"noPriorityA, noPriorityB, noPriorityC, num20, num40, num42, num60, num70, num80, alpha10, alpha11, alpha12, alpha13, alpha14, alpha20, alpha30, alpha40, alpha41, alpha42, ";
-
+
XCTAssertTrue([expected isEqualToString:out], @"Proper ordering seen");
}
diff --git a/Example/Database/Tests/Unit/FLevelDBStorageEngineTests.m b/Example/Database/Tests/Unit/FLevelDBStorageEngineTests.m
index f26a913..560104a 100644
--- a/Example/Database/Tests/Unit/FLevelDBStorageEngineTests.m
+++ b/Example/Database/Tests/Unit/FLevelDBStorageEngineTests.m
@@ -495,7 +495,7 @@
id intValue = @247;
id longValue = @1542405709418655810;
id doubleValue = @0xFFFFFFFFFFFFFFFFUL; // This number can't be represented as a signed long.
-
+
id<FNode> expectedData = NODE((@{@"int": @247, @"long": longValue, @"double": doubleValue}));
FLevelDBStorageEngine *engine = [self cleanStorageEngine];
[engine updateServerCache:expectedData atPath:PATH(@"foo") merge:NO];
@@ -503,7 +503,7 @@
NSNumber* actualInt = [actualData val][@"int"];
NSNumber* actualLong = [actualData val][@"long"];
NSNumber* actualDouble = [actualData val][@"double"];
-
+
XCTAssertEqualObjects([actualInt stringValue], [intValue stringValue]);
XCTAssertEqual(CFNumberGetType((CFNumberRef)actualInt), kCFNumberSInt64Type);
XCTAssertEqualObjects([actualLong stringValue ], [longValue stringValue]);
diff --git a/Example/Database/Tests/Unit/FPathTests.m b/Example/Database/Tests/Unit/FPathTests.m
index 9b26a85..c70e3ab 100644
--- a/Example/Database/Tests/Unit/FPathTests.m
+++ b/Example/Database/Tests/Unit/FPathTests.m
@@ -25,7 +25,7 @@
XCTAssertTrue([[[FPath alloc] initWith:@"/a"] contains:[[FPath alloc] initWith:@"/a/b/c"]], @"contains should be correct");
XCTAssertTrue([[[FPath alloc] initWith:@"/a/b"] contains:[[FPath alloc] initWith:@"/a/b/c"]], @"contains should be correct");
XCTAssertTrue([[[FPath alloc] initWith:@"/a/b/c"] contains:[[FPath alloc] initWith:@"/a/b/c"]], @"contains should be correct");
-
+
XCTAssertFalse([[[FPath alloc] initWith:@"/a/b/c"] contains:[[FPath alloc] initWith:@"/a/b"]], @"contains should be correct");
XCTAssertFalse([[[FPath alloc] initWith:@"/a/b/c"] contains:[[FPath alloc] initWith:@"/a"]], @"contains should be correct");
XCTAssertFalse([[[FPath alloc] initWith:@"/a/b/c"] contains:[[FPath alloc] initWith:@"/"]], @"contains should be correct");
@@ -34,7 +34,7 @@
XCTAssertTrue([[[FPath alloc] initWithPieces:pathPieces andPieceNum:1] contains:[[FPath alloc] initWith:@"/b/c"]], @"contains should be correct");
XCTAssertTrue([[[FPath alloc] initWithPieces:pathPieces andPieceNum:1] contains:[[FPath alloc] initWith:@"/b/c/d"]], @"contains should be correct");
-
+
XCTAssertFalse([[[FPath alloc] initWith:@"/a/b/c"] contains:[[FPath alloc] initWith:@"/b/c"]], @"contains should be correct");
XCTAssertFalse([[[FPath alloc] initWith:@"/a/b/c"] contains:[[FPath alloc] initWith:@"/a/c/b"]], @"contains should be correct");
diff --git a/Example/Database/Tests/Unit/FTreeSortedDictionaryTests.m b/Example/Database/Tests/Unit/FTreeSortedDictionaryTests.m
index 6aee84d..396be06 100644
--- a/Example/Database/Tests/Unit/FTreeSortedDictionaryTests.m
+++ b/Example/Database/Tests/Unit/FTreeSortedDictionaryTests.m
@@ -75,7 +75,7 @@
FTreeSortedDictionary* map = [[[[FTreeSortedDictionary alloc] initWithComparator:[self defaultComparator]]
insertKey:@1 withValue:@1]
insertKey:@2 withValue:@2];
-
+
XCTAssertEqualObjects([map get:@1], @1, @"Found first object");
XCTAssertEqualObjects([map get:@2], @2, @"Found second object");
XCTAssertNil([map get:@3], @"Properly not found object");
@@ -85,7 +85,7 @@
FTreeSortedDictionary* map = [[[[FTreeSortedDictionary alloc] initWithComparator:[self defaultComparator]]
insertKey:@1 withValue:@1]
insertKey:@2 withValue:@2];
-
+
XCTAssertEqualObjects(map.root.key, @2, @"Check the root key");
XCTAssertEqualObjects(map.root.left.key, @1, @"Check the root.left key");
}
@@ -94,11 +94,11 @@
FTreeSortedDictionary* map = [[[[FTreeSortedDictionary alloc] initWithComparator:[self defaultComparator]]
insertKey:@1 withValue:@1]
insertKey:@2 withValue:@2];
-
+
FImmutableSortedDictionary* newMap = [map removeKey:@1];
XCTAssertEqualObjects([newMap get:@2], @2, @"Found second object");
XCTAssertNil([newMap get:@1], @"Properly not found object");
-
+
// Make sure the original one is not mutated
XCTAssertEqualObjects([map get:@1], @1, @"Found first object");
XCTAssertEqualObjects([map get:@2], @2, @"Found second object");
@@ -121,21 +121,21 @@
XCTAssertNotNil([map get:@7], @"Found object");
XCTAssertNotNil([map get:@3], @"Found object");
XCTAssertNotNil([map get:@1], @"Found object");
-
-
+
+
FImmutableSortedDictionary* m1 = [map removeKey:@7];
FImmutableSortedDictionary* m2 = [map removeKey:@3];
FImmutableSortedDictionary* m3 = [map removeKey:@1];
-
+
XCTAssertNil([m1 get:@7], @"Removed object");
XCTAssertNotNil([m1 get:@3], @"Found object");
XCTAssertNotNil([m1 get:@1], @"Found object");
-
+
XCTAssertNil([m2 get:@3], @"Removed object");
XCTAssertNotNil([m2 get:@7], @"Found object");
XCTAssertNotNil([m2 get:@1], @"Found object");
-
-
+
+
XCTAssertNil([m3 get:@1], @"Removed object");
XCTAssertNotNil([m3 get:@7], @"Found object");
XCTAssertNotNil([m3 get:@3], @"Found object");
@@ -146,11 +146,11 @@
insertKey:@1 withValue:@1]
insertKey:@2 withValue:@2]
insertKey:@3 withValue:@3];
-
+
XCTAssertEqualObjects([map get:@1], @1, @"Found object");
XCTAssertEqualObjects([map get:@2], @2, @"Found object");
XCTAssertEqualObjects([map get:@3], @3, @"Found object");
-
+
FImmutableSortedDictionary* m1 = [map removeKey:@2];
XCTAssertEqualObjects([m1 get:@1], @1, @"Found object");
XCTAssertEqualObjects([m1 get:@3], @3, @"Found object");
@@ -159,23 +159,23 @@
- (void) testIncreasing {
int total = 100;
-
+
FTreeSortedDictionary* map = [[FTreeSortedDictionary alloc] initWithComparator:[self defaultComparator]];
-
+
for(int i = 0; i < total; i++) {
NSNumber* item = [NSNumber numberWithInt:i];
map = [map insertKey:item withValue:item];
}
-
+
XCTAssertTrue([map count] == 100, @"Check if all 100 objects are in the map");
XCTAssertTrue([map.root isMemberOfClass:[FLLRBValueNode class]], @"Root is a value node");
XCTAssertTrue([(FLLRBValueNode *)map.root checkMaxDepth], @"Checking valid depth and tree structure");
-
+
for(int i = 0; i < total; i++) {
NSNumber* item = [NSNumber numberWithInt:i];
map = [map removeKey:item];
}
-
+
XCTAssertTrue([map count] == 0, @"Check if all 100 objects were removed");
// We can't check the depth here because the map no longer contains values, so we check that it doesn't responsd to this check
XCTAssertTrue([map.root isMemberOfClass:[FLLRBEmptyNode class]], @"Root is an empty node");
@@ -187,8 +187,8 @@
insertKey:@1 withValue:@1]
insertKey:@2 withValue:@2]
insertKey:@3 withValue:@3];
-
-
+
+
XCTAssertEqualObjects(map.root.key, @2, @"Check root key");
XCTAssertEqualObjects(map.root.left.key, @1, @"Check the left key is correct");
XCTAssertEqualObjects(map.root.right.key, @3, @"Check the right key is correct");
@@ -208,7 +208,7 @@
insertKey:@71 withValue:@71]
insertKey:@42 withValue:@42]
insertKey:@88 withValue:@88];
-
+
XCTAssertTrue([map count] == 12, @"Check if all 12 objects are in the map");
XCTAssertTrue([map.root isMemberOfClass:[FLLRBValueNode class]], @"Root is a value node");
XCTAssertTrue([(FLLRBValueNode *)map.root checkMaxDepth], @"Checking valid depth and tree structure");
@@ -217,18 +217,18 @@
- (void) testRotateLeftLeavesTreeInAValidState {
FLLRBValueNode* node = [[FLLRBValueNode alloc] initWithKey:@4 withValue:@4 withColor:BLACK withLeft:
[[FLLRBValueNode alloc] initWithKey:@2 withValue:@2 withColor:BLACK withLeft:nil withRight:nil] withRight:[[FLLRBValueNode alloc]initWithKey:@7 withValue:@7 withColor:RED withLeft:[[FLLRBValueNode alloc ]initWithKey:@5 withValue:@5 withColor:BLACK withLeft:nil withRight:nil] withRight:[[FLLRBValueNode alloc] initWithKey:@8 withValue:@8 withColor:BLACK withLeft:nil withRight:nil]]];
-
+
FLLRBValueNode* node2 = [node performSelector:@selector(rotateLeft)];
-
+
XCTAssertTrue([node2 count] == 5, @"Make sure the count is correct");
XCTAssertTrue([node2 checkMaxDepth], @"Check proper structure");
}
- (void) testRotateRightLeavesTreeInAValidState {
FLLRBValueNode* node = [[FLLRBValueNode alloc] initWithKey:@7 withValue:@7 withColor:BLACK withLeft:[[FLLRBValueNode alloc] initWithKey:@4 withValue:@4 withColor:RED withLeft:[[FLLRBValueNode alloc] initWithKey:@2 withValue:@2 withColor:BLACK withLeft:nil withRight:nil] withRight:[[FLLRBValueNode alloc] initWithKey:@5 withValue:@5 withColor:BLACK withLeft:nil withRight:nil]] withRight:[[FLLRBValueNode alloc] initWithKey:@8 withValue:@8 withColor:BLACK withLeft:nil withRight:nil]];
-
+
FLLRBValueNode* node2 = [node performSelector:@selector(rotateRight)];
-
+
XCTAssertTrue([node2 count] == 5, @"Make sure the count is correct");
XCTAssertEqualObjects(node2.key, @4, @"Check roots key");
XCTAssertEqualObjects(node2.left.key, @2, @"Check first left child key");
@@ -245,18 +245,18 @@
insertKey:@4 withValue:@4]
insertKey:@7 withValue:@7]
insertKey:@9 withValue:@9];
-
+
XCTAssertTrue([map count] == 6, @"Check if all 6 objects are in the map");
XCTAssertTrue([map.root isMemberOfClass:[FLLRBValueNode class]], @"Root is a value node");
XCTAssertTrue([(FLLRBValueNode *)map.root checkMaxDepth], @"Checking valid depth and tree structure");
-
+
FTreeSortedDictionary* m2 = [[[map insertKey:@20 withValue:@20]
insertKey:@18 withValue:@18]
insertKey:@2 withValue:@2];
XCTAssertTrue([m2 count] == 9, @"Check if all 9 objects are in the map");
XCTAssertTrue([m2.root isMemberOfClass:[FLLRBValueNode class]], @"Root is a value node");
XCTAssertTrue([(FLLRBValueNode *)m2.root checkMaxDepth], @"Checking valid depth and tree structure");
-
+
FTreeSortedDictionary* m3 = [[[[m2 insertKey:@71 withValue:@71]
insertKey:@42 withValue:@42]
insertKey:@88 withValue:@88]
@@ -270,16 +270,16 @@
FTreeSortedDictionary* map = [[[[FTreeSortedDictionary alloc] initWithComparator:[self defaultComparator]]
insertKey:@10 withValue:@10]
insertKey:@10 withValue:@8];
-
+
XCTAssertEqualObjects([map get:@10], @8, @"Found first object");
}
- (void) testEmpty {
FTreeSortedDictionary* map = [[[[FTreeSortedDictionary alloc] initWithComparator:[self defaultComparator]]
insertKey:@10 withValue:@10]
removeKey:@10];
-
+
XCTAssertTrue([map isEmpty], @"Properly empty");
-
+
}
- (void) testEmptyGet {
@@ -304,7 +304,7 @@
insertKey:@3 withValue:@3]
insertKey:@2 withValue:@2]
insertKey:@4 withValue:@4];
-
+
__block int next = 5;
[map enumerateKeysAndObjectsReverse:YES usingBlock:^(id key, id value, BOOL *stop) {
XCTAssertEqualObjects(key, [NSNumber numberWithInt:next], @"Properly equal");
@@ -317,18 +317,18 @@
int N = 100;
NSMutableArray* toInsert = [[NSMutableArray alloc] initWithCapacity:N];
NSMutableArray* toRemove = [[NSMutableArray alloc] initWithCapacity:N];
-
+
for(int i = 0; i < N; i++) {
[toInsert addObject:[NSNumber numberWithInt:i]];
[toRemove addObject:[NSNumber numberWithInt:i]];
}
-
-
+
+
[self shuffleArray:toInsert];
[self shuffleArray:toRemove];
-
+
FTreeSortedDictionary* map = [[FTreeSortedDictionary alloc] initWithComparator:[self defaultComparator]];
-
+
// add them to the dictionary
for(int i = 0; i < N; i++) {
map = [map insertKey:[toInsert objectAtIndex:i] withValue:[toInsert objectAtIndex:i]];
@@ -336,7 +336,7 @@
XCTAssertTrue([(FLLRBValueNode *)map.root checkMaxDepth], @"Checking valid depth and tree structure");
}
XCTAssertTrue([map count] == N, @"Check if all N objects are in the map");
-
+
// check the order is correct
__block int next = 0;
[map enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL *stop) {
@@ -345,9 +345,9 @@
next = next + 1;
}];
XCTAssertEqual(next, N, @"Check we traversed all of the items");
-
+
// remove them
-
+
for(int i = 0; i < N; i++) {
if([map.root isMemberOfClass:[FLLRBValueNode class]]) {
XCTAssertTrue([map.root isMemberOfClass:[FLLRBValueNode class]], @"Root is a value node");
@@ -355,8 +355,8 @@
}
map = [map removeKey:[toRemove objectAtIndex:i]];
}
-
-
+
+
XCTAssertEqual([map count], 0, @"Check we removed all of the items");
}
@@ -370,11 +370,11 @@
}
- (void) testBalanceProblem {
-
+
NSArray* toInsert = [[NSArray alloc] initWithObjects:@1,@7,@8,@5,@2,@6,@4,@0,@3, nil];
-
+
FTreeSortedDictionary* map = [[FTreeSortedDictionary alloc] initWithComparator:[self defaultComparator]];
-
+
// add them to the dictionary
for(int i = 0; i < [toInsert count]; i++) {
map = [map insertKey:[toInsert objectAtIndex:i] withValue:[toInsert objectAtIndex:i]];
@@ -382,7 +382,7 @@
XCTAssertTrue([(FLLRBValueNode *)map.root checkMaxDepth], @"Checking valid depth and tree structure");
}
XCTAssertTrue([map count] == [toInsert count], @"Check if all N objects are in the map");
-
+
// check the order is correct
__block int next = 0;
[map enumerateKeysAndObjectsUsingBlock:^(id key, id value, BOOL *stop) {
@@ -391,11 +391,11 @@
next = next + 1;
}];
XCTAssertEqual(next, [[NSNumber numberWithUnsignedInteger:[toInsert count]] intValue], @"Check we traversed all of the items");
-
+
// removing one triggers the balance problem
-
+
map = [map removeKey:@5];
-
+
if([map.root isMemberOfClass:[FLLRBValueNode class]]) {
XCTAssertTrue([map.root isMemberOfClass:[FLLRBValueNode class]], @"Root is a value node");
XCTAssertTrue([(FLLRBValueNode *)map.root checkMaxDepth], @"Checking valid depth and tree structure");
@@ -410,7 +410,7 @@
insertKey:@4 withValue:@4]
insertKey:@7 withValue:@7]
insertKey:@9 withValue:@9];
-
+
XCTAssertNil([map getPredecessorKey:@1], @"First object doesn't have a predecessor");
XCTAssertEqualObjects([map getPredecessorKey:@3], @1, @"@1");
XCTAssertEqualObjects([map getPredecessorKey:@4], @3, @"@3");
@@ -424,18 +424,18 @@
int N = 100;
NSMutableArray* toInsert = [[NSMutableArray alloc] initWithCapacity:N];
NSMutableArray* toRemove = [[NSMutableArray alloc] initWithCapacity:N];
-
+
for(int i = 0; i < N; i++) {
[toInsert addObject:[NSNumber numberWithInt:i]];
[toRemove addObject:[NSNumber numberWithInt:i]];
}
-
-
+
+
[self shuffleArray:toInsert];
[self shuffleArray:toRemove];
-
+
FTreeSortedDictionary* map = [[FTreeSortedDictionary alloc] initWithComparator:[self defaultComparator]];
-
+
// add them to the dictionary
for(int i = 0; i < N; i++) {
map = [map insertKey:[toInsert objectAtIndex:i] withValue:[toInsert objectAtIndex:i]];
diff --git a/Example/Database/Tests/third_party/Base64.m b/Example/Database/Tests/third_party/Base64.m
index b3d73db..ef962ff 100644
--- a/Example/Database/Tests/third_party/Base64.m
+++ b/Example/Database/Tests/third_party/Base64.m
@@ -45,20 +45,20 @@
{
const char lookup[] =
{
- 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
- 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 62, 99, 99, 99, 63,
- 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 99, 99, 99, 99, 99, 99,
- 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
- 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 99, 99, 99, 99, 99,
- 99, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99,
+ 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 99, 62, 99, 99, 99, 63,
+ 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 99, 99, 99, 99, 99, 99,
+ 99, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
+ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 99, 99, 99, 99, 99,
+ 99, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 99, 99, 99, 99, 99
};
-
+
NSData *inputData = [string dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];
long long inputLength = [inputData length];
const unsigned char *inputBytes = [inputData bytes];
-
+
long long maxOutputLength = (inputLength / 4 + 1) * 3;
NSMutableData *outputData = [NSMutableData dataWithLength:maxOutputLength];
unsigned char *outputBytes = (unsigned char *)[outputData mutableBytes];
@@ -74,19 +74,19 @@
accumulated[accumulator] = decoded;
if (accumulator == 3)
{
- outputBytes[outputLength++] = (accumulated[0] << 2) | (accumulated[1] >> 4);
- outputBytes[outputLength++] = (accumulated[1] << 4) | (accumulated[2] >> 2);
+ outputBytes[outputLength++] = (accumulated[0] << 2) | (accumulated[1] >> 4);
+ outputBytes[outputLength++] = (accumulated[1] << 4) | (accumulated[2] >> 2);
outputBytes[outputLength++] = (accumulated[2] << 6) | accumulated[3];
}
accumulator = (accumulator + 1) % 4;
}
}
-
+
//handle left-over data
if (accumulator > 0) outputBytes[outputLength] = (accumulated[0] << 2) | (accumulated[1] >> 4);
if (accumulator > 1) outputBytes[++outputLength] = (accumulated[1] << 4) | (accumulated[2] >> 2);
if (accumulator > 2) outputLength++;
-
+
//truncate data to match actual output length
outputData.length = outputLength;
return outputLength? outputData: nil;
@@ -96,16 +96,16 @@
{
//ensure wrapWidth is a multiple of 4
wrapWidth = (wrapWidth / 4) * 4;
-
+
const char lookup[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
+
long long inputLength = [self length];
const unsigned char *inputBytes = [self bytes];
-
+
long long maxOutputLength = (inputLength / 3 + 1) * 4;
maxOutputLength += wrapWidth? (maxOutputLength / wrapWidth) * 2: 0;
unsigned char *outputBytes = (unsigned char *)malloc(maxOutputLength);
-
+
long long i;
long long outputLength = 0;
for (i = 0; i < inputLength - 2; i += 3)
@@ -114,7 +114,7 @@
outputBytes[outputLength++] = lookup[((inputBytes[i] & 0x03) << 4) | ((inputBytes[i + 1] & 0xF0) >> 4)];
outputBytes[outputLength++] = lookup[((inputBytes[i + 1] & 0x0F) << 2) | ((inputBytes[i + 2] & 0xC0) >> 6)];
outputBytes[outputLength++] = lookup[inputBytes[i + 2] & 0x3F];
-
+
//add line break
if (wrapWidth && (outputLength + 2) % (wrapWidth + 2) == 0)
{
@@ -122,7 +122,7 @@
outputBytes[outputLength++] = '\n';
}
}
-
+
//handle left-over data
if (i == inputLength - 2)
{
@@ -140,7 +140,7 @@
outputBytes[outputLength++] = '=';
outputBytes[outputLength++] = '=';
}
-
+
if (outputLength >= 4)
{
//truncate data to match actual output length
diff --git a/Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m b/Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m
index 60a2496..882d45e 100644
--- a/Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m
+++ b/Example/Storage/Tests/Integration/FIRStorageIntegrationTests.m
@@ -30,7 +30,7 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
* - authentication read/write access to /ios/private
*
* A sample configuration may look like:
- *
+ *
* service firebase.storage {
* match /b/{YOUR_PROJECT_ID}.appspot.com/o {
* ...
@@ -63,14 +63,14 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
- (void)setUp {
[super setUp];
-
+
self.app = [FIRApp defaultApp];
self.storage = [FIRStorage storageForApp:self.app];
-
+
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");
@@ -78,7 +78,7 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
XCTAssertNil(error);
[expectation fulfill];
}];
-
+
[self waitForExpectations];
});
}
@@ -86,7 +86,7 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
- (void)tearDown {
self.app = nil;
self.storage = nil;
-
+
[super tearDown];
}
@@ -100,22 +100,22 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedGetMetadata"];
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];
}];
-
+
[self waitForExpectations];
}
- (void)testUnauthenticatedUpdateMetadata {
XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedUpdateMetadata"];
-
+
FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/1mb"];
-
+
FIRStorageMetadata *meta = [[FIRStorageMetadata alloc] init];
[meta setContentType:@"lol/custom"];
[meta setCustomMetadata:@{
@@ -123,7 +123,7 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
@"ちかてつ" : @"🚇",
@"shinkansen" : @"新幹線"
}];
-
+
[ref updateMetadata:meta
completion:^(FIRStorageMetadata *metadata, NSError *error) {
XCTAssertEqualObjects(meta.contentType, metadata.contentType);
@@ -136,17 +136,17 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
XCTAssertNil(error, "Error should be nil");
[expectation fulfill];
}];
-
+
[self waitForExpectations];
}
- (void)testUnauthenticatedDelete {
XCTestExpectation *expectation = [self expectationWithDescription:@"testUnauthenticatedDelete"];
-
+
FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/fileToDelete"];
-
+
NSData *data = [@"Delete me!!!!!!!" dataUsingEncoding:NSUTF8StringEncoding];
-
+
[ref putData:data
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
@@ -157,17 +157,17 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
[expectation fulfill];
}];
}];
-
+
[self waitForExpectations];
}
- (void)testDeleteWithNilCompletion {
XCTestExpectation *expectation = [self expectationWithDescription:@"testDeleteWithNilCompletion"];
-
+
FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/fileToDelete"];
-
+
NSData *data = [@"Delete me!!!!!!!" dataUsingEncoding:NSUTF8StringEncoding];
-
+
[ref putData:data
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
@@ -176,7 +176,7 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
[ref deleteWithCompletion:nil];
[expectation fulfill];
}];
-
+
[self waitForExpectations];
}
@@ -184,9 +184,9 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimplePutData"];
FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/testBytesUpload"];
-
+
NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
-
+
[ref putData:data
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
@@ -194,19 +194,19 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
XCTAssertNil(error, "Error should be nil");
[expectation fulfill];
}];
-
+
[self waitForExpectations];
}
- (void)testUnauthenticatedSimplePutEmptyData {
XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimplePutEmptyData"];
-
+
FIRStorageReference *ref =
[self.storage referenceWithPath:@"ios/public/testUnauthenticatedSimplePutEmptyData"];
-
+
NSData *data = [[NSData alloc] init];
-
+
[ref putData:data
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
@@ -214,7 +214,7 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
XCTAssertNil(error, "Error should be nil");
[expectation fulfill];
}];
-
+
[self waitForExpectations];
}
@@ -222,9 +222,9 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimplePutDataUnauthorized"];
FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/private/secretfile.txt"];
-
+
NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
-
+
[ref putData:data
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
@@ -233,38 +233,38 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
XCTAssertEqual(error.code, FIRStorageErrorCodeUnauthorized);
[expectation fulfill];
}];
-
+
[self waitForExpectations];
}
- (void)testUnauthenticatedSimplePutFile {
XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimplePutFile"];
-
+
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"] ||
@@ -273,23 +273,23 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
XCTAssertGreaterThanOrEqual(progress.completedUnitCount, uploadedBytes);
uploadedBytes = progress.completedUnitCount;
}];
-
+
[self waitForExpectations];
}
- (void)testPutFileWithSpecialCharacters {
XCTestExpectation *expectation =
[self expectationWithDescription:@"testPutFileWithSpecialCharacters"];
-
+
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];
-
+
[ref putFile:fileURL
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
@@ -305,19 +305,19 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
[expectation fulfill];
}];
}];
-
+
[self waitForExpectations];
}
- (void)testUnauthenticatedSimplePutDataNoMetadata {
XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimplePutDataNoMetadata"];
-
+
FIRStorageReference *ref =
[self.storage referenceWithPath:@"ios/public/testUnauthenticatedSimplePutDataNoMetadata"];
-
+
NSData *data = [@"Hello World" dataUsingEncoding:NSUTF8StringEncoding];
-
+
[ref putData:data
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
@@ -325,23 +325,23 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
XCTAssertNil(error, "Error should be nil");
[expectation fulfill];
}];
-
+
[self waitForExpectations];
}
- (void)testUnauthenticatedSimplePutFileNoMetadata {
XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimplePutFileNoMetadata"];
-
+
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];
-
+
[ref putFile:fileURL
metadata:nil
completion:^(FIRStorageMetadata *metadata, NSError *error) {
@@ -349,32 +349,32 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
XCTAssertNil(error, "Error should be nil");
[expectation fulfill];
}];
-
+
[self waitForExpectations];
}
- (void)testUnauthenticatedSimpleGetData {
XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimpleGetData"];
-
+
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];
}];
-
+
[self waitForExpectations];
}
- (void)testUnauthenticatedSimpleGetDataTooSmall {
XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimpleGetDataTooSmall"];
-
+
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) {
@@ -382,25 +382,25 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
XCTAssertEqual(error.code, FIRStorageErrorCodeDownloadSizeExceeded);
[expectation fulfill];
}];
-
+
[self waitForExpectations];
}
- (void)testUnauthenticatedSimpleGetFile {
XCTestExpectation *expectation =
[self expectationWithDescription:@"testUnauthenticatedSimpleGetData"];
-
+
FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/helloworld"];
-
+
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)
{
FIRStorageDownloadTask *task = [ref writeToFile:fileURL];
-
+
[task observeStatus:FIRStorageTaskStatusSuccess
handler:^(FIRStorageTaskSnapshot *snapshot) {
NSString *data = [NSString stringWithContentsOfURL:fileURL
@@ -411,71 +411,71 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
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);
}];
-
+
[task observeStatus:FIRStorageTaskStatusFailure
handler:^(FIRStorageTaskSnapshot *snapshot) {
XCTAssertNil(snapshot.error);
[expectation fulfill];
}];
}];
-
+
[self waitForExpectations];
}
- (void)testCancelDownload {
XCTestExpectation *expectation =
[self expectationWithDescription:@"testCancelDownload"];
-
+
FIRStorageReference *ref = [self.storage referenceWithPath:@"ios/public/1mb"];
-
+
NSURL *tmpDirURL = [NSURL fileURLWithPath:NSTemporaryDirectory()];
NSURL *fileURL =
[[tmpDirURL URLByAppendingPathComponent:@"hello"] URLByAppendingPathExtension:@"dat"];
-
+
FIRStorageDownloadTask *task = [ref writeToFile:fileURL];
-
+
[task observeStatus:FIRStorageTaskStatusFailure
handler:^(FIRStorageTaskSnapshot *snapshot) {
XCTAssertTrue([[snapshot description] containsString:@"State: Failed"]);
[expectation fulfill];
}];
-
+
[task observeStatus:FIRStorageTaskStatusProgress
handler:^(FIRStorageTaskSnapshot *_Nonnull snapshot) {
[task cancel];
}];
-
+
[self waitForExpectations];
}
- (void)testUnauthenticatedResumeGetFile {
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"] ||
@@ -495,14 +495,14 @@ NSTimeInterval kFIRStorageIntegrationTestTimeout = 30;
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);
diff --git a/Firebase/Auth/Source/Public/FIRPhoneAuthProvider.h b/Firebase/Auth/Source/Public/FIRPhoneAuthProvider.h
index 402edb5..138028a 100644
--- a/Firebase/Auth/Source/Public/FIRPhoneAuthProvider.h
+++ b/Firebase/Auth/Source/Public/FIRPhoneAuthProvider.h
@@ -62,7 +62,7 @@ FIR_SWIFT_NAME(PhoneAuthProvider)
@param phoneNumber The phone number to be verified.
@param completion The callback to be invoked when the verification flow is finished.
-
+
@remarks Possible error codes:
<ul>
<li>@c FIRAuthErrorCodeAppNotVerified - Indicates that Firebase could not retrieve the
diff --git a/Firebase/Database/Api/FIRDatabaseQuery.m b/Firebase/Database/Api/FIRDatabaseQuery.m
index bcb1733..eedc735 100644
--- a/Firebase/Database/Api/FIRDatabaseQuery.m
+++ b/Firebase/Database/Api/FIRDatabaseQuery.m
@@ -44,11 +44,11 @@
// We use this shared queue across all of the FQueries so things happen FIFO (as opposed to dispatch_get_global_queue(0, 0) which is concurrent)
static dispatch_once_t pred;
static dispatch_queue_t sharedDispatchQueue;
-
+
dispatch_once(&pred, ^{
sharedDispatchQueue = dispatch_queue_create("FirebaseWorker", NULL);
});
-
+
return sharedDispatchQueue;
}
diff --git a/Firebase/Database/Core/FPersistentConnection.m b/Firebase/Database/Core/FPersistentConnection.m
index dc5877f..826b995 100644
--- a/Firebase/Database/Core/FPersistentConnection.m
+++ b/Firebase/Database/Core/FPersistentConnection.m
@@ -282,7 +282,7 @@ typedef enum {
if (firstConnection) {
[self sendConnectStats];
}
-
+
[self restoreAuth];
firstConnection = NO;
self.lastSessionID = sessionID;
@@ -564,7 +564,7 @@ static void reachabilityCallback(SCNetworkReachabilityRef ref, SCNetworkReachabi
FOutstandingPut* put = self.outstandingPuts[index];
assert(put != nil);
fbt_void_nsstring_nsstring onComplete = put.onCompleteBlock;
-
+
// Do not async this block; copying the block insinde sendAction: doesn't happen in time (or something) so coredumps
put.sent = YES;
[self sendAction:put.action
@@ -611,23 +611,23 @@ static void reachabilityCallback(SCNetworkReachabilityRef ref, SCNetworkReachabi
}
- (void) putInternal:(id)data forAction:(NSString *)action forPath:(NSString *)pathString withHash:(NSString *)hash withCallback:(fbt_void_nsstring_nsstring)onComplete {
-
+
NSMutableDictionary *request = [NSMutableDictionary dictionaryWithObjectsAndKeys:
pathString, kFWPRequestPath,
data, kFWPRequestData, nil];
if(hash) {
[request setObject:hash forKey:kFWPRequestHash];
}
-
+
FOutstandingPut *put = [[FOutstandingPut alloc] init];
put.action = action;
put.request = request;
put.onCompleteBlock = onComplete;
put.sent = NO;
-
+
NSNumber* index = [self.putCounter getAndIncrement];
self.outstandingPuts[index] = put;
-
+
if ([self canSendWrites]) {
FFLog(@"I-RDB034024", @"Was connected, and added as index: %@", index);
[self sendPut:index];
@@ -725,7 +725,7 @@ static void reachabilityCallback(SCNetworkReachabilityRef ref, SCNetworkReachabi
nil];
[self.realtime sendRequest:msg sensitive:sensitive];
-
+
if (onMessage) {
// Debug message without a callback; bump the rn, but don't hold onto the cb
[self.requestCBHash setObject:[onMessage copy] forKey:rn];
diff --git a/Firebase/Database/Core/FRepo.h b/Firebase/Database/Core/FRepo.h
index 69ec6bf..ab0b074 100644
--- a/Firebase/Database/Core/FRepo.h
+++ b/Firebase/Database/Core/FRepo.h
@@ -42,7 +42,7 @@
- (void) addEventRegistration:(id<FEventRegistration>)eventRegistration forQuery:(FQuerySpec *)query;
- (void) removeEventRegistration:(id<FEventRegistration>)eventRegistration forQuery:(FQuerySpec *)query;
- (void) keepQuery:(FQuerySpec *)query synced:(BOOL)synced;
-
+
- (NSString*)name;
- (NSTimeInterval)serverTime;
diff --git a/Firebase/Database/Core/FRepo.m b/Firebase/Database/Core/FRepo.m
index 17e7480..bb176c0 100644
--- a/Firebase/Database/Core/FRepo.m
+++ b/Firebase/Database/Core/FRepo.m
@@ -457,7 +457,7 @@
// For testing.
self.dataUpdateCount++;
-
+
FPath* path = [[FPath alloc] initWith:pathString];
data = self.interceptServerDataCallback ? self.interceptServerDataCallback(pathString, data) : data;
NSArray *events = nil;
@@ -543,7 +543,7 @@
- (void) didEnterBackground {
if (!self.config.persistenceEnabled)
return;
-
+
// Targetted compilation is ONLY for testing. UIKit is weak-linked in actual release build.
#if TARGET_OS_IOS
// The idea is to wait until any outstanding sets get written to disk. Since the sets might still be in our
diff --git a/Firebase/Database/Core/Utilities/FPath.m b/Firebase/Database/Core/Utilities/FPath.m
index 485b903..5215596 100644
--- a/Firebase/Database/Core/Utilities/FPath.m
+++ b/Firebase/Database/Core/Utilities/FPath.m
@@ -175,11 +175,11 @@
for (NSInteger i = self.pieceNum; i < self.pieces.count; i++) {
[newPieces addObject:[self.pieces objectAtIndex:i]];
}
-
+
for (NSInteger i = childPathObj.pieceNum; i < childPathObj.pieces.count; i++) {
[newPieces addObject:[childPathObj.pieces objectAtIndex:i]];
}
-
+
return [[FPath alloc] initWithPieces:newPieces andPieceNum:0];
}
diff --git a/Firebase/Database/Core/Utilities/FTree.m b/Firebase/Database/Core/Utilities/FTree.m
index 8576ffb..8e7a334 100644
--- a/Firebase/Database/Core/Utilities/FTree.m
+++ b/Firebase/Database/Core/Utilities/FTree.m
@@ -107,11 +107,11 @@
if(incSelf && !childFirst) {
action(self);
}
-
+
[self forEachChild:^(FTree* child) {
[child forEachDescendant:action includeSelf:YES childrenFirst:childFirst];
}];
-
+
if(incSelf && childFirst) {
action(self);
}
diff --git a/Firebase/Database/FImmutableSortedDictionary/FImmutableSortedDictionary/FLLRBEmptyNode.m b/Firebase/Database/FImmutableSortedDictionary/FImmutableSortedDictionary/FLLRBEmptyNode.m
index adbc6ca..5528285 100644
--- a/Firebase/Database/FImmutableSortedDictionary/FImmutableSortedDictionary/FLLRBEmptyNode.m
+++ b/Firebase/Database/FImmutableSortedDictionary/FImmutableSortedDictionary/FLLRBEmptyNode.m
@@ -44,7 +44,7 @@
return result;
}
-- (id<FLLRBNode>) remove:(id) key withComparator:(NSComparator)aComparator {
+- (id<FLLRBNode>) remove:(id) key withComparator:(NSComparator)aComparator {
return self;
}
diff --git a/Firebase/Database/FImmutableSortedDictionary/FImmutableSortedDictionary/FLLRBValueNode.m b/Firebase/Database/FImmutableSortedDictionary/FImmutableSortedDictionary/FLLRBValueNode.m
index f361278..fb0dc8d 100644
--- a/Firebase/Database/FImmutableSortedDictionary/FImmutableSortedDictionary/FLLRBValueNode.m
+++ b/Firebase/Database/FImmutableSortedDictionary/FImmutableSortedDictionary/FLLRBValueNode.m
@@ -95,7 +95,7 @@
- (id<FLLRBNode>) insertKey:(__unsafe_unretained id) aKey forValue:(__unsafe_unretained id)aValue withComparator:(NSComparator)aComparator {
NSComparisonResult cmp = aComparator(aKey, self.key);
FLLRBValueNode* n = self;
-
+
if(cmp == NSOrderedAscending) {
n = [n copyWith:nil withValue:nil withColor:nil withLeft:[n.left insertKey:aKey forValue:aValue withComparator:aComparator] withRight:nil];
}
@@ -105,7 +105,7 @@
else {
n = [n copyWith:nil withValue:nil withColor:nil withLeft:nil withRight:[n.right insertKey:aKey forValue:aValue withComparator:aComparator]];
}
-
+
return [n fixUp];
}
@@ -114,12 +114,12 @@
if([self.left isEmpty]) {
return [FLLRBEmptyNode emptyNode];
}
-
+
FLLRBValueNode* n = self;
if(! [n.left isRed] && ! [n.left.left isRed]) {
n = [n moveRedLeft];
}
-
+
n = [n copyWith:nil withValue:nil withColor:nil withLeft:[(FLLRBValueNode*)n.left removeMin] withRight:nil];
return [n fixUp];
}
@@ -165,14 +165,14 @@
- (id<FLLRBNode>) colorFlip {
id<FLLRBNode> nleft = [self.left copyWith:nil withValue:nil withColor:[NSNumber numberWithBool:![self.left.color boolValue]] withLeft:nil withRight:nil];
id<FLLRBNode> nright = [self.right copyWith:nil withValue:nil withColor:[NSNumber numberWithBool:![self.right.color boolValue]] withLeft:nil withRight:nil];
-
+
return [self copyWith:nil withValue:nil withColor:[NSNumber numberWithBool:![self.color boolValue]] withLeft:nleft withRight:nright];
}
- (id<FLLRBNode>) remove:(__unsafe_unretained id) aKey withComparator:(NSComparator)comparator {
id<FLLRBNode> smallest;
FLLRBValueNode* n = self;
-
+
if(comparator(aKey, n.key) == NSOrderedAscending) {
if(![n.left isEmpty] && ![n.left isRed] && ![n.left.left isRed]) {
n = [n moveRedLeft];
@@ -183,11 +183,11 @@
if([n.left isRed]) {
n = [n rotateRight];
}
-
+
if(![n.right isEmpty] && ![n.right isRed] && ![n.right.left isRed]) {
n = [n moveRedRight];
}
-
+
if(comparator(aKey, n.key) == NSOrderedSame) {
if([n.right isEmpty]) {
return [FLLRBEmptyNode emptyNode];
@@ -218,15 +218,15 @@
- (int) check {
int blackDepth = 0;
-
+
if([self isRed] && [self.left isRed]) {
@throw [[NSException alloc] initWithName:@"check" reason:@"Red node has a red child" userInfo:nil];
}
-
+
if([self.right isRed]) {
@throw [[NSException alloc] initWithName:@"check" reason:@"Right child is red" userInfo:nil];
}
-
+
blackDepth = [self.left check];
// NSLog(err);
if(blackDepth != [self.right check]) {
diff --git a/Firebase/Database/FImmutableSortedDictionary/FImmutableSortedDictionary/FTreeSortedDictionaryEnumerator.m b/Firebase/Database/FImmutableSortedDictionary/FImmutableSortedDictionary/FTreeSortedDictionaryEnumerator.m
index 6636d1e..8eb30be 100644
--- a/Firebase/Database/FImmutableSortedDictionary/FImmutableSortedDictionary/FTreeSortedDictionaryEnumerator.m
+++ b/Firebase/Database/FImmutableSortedDictionary/FImmutableSortedDictionary/FTreeSortedDictionaryEnumerator.m
@@ -71,7 +71,7 @@
if([self.stack count] == 0) {
return nil;
}
-
+
id<FLLRBNode> node = nil;
@synchronized(self.stack) {
node = [self.stack lastObject];
diff --git a/Firebase/Database/FViewProcessor.m b/Firebase/Database/FViewProcessor.m
index 41ff91d..8acefb8 100644
--- a/Firebase/Database/FViewProcessor.m
+++ b/Firebase/Database/FViewProcessor.m
@@ -522,7 +522,7 @@
accumulator:accumulator];
}
}];
-
+
return curViewCache;
}
diff --git a/Firebase/Database/Public/FIRDataSnapshot.h b/Firebase/Database/Public/FIRDataSnapshot.h
index e615260..c3082df 100644
--- a/Firebase/Database/Public/FIRDataSnapshot.h
+++ b/Firebase/Database/Public/FIRDataSnapshot.h
@@ -38,7 +38,7 @@ FIR_SWIFT_NAME(DataSnapshot)
/**
* Gets a FIRDataSnapshot for the location at the specified relative path.
- * The relative path can either be a simple child key (e.g. 'fred')
+ * The relative path can either be a simple child key (e.g. 'fred')
* or a deeper slash-separated path (e.g. 'fred/name/first'). If the child
* location has no data, an empty FIRDataSnapshot is returned.
*
@@ -59,7 +59,7 @@ FIR_SWIFT_NAME(DataSnapshot)
/**
* Return YES if the DataSnapshot has any children.
- *
+ *
* @return YES if this snapshot has any children, else NO.
*/
- (BOOL) hasChildren;
@@ -78,7 +78,7 @@ FIR_SWIFT_NAME(DataSnapshot)
/**
* Returns the raw value at this location, coupled with any metadata, such as priority.
*
- * Priorities, where they exist, are accessible under the ".priority" key in instances of NSDictionary.
+ * Priorities, where they exist, are accessible under the ".priority" key in instances of NSDictionary.
* For leaf locations with priorities, the value will be under the ".value" key.
*/
- (id __nullable) valueInExportFormat;
diff --git a/Firebase/Database/Public/FIRDatabase.h b/Firebase/Database/Public/FIRDatabase.h
index ebdbf8a..fd4535f 100644
--- a/Firebase/Database/Public/FIRDatabase.h
+++ b/Firebase/Database/Public/FIRDatabase.h
@@ -29,9 +29,9 @@ NS_ASSUME_NONNULL_BEGIN
*/
FIR_SWIFT_NAME(Database)
@interface FIRDatabase : NSObject
-
+
/**
- * The NSObject initializer that has been marked as unavailable. Use the `database`
+ * The NSObject initializer that has been marked as unavailable. Use the `database`
* method instead
*
* @return An instancetype instance
diff --git a/Firebase/Database/Public/FIRDatabaseReference.h b/Firebase/Database/Public/FIRDatabaseReference.h
index eb3fecd..53d0cdd 100644
--- a/Firebase/Database/Public/FIRDatabaseReference.h
+++ b/Firebase/Database/Public/FIRDatabaseReference.h
@@ -74,8 +74,8 @@ FIR_SWIFT_NAME(DatabaseReference)
/** Write data to this Firebase Database location.
-This will overwrite any data at this location and all child locations.
-
+This will overwrite any data at this location and all child locations.
+
Data types that can be set are:
- NSString -- @"Hello World"
@@ -86,7 +86,7 @@ Data types that can be set are:
The effect of the write will be visible immediately and the corresponding
events will be triggered. Synchronization of the data to the Firebase Database
servers will also be started.
-
+
Passing null for the new value is equivalent to calling remove:;
all data at this location or any child location will be deleted.
@@ -131,7 +131,7 @@ is meant to be preserved, you should use setValue:andPriority: instead.
/**
* Remove the data at this Firebase Database location. Any data at child locations will also be deleted.
- *
+ *
* The effect of the delete will be visible immediately and the corresponding events
* will be triggered. Synchronization of the delete to the Firebase Database servers will
* also be started.
@@ -165,7 +165,7 @@ is meant to be preserved, you should use setValue:andPriority: instead.
* Children with a string as their priority come last. They are sorted lexicographically by priority.
* Whenever two children have the same priority (including no priority), they are sorted by key. Numeric
* keys come first (sorted numerically), followed by the remaining keys (sorted lexicographically).
- *
+ *
* Note that priorities are parsed and ordered as IEEE 754 double-precision floating-point numbers.
* Keys are always stored as strings and are treated as numbers only when they can be parsed as a
* 32-bit integer
@@ -193,7 +193,7 @@ is meant to be preserved, you should use setValue:andPriority: instead.
- (void) updateChildValues:(NSDictionary *)values;
/**
- * The same as update: with a block that is called once the update has been committed to the
+ * The same as update: with a block that is called once the update has been committed to the
* Firebase Database servers
*
* @param values A dictionary of the keys to change and their new values
@@ -553,7 +553,7 @@ is meant to be preserved, you should use setValue:andPriority: instead.
/**
* Cancel any operations that are set to run on disconnect. If you previously called onDisconnectSetValue:,
- * onDisconnectRemoveValue:, or onDisconnectUpdateChildValues:, and no longer want the values updated when the
+ * onDisconnectRemoveValue:, or onDisconnectUpdateChildValues:, and no longer want the values updated when the
* connection is lost, call cancelDisconnectOperations:
*/
- (void) cancelDisconnectOperations;
@@ -575,19 +575,19 @@ is meant to be preserved, you should use setValue:andPriority: instead.
* Manually disconnect the Firebase Database client from the server and disable automatic reconnection.
*
* The Firebase Database client automatically maintains a persistent connection to the Firebase Database server,
- * which will remain active indefinitely and reconnect when disconnected. However, the goOffline( )
- * and goOnline( ) methods may be used to manually control the client connection in cases where
+ * which will remain active indefinitely and reconnect when disconnected. However, the goOffline( )
+ * and goOnline( ) methods may be used to manually control the client connection in cases where
* a persistent connection is undesirable.
- *
+ *
* While offline, the Firebase Database client will no longer receive data updates from the server. However,
* all database operations performed locally will continue to immediately fire events, allowing
- * your application to continue behaving normally. Additionally, each operation performed locally
+ * your application to continue behaving normally. Additionally, each operation performed locally
* will automatically be queued and retried upon reconnection to the Firebase Database server.
- *
+ *
* To reconnect to the Firebase Database server and begin receiving remote events, see goOnline( ).
* Once the connection is reestablished, the Firebase Database client will transmit the appropriate data
* and fire the appropriate events so that your client "catches up" automatically.
- *
+ *
* Note: Invoking this method will impact all Firebase Database connections.
*/
+ (void) goOffline;
@@ -596,16 +596,16 @@ is meant to be preserved, you should use setValue:andPriority: instead.
* Manually reestablish a connection to the Firebase Database server and enable automatic reconnection.
*
* The Firebase Database client automatically maintains a persistent connection to the Firebase Database server,
- * which will remain active indefinitely and reconnect when disconnected. However, the goOffline( )
- * and goOnline( ) methods may be used to manually control the client connection in cases where
+ * which will remain active indefinitely and reconnect when disconnected. However, the goOffline( )
+ * and goOnline( ) methods may be used to manually control the client connection in cases where
* a persistent connection is undesirable.
- *
- * This method should be used after invoking goOffline( ) to disable the active connection.
+ *
+ * This method should be used after invoking goOffline( ) to disable the active connection.
* Once reconnected, the Firebase Database client will automatically transmit the proper data and fire
* the appropriate events so that your client "catches up" automatically.
- *
+ *
* To disconnect from the Firebase Database server, see goOffline( ).
- *
+ *
* Note: Invoking this method will impact all Firebase Database connections.
*/
+ (void) goOnline;
diff --git a/Firebase/Database/Realtime/FConnection.m b/Firebase/Database/Realtime/FConnection.m
index 1550bfc..53f434c 100644
--- a/Firebase/Database/Realtime/FConnection.m
+++ b/Firebase/Database/Realtime/FConnection.m
@@ -67,13 +67,13 @@ typedef enum {
if (state != REALTIME_STATE_DISCONNECTED) {
FFLog(@"I-RDB082002", @"Closing realtime connection.");
state = REALTIME_STATE_DISCONNECTED;
-
+
if (self.conn) {
FFLog(@"I-RDB082003", @"Calling close again.");
[self.conn close];
self.conn = nil;
}
-
+
[self.delegate onDisconnect:self withReason:reason];
}
}
@@ -123,7 +123,7 @@ typedef enum {
} else if (state == REALTIME_STATE_CONNECTED) {
FFLog(@"I-RDB082007", @"Realtime connection lost.");
}
-
+
[self close];
}
@@ -138,7 +138,7 @@ typedef enum {
[self onControl:[message objectForKey:kFWPAsyncServerEnvelopeData]];
}
else {
- FFLog(@"I-RDB082008", @"Unrecognized server packet type: %@", rawMessageType);
+ FFLog(@"I-RDB082008", @"Unrecognized server packet type: %@", rawMessageType);
}
}
else {
@@ -174,7 +174,7 @@ typedef enum {
- (void) onConnectionShutdownWithReason:(NSString *)reason {
FFLog(@"I-RDB082013", @"Connection shutdown command received. Shutting down...");
-
+
[self.delegate onKill:self withReason:reason];
[self close];
}
@@ -184,9 +184,9 @@ typedef enum {
// NSString* version = [handshake objectForKey:kFWPAsyncServerHelloVersion];
NSString* host = [handshake objectForKey:kFWPAsyncServerHelloConnectedHost];
NSString* sessionID = [handshake objectForKey:kFWPAsyncServerHelloSession];
-
+
self.repoInfo.internalHost = host;
-
+
if (state == REALTIME_STATE_CONNECTING) {
[self.conn start];
[self onConnection:self.conn readyAtTime:timestamp sessionID:sessionID];
@@ -196,7 +196,7 @@ typedef enum {
- (void) onConnection:(FWebSocketConnection *)conn readyAtTime:(NSNumber *)timestamp sessionID:(NSString *)sessionID {
FFLog(@"I-RDB082014", @"Realtime connection established");
state = REALTIME_STATE_CONNECTED;
-
+
[self.delegate onReady:self atTime:timestamp sessionID:sessionID];
}
diff --git a/Firebase/Database/Realtime/FWebSocketConnection.m b/Firebase/Database/Realtime/FWebSocketConnection.m
index c4ead9e..5cd8bb0 100644
--- a/Firebase/Database/Realtime/FWebSocketConnection.m
+++ b/Firebase/Database/Realtime/FWebSocketConnection.m
@@ -65,11 +65,11 @@
self.totalFrames = 0;
self.dispatchQueue = queue;
frame = nil;
-
+
NSString* connectionUrl = [repoInfo connectionURLWithLastSessionID:lastSessionID];
NSString* ua = [self userAgent];
FFLog(@"I-RDB083001", @"(wsc:%@) Connecting to: %@ as %@", self.connectionId, connectionUrl, ua);
-
+
NSURLRequest* req = [[NSURLRequest alloc] initWithURL:[[NSURL alloc] initWithString:connectionUrl]];
self.webSocket = [[FSRWebSocket alloc] initWithURLRequest:req queue:queue andUserAgent:ua];
[self.webSocket setDelegateDispatchQueue:queue];
@@ -82,7 +82,7 @@
NSString* systemVersion;
NSString* deviceName;
BOOL hasUiDeviceClass = NO;
-
+
// Targetted compilation is ONLY for testing. UIKit is weak-linked in actual release build.
#if TARGET_OS_IOS
Class uiDeviceClass = NSClassFromString(@"UIDevice");
@@ -92,7 +92,7 @@
hasUiDeviceClass = YES;
}
#endif
-
+
if (!hasUiDeviceClass) {
NSDictionary *systemVersionDictionary = [NSDictionary dictionaryWithContentsOfFile:@"/System/Library/CoreServices/SystemVersion.plist"];
systemVersion = [systemVersionDictionary objectForKey:@"ProductVersion"];
@@ -143,19 +143,19 @@
[self resetKeepAlive];
- NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dictionary
+ NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dictionary
options:kNilOptions error:nil];
-
+
NSString* data = [[NSString alloc] initWithData:jsonData
encoding:NSUTF8StringEncoding];
-
+
NSArray* dataSegs = [FUtilities splitString:data intoMaxSize:kWebsocketMaxFrameSize];
// First send the header so the server knows how many segments are forthcoming
if (dataSegs.count > 1) {
[self.webSocket send:[NSString stringWithFormat:@"%u", (unsigned int)dataSegs.count]];
}
-
+
// Then, actually send the segments.
for(NSString * segment in dataSegs) {
[self.webSocket send:segment];
@@ -165,7 +165,7 @@
- (void) nop:(NSTimer *)timer {
if (!isClosed) {
FFLog(@"I-RDB083004", @"(wsc:%@) nop", self.connectionId);
- [self.webSocket send:@"0"];
+ [self.webSocket send:@"0"];
}
else {
FFLog(@"I-RDB083005", @"(wsc:%@) No more websocket; invalidating nop timer.", self.connectionId);
@@ -202,7 +202,7 @@
error:nil];
frame = nil;
FFLog(@"I-RDB083007", @"(wsc:%@) handleIncomingFrame sending complete frame: %d", self.connectionId, self.totalFrames);
-
+
@autoreleasepool {
[self.delegate onMessage:self withMessage:json];
}
@@ -231,9 +231,9 @@
- (void)webSocketDidOpen:(FSRWebSocket *)webSocket
{
FFLog(@"I-RDB083008", @"(wsc:%@) webSocketDidOpen", self.connectionId);
-
+
everConnected = YES;
-
+
dispatch_async(dispatch_get_main_queue(), ^{
self->keepAlive = [NSTimer scheduledTimerWithTimeInterval:kWebsocketKeepaliveInterval
target:self
@@ -261,8 +261,8 @@
/**
* Note that the close / onClosed / shutdown cycle here is a little different from the javascript client.
- * In order to properly handle deallocation, no close-related action is taken at a higher level until we
- * have received notification from the websocket itself that it is closed. Otherwise, we end up deallocating
+ * In order to properly handle deallocation, no close-related action is taken at a higher level until we
+ * have received notification from the websocket itself that it is closed. Otherwise, we end up deallocating
* this class and the FConnection class before the websocket has a change to call some of its delegate methods.
* So, since close is the external close handler, we just set a flag saying not to call our own delegate method
* and close the websocket. That will trigger a callback into this class that can then do things like clean up
@@ -278,7 +278,7 @@
- (void) shutdown {
isClosed = YES;
-
+
// Call delegate methods
[self.delegate onDisconnect:self wasEverConnected:everConnected];
diff --git a/Firebase/Database/Snapshot/FChildrenNode.m b/Firebase/Database/Snapshot/FChildrenNode.m
index b5598ad..d53ae80 100644
--- a/Firebase/Database/Snapshot/FChildrenNode.m
+++ b/Firebase/Database/Snapshot/FChildrenNode.m
@@ -157,7 +157,7 @@
if([self isEmpty]) {
return [NSNull null];
}
-
+
__block int numKeys = 0;
__block NSInteger maxKey = 0;
__block BOOL allIntegerKeys = YES;
@@ -208,7 +208,7 @@
if(exp && [self getPriority] != nil && !self.getPriority.isEmpty) {
obj[kPayloadPriority] = [self.getPriority val];
}
-
+
return obj;
}
}
diff --git a/Firebase/Database/Snapshot/FSnapshotUtilities.m b/Firebase/Database/Snapshot/FSnapshotUtilities.m
index 1b83430..c6012d3 100644
--- a/Firebase/Database/Snapshot/FSnapshotUtilities.m
+++ b/Firebase/Database/Snapshot/FSnapshotUtilities.m
@@ -52,7 +52,7 @@
+ (id<FNode>) internalNodeFrom:(id)val priority:(id)aPriority withValidationFrom:(NSString *)fn atDepth:(int)depth path:(NSMutableArray *)path {
-
+
if (depth > kFirebaseMaxObjectDepth) {
NSRange range;
range.location = 0;
@@ -179,7 +179,7 @@
[updatePaths addObject:path];
compoundWrite = [compoundWrite addWrite:node atPath:path];
}
-
+
// Check that the update paths are not descendants of each other.
[updatePaths sortUsingComparator:^NSComparisonResult(FPath* left, FPath* right) {
return [left compare:right];
diff --git a/Firebase/Database/Utilities/FAtomicNumber.m b/Firebase/Database/Utilities/FAtomicNumber.m
index be0e537..4a14caa 100644
--- a/Firebase/Database/Utilities/FAtomicNumber.m
+++ b/Firebase/Database/Utilities/FAtomicNumber.m
@@ -42,12 +42,12 @@
NSNumber* result;
// See: http://developer.apple.com/library/ios/#DOCUMENTATION/Cocoa/Conceptual/Multithreading/ThreadSafety/ThreadSafety.html#//apple_ref/doc/uid/10000057i-CH8-SW14 to improve, etc.
-
+
[self.lock lock];
result = [NSNumber numberWithUnsignedLong:number];
number = number + 1;
[self.lock unlock];
-
+
return result;
}
diff --git a/Firebase/Database/Utilities/FNextPushId.m b/Firebase/Database/Utilities/FNextPushId.m
index af54e3d..ee3ba13 100644
--- a/Firebase/Database/Utilities/FNextPushId.m
+++ b/Firebase/Database/Utilities/FNextPushId.m
@@ -26,20 +26,20 @@ static NSString *const PUSH_CHARS = @"-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcd
static int lastRandChars[12];
long long now = (long long)(currentTime * 1000);
-
+
BOOL duplicateTime = now == lastPushTime;
lastPushTime = now;
-
+
unichar timeStampChars[8];
for(int i = 7; i >= 0; i--) {
timeStampChars[i] = [PUSH_CHARS characterAtIndex:(now % 64)];
now = (long long)floor(now / 64);
}
-
+
NSMutableString* id = [[NSMutableString alloc] init];
[id appendString:[NSString stringWithCharacters:timeStampChars length:8]];
-
-
+
+
if(!duplicateTime) {
for(int i = 0; i < 12; i++) {
lastRandChars[i] = (int)floor(arc4random() % 64);
@@ -52,11 +52,11 @@ static NSString *const PUSH_CHARS = @"-0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ_abcd
}
lastRandChars[i]++;
}
-
+
for(int i = 0; i < 12; i++) {
[id appendFormat:@"%C", [PUSH_CHARS characterAtIndex:lastRandChars[i]]];
}
-
+
return [NSString stringWithString:id];
}
diff --git a/Firebase/Database/Utilities/FUtilities.m b/Firebase/Database/Utilities/FUtilities.m
index 7c25e3b..93b892a 100644
--- a/Firebase/Database/Utilities/FUtilities.m
+++ b/Firebase/Database/Utilities/FUtilities.m
@@ -41,7 +41,7 @@ void firebaseJobsTroll(void) {
#pragma mark Private property and singleton specification
@interface FUtilities() {
-
+
}
@property (nonatomic, strong) FAtomicNumber* localUid;
@@ -87,7 +87,7 @@ void firebaseJobsTroll(void) {
if(str.length <= size) {
return [NSArray arrayWithObject:str];
}
-
+
NSMutableArray* dataSegs = [[NSMutableArray alloc] init];
for(int c = 0; c < str.length; c += size) {
if (c + size > str.length) {
@@ -97,7 +97,7 @@ void firebaseJobsTroll(void) {
}
else {
int rangeStart = c;
- int rangeLength = size;
+ int rangeLength = size;
[dataSegs addObject:[str substringWithRange:NSMakeRange(rangeStart, rangeLength)]];
}
}
@@ -168,7 +168,7 @@ void firebaseJobsTroll(void) {
FRepoInfo* repoInfo = [[FRepoInfo alloc] initWithHost:host isSecure:secure withNamespace:namespace];
FFLog(@"I-RDB095002", @"---> Parsed (%@) to: (%@,%@); ns=(%@); path=(%@)", original, [repoInfo description], [repoInfo connectionURL], repoInfo.namespace, [path description]);
-
+
FParsedUrl* parsedUrl = [[FParsedUrl alloc] init];
parsedUrl.repoInfo = repoInfo;
parsedUrl.path = path;
diff --git a/Firebase/Database/Utilities/FValidation.m b/Firebase/Database/Utilities/FValidation.m
index c4c6b2b..f088da2 100644
--- a/Firebase/Database/Utilities/FValidation.m
+++ b/Firebase/Database/Utilities/FValidation.m
@@ -221,7 +221,7 @@ NSString *const kInvalidKeyCharacters = @"[].#$/";
[self validateFrom:fn isValidPriorityValue:value withPath:@[]];
} else {
keyNum++;
-
+
if (![FValidation isValidKey:key]) {
@throw [[NSException alloc] initWithName:@"InvalidFirebaseData" reason:[NSString stringWithFormat:@"(%@) Invalid key in object. Keys must be non-empty and cannot contain '.' '#' '$' '[' or ']'", fn] userInfo:nil];
}
diff --git a/Firebase/Database/third_party/SocketRocket/FSRWebSocket.h b/Firebase/Database/third_party/SocketRocket/FSRWebSocket.h
index dfda376..1ca1815 100644
--- a/Firebase/Database/third_party/SocketRocket/FSRWebSocket.h
+++ b/Firebase/Database/third_party/SocketRocket/FSRWebSocket.h
@@ -22,7 +22,7 @@ typedef enum {
SR_OPEN = 1,
SR_CLOSING = 2,
SR_CLOSED = 3,
-
+
} FSRReadyState;
@class FSRWebSocket;
@@ -74,7 +74,7 @@ extern NSString *const FSRWebSocketErrorDomain;
@protocol FSRWebSocketDelegate <NSObject>
-// message will either be an NSString if the server is using text
+// message will either be an NSString if the server is using text
// or NSData if the server is using binary
- (void)webSocket:(FSRWebSocket *)webSocket didReceiveMessage:(id)message;
diff --git a/Firebase/Database/third_party/SocketRocket/FSRWebSocket.m b/Firebase/Database/third_party/SocketRocket/FSRWebSocket.m
index f96d863..a2c857b 100644
--- a/Firebase/Database/third_party/SocketRocket/FSRWebSocket.m
+++ b/Firebase/Database/third_party/SocketRocket/FSRWebSocket.m
@@ -52,7 +52,7 @@
typedef enum {
SROpCodeTextFrame = 0x1,
SROpCodeBinaryFrame = 0x2,
- //3-7Reserved
+ //3-7Reserved
SROpCodeConnectionClose = 0x8,
SROpCodePing = 0x9,
SROpCodePong = 0xA,
@@ -117,13 +117,13 @@ static inline void SRFastLog(NSString *format, ...);
static NSString *newSHA1String(const char *bytes, size_t length) {
uint8_t md[CC_SHA1_DIGEST_LENGTH];
-
+
CC_SHA1(bytes, (int)length, md);
-
+
size_t buffer_size = ((sizeof(md) * 3 + 2) / 2);
-
+
char *buffer = (char *)malloc(buffer_size);
-
+
int len = f_b64_ntop(md, CC_SHA1_DIGEST_LENGTH, buffer, buffer_size);
if (len == -1) {
free(buffer);
@@ -232,10 +232,10 @@ typedef void (^data_callback)(FSRWebSocket *webSocket, NSData *data);
NSInputStream *_inputStream;
NSOutputStream *_outputStream;
-
+
NSMutableData *_readBuffer;
NSInteger _readBufferOffset;
-
+
NSMutableData *_outputBuffer;
NSInteger _outputBufferOffset;
@@ -244,18 +244,18 @@ typedef void (^data_callback)(FSRWebSocket *webSocket, NSData *data);
size_t _readOpCount;
uint32_t _currentStringScanPosition;
NSMutableData *_currentFrameData;
-
+
NSString *_closeReason;
-
+
NSString *_secKey;
-
+
BOOL _pinnedCertFound;
-
+
uint8_t _currentReadMaskKey[4];
size_t _currentReadMaskOffset;
BOOL _consumerStopped;
-
+
BOOL _closeWhenFinishedWriting;
BOOL _failed;
@@ -264,19 +264,19 @@ typedef void (^data_callback)(FSRWebSocket *webSocket, NSData *data);
NSString *_userAgent;
CFHTTPMessageRef _receivedHTTPHeaders;
-
+
BOOL _sentClose;
BOOL _didFail;
BOOL _cleanupScheduled;
int _closeCode;
-
+
BOOL _isPumping;
NSMutableSet *_scheduledRunloops;
-
+
// We use this to retain ourselves.
__strong FSRWebSocket *_selfRetain;
-
+
NSArray *_requestedProtocols;
FSRIOConsumerPool *_consumerPool;
}
@@ -300,26 +300,26 @@ static __strong NSData *CRLFCRLF;
assert(request.URL);
_url = request.URL;
NSString *scheme = [_url scheme];
-
+
_requestedProtocols = [protocols copy];
_userAgent = userAgent;
assert([scheme isEqualToString:@"ws"] || [scheme isEqualToString:@"http"] || [scheme isEqualToString:@"wss"] || [scheme isEqualToString:@"https"]);
_urlRequest = request;
-
+
if ([scheme isEqualToString:@"wss"] || [scheme isEqualToString:@"https"]) {
_secure = YES;
}
-
+
if (!queue) {
_delegateDispatchQueue = dispatch_get_main_queue();
} else {
_delegateDispatchQueue = queue;
}
-
+
[self _SR_commonInit];
}
-
+
return self;
}
@@ -345,7 +345,7 @@ static __strong NSData *CRLFCRLF;
- (id)initWithURL:(NSURL *)url protocols:(NSArray *)protocols;
{
- NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
+ NSMutableURLRequest *request = [[NSMutableURLRequest alloc] initWithURL:url];
return [self initWithURLRequest:request protocols:protocols];
}
@@ -354,9 +354,9 @@ static __strong NSData *CRLFCRLF;
_readyState = SR_CONNECTING;
_consumerStopped = YES;
-
+
_webSocketVersion = 13;
-
+
_workQueue = dispatch_queue_create(NULL, DISPATCH_QUEUE_SERIAL);
// Going to set a specific on the queue so we can validate we're on the work queue
@@ -366,7 +366,7 @@ static __strong NSData *CRLFCRLF;
_readBuffer = [[NSMutableData alloc] init];
_outputBuffer = [[NSMutableData alloc] init];
-
+
_currentFrameData = [[NSMutableData alloc] init];
_consumers = [[NSMutableArray alloc] init];
@@ -376,7 +376,7 @@ static __strong NSData *CRLFCRLF;
_scheduledRunloops = [[NSMutableSet alloc] init];
[self _initializeStreams];
-
+
// default handlers
}
@@ -395,7 +395,7 @@ static __strong NSData *CRLFCRLF;
sr_dispatch_release(_workQueue);
_workQueue = NULL;
-
+
if (_receivedHTTPHeaders) {
CFRelease(_receivedHTTPHeaders);
_receivedHTTPHeaders = NULL;
@@ -460,29 +460,29 @@ static __strong NSData *CRLFCRLF;
if (acceptHeader == nil) {
return NO;
}
-
+
NSString *concattedString = [_secKey stringByAppendingString:SRWebSocketAppendToSecKeyString];
NSString *expectedAccept = [concattedString stringBySHA1ThenBase64Encoding];
-
+
return [acceptHeader isEqualToString:expectedAccept];
}
- (void)_HTTPHeadersDidFinish;
{
NSInteger responseCode = CFHTTPMessageGetResponseStatusCode(_receivedHTTPHeaders);
-
+
if (responseCode >= 400) {
SRFastLog(@"Request failed with response code %d", responseCode);
[self _failWithError:[NSError errorWithDomain:@"org.lolrus.SocketRocket" code:2132 userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"received bad response code from server %u", (int)responseCode] forKey:NSLocalizedDescriptionKey]]];
return;
}
-
+
if(![self _checkHandshake:_receivedHTTPHeaders]) {
[self _failWithError:[NSError errorWithDomain:FSRWebSocketErrorDomain code:2133 userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Invalid Sec-WebSocket-Accept response"] forKey:NSLocalizedDescriptionKey]]];
return;
}
-
+
NSString *negotiatedProtocol = CFBridgingRelease(CFHTTPMessageCopyHeaderFieldValue(_receivedHTTPHeaders, CFSTR("Sec-WebSocket-Protocol")));
if (negotiatedProtocol) {
// Make sure we requested the protocol
@@ -490,12 +490,12 @@ static __strong NSData *CRLFCRLF;
[self _failWithError:[NSError errorWithDomain:FSRWebSocketErrorDomain code:2133 userInfo:[NSDictionary dictionaryWithObject:[NSString stringWithFormat:@"Server specified Sec-WebSocket-Protocol that wasn't requested"] forKey:NSLocalizedDescriptionKey]]];
return;
}
-
+
_protocol = negotiatedProtocol;
}
-
+
self.readyState = SR_OPEN;
-
+
if (!_didFail) {
[self _readFrameNew];
}
@@ -513,10 +513,10 @@ static __strong NSData *CRLFCRLF;
if (_receivedHTTPHeaders == NULL) {
_receivedHTTPHeaders = CFHTTPMessageCreateEmpty(NULL, NO);
}
-
+
[self _readUntilHeaderCompleteWithCallback:^(FSRWebSocket *self, NSData *data) {
CFHTTPMessageAppendBytes(_receivedHTTPHeaders, (const UInt8 *)data.bytes, data.length);
-
+
if (CFHTTPMessageIsHeaderComplete(_receivedHTTPHeaders)) {
SRFastLog(@"Finished reading headers %@", CFBridgingRelease(CFHTTPMessageCopyAllHeaderFields(_receivedHTTPHeaders)));
[self _HTTPHeadersDidFinish];
@@ -530,16 +530,16 @@ static __strong NSData *CRLFCRLF;
{
SRFastLog(@"Connected");
CFHTTPMessageRef request = CFHTTPMessageCreateRequest(NULL, CFSTR("GET"), (__bridge CFURLRef)_url, kCFHTTPVersion1_1);
-
+
// Set host first so it defaults
CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Host"), (__bridge CFStringRef)(_url.port ? [NSString stringWithFormat:@"%@:%@", _url.host, _url.port] : _url.host));
-
+
NSMutableData *keyBytes = [[NSMutableData alloc] initWithLength:16];
int result = SecRandomCopyBytes(kSecRandomDefault, keyBytes.length, keyBytes.mutableBytes);
assert(result == 0);
_secKey = [FSRUtilities base64EncodedStringFromData:keyBytes];
assert([_secKey length] == 24);
-
+
CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Upgrade"), CFSTR("websocket"));
CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Connection"), CFSTR("Upgrade"));
if (_userAgent) {
@@ -548,9 +548,9 @@ static __strong NSData *CRLFCRLF;
CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Sec-WebSocket-Key"), (__bridge CFStringRef)_secKey);
CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Sec-WebSocket-Version"), (__bridge CFStringRef)[NSString stringWithFormat:@"%u", (int)_webSocketVersion]);
-
+
CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Origin"), (__bridge CFStringRef)_url.SR_origin);
-
+
if (_requestedProtocols) {
CFHTTPMessageSetHeaderFieldValue(request, CFSTR("Sec-WebSocket-Protocol"), (__bridge CFStringRef)[_requestedProtocols componentsJoinedByString:@", "]);
}
@@ -558,9 +558,9 @@ static __strong NSData *CRLFCRLF;
[_urlRequest.allHTTPHeaderFields enumerateKeysAndObjectsUsingBlock:^(id key, id obj, BOOL *stop) {
CFHTTPMessageSetHeaderFieldValue(request, (__bridge CFStringRef)key, (__bridge CFStringRef)obj);
}];
-
+
NSData *message = CFBridgingRelease(CFHTTPMessageCopySerializedMessage(request));
-
+
CFRelease(request);
[self _writeData:message];
@@ -582,34 +582,34 @@ static __strong NSData *CRLFCRLF;
CFReadStreamRef readStream = NULL;
CFWriteStreamRef writeStream = NULL;
-
+
CFStreamCreatePairWithSocketToHost(NULL, (__bridge CFStringRef)host, (int)port, &readStream, &writeStream);
-
+
// XXX
CFReadStreamSetProperty(readStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeBackground);
CFWriteStreamSetProperty(writeStream, kCFStreamNetworkServiceType, kCFStreamNetworkServiceTypeBackground);
-
+
_outputStream = CFBridgingRelease(writeStream);
_inputStream = CFBridgingRelease(readStream);
-
-
+
+
if (_secure) {
NSMutableDictionary *SSLOptions = [[NSMutableDictionary alloc] init];
-
+
[_outputStream setProperty:(__bridge id)kCFStreamSocketSecurityLevelNegotiatedSSL forKey:(__bridge id)kCFStreamPropertySocketSecurityLevel];
-
+
// If we're using pinned certs, don't validate the certificate chain
if ([_urlRequest FSR_SSLPinnedCertificates].count) {
[SSLOptions setValue:[NSNumber numberWithBool:NO] forKey:(__bridge id)kCFStreamSSLValidatesCertificateChain];
}
-
+
[_outputStream setProperty:SSLOptions
forKey:(__bridge id)kCFStreamPropertySSLSettings];
}
-
+
_inputStream.delegate = self;
_outputStream.delegate = self;
-
+
[_outputStream open];
[_inputStream open];
}
@@ -653,7 +653,7 @@ static __strong NSData *CRLFCRLF;
if (self.readyState == SR_CLOSING || self.readyState == SR_CLOSED) {
return;
}
-
+
BOOL wasConnecting = self.readyState == SR_CONNECTING;
self.readyState = SR_CLOSING;
@@ -668,16 +668,16 @@ static __strong NSData *CRLFCRLF;
size_t maxMsgSize = [reason maximumLengthOfBytesUsingEncoding:NSUTF8StringEncoding];
NSMutableData *mutablePayload = [[NSMutableData alloc] initWithLength:sizeof(uint16_t) + maxMsgSize];
NSData *payload = mutablePayload;
-
+
((uint16_t *)mutablePayload.mutableBytes)[0] = EndianU16_BtoN(code);
-
+
if (reason) {
NSRange remainingRange = {0};
-
+
NSUInteger usedLength = 0;
-
+
BOOL success = [reason getBytes:(char *)mutablePayload.mutableBytes + sizeof(uint16_t) maxLength:payload.length - sizeof(uint16_t) usedLength:&usedLength encoding:NSUTF8StringEncoding options:NSStringEncodingConversionExternalRepresentation range:NSMakeRange(0, reason.length) remainingRange:&remainingRange];
-
+
assert(success);
assert(remainingRange.length == 0);
@@ -685,15 +685,15 @@ static __strong NSData *CRLFCRLF;
payload = [payload subdataWithRange:NSMakeRange(0, usedLength + sizeof(uint16_t))];
}
}
-
-
+
+
[self _sendFrameWithOpcode:SROpCodeConnectionClose data:payload];
});
}
- (void)_closeWithProtocolError:(NSString *)message;
{
- // Need to shunt this on the _callbackQueue first to see if they received any messages
+ // Need to shunt this on the _callbackQueue first to see if they received any messages
[self _performDelegateBlock:^{
[self closeWithCode:SRStatusCodeProtocolError reason:message];
dispatch_async(_workQueue, ^{
@@ -716,7 +716,7 @@ static __strong NSData *CRLFCRLF;
self.readyState = SR_CLOSED;
SRFastLog(@"Failing with error %@", error.localizedDescription);
-
+
[self _disconnect];
[self _scheduleCleanup];
}
@@ -724,7 +724,7 @@ static __strong NSData *CRLFCRLF;
}
- (void)_writeData:(NSData *)data;
-{
+{
[self assertOnWorkQueue];
if (_closeWhenFinishedWriting) {
@@ -782,7 +782,7 @@ static inline BOOL closeCodeIsValid(int closeCode) {
if (closeCode < 1000) {
return NO;
}
-
+
if (closeCode >= 1000 && closeCode <= 1011) {
if (closeCode == 1004 ||
closeCode == 1005 ||
@@ -791,11 +791,11 @@ static inline BOOL closeCodeIsValid(int closeCode) {
}
return YES;
}
-
+
if (closeCode >= 3000 && closeCode <= 3999) {
return YES;
}
-
+
if (closeCode >= 4000 && closeCode <= 4999) {
return YES;
}
@@ -816,9 +816,9 @@ static inline BOOL closeCodeIsValid(int closeCode) {
{
size_t dataSize = data.length;
__block uint16_t closeCode = 0;
-
+
SRFastLog(@"Received close frame");
-
+
if (dataSize == 1) {
// TODO handle error
[self _closeWithProtocolError:@"Payload for close must be larger than 2 bytes"];
@@ -840,9 +840,9 @@ static inline BOOL closeCodeIsValid(int closeCode) {
} else {
_closeCode = SRStatusNoStatusReceived;
}
-
+
[self assertOnWorkQueue];
-
+
if (self.readyState == SR_OPEN) {
[self closeWithCode:1000 reason:nil];
}
@@ -860,9 +860,9 @@ static inline BOOL closeCodeIsValid(int closeCode) {
}
- (void)_handleFrameWithData:(NSData *)frameData opCode:(NSInteger)opcode;
-{
+{
// Check that the current data is valid UTF8
-
+
BOOL isControlFrame = (opcode == SROpCodePing || opcode == SROpCodePong || opcode == SROpCodeConnectionClose);
if (!isControlFrame) {
[self _readFrameNew];
@@ -871,7 +871,7 @@ static inline BOOL closeCodeIsValid(int closeCode) {
[self _readFrameContinue];
});
}
-
+
switch (opcode) {
case SROpCodeTextFrame: {
NSString *str = [[NSString alloc] initWithData:frameData encoding:NSUTF8StringEncoding];
@@ -908,29 +908,29 @@ static inline BOOL closeCodeIsValid(int closeCode) {
- (void)_handleFrameHeader:(frame_header)frame_header curData:(NSData *)curData;
{
assert(frame_header.opcode != 0);
-
+
if (self.readyState != SR_OPEN) {
return;
}
-
-
+
+
BOOL isControlFrame = (frame_header.opcode == SROpCodePing || frame_header.opcode == SROpCodePong || frame_header.opcode == SROpCodeConnectionClose);
-
+
if (isControlFrame && !frame_header.fin) {
[self _closeWithProtocolError:@"Fragmented control frames not allowed"];
return;
}
-
+
if (isControlFrame && frame_header.payload_length >= 126) {
[self _closeWithProtocolError:@"Control frames cannot have payloads larger than 126 bytes"];
return;
}
-
+
if (!isControlFrame) {
_currentFrameOpcode = frame_header.opcode;
_currentFrameCount += 1;
}
-
+
if (frame_header.payload_length == 0) {
if (isControlFrame) {
[self _handleFrameWithData:curData opCode:frame_header.opcode];
@@ -953,7 +953,7 @@ static inline BOOL closeCodeIsValid(int closeCode) {
// TODO add assert that opcode is not a control;
[self _readFrameContinue];
}
-
+
}
} readToCurrentFrame:!isControlFrame unmaskBytes:frame_header.masked];
}
@@ -994,51 +994,51 @@ static const uint8_t SRPayloadLenMask = 0x7F;
[self _addConsumerWithDataLength:2 callback:^(FSRWebSocket *self, NSData *data) {
__block frame_header header = {0};
-
+
const uint8_t *headerBuffer = data.bytes;
assert(data.length >= 2);
-
+
if (headerBuffer[0] & SRRsvMask) {
[self _closeWithProtocolError:@"Server used RSV bits"];
return;
}
-
+
uint8_t receivedOpcode = (SROpCodeMask & headerBuffer[0]);
-
+
BOOL isControlFrame = (receivedOpcode == SROpCodePing || receivedOpcode == SROpCodePong || receivedOpcode == SROpCodeConnectionClose);
-
+
if (!isControlFrame && receivedOpcode != 0 && self->_currentFrameCount > 0) {
[self _closeWithProtocolError:@"all data frames after the initial data frame must have opcode 0"];
return;
}
-
+
if (receivedOpcode == 0 && self->_currentFrameCount == 0) {
[self _closeWithProtocolError:@"cannot continue a message"];
return;
}
-
+
header.opcode = receivedOpcode == 0 ? self->_currentFrameOpcode : receivedOpcode;
-
+
header.fin = !!(SRFinMask & headerBuffer[0]);
-
-
+
+
header.masked = !!(SRMaskMask & headerBuffer[1]);
header.payload_length = SRPayloadLenMask & headerBuffer[1];
-
+
headerBuffer = NULL;
-
+
if (header.masked) {
[self _closeWithProtocolError:@"Client must receive unmasked data"];
}
-
+
size_t extra_bytes_needed = header.masked ? sizeof(_currentReadMaskKey) : 0;
-
+
if (header.payload_length == 126) {
extra_bytes_needed += sizeof(uint16_t);
} else if (header.payload_length == 127) {
extra_bytes_needed += sizeof(uint64_t);
}
-
+
if (extra_bytes_needed == 0) {
[self _handleFrameHeader:header curData:self->_currentFrameData];
} else {
@@ -1046,7 +1046,7 @@ static const uint8_t SRPayloadLenMask = 0x7F;
size_t mapped_size = data.length;
const void *mapped_buffer = data.bytes;
size_t offset = 0;
-
+
if (header.payload_length == 126) {
assert(mapped_size >= sizeof(uint16_t));
uint16_t newLen = EndianU16_BtoN(*(uint16_t *)(mapped_buffer));
@@ -1059,13 +1059,13 @@ static const uint8_t SRPayloadLenMask = 0x7F;
} else {
assert(header.payload_length < 126 && header.payload_length >= 0);
}
-
-
+
+
if (header.masked) {
assert(mapped_size >= sizeof(_currentReadMaskOffset) + offset);
memcpy(self->_currentReadMaskKey, ((uint8_t *)mapped_buffer) + offset, sizeof(self->_currentReadMaskKey));
}
-
+
[self _handleFrameHeader:header curData:self->_currentFrameData];
} readToCurrentFrame:NO unmaskBytes:NO];
}
@@ -1076,12 +1076,12 @@ static const uint8_t SRPayloadLenMask = 0x7F;
{
dispatch_async(_workQueue, ^{
[_currentFrameData setLength:0];
-
+
_currentFrameOpcode = 0;
_currentFrameCount = 0;
_readOpCount = 0;
_currentStringScanPosition = 0;
-
+
[self _readFrameContinue];
});
}
@@ -1097,17 +1097,17 @@ static const uint8_t SRPayloadLenMask = 0x7F;
[self _failWithError:[NSError errorWithDomain:@"org.lolrus.SocketRocket" code:2145 userInfo:[NSDictionary dictionaryWithObject:@"Error writing to stream" forKey:NSLocalizedDescriptionKey]]];
return;
}
-
+
_outputBufferOffset += bytesWritten;
-
+
if (_outputBufferOffset > 4096 && _outputBufferOffset > (_outputBuffer.length >> 1)) {
_outputBuffer = [[NSMutableData alloc] initWithBytes:(char *)_outputBuffer.bytes + _outputBufferOffset length:_outputBuffer.length - _outputBufferOffset];
_outputBufferOffset = 0;
}
}
-
- if (_closeWhenFinishedWriting &&
- _outputBuffer.length - _outputBufferOffset == 0 &&
+
+ if (_closeWhenFinishedWriting &&
+ _outputBuffer.length - _outputBufferOffset == 0 &&
(_inputStream.streamStatus != NSStreamStatusNotOpen &&
_inputStream.streamStatus != NSStreamStatusClosed) &&
!_sentClose) {
@@ -1119,7 +1119,7 @@ static const uint8_t SRPayloadLenMask = 0x7F;
// TODO: Why are we missing the SocketRocket code to call unscheduleFromRunLoop???
}
-
+
if (!_failed) {
[self _performDelegateBlock:^{
if ([self.delegate respondsToSelector:@selector(webSocket:didCloseWithCode:reason:wasClean:)]) {
@@ -1138,7 +1138,7 @@ static const uint8_t SRPayloadLenMask = 0x7F;
}
- (void)_addConsumerWithDataLength:(size_t)dataLength callback:(data_callback)callback readToCurrentFrame:(BOOL)readToCurrentFrame unmaskBytes:(BOOL)unmaskBytes;
-{
+{
[self assertOnWorkQueue];
assert(dataLength);
@@ -1147,7 +1147,7 @@ static const uint8_t SRPayloadLenMask = 0x7F;
}
- (void)_addConsumerWithScanner:(stream_scanner)consumer callback:(data_callback)callback dataLength:(size_t)dataLength;
-{
+{
[self assertOnWorkQueue];
[_consumers addObject:[_consumerPool consumerWithScanner:consumer handler:callback bytesNeeded:dataLength readToCurrentFrame:NO unmaskBytes:NO]];
[self _pumpScanner];
@@ -1202,7 +1202,7 @@ static const char CRLFCRLFBytes[] = {'\r', '\n', '\r', '\n'};
stream_scanner consumer = ^size_t(NSData *data) {
__block size_t found_size = 0;
__block size_t match_count = 0;
-
+
size_t size = data.length;
const unsigned char *buffer = data.bytes;
for (int i = 0; i < size; i++ ) {
@@ -1224,29 +1224,29 @@ static const char CRLFCRLFBytes[] = {'\r', '\n', '\r', '\n'};
// Returns true if did work
- (BOOL)_innerPumpScanner {
-
+
BOOL didWork = NO;
-
+
if (self.readyState >= SR_CLOSING) {
return didWork;
}
-
+
if (!_consumers.count) {
return didWork;
}
-
+
size_t curSize = _readBuffer.length - _readBufferOffset;
if (!curSize) {
return didWork;
}
-
+
FSRIOConsumer *consumer = [_consumers objectAtIndex:0];
-
+
size_t bytesNeeded = consumer.bytesNeeded;
-
+
size_t foundSize = 0;
if (consumer.consumer) {
- NSData *tempView = [NSData dataWithBytesNoCopy:(char *)_readBuffer.bytes + _readBufferOffset length:_readBuffer.length - _readBufferOffset freeWhenDone:NO];
+ NSData *tempView = [NSData dataWithBytesNoCopy:(char *)_readBuffer.bytes + _readBufferOffset length:_readBuffer.length - _readBufferOffset freeWhenDone:NO];
foundSize = consumer.consumer(tempView);
} else {
assert(consumer.bytesNeeded);
@@ -1256,48 +1256,48 @@ static const char CRLFCRLFBytes[] = {'\r', '\n', '\r', '\n'};
foundSize = curSize;
}
}
-
+
NSData *slice = nil;
if (consumer.readToCurrentFrame || foundSize) {
NSRange sliceRange = NSMakeRange(_readBufferOffset, foundSize);
slice = [_readBuffer subdataWithRange:sliceRange];
-
+
_readBufferOffset += foundSize;
-
+
if (_readBufferOffset > 4096 && _readBufferOffset > (_readBuffer.length >> 1)) {
_readBuffer = [[NSMutableData alloc] initWithBytes:(char *)_readBuffer.bytes + _readBufferOffset length:_readBuffer.length - _readBufferOffset]; _readBufferOffset = 0;
}
-
+
if (consumer.unmaskBytes) {
NSMutableData *mutableSlice = [slice mutableCopy];
-
+
NSUInteger len = mutableSlice.length;
uint8_t *bytes = mutableSlice.mutableBytes;
-
+
for (int i = 0; i < len; i++) {
bytes[i] = bytes[i] ^ _currentReadMaskKey[_currentReadMaskOffset % sizeof(_currentReadMaskKey)];
_currentReadMaskOffset += 1;
}
-
+
slice = mutableSlice;
}
-
+
if (consumer.readToCurrentFrame) {
[_currentFrameData appendData:slice];
-
+
_readOpCount += 1;
-
+
if (_currentFrameOpcode == SROpCodeTextFrame) {
// Validate UTF8 stuff.
size_t currentDataSize = _currentFrameData.length;
if (_currentFrameOpcode == SROpCodeTextFrame && currentDataSize > 0) {
// TODO: Optimize the crap out of this. Don't really have to copy all the data each time
-
+
size_t scanSize = currentDataSize - _currentStringScanPosition;
-
+
NSData *scan_data = [_currentFrameData subdataWithRange:NSMakeRange(_currentStringScanPosition, scanSize)];
int32_t valid_utf8_size = validate_dispatch_data_partial_string(scan_data);
-
+
if (valid_utf8_size == -1) {
[self closeWithCode:SRStatusCodeInvalidUTF8 reason:@"Text frames must be valid UTF-8"];
dispatch_async(_workQueue, ^{
@@ -1307,12 +1307,12 @@ static const char CRLFCRLFBytes[] = {'\r', '\n', '\r', '\n'};
} else {
_currentStringScanPosition += valid_utf8_size;
}
- }
-
+ }
+
}
-
+
consumer.bytesNeeded -= foundSize;
-
+
if (consumer.bytesNeeded == 0) {
[_consumers removeObjectAtIndex:0];
consumer.handler(self, nil);
@@ -1330,17 +1330,17 @@ static const char CRLFCRLFBytes[] = {'\r', '\n', '\r', '\n'};
-(void)_pumpScanner;
{
[self assertOnWorkQueue];
-
+
if (!_isPumping) {
_isPumping = YES;
} else {
return;
}
-
+
while ([self _innerPumpScanner]) {
-
+
}
-
+
_isPumping = NO;
}
@@ -1351,33 +1351,33 @@ static const size_t SRFrameHeaderOverhead = 32;
- (void)_sendFrameWithOpcode:(FSROpCode)opcode data:(id)data;
{
[self assertOnWorkQueue];
-
+
NSAssert(data == nil || [data isKindOfClass:[NSData class]] || [data isKindOfClass:[NSString class]], @"Function expects nil, NSString or NSData");
-
+
size_t payloadLength = [data isKindOfClass:[NSString class]] ? [(NSString *)data lengthOfBytesUsingEncoding:NSUTF8StringEncoding] : [data length];
-
+
NSMutableData *frame = [[NSMutableData alloc] initWithLength:payloadLength + SRFrameHeaderOverhead];
if (!frame) {
[self closeWithCode:SRStatusCodeMessageTooBig reason:@"Message too big"];
return;
}
uint8_t *frame_buffer = (uint8_t *)[frame mutableBytes];
-
+
// set fin
frame_buffer[0] = SRFinMask | opcode;
-
+
BOOL useMask = YES;
#ifdef NOMASK
useMask = NO;
#endif
-
+
if (useMask) {
// set the mask and header
frame_buffer[1] |= SRMaskMask;
}
-
+
size_t frame_buffer_size = 2;
-
+
const uint8_t *unmasked_payload = NULL;
if ([data isKindOfClass:[NSData class]]) {
unmasked_payload = (uint8_t *)[data bytes];
@@ -1386,7 +1386,7 @@ static const size_t SRFrameHeaderOverhead = 32;
} else {
assert(NO);
}
-
+
if (payloadLength < 126) {
frame_buffer[1] |= payloadLength;
} else if (payloadLength <= UINT16_MAX) {
@@ -1398,7 +1398,7 @@ static const size_t SRFrameHeaderOverhead = 32;
*((uint64_t *)(frame_buffer + frame_buffer_size)) = EndianU64_BtoN((uint64_t)payloadLength);
frame_buffer_size += sizeof(uint64_t);
}
-
+
if (!useMask) {
for (int i = 0; i < payloadLength; i++) {
frame_buffer[frame_buffer_size] = unmasked_payload[i];
@@ -1409,7 +1409,7 @@ static const size_t SRFrameHeaderOverhead = 32;
int result = SecRandomCopyBytes(kSecRandomDefault, sizeof(uint32_t), (uint8_t *)mask_key);
assert(result == 0);
frame_buffer_size += sizeof(uint32_t);
-
+
// TODO: could probably optimize this with SIMD
for (int i = 0; i < payloadLength; i++) {
frame_buffer[frame_buffer_size] = unmasked_payload[i] ^ mask_key[i % sizeof(uint32_t)];
@@ -1419,7 +1419,7 @@ static const size_t SRFrameHeaderOverhead = 32;
assert(frame_buffer_size <= [frame length]);
frame.length = frame_buffer_size;
-
+
[self _writeData:frame];
}
@@ -1445,7 +1445,7 @@ static const size_t SRFrameHeaderOverhead = 32;
}
if (_secure && !_pinnedCertFound && (eventCode == NSStreamEventHasBytesAvailable || eventCode == NSStreamEventHasSpaceAvailable)) {
-
+
NSArray *sslCerts = [_urlRequest FSR_SSLPinnedCertificates];
if (sslCerts) {
SecTrustRef secTrust = (__bridge SecTrustRef)[aStream propertyForKey:(__bridge id)kCFStreamPropertySSLPeerTrust];
@@ -1454,11 +1454,11 @@ static const size_t SRFrameHeaderOverhead = 32;
for (NSInteger i = 0; i < numCerts && !_pinnedCertFound; i++) {
SecCertificateRef cert = SecTrustGetCertificateAtIndex(secTrust, i);
NSData *certData = CFBridgingRelease(SecCertificateCopyData(cert));
-
+
for (id ref in sslCerts) {
SecCertificateRef trustedCert = (__bridge SecCertificateRef)ref;
NSData *trustedCertData = CFBridgingRelease(SecCertificateCopyData(trustedCert));
-
+
if ([trustedCertData isEqualToData:certData]) {
_pinnedCertFound = YES;
break;
@@ -1466,7 +1466,7 @@ static const size_t SRFrameHeaderOverhead = 32;
}
}
}
-
+
if (!_pinnedCertFound) {
dispatch_async(_workQueue, ^{
NSDictionary *userInfo = @{ NSLocalizedDescriptionKey : @"Invalid server cert" };
@@ -1669,13 +1669,13 @@ static const size_t SRFrameHeaderOverhead = 32;
- (NSString *)SR_origin;
{
NSString *scheme = [self.scheme lowercaseString];
-
+
if ([scheme isEqualToString:@"wss"]) {
scheme = @"https";
} else if ([scheme isEqualToString:@"ws"]) {
scheme = @"http";
}
-
+
if (self.port) {
return [NSString stringWithFormat:@"%@://%@:%@/", scheme, self.host, self.port];
} else {
@@ -1691,11 +1691,11 @@ static inline void SRFastLog(NSString *format, ...) {
#ifdef SR_ENABLE_LOG
__block va_list arg_list;
va_start (arg_list, format);
-
+
NSString *formattedString = [[NSString alloc] initWithFormat:format arguments:arg_list];
-
+
va_end(arg_list);
-
+
NSLog(@"[SR] %@", formattedString);
#endif
}
@@ -1704,13 +1704,13 @@ static inline void SRFastLog(NSString *format, ...) {
#ifdef HAS_ICU
static inline int32_t validate_dispatch_data_partial_string(NSData *data) {
-
+
const void * contents = [data bytes];
long size = [data length];
-
+
const uint8_t *str = (const uint8_t *)contents;
-
-
+
+
UChar32 codepoint = 1;
int32_t offset = 0;
int32_t lastOffset = 0;
@@ -1718,33 +1718,33 @@ static inline int32_t validate_dispatch_data_partial_string(NSData *data) {
lastOffset = offset;
U8_NEXT(str, offset, size, codepoint);
}
-
+
if (codepoint == -1) {
// Check to see if the last byte is valid or whether it was just continuing
if (!U8_IS_LEAD(str[lastOffset]) || U8_COUNT_TRAIL_BYTES(str[lastOffset]) + lastOffset < (int32_t)size) {
-
+
size = -1;
} else {
uint8_t leadByte = str[lastOffset];
U8_MASK_LEAD_BYTE(leadByte, U8_COUNT_TRAIL_BYTES(leadByte));
-
+
for (int i = lastOffset + 1; i < offset; i++) {
-
+
if (U8_IS_SINGLE(str[i]) || U8_IS_LEAD(str[i]) || !U8_IS_TRAIL(str[i])) {
size = -1;
}
}
-
+
if (size != -1) {
size = lastOffset;
}
}
}
-
+
if (size != -1 && ![[NSString alloc] initWithBytesNoCopy:(char *)[data bytes] length:size encoding:NSUTF8StringEncoding freeWhenDone:NO]) {
size = -1;
}
-
+
return (int32_t)size;
}
@@ -1753,14 +1753,14 @@ static inline int32_t validate_dispatch_data_partial_string(NSData *data) {
// This is a hack, and probably not optimal
static inline int32_t validate_dispatch_data_partial_string(NSData *data) {
static const int maxCodepointSize = 3;
-
+
for (int i = 0; i < maxCodepointSize; i++) {
NSString *str = [[NSString alloc] initWithBytesNoCopy:(char *)data.bytes length:data.length - i encoding:NSUTF8StringEncoding freeWhenDone:NO];
if (str) {
return (int)(data.length - i);
}
}
-
+
return -1;
}
diff --git a/Firebase/Database/third_party/SocketRocket/fbase64.c b/Firebase/Database/third_party/SocketRocket/fbase64.c
index 1750673..238c23c 100644
--- a/Firebase/Database/third_party/SocketRocket/fbase64.c
+++ b/Firebase/Database/third_party/SocketRocket/fbase64.c
@@ -73,23 +73,23 @@ static const char Pad64 = '=';
The following encoding technique is taken from RFC 1521 by Borenstein
and Freed. It is reproduced here in a slightly edited form for
convenience.
-
+
A 65-character subset of US-ASCII is used, enabling 6 bits to be
represented per printable character. (The extra 65th character, "=",
is used to signify a special processing function.)
-
+
The encoding process represents 24-bit groups of input bits as output
strings of 4 encoded characters. Proceeding from left to right, a
24-bit input group is formed by concatenating 3 8-bit input groups.
These 24 bits are then treated as 4 concatenated 6-bit groups, each
of which is translated into a single digit in the base64 alphabet.
-
+
Each 6-bit group is used as an index into an array of 64 printable
characters. The character referenced by the index is placed in the
output string.
-
+
Table 1: The Base64 Alphabet
-
+
Value Encoding Value Encoding Value Encoding Value Encoding
0 A 17 R 34 i 51 z
1 B 18 S 35 j 52 0
@@ -108,18 +108,18 @@ static const char Pad64 = '=';
14 O 31 f 48 w (pad) =
15 P 32 g 49 x
16 Q 33 h 50 y
-
+
Special processing is performed if fewer than 24 bits are available
at the end of the data being encoded. A full encoding quantum is
always completed at the end of a quantity. When fewer than 24 input
bits are available in an input group, zero bits are added (on the
right) to form an integral number of 6-bit groups. Padding at the
end of the data is performed using the '=' character.
-
+
Since all base64 input is an integral number of octets, only the
- -------------------------------------------------
+ -------------------------------------------------
following cases can arise:
-
+
(1) the final quantum of encoding input is an integral
multiple of 24 bits; here, the final unit of encoded
output will be an integral multiple of 4 characters
@@ -132,7 +132,7 @@ static const char Pad64 = '=';
characters followed by one "=" padding character.
*/
-#if !defined(HAVE_B64_NTOP) && !defined(HAVE___B64_NTOP)
+#if !defined(HAVE_B64_NTOP) && !defined(HAVE___B64_NTOP)
int
f_b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize)
{
@@ -140,18 +140,18 @@ f_b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize)
u_char input[3];
u_char output[4];
u_int i;
-
+
while (2 < srclength) {
input[0] = *src++;
input[1] = *src++;
input[2] = *src++;
srclength -= 3;
-
+
output[0] = input[0] >> 2;
output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
output[3] = input[2] & 0x3f;
-
+
if (datalength + 4 > targsize)
return (-1);
target[datalength++] = Base64[output[0]];
@@ -159,18 +159,18 @@ f_b64_ntop(u_char const *src, size_t srclength, char *target, size_t targsize)
target[datalength++] = Base64[output[2]];
target[datalength++] = Base64[output[3]];
}
-
+
/* Now we worry about padding. */
if (0 != srclength) {
/* Get what's left. */
input[0] = input[1] = input[2] = '\0';
for (i = 0; i < srclength; i++)
input[i] = *src++;
-
+
output[0] = input[0] >> 2;
output[1] = ((input[0] & 0x03) << 4) + (input[1] >> 4);
output[2] = ((input[1] & 0x0f) << 2) + (input[2] >> 6);
-
+
if (datalength + 4 > targsize)
return (-1);
target[datalength++] = Base64[output[0]];
@@ -202,21 +202,21 @@ f_b64_pton(char const *src, u_char *target, size_t targsize)
u_int tarindex, state;
int ch;
char *pos;
-
+
state = 0;
tarindex = 0;
-
+
while ((ch = *src++) != '\0') {
if (isspace(ch)) /* Skip whitespace anywhere. */
continue;
-
+
if (ch == Pad64)
break;
-
+
pos = strchr(Base64, ch);
if (pos == 0) /* A non-base64 character. */
return (-1);
-
+
switch (state) {
case 0:
if (target) {
@@ -259,19 +259,19 @@ f_b64_pton(char const *src, u_char *target, size_t targsize)
break;
}
}
-
+
/*
* We are done decoding Base-64 chars. Let's see if we ended
* on a byte boundary, and/or with erroneous trailing characters.
*/
-
+
if (ch == Pad64) { /* We got a pad char. */
ch = *src++; /* Skip it, get next. */
switch (state) {
case 0: /* Invalid = in first position */
case 1: /* Invalid = in second position */
return (-1);
-
+
case 2: /* Valid, means one byte of info */
/* Skip any number of spaces. */
for (; ch != '\0'; ch = *src++)
@@ -283,7 +283,7 @@ f_b64_pton(char const *src, u_char *target, size_t targsize)
ch = *src++; /* Skip the = */
/* Fall through to "single trailing =" case. */
/* FALLTHROUGH */
-
+
case 3: /* Valid, means two bytes of info */
/*
* We know this char is an =. Is there anything but
@@ -292,7 +292,7 @@ f_b64_pton(char const *src, u_char *target, size_t targsize)
for (; ch != '\0'; ch = *src++)
if (!isspace(ch))
return (-1);
-
+
/*
* Now make sure for cases 2 and 3 that the "extra"
* bits that slopped past the last full byte were
@@ -310,9 +310,9 @@ f_b64_pton(char const *src, u_char *target, size_t targsize)
if (state != 0)
return (-1);
}
-
+
return (tarindex);
}
#endif /* !defined(HAVE_B64_PTON) && !defined(HAVE___B64_PTON) */
-#endif \ No newline at end of file
+#endif
diff --git a/Firebase/Database/third_party/SocketRocket/fbase64.h b/Firebase/Database/third_party/SocketRocket/fbase64.h
index a9c55c9..a9bf142 100644
--- a/Firebase/Database/third_party/SocketRocket/fbase64.h
+++ b/Firebase/Database/third_party/SocketRocket/fbase64.h
@@ -26,7 +26,7 @@ f_b64_ntop(u_char const *src,
extern int
f_b64_pton(char const *src,
- u_char *target,
+ u_char *target,
size_t targsize);
diff --git a/Firebase/Storage/FIRStorageDeleteTask.m b/Firebase/Storage/FIRStorageDeleteTask.m
index 63254c7..825bd51 100644
--- a/Firebase/Storage/FIRStorageDeleteTask.m
+++ b/Firebase/Storage/FIRStorageDeleteTask.m
@@ -48,9 +48,9 @@
GTMSessionFetcher *fetcher = [self.fetcherService fetcherWithRequest:request];
_fetcher = fetcher;
-
+
fetcher.comment = @"DeleteTask";
-
+
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-retain-cycles"
_fetcherCompletion = ^(NSData *_Nullable data, NSError *_Nullable error) {
diff --git a/Firebase/Storage/FIRStorageGetMetadataTask.m b/Firebase/Storage/FIRStorageGetMetadataTask.m
index c7be8cc..fe0844d 100644
--- a/Firebase/Storage/FIRStorageGetMetadataTask.m
+++ b/Firebase/Storage/FIRStorageGetMetadataTask.m
@@ -93,7 +93,7 @@
_fetcherCompletion = nil;
};
#pragma clang diagnostic pop
-
+
__weak FIRStorageGetMetadataTask *weakSelf = self;
[fetcher beginFetchWithCompletionHandler:^(NSData *data, NSError *error) {
weakSelf.fetcherCompletion(data, error);
diff --git a/Firebase/Storage/FIRStorageUpdateMetadataTask.m b/Firebase/Storage/FIRStorageUpdateMetadataTask.m
index 5f019f4..005f78f 100644
--- a/Firebase/Storage/FIRStorageUpdateMetadataTask.m
+++ b/Firebase/Storage/FIRStorageUpdateMetadataTask.m
@@ -60,7 +60,7 @@
GTMSessionFetcher *fetcher = [self.fetcherService fetcherWithRequest:request];
_fetcher = fetcher;
-
+
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-retain-cycles"
_fetcherCompletion =^(NSData *data, NSError *error) {
diff --git a/Firebase/Storage/FIRStorageUploadTask.m b/Firebase/Storage/FIRStorageUploadTask.m
index f9f6275..dd3b329 100644
--- a/Firebase/Storage/FIRStorageUploadTask.m
+++ b/Firebase/Storage/FIRStorageUploadTask.m
@@ -108,7 +108,7 @@
}
uploadFetcher.maxRetryInterval = self.reference.storage.maxUploadRetryTime;
-
+
__weak FIRStorageUploadTask* weakSelf = self;
[uploadFetcher setSendProgressBlock:^(int64_t bytesSent, int64_t totalBytesSent,
@@ -125,7 +125,7 @@
// Process fetches
self.state = FIRStorageTaskStateRunning;
-
+
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Warc-retain-cycles"
_fetcherCompletion = ^(NSData *_Nullable data,
@@ -170,7 +170,7 @@
_fetcherCompletion = nil;
};
#pragma clang diagnostic pop
-
+
[_uploadFetcher beginFetchWithCompletionHandler:^(NSData *_Nullable data,
NSError *_Nullable error) {
weakSelf.fetcherCompletion(data, error);
diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md
index 2572425..7d47907 100644
--- a/PULL_REQUEST_TEMPLATE.md
+++ b/PULL_REQUEST_TEMPLATE.md
@@ -1,10 +1,10 @@
-Hey there! So you want to contribute to a Firebase SDK?
+Hey there! So you want to contribute to a Firebase SDK?
Before you file this pull request, please read these guidelines:
### Discussion
* Read the contribution guidelines (CONTRIBUTING.md).
- * If this has been discussed in an issue, make sure to link to the issue here.
+ * If this has been discussed in an issue, make sure to link to the issue here.
If not, go file an issue about this **before creating a pull request** to discuss.
### Testing
@@ -14,6 +14,6 @@ Before you file this pull request, please read these guidelines:
### API Changes
- * At this time we cannot accept changes that affect the public API. If you'd like to help
- us make Firebase APIs better, please propose your change in a feature request so that we
+ * At this time we cannot accept changes that affect the public API. If you'd like to help
+ us make Firebase APIs better, please propose your change in a feature request so that we
can discuss it together.
diff --git a/README.md b/README.md
index 184de0e..11cf907 100644
--- a/README.md
+++ b/README.md
@@ -69,7 +69,7 @@ To run the Storage Integration tests, follow the instructions in
#### Push Notifications
-Push notifications can only be delivered to specially provisioned App IDs in the developer portal. In order to actually test receiving push notifications, you will need to:
+Push notifications can only be delivered to specially provisioned App IDs in the developer portal. In order to actually test receiving push notifications, you will need to:
1. Change the bundle identifier of the sample app to something you own in your Apple Developer account, and enable that App ID for push notifications.
2. You'll also need to [upload your APNs Provider Authentication Key or certificate to the Firebase Console](https://firebase.google.com/docs/cloud-messaging/ios/certs) at **Project Settings > Cloud Messaging > [Your Firebase App]**.
@@ -80,26 +80,26 @@ Push notifications can only be delivered to specially provisioned App IDs in the
The iOS Simulator cannot register for remote notifications, and will not receive push notifications. In order to receive push notifications, you'll have to follow the steps above and run the app on a physical device.
## Community Supported Efforts
-
-We've seen an amazing amount of interest and contributions to improve the Firebase SDKs, and we are very grateful! We'd like to empower as many developers as we can to be able to use Firebase and participate in the Firebase community.
-
+
+We've seen an amazing amount of interest and contributions to improve the Firebase SDKs, and we are very grateful! We'd like to empower as many developers as we can to be able to use Firebase and participate in the Firebase community.
+
Note that if you are using CocoaPods and using the FirebaseCommunity podspec (the one in this repo), you cannot bring in Pods from the official Firebase podspec, because of duplicated symbol conflicts. If you're not using one of the open-source SDKs in this repo for development purposes, we recommend using the regular Firebase pods for the best experience.
-
+
To get started using the FirebaseCommunity SDKs, here is a typical Podfile:
-
+
```
use_frameworks!
-
+
target 'MyAppTarget' do
platform :ios, '8.0'
pod 'FirebaseCommunity', :git => 'https://github.com/firebase/firebase-ios-sdk.git'
end
-```
+```
Replace `MyAppTarget` with the name of the target in your Xcode project.
### macOS
-FirebaseAuth, FirebaseCore, FirebaseDatabase and FirebaseStorage now compile, run unit tests, and work on macOS, thanks to contributions from the community. There are a few tweaks needed, like ensuring iOS-only or macOS-only code is correctly guarded with checks for `TARGET_OS_IOS` and `TARGET_OS_OSX`.
-
+FirebaseAuth, FirebaseCore, FirebaseDatabase and FirebaseStorage now compile, run unit tests, and work on macOS, thanks to contributions from the community. There are a few tweaks needed, like ensuring iOS-only or macOS-only code is correctly guarded with checks for `TARGET_OS_IOS` and `TARGET_OS_OSX`.
+
Keep in mind that macOS is not officially supported by Firebase, and this repository is actively developed primarily for iOS. While we can catch basic unit test issues with Travis, there may be some changes where the SDK no longer works as expected on macOS. If you encounter this, please [file an issue](https://github.com/firebase/firebase-ios-sdk/issues) for it.
## Roadmap