0
0
mirror of https://github.com/ankidroid/Anki-Android.git synced 2024-09-20 12:02:16 +02:00

fix: StackOverflowException in androidTest

Cause: `getDefaultAnkiDroidDirectory` caused recursion.
This recursion is normally gated on the existence of PREF_COLLECTION_PATH
But we didn't take this into account when in INSTRUMENTATION_TEST mode

This is fixed incidentally by 6dcf23fd10,
but the underlying cause wasn't handled

Tested by rebasing onto d88ad6251c
and running tests on `playDebug` (API 32 emulator)

Tests now fail due to an alternate setup issue

```
java.lang.NullPointerException
at com.ichi2.anki.TestUtils.isScreenSw600dp(TestUtils.kt:78)
at com.ichi2.anki.DeckPickerTest.checkIfStudyOptionsIsDisplayedOnTablet(DeckPickerTest.kt:91)
```

Fixes 13644
This commit is contained in:
David Allison 2023-04-22 16:45:10 +01:00 committed by Arthur Milchior
parent c0d004b511
commit d133123cea

View File

@ -544,8 +544,9 @@ open class CollectionHelper {
return if (AnkiDroidApp.INSTRUMENTATION_TESTING) {
// create an "androidTest" directory inside the current collection directory which contains the test data
// "/AnkiDroid/androidTest" would be a new collection path
val currentCollectionDirectory = preferences.getOrSetString(PREF_COLLECTION_PATH) { getDefaultAnkiDroidDirectory(context) }
File(
getDefaultAnkiDroidDirectory(context),
currentCollectionDirectory,
"androidTest"
).absolutePath
} else if (ankiDroidDirectoryOverride != null) {