Skip to content

Commit 13fb4ab

Browse files
authored
Fixed get() to propagate events to listeners (#3962)
Fixed issue where a pending get() would fail to fire events to subsequent listeners.
1 parent 9d927a5 commit 13fb4ab

File tree

4 files changed

+324
-304
lines changed

4 files changed

+324
-304
lines changed

firebase-database/src/androidTest/java/com/google/firebase/database/IntegrationTestHelpers.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,11 @@
1919
import static org.junit.Assert.assertTrue;
2020
import static org.junit.Assert.fail;
2121

22+
import androidx.test.platform.app.InstrumentationRegistry;
2223
import com.fasterxml.jackson.core.type.TypeReference;
2324
import com.fasterxml.jackson.databind.ObjectMapper;
2425
import com.google.firebase.FirebaseApp;
26+
import com.google.firebase.FirebaseOptions;
2527
import com.google.firebase.database.android.AndroidAppCheckTokenProvider;
2628
import com.google.firebase.database.android.AndroidAuthTokenProvider;
2729
import com.google.firebase.database.core.CompoundWrite;
@@ -342,6 +344,23 @@ public static DataSnapshot referenceAtPath(DatabaseReference node, EventRecord r
342344
return record.getSnapshot().child(node.getPath().toString());
343345
}
344346

347+
public static FirebaseApp appForDatabaseUrl(String url, String name) {
348+
return FirebaseApp.initializeApp(
349+
InstrumentationRegistry.getInstrumentation().getTargetContext(),
350+
new FirebaseOptions.Builder()
351+
.setApplicationId("appid")
352+
.setApiKey("apikey")
353+
.setDatabaseUrl(url)
354+
.build(),
355+
name);
356+
}
357+
358+
public static FirebaseDatabase getNewDatabase() {
359+
FirebaseApp app =
360+
appForDatabaseUrl(IntegrationTestValues.getDatabaseUrl(), UUID.randomUUID().toString());
361+
return FirebaseDatabase.getInstance(app);
362+
}
363+
345364
public static DataSnapshot getSnap(Query ref) throws InterruptedException {
346365

347366
final Semaphore semaphore = new Semaphore(0);

0 commit comments

Comments
 (0)