Usage
In these sections, you'll find how to configure your screenshot tests with AndroidUiTestingUtils with different libraries. Currently, the following configurations are supported:
Locale
UI Mode (i.e. Light/Dark mode)
Custom theme
Font Size
Display Size
Font Size
Since SDK 34, Android uses non-linear font scaling and enabled users to scale system fonts up to 200%.
AndroidUiTestingUtils allows setting font scaling via FontSizeTestRule or fontSize configuration in the corresponding ActivityScenarioForXXXRule and RobolectricActivityScenarioForXXXRule, where XXX is an Activity, Fragment, View, Composable... You can set the font scaling factor value in several means:
Custom Font Scale
Linear + Non-linear
You can also use the default values provided by AndroidUiTestingUtils, which correspond to those users can configure on their devices under Configuration > Accessibility > Font Size.
Keep in mind that the same value might result in a different screenshot depending on whether the SDK the tests are running on supports linear or non-linear font scaling
Some of these values are only available on devices running an SDK that supports non-linear scaling (i.e. SDK 34+)
You can get an Array with only the Linear/Non-Linear values depending on the SDK with
FontSizeScale.supportedValuesForCurrentSdk()
You can find these values below
Linear
Previous to AndroidUiTestingUtils 2.3.0, only these values were supported
Non-linear
FontSize.LARGEST
applies different scale factors depending on the SDK.
Skip Tests
You can skip FontSizeScales that the current API Level does not support by using assumeSdkSupports
at the beginning of the test, for instance:
Last updated