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 Android device commands #518

Merged
merged 26 commits into from
Nov 26, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
b6aa487
Splitting of TouchActions
SrinivasanTarget Aug 11, 2016
d76bad8
Codacy Fixes
SrinivasanTarget Aug 11, 2016
1909222
Merge branch 'master' of https://github.com/appium/java-client into T…
SrinivasanTarget Oct 30, 2016
b5bc4e6
Merge branch 'TouchActionSplitting' of https://github.com/SrinivasanT…
TikhomirovSergey Nov 3, 2016
ffbb4de
#456 FIX #454 FIX: API redesign.
TikhomirovSergey Nov 4, 2016
4ea6635
#456 FIX #454 FIX: MultiTouchAction refactoring
TikhomirovSergey Nov 6, 2016
34a718b
#456 FIX #454 FIX: New CreatesSwipeAction API
TikhomirovSergey Nov 8, 2016
e890280
#456 FIX #454 FIX:
TikhomirovSergey Nov 8, 2016
4b87991
#456 FIX #454 FIX: CreatesSwipeAction API was implemented
TikhomirovSergey Nov 9, 2016
f799d34
#456 FIX #454 FIX: AndroidTouchActions were covered with tests.
TikhomirovSergey Nov 10, 2016
f07ac6e
#456 FIX #454 FIX: Refactoring of MobileElement
TikhomirovSergey Nov 10, 2016
980b6a1
#456 FIX #454 FIX: IOSGesturesTest was redesigned.
TikhomirovSergey Nov 11, 2016
d832a19
#456 FIX #454 FIX: Checkstyle issues were got fixed
TikhomirovSergey Nov 11, 2016
f8ad455
#456 FIX #454 FIX: The additional test on Android.
TikhomirovSergey Nov 12, 2016
2ba3652
Issues that found by codecy were got fixed
TikhomirovSergey Nov 13, 2016
5b9a7c0
Merge branch 'SrinivasanTarget-TouchActionSplitting' of https://githu…
SrinivasanTarget Nov 14, 2016
f9a928e
The addition #513
SrinivasanTarget Nov 16, 2016
da9064b
Merge branch 'master' of https://github.com/appium/java-client into T…
SrinivasanTarget Nov 18, 2016
9ae8606
Added isKeyboardShown,getDisplayDensity and getSystemBars Commands
SrinivasanTarget Nov 19, 2016
d42df2b
Fixed Tests
SrinivasanTarget Nov 19, 2016
b63df4b
Merge branch 'TikhomirovSergey-SrinivasanTarget-TouchActionSplitting'…
SrinivasanTarget Nov 19, 2016
db74f17
Refractoring
SrinivasanTarget Nov 22, 2016
b2b5c14
Merge branch 'master' of https://github.com/appium/java-client into A…
SrinivasanTarget Nov 24, 2016
a3fdeda
Fixed styling issues
SrinivasanTarget Nov 24, 2016
20ba018
Fixed review comments
SrinivasanTarget Nov 25, 2016
358bdce
Fixed review comments
SrinivasanTarget Nov 25, 2016
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
6 changes: 6 additions & 0 deletions src/main/java/io/appium/java_client/MobileCommand.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ public class MobileCommand {
//Android
protected static final String CURRENT_ACTIVITY = "currentActivity";
protected static final String END_TEST_COVERAGE = "endTestCoverage";
protected static final String GET_DISPLAY_DENSITY = "getDisplayDensity";
protected static final String GET_NETWORK_CONNECTION = "getNetworkConnection";
protected static final String GET_SYSTEM_BARS = "getSystemBars";
protected static final String IS_KEYBOARD_SHOWN = "isKeyboardShown";
protected static final String IS_LOCKED = "isLocked";
protected static final String LONG_PRESS_KEY_CODE = "longPressKeyCode";
protected static final String OPEN_NOTIFICATIONS = "openNotifications";
Expand Down Expand Up @@ -102,7 +105,10 @@ private static Map<String, CommandInfo> createCommandRepository() {
getC("/session/:sessionId/appium/device/current_activity"));
result.put(END_TEST_COVERAGE,
postC("/session/:sessionId/appium/app/end_test_coverage"));
result.put(GET_DISPLAY_DENSITY, getC("/session/:sessionId/appium/device/display_density"));
result.put(GET_NETWORK_CONNECTION, getC("/session/:sessionId/network_connection"));
result.put(GET_SYSTEM_BARS, getC("/session/:sessionId/appium/device/system_bars"));
result.put(IS_KEYBOARD_SHOWN, getC("/session/:sessionId/appium/device/is_keyboard_shown"));
result.put(IS_LOCKED, postC("/session/:sessionId/appium/device/is_locked"));
result.put(LONG_PRESS_KEY_CODE,
postC("/session/:sessionId/appium/device/long_press_keycode"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
public class AndroidDriver<T extends WebElement>
extends AppiumDriver<T>
implements PressesKeyCode, HasNetworkConnection, PushesFiles, StartsActivity,
FindsByAndroidUIAutomator<T>, LocksAndroidDevice, HasSettings {
FindsByAndroidUIAutomator<T>, LocksAndroidDevice, HasSettings, HasDeviceDetails {

private static final String ANDROID_PLATFORM = MobilePlatform.ANDROID;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ public class AndroidMobileCommandHelper extends MobileCommand {
END_TEST_COVERAGE, prepareArguments(parameters, values));
}

/**
* This method forms a {@link java.util.Map} of parameters to
* Retrieve the display density of the Android device.
*
* @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, ?>> getDisplayDensityCommand() {
return new AbstractMap.SimpleEntry<>(
GET_DISPLAY_DENSITY, ImmutableMap.<String, Object>of());
}

/**
* This method forms a {@link java.util.Map} of parameters for the
* getting of a network connection value.
Expand All @@ -75,6 +87,30 @@ public class AndroidMobileCommandHelper extends MobileCommand {
GET_NETWORK_CONNECTION, ImmutableMap.<String, Object>of());
}

/**
* This method forms a {@link java.util.Map} of parameters to
* Retrieve visibility and bounds information of the status and navigation bars.
*
* @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, ?>> getSystemBarsCommand() {
return new AbstractMap.SimpleEntry<>(
GET_SYSTEM_BARS, ImmutableMap.<String, Object>of());
}

/**
* This method forms a {@link java.util.Map} of parameters for the
* checking of the keyboard state (is it shown or not).
*
* @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, ?>> isKeyboardShownCommand() {
return new AbstractMap.SimpleEntry<>(
IS_KEYBOARD_SHOWN, ImmutableMap.<String, Object>of());
}

/**
* This method forms a {@link java.util.Map} of parameters for the
* checking of the device state (is it locked or not).
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package io.appium.java_client.android;

import static io.appium.java_client.android.AndroidMobileCommandHelper.getDisplayDensityCommand;
import static io.appium.java_client.android.AndroidMobileCommandHelper.getSystemBarsCommand;
import static io.appium.java_client.android.AndroidMobileCommandHelper.isKeyboardShownCommand;

import io.appium.java_client.CommandExecutionHelper;
import io.appium.java_client.ExecutesMethod;

import java.util.Map;

public interface HasDeviceDetails extends ExecutesMethod {
/*
Retrieve the display density of the Android device.
*/
default Long getDisplayDensity() {
return CommandExecutionHelper.execute(this, getDisplayDensityCommand());
}

/*
Retrieve visibility and bounds information of the status and navigation bars.
*/
default Map<String, String> getSystemBars() {
return CommandExecutionHelper.execute(this, getSystemBarsCommand());
}

/**
* Check if the keyboard is displayed.
*
* @return true if keyboard is displayed. False otherwise
*/
default boolean isKeyboardShown() {
return CommandExecutionHelper.execute(this, isKeyboardShownCommand());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,10 @@ public class AndroidDriverTest extends BaseAndroidTest {
Map<?,?> map = (Map<?, ?>) driver.getSessionDetail("desired");
assertNotEquals(map.size(), 0);
}

@Test public void deviceDetailsAndKeyboardTest() {
assertFalse(driver.isKeyboardShown());
assertNotNull(driver.getDisplayDensity());
assertNotEquals(0, driver.getSystemBars().size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.junit.Before;
import org.junit.Test;


public class AndroidSearchingTest extends BaseAndroidTest {

@Before
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import io.appium.java_client.remote.MobileCapabilityType;
import io.appium.java_client.service.local.AppiumDriverLocalService;
import io.appium.java_client.service.local.AppiumServerHasNotBeenStartedLocallyException;

import org.junit.AfterClass;
import org.junit.BeforeClass;
Expand All @@ -38,7 +39,8 @@ public class BaseAndroidTest {
service.start();

if (service == null || !service.isRunning()) {
throw new RuntimeException("An appium server node is not started!");
throw new AppiumServerHasNotBeenStartedLocallyException(
"An appium server node is not started!");
}

File appDir = new File("src/test/java/io/appium/java_client");
Expand Down