Skip to content
This repository has been archived by the owner on Nov 5, 2024. It is now read-only.

Commit

Permalink
Fix DeleteAccount() test
Browse files Browse the repository at this point in the history
  • Loading branch information
ILIYANGERMANOV committed Apr 28, 2022
1 parent 535d3b9 commit 71e812d
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
15 changes: 15 additions & 0 deletions app/src/androidTest/java/com/ivy/wallet/compose/IvyComposeTest.kt
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package com.ivy.wallet.compose

import android.content.Context
import android.content.Context.INPUT_METHOD_SERVICE
import android.util.Log
import android.view.inputmethod.InputMethodManager
import androidx.activity.ComponentActivity
import androidx.compose.ui.test.IdlingResource
import androidx.compose.ui.test.SemanticsNodeInteraction
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.compose.ui.test.junit4.ComposeTestRule
import androidx.compose.ui.test.junit4.createAndroidComposeRule
import androidx.compose.ui.test.performClick
import androidx.test.ext.junit.rules.ActivityScenarioRule
import androidx.test.platform.app.InstrumentationRegistry
import androidx.work.Configuration
import androidx.work.impl.utils.SynchronousExecutor
Expand Down Expand Up @@ -191,4 +196,14 @@ fun ComposeTestRule.clickWithRetry(
)
}
}
}

fun <A : ComponentActivity> AndroidComposeTestRule<ActivityScenarioRule<A>, A>.hideKeyboard() {
with(this.activity) {
if (currentFocus != null) {
val inputMethodManager: InputMethodManager =
this.getSystemService(INPUT_METHOD_SERVICE) as InputMethodManager
inputMethodManager.hideSoftInputFromWindow(currentFocus!!.windowToken, 0)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import androidx.compose.ui.graphics.Color
import androidx.compose.ui.test.*
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.test.ext.junit.rules.ActivityScenarioRule
import com.ivy.wallet.compose.hideKeyboard
import com.ivy.wallet.compose.printTree
import com.ivy.wallet.ui.theme.Ivy

Expand Down Expand Up @@ -65,6 +66,8 @@ class AccountsTab<A : ComponentActivity>(
accountModal.apply {
enterTitle(name)

composeTestRule.hideKeyboard()

ivyColorPicker.chooseColor(color = color)

if (icon != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,12 @@ import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.compose.ui.test.performClick
import androidx.compose.ui.test.performScrollTo
import androidx.test.ext.junit.rules.ActivityScenarioRule
import com.ivy.wallet.compose.printTree

class IvyColorPicker<A : ComponentActivity>(
private val composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<A>, A>
) {

fun chooseColor(color: Color) {
composeTestRule.printTree()

composeTestRule.onNode(hasTestTag("color_item_${color.value}"))
.performScrollTo()
.performClick()
Expand Down

0 comments on commit 71e812d

Please sign in to comment.