Skip to content

Commit

Permalink
refactor(AndroidTest): remove col dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
david-allison committed Dec 17, 2024
1 parent 0d4d515 commit 110a177
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
5 changes: 4 additions & 1 deletion AnkiDroid/src/test/java/com/ichi2/anki/RobolectricTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import com.ichi2.libanki.utils.TimeManager
import com.ichi2.testutils.AndroidTest
import com.ichi2.testutils.MockTime
import com.ichi2.testutils.TaskSchedulerRule
import com.ichi2.testutils.TestClass
import com.ichi2.testutils.common.FailOnUnhandledExceptionRule
import com.ichi2.testutils.common.IgnoreFlakyTestsInCIRule
import com.ichi2.testutils.filter
Expand Down Expand Up @@ -75,7 +76,9 @@ import org.robolectric.shadows.ShadowMediaPlayer
import timber.log.Timber
import kotlin.test.assertNotNull

open class RobolectricTest : AndroidTest {
open class RobolectricTest :
TestClass,
AndroidTest {
@Suppress("PLATFORM_CLASS_MAPPED_TO_KOTLIN")
private fun Any.wait(timeMs: Long) = (this as Object).wait(timeMs)

Expand Down
15 changes: 13 additions & 2 deletions AnkiDroid/src/test/java/com/ichi2/testutils/AndroidTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,21 @@ import android.content.Context
import android.content.SharedPreferences
import androidx.core.content.edit
import androidx.test.core.app.ApplicationProvider
import com.ichi2.anki.RobolectricTest
import com.ichi2.anki.preferences.sharedPrefs

/** Marker interface for classes annotated with `@RunWith(AndroidJUnit4.class)` */
interface AndroidTest : TestClass
/**
* Marker interface for classes annotated with `@RunWith(AndroidJUnit4.class)` which do
* not need access to the collection
*
* Classes should also be marked with `@Config(application = EmptyApplication::class)` for
* performance improvements
*
* Use [JvmTest] if a reference to Android is not necessary but the collection is required
*
* Use [RobolectricTest] if access the collection is necessary
*/
interface AndroidTest

val AndroidTest.targetContext: Context
get() {
Expand Down

0 comments on commit 110a177

Please sign in to comment.