Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added get_current_package session #657

Merged
merged 3 commits into from
Jun 20, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/main/java/io/appium/java_client/MobileCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ public class MobileCommand {
protected static final String REPLACE_VALUE;
protected static final String GET_SETTINGS;
protected static final String SET_SETTINGS;
protected static final String GET_CURRENT_PACKAGE;

public static final Map<String, AppiumCommandInfo> commandRepository;

Expand Down Expand Up @@ -122,6 +123,7 @@ public class MobileCommand {
REPLACE_VALUE = "replaceValue";
GET_SETTINGS = "getSettings";
SET_SETTINGS = "setSettings";
GET_CURRENT_PACKAGE = "getCurrentPackage";

commandRepository = new HashMap<>();
commandRepository.put(RESET, postC("/session/:sessionId/appium/app/reset"));
Expand Down Expand Up @@ -176,6 +178,7 @@ public class MobileCommand {
postC("/session/:sessionId/appium/device/toggle_location_services"));
commandRepository.put(UNLOCK, postC("/session/:sessionId/appium/device/unlock"));
commandRepository. put(REPLACE_VALUE, postC("/session/:sessionId/appium/element/:id/replace_value"));
commandRepository.put(GET_CURRENT_PACKAGE,getC("/session/:sessionId/appium/device/current_package"));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,4 +180,5 @@ public void openNotifications() {
public void toggleLocationServices() {
CommandExecutionHelper.execute(this, toggleLocationServicesCommand());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,18 @@ public class AndroidMobileCommandHelper extends MobileCommand {
CURRENT_ACTIVITY, ImmutableMap.<String, Object>of());
}

/**
* This method forms a {@link java.util.Map} of parameters for the
* getting of the current package.
*
* @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<String, Map<String, ?>> currentPackageCommand() {
return new AbstractMap.SimpleEntry<>(
GET_CURRENT_PACKAGE, ImmutableMap.<String, Object>of());
}

/**
* This method forms a {@link java.util.Map} of parameters for the
* ending of the test coverage.
Expand Down
10 changes: 10 additions & 0 deletions src/main/java/io/appium/java_client/android/StartsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
package io.appium.java_client.android;

import static io.appium.java_client.android.AndroidMobileCommandHelper.currentActivityCommand;
import static io.appium.java_client.android.AndroidMobileCommandHelper.currentPackageCommand;
import static io.appium.java_client.android.AndroidMobileCommandHelper.startActivityCommand;

import io.appium.java_client.CommandExecutionHelper;
Expand Down Expand Up @@ -158,4 +159,13 @@ default void startActivity(String appPackage, String appActivity, String appWait
default String currentActivity() {
return CommandExecutionHelper.execute(this, currentActivityCommand());
}

/**
* Get the current package being run on the mobile device.
*
* @return a current package being run on the mobile device.
*/
default String getCurrentPackage() {
return CommandExecutionHelper.execute(this, currentPackageCommand());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,4 +183,8 @@ public class AndroidDriverTest extends BaseAndroidTest {

}

@Test public void getCurrentPackageTest() {
assertEquals("io.appium.android.apis",driver.getCurrentPackage());
}

}