Skip to content

Commit

Permalink
Navigate to accounts from transfer actions
Browse files Browse the repository at this point in the history
Implemented a read only view for the proxy voter
Only allow the TransferDetailLayout to navigate one level deep into accounts
Added a ui test for navigating to account from confirm transfer
Implemented a ui test for navigating to accounts from actions
:robot:
  • Loading branch information
samkirton committed Oct 16, 2018
1 parent 6243cc3 commit 1f9b0ea
Show file tree
Hide file tree
Showing 22 changed files with 4,062 additions and 258 deletions.
2 changes: 1 addition & 1 deletion android/app/build.gradle
Expand Up @@ -60,7 +60,7 @@ dependencies {
implementation 'com.android.billingclient:billing:1.1'

/* eos-jvm */
implementation ('com.memtrip.eos-jvm:eos-chain-actions:1.0.0-alpha15') {
implementation ('com.memtrip.eos-jvm:eos-chain-actions:1.0.0-alpha16') {
exclude group: "com.lambdaworks", module: "scrypt"
}

Expand Down
Expand Up @@ -19,6 +19,7 @@ package com.memtrip.eosreach.robot.account
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.action.ViewActions.swipeDown
import androidx.test.espresso.assertion.ViewAssertions.doesNotExist
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
Expand All @@ -45,6 +46,20 @@ class AccountRobot {
return this
}

fun verifyReadOnlyAccountScreen(): AccountRobot {

onView(withId(R.id.account_toolbar))
.check(matches(isDisplayed()))

onView(withId(R.id.account_balance_background))
.check(matches(isDisplayed()))

onView(withId(R.id.account_menu_search))
.check(doesNotExist())

return this
}

fun verifyAvailableBalance(): AccountRobot {

onView(withId(R.id.account_available_balance_value))
Expand Down
Expand Up @@ -19,10 +19,13 @@ package com.memtrip.eosreach.robot.account.actions
import androidx.test.espresso.Espresso.onView
import androidx.test.espresso.action.ViewActions.click
import androidx.test.espresso.assertion.ViewAssertions.matches
import androidx.test.espresso.contrib.RecyclerViewActions
import androidx.test.espresso.matcher.ViewMatchers
import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
import androidx.test.espresso.matcher.ViewMatchers.withId
import com.memtrip.eosreach.R
import com.memtrip.eosreach.api.actions.model.AccountAction
import com.memtrip.eosreach.uikit.SimpleAdapterViewHolder
import org.hamcrest.CoreMatchers.not

class ActionsRobot {
Expand All @@ -37,6 +40,12 @@ class ActionsRobot {
return this
}

fun selectFirstActionRow(): ActionsRobot {
onView(withId(R.id.account_actions_list_recyclerview))
.perform(RecyclerViewActions.actionOnItemAtPosition<SimpleAdapterViewHolder<AccountAction>>(0, click()))
return this
}

fun selectTransferButton(): ActionsRobot {
onView(ViewMatchers.withId(R.id.account_actions_transfer_button))
.check(matches(isDisplayed()))
Expand All @@ -51,4 +60,21 @@ class ActionsRobot {
.check(matches(not(isDisplayed())))
return this
}

fun verifyViewTransferActionScreen(): ActionsRobot {
onView(withId(R.id.account_actions_view_transfer_action_toolbar))
.check(matches(isDisplayed()))
onView(withId(R.id.account_actions_view_transfer_details))
.check(matches(isDisplayed()))
onView(withId(R.id.account_actions_view_transaction_block_explorer_button))
.check(matches(isDisplayed()))
return this
}

fun selectViewTransferActionFromAccountLabel(): ActionsRobot {
onView(withId(R.id.transfer_details_from_value))
.check(matches(isDisplayed()))
.perform(click())
return this
}
}
Expand Up @@ -29,6 +29,26 @@ import com.memtrip.eosreach.R

class TransferRobot {

fun verifyTransferScreen(): TransferRobot {
onView(withId(R.id.transfer_form_toolbar))
.check(matches(isDisplayed()))
onView(withId(R.id.transfer_form_to_label))
.check(matches(isDisplayed()))
onView(withId(R.id.transfer_form_to_input))
.check(matches(isDisplayed()))
onView(withId(R.id.transfer_form_amount_label))
.check(matches(isDisplayed()))
onView(withId(R.id.transfer_form_amount_input))
.check(matches(isDisplayed()))
onView(withId(R.id.transfer_form_memo_label))
.check(matches(isDisplayed()))
onView(withId(R.id.transfer_form_memo_input))
.check(matches(isDisplayed()))
onView(withId(R.id.transfer_form_next_button))
.check(matches(isDisplayed()))
return this
}

fun enterRecipient(recipient: String): TransferRobot {
onView(withId(R.id.transfer_form_to_input))
.check(matches(isDisplayed()))
Expand Down Expand Up @@ -60,6 +80,23 @@ class TransferRobot {
return this
}

fun verifyTransferConfirmationScreen(): TransferRobot {
onView(withId(R.id.transfer_confirm_toolbar))
.check(matches(isDisplayed()))
onView(withId(R.id.transfer_confirm_form_details))
.check(matches(isDisplayed()))
onView(withId(R.id.transfer_confirm_confirm_button))
.check(matches(isDisplayed()))
return this
}

fun selectToAccountLabel(): TransferRobot {
onView(withId(R.id.transfer_details_to_value))
.check(matches(isDisplayed()))
.perform(click())
return this
}

fun verifyAmount(amount: String): TransferRobot {
onView(withId(R.id.transfer_details_amount_value))
.check(matches(isDisplayed()))
Expand Down
Expand Up @@ -15,7 +15,7 @@ class SearchAccountTestCase : StubTestCase() {
.typeAccountName("memtripissue")
.selectAccount()
accountRobot
.verifyAccountScreen()
.verifyReadOnlyAccountScreen()
.verifyAvailableBalance()
}
}
Expand Up @@ -12,11 +12,12 @@ class VerifyReadOnlySearchAccountTestCase : StubTestCase() {
.typeAccountName("memtripissue")
.selectAccount()
accountRobot
.verifyAccountScreen()
.verifyReadOnlyAccountScreen()
.verifyAvailableBalance()
balanceRobot
.selectFirstTokenRow()
actionsRobot
.verifyActionsReadOnlyScreen()

}
}
@@ -0,0 +1,33 @@
package com.memtrip.eosreach.app.actions

import com.memtrip.eosreach.StubTestCase

class NavigateToAccountFromActionTestCase : StubTestCase() {

override fun test() {
importKeyOrchestra.go("5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3")
accountRobot
.verifyAccountScreen()
balanceRobot
.verifyBalanceScreen()
.selectFirstTokenRow()
actionsRobot
.verifyActionsScreen()
.selectFirstActionRow()
.verifyViewTransferActionScreen()
.selectViewTransferActionFromAccountLabel()
accountRobot
.verifyReadOnlyAccountScreen()
balanceRobot
.verifyBalanceScreen()
.selectFirstTokenRow()
actionsRobot
.verifyActionsReadOnlyScreen()
.selectFirstActionRow()
.verifyViewTransferActionScreen()
.selectViewTransferActionFromAccountLabel()
// the label will be read only at the point, so the user will remain on the current screen
.verifyViewTransferActionScreen()
}
}

@@ -0,0 +1,28 @@
package com.memtrip.eosreach.app.transfer

import com.memtrip.eosreach.StubTestCase

class NavigateToAccountFromTransferTestCase : StubTestCase() {

override fun test() {
importKeyOrchestra.go("5KQwrPbwdL6PhXujxW37FSSQZ1JiwsST4cqQzDeyXtP79zkvFD3")
accountRobot
.verifyAccountScreen()
balanceRobot
.verifyBalanceScreen()
.selectFirstTokenRow()
actionsRobot
.verifyActionsScreen()
.selectTransferButton()
transferRobot
.verifyTransferScreen()
.enterRecipient("memtripblock")
.enterAmount("0.0001")
.enterMemo("Here is some coin")
.selectNextButton()
.verifyTransferConfirmationScreen()
.selectToAccountLabel()
accountRobot
.verifyReadOnlyAccountScreen()
}
}
3 changes: 2 additions & 1 deletion android/app/src/main/AndroidManifest.xml
Expand Up @@ -32,7 +32,8 @@
<activity android:name=".app.blockproducer.ReadOnlyViewBlockProducerActivity" />

<activity android:name=".app.proxyvoter.ProxyVoterListActivity" />
<activity android:name=".app.proxyvoter.ViewProxyVoterActivity" />
<activity android:name=".app.proxyvoter.DefaultViewProxyVoterActivity" />
<activity android:name=".app.proxyvoter.ReadOnlyViewProxyVoterActivity" />

<activity android:name=".app.account.DefaultAccountActivity" />
<activity android:name=".app.account.ReadonlyAccountActivity" />
Expand Down
Expand Up @@ -87,6 +87,7 @@ class ViewTransferActionActivity
accountAction.to,
accountAction.from,
accountAction.memo,
accountTheme,
accountAction.contractAccountBalance)

account_actions_view_transfer_details.populateDate(
Expand Down
Expand Up @@ -173,7 +173,7 @@ abstract class VoteFragment

override fun navigateToViewProxyVote(accountName: String) {
model().publish(VoteIntent.Idle)
startActivity(viewProxyVoterIntentWithName(accountName, ViewProxyVoterDisplayAction.LOAD, context!!))
startActivity(viewProxyVoterIntentWithName(accountName, ViewProxyVoterDisplayAction.LOAD, accountTheme(), context!!))
}

companion object {
Expand Down
@@ -0,0 +1,10 @@
package com.memtrip.eosreach.app.proxyvoter

import dagger.android.AndroidInjection

class DefaultViewProxyVoterActivity : ViewProxyVoterActivity() {

override fun inject() {
AndroidInjection.inject(this)
}
}
Expand Up @@ -23,6 +23,7 @@ import com.memtrip.eosreach.app.MviActivity
import com.memtrip.eosreach.R
import com.memtrip.eosreach.api.proxyvoter.ProxyVoterDetails
import com.memtrip.eosreach.app.ViewModelFactory
import com.memtrip.eosreach.app.account.AccountTheme
import com.memtrip.eosreach.app.proxyvoter.ViewProxyVoterActivity.Companion.viewProxyVoterIntentWithDetails
import com.memtrip.eosreach.uikit.Interaction
import com.memtrip.eosreach.uikit.gone
Expand Down Expand Up @@ -112,7 +113,7 @@ class ProxyVoterListActivity

override fun navigateToProxyVoterDetails(proxyVoterDetails: ProxyVoterDetails) {
model().publish(ProxyVoterListIntent.Idle)
startActivity(viewProxyVoterIntentWithDetails(proxyVoterDetails, ViewProxyVoterDisplayAction.DETAILS, this))
startActivity(viewProxyVoterIntentWithDetails(proxyVoterDetails, ViewProxyVoterDisplayAction.DETAILS, AccountTheme.DEFAULT, this))
}

override fun selectProxyVoter(proxyVoterDetails: ProxyVoterDetails) {
Expand Down
Expand Up @@ -26,5 +26,8 @@ abstract class ProxyVoterModule {
internal abstract fun contributeProxyVoterListActivity(): ProxyVoterListActivity

@ContributesAndroidInjector(modules = [ViewProxyVoterActivityModule::class])
internal abstract fun contributeViewProxyVoterActivity(): ViewProxyVoterActivity
internal abstract fun contributeReadOnlyViewProxyVoterActivity(): ReadOnlyViewProxyVoterActivity

@ContributesAndroidInjector(modules = [ViewProxyVoterActivityModule::class])
internal abstract fun contributeDefaultViewProxyVoterActivity(): DefaultViewProxyVoterActivity
}
@@ -0,0 +1,27 @@
package com.memtrip.eosreach.app.proxyvoter

import android.content.res.Resources
import com.memtrip.eosreach.R
import com.memtrip.eosreach.api.proxyvoter.ProxyVoterDetails
import com.memtrip.eosreach.uikit.gone
import kotlinx.android.synthetic.main.proxy_voter_view_activity.*

import dagger.android.AndroidInjection

class ReadOnlyViewProxyVoterActivity : ViewProxyVoterActivity() {

override fun populate(proxyVoterDetails: ProxyVoterDetails) {
super.populate(proxyVoterDetails)
proxy_voter_view_owner_account_button.gone()
}

override fun inject() {
AndroidInjection.inject(this)
}

override fun getTheme(): Resources.Theme {
val theme = super.getTheme()
theme.applyStyle(R.style.ReadOnlyAppTheme, true)
return theme
}
}

0 comments on commit 1f9b0ea

Please sign in to comment.