Skip to content

Commit 8bd97a4

Browse files
authored
Some cleanup in AabUpdaterTest (#3921)
1 parent e2e41f5 commit 8bd97a4

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

firebase-appdistribution/src/test/java/com/google/firebase/appdistribution/impl/AabUpdaterTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public void updateAppTask_emptyLocationHeader_setsDownloadFailure() throws Inter
142142

143143
@Test
144144
public void updateAppTask_whenAabReleaseAvailable_redirectsToPlay() throws Exception {
145-
TestOnProgressListener listener = new TestOnProgressListener(1);
145+
TestOnProgressListener listener = TestOnProgressListener.withExpectedCount(1);
146146
UpdateTask updateTask = aabUpdater.updateAab(TEST_RELEASE_NEWER_AAB_INTERNAL);
147147
updateTask.addOnProgressListener(testExecutor, listener);
148148

firebase-appdistribution/src/test/java/com/google/firebase/appdistribution/impl/TestOnProgressListener.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
import java.util.concurrent.TimeUnit;
2424

2525
/**
26-
* Helper listener that awaits a specific number of progress events on a {@code UpdateTask}.
26+
* Helper listener that awaits a specific number of progress events on an {@code UpdateTask}.
2727
*
2828
* <p>This works around a limitation of the Tasks API where await() cannot be called on the main
2929
* thread. This listener works around it by running itself on a different thread, thus allowing the
@@ -38,11 +38,15 @@ class TestOnProgressListener implements OnProgressListener {
3838
private final CountDownLatch latch;
3939
private final List<UpdateProgress> progressUpdates = new ArrayList<>();
4040

41-
TestOnProgressListener(int expectedProgressCount) {
41+
private TestOnProgressListener(int expectedProgressCount) {
4242
this.expectedProgressCount = expectedProgressCount;
4343
this.latch = new CountDownLatch(expectedProgressCount);
4444
}
4545

46+
static TestOnProgressListener withExpectedCount(int expectedCount) {
47+
return new TestOnProgressListener(expectedCount);
48+
}
49+
4650
@Override
4751
public void onProgressUpdate(@NonNull UpdateProgress updateProgress) {
4852
progressUpdates.add(updateProgress);

0 commit comments

Comments
 (0)