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,30 @@ 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 () throws InterruptedException , FirebaseAppDistributionException , ExecutionException {
522
+ Task <AppDistributionReleaseInternal > setCachedNewReleaseTask = firebaseAppDistribution .getCachedNewRelease ().set (TEST_RELEASE_NEWER_AAB_INTERNAL );
523
+
524
+ // Confirm that the cached new release is initially set
525
+ awaitTask (setCachedNewReleaseTask );
526
+ assertThat (setCachedNewReleaseTask .getResult ()).isEqualTo (TEST_RELEASE_NEWER_AAB_INTERNAL );
527
+
528
+ // Sign out the tester
529
+ firebaseAppDistribution .signOutTester ();
530
+ awaitAsyncOperations (lightweightExecutor );
531
+
532
+ // Confirm that the cached new release is now null
533
+ Task <AppDistributionReleaseInternal > cachedNewReleaseTask = firebaseAppDistribution .getCachedNewRelease ().get ();
534
+ awaitTask (cachedNewReleaseTask );
535
+ assertThat (cachedNewReleaseTask .getResult ()).isNull ();
536
+ }
537
+
515
538
@ Test
516
539
public void updateIfNewReleaseAvailable_receiveProgressUpdateFromUpdateApp ()
517
540
throws InterruptedException {
@@ -760,7 +783,7 @@ public void startFeedback_screenshotFails_startActivityWithNoScreenshot()
760
783
throws InterruptedException {
761
784
when (mockScreenshotTaker .takeScreenshot ())
762
785
.thenReturn (
763
- Tasks .forException (new FirebaseAppDistributionException ("Error" , Status . UNKNOWN )));
786
+ Tasks .forException (new FirebaseAppDistributionException ("Error" , UNKNOWN )));
764
787
when (mockReleaseIdentifier .identifyRelease ()).thenReturn (Tasks .forResult ("release-name" ));
765
788
766
789
firebaseAppDistribution .startFeedback ("Some terms and conditions" );
@@ -781,7 +804,7 @@ public void startFeedback_signInTesterFails_logsAndSetsInProgressToFalse()
781
804
throws InterruptedException {
782
805
when (mockReleaseIdentifier .identifyRelease ()).thenReturn (Tasks .forResult ("release-name" ));
783
806
FirebaseAppDistributionException exception =
784
- new FirebaseAppDistributionException ("Error" , Status . UNKNOWN );
807
+ new FirebaseAppDistributionException ("Error" , UNKNOWN );
785
808
when (mockTesterSignInManager .signInTester ()).thenReturn (Tasks .forException (exception ));
786
809
787
810
firebaseAppDistribution .startFeedback ("Some terms and conditions" );
@@ -795,7 +818,7 @@ public void startFeedback_signInTesterFails_logsAndSetsInProgressToFalse()
795
818
public void startFeedback_cantIdentifyRelease_logsAndSetsInProgressToFalse ()
796
819
throws InterruptedException {
797
820
FirebaseAppDistributionException exception =
798
- new FirebaseAppDistributionException ("Error" , Status . UNKNOWN );
821
+ new FirebaseAppDistributionException ("Error" , UNKNOWN );
799
822
when (mockReleaseIdentifier .identifyRelease ()).thenReturn (Tasks .forException (exception ));
800
823
801
824
firebaseAppDistribution .startFeedback ("Some terms and conditions" );
0 commit comments