Skip to content

Some cleanup in AabUpdaterTest #3921

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 19, 2022
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
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public void updateAppTask_emptyLocationHeader_setsDownloadFailure() throws Inter

@Test
public void updateAppTask_whenAabReleaseAvailable_redirectsToPlay() throws Exception {
TestOnProgressListener listener = new TestOnProgressListener(1);
TestOnProgressListener listener = TestOnProgressListener.withExpectedCount(1);
UpdateTask updateTask = aabUpdater.updateAab(TEST_RELEASE_NEWER_AAB_INTERNAL);
updateTask.addOnProgressListener(testExecutor, listener);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import java.util.concurrent.TimeUnit;

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

TestOnProgressListener(int expectedProgressCount) {
private TestOnProgressListener(int expectedProgressCount) {
this.expectedProgressCount = expectedProgressCount;
this.latch = new CountDownLatch(expectedProgressCount);
}

static TestOnProgressListener withExpectedCount(int expectedCount) {
return new TestOnProgressListener(expectedCount);
}

@Override
public void onProgressUpdate(@NonNull UpdateProgress updateProgress) {
progressUpdates.add(updateProgress);
Expand Down