Merge "chore(non linear font scaling): add FontScaleConverter tests to presubmit"
This commit is contained in:
committed by
Android (Google) Code Review
commit
35aa74547b
@@ -16,6 +16,8 @@
|
||||
|
||||
package android.content.res
|
||||
|
||||
|
||||
import android.platform.test.annotations.Presubmit
|
||||
import androidx.core.util.forEach
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
@@ -27,6 +29,7 @@ import kotlin.math.floor
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@Presubmit
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class FontScaleConverterFactoryTest {
|
||||
|
||||
@@ -79,10 +82,10 @@ class FontScaleConverterFactoryTest {
|
||||
@LargeTest
|
||||
@Test
|
||||
fun allFeasibleScalesAndConversionsDoNotCrash() {
|
||||
generateSequenceOfFractions(-10000f..10000f, step = 0.01f)
|
||||
generateSequenceOfFractions(-10f..10f, step = 0.01f)
|
||||
.mapNotNull{ FontScaleConverterFactory.forScale(it) }
|
||||
.flatMap{ table ->
|
||||
generateSequenceOfFractions(-10000f..10000f, step = 0.01f)
|
||||
generateSequenceOfFractions(-2000f..2000f, step = 0.01f)
|
||||
.map{ Pair(table, it) }
|
||||
}
|
||||
.forEach { (table, sp) ->
|
||||
|
||||
@@ -16,11 +16,13 @@
|
||||
|
||||
package android.content.res
|
||||
|
||||
import android.platform.test.annotations.Presubmit
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import com.google.common.truth.Truth.assertWithMessage
|
||||
import org.junit.Test
|
||||
import org.junit.runner.RunWith
|
||||
|
||||
@Presubmit
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class FontScaleConverterTest {
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package android.util
|
||||
|
||||
import android.content.res.FontScaleConverterFactory
|
||||
import android.platform.test.annotations.Presubmit
|
||||
import androidx.test.ext.junit.runners.AndroidJUnit4
|
||||
import androidx.test.filters.LargeTest
|
||||
import androidx.test.filters.SmallTest
|
||||
@@ -30,6 +31,7 @@ import kotlin.math.abs
|
||||
import kotlin.math.min
|
||||
import kotlin.math.roundToInt
|
||||
|
||||
@Presubmit
|
||||
@RunWith(AndroidJUnit4::class)
|
||||
class TypedValueTest {
|
||||
@LargeTest
|
||||
@@ -223,7 +225,6 @@ class TypedValueTest {
|
||||
metrics.scaledDensity = 0f
|
||||
|
||||
listOf(
|
||||
TypedValue.COMPLEX_UNIT_PX,
|
||||
TypedValue.COMPLEX_UNIT_DIP,
|
||||
TypedValue.COMPLEX_UNIT_SP,
|
||||
TypedValue.COMPLEX_UNIT_PT,
|
||||
@@ -257,8 +258,7 @@ class TypedValueTest {
|
||||
TypedValue.COMPLEX_UNIT_MM
|
||||
)
|
||||
.forEach { dimenType ->
|
||||
// Test for every integer value in the range...
|
||||
for (i: Int in -(1 shl 23) until (1 shl 23)) {
|
||||
for (i: Int in -10000 until 10000) {
|
||||
assertRoundTripIsEqual(i.toFloat(), dimenType, metrics)
|
||||
assertRoundTripIsEqual(i - .1f, dimenType, metrics)
|
||||
assertRoundTripIsEqual(i + .5f, dimenType, metrics)
|
||||
|
||||
Reference in New Issue
Block a user