sergio-sastre / AndroidUiTestingUtils

A set of TestRules, ActivityScenarios and utils to facilitate UI and screenshot testing under given configurations: FontSizes, Locales...
MIT License
285 stars 14 forks source link

Support non-linear font sizes #86

Closed sergio-sastre closed 3 months ago

sergio-sastre commented 8 months ago

Currently, FontSize supports only till HUGE, which is 1.3f Since Android 34, it is possible to scale up to 2.0f, and this scaling is not linear.

Robolectric supports that as well.

the idea is to add the new values, e.g EXTRA_HUGE(1.5f) EXTREMELY_HUGE(1.8f) MAXIMUM(2.0f)

that will run on API 34+ and such tests will skip on API <34

Additionally add other values that will force these new font scaling in older API e.g FORCED_EXTRA_HUGE(1.5f) etc.

sergio-sastre commented 4 months ago

Update: It's plan to look as follows:

SMALL(0.85f),
    NORMAL(1f),
    LARGE(1.15f),
    @Discouraged("Use XLARGE instead") HUGE(1.3f),
    XLARGE(1.3f),
    XXLARGE(1.5f),
    XXXLARGE(1.8f),
    LARGEST(2.0f)

Moreover, custom values will also be allowed. Some examples:

ActivityScenarioForComposableRule(
   config = ComposableConfig(fontSize = FontSize.XXLARGE)
)

or

ActivityScenarioForComposableRule(
   config = ComposableConfig(fontSize = FontSizeScaleValue(2.2f))
)

Additionally, you can skip non-officially-supported values by calling the following method at the beginning of a test:

assumeSupportsFontSizeScale(FontSize.XXLARGE))

This will skip that test if SDK < 34.

The reasoning behind is that you might want to test it anyway, since some Manufactures build on top of standard Android OS and provide their custom Font Size Options in some models (Hello Samsung!). That is allowed by default

No breaking changes expected :) :)

sergio-sastre commented 3 months ago

included in 2.3.0