21
21
import static com .google .firebase .appdistribution .FirebaseAppDistributionException .Status .HOST_ACTIVITY_INTERRUPTED ;
22
22
import static com .google .firebase .appdistribution .FirebaseAppDistributionException .Status .INSTALLATION_CANCELED ;
23
23
import static com .google .firebase .appdistribution .FirebaseAppDistributionException .Status .NETWORK_FAILURE ;
24
+ import static com .google .firebase .appdistribution .FirebaseAppDistributionException .Status .UNKNOWN ;
24
25
import static com .google .firebase .appdistribution .FirebaseAppDistributionException .Status .UPDATE_NOT_AVAILABLE ;
25
26
import static com .google .firebase .appdistribution .impl .ErrorMessages .AUTHENTICATION_ERROR ;
26
27
import static com .google .firebase .appdistribution .impl .ErrorMessages .JSON_PARSING_ERROR ;
42
43
import static org .junit .Assert .assertNull ;
43
44
import static org .junit .Assert .assertTrue ;
44
45
import static org .mockito .ArgumentMatchers .any ;
46
+ import static org .mockito .ArgumentMatchers .anyBoolean ;
45
47
import static org .mockito .Mockito .doReturn ;
46
48
import static org .mockito .Mockito .never ;
47
49
import static org .mockito .Mockito .spy ;
68
70
import com .google .android .gms .tasks .Tasks ;
69
71
import com .google .firebase .FirebaseApp ;
70
72
import com .google .firebase .FirebaseOptions ;
73
+ import com .google .firebase .annotations .concurrent .Blocking ;
74
+ import com .google .firebase .annotations .concurrent .Lightweight ;
71
75
import com .google .firebase .appdistribution .AppDistributionRelease ;
72
76
import com .google .firebase .appdistribution .BinaryType ;
73
77
import com .google .firebase .appdistribution .FirebaseAppDistributionException ;
@@ -137,8 +141,8 @@ public class FirebaseAppDistributionServiceImplTest {
137
141
.setDownloadUrl (TEST_URL )
138
142
.build ();
139
143
140
- private final ExecutorService lightweightExecutor = TestOnlyExecutors .lite ();
141
- private final ExecutorService blockingExecutor = TestOnlyExecutors .blocking ();
144
+ @ Lightweight private final ExecutorService lightweightExecutor = TestOnlyExecutors .lite ();
145
+ @ Blocking private final ExecutorService blockingExecutor = TestOnlyExecutors .blocking ();
142
146
143
147
private FirebaseAppDistributionImpl firebaseAppDistribution ;
144
148
private ActivityController <TestActivity > activityController ;
@@ -190,6 +194,7 @@ public void setup() throws FirebaseAppDistributionException {
190
194
191
195
when (mockTesterSignInManager .signInTester ()).thenReturn (Tasks .forResult (null ));
192
196
when (mockSignInStorage .getSignInStatus ()).thenReturn (Tasks .forResult (true ));
197
+ when (mockSignInStorage .setSignInStatus (anyBoolean ())).thenReturn (Tasks .forResult (null ));
193
198
194
199
when (mockInstallationTokenResult .getToken ()).thenReturn (TEST_AUTH_TOKEN );
195
200
@@ -506,12 +511,33 @@ private AlertDialog assertAlertDialogShown() {
506
511
}
507
512
508
513
@ Test
509
- public void signOutTester_setsSignInStatusFalse () throws InterruptedException {
514
+ public void signOutTester_setsSignInStatusFalse () {
510
515
firebaseAppDistribution .signOutTester ();
511
- awaitTermination ( lightweightExecutor );
516
+
512
517
verify (mockSignInStorage ).setSignInStatus (false );
513
518
}
514
519
520
+ @ Test
521
+ public void signOutTester_unsetsCachedNewRelease ()
522
+ throws InterruptedException , FirebaseAppDistributionException , ExecutionException {
523
+ Task <AppDistributionReleaseInternal > setCachedNewReleaseTask =
524
+ firebaseAppDistribution .getCachedNewRelease ().set (TEST_RELEASE_NEWER_AAB_INTERNAL );
525
+
526
+ // Confirm that the cached new release is initially set
527
+ awaitTask (setCachedNewReleaseTask );
528
+ assertThat (setCachedNewReleaseTask .getResult ()).isEqualTo (TEST_RELEASE_NEWER_AAB_INTERNAL );
529
+
530
+ // Sign out the tester
531
+ firebaseAppDistribution .signOutTester ();
532
+ awaitAsyncOperations (lightweightExecutor );
533
+
534
+ // Confirm that the cached new release is now null
535
+ Task <AppDistributionReleaseInternal > cachedNewReleaseTask =
536
+ firebaseAppDistribution .getCachedNewRelease ().get ();
537
+ awaitTask (cachedNewReleaseTask );
538
+ assertThat (cachedNewReleaseTask .getResult ()).isNull ();
539
+ }
540
+
515
541
@ Test
516
542
public void updateIfNewReleaseAvailable_receiveProgressUpdateFromUpdateApp ()
517
543
throws InterruptedException {
@@ -759,8 +785,7 @@ public boolean isFinishing() {
759
785
public void startFeedback_screenshotFails_startActivityWithNoScreenshot ()
760
786
throws InterruptedException {
761
787
when (mockScreenshotTaker .takeScreenshot ())
762
- .thenReturn (
763
- Tasks .forException (new FirebaseAppDistributionException ("Error" , Status .UNKNOWN )));
788
+ .thenReturn (Tasks .forException (new FirebaseAppDistributionException ("Error" , UNKNOWN )));
764
789
when (mockReleaseIdentifier .identifyRelease ()).thenReturn (Tasks .forResult ("release-name" ));
765
790
766
791
firebaseAppDistribution .startFeedback ("Some terms and conditions" );
@@ -781,7 +806,7 @@ public void startFeedback_signInTesterFails_logsAndSetsInProgressToFalse()
781
806
throws InterruptedException {
782
807
when (mockReleaseIdentifier .identifyRelease ()).thenReturn (Tasks .forResult ("release-name" ));
783
808
FirebaseAppDistributionException exception =
784
- new FirebaseAppDistributionException ("Error" , Status . UNKNOWN );
809
+ new FirebaseAppDistributionException ("Error" , UNKNOWN );
785
810
when (mockTesterSignInManager .signInTester ()).thenReturn (Tasks .forException (exception ));
786
811
787
812
firebaseAppDistribution .startFeedback ("Some terms and conditions" );
@@ -795,7 +820,7 @@ public void startFeedback_signInTesterFails_logsAndSetsInProgressToFalse()
795
820
public void startFeedback_cantIdentifyRelease_logsAndSetsInProgressToFalse ()
796
821
throws InterruptedException {
797
822
FirebaseAppDistributionException exception =
798
- new FirebaseAppDistributionException ("Error" , Status . UNKNOWN );
823
+ new FirebaseAppDistributionException ("Error" , UNKNOWN );
799
824
when (mockReleaseIdentifier .identifyRelease ()).thenReturn (Tasks .forException (exception ));
800
825
801
826
firebaseAppDistribution .startFeedback ("Some terms and conditions" );
0 commit comments