-
Notifications
You must be signed in to change notification settings - Fork 625
Do not wait to store state when signing out #4490
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,6 +21,7 @@ | |
import static com.google.firebase.appdistribution.FirebaseAppDistributionException.Status.HOST_ACTIVITY_INTERRUPTED; | ||
import static com.google.firebase.appdistribution.FirebaseAppDistributionException.Status.INSTALLATION_CANCELED; | ||
import static com.google.firebase.appdistribution.FirebaseAppDistributionException.Status.NETWORK_FAILURE; | ||
import static com.google.firebase.appdistribution.FirebaseAppDistributionException.Status.UNKNOWN; | ||
import static com.google.firebase.appdistribution.FirebaseAppDistributionException.Status.UPDATE_NOT_AVAILABLE; | ||
import static com.google.firebase.appdistribution.impl.ErrorMessages.AUTHENTICATION_ERROR; | ||
import static com.google.firebase.appdistribution.impl.ErrorMessages.JSON_PARSING_ERROR; | ||
|
@@ -42,6 +43,7 @@ | |
import static org.junit.Assert.assertNull; | ||
import static org.junit.Assert.assertTrue; | ||
import static org.mockito.ArgumentMatchers.any; | ||
import static org.mockito.ArgumentMatchers.anyBoolean; | ||
import static org.mockito.Mockito.doReturn; | ||
import static org.mockito.Mockito.never; | ||
import static org.mockito.Mockito.spy; | ||
|
@@ -68,6 +70,8 @@ | |
import com.google.android.gms.tasks.Tasks; | ||
import com.google.firebase.FirebaseApp; | ||
import com.google.firebase.FirebaseOptions; | ||
import com.google.firebase.annotations.concurrent.Blocking; | ||
import com.google.firebase.annotations.concurrent.Lightweight; | ||
import com.google.firebase.appdistribution.AppDistributionRelease; | ||
import com.google.firebase.appdistribution.BinaryType; | ||
import com.google.firebase.appdistribution.FirebaseAppDistributionException; | ||
|
@@ -137,8 +141,8 @@ public class FirebaseAppDistributionServiceImplTest { | |
.setDownloadUrl(TEST_URL) | ||
.build(); | ||
|
||
private final ExecutorService lightweightExecutor = TestOnlyExecutors.lite(); | ||
private final ExecutorService blockingExecutor = TestOnlyExecutors.blocking(); | ||
@Lightweight private final ExecutorService lightweightExecutor = TestOnlyExecutors.lite(); | ||
@Blocking private final ExecutorService blockingExecutor = TestOnlyExecutors.blocking(); | ||
|
||
private FirebaseAppDistributionImpl firebaseAppDistribution; | ||
private ActivityController<TestActivity> activityController; | ||
|
@@ -190,6 +194,7 @@ public void setup() throws FirebaseAppDistributionException { | |
|
||
when(mockTesterSignInManager.signInTester()).thenReturn(Tasks.forResult(null)); | ||
when(mockSignInStorage.getSignInStatus()).thenReturn(Tasks.forResult(true)); | ||
when(mockSignInStorage.setSignInStatus(anyBoolean())).thenReturn(Tasks.forResult(null)); | ||
|
||
when(mockInstallationTokenResult.getToken()).thenReturn(TEST_AUTH_TOKEN); | ||
|
||
|
@@ -506,12 +511,33 @@ private AlertDialog assertAlertDialogShown() { | |
} | ||
|
||
@Test | ||
public void signOutTester_setsSignInStatusFalse() throws InterruptedException { | ||
public void signOutTester_setsSignInStatusFalse() { | ||
firebaseAppDistribution.signOutTester(); | ||
awaitTermination(lightweightExecutor); | ||
|
||
verify(mockSignInStorage).setSignInStatus(false); | ||
} | ||
|
||
@Test | ||
public void signOutTester_unsetsCachedNewRelease() | ||
throws InterruptedException, FirebaseAppDistributionException, ExecutionException { | ||
Task<AppDistributionReleaseInternal> setCachedNewReleaseTask = | ||
firebaseAppDistribution.getCachedNewRelease().set(TEST_RELEASE_NEWER_AAB_INTERNAL); | ||
|
||
// Confirm that the cached new release is initially set | ||
awaitTask(setCachedNewReleaseTask); | ||
assertThat(setCachedNewReleaseTask.getResult()).isEqualTo(TEST_RELEASE_NEWER_AAB_INTERNAL); | ||
|
||
// Sign out the tester | ||
firebaseAppDistribution.signOutTester(); | ||
awaitAsyncOperations(lightweightExecutor); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If I understand this change correctly, this should no be needed There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah you're right, great catch! |
||
|
||
// Confirm that the cached new release is now null | ||
Task<AppDistributionReleaseInternal> cachedNewReleaseTask = | ||
firebaseAppDistribution.getCachedNewRelease().get(); | ||
awaitTask(cachedNewReleaseTask); | ||
assertThat(cachedNewReleaseTask.getResult()).isNull(); | ||
} | ||
|
||
@Test | ||
public void updateIfNewReleaseAvailable_receiveProgressUpdateFromUpdateApp() | ||
throws InterruptedException { | ||
|
@@ -759,8 +785,7 @@ public boolean isFinishing() { | |
public void startFeedback_screenshotFails_startActivityWithNoScreenshot() | ||
throws InterruptedException { | ||
when(mockScreenshotTaker.takeScreenshot()) | ||
.thenReturn( | ||
Tasks.forException(new FirebaseAppDistributionException("Error", Status.UNKNOWN))); | ||
.thenReturn(Tasks.forException(new FirebaseAppDistributionException("Error", UNKNOWN))); | ||
when(mockReleaseIdentifier.identifyRelease()).thenReturn(Tasks.forResult("release-name")); | ||
|
||
firebaseAppDistribution.startFeedback("Some terms and conditions"); | ||
|
@@ -781,7 +806,7 @@ public void startFeedback_signInTesterFails_logsAndSetsInProgressToFalse() | |
throws InterruptedException { | ||
when(mockReleaseIdentifier.identifyRelease()).thenReturn(Tasks.forResult("release-name")); | ||
FirebaseAppDistributionException exception = | ||
new FirebaseAppDistributionException("Error", Status.UNKNOWN); | ||
new FirebaseAppDistributionException("Error", UNKNOWN); | ||
when(mockTesterSignInManager.signInTester()).thenReturn(Tasks.forException(exception)); | ||
|
||
firebaseAppDistribution.startFeedback("Some terms and conditions"); | ||
|
@@ -795,7 +820,7 @@ public void startFeedback_signInTesterFails_logsAndSetsInProgressToFalse() | |
public void startFeedback_cantIdentifyRelease_logsAndSetsInProgressToFalse() | ||
throws InterruptedException { | ||
FirebaseAppDistributionException exception = | ||
new FirebaseAppDistributionException("Error", Status.UNKNOWN); | ||
new FirebaseAppDistributionException("Error", UNKNOWN); | ||
when(mockReleaseIdentifier.identifyRelease()).thenReturn(Tasks.forException(exception)); | ||
|
||
firebaseAppDistribution.startFeedback("Some terms and conditions"); | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not a big fan of this pattern - I think, in general, we should trust (but not verify) test setup.
In this case I think you should be able to drop this comment, the blank line above it, and the assert on line 528
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good. Removed.