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 24 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
22 changes: 22 additions & 0 deletions src/main/java/io/appium/java_client/HasDeviceDetails.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.appium.java_client;

import static io.appium.java_client.MobileCommand.GET_DISPLAY_DENSITY;
import static io.appium.java_client.MobileCommand.GET_SYSTEM_BARS;

import java.util.Map;

public interface HasDeviceDetails extends ExecutesMethod {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems that methods that declared by this interface are Android-specific. Please take a look at
https://github.com/search?q=org%3Aappium+DISPLAY+DENSITY&type=Code

https://github.com/search?q=org%3Aappium+GET+SYSTEM+BARS&type=Code

I think it has more sense to move this interface to the io.appium.java_client.android

/*
Retrieve the display density of the Android device.
*/
default Long getDisplayDensity() {
return CommandExecutionHelper.execute(this, GET_DISPLAY_DENSITY);
}

/*
Retrieve visibility and bounds information of the status and navigation bars.
*/
default Map<String, String> getSystemBars() {
return CommandExecutionHelper.execute(this, GET_SYSTEM_BARS);
}
}
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 @@ -23,6 +23,7 @@
import io.appium.java_client.AppiumDriver;
import io.appium.java_client.CommandExecutionHelper;
import io.appium.java_client.FindsByAndroidUIAutomator;
import io.appium.java_client.HasDeviceDetails;
import io.appium.java_client.PressesKeyCode;
import io.appium.java_client.android.internal.JsonToAndroidElementConverter;
import io.appium.java_client.remote.MobilePlatform;
Expand All @@ -48,7 +49,8 @@
public class AndroidDriver<T extends WebElement>
extends AppiumDriver<T>
implements PressesKeyCode, HasNetworkConnection, PushesFiles, StartsActivity,
FindsByAndroidUIAutomator<T>, LocksAndroidDevice, HasSettings {
FindsByAndroidUIAutomator<T>, LocksAndroidDevice, HasSettings, IsKeyboardShown,
HasDeviceDetails {

private static final String ANDROID_PLATFORM = MobilePlatform.ANDROID;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,18 @@ public class AndroidMobileCommandHelper extends MobileCommand {
GET_NETWORK_CONNECTION, 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
17 changes: 17 additions & 0 deletions src/main/java/io/appium/java_client/android/IsKeyboardShown.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.appium.java_client.android;

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

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

public interface IsKeyboardShown extends ExecutesMethod {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it has more sense to unite this interface with HasDeviceDetails

/**
* 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 @@ -17,6 +17,7 @@
package io.appium.java_client.android;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;

Expand All @@ -25,6 +26,7 @@
import org.junit.Before;
import org.junit.Test;


public class AndroidSearchingTest extends BaseAndroidTest {

@Before
Expand Down Expand Up @@ -63,4 +65,10 @@ public void setup() throws Exception {
+ "new UiSelector().text(\"Radio Group\"));");
assertNotNull(radioGroup.getLocation());
}

@Test public void deviceDetailsAndKeyboardTest() {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why this method is here? Maybe it has more sense to move it to AndroidDriverTest

assertFalse(driver.isKeyboardShown());
assertNotNull(driver.getDisplayDensity());
assertNotEquals(0, driver.getSystemBars().size());
}
}
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