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

Commit b7eedb45 authored by vadimt's avatar vadimt
Browse files

Support for overriding test run flavor

Change-Id: I054a1eaa888cd97a7c7fa5fcc65513d6d89c3a1c
parent 51a4c7bd
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -21,6 +21,7 @@ import android.content.pm.PackageManager;
import android.os.Build;
import android.util.Log;

import androidx.test.InstrumentationRegistry;
import androidx.test.uiautomator.UiDevice;

import org.junit.rules.TestRule;
@@ -86,6 +87,19 @@ public class TestStabilityRule implements TestRule {
    }

    private static int getRunFlavor() {
        final String flavorOverride = InstrumentationRegistry.getArguments().getString("flavor");

        if (flavorOverride != null) {
            Log.d(TAG, "Flavor override: " + flavorOverride);
            try {
                return (int) TestStabilityRule.class.getField(flavorOverride).get(null);
            } catch (NoSuchFieldException e) {
                throw new AssertionError("Unrecognized run flavor override: " + flavorOverride);
            } catch (IllegalAccessException e) {
                throw new RuntimeException(e);
            }
        }

        final String launcherVersion;
        try {
            launcherVersion = getInstrumentation().