fix(non linear font scaling): wait longer after setting font scale to fix flaky test

Fix: 269555148
Test: atest android.content.res.FontScaleConverterActivityTest
Change-Id: Iac66a9c089167913a2b162e16cde0dacc85728ea
This commit is contained in:
Tyler Freeman
2023-02-16 15:47:54 -08:00
parent 5dda390795
commit 23380ed389

View File

@@ -27,6 +27,7 @@ import android.compat.testing.PlatformCompatChangeRule;
import android.os.Bundle;
import android.platform.test.annotations.Presubmit;
import android.provider.Settings;
import android.util.PollingCheck;
import android.view.View;
import android.widget.TextView;
@@ -91,6 +92,9 @@ public class FontScaleConverterActivityTest {
var densityRef = new AtomicReference<Float>();
scenario.onActivity(activity -> {
assertThat(activity.getResources().getConfiguration().fontScale)
.isWithin(0.05f)
.of(2f);
densityRef.compareAndSet(null, activity.getResources().getDisplayMetrics().density);
});
var density = densityRef.get();
@@ -141,6 +145,15 @@ public class FontScaleConverterActivityTest {
fontScale
);
});
PollingCheck.waitFor(/* timeout= */ 5000, () ->
InstrumentationRegistry
.getInstrumentation()
.getContext()
.getResources()
.getConfiguration()
.fontScale == fontScale
);
}
private Matcher<View> withTextSizeInRange(float sizeStartPx, float sizeEndPx) {