Skip to content

Commit 04a16f2

Browse files
author
Manny Jimenez
committed
Responding to feedback and moving tests to their respective clients
1 parent b744e3f commit 04a16f2

File tree

4 files changed

+33
-40
lines changed

4 files changed

+33
-40
lines changed

firebase-app-distribution/src/main/java/com/google/firebase/app/distribution/FirebaseAppDistribution.java

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -237,31 +237,30 @@ public UpdateTask updateApp() {
237237
* Overloaded updateApp with boolean input showDownloadInNotificationsManager. Set to true for
238238
* basic configuration and false for advanced configuration.
239239
*/
240-
private UpdateTask updateApp(boolean showDownloadInNotificationManager) {
240+
public UpdateTask updateApp(boolean showDownloadInNotificationManager) {
241241
if (!isTesterSignedIn()) {
242242
UpdateTaskImpl updateTask = new UpdateTaskImpl();
243243
updateTask.setException(
244244
new FirebaseAppDistributionException(
245245
Constants.ErrorMessages.AUTHENTICATION_ERROR, AUTHENTICATION_FAILURE));
246246
return updateTask;
247247
}
248+
synchronized (cachedNewReleaseLock) {
249+
if (cachedNewRelease == null) {
250+
LogWrapper.getInstance().v("New release not found.");
251+
return getErrorUpdateTask(
252+
new FirebaseAppDistributionException(
253+
Constants.ErrorMessages.NOT_FOUND_ERROR, UPDATE_NOT_AVAILABLE));
254+
}
248255

249-
if (cachedNewRelease == null) {
250-
LogWrapper.getInstance().v("New release not found.");
251-
return getErrorUpdateTask(
252-
new FirebaseAppDistributionException(
253-
Constants.ErrorMessages.NOT_FOUND_ERROR, UPDATE_NOT_AVAILABLE));
254-
}
255-
256-
if (cachedNewRelease.getDownloadUrl() == null) {
257-
LogWrapper.getInstance().v("Download failed to execute");
258-
return getErrorUpdateTask(
259-
new FirebaseAppDistributionException(
260-
Constants.ErrorMessages.DOWNLOAD_URL_NOT_FOUND,
261-
FirebaseAppDistributionException.Status.DOWNLOAD_FAILURE));
262-
}
256+
if (cachedNewRelease.getDownloadUrl() == null) {
257+
LogWrapper.getInstance().v("Download failed to execute");
258+
return getErrorUpdateTask(
259+
new FirebaseAppDistributionException(
260+
Constants.ErrorMessages.DOWNLOAD_URL_NOT_FOUND,
261+
FirebaseAppDistributionException.Status.DOWNLOAD_FAILURE));
262+
}
263263

264-
synchronized (cachedNewReleaseLock) {
265264
if (cachedNewRelease.getBinaryType() == BinaryType.AAB) {
266265
return this.updateAabClient.updateAab(cachedNewRelease);
267266
} else {

firebase-app-distribution/src/test/java/com/google/firebase/app/distribution/FirebaseAppDistributionTest.java

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -437,30 +437,6 @@ public void taskCancelledOnScreenRotation() {
437437
assertEquals(INSTALLATION_CANCELED, e.getErrorCode());
438438
}
439439

440-
@Test
441-
public void updateApp_whenCalledMultipleTimesWithAAB_returnsSameUpdateTask() {
442-
when(mockSignInStorage.getSignInStatus()).thenReturn(true);
443-
AppDistributionReleaseInternal newRelease = TEST_RELEASE_NEWER_AAB_INTERNAL.build();
444-
firebaseAppDistribution.setCachedNewRelease(newRelease);
445-
446-
UpdateTask updateTask1 = firebaseAppDistribution.updateApp(true);
447-
UpdateTask updateTask2 = firebaseAppDistribution.updateApp(true);
448-
449-
assertEquals(updateTask1, updateTask2);
450-
}
451-
452-
@Test
453-
public void updateApp_whenCalledMultipleTimesWithApk_returnsSameUpdateTask() {
454-
when(mockSignInStorage.getSignInStatus()).thenReturn(true);
455-
AppDistributionReleaseInternal newRelease = TEST_RELEASE_NEWER_APK_INTERNAL.build();
456-
firebaseAppDistribution.setCachedNewRelease(newRelease);
457-
458-
UpdateTask updateTask1 = firebaseAppDistribution.updateApp();
459-
UpdateTask updateTask2 = firebaseAppDistribution.updateApp();
460-
461-
assertEquals(updateTask1, updateTask2);
462-
}
463-
464440
@Test
465441
public void updateAppTask_whenNoReleaseAvailable_throwsError() {
466442
firebaseAppDistribution.setCachedNewRelease(null);

firebase-app-distribution/src/test/java/com/google/firebase/app/distribution/UpdateAabClientTest.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,4 +145,14 @@ public void updateAppTask_onAppResume_setsUpdateCancelled()
145145
assertThrows(FirebaseAppDistributionException.class, onCompleteListener::await);
146146
assertEquals(ReleaseUtils.convertToAppDistributionRelease(newRelease), exception.getRelease());
147147
}
148+
149+
@Test
150+
public void updateApp_whenCalledMultipleTimesWithAAB_returnsSameUpdateTask() {
151+
AppDistributionReleaseInternal newRelease = TEST_RELEASE_NEWER_AAB_INTERNAL.build();
152+
153+
UpdateTask updateTask1 = updateAabClient.updateAab(newRelease);
154+
UpdateTask updateTask2 = updateAabClient.updateAab(newRelease);
155+
156+
assertEquals(updateTask1, updateTask2);
157+
}
148158
}

firebase-app-distribution/src/test/java/com/google/firebase/app/distribution/UpdateApkClientTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,4 +209,12 @@ public void postProgressUpdate_whenErrorStatus_updatesNotificationsManagerWithEr
209209
updateApkClient.postUpdateProgress(1000, 900, UpdateStatus.DOWNLOADING, false);
210210
assertEquals(0, shadowNotificationManager.size());
211211
}
212+
213+
@Test
214+
public void updateApp_whenCalledMultipleTimesWithApk_returnsSameUpdateTask() {
215+
UpdateTask updateTask1 = updateApkClient.updateApk(TEST_RELEASE, false);
216+
UpdateTask updateTask2 = updateApkClient.updateApk(TEST_RELEASE, false);
217+
218+
assertEquals(updateTask1, updateTask2);
219+
}
212220
}

0 commit comments

Comments
 (0)