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

[Kotlin Cleanup] Various

This commit is contained in:
oyeraghib 2022-05-10 13:03:10 +05:30 committed by Mike Hardy
parent 6148c90ebb
commit e992dab68d
2 changed files with 6 additions and 11 deletions

View File

@ -17,17 +17,13 @@ package com.ichi2.anki
import android.content.Intent
import android.graphics.Color
import com.ichi2.utils.KotlinCleanup
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.`is`
import org.hamcrest.Matchers.equalTo
import org.junit.Test
import org.junit.runner.RunWith
import org.robolectric.ParameterizedRobolectricTestRunner
import java.util.*
@RunWith(ParameterizedRobolectricTestRunner::class)
@KotlinCleanup("IDE lint")
@KotlinCleanup("`is` -> equalTo")
class WhiteboardDefaultForegroundColorTest : RobolectricTest() {
@ParameterizedRobolectricTestRunner.Parameter
@JvmField
@ -38,10 +34,10 @@ class WhiteboardDefaultForegroundColorTest : RobolectricTest() {
var mExpectedResult = 0
@Test
fun testDefaultForegroundColor() {
assertThat(foregroundColor, `is`(mExpectedResult))
assertThat(foregroundColor, equalTo(mExpectedResult))
}
protected val foregroundColor: Int
private val foregroundColor: Int
get() {
val mock: AbstractFlashcardViewer = super.startActivityNormallyOpenCollectionWithIntent(Reviewer::class.java, Intent())
return Whiteboard(mock, true, mIsInverted).foregroundColor
@ -51,7 +47,7 @@ class WhiteboardDefaultForegroundColorTest : RobolectricTest() {
@ParameterizedRobolectricTestRunner.Parameters
@JvmStatic
fun initParameters(): Collection<Array<Any>> {
return Arrays.asList(*arrayOf(arrayOf(true, Color.WHITE), arrayOf(false, Color.BLACK)))
return mutableListOf((arrayOf(true, Color.WHITE)), arrayOf(false, Color.BLACK))
}
}
}

View File

@ -5,13 +5,12 @@ package com.ichi2.libanki
import androidx.test.ext.junit.runners.AndroidJUnit4
import com.ichi2.anki.RobolectricTest
import com.ichi2.utils.JSONException
import com.ichi2.utils.KotlinCleanup
import org.hamcrest.MatcherAssert.assertThat
import org.hamcrest.Matchers.*
import org.junit.Assert.*
import org.junit.Test
import org.junit.runner.RunWith
@KotlinCleanup("is -> equalTo")
@RunWith(AndroidJUnit4::class)
class ClozeTest : RobolectricTest() {
@Test
@ -26,7 +25,7 @@ class ClozeTest : RobolectricTest() {
}
// a cloze model with no clozes is not empty
f.setItem("Text", "nothing")
assertThat(d.addNote(f), `is`(greaterThan(0)))
assertThat(d.addNote(f), greaterThan(0))
val card = f.cards()[0]
assertTrue(card.isEmpty)
// try with one cloze