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

Commit e434d879 authored by Tyler Freeman's avatar Tyler Freeman Committed by Android (Google) Code Review
Browse files

Merge "fix(non linear font scaling): fix tests polluting the cache" into main

parents 311f15de c6858671
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -20,12 +20,15 @@ import android.platform.test.annotations.Presubmit
import android.platform.test.annotations.RequiresFlagsEnabled
import android.platform.test.flag.junit.CheckFlagsRule
import android.platform.test.flag.junit.DeviceFlagsValueProvider
import android.util.SparseArray
import androidx.core.util.forEach
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.LargeTest
import androidx.test.filters.SmallTest
import com.google.common.truth.Truth.assertThat
import com.google.common.truth.Truth.assertWithMessage
import org.junit.After
import org.junit.Before
import org.junit.Rule
import kotlin.math.ceil
import kotlin.math.floor
@@ -45,6 +48,19 @@ class FontScaleConverterFactoryTest {
    @get:Rule
    val checkFlagsRule: CheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule()

    private lateinit var defaultLookupTables: SparseArray<FontScaleConverter>

    @Before
    fun setup() {
        defaultLookupTables = FontScaleConverterFactory.sLookupTables.clone()
    }

    @After
    fun teardown() {
        // Restore the default tables (since some tests will have added extras to the cache)
        FontScaleConverterFactory.sLookupTables = defaultLookupTables
    }

    @Test
    fun scale200IsTwiceAtSmallSizes() {
        val table = FontScaleConverterFactory.forScale(2F)!!
@@ -245,7 +261,7 @@ class FontScaleConverterFactoryTest {
    }

    companion object {
        private const val CONVERSION_TOLERANCE = 0.05f
        private const val CONVERSION_TOLERANCE = 0.18f
    }
}