Skip to content

Commit

Permalink
chore: Switch the implementation of backgroundApp for iOS, so it's in…
Browse files Browse the repository at this point in the history
… sync with other platforms (#1229)
  • Loading branch information
mykola-mokhnach committed Sep 7, 2019
1 parent 9020174 commit 822f004
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 19 deletions.
9 changes: 5 additions & 4 deletions src/main/java/io/appium/java_client/InteractsWithApps.java
Expand Up @@ -95,13 +95,14 @@ 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 second
* @param duration The time to run App in background. Minimum time resolution is one millisecond.
* 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.getSeconds()));
execute(RUN_APP_IN_BACKGROUND, ImmutableMap.of("seconds", duration.toMillis() / 1000.0));
}

/**
Expand Down
15 changes: 0 additions & 15 deletions src/main/java/io/appium/java_client/ios/IOSDriver.java
Expand Up @@ -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;

Expand All @@ -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;

Expand Down Expand Up @@ -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();
}
Expand Down

0 comments on commit 822f004

Please sign in to comment.