Skip to content

Instantly share code, notes, and snippets.

@malvinstn
Created October 24, 2019 08:42
Show Gist options
  • Save malvinstn/09394a7363ce301984cd81706dca45be to your computer and use it in GitHub Desktop.
Save malvinstn/09394a7363ce301984cd81706dca45be to your computer and use it in GitHub Desktop.
Sample integration test with FakeAppUpdateManager to validate in app update implementation.
@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)
}
@SurenderJangir
Copy link

Hi Actually i am stuck in this line and getting assertTrue(fakeAppUpdateManager.isConfirmationDialogVisible) false .
Could you please help here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment