From e578b8d728eff21ac494c0d18895527c91a3a7d7 Mon Sep 17 00:00:00 2001 From: Eric Engelking Date: Fri, 29 Jul 2016 14:52:54 -0700 Subject: [PATCH] Added homeScreen support. --- .../java/io/appium/java_client/MobileCommand.java | 1 + .../java_client/ios/IOSDeviceActionShortcuts.java | 7 +++++++ .../java/io/appium/java_client/ios/IOSDriver.java | 9 +++++++++ .../java_client/ios/IOSMobileCommandHelper.java | 12 ++++++++++++ 4 files changed, 29 insertions(+) diff --git a/src/main/java/io/appium/java_client/MobileCommand.java b/src/main/java/io/appium/java_client/MobileCommand.java index 8249902a9..7aee1f7ed 100644 --- a/src/main/java/io/appium/java_client/MobileCommand.java +++ b/src/main/java/io/appium/java_client/MobileCommand.java @@ -53,6 +53,7 @@ public class MobileCommand { protected static final String GET_SESSION = "getSession"; //iOS protected static final String SHAKE = "shake"; + protected static final String HOME_SCREEN = "homeScreen"; //Android protected static final String CURRENT_ACTIVITY = "currentActivity"; protected static final String END_TEST_COVERAGE = "endTestCoverage"; diff --git a/src/main/java/io/appium/java_client/ios/IOSDeviceActionShortcuts.java b/src/main/java/io/appium/java_client/ios/IOSDeviceActionShortcuts.java index 0916bb672..305925e8e 100644 --- a/src/main/java/io/appium/java_client/ios/IOSDeviceActionShortcuts.java +++ b/src/main/java/io/appium/java_client/ios/IOSDeviceActionShortcuts.java @@ -46,5 +46,12 @@ public interface IOSDeviceActionShortcuts extends DeviceActionShortcuts { * Simulate shaking the device. */ void shake(); + + /** + * Simulate tapping the home button. + */ + void homeScreen(); + + } diff --git a/src/main/java/io/appium/java_client/ios/IOSDriver.java b/src/main/java/io/appium/java_client/ios/IOSDriver.java index 3c8d839f8..d138f5e4b 100644 --- a/src/main/java/io/appium/java_client/ios/IOSDriver.java +++ b/src/main/java/io/appium/java_client/ios/IOSDriver.java @@ -19,6 +19,8 @@ import static io.appium.java_client.ios.IOSMobileCommandHelper.hideKeyboardCommand; import static io.appium.java_client.ios.IOSMobileCommandHelper.lockDeviceCommand; import static io.appium.java_client.ios.IOSMobileCommandHelper.shakeCommand; +import static io.appium.java_client.ios.IOSMobileCommandHelper.homeScreenCommand; + import io.appium.java_client.AppiumDriver; import io.appium.java_client.CommandExecutionHelper; @@ -192,6 +194,13 @@ public IOSDriver(Capabilities desiredCapabilities) { CommandExecutionHelper.execute(this, shakeCommand()); } + /** + * @see IOSDeviceActionShortcuts#homeScreen(). + */ + @Override public void homeScreen() { + CommandExecutionHelper.execute(this, homeScreenCommand()); + } + /** * @throws WebDriverException * This method is not applicable with browser/webview UI. diff --git a/src/main/java/io/appium/java_client/ios/IOSMobileCommandHelper.java b/src/main/java/io/appium/java_client/ios/IOSMobileCommandHelper.java index 4de1bb8c7..14318c71e 100644 --- a/src/main/java/io/appium/java_client/ios/IOSMobileCommandHelper.java +++ b/src/main/java/io/appium/java_client/ios/IOSMobileCommandHelper.java @@ -81,4 +81,16 @@ public class IOSMobileCommandHelper extends MobileCommand { return new AbstractMap.SimpleEntry>(SHAKE, ImmutableMap.of()); } + + /** + * This method forms a {@link java.util.Map} of parameters for the + * tapping home button. + * + * @return a key-value pair. The key is the command name. The value is a + * {@link java.util.Map} command arguments. + */ + public static Map.Entry> homeScreenCommand() { + return new AbstractMap.SimpleEntry>(HOME_SCREEN, ImmutableMap.of()); + } }