diff options
author | Dorothy Chen <dorothychen@google.com> | 2023-02-10 17:12:45 +0800 |
---|---|---|
committer | Dorothy Chen <dorothychen@google.com> | 2023-03-01 23:14:09 +0800 |
commit | 6e2e597333deadd0dfdbf94001abbf78bd30a8ce (patch) | |
tree | a5c193534407b94bf88629979b5959e37bdc35b4 | |
parent | c3975ba61a3142759496c08f9f2a3f226fa08cb4 (diff) | |
download | platform_testing-6e2e597333deadd0dfdbf94001abbf78bd30a8ce.tar.gz |
Drag the app icon into the target position and add the String Option to
change the poistions more flexible
Bug:263695370
Test: Run the test instrument command
Change-Id: Ia79cc93527d53e01e2fe4d1d64025cd0de298ba7
-rw-r--r-- | tests/health/scenarios/src/android/platform/test/scenario/generic/CloseAppsToHome.java | 104 | ||||
-rw-r--r-- | tests/health/scenarios/src/android/platform/test/scenario/generic/OpenAppsFromHome.java | 16 |
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()); } |