Skip to content

Instantly share code, notes, and snippets.

@malvinstn
Created October 24, 2019 08:38
Show Gist options
  • Save malvinstn/d96e40cd70ac1bb2f41f0402a8a8f3df to your computer and use it in GitHub Desktop.
Save malvinstn/d96e40cd70ac1bb2f41f0402a8a8f3df to your computer and use it in GitHub Desktop.
Sample integration test with FakeAppUpdateManager to validate in app update implementation.
@Test
fun testImmediateUpdate_Completes() {
// Setup immediate update.
fakeAppUpdateManager.partiallyAllowedUpdateType = AppUpdateType.IMMEDIATE
fakeAppUpdateManager.setUpdateAvailable(2)
ActivityScenario.launch(MainActivity::class.java)
// Validate that immediate update is prompted to the user.
assertTrue(fakeAppUpdateManager.isImmediateFlowVisible)
// Simulate user's and download behavior.
fakeAppUpdateManager.userAcceptsUpdate()
fakeAppUpdateManager.downloadStarts()
fakeAppUpdateManager.downloadCompletes()
// Validate that update is completed and app is restarted.
assertTrue(fakeAppUpdateManager.isInstallSplashScreenVisible)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment