Skip to content

Commit 1adbfe3

Browse files
committed
Fixed: disabling of animations during testing for beta and production builds
Added waiting time between tests
1 parent 1bd18d2 commit 1adbfe3

5 files changed

Lines changed: 25 additions & 20 deletions

File tree

app/build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ afterEvaluate {
132132
commandLine "$adb shell pm grant $android.productFlavors.development.applicationId android.permission.SET_ANIMATION_SCALE".split(' ')
133133
}
134134

135-
task grantAnimationPermissionProduction(type: Exec, dependsOn: ['installBetaDebug', 'installProductionDebug']){
136-
commandLine "$adb shell pm grant $android.productFlavors.production.applicationId android.permission.SET_ANIMATION_SCALE".split(' ')
135+
task grantAnimationPermissionProduction(type: Exec, dependsOn: 'installProductionDebug'){
136+
commandLine "$adb shell pm grant $android.defaultConfig.applicationId android.permission.SET_ANIMATION_SCALE".split(' ')
137137
}
138138
// When launching individual tests from Android Studio, it seems that only the assemble tasks
139139
// get called directly, not the install* versions

app/src/androidTest/java/org/gnucash/android/test/ui/AccountsActivityTest.java

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void setUp() throws Exception {
9696
mSplitsDbAdapter = new SplitsDbAdapter(mDb);
9797
mTransactionsDbAdapter = new TransactionsDbAdapter(mDb, mSplitsDbAdapter);
9898
mAccountsDbAdapter = new AccountsDbAdapter(mDb, mTransactionsDbAdapter);
99-
99+
100100
Account account = new Account(DUMMY_ACCOUNT_NAME);
101101
account.setUID(DUMMY_ACCOUNT_UID);
102102
account.setCurrency(Currency.getInstance(DUMMY_ACCOUNT_CURRENCY_CODE));
@@ -246,43 +246,47 @@ public void testDeleteAccount() {
246246
transaction.addSplit(new Split(Money.getZeroInstance(), DUMMY_ACCOUNT_UID));
247247
mTransactionsDbAdapter.addTransaction(transaction);
248248

249-
onView(withId(R.id.primary_text)).perform(longClick());
249+
onView(withText(DUMMY_ACCOUNT_NAME)).perform(longClick());
250250
onView(withId(R.id.context_menu_delete)).perform(click());
251-
onView(withText(R.string.label_delete_sub_accounts)).perform(click());
251+
252+
//the account has no sub-accounts
253+
onView(withId(R.id.accounts_options)).check(matches(not(isDisplayed())));
254+
onView(withId(R.id.transactions_options)).check(matches(isDisplayed()));
255+
256+
onView(withText(R.string.label_delete_transactions)).perform(click());
252257
onView(withId(R.id.btn_save)).perform(click());
253258

254259
//should throw expected exception
255260
mAccountsDbAdapter.getID(DUMMY_ACCOUNT_UID);
256261

257262
List<Transaction> transactions = mTransactionsDbAdapter.getAllTransactionsForAccount(DUMMY_ACCOUNT_UID);
258-
assertThat(transactions).hasSize(0);
263+
assertThat(transactions).isEmpty();
259264
}
260265

261266
//TODO: Test import of account file
262267
//TODO: test settings activity
263268
@Test
264269
public void testIntentAccountCreation(){
265270
Intent intent = new Intent(Intent.ACTION_INSERT);
266-
intent.putExtra(Intent.EXTRA_TITLE, "Intent Account");
267-
intent.putExtra(Intent.EXTRA_UID, "intent-account");
271+
intent.putExtra(Intent.EXTRA_TITLE, "Intent Account");
272+
intent.putExtra(Intent.EXTRA_UID, "intent-account");
268273
intent.putExtra(Account.EXTRA_CURRENCY_CODE, "EUR");
269274
intent.setType(Account.MIME_TYPE);
270275

271-
AccountCreator accountCreator = new AccountCreator();
272-
accountCreator.onReceive(mAcccountsActivity, intent);
276+
new AccountCreator().onReceive(mAcccountsActivity, intent);
273277

274278
Account account = mAccountsDbAdapter.getAccount("intent-account");
275-
assertNotNull(account);
276-
assertEquals("Intent Account", account.getName());
277-
assertEquals("intent-account", account.getUID());
278-
assertEquals("EUR", account.getCurrency().getCurrencyCode());
279+
assertThat(account).isNotNull();
280+
assertThat(account.getName()).isEqualTo("Intent Account");
281+
assertThat(account.getUID()).isEqualTo("intent-account");
282+
assertThat(account.getCurrency().getCurrencyCode()).isEqualTo("EUR");
279283
}
280284

281285
@After
282286
public void tearDown() throws Exception {
283287
mAcccountsActivity.finish();
284-
Thread.sleep(1000);
285-
mAccountsDbAdapter.deleteAllRecords();
288+
Thread.sleep(2000);
289+
mAccountsDbAdapter.deleteAllRecords(); //clear the data
286290
super.tearDown();
287291
}
288292

app/src/androidTest/java/org/gnucash/android/test/ui/TransactionsActivityTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ public void setUp() throws Exception {
125125
mSplitsDbAdapter = new SplitsDbAdapter(mDb);
126126
mTransactionsDbAdapter = new TransactionsDbAdapter(mDb, mSplitsDbAdapter);
127127
mAccountsDbAdapter = new AccountsDbAdapter(mDb, mTransactionsDbAdapter);
128-
mAccountsDbAdapter.deleteAllRecords();
129128

130129
mTransactionTimeMillis = System.currentTimeMillis();
131130
Account account = new Account(DUMMY_ACCOUNT_NAME);
@@ -541,7 +540,8 @@ private void clickOnView(int viewId){
541540
@After
542541
public void tearDown() throws Exception {
543542
mTransactionsActivity.finish();
544-
Thread.sleep(1000);
543+
Thread.sleep(2000);
544+
mAccountsDbAdapter.deleteAllRecords();
545545
super.tearDown();
546546
}
547547
}

app/src/debug/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@
1515
limitations under the License.
1616
-->
1717

18-
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
18+
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
19+
package="org.gnucash.android">
1920
<!-- Disable animations on debug builds so that the animations do not interfere with Espresso
2021
tests. Adding this permission to the manifest is not sufficient - you must also grant the
2122
permission over adb! -->

app/src/main/java/org/gnucash/android/db/TransactionsDbAdapter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ public Cursor fetchAllTransactionsForAccount(long accountID){
301301
*/
302302
public List<Transaction> getAllTransactionsForAccount(String accountUID){
303303
Cursor c = fetchAllTransactionsForAccount(accountUID);
304-
ArrayList<Transaction> transactionsList = new ArrayList<Transaction>();
304+
ArrayList<Transaction> transactionsList = new ArrayList<>();
305305
try {
306306
while (c.moveToNext()) {
307307
transactionsList.add(buildTransactionInstance(c));

0 commit comments

Comments
 (0)