Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 276bcea0 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Automerger Merge Worker
Browse files

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

parents 69a60afc f197ae41
Loading
Loading
Loading
Loading
+14 −5
Original line number Original line Diff line number Diff line
@@ -50,6 +50,7 @@ import org.junit.Test;
import org.junit.rules.TestRule;
import org.junit.rules.TestRule;
import org.junit.runner.RunWith;
import org.junit.runner.RunWith;


import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;
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(() -> {
        ShellIdentityUtils.invokeWithShellPermissions(() -> {
            Settings.System.putFloat(
            Settings.System.putFloat(
                    InstrumentationRegistry.getInstrumentation().getContext().getContentResolver(),
                    InstrumentationRegistry.getInstrumentation().getContext().getContentResolver(),
@@ -136,14 +137,22 @@ public class FontScaleConverterActivityTest {
            );
            );
        });
        });


        PollingCheck.waitFor(/* timeout= */ 5000, () ->
        PollingCheck.waitFor(/* timeout= */ 5000, () -> {
                InstrumentationRegistry
            AtomicBoolean isActivityAtCorrectScale = new AtomicBoolean(false);
            rule.getScenario().onActivity(activity ->
                    isActivityAtCorrectScale.set(
                            activity.getResources()
                                .getConfiguration()
                                .fontScale == fontScale
                    )
            );
            return isActivityAtCorrectScale.get() && InstrumentationRegistry
                    .getInstrumentation()
                    .getInstrumentation()
                    .getContext()
                    .getContext()
                    .getResources()
                    .getResources()
                    .getConfiguration()
                    .getConfiguration()
                    .fontScale == fontScale
                    .fontScale == fontScale;
        );
        });
    }
    }


    private static void restoreSystemFontScaleToDefault() {
    private static void restoreSystemFontScaleToDefault() {