Skip to main content
Version: 3.2.0

Changing the font scale in a test

Testify allows you to change the current Activity scaling factor for fonts, relative to the base density scaling. This allows you to simulate the impact of a user modifying the default font size on their device, such as tiny, large or huge.

note

Similar to changing the Locale, you are required to implement TestifyResourcesOverride when configuring fontScale. See Changing the Locale in a test.

See Change text & display settings

Example Test:

class MainActivityScreenshotTest {

@get:Rule var rule = ScreenshotRule(MainActivity::class.java)

@ScreenshotInstrumentation
@TestifyLayout(R.layout.view_client_details)
@Test
fun testHugeFontScale() {
rule
.configure {
fontScale = 2.0f
}
.assertSame()
}
}