2023-02-28 05:54:07 -08:00
|
|
|
package co.electriccoin.zcash.ui.screen.receive.view
|
|
|
|
|
|
|
|
import androidx.compose.ui.test.junit4.createComposeRule
|
|
|
|
import androidx.compose.ui.test.onNodeWithContentDescription
|
|
|
|
import androidx.compose.ui.test.onNodeWithText
|
|
|
|
import androidx.compose.ui.test.performClick
|
|
|
|
import androidx.test.filters.MediumTest
|
|
|
|
import cash.z.ecc.android.sdk.fixture.WalletAddressFixture
|
|
|
|
import cash.z.ecc.android.sdk.model.WalletAddress
|
|
|
|
import co.electriccoin.zcash.ui.R
|
|
|
|
import co.electriccoin.zcash.ui.test.getStringResource
|
|
|
|
import kotlinx.coroutines.test.runTest
|
|
|
|
import org.junit.Assert.assertEquals
|
|
|
|
import org.junit.Rule
|
|
|
|
import org.junit.Test
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Note: It is difficult to test the QR code from automated tests. There is a manual test case
|
|
|
|
* for that currently. A future enhancement could take a screenshot and try to analyze the
|
|
|
|
* screenshot contents.
|
|
|
|
*/
|
|
|
|
class ReceiveViewTest {
|
|
|
|
@get:Rule
|
|
|
|
val composeTestRule = createComposeRule()
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@MediumTest
|
2023-12-11 01:20:32 -08:00
|
|
|
fun setup() =
|
|
|
|
runTest {
|
|
|
|
val walletAddress = WalletAddressFixture.unified()
|
|
|
|
newTestSetup(walletAddress)
|
2023-02-28 05:54:07 -08:00
|
|
|
|
2023-12-11 01:20:32 -08:00
|
|
|
// Enable substring for ellipsizing
|
|
|
|
composeTestRule.onNodeWithText(walletAddress.address, substring = true).also {
|
|
|
|
it.assertExists()
|
|
|
|
}
|
2023-02-28 05:54:07 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
@Test
|
|
|
|
@MediumTest
|
2023-12-11 01:20:32 -08:00
|
|
|
fun back() =
|
|
|
|
runTest {
|
|
|
|
val testSetup = newTestSetup(WalletAddressFixture.unified())
|
2023-02-28 05:54:07 -08:00
|
|
|
|
2023-12-11 01:20:32 -08:00
|
|
|
assertEquals(0, testSetup.getOnBackCount())
|
2023-02-28 05:54:07 -08:00
|
|
|
|
2023-12-11 01:20:32 -08:00
|
|
|
composeTestRule.onNodeWithContentDescription(
|
|
|
|
getStringResource(R.string.receive_back_content_description)
|
|
|
|
).also {
|
|
|
|
it.performClick()
|
|
|
|
}
|
2023-02-28 05:54:07 -08:00
|
|
|
|
2023-12-11 01:20:32 -08:00
|
|
|
assertEquals(1, testSetup.getOnBackCount())
|
|
|
|
}
|
2023-02-28 05:54:07 -08:00
|
|
|
|
|
|
|
@Test
|
|
|
|
@MediumTest
|
2023-12-11 01:20:32 -08:00
|
|
|
fun address_details() =
|
|
|
|
runTest {
|
|
|
|
val testSetup = newTestSetup(WalletAddressFixture.unified())
|
2023-02-28 05:54:07 -08:00
|
|
|
|
2023-12-11 01:20:32 -08:00
|
|
|
assertEquals(0, testSetup.getOnAddressDetailsCount())
|
2023-02-28 05:54:07 -08:00
|
|
|
|
2023-12-11 01:20:32 -08:00
|
|
|
composeTestRule.onNodeWithText(
|
|
|
|
text = getStringResource(R.string.receive_see_address_details),
|
|
|
|
ignoreCase = true
|
|
|
|
).also {
|
|
|
|
it.performClick()
|
|
|
|
}
|
2023-02-28 05:54:07 -08:00
|
|
|
|
2023-12-11 01:20:32 -08:00
|
|
|
assertEquals(1, testSetup.getOnAddressDetailsCount())
|
|
|
|
}
|
2023-02-28 05:54:07 -08:00
|
|
|
|
2023-12-07 07:35:27 -08:00
|
|
|
private fun newTestSetup(walletAddress: WalletAddress) = ReceiveViewTestSetup(composeTestRule, walletAddress)
|
2023-02-28 05:54:07 -08:00
|
|
|
}
|