From a5ab6352c88ce46cf5d9fe3757835896c0c9cba1 Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Fri, 6 Sep 2019 18:44:11 +0200 Subject: [PATCH 1/3] chore: Switch the implementation of backgroundApp for iOS, so it's in sync with other platforms --- .../io/appium/java_client/InteractsWithApps.java | 4 ++-- .../java/io/appium/java_client/ios/IOSDriver.java | 15 --------------- 2 files changed, 2 insertions(+), 17 deletions(-) diff --git a/src/main/java/io/appium/java_client/InteractsWithApps.java b/src/main/java/io/appium/java_client/InteractsWithApps.java index f0624db4a..11549cd1a 100644 --- a/src/main/java/io/appium/java_client/InteractsWithApps.java +++ b/src/main/java/io/appium/java_client/InteractsWithApps.java @@ -98,10 +98,10 @@ default void resetApp() { * requested. This is a synchronous method, it returns after the back has * been returned to the foreground. * - * @param duration The time to run App in background. Minimum time resolution is one second + * @param duration The time to run App in background. Minimum time resolution is one millisecond */ default void runAppInBackground(Duration duration) { - execute(RUN_APP_IN_BACKGROUND, ImmutableMap.of("seconds", duration.getSeconds())); + execute(RUN_APP_IN_BACKGROUND, ImmutableMap.of("seconds", duration.toMillis() / 1000.0)); } /** 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 1d668c5de..229aac70b 100644 --- a/src/main/java/io/appium/java_client/ios/IOSDriver.java +++ b/src/main/java/io/appium/java_client/ios/IOSDriver.java @@ -16,7 +16,6 @@ package io.appium.java_client.ios; -import static io.appium.java_client.MobileCommand.RUN_APP_IN_BACKGROUND; import static io.appium.java_client.MobileCommand.prepareArguments; import static org.openqa.selenium.remote.DriverCommand.EXECUTE_SCRIPT; @@ -43,7 +42,6 @@ import org.openqa.selenium.remote.http.HttpClient; import java.net.URL; -import java.time.Duration; import java.util.Collections; import java.util.Map; @@ -169,19 +167,6 @@ public IOSDriver(Capabilities desiredCapabilities) { super(updateDefaultPlatformName(desiredCapabilities, IOS_DEFAULT_PLATFORM)); } - /** - * Runs the current app as a background app for the number of seconds - * or minimizes the app. - * - * @param duration The time to run App in background. - */ - @Override public void runAppInBackground(Duration duration) { - // timeout parameter is expected to be in milliseconds - // float values are allowed - execute(RUN_APP_IN_BACKGROUND, - prepareArguments("seconds", prepareArguments("timeout", duration.toMillis()))); - } - @Override public TargetLocator switchTo() { return new InnerTargetLocator(); } From e8cb616d5a1916e13340e4b059f052ab35b00ca0 Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Fri, 6 Sep 2019 18:48:29 +0200 Subject: [PATCH 2/3] Tune docstring --- src/main/java/io/appium/java_client/InteractsWithApps.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/appium/java_client/InteractsWithApps.java b/src/main/java/io/appium/java_client/InteractsWithApps.java index 11549cd1a..ae44d7be4 100644 --- a/src/main/java/io/appium/java_client/InteractsWithApps.java +++ b/src/main/java/io/appium/java_client/InteractsWithApps.java @@ -98,7 +98,8 @@ default void resetApp() { * requested. This is a synchronous method, it returns after the back has * been returned to the foreground. * - * @param duration The time to run App in background. Minimum time resolution is one millisecond + * @param duration The time to run App in background. Minimum time resolution is one millisecond. + * Passing zero of negative value will switch to Home screen and return immediately. */ default void runAppInBackground(Duration duration) { execute(RUN_APP_IN_BACKGROUND, ImmutableMap.of("seconds", duration.toMillis() / 1000.0)); From 1353b3da8d82e7efdf373458abbacbfd86ee87bb Mon Sep 17 00:00:00 2001 From: Mykola Mokhnach Date: Fri, 6 Sep 2019 19:01:28 +0200 Subject: [PATCH 3/3] Change wording --- src/main/java/io/appium/java_client/InteractsWithApps.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/io/appium/java_client/InteractsWithApps.java b/src/main/java/io/appium/java_client/InteractsWithApps.java index ae44d7be4..202360e22 100644 --- a/src/main/java/io/appium/java_client/InteractsWithApps.java +++ b/src/main/java/io/appium/java_client/InteractsWithApps.java @@ -95,11 +95,11 @@ default void resetApp() { /** * Runs the current app as a background app for the time - * requested. This is a synchronous method, it returns after the back has - * been returned to the foreground. + * requested. This is a synchronous method, it blocks while the + * application is in background. * * @param duration The time to run App in background. Minimum time resolution is one millisecond. - * Passing zero of negative value will switch to Home screen and return immediately. + * Passing zero or a negative value will switch to Home screen and return immediately. */ default void runAppInBackground(Duration duration) { execute(RUN_APP_IN_BACKGROUND, ImmutableMap.of("seconds", duration.toMillis() / 1000.0));