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,27 @@ 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
+ awaitTask (setCachedNewReleaseTask );
526
+
527
+ firebaseAppDistribution .signOutTester ();
528
+
529
+ Task <AppDistributionReleaseInternal > cachedNewReleaseTask =
530
+ firebaseAppDistribution .getCachedNewRelease ().get ();
531
+ awaitTask (cachedNewReleaseTask );
532
+ assertThat (cachedNewReleaseTask .getResult ()).isNull ();
533
+ }
534
+
515
535
@ Test
516
536
public void updateIfNewReleaseAvailable_receiveProgressUpdateFromUpdateApp ()
517
537
throws InterruptedException {
@@ -759,8 +779,7 @@ public boolean isFinishing() {
759
779
public void startFeedback_screenshotFails_startActivityWithNoScreenshot ()
760
780
throws InterruptedException {
761
781
when (mockScreenshotTaker .takeScreenshot ())
762
- .thenReturn (
763
- Tasks .forException (new FirebaseAppDistributionException ("Error" , Status .UNKNOWN )));
782
+ .thenReturn (Tasks .forException (new FirebaseAppDistributionException ("Error" , UNKNOWN )));
764
783
when (mockReleaseIdentifier .identifyRelease ()).thenReturn (Tasks .forResult ("release-name" ));
765
784
766
785
firebaseAppDistribution .startFeedback ("Some terms and conditions" );
@@ -781,7 +800,7 @@ public void startFeedback_signInTesterFails_logsAndSetsInProgressToFalse()
781
800
throws InterruptedException {
782
801
when (mockReleaseIdentifier .identifyRelease ()).thenReturn (Tasks .forResult ("release-name" ));
783
802
FirebaseAppDistributionException exception =
784
- new FirebaseAppDistributionException ("Error" , Status . UNKNOWN );
803
+ new FirebaseAppDistributionException ("Error" , UNKNOWN );
785
804
when (mockTesterSignInManager .signInTester ()).thenReturn (Tasks .forException (exception ));
786
805
787
806
firebaseAppDistribution .startFeedback ("Some terms and conditions" );
@@ -795,7 +814,7 @@ public void startFeedback_signInTesterFails_logsAndSetsInProgressToFalse()
795
814
public void startFeedback_cantIdentifyRelease_logsAndSetsInProgressToFalse ()
796
815
throws InterruptedException {
797
816
FirebaseAppDistributionException exception =
798
- new FirebaseAppDistributionException ("Error" , Status . UNKNOWN );
817
+ new FirebaseAppDistributionException ("Error" , UNKNOWN );
799
818
when (mockReleaseIdentifier .identifyRelease ()).thenReturn (Tasks .forException (exception ));
800
819
801
820
firebaseAppDistribution .startFeedback ("Some terms and conditions" );
0 commit comments