65
65
import com .google .firebase .appdistribution .UpdateStatus ;
66
66
import com .google .firebase .appdistribution .UpdateTask ;
67
67
import com .google .firebase .concurrent .FirebaseExecutors ;
68
+ import com .google .firebase .concurrent .TestOnlyExecutors ;
68
69
import com .google .firebase .installations .InstallationTokenResult ;
69
70
import java .util .ArrayList ;
70
71
import java .util .List ;
@@ -119,7 +120,7 @@ public class FirebaseAppDistributionServiceImplTest {
119
120
.setDownloadUrl (TEST_URL )
120
121
.build ();
121
122
122
- private final ExecutorService testExecutor = Executors . newSingleThreadExecutor ();
123
+ private final ExecutorService lightweightExecutor = TestOnlyExecutors . lite ();
123
124
124
125
private FirebaseAppDistributionImpl firebaseAppDistribution ;
125
126
private TestActivity activity ;
@@ -161,7 +162,7 @@ public void setup() throws FirebaseAppDistributionException {
161
162
mockAabUpdater ,
162
163
mockSignInStorage ,
163
164
mockLifecycleNotifier ,
164
- testExecutor ));
165
+ lightweightExecutor ));
165
166
166
167
when (mockTesterSignInManager .signInTester ()).thenReturn (Tasks .forResult (null ));
167
168
when (mockSignInStorage .getSignInStatus ()).thenReturn (true );
@@ -236,7 +237,7 @@ public void checkForNewRelease_authenticationFailure_signOutTester() throws Inte
236
237
Task <AppDistributionRelease > task = firebaseAppDistribution .checkForNewRelease ();
237
238
238
239
awaitTaskFailure (task , AUTHENTICATION_FAILURE , "Test" );
239
- awaitTermination (testExecutor );
240
+ awaitTermination (lightweightExecutor );
240
241
verify (mockSignInStorage , times (1 )).setSignInStatus (false );
241
242
}
242
243
@@ -256,7 +257,7 @@ public void updateIfNewReleaseAvailable_whenNewAabReleaseAvailable_showsUpdateDi
256
257
.thenReturn (Tasks .forResult ((TEST_RELEASE_NEWER_AAB_INTERNAL )));
257
258
258
259
firebaseAppDistribution .updateIfNewReleaseAvailable ();
259
- awaitAsyncOperations (testExecutor );
260
+ awaitAsyncOperations (lightweightExecutor );
260
261
261
262
AlertDialog dialog = assertAlertDialogShown ();
262
263
assertEquals (
@@ -290,7 +291,7 @@ public void updateIfNewReleaseAvailable_whenReleaseNotesEmpty_doesNotShowRelease
290
291
(TEST_RELEASE_NEWER_AAB_INTERNAL .toBuilder ().setReleaseNotes ("" ).build ())));
291
292
292
293
firebaseAppDistribution .updateIfNewReleaseAvailable ();
293
- awaitAsyncOperations (testExecutor );
294
+ awaitAsyncOperations (lightweightExecutor );
294
295
295
296
AlertDialog dialog = assertAlertDialogShown ();
296
297
assertEquals (
@@ -309,7 +310,7 @@ public void updateIfNewReleaseAvailable_whenNoReleaseAvailable_updateDialogNotSh
309
310
310
311
List <UpdateProgress > progressEvents = new ArrayList <>();
311
312
task .addOnProgressListener (FirebaseExecutors .directExecutor (), progressEvents ::add );
312
- awaitTermination (testExecutor );
313
+ awaitTermination (lightweightExecutor );
313
314
314
315
assertEquals (1 , progressEvents .size ());
315
316
assertEquals (UpdateStatus .NEW_RELEASE_NOT_AVAILABLE , progressEvents .get (0 ).getUpdateStatus ());
@@ -325,7 +326,7 @@ public void updateIfNewReleaseAvailable_whenActivityBackgrounded_updateDialogNot
325
326
326
327
List <UpdateProgress > progressEvents = new ArrayList <>();
327
328
task .addOnProgressListener (FirebaseExecutors .directExecutor (), progressEvents ::add );
328
- awaitTermination (testExecutor );
329
+ awaitTermination (lightweightExecutor );
329
330
330
331
assertEquals (1 , progressEvents .size ());
331
332
assertEquals (UpdateStatus .NEW_RELEASE_NOT_AVAILABLE , progressEvents .get (0 ).getUpdateStatus ());
@@ -375,7 +376,7 @@ public void updateIfNewReleaseAvailable_whenDialogDismissed_taskFails()
375
376
.thenReturn (Tasks .forResult (TEST_RELEASE_NEWER_AAB_INTERNAL ));
376
377
377
378
UpdateTask updateTask = firebaseAppDistribution .updateIfNewReleaseAvailable ();
378
- awaitAsyncOperations (testExecutor );
379
+ awaitAsyncOperations (lightweightExecutor );
379
380
380
381
AlertDialog updateDialog = assertAlertDialogShown ();
381
382
updateDialog .getButton (AlertDialog .BUTTON_NEGATIVE ).performClick (); // dismiss dialog
@@ -393,7 +394,7 @@ public void updateIfNewReleaseAvailable_whenDialogCanceled_taskFails()
393
394
UpdateTask updateTask = firebaseAppDistribution .updateIfNewReleaseAvailable ();
394
395
395
396
// Task callbacks happen on the executor
396
- awaitTermination (testExecutor );
397
+ awaitTermination (lightweightExecutor );
397
398
398
399
// Show update confirmation dialog happens on the UI thread
399
400
shadowOf (getMainLooper ()).idle ();
@@ -469,7 +470,7 @@ private AlertDialog assertAlertDialogShown() {
469
470
@ Test
470
471
public void signOutTester_setsSignInStatusFalse () throws InterruptedException {
471
472
firebaseAppDistribution .signOutTester ();
472
- awaitTermination (testExecutor );
473
+ awaitTermination (lightweightExecutor );
473
474
verify (mockSignInStorage ).setSignInStatus (false );
474
475
}
475
476
@@ -491,12 +492,12 @@ public void updateIfNewReleaseAvailable_receiveProgressUpdateFromUpdateApp()
491
492
492
493
List <UpdateProgress > progressEvents = new ArrayList <>();
493
494
updateTask .addOnProgressListener (FirebaseExecutors .directExecutor (), progressEvents ::add );
494
- awaitAsyncOperations (testExecutor );
495
+ awaitAsyncOperations (lightweightExecutor );
495
496
496
497
// Clicking the update button.
497
498
AlertDialog updateDialog = (AlertDialog ) ShadowAlertDialog .getLatestDialog ();
498
499
updateDialog .getButton (Dialog .BUTTON_POSITIVE ).performClick ();
499
- awaitAsyncOperations (testExecutor );
500
+ awaitAsyncOperations (lightweightExecutor );
500
501
501
502
// Update flow
502
503
assertEquals (1 , progressEvents .size ());
@@ -541,7 +542,7 @@ public void updateIfNewReleaseAvailable_whenScreenRotates_updateDialogReappears(
541
542
when (activity .isChangingConfigurations ()).thenReturn (true );
542
543
543
544
UpdateTask updateTask = firebaseAppDistribution .updateIfNewReleaseAvailable ();
544
- awaitAsyncOperations (testExecutor );
545
+ awaitAsyncOperations (lightweightExecutor );
545
546
546
547
// Mimic activity recreation due to a configuration change
547
548
firebaseAppDistribution .onActivityDestroyed (activity );
@@ -576,7 +577,7 @@ public void updateIfNewReleaseAvailable_whenScreenRotates_updateDialogReappears(
576
577
when (mockNewReleaseFetcher .checkForNewRelease ()).thenReturn (Tasks .forResult (newRelease ));
577
578
578
579
UpdateTask updateTask = firebaseAppDistribution .updateIfNewReleaseAvailable ();
579
- awaitAsyncOperations (testExecutor );
580
+ awaitAsyncOperations (lightweightExecutor );
580
581
581
582
// Mimic different activity getting resumed
582
583
firebaseAppDistribution .onActivityPaused (activity );
0 commit comments