diff --git a/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/account/AccountTestSetup.kt b/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/account/AccountTestSetup.kt index b7d53c8c..e02df0d7 100644 --- a/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/account/AccountTestSetup.kt +++ b/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/account/AccountTestSetup.kt @@ -5,7 +5,10 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.test.junit4.ComposeContentTestRule import co.electriccoin.zcash.ui.common.model.WalletRestoringState import co.electriccoin.zcash.ui.common.model.WalletSnapshot +import co.electriccoin.zcash.ui.design.R +import co.electriccoin.zcash.ui.design.component.IconButtonState import co.electriccoin.zcash.ui.design.theme.ZcashTheme +import co.electriccoin.zcash.ui.design.util.stringRes import co.electriccoin.zcash.ui.fixture.BalanceStateFixture import co.electriccoin.zcash.ui.fixture.WalletSnapshotFixture import co.electriccoin.zcash.ui.fixture.ZashiMainTopAppBarStateFixture @@ -60,7 +63,27 @@ class AccountTestSetup( transactionsUiState = initialTransactionState, walletRestoringState = WalletRestoringState.NONE, walletSnapshot = WalletSnapshotFixture.new(), - zashiMainTopAppBarState = ZashiMainTopAppBarStateFixture.new() + zashiMainTopAppBarState = + ZashiMainTopAppBarStateFixture.new( + settingsButton = + IconButtonState( + icon = R.drawable.ic_app_bar_settings, + contentDescription = + stringRes(co.electriccoin.zcash.ui.R.string.settings_menu_content_description), + ) { + onSettingsCount.incrementAndGet() + }, + balanceVisibilityButton = + IconButtonState( + icon = R.drawable.ic_app_bar_balances_hide, + contentDescription = + stringRes( + co.electriccoin.zcash.ui.R.string.hide_balances_content_description + ), + ) { + onHideBalancesCount.incrementAndGet() + }, + ) ) } diff --git a/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/balances/BalancesTestSetup.kt b/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/balances/BalancesTestSetup.kt index 18d94056..6d42a94e 100644 --- a/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/balances/BalancesTestSetup.kt +++ b/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/balances/BalancesTestSetup.kt @@ -5,7 +5,10 @@ import androidx.compose.runtime.Composable import androidx.compose.ui.test.junit4.ComposeContentTestRule import co.electriccoin.zcash.ui.common.model.WalletRestoringState import co.electriccoin.zcash.ui.common.model.WalletSnapshot +import co.electriccoin.zcash.ui.design.R +import co.electriccoin.zcash.ui.design.component.IconButtonState import co.electriccoin.zcash.ui.design.theme.ZcashTheme +import co.electriccoin.zcash.ui.design.util.stringRes import co.electriccoin.zcash.ui.fixture.BalanceStateFixture import co.electriccoin.zcash.ui.fixture.ZashiMainTopAppBarStateFixture import co.electriccoin.zcash.ui.screen.balances.model.ShieldState @@ -47,7 +50,16 @@ class BalancesTestSetup( walletSnapshot = walletSnapshot, walletRestoringState = WalletRestoringState.NONE, zashiMainTopAppBarState = - ZashiMainTopAppBarStateFixture.new() + ZashiMainTopAppBarStateFixture.new( + settingsButton = + IconButtonState( + icon = R.drawable.ic_app_bar_settings, + contentDescription = + stringRes(co.electriccoin.zcash.ui.R.string.settings_menu_content_description), + ) { + onSettingsCount.incrementAndGet() + } + ) ) } diff --git a/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/receive/view/ReceiveViewTest.kt b/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/receive/view/ReceiveViewTest.kt index 6f9128d0..9cbaf9c3 100644 --- a/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/receive/view/ReceiveViewTest.kt +++ b/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/receive/view/ReceiveViewTest.kt @@ -5,10 +5,8 @@ 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.WalletAddressesFixture +import cash.z.ecc.android.sdk.fixture.WalletAddressFixture import co.electriccoin.zcash.ui.R -import co.electriccoin.zcash.ui.screen.send.ext.abbreviated -import co.electriccoin.zcash.ui.test.getAppContext import co.electriccoin.zcash.ui.test.getStringResource import kotlinx.coroutines.test.runTest import org.junit.Assert.assertEquals @@ -31,16 +29,14 @@ class ReceiveViewTest { @MediumTest fun setup() = runTest { - val walletAddresses = WalletAddressesFixture.new() newTestSetup() // Enable substring for ellipsizing composeTestRule.onNodeWithText( - text = walletAddresses.unified.abbreviated(getAppContext()), - substring = true - ).also { - it.assertExists() - } + text = "${WalletAddressFixture.UNIFIED_ADDRESS_STRING.take(20)}...", + substring = true, + useUnmergedTree = true + ).assertExists() } @Test diff --git a/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/receive/view/ReceiveViewTestSetup.kt b/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/receive/view/ReceiveViewTestSetup.kt index 789578c5..2ba128f5 100644 --- a/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/receive/view/ReceiveViewTestSetup.kt +++ b/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/receive/view/ReceiveViewTestSetup.kt @@ -1,8 +1,13 @@ package co.electriccoin.zcash.ui.screen.receive.view import androidx.compose.ui.test.junit4.ComposeContentTestRule +import cash.z.ecc.android.sdk.fixture.WalletAddressFixture +import co.electriccoin.zcash.ui.R +import co.electriccoin.zcash.ui.design.component.IconButtonState import co.electriccoin.zcash.ui.design.theme.ZcashTheme +import co.electriccoin.zcash.ui.design.util.stringRes import co.electriccoin.zcash.ui.fixture.ZashiMainTopAppBarStateFixture +import co.electriccoin.zcash.ui.screen.receive.model.ReceiveAddressState import co.electriccoin.zcash.ui.screen.receive.model.ReceiveState import java.util.concurrent.atomic.AtomicInteger @@ -23,10 +28,36 @@ class ReceiveViewTestSetup( ReceiveView( state = ReceiveState( - items = listOf(), + items = + listOf( + ReceiveAddressState( + icon = R.drawable.ic_zec_round_full, + title = stringRes("Zashi"), + subtitle = + stringRes( + "${WalletAddressFixture.UNIFIED_ADDRESS_STRING.take(20)}...", + ), + isShielded = true, + onCopyClicked = {}, + onQrClicked = { }, + onRequestClicked = {}, + isExpanded = true, + onClick = {} + ) + ), isLoading = false, ), - zashiMainTopAppBarState = ZashiMainTopAppBarStateFixture.new() + zashiMainTopAppBarState = + ZashiMainTopAppBarStateFixture.new( + settingsButton = + IconButtonState( + icon = co.electriccoin.zcash.ui.design.R.drawable.ic_app_bar_settings, + contentDescription = + stringRes(R.string.settings_menu_content_description), + ) { + onSettingsCount.incrementAndGet() + } + ) ) } } diff --git a/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/send/SendViewTestSetup.kt b/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/send/SendViewTestSetup.kt index bdfdc231..40c1d4dc 100644 --- a/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/send/SendViewTestSetup.kt +++ b/ui-lib/src/androidTest/java/co/electriccoin/zcash/ui/screen/send/SendViewTestSetup.kt @@ -12,7 +12,10 @@ import cash.z.ecc.android.sdk.model.Zatoshi import cash.z.ecc.android.sdk.model.ZecSend import cash.z.ecc.android.sdk.type.AddressType import co.electriccoin.zcash.ui.common.wallet.ExchangeRateState +import co.electriccoin.zcash.ui.design.R +import co.electriccoin.zcash.ui.design.component.IconButtonState import co.electriccoin.zcash.ui.design.theme.ZcashTheme +import co.electriccoin.zcash.ui.design.util.stringRes import co.electriccoin.zcash.ui.fixture.BalanceStateFixture import co.electriccoin.zcash.ui.fixture.WalletSnapshotFixture import co.electriccoin.zcash.ui.fixture.ZashiMainTopAppBarStateFixture @@ -148,7 +151,17 @@ class SendViewTestSetup( isHintVisible = false, onButtonClick = {} ), - zashiMainTopAppBarState = ZashiMainTopAppBarStateFixture.new() + zashiMainTopAppBarState = + ZashiMainTopAppBarStateFixture.new( + settingsButton = + IconButtonState( + icon = R.drawable.ic_app_bar_settings, + contentDescription = + stringRes(co.electriccoin.zcash.ui.R.string.settings_menu_content_description), + ) { + onSettingsCount.incrementAndGet() + } + ) ) } } diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/viewmodel/ZashiMainTopAppBarViewModel.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/viewmodel/ZashiMainTopAppBarViewModel.kt index 7444eb5d..2dca3c63 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/viewmodel/ZashiMainTopAppBarViewModel.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/common/viewmodel/ZashiMainTopAppBarViewModel.kt @@ -15,6 +15,7 @@ import co.electriccoin.zcash.ui.design.R import co.electriccoin.zcash.ui.design.component.AccountSwitchState import co.electriccoin.zcash.ui.design.component.IconButtonState import co.electriccoin.zcash.ui.design.component.ZashiMainTopAppBarState +import co.electriccoin.zcash.ui.design.util.stringRes import co.electriccoin.zcash.ui.preference.StandardPreferenceKeys import co.electriccoin.zcash.ui.screen.accountlist.AccountList import kotlinx.coroutines.flow.SharingStarted @@ -65,12 +66,14 @@ class ZashiMainTopAppBarViewModel( } else { R.drawable.ic_app_bar_balances_hide }, - onClick = ::onShowOrHideBalancesClicked + onClick = ::onShowOrHideBalancesClicked, + contentDescription = stringRes(co.electriccoin.zcash.ui.R.string.hide_balances_content_description) ), settingsButton = IconButtonState( icon = R.drawable.ic_app_bar_settings, - onClick = ::onSettingsClicked + onClick = ::onSettingsClicked, + contentDescription = stringRes(co.electriccoin.zcash.ui.R.string.settings_menu_content_description) ) ) diff --git a/ui-lib/src/main/java/co/electriccoin/zcash/ui/fixture/ZashiMainTopAppBarStateFixture.kt b/ui-lib/src/main/java/co/electriccoin/zcash/ui/fixture/ZashiMainTopAppBarStateFixture.kt index 275a40cc..f4734e10 100644 --- a/ui-lib/src/main/java/co/electriccoin/zcash/ui/fixture/ZashiMainTopAppBarStateFixture.kt +++ b/ui-lib/src/main/java/co/electriccoin/zcash/ui/fixture/ZashiMainTopAppBarStateFixture.kt @@ -4,16 +4,28 @@ import co.electriccoin.zcash.ui.design.R import co.electriccoin.zcash.ui.design.component.AccountSwitchState import co.electriccoin.zcash.ui.design.component.IconButtonState import co.electriccoin.zcash.ui.design.component.ZashiMainTopAppBarState +import co.electriccoin.zcash.ui.design.util.stringRes object ZashiMainTopAppBarStateFixture { - fun new() = - ZashiMainTopAppBarState( - accountSwitchState = - AccountSwitchState( - accountType = ZashiMainTopAppBarState.AccountType.ZASHI, - onAccountTypeClick = {} - ), - balanceVisibilityButton = IconButtonState(R.drawable.ic_app_bar_balances_hide) {}, - settingsButton = IconButtonState(R.drawable.ic_app_bar_settings) {}, - ) + fun new( + accountSwitchState: AccountSwitchState = + AccountSwitchState( + accountType = ZashiMainTopAppBarState.AccountType.ZASHI, + onAccountTypeClick = {} + ), + balanceVisibilityButton: IconButtonState = + IconButtonState( + icon = R.drawable.ic_app_bar_balances_hide, + contentDescription = stringRes(co.electriccoin.zcash.ui.R.string.hide_balances_content_description) + ) {}, + settingsButton: IconButtonState = + IconButtonState( + icon = R.drawable.ic_app_bar_settings, + contentDescription = stringRes(co.electriccoin.zcash.ui.R.string.settings_menu_content_description) + ) {}, + ) = ZashiMainTopAppBarState( + accountSwitchState = accountSwitchState, + balanceVisibilityButton = balanceVisibilityButton, + settingsButton = settingsButton, + ) }