Skip to content

Commit

Permalink
Adapt to new signature for TransactionInfo
Browse files Browse the repository at this point in the history
Make sure element is scrolled to on screens where it is not visible due to
large margins of material dialogs
  • Loading branch information
mtotschnig committed Aug 17, 2024
1 parent 0768a4e commit 64a49db
Show file tree
Hide file tree
Showing 5 changed files with 62 additions and 46 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ class ManageCurrenciesTest : BaseUiTest<ManageCurrencies>() {
onData(Matchers.`is`(currency))
.inAdapterView(withId(android.R.id.list)).perform(click())
onView(withId(R.id.edt_currency_fraction_digits))
.perform(replaceText("3"))
.perform(scrollTo(), replaceText("3"))
if (withUpdate) {
onView(withId(R.id.checkBox)).perform(scrollTo())
BaristaCheckboxInteractions.check(R.id.checkBox)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ import org.totschnig.myexpenses.provider.TransactionProvider.TRANSACTIONS_ATTACH
import org.totschnig.myexpenses.provider.insert
import org.totschnig.myexpenses.testutils.BaseDbTest
import org.totschnig.shared_test.CursorSubject.Companion.useAndAssert
import java.util.Date

class AttachmentTest : BaseDbTest() {

Expand All @@ -38,7 +37,7 @@ class AttachmentTest : BaseDbTest() {
private fun insertFixture() {
val account = AccountInfo("Test account", AccountType.CASH, 0, "USD")
val accountId = mDb.insert(TABLE_ACCOUNTS, account.contentValues)
val transaction = TransactionInfo(accountId, 0, Date(), "Transaction 0")
val transaction = TransactionInfo(accountId, 0, comment = "Transaction 0")
//We insert two transactions, in order to have transactionId and attachmentId with different values,
//so that a bug where they were mixed up, would surface
mDb.insert(TABLE_TRANSACTIONS, transaction.contentValues)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import org.totschnig.myexpenses.provider.insert
import org.totschnig.myexpenses.testutils.BaseDbTest
import org.totschnig.shared_test.CursorSubject
import org.totschnig.shared_test.CursorSubject.Companion.useAndAssert
import java.util.Date

class AutoFillTest : BaseDbTest() {
private val testTransactions = arrayOfNulls<TransactionInfo>(3)
Expand All @@ -27,36 +26,32 @@ class AutoFillTest : BaseDbTest() {
private var methodCreditCardId: Long = 0

private fun insertData() {
val now = Date()
testTransactions[0] = TransactionInfo(
testAccountId,
0,
now,
"Transaction 0",
payeeId,
null,
catId1,
methodCreditCardId
accountId = testAccountId,
amount = 0,
comment = "Transaction 0",
payeeId = payeeId,
debtId = null,
catId = catId1,
methodId = methodCreditCardId
)
testTransactions[1] = TransactionInfo(
testAccountId,
200,
now,
"Transaction 1",
payeeId,
null,
catId,
methodChequeId
accountId = testAccountId,
amount = 200,
comment = "Transaction 1",
payeeId = payeeId,
debtId = null,
catId = catId,
methodId = methodChequeId
)
testTransactions[2] = TransactionInfo(
testAccountId,
-100,
now,
"Transaction 2",
payeeId1,
null,
catId,
methodCreditCardId
accountId = testAccountId,
amount = -100,
comment = "Transaction 2",
payeeId = payeeId1,
debtId = null,
catId = catId,
methodId = methodCreditCardId
)

for (testTransaction in testTransactions) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,11 @@ package org.totschnig.myexpenses.test.provider

import android.content.ContentValues
import android.database.sqlite.SQLiteConstraintException
import org.totschnig.myexpenses.model.AccountType
import org.totschnig.myexpenses.model.CurrencyUnit
import org.totschnig.myexpenses.provider.DatabaseConstants
import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_AMOUNT
import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_ROWID
import org.totschnig.myexpenses.provider.DatabaseConstants.KEY_SEALED
import org.totschnig.myexpenses.provider.DatabaseConstants.TABLE_ACCOUNTS
import org.totschnig.myexpenses.provider.DatabaseConstants.TABLE_DEBTS
import org.totschnig.myexpenses.provider.DatabaseConstants.TABLE_PAYEES
import org.totschnig.myexpenses.provider.TransactionInfo
Expand All @@ -28,6 +26,7 @@ class TransactionDebtTest: BaseDbTest() {
private var closedTransaction: Long = 0
val currency = CurrencyUnit.DebugInstance

@Deprecated("Deprecated in Java")
@Throws(Exception::class)
override fun setUp() {
super.setUp()
Expand Down Expand Up @@ -55,7 +54,13 @@ class TransactionDebtTest: BaseDbTest() {
)
closedTransaction = mDb.insert(
DatabaseConstants.TABLE_TRANSACTIONS,
TransactionInfo(testAccountId, 0, Date(), "Transaction closed", payeeId1, closedDebt).contentValues
TransactionInfo(
accountId = testAccountId,
amount = 0,
comment = "Transaction closed",
payeeId = payeeId1,
debtId = closedDebt
).contentValues
)
mDb.update(TABLE_DEBTS, ContentValues(1).apply { put(KEY_SEALED, 1) },
"$KEY_ROWID = ?", arrayOf(closedDebt.toString()))
Expand Down Expand Up @@ -88,12 +93,11 @@ class TransactionDebtTest: BaseDbTest() {

fun testInsertIntoSealedDebtShouldFail() {
val testTransaction = TransactionInfo(
testAccountId,
0,
Date(),
"Transaction 0",
payeeId1,
closedDebt
accountId = testAccountId,
amount = 0,
comment = "Transaction 0",
payeeId = payeeId1,
debtId = closedDebt
)

try {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import org.totschnig.myexpenses.provider.TransactionProvider
import org.totschnig.myexpenses.provider.insert
import org.totschnig.myexpenses.testutils.BaseDbTest
import org.totschnig.shared_test.CursorSubject.Companion.useAndAssert
import java.util.Date

class TransactionTest : BaseDbTest() {
private lateinit var infos: Array<TransactionInfo>
Expand All @@ -44,9 +43,24 @@ class TransactionTest : BaseDbTest() {

private fun insertData() {
infos = arrayOf(
TransactionInfo(testAccountId, 0, Date(), "Transaction 0", payeeId),
TransactionInfo(testAccountId, 100, Date(), "Transaction 1", payeeId),
TransactionInfo(testAccountId, -100, Date(), "Transaction 2", payeeId)
TransactionInfo(
accountId = testAccountId,
amount = 0,
comment = "Transaction 0",
payeeId = payeeId
),
TransactionInfo(
accountId = testAccountId,
amount = 100,
comment = "Transaction 1",
payeeId = payeeId
),
TransactionInfo(
accountId = testAccountId,
amount = -100,
comment = "Transaction 2",
payeeId = payeeId
)
)

for (transactionInfo in infos) {
Expand Down Expand Up @@ -190,8 +204,10 @@ class TransactionTest : BaseDbTest() {
*/
fun testInserts() {
val transaction = TransactionInfo(
testAccountId,
1000, Date(), "Transaction 4", payeeId
accountId = testAccountId,
amount = 1000,
comment = "Transaction 4",
payeeId = payeeId
)

// Insert subtest 1.
Expand Down Expand Up @@ -239,8 +255,10 @@ class TransactionTest : BaseDbTest() {
//Test that we can't insert a record that links to an account_id that does not exist
fun testInsertViolatesForeignKey() {
val transaction = TransactionInfo(
testAccountId + 1,
1000, Date(), "Transaction 4", payeeId
accountId = testAccountId + 1,
amount = 1000,
comment = "Transaction 4",
payeeId = payeeId
)
try {
mockContentResolver.insert(
Expand Down

0 comments on commit 64a49db

Please sign in to comment.