2022-05-16 04:40:50 -07:00
|
|
|
package co.electriccoin.zcash.ui.screen.update.integration
|
|
|
|
|
|
|
|
import androidx.compose.ui.test.junit4.StateRestorationTester
|
|
|
|
import androidx.compose.ui.test.junit4.createComposeRule
|
|
|
|
import androidx.compose.ui.test.onNodeWithText
|
|
|
|
import androidx.compose.ui.test.performClick
|
|
|
|
import androidx.test.filters.MediumTest
|
|
|
|
import co.electriccoin.zcash.ui.R
|
2022-07-13 00:16:05 -07:00
|
|
|
import co.electriccoin.zcash.ui.fixture.UpdateInfoFixture
|
2022-05-16 04:40:50 -07:00
|
|
|
import co.electriccoin.zcash.ui.screen.update.AppUpdateChecker
|
|
|
|
import co.electriccoin.zcash.ui.screen.update.model.UpdateInfo
|
|
|
|
import co.electriccoin.zcash.ui.screen.update.model.UpdateState
|
|
|
|
import co.electriccoin.zcash.ui.screen.update.view.UpdateViewTestSetup
|
|
|
|
import co.electriccoin.zcash.ui.test.getStringResource
|
|
|
|
import org.junit.Rule
|
|
|
|
import org.junit.Test
|
|
|
|
import kotlin.test.assertEquals
|
|
|
|
import kotlin.test.assertNotEquals
|
|
|
|
|
|
|
|
class UpdateViewIntegrationTest {
|
|
|
|
|
|
|
|
@get:Rule
|
|
|
|
val composeTestRule = createComposeRule()
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@MediumTest
|
|
|
|
fun update_info_state_restoration() {
|
|
|
|
val restorationTester = StateRestorationTester(composeTestRule)
|
|
|
|
val testSetup = newTestSetup(
|
|
|
|
UpdateInfoFixture.new(
|
|
|
|
priority = AppUpdateChecker.Priority.HIGH,
|
|
|
|
force = true,
|
|
|
|
appUpdateInfo = null,
|
2022-06-22 02:48:19 -07:00
|
|
|
state = UpdateState.Prepared
|
2022-05-16 04:40:50 -07:00
|
|
|
)
|
|
|
|
)
|
|
|
|
|
|
|
|
restorationTester.setContent {
|
2023-03-01 04:58:47 -08:00
|
|
|
testSetup.DefaultContent()
|
2022-05-16 04:40:50 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
assertEquals(testSetup.getUpdateInfo().priority, AppUpdateChecker.Priority.HIGH)
|
|
|
|
assertEquals(testSetup.getUpdateState(), UpdateState.Prepared)
|
|
|
|
|
|
|
|
composeTestRule.onNodeWithText(getStringResource(R.string.update_download_button)).also {
|
|
|
|
it.performClick()
|
|
|
|
}
|
|
|
|
|
|
|
|
// can be Running, Done, Canceled or Failed - depends on the Play API response
|
|
|
|
assertNotEquals(testSetup.getUpdateState(), UpdateState.Prepared)
|
|
|
|
|
|
|
|
restorationTester.emulateSavedInstanceStateRestore()
|
|
|
|
|
|
|
|
assertEquals(testSetup.getUpdateInfo().priority, AppUpdateChecker.Priority.HIGH)
|
|
|
|
assertNotEquals(testSetup.getUpdateState(), UpdateState.Prepared)
|
|
|
|
}
|
|
|
|
|
|
|
|
private fun newTestSetup(updateInfo: UpdateInfo) = UpdateViewTestSetup(
|
|
|
|
composeTestRule,
|
|
|
|
updateInfo
|
|
|
|
)
|
|
|
|
}
|