deviceConfiguration

fun deviceConfiguration(locales: LocaleList? = null, layoutDirection: LayoutDirection? = null, fontScale: Float? = null, darkMode: Boolean? = null, size: DpSize? = null): DeviceConfigurationOverride(source)

Combines the device settings a UI test most often varies into one override; null leaves a setting unchanged.

Apply it around the content under test, so one test class can cover right-to-left layouts, large text, and dark mode without changing the emulator:

composeRule.setContent {
DeviceConfigurationOverride(deviceConfiguration(locales = LocaleList("fa"), fontScale = 2f)) {
AppTheme { Calendar() }
}
}

Return

The combined override.

Parameters

locales

The locales to report, such as LocaleList("fa-IR").

layoutDirection

The layout direction; defaults to the locale's direction when null.

fontScale

The font scale, such as 2f for 200%.

darkMode

Whether the system is in dark mode.

size

A forced size for the content.