Merge "fix(non linear font scaling): fix activity test flakiness" into udc-dev am: f197ae41de

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23265636

Change-Id: I9b583cd7ea215225da39eb804f7e6b75ad17b065
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
TreeHugger Robot
2023-05-17 20:45:31 +00:00
committed by Automerger Merge Worker

View File

@@ -50,6 +50,7 @@ import org.junit.Test;
import org.junit.rules.TestRule;
import org.junit.runner.RunWith;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
/**
@@ -127,7 +128,7 @@ public class FontScaleConverterActivityTest {
});
}
private static void setSystemFontScale(float fontScale) {
private void setSystemFontScale(float fontScale) {
ShellIdentityUtils.invokeWithShellPermissions(() -> {
Settings.System.putFloat(
InstrumentationRegistry.getInstrumentation().getContext().getContentResolver(),
@@ -136,14 +137,22 @@ public class FontScaleConverterActivityTest {
);
});
PollingCheck.waitFor(/* timeout= */ 5000, () ->
InstrumentationRegistry
PollingCheck.waitFor(/* timeout= */ 5000, () -> {
AtomicBoolean isActivityAtCorrectScale = new AtomicBoolean(false);
rule.getScenario().onActivity(activity ->
isActivityAtCorrectScale.set(
activity.getResources()
.getConfiguration()
.fontScale == fontScale
)
);
return isActivityAtCorrectScale.get() && InstrumentationRegistry
.getInstrumentation()
.getContext()
.getResources()
.getConfiguration()
.fontScale == fontScale
);
.fontScale == fontScale;
});
}
private static void restoreSystemFontScaleToDefault() {