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

Commit 44366c96 authored by Tyler Freeman's avatar Tyler Freeman
Browse files

fix(non linear font scaling): add missing @Test annotations

Had to fix visibility on a couple fields under test.

Bug: 239736383
Test: atest FrameworksCoreTests:android.content.res.FontScaleConverterActivityTest

Change-Id: Id746323bebf3840c943e70ce6f7c2b04a8432603
parent a16cb467
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -37,10 +37,13 @@ import java.util.Arrays;
 */
public class FontScaleConverter {

    /** @hide */
    @VisibleForTesting
    final float[] mFromSpValues;
    public final float[] mFromSpValues;

    /** @hide */
    @VisibleForTesting
    final float[] mToDpValues;
    public final float[] mToDpValues;

    /**
     * Creates a lookup table for the given conversions.
+2 −1
Original line number Diff line number Diff line
@@ -31,8 +31,9 @@ import com.android.internal.annotations.VisibleForTesting;
public class FontScaleConverterFactory {
    private static final float SCALE_KEY_MULTIPLIER = 100f;

    /** @hide */
    @VisibleForTesting
    static final SparseArray<FontScaleConverter> LOOKUP_TABLES = new SparseArray<>();
    public static final SparseArray<FontScaleConverter> LOOKUP_TABLES = new SparseArray<>();

    private static float sMinScaleBeforeCurvesApplied = 1.05f;

+5 −13
Original line number Diff line number Diff line
@@ -61,19 +61,6 @@ class FontScaleConverterFactoryTest {
        assertThat(table.convertSpToDp(100F)).isWithin(CONVERSION_TOLERANCE).of(300f)
    }

    @SmallTest
    fun missingLookupTable110_returnsInterpolated() {
        val table = FontScaleConverterFactory.forScale(1.1F)!!

        assertThat(table.convertSpToDp(1F)).isWithin(CONVERSION_TOLERANCE).of(1.1f)
        assertThat(table.convertSpToDp(8F)).isWithin(CONVERSION_TOLERANCE).of(8f * 1.1f)
        assertThat(table.convertSpToDp(10F)).isWithin(CONVERSION_TOLERANCE).of(11f)
        assertThat(table.convertSpToDp(5F)).isWithin(CONVERSION_TOLERANCE).of(5f * 1.1f)
        assertThat(table.convertSpToDp(0F)).isWithin(CONVERSION_TOLERANCE).of(0f)
        assertThat(table.convertSpToDp(50F)).isLessThan(50f * 1.1f)
        assertThat(table.convertSpToDp(100F)).isLessThan(100f * 1.1f)
    }

    @Test
    fun missingLookupTable199_returnsInterpolated() {
        val table = FontScaleConverterFactory.forScale(1.9999F)!!
@@ -97,18 +84,22 @@ class FontScaleConverterFactoryTest {
    }

    @SmallTest
    @Test
    fun missingLookupTableNegativeReturnsNull() {
        assertThat(FontScaleConverterFactory.forScale(-1F)).isNull()
    }

    @SmallTest
    @Test
    fun unnecessaryFontScalesReturnsNull() {
        assertThat(FontScaleConverterFactory.forScale(0F)).isNull()
        assertThat(FontScaleConverterFactory.forScale(1F)).isNull()
        assertThat(FontScaleConverterFactory.forScale(1.1F)).isNull()
        assertThat(FontScaleConverterFactory.forScale(0.85F)).isNull()
    }

    @SmallTest
    @Test
    fun tablesMatchAndAreMonotonicallyIncreasing() {
        FontScaleConverterFactory.LOOKUP_TABLES.forEach { _, lookupTable ->
            assertThat(lookupTable.mToDpValues).hasLength(lookupTable.mFromSpValues.size)
@@ -123,6 +114,7 @@ class FontScaleConverterFactoryTest {
    }

    @SmallTest
    @Test
    fun testIsNonLinearFontScalingActive() {
        assertThat(FontScaleConverterFactory.isNonLinearFontScalingActive(1f)).isFalse()
        assertThat(FontScaleConverterFactory.isNonLinearFontScalingActive(0f)).isFalse()