Skip to content

Commit

Permalink
chore: extract test methods to trsts
Browse files Browse the repository at this point in the history
  • Loading branch information
david-allison committed Dec 14, 2023
1 parent b4db9f8 commit 5e4eae5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 14 deletions.
16 changes: 3 additions & 13 deletions AnkiDroid/src/main/java/com/ichi2/anki/AbstractFlashcardViewer.kt
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,9 @@ abstract class AbstractFlashcardViewer :

// Android WebView
var automaticAnswer = AutomaticAnswer.defaultInstance(this)
protected var typeAnswer: TypeAnswer? = null

@VisibleForTesting(otherwise = VisibleForTesting.PROTECTED)
internal var typeAnswer: TypeAnswer? = null

/** Generates HTML content */
private var mHtmlGenerator: HtmlGenerator? = null
Expand Down Expand Up @@ -2662,9 +2664,6 @@ abstract class AbstractFlashcardViewer :
}
}

@VisibleForTesting(otherwise = VisibleForTesting.NONE)
protected val typedInputText get() = typeAnswer!!.input

@SuppressLint("WebViewApiAvailability")
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
fun handleUrlFromJavascript(url: String) {
Expand All @@ -2678,21 +2677,12 @@ abstract class AbstractFlashcardViewer :
}
}

@VisibleForTesting
fun loadInitialCard() {
launchCatchingTask { updateCardAndRedraw() }
}

val isDisplayingAnswer
get() = displayAnswer

open val isControlBlocked: Boolean
get() = controlBlocked !== ControlBlock.UNBLOCKED

@VisibleForTesting(otherwise = VisibleForTesting.NONE)
@KotlinCleanup("move to test class as extension")
val correctTypedAnswer get() = typeAnswer!!.correct

internal fun showTagsDialog() {
val tags = ArrayList(getColUnsafe.tags.all())
val selTags = ArrayList(currentCard!!.note().tags)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class AbstractFlashcardViewerTest : RobolectricTest() {
// intentionally blank
}

val typedInput get() = super.typedInputText
val typedInput get() = typedInputText

override fun answerCard(ease: Int) {
super.answerCard(ease)
Expand Down Expand Up @@ -354,3 +354,8 @@ class AbstractFlashcardViewerTest : RobolectricTest() {
}
}
}

fun AbstractFlashcardViewer.loadInitialCard() = launchCatchingTask { updateCardAndRedraw() }

val AbstractFlashcardViewer.typedInputText get() = typeAnswer!!.input
val AbstractFlashcardViewer.correctTypedAnswer get() = typeAnswer!!.correct

0 comments on commit 5e4eae5

Please sign in to comment.