Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion FirebaseDatabase/Tests/Helpers/FTestContants.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@
#define Firebase_FTestContants_h

#define kFirebaseTestTimeout 7
#define kFirebaseTestWaitUntilTimeout 5
#define kFirebaseTestWaitUntilTimeout 10

#endif
55 changes: 24 additions & 31 deletions FirebaseDatabase/Tests/Integration/FEventTests.m
Original file line number Diff line number Diff line change
Expand Up @@ -362,42 +362,35 @@ - (void)testOnceValueFiresExactlyOnce {
}

- (void)testOnceChildAddedFiresExactlyOnce {
__block int badCount = 0;
for (int i = 0; i < 100; i++) {
FIRDatabaseReference* path = [FTestHelpers getRandomNode];
__block BOOL firstCall = YES;

// for(int i = 0; i < 100; i++) {
__block BOOL done = NO;

FIRDatabaseReference* path = [FTestHelpers getRandomNode];
__block BOOL firstCall = YES;

__block BOOL done = NO;

[path observeSingleEventOfType:FIRDataEventTypeChildAdded
withBlock:^(FIRDataSnapshot* snapshot) {
XCTAssertTrue(firstCall, @"Properly saw first call");
firstCall = NO;
XCTAssertEqualObjects(@42, [snapshot value], @"Properly saw node value");
XCTAssertEqualObjects(@"foo", [snapshot key],
@"Properly saw the first node");
if (![[snapshot value] isEqual:@42]) {
exit(-1);
badCount = badCount + 1;
}

done = YES;
}];

[[path child:@"foo"] setValue:@42];
[[path child:@"bar"] setValue:@84]; // XXX FIXME sometimes this event fires first
[[path child:@"foo"] setValue:@168];
[path observeSingleEventOfType:FIRDataEventTypeChildAdded
withBlock:^(FIRDataSnapshot* snapshot) {
XCTAssertTrue(firstCall, @"Properly saw first call");
firstCall = NO;
XCTAssertEqualObjects(@42, [snapshot value], @"Properly saw node value");
XCTAssertEqualObjects(@"foo", [snapshot key],
@"Properly saw the first node");
if (![[snapshot value] isEqual:@42]) {
exit(-1);
}

// [path setValue:nil withCompletionBlock:^(BOOL status) { done = YES; }];
[self waitUntil:^BOOL {
return done;
}];
done = YES;
}];

// }
[[path child:@"foo"] setValue:@42];
[[path child:@"bar"] setValue:@84]; // XXX FIXME sometimes this event fires first
[[path child:@"foo"] setValue:@168];

NSLog(@"BADCOUNT: %d", badCount);
// [path setValue:nil withCompletionBlock:^(BOOL status) { done = YES; }];
[self waitUntil:^BOOL {
return done;
}];
}
}

- (void)testOnceValueFiresExactlyOnceEvenIfThereIsASetInsideCallback {
Expand Down
2 changes: 1 addition & 1 deletion scripts/run_database_emulator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

set -euo pipefail

VERSION='4.7.2'
VERSION='4.12.0'
FILENAME="firebase-database-emulator-v${VERSION}.jar"
URL="https://storage.googleapis.com/firebase-preview-drop/emulator/${FILENAME}"

Expand Down
Loading