Skip to content

Commit 7736755

Browse files
committed
Fix test failure in CI
1 parent 122258a commit 7736755

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

firebase-appdistribution/src/main/java/com/google/firebase/appdistribution/impl/ApkUpdater.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,8 +110,7 @@ private void installApk(File file, boolean showDownloadNotificationManager) {
110110
activity -> apkInstaller.installApk(file.getPath(), activity))
111111
.addOnSuccessListener(lightweightExecutor, unused -> cachedUpdateTask.setResult())
112112
.addOnFailureListener(
113-
// TODO(lkellogg): check if this can switch to lightweight (uses NotificationManager)
114-
blockingExecutor,
113+
lightweightExecutor,
115114
e -> {
116115
postUpdateProgress(
117116
file.length(),

firebase-appdistribution/src/main/java/com/google/firebase/appdistribution/impl/TaskCache.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@
1616

1717
import com.google.android.gms.tasks.Task;
1818

19-
// TODO: replace this with TaskCompletionSourceCache and UpdateTaskCache, then rename
20-
// TaskCompletionSourceCache to TaskCache
2119
/**
2220
* A cache for Tasks, for use in cases where we only ever want one active task at a time for a
2321
* particular operation.

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,18 @@ public void updateApk_whenSuccessfullyUpdated_notificationsSetCorrectly()
183183
doReturn(new ByteArrayInputStream(TEST_FILE.getBytes()))
184184
.when(mockHttpsUrlConnection)
185185
.getInputStream();
186+
// Sleep thread to simulate actually making the request, which gives us time to add
187+
// a listener to the returned UpdateTask in time to get all the progress updates
188+
when(mockHttpsUrlConnectionFactory.openConnection(TEST_URL))
189+
.thenAnswer(
190+
invocation -> {
191+
try {
192+
Thread.sleep(100);
193+
} catch (InterruptedException e) {
194+
throw new AssertionError("Interrupted while sleeping in mock");
195+
}
196+
return mockHttpsUrlConnection;
197+
});
186198
doNothing().when(apkUpdater).validateJarFile(any(), anyLong(), anyBoolean(), anyLong());
187199
when(mockApkInstaller.installApk(any(), any())).thenReturn(Tasks.forResult(null));
188200

0 commit comments

Comments
 (0)