Created
October 24, 2019 08:42
-
-
Save malvinstn/09394a7363ce301984cd81706dca45be 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_DownloadFails() { | |
// 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.downloadFails() | |
// Perform a click on the Snackbar to retry the update process. | |
onView( | |
allOf( | |
isDescendantOfA(instanceOf(Snackbar.SnackbarLayout::class.java)), | |
instanceOf(AppCompatButton::class.java) | |
) | |
).perform(ViewActions.click()) | |
// Validate that update is not completed and app is not restarted. | |
assertFalse(fakeAppUpdateManager.isInstallSplashScreenVisible) | |
// Validate that Flexible update is prompted to the user again. | |
assertTrue(fakeAppUpdateManager.isConfirmationDialogVisible) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi Actually i am stuck in this line and getting assertTrue(fakeAppUpdateManager.isConfirmationDialogVisible) false .
Could you please help here.