Support for overriding test run flavor
Change-Id: I054a1eaa888cd97a7c7fa5fcc65513d6d89c3a1c
This commit is contained in:
@@ -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().
|
||||
|
||||
Reference in New Issue
Block a user