diff options
author | vadimt <vadimt@google.com> | 2019-09-25 13:59:37 -0700 |
---|---|---|
committer | vadimt <vadimt@google.com> | 2019-09-25 13:59:37 -0700 |
commit | 7ad1026cad1029ca12e95f51f8b7322617f46806 (patch) | |
tree | cb0854376f8ef673c8be51128d02a1f0a74d8a17 /tests/src/com/android/launcher3/util | |
parent | b72cd2629c3c478714154e407e8bf8275c24d8e9 (diff) | |
download | android_packages_apps_Trebuchet-7ad1026cad1029ca12e95f51f8b7322617f46806.tar.gz android_packages_apps_Trebuchet-7ad1026cad1029ca12e95f51f8b7322617f46806.tar.bz2 android_packages_apps_Trebuchet-7ad1026cad1029ca12e95f51f8b7322617f46806.zip |
Continuing experiments with test stability attribute
Change-Id: I7ada0a7f4f0e0e9ca90a3d44ae88fc00d54d74df
Diffstat (limited to 'tests/src/com/android/launcher3/util')
-rw-r--r-- | tests/src/com/android/launcher3/util/rule/TestStabilityRule.java | 115 |
1 files changed, 49 insertions, 66 deletions
diff --git a/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java b/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java index 8feadbee9..d7f41bf04 100644 --- a/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java +++ b/tests/src/com/android/launcher3/util/rule/TestStabilityRule.java @@ -40,8 +40,8 @@ public class TestStabilityRule implements TestRule { + "(?<local>(BuildFromAndroidStudio|" + "([0-9]+|[A-Z])-eng\\.[a-z]+\\.[0-9]+\\.[0-9]+))|" + "(?<presubmit>([0-9]+|[A-Z])-P[0-9]+)|" - + "(?<postsubmit>([0-9]+|[A-Z])+-[0-9]+|" - + "(?<platform>([0-9]+|[A-Z])+))" + + "(?<postsubmit>([0-9]+|[A-Z])-[0-9]+)|" + + "(?<platform>[0-9]+|[A-Z])" + ")$"); private static final Pattern PLATFORM_BUILD = Pattern.compile("^(" @@ -61,70 +61,7 @@ public class TestStabilityRule implements TestRule { return new Statement() { @Override public void evaluate() throws Throwable { - final String launcherVersion = - getInstrumentation(). - getContext(). - getPackageManager(). - getPackageInfo( - UiDevice.getInstance(getInstrumentation()). - getLauncherPackageName(), - 0). - versionName; - - final Matcher launcherBuildMatcher = LAUNCHER_BUILD.matcher(launcherVersion); - - boolean launcherLocalBuild = false; - boolean launcherUnbundledPresubmit = false; - boolean launcherUnbundledPostsubmit = false; - boolean launcherPlatform = false; - - if (!launcherBuildMatcher.find()) { - Log.e(TAG, "Match not found"); - } else if (launcherBuildMatcher.group("local") != null) { - launcherLocalBuild = true; - } else if (launcherBuildMatcher.group("presubmit") != null) { - launcherUnbundledPresubmit = true; - } else if (launcherBuildMatcher.group("postsubmit") != null) { - launcherUnbundledPostsubmit = true; - } else if (launcherBuildMatcher.group("platform") != null) { - launcherPlatform = true; - } else { - Log.e(TAG, "ERROR1"); - } - - boolean platformLocalBuild = false; - boolean platformPresubmit = false; - boolean platformPostsubmit = false; - - final String platformVersion = Build.VERSION.INCREMENTAL; - final Matcher platformBuildMatcher = PLATFORM_BUILD.matcher(platformVersion); - if (!platformBuildMatcher.find()) { - Log.e(TAG, "Match not found"); - } else if (platformBuildMatcher.group("commandLine") != null) { - platformLocalBuild = true; - } else if (platformBuildMatcher.group("presubmit") != null) { - platformPresubmit = true; - } else if (platformBuildMatcher.group("postsubmit") != null) { - platformPostsubmit = true; - } else { - Log.e(TAG, "ERROR2"); - } - - Log.d(TAG, "Launcher: " + launcherVersion + ", platform: " + platformVersion); - - if (launcherLocalBuild && (platformLocalBuild || platformPostsubmit)) { - Log.d(TAG, "LOCAL RUN"); - } else if (launcherUnbundledPresubmit && platformPostsubmit) { - Log.d(TAG, "UNBUNDLED PRESUBMIT"); - } else if (launcherUnbundledPostsubmit && platformPostsubmit) { - Log.d(TAG, "UNBUNDLED POSTSUBMIT"); - } else if (launcherPlatform && platformPresubmit) { - Log.d(TAG, "PLATFORM PRESUBMIT"); - } else if (launcherPlatform && platformPostsubmit) { - Log.d(TAG, "PLATFORM POSTSUBMIT"); - } else { - Log.e(TAG, "ERROR3"); - } + getRunFlavor(); base.evaluate(); } @@ -133,4 +70,50 @@ public class TestStabilityRule implements TestRule { return base; } } + + private static void getRunFlavor() throws Exception { + final String launcherVersion = getInstrumentation(). + getContext(). + getPackageManager(). + getPackageInfo( + UiDevice.getInstance(getInstrumentation()). + getLauncherPackageName(), + 0). + versionName; + + final Matcher launcherBuildMatcher = LAUNCHER_BUILD.matcher(launcherVersion); + + if (!launcherBuildMatcher.find()) { + Log.e(TAG, "Match not found"); + } + + final String platformVersion = Build.VERSION.INCREMENTAL; + final Matcher platformBuildMatcher = PLATFORM_BUILD.matcher(platformVersion); + + if (!platformBuildMatcher.find()) { + Log.e(TAG, "Match not found"); + } + + Log.d(TAG, "Launcher: " + launcherVersion + ", platform: " + platformVersion); + + if (launcherBuildMatcher.group("local") != null && ( + platformBuildMatcher.group("commandLine") != null || + platformBuildMatcher.group("postsubmit") != null)) { + Log.d(TAG, "LOCAL RUN"); + } else if (launcherBuildMatcher.group("presubmit") != null + && platformBuildMatcher.group("postsubmit") != null) { + Log.d(TAG, "UNBUNDLED PRESUBMIT"); + } else if (launcherBuildMatcher.group("postsubmit") != null + && platformBuildMatcher.group("postsubmit") != null) { + Log.d(TAG, "UNBUNDLED POSTSUBMIT"); + } else if (launcherBuildMatcher.group("platform") != null + && platformBuildMatcher.group("presubmit") != null) { + Log.d(TAG, "PLATFORM PRESUBMIT"); + } else if (launcherBuildMatcher.group("platform") != null + && platformBuildMatcher.group("postsubmit") != null) { + Log.d(TAG, "PLATFORM POSTSUBMIT"); + } else { + Log.e(TAG, "ERROR3"); + } + } } |