Last active
October 24, 2019 08:46
-
-
Save malvinstn/4074a6bd6b410af9b7177502a09e6349 to your computer and use it in GitHub Desktop.
Sample integration test with FakeAppUpdateManager to validate in app update implementation.
This file contains 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
@Test | |
fun testFlexibleUpdate_Completes() { | |
// Setup flexible update. | |
fakeAppUpdateManager.partiallyAllowedUpdateType = AppUpdateType.FLEXIBLE | |
fakeAppUpdateManager.setUpdateAvailable(2) | |
ActivityScenario.launch(MainActivity::class.java) | |
// Validate that flexible update is prompted to the user. | |
assertTrue(fakeAppUpdateManager.isConfirmationDialogVisible) | |
// Simulate user's and download behavior. | |
fakeAppUpdateManager.userAcceptsUpdate() | |
fakeAppUpdateManager.downloadStarts() | |
fakeAppUpdateManager.downloadCompletes() | |
// Perform a click on the Snackbar to complete the update process. | |
onView( | |
allOf( | |
isDescendantOfA(instanceOf(Snackbar.SnackbarLayout::class.java)), | |
instanceOf(AppCompatButton::class.java) | |
) | |
).perform(ViewActions.click()) | |
// Validate that update is completed and app is restarted. | |
assertTrue(fakeAppUpdateManager.isInstallSplashScreenVisible) | |
fakeAppUpdateManager.installCompletes() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment