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

Commit

Permalink
Merge Fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Vishwa-Raghavendra committed May 3, 2022
2 parents 120a26d + 49d8741 commit 9e7c1eb
Show file tree
Hide file tree
Showing 55 changed files with 1,627 additions and 314 deletions.
1 change: 1 addition & 0 deletions .github/workflows/internal_release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ jobs:
REPO: ${{ github.repository }}

- name: Create GitHub Release
if: always() #Execute even the generation of changelog has failed
id: create_release
uses: actions/create-release@latest
env:
Expand Down
21 changes: 8 additions & 13 deletions app/proguard-rules.pro
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@
# hide the original source file name.
#-renamesourcefileattribute SourceFile

# Fix broken stuff by R8
-keep class com.ivy.wallet.ui.widget.** { *; }
-keep class com.ivy.wallet.domain.data.** { *; }
-keep class com.ivy.wallet.io.network.** { *; }
-keep class com.ivy.wallet.io.persistence.data.** { *; }
-keep class com.ivy.wallet.io.network.data.** { *; }
-keep class com.ivy.wallet.domain.event.** { *; }

-keepattributes EnclosingMethod
-keepattributes InnerClasses

# Widget
-keep class com.ivy.wallet.widget.** { *; }
# ------


# Firebase Crashlytics
-dontwarn org.xmlpull.v1.**
-dontnote org.xmlpull.v1.**
Expand Down Expand Up @@ -136,14 +139,6 @@
# Application classes that will be serialized/deserialized over Gson
-keep class com.ivy.wallet.model.** { <fields>; }

# Fix broken stuff by R8
-keep class com.ivy.wallet.domain.data.** { *; }
-keep class com.ivy.wallet.ui.widget.** { *; }
-keep class com.ivy.wallet.io.network.** { *; }
-keep class com.ivy.wallet.io.persistence.data.** { *; }
-keep class com.ivy.wallet.io.network.data.** { *; }
-keep class com.ivy.wallet.domain.event.** { *; }

# Prevent proguard from stripping interface information from TypeAdapter, TypeAdapterFactory,
# JsonSerializer, JsonDeserializer instances (so they can be used in @JsonAdapter)
-keep class * implements com.google.gson.TypeAdapter
Expand Down
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 @@ -4,30 +4,46 @@ import androidx.activity.ComponentActivity
import androidx.compose.ui.test.hasTestTag
import androidx.compose.ui.test.hasText
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.performClick
import androidx.test.ext.junit.rules.ActivityScenarioRule

class AmountInput<A : ComponentActivity>(
private val composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<A>, A>
) {
fun enterNumber(number: String) {
fun enterNumber(
number: String,
onCalculator: Boolean = false,
autoPressNonCalculator: Boolean = true,
) {
composeTestRule.waitForIdle()

for (char in number) {
when (char) {
in '0'..'9' -> pressNumber(char.toString().toInt())
in '0'..'9' -> pressNumber(
number = char.toString().toInt(),
onCalculator = onCalculator
)
',' -> {
//do nothing
}
'.' -> pressDecimalSeparator()
'.' -> pressDecimalSeparator(
onCalculator = onCalculator
)
}
}

clickSet()
if (!onCalculator && autoPressNonCalculator) {
clickSet()
}
}

fun pressNumber(number: Int) {
composeTestRule.onNode(hasTestTag("key_$number"))
private fun pressNumber(number: Int, onCalculator: Boolean) {
composeTestRule.onNode(
hasTestTag(
if (onCalculator) "calc_key_$number" else "key_$number"
)
)
.performClick()
}

Expand All @@ -36,13 +52,64 @@ class AmountInput<A : ComponentActivity>(
.performClick()
}

fun pressDecimalSeparator() {
composeTestRule.onNode(hasTestTag("key_decimal_separator"))
fun pressDecimalSeparator(
onCalculator: Boolean
) {
composeTestRule.onNode(
hasTestTag(
if (onCalculator) "calc_key_decimal_separator" else "key_decimal_separator"
)
)
.performClick()
}

fun pressPlus() {
composeTestRule.onNodeWithTag("key_+")
.performClick()
}

fun pressMinus() {
composeTestRule.onNodeWithTag("key_-")
.performClick()
}

fun pressMultiplication() {
composeTestRule.onNodeWithTag("key_*")
.performClick()
}

fun pressDivision() {
composeTestRule.onNodeWithTag("key_/")
.performClick()
}

fun pressLeftBracket() {
composeTestRule.onNodeWithTag("key_(")
.performClick()
}

fun pressRightBracket() {
composeTestRule.onNodeWithTag("key_)")
.performClick()
}

fun pressCalcEqual() {
composeTestRule.onNodeWithTag("key_=")
.performClick()
}

fun clickCalcSet() {
composeTestRule.onNodeWithTag("calc_set")
.performClick()
}

fun clickSet() {
composeTestRule.onNode(hasText("Enter"))
.performClick()
}

fun clickCalculator() {
composeTestRule.onNodeWithTag("btn_calculator")
.performClick()
}
}
48 changes: 40 additions & 8 deletions app/src/androidTest/java/com/ivy/wallet/compose/helpers/HomeTab.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import androidx.activity.ComponentActivity
import androidx.compose.ui.test.*
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.test.ext.junit.rules.ActivityScenarioRule
import com.ivy.wallet.compose.printTree

class HomeTab<A : ComponentActivity>(
private val composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<A>, A>
Expand All @@ -24,25 +25,46 @@ class HomeTab<A : ComponentActivity>(
account: String? = null,
category: String? = null
) {
var matcher = hasTestTag("transaction_card")
.and(hasText(amount))
var matcher = hasTestTag("type_amount_currency")
.and(hasAnyDescendant(hasText(amount)))

if (account != null) {
matcher = matcher.and(hasAnyDescendant(hasText(account)))
matcher = matcher.and(
hasAnySibling(
hasAnyDescendant(
hasText(account)
)
)
)
}

if (category != null) {
matcher = matcher.and(hasAnyDescendant(hasText(category)))
matcher = matcher.and(
hasAnySibling(
hasAnyDescendant(
hasText(category)
)
)
)
}

if (title != null) {
matcher = matcher.and(hasText(title))
matcher = matcher.and(
hasAnySibling(
hasText(title)
)
)
}

composeTestRule.onNode(matcher)
composeTestRule.printTree(
useUnmergedTree = true
)

composeTestRule.onNode(
matcher = matcher,
useUnmergedTree = true
)
.assertIsDisplayed()
.assertHasClickAction()
.performScrollTo()
.performClick()
}

Expand Down Expand Up @@ -109,4 +131,14 @@ class HomeTab<A : ComponentActivity>(
composeTestRule.onNodeWithTag("home_greeting_text", useUnmergedTree = true)
.assertTextEquals(greeting)
}

fun clickIncomeCard() {
composeTestRule.onNodeWithTag("home_card_income")
.performClick()
}

fun clickExpenseCard() {
composeTestRule.onNodeWithTag("home_card_expense")
.performClick()
}
}
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.ivy.wallet.compose.helpers

import androidx.activity.ComponentActivity
import androidx.compose.ui.test.*
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.test.ext.junit.rules.ActivityScenarioRule

class PieChartScreen<A : ComponentActivity>(
private val composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<A>, A>
) {
fun assertTitle(title: String) {
composeTestRule.onNodeWithTag("piechart_title")
.assertTextContains(title)
}

fun assertTotalAmount(
amountInt: String,
decimalPart: String,
currency: String = "USD"
) {
val matchText: (String) -> SemanticsMatcher = { text ->
hasTestTag("piechart_total_amount")
.and(
hasAnyDescendant(
hasText(text)
)
)
}

composeTestRule.onNode(matchText(amountInt))
.assertIsDisplayed()

composeTestRule.onNode(matchText(decimalPart))
.assertIsDisplayed()

composeTestRule.onNode(matchText(currency))
.assertIsDisplayed()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import androidx.compose.ui.test.*
import androidx.compose.ui.test.junit4.AndroidComposeTestRule
import androidx.test.ext.junit.rules.ActivityScenarioRule

class EditTransactionScreen<A : ComponentActivity>(
class TransactionScreen<A : ComponentActivity>(
private val composeTestRule: AndroidComposeTestRule<ActivityScenarioRule<A>, A>
) {
private val amountInput = AmountInput(composeTestRule)
Expand Down Expand Up @@ -60,4 +60,14 @@ class EditTransactionScreen<A : ComponentActivity>(
composeTestRule.onNodeWithText("Save")
.performClick()
}

fun clickAdd() {
composeTestRule.onNodeWithText("Add")
.performClick()
}

fun skipCategory() {
composeTestRule.onNodeWithText("Skip")
.performClick()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AccountsTest : IvyComposeTest() {
private val transactionFlow = TransactionFlow(composeTestRule)
private val homeTab = HomeTab(composeTestRule)
private val accountsTab = AccountsTab(composeTestRule)
private val editTransactionScreen = EditTransactionScreen(composeTestRule)
private val editTransactionScreen = TransactionScreen(composeTestRule)
private val itemStatisticScreen = ItemStatisticScreen(composeTestRule)
private val reorderModal = ReorderModal(composeTestRule)
private val deleteConfirmationModal = DeleteConfirmationModal(composeTestRule)
Expand Down
Loading

0 comments on commit 9e7c1eb

Please sign in to comment.