Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4f02784f authored by Tyler Freeman's avatar Tyler Freeman
Browse files

chore(non linear font scaling): add FontScaleConverter tests to presubmit

Reduce scope of tests so they don't time out.

Test: atest FrameworksCoreTests:android.content.res.FontScaleConverterTest \
  &&  atest FrameworksCoreTests:android.content.res.FontScaleConverterFactoryTest \
  &&  atest FrameworksCoreTests:android.util.TypedValueTest

Bug: b/264885708

Change-Id: I0915fb68cb228360fb26897edc2f1c1ccbd526d4
parent bfb5f457
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -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) ->
+2 −0
Original line number Diff line number Diff line
@@ -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 {

+3 −3
Original line number Diff line number Diff line
@@ -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)