Skip to content

Commit

Permalink
style(lint): result of auto-formatting run mixed with some hand fixes
Browse files Browse the repository at this point in the history
which is a bad practice really, but I'm still learning how to drive the
linter via suppression etc
  • Loading branch information
mikehardy committed Dec 22, 2023
1 parent 9bd6587 commit 05b4c94
Show file tree
Hide file tree
Showing 639 changed files with 18,543 additions and 12,649 deletions.
10 changes: 5 additions & 5 deletions AnkiDroid/src/androidTest/java/com/ichi2/anki/DeckPickerTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ class DeckPickerTest : InstrumentedTest() {
onView(withId(R.id.files)).perform(
RecyclerViewActions.actionOnItem<RecyclerView.ViewHolder>(
hasDescendant(withText("TestDeck$testString")),
clickChildViewWithId(R.id.counts_layout)
)
clickChildViewWithId(R.id.counts_layout),
),
)

// without this sleep, the study options fragment sometimes loses the "load and become active" race vs the assertion below.
Expand All @@ -77,7 +77,7 @@ class DeckPickerTest : InstrumentedTest() {
// Check if currently open Activity is StudyOptionsActivity
assertThat(
activityInstance,
instanceOf(StudyOptionsActivity::class.java)
instanceOf(StudyOptionsActivity::class.java),
)
}

Expand Down Expand Up @@ -108,8 +108,8 @@ class DeckPickerTest : InstrumentedTest() {
onView(withId(R.id.files)).perform(
RecyclerViewActions.actionOnItem<RecyclerView.ViewHolder>(
hasDescendant(withText("TestDeck$testString")),
clickChildViewWithId(R.id.counts_layout)
)
clickChildViewWithId(R.id.counts_layout),
),
)

// Create a card belonging to the new deck, using Basic type (guaranteed to exist)
Expand Down
22 changes: 12 additions & 10 deletions AnkiDroid/src/androidTest/java/com/ichi2/anki/FieldEditLineTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,12 @@ import java.util.concurrent.atomic.AtomicReference
class FieldEditLineTest : NoteEditorTest() {
@Test
fun testSetters() {
val line = fieldEditLine().apply {
setContent("Hello", true)
name = "Name"
setOrd(5)
}
val line =
fieldEditLine().apply {
setContent("Hello", true)
name = "Name"
setOrd(5)
}
val text = line.editText
assertThat(text.ord, equalTo(5))
assertThat(text.text.toString(), equalTo("Hello"))
Expand All @@ -39,11 +40,12 @@ class FieldEditLineTest : NoteEditorTest() {

@Test
fun testSaveRestore() {
val toSave = fieldEditLine().apply {
setContent("Hello", true)
name = "Name"
setOrd(5)
}
val toSave =
fieldEditLine().apply {
setContent("Hello", true)
name = "Name"
setOrd(5)
}
val b = toSave.onSaveInstanceState()

val restored = fieldEditLine()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ class NoteEditorTabOrderTest : NoteEditorTest() {
java.lang.AssertionError:
Expected: is "a""""
Expected: is "a"""",
)
@Throws(Throwable::class)
fun testTabOrder() {
Expand All @@ -66,7 +66,10 @@ class NoteEditorTabOrderTest : NoteEditorTest() {
}
}

private fun sendKeyDownUp(activity: Activity, keyCode: Int) {
private fun sendKeyDownUp(
activity: Activity,
keyCode: Int,
) {
val focusedView = activity.currentFocus
if (focusedView != null) {
val inputConnection = BaseInputConnection(focusedView, true)
Expand All @@ -78,7 +81,7 @@ class NoteEditorTabOrderTest : NoteEditorTest() {
@Throws(Throwable::class)
private fun onActivity(
scenario: ActivityScenario<NoteEditor>,
noteEditorActivityAction: ActivityAction<NoteEditor>
noteEditorActivityAction: ActivityAction<NoteEditor>,
) {
val wrapped = AtomicReference<Throwable?>(null)
scenario.onActivity { a: NoteEditor ->
Expand Down
13 changes: 7 additions & 6 deletions AnkiDroid/src/androidTest/java/com/ichi2/anki/NoteEditorTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,10 @@ abstract class NoteEditorTest protected constructor() {
var runtimePermissionRule: TestRule? = GrantStoragePermission.instance

@get:Rule
var activityRule: ActivityScenarioRule<NoteEditor>? = ActivityScenarioRule(
noteEditorIntent
)
var activityRule: ActivityScenarioRule<NoteEditor>? =
ActivityScenarioRule(
noteEditorIntent,
)

private val noteEditorIntent: Intent
get() {
Expand All @@ -53,8 +54,8 @@ abstract class NoteEditorTest protected constructor() {
"Test fails on Travis API $invalid",
Build.VERSION.SDK_INT,
not(
equalTo(invalid)
)
equalTo(invalid),
),
)
}
}
Expand All @@ -64,7 +65,7 @@ abstract class NoteEditorTest protected constructor() {
/*
java.lang.AssertionError: Activity never becomes requested state "[DESTROYED]" (last lifecycle transition = "PAUSED")
at androidx.test.core.app.ActivityScenario.waitForActivityToBecomeAnyOf(ActivityScenario.java:301)
*/
*/
val invalid = Build.VERSION_CODES.N_MR1
val integers = ArrayList(listOf(invalid))
integers.addAll(invalidSdks!!)
Expand Down
26 changes: 15 additions & 11 deletions AnkiDroid/src/androidTest/java/com/ichi2/anki/PagesActivityTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -68,16 +68,17 @@ class PagesActivityTest : InstrumentedTest() {
@JvmStatic // required for initParameters
fun initParameters(): Collection<Array<out Any>> {
/** See [PageFragment] */
val intents = listOf<Pair<PagesActivityTest.(Context) -> Intent, String>>(
Pair(PagesActivityTest::getStatistics, "Statistics"),
Pair(PagesActivityTest::getCardInfo, "CardInfo"),
Pair(PagesActivityTest::getCongratsPage, "CongratsPage"),
Pair(PagesActivityTest::getDeckOptions, "DeckOptions"),
// the following need a file path
Pair(PagesActivityTest::needsPath, "AnkiPackageImporterFragment"),
Pair(PagesActivityTest::needsPath, "CsvImporter"),
Pair(PagesActivityTest::needsPath, "ImageOcclusion")
)
val intents =
listOf<Pair<PagesActivityTest.(Context) -> Intent, String>>(
Pair(PagesActivityTest::getStatistics, "Statistics"),
Pair(PagesActivityTest::getCardInfo, "CardInfo"),
Pair(PagesActivityTest::getCongratsPage, "CongratsPage"),
Pair(PagesActivityTest::getDeckOptions, "DeckOptions"),
// the following need a file path
Pair(PagesActivityTest::needsPath, "AnkiPackageImporterFragment"),
Pair(PagesActivityTest::needsPath, "CsvImporter"),
Pair(PagesActivityTest::needsPath, "ImageOcclusion"),
)

return intents.map { arrayOf(it.first, it.second) }
}
Expand All @@ -101,11 +102,14 @@ fun PagesActivityTest.getCongratsPage(context: Context): Intent {
CardInfoDestination(card.id).toIntent(context)
}
}

fun PagesActivityTest.getDeckOptions(context: Context): Intent {
return DeckOptions.getIntent(context, col.decks.allNamesAndIds().first().id)
}

fun PagesActivityTest.needsPath(@Suppress("UNUSED_PARAMETER") context: Context): Intent {
fun PagesActivityTest.needsPath(
@Suppress("UNUSED_PARAMETER") context: Context,
): Intent {
assumeThat("not implemented: path needed", false, equalTo(true))
TODO()
}
Loading

0 comments on commit 05b4c94

Please sign in to comment.