summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDorothy Chen <dorothychen@google.com>2023-03-08 03:16:39 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2023-03-08 03:16:39 +0000
commit873431053ed6be85b1dfd568443d422f3f4b2b36 (patch)
tree6e998c61441880c2b3a8bd66a2dce6be63de2d51
parentd393fb5de0a972d1bad39db3b762280a75b164bc (diff)
parent6e2e597333deadd0dfdbf94001abbf78bd30a8ce (diff)
downloadplatform_testing-873431053ed6be85b1dfd568443d422f3f4b2b36.tar.gz
Merge "Drag the app icon into the target position and add the String Option to change the poistions more flexible" into tm-qpr-dev
-rw-r--r--tests/health/scenarios/src/android/platform/test/scenario/generic/CloseAppsToHome.java104
-rw-r--r--tests/health/scenarios/src/android/platform/test/scenario/generic/OpenAppsFromHome.java16
2 files changed, 73 insertions, 47 deletions
diff --git a/tests/health/scenarios/src/android/platform/test/scenario/generic/CloseAppsToHome.java b/tests/health/scenarios/src/android/platform/test/scenario/generic/CloseAppsToHome.java
index a623fea5e..183e251f0 100644
--- a/tests/health/scenarios/src/android/platform/test/scenario/generic/CloseAppsToHome.java
+++ b/tests/health/scenarios/src/android/platform/test/scenario/generic/CloseAppsToHome.java
@@ -38,53 +38,65 @@ import org.junit.runners.JUnit4;
import java.io.IOException;
import java.util.concurrent.TimeUnit;
-/**
- * Swipe up to home to close the required application
- */
+/** Swipe up to home to close the required application */
@Scenario
@RunWith(JUnit4.class)
public class CloseAppsToHome {
- // Class-level rules
- @ClassRule public static UnlockScreenRule unlockScreenRule = new UnlockScreenRule();
-
- @ClassRule public static NaturalOrientationRule orientationRule = new NaturalOrientationRule();
-
- private static LauncherInstrumentation sLauncher;
- private static AppIcon sAppIcon;
-
- @ClassRule
- public static StringOption sNameOption = new StringOption("app-name").setRequired(true);
-
- @ClassRule
- public static StringOption sPkgOption = new StringOption("app-package-name").setRequired(true);
-
- @ClassRule
- public static IntegerOption delayTimeOption =
- new IntegerOption("delay-after-touching-sec").setRequired(false).setDefault(1);
-
- @BeforeClass
- public static void setup() throws IOException {
- sLauncher = new LauncherInstrumentation();
- final HomeAllApps allApps = sLauncher.goHome().switchToAllApps();
- allApps.getAppIcon(sNameOption.get()).dragToWorkspace(false, false);
- sAppIcon = sLauncher.getWorkspace().getWorkspaceAppIcon(sNameOption.get());
- }
-
- @NoMetricBefore
- public void OpenApps() {
- sAppIcon.launch(sPkgOption.get());
- }
-
- @Test
- public void testCloseApps() {
- SystemClock.sleep(TimeUnit.SECONDS.toMillis(delayTimeOption.get()));
- sLauncher.goHome();
- }
-
- @AfterClass
- public static void closeAppAndRemoveIcon() throws IOException {
- sLauncher.getDevice().executeShellCommand("pm clear com.google.android.apps.nexuslauncher");
- sLauncher.goHome();
- }
-} \ No newline at end of file
+ // Class-level rules
+ @ClassRule public static UnlockScreenRule unlockScreenRule = new UnlockScreenRule();
+
+ @ClassRule public static NaturalOrientationRule orientationRule = new NaturalOrientationRule();
+
+ private static LauncherInstrumentation sLauncher;
+ private static AppIcon sAppIcon;
+ private static int sCellX;
+ private static int sCellY;
+
+ // Starting from the left of the screen to set the column number for the target position
+ @ClassRule
+ public static IntegerOption sCellXOption =
+ new IntegerOption("column-number").setRequired(false).setDefault(2);
+
+ // Starting from the top of the screen to set the row number for target position
+ @ClassRule
+ public static IntegerOption sCellYOption =
+ new IntegerOption("row-number").setRequired(false).setDefault(2);
+
+ @ClassRule
+ public static StringOption sNameOption = new StringOption("app-name").setRequired(true);
+
+ @ClassRule
+ public static StringOption sPkgOption = new StringOption("app-package-name").setRequired(true);
+
+ @ClassRule
+ public static IntegerOption delayTimeOption =
+ new IntegerOption("delay-after-touching-sec").setRequired(false).setDefault(1);
+
+ @BeforeClass
+ public static void setup() throws IOException {
+ sLauncher = new LauncherInstrumentation();
+ sCellX = sCellXOption.get();
+ sCellY = sCellYOption.get();
+ final HomeAllApps allApps = sLauncher.goHome().switchToAllApps();
+ allApps.getAppIcon(sNameOption.get()).dragToWorkspace(sCellX, sCellY);
+ sAppIcon = sLauncher.getWorkspace().getWorkspaceAppIcon(sNameOption.get());
+ }
+
+ @NoMetricBefore
+ public void openApps() {
+ sAppIcon.launch(sPkgOption.get());
+ }
+
+ @Test
+ public void testCloseApps() {
+ SystemClock.sleep(TimeUnit.SECONDS.toMillis(delayTimeOption.get()));
+ sLauncher.goHome();
+ }
+
+ @AfterClass
+ public static void closeAppAndRemoveIcon() throws IOException {
+ sLauncher.getDevice().executeShellCommand("pm clear com.google.android.apps.nexuslauncher");
+ sLauncher.goHome();
+ }
+}
diff --git a/tests/health/scenarios/src/android/platform/test/scenario/generic/OpenAppsFromHome.java b/tests/health/scenarios/src/android/platform/test/scenario/generic/OpenAppsFromHome.java
index 064a337e3..344a86c12 100644
--- a/tests/health/scenarios/src/android/platform/test/scenario/generic/OpenAppsFromHome.java
+++ b/tests/health/scenarios/src/android/platform/test/scenario/generic/OpenAppsFromHome.java
@@ -54,6 +54,18 @@ public class OpenAppsFromHome {
private static LauncherInstrumentation sLauncher;
private static AppIcon sAppIcon;
+ private static int sCellX;
+ private static int sCellY;
+
+ // Starting from the left of the screen to set the column number for the target position
+ @ClassRule
+ public static IntegerOption sCellXOption =
+ new IntegerOption("column-number").setRequired(false).setDefault(2);
+
+ // Starting from the top of the screen to set the row number for target position
+ @ClassRule
+ public static IntegerOption sCellYOption =
+ new IntegerOption("row-number").setRequired(false).setDefault(2);
@ClassRule
public static StringOption sNameOption = new StringOption("app-name").setRequired(true);
@@ -67,8 +79,10 @@ public class OpenAppsFromHome {
@BeforeClass
public static void setup() throws IOException {
sLauncher = new LauncherInstrumentation();
+ sCellX = sCellXOption.get();
+ sCellY = sCellYOption.get();
final HomeAllApps allApps = sLauncher.goHome().switchToAllApps();
- allApps.getAppIcon(sNameOption.get()).dragToWorkspace(false, false);
+ allApps.getAppIcon(sNameOption.get()).dragToWorkspace(sCellX, sCellY);
sAppIcon = sLauncher.getWorkspace().getWorkspaceAppIcon(sNameOption.get());
}