Merge "Migration of hermetic startup test to CrystalBall." am: bc06403704

Original change: undetermined

Change-Id: I0e8cd9758bf1b8852b374bc658e6c3023986c7db
diff --git a/tests/health/scenarios/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenEmptyActivity.java b/tests/health/scenarios/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenEmptyActivity.java
new file mode 100644
index 0000000..882329e
--- /dev/null
+++ b/tests/health/scenarios/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenEmptyActivity.java
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.platform.test.scenario.performancelaunch.hermeticapp;
+
+import android.platform.test.rule.NaturalOrientationRule;
+import android.platform.test.scenario.annotation.Scenario;
+
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/** Opens the Performance Launch Empty activity and exits after. */
+@Scenario
+@RunWith(JUnit4.class)
+public class OpenEmptyActivity extends PerformanceBase {
+
+    private static final String EMPTY_ACTIVITY = "com.android.performanceLaunch.EmptyActivity";
+
+    // Class-level rules
+    @ClassRule public static NaturalOrientationRule orientationRule = new NaturalOrientationRule();
+
+    @Test
+    public void testOpen() {
+        open(EMPTY_ACTIVITY);
+    }
+}
diff --git a/tests/health/scenarios/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenEmptyWebViewActivity.java b/tests/health/scenarios/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenEmptyWebViewActivity.java
new file mode 100644
index 0000000..f2d2482
--- /dev/null
+++ b/tests/health/scenarios/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenEmptyWebViewActivity.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.platform.test.scenario.performancelaunch.hermeticapp;
+
+import android.platform.test.rule.NaturalOrientationRule;
+import android.platform.test.scenario.annotation.Scenario;
+
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/** Opens the Performance Launch Empty WebView activity and exits after. */
+@Scenario
+@RunWith(JUnit4.class)
+public class OpenEmptyWebViewActivity extends PerformanceBase {
+
+    private static final String EMPTY_WEB_VIEW_ACTIVITY =
+            "com.android.performanceLaunch.EmptyWebViewActivity";
+
+    // Class-level rules
+    @ClassRule public static NaturalOrientationRule orientationRule = new NaturalOrientationRule();
+
+    @Test
+    public void testOpen() {
+        open(EMPTY_WEB_VIEW_ACTIVITY);
+    }
+}
diff --git a/tests/health/scenarios/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenManyConfigResourceActivity.java b/tests/health/scenarios/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenManyConfigResourceActivity.java
new file mode 100644
index 0000000..f001685
--- /dev/null
+++ b/tests/health/scenarios/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenManyConfigResourceActivity.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.platform.test.scenario.performancelaunch.hermeticapp;
+
+import android.platform.test.rule.NaturalOrientationRule;
+import android.platform.test.scenario.annotation.Scenario;
+
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/** Opens the Performance Launch ManyConfigResource activity and exits after. */
+@Scenario
+@RunWith(JUnit4.class)
+public class OpenManyConfigResourceActivity extends PerformanceBase {
+
+    private static final String MANY_CONFIG_ACTIVITY =
+            "com.android.performanceLaunch.ManyConfigResourceActivity";
+
+    // Class-level rules
+    @ClassRule public static NaturalOrientationRule orientationRule = new NaturalOrientationRule();
+
+    @Test
+    public void testOpen() {
+        open(MANY_CONFIG_ACTIVITY);
+    }
+}
diff --git a/tests/health/scenarios/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenSimpleSurfaceGLActivity.java b/tests/health/scenarios/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenSimpleSurfaceGLActivity.java
new file mode 100644
index 0000000..ce448cc
--- /dev/null
+++ b/tests/health/scenarios/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenSimpleSurfaceGLActivity.java
@@ -0,0 +1,41 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.platform.test.scenario.performancelaunch.hermeticapp;
+
+import android.platform.test.rule.NaturalOrientationRule;
+import android.platform.test.scenario.annotation.Scenario;
+
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.junit.runners.JUnit4;
+
+/** Opens the Performance Launch Simple Surface GLA activity and exits after. */
+@Scenario
+@RunWith(JUnit4.class)
+public class OpenSimpleSurfaceGLActivity extends PerformanceBase {
+
+    private static final String SIMPLE_SURFACE_GL_ACTIVITY =
+            "com.android.performanceLaunch.SimpleSurfaceGLActivity";
+
+    // Class-level rules
+    @ClassRule public static NaturalOrientationRule orientationRule = new NaturalOrientationRule();
+
+    @Test
+    public void testOpen() {
+        open(SIMPLE_SURFACE_GL_ACTIVITY);
+    }
+}
diff --git a/tests/health/scenarios/src/android/platform/test/scenario/performancelaunch/hermeticapp/PerformanceBase.java b/tests/health/scenarios/src/android/platform/test/scenario/performancelaunch/hermeticapp/PerformanceBase.java
new file mode 100644
index 0000000..d072129
--- /dev/null
+++ b/tests/health/scenarios/src/android/platform/test/scenario/performancelaunch/hermeticapp/PerformanceBase.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.platform.test.scenario.performancelaunch.hermeticapp;
+
+import android.content.Context;
+import android.content.Intent;
+import android.support.test.uiautomator.UiDevice;
+import android.support.test.uiautomator.Until;
+import android.support.test.uiautomator.By;
+
+import androidx.test.InstrumentationRegistry;
+
+import org.junit.AfterClass;
+
+/** Performance helper to open application and exits after. */
+public class PerformanceBase {
+
+    private static final String PACKAGE = "com.android.performanceLaunch";
+
+    private static UiDevice mDevice;
+
+    public PerformanceBase() {
+        mDevice = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
+    }
+
+    public void open(String actvity) {
+
+        // Launch the app
+        Context context = InstrumentationRegistry.getContext();
+        final Intent intent = context.getPackageManager().getLaunchIntentForPackage(PACKAGE);
+        // Clear out any previous instances
+        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
+        intent.setClassName(PACKAGE, actvity);
+        context.startActivity(intent);
+
+        mDevice.wait(Until.hasObject(By.pkg(PACKAGE).depth(0)), 5000);
+    }
+
+    @AfterClass
+    public static void close() {
+        mDevice.pressHome();
+    }
+}
diff --git a/tests/health/scenarios/tests/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenEmptyActivityMicrobenchmark.java b/tests/health/scenarios/tests/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenEmptyActivityMicrobenchmark.java
new file mode 100644
index 0000000..689db66
--- /dev/null
+++ b/tests/health/scenarios/tests/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenEmptyActivityMicrobenchmark.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.platform.test.scenario.performancelaunch.hermeticapp;
+
+import android.platform.test.microbenchmark.Microbenchmark;
+import android.platform.test.rule.CompilationFilterRule;
+import android.platform.test.rule.DropCachesRule;
+import android.platform.test.rule.KillAppsRule;
+import android.platform.test.rule.PressHomeRule;
+
+import org.junit.Rule;
+import org.junit.rules.RuleChain;
+import org.junit.runner.RunWith;
+
+@RunWith(Microbenchmark.class)
+public class OpenEmptyActivityMicrobenchmark extends OpenEmptyActivity {
+    private static final String PACKAGE = "com.android.performanceLaunch";
+
+    // Method-level rules
+    @Rule
+    public RuleChain rules =
+            RuleChain.outerRule(new KillAppsRule(PACKAGE))
+                    .around(new DropCachesRule())
+                    .around(new CompilationFilterRule(PACKAGE))
+                    .around(new PressHomeRule());
+}
diff --git a/tests/health/scenarios/tests/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenEmptyWebViewActivityMicrobenchmark.java b/tests/health/scenarios/tests/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenEmptyWebViewActivityMicrobenchmark.java
new file mode 100644
index 0000000..1e9f2b8
--- /dev/null
+++ b/tests/health/scenarios/tests/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenEmptyWebViewActivityMicrobenchmark.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.platform.test.scenario.performancelaunch.hermeticapp;
+
+import android.platform.test.microbenchmark.Microbenchmark;
+import android.platform.test.rule.CompilationFilterRule;
+import android.platform.test.rule.DropCachesRule;
+import android.platform.test.rule.KillAppsRule;
+import android.platform.test.rule.PressHomeRule;
+
+import org.junit.Rule;
+import org.junit.rules.RuleChain;
+import org.junit.runner.RunWith;
+
+@RunWith(Microbenchmark.class)
+public class OpenEmptyWebViewActivityMicrobenchmark extends OpenEmptyWebViewActivity {
+    private static final String PACKAGE = "com.android.performanceLaunch";
+
+    // Method-level rules
+    @Rule
+    public RuleChain rules =
+            RuleChain.outerRule(new KillAppsRule(PACKAGE))
+                    .around(new DropCachesRule())
+                    .around(new CompilationFilterRule(PACKAGE))
+                    .around(new PressHomeRule());
+}
diff --git a/tests/health/scenarios/tests/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenManyConfigResourceActivityMicrobenchmark.java b/tests/health/scenarios/tests/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenManyConfigResourceActivityMicrobenchmark.java
new file mode 100644
index 0000000..d6fab0f
--- /dev/null
+++ b/tests/health/scenarios/tests/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenManyConfigResourceActivityMicrobenchmark.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.platform.test.scenario.performancelaunch.hermeticapp;
+
+import android.platform.test.microbenchmark.Microbenchmark;
+import android.platform.test.rule.CompilationFilterRule;
+import android.platform.test.rule.DropCachesRule;
+import android.platform.test.rule.KillAppsRule;
+import android.platform.test.rule.PressHomeRule;
+
+import org.junit.Rule;
+import org.junit.rules.RuleChain;
+import org.junit.runner.RunWith;
+
+@RunWith(Microbenchmark.class)
+public class OpenManyConfigResourceActivityMicrobenchmark extends OpenManyConfigResourceActivity {
+    private static final String PACKAGE = "com.android.performanceLaunch";
+
+    // Method-level rules
+    @Rule
+    public RuleChain rules =
+            RuleChain.outerRule(new KillAppsRule(PACKAGE))
+                    .around(new DropCachesRule())
+                    .around(new CompilationFilterRule(PACKAGE))
+                    .around(new PressHomeRule());
+}
diff --git a/tests/health/scenarios/tests/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenSimpleSurfaceGLActivityMicrobenchmark.java b/tests/health/scenarios/tests/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenSimpleSurfaceGLActivityMicrobenchmark.java
new file mode 100644
index 0000000..03b0728
--- /dev/null
+++ b/tests/health/scenarios/tests/src/android/platform/test/scenario/performancelaunch/hermeticapp/OpenSimpleSurfaceGLActivityMicrobenchmark.java
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2020 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package android.platform.test.scenario.performancelaunch.hermeticapp;
+
+import android.platform.test.microbenchmark.Microbenchmark;
+import android.platform.test.rule.CompilationFilterRule;
+import android.platform.test.rule.DropCachesRule;
+import android.platform.test.rule.KillAppsRule;
+import android.platform.test.rule.PressHomeRule;
+
+import org.junit.Rule;
+import org.junit.rules.RuleChain;
+import org.junit.runner.RunWith;
+
+@RunWith(Microbenchmark.class)
+public class OpenSimpleSurfaceGLActivityMicrobenchmark extends OpenSimpleSurfaceGLActivity {
+    private static final String PACKAGE = "com.android.performanceLaunch";
+
+    // Method-level rules
+    @Rule
+    public RuleChain rules =
+            RuleChain.outerRule(new KillAppsRule(PACKAGE))
+                    .around(new DropCachesRule())
+                    .around(new CompilationFilterRule(PACKAGE))
+                    .around(new PressHomeRule());
+}