Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
New interfaces. The beginning of #105 fix
  • Loading branch information
TikhomirovSergey committed Sep 12, 2014
commit a729d738cbdf3d9a674ebab9d5236181e9e4b4c6
5 changes: 5 additions & 0 deletions src/main/java/io/appium/java_client/AppiumDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ public void sendKeyEvent(int key, Integer metastate) {
/**
* Get the current activity being run on the mobile device
*/
//Should be moved to the subclass (Android)
public String currentActivity() {
Response response = execute(CURRENT_ACTIVITY);
return response.getValue().toString();
Expand Down Expand Up @@ -304,6 +305,7 @@ public void runAppInBackground(int seconds) {
* Open the notification shade, on Android devices.
* Android only method.
*/
//Should be moved to the subclass
public void openNotifications() { execute(OPEN_NOTIFICATIONS); }
/**
* Performs a chain of touch actions, which together can be considered an entire gesture.
Expand Down Expand Up @@ -541,6 +543,7 @@ public void closeApp() {
* @param intent intent to broadcast
* @param path path to .ec file
*/
//Should be moved to the subclass
public void endTestCoverage(String intent, String path) {
ImmutableMap.Builder builder = ImmutableMap.builder();
builder.put("intent", intent).put("path", path);
Expand All @@ -561,6 +564,7 @@ public void lockScreen(int seconds) {
*
* @return true if device is locked. False otherwise
*/
//Should be moved to the subclass
public boolean isLocked() {

Response response = execute(IS_LOCKED);
Expand Down Expand Up @@ -659,6 +663,7 @@ private void setSetting(AppiumSetting setting, Object value) {
*
* @param compress ignores unimportant views if true, doesn't ignore otherwise.
*/
//Should be moved to the subclass
public void ignoreUnimportantViews(Boolean compress) {
setSetting(AppiumSetting.IGNORE_UNIMPORTANT_VIEWS, compress);
}
Expand Down
22 changes: 22 additions & 0 deletions src/main/java/io/appium/java_client/DeviceActionShortcuts.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package io.appium.java_client;

public interface DeviceActionShortcuts {

/**
* Hides the keyboard if it is showing.
* On iOS, there are multiple strategies for hiding the keyboard. Defaults to the "tapOutside" strategy (taps outside the keyboard).
* Switch to using hideKeyboard(HideKeyboardStrategy.PRESS_KEY, "Done") if this doesn't work.
*/
public void hideKeyboard();

/**
* Send a key event to the device
*
* @param key code for the key pressed on the device
*
* @see AndroidKeyCode
* @see IOSKeyCode
*/
public void sendKeyEvent(int key);

}
2 changes: 1 addition & 1 deletion src/main/java/io/appium/java_client/IOSKeyCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
package io.appium.java_client;

/**
* Some common key codes for Android Key Events
* Some common key codes for iOS Key Events
*/
public interface IOSKeyCode {

Expand Down
30 changes: 30 additions & 0 deletions src/main/java/io/appium/java_client/InteractsWithFiles.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.appium.java_client;

public interface InteractsWithFiles {

/**
*
* @param remotePath
* On Android and iOS, this is either the path to the file
* (relative to the root of the app's file system). On iOS only,
* if path starts with /AppName.app, which will be replaced with
* the application's .app directory
* @return A byte array of Base64 encoded data.
*/
public byte[] pullFile(String remotePath);

/**
* Pull a folder from the simulator/device. Does not work on iOS Real
* Devices, but works on simulators
*
* @param remotePath
* On Android and iOS, this is either the path to the file
* (relative to the root of the app's file system). On iOS only,
* if path starts with /AppName.app, which will be replaced with
* the application's .app directory
* @return A byte array of Base64 encoded data, representing a ZIP ARCHIVE
* of the contents of the requested folder.
*/
public byte[] pullFolder(String remotePath);

}
12 changes: 3 additions & 9 deletions src/main/java/io/appium/java_client/MobileDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,13 @@

package io.appium.java_client;


import org.openqa.selenium.ContextAware;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.remote.Response;

import java.util.Map;

public interface MobileDriver extends WebDriver, ContextAware {


public Response execute(String driverCommand, Map<String, ?> parameters);

public TouchAction performTouchAction(TouchAction touchAction);

public void performMultiTouchAction(MultiTouchAction multiAction);
public interface MobileDriver extends WebDriver, ContextAware,
PerformsTouchActions {
public Response execute(String driverCommand, Map<String, ?> parameters);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.appium.java_client;

public interface PerformsTouchActions {
public TouchAction performTouchAction(TouchAction touchAction);

public void performMultiTouchAction(MultiTouchAction multiAction);
}
9 changes: 9 additions & 0 deletions src/main/java/io/appium/java_client/ScrollsTo.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.appium.java_client;

public interface ScrollsTo {

public MobileElement scrollTo(String text);

public MobileElement scrollToExact(String text);

}
99 changes: 99 additions & 0 deletions src/main/java/io/appium/java_client/TouchShortcuts.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
package io.appium.java_client;

import org.openqa.selenium.WebElement;

public interface TouchShortcuts {

/**
* Convenience method for "zooming in" on an element on the screen.
* "zooming in" refers to the action of two appendages pressing the screen and sliding away from each other.
* NOTE:
* This convenience method slides touches away from the element, if this would happen to place one of them
* off the screen, appium will return an outOfBounds error. In this case, revert to using the MultiTouchAction api
* instead of this method.
*
* @param x x coordinate to start zoom on
* @param y y coordinate to start zoom on
*/
public void zoom(int x, int y);

/**
* Convenience method for "zooming in" on an element on the screen.
* "zooming in" refers to the action of two appendages pressing the screen and sliding away from each other.
* NOTE:
* This convenience method slides touches away from the element, if this would happen to place one of them
* off the screen, appium will return an outOfBounds error. In this case, revert to using the MultiTouchAction api
* instead of this method.
*
* @param el The element to pinch
*/
public void zoom(WebElement el);

/**
* Convenience method for tapping a position on the screen
*
* @param fingers
* number of fingers/appendages to tap with
* @param x
* x coordinate
* @param y
* y coordinate
* @param duration
*/
public void tap(int fingers, int x, int y, int duration);

/**
* Convenience method for tapping the center of an element on the screen
*
* @param fingers
* number of fingers/appendages to tap with
* @param element
* element to tap
* @param duration
* how long between pressing down, and lifting fingers/appendages
*/
public void tap(int fingers, WebElement element, int duration);

/**
* Convenience method for swiping across the screen
*
* @param startx
* starting x coordinate
* @param starty
* starting y coordinate
* @param endx
* ending x coordinate
* @param endy
* ending y coordinate
* @param duration
* amount of time in milliseconds for the entire swipe action to
* take
*/
public void swipe(int startx, int starty, int endx, int endy, int duration);

/**
* Convenience method for pinching an element on the screen.
* "pinching" refers to the action of two appendages pressing the screen and sliding towards each other.
* NOTE:
* This convenience method places the initial touches around the element at a distance, if this would happen to place
* one of them off the screen, appium will return an outOfBounds error. In this case, revert to using the
* MultiTouchAction api instead of this method.
*
* @param x x coordinate to terminate the pinch on
* @param y y coordinate to terminate the pinch on
*/
public void pinch(int x, int y);

/**
* Convenience method for pinching an element on the screen.
* "pinching" refers to the action of two appendages pressing the screen and sliding towards each other.
* NOTE:
* This convenience method places the initial touches around the element, if this would happen to place one of them
* off the screen, appium with return an outOfBounds error. In this case, revert to using the MultiTouchAction api
* instead of this method.
*
* @param el The element to pinch
*/
public void pinch(WebElement el);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package io.appium.java_client.android;

import io.appium.java_client.AndroidKeyCode;
import io.appium.java_client.DeviceActionShortcuts;

public interface AndroidDeviceActionShortcuts extends DeviceActionShortcuts {
/**
* Send a key event along with an Android metastate to an Android device
* Metastates are things like *shift* to get uppercase characters
*
* @param key code for the key pressed on the Android device
* @param metastate metastate for the keypress
*
* @see AndroidKeyCode
* @see AndroidKeyMetastate
*/
public void sendKeyEvent(int key, Integer metastate);
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
+limitations under the License.
+ */

package io.appium.java_client;
package io.appium.java_client.android;

/**
* Metastates for Android Key Events
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/io/appium/java_client/android/HasAppStrings.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package io.appium.java_client.android;


public interface HasAppStrings {

/**
* Get all defined Strings from an Android app for the default language
*
* @return a string of all the localized strings defined in the app
*/
public String getAppStrings();

/**
* Get all defined Strings from an Android app for the specified language
*
* @param language strings language code
* @return a string of all the localized strings defined in the app
*/
public String getAppStrings(String language);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package io.appium.java_client.android;

import io.appium.java_client.NetworkConnectionSetting;

public interface HasNetworkConnection {

/**
* Get the current network settings of the device.
*
* @return NetworkConnectionSetting objects will let you inspect the status
* of AirplaneMode, Wifi, Data connections
*/
public NetworkConnectionSetting getNetworkConnection();

/**
* Set the network connection of the device. This is an Android-only method
*
* @param connection
* The NetworkConnectionSetting configuration to use for the
* device
*/
public void setNetworkConnection(NetworkConnectionSetting connection);

}
17 changes: 17 additions & 0 deletions src/main/java/io/appium/java_client/android/PushesFiles.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.appium.java_client.android;

import io.appium.java_client.InteractsWithFiles;

public interface PushesFiles extends InteractsWithFiles {

/**
* Save base64 encoded data as a file on the remote mobile device.
*
* @param remotePath
* Path to file to write data to on remote device
* @param base64Data
* Base64 encoded byte array of data to write to remote device
*/
public void pushFile(String remotePath, byte[] base64Data);

}
30 changes: 30 additions & 0 deletions src/main/java/io/appium/java_client/android/StartsActivity.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package io.appium.java_client.android;

public interface StartsActivity {
/**
* This method should start arbitrary activity during a test. If the activity belongs to
* another application, that application is started and the activity is opened.
*
* @param appPackage The package containing the activity. [Required]
* @param appActivity The activity to start. [Required]
* @param appWaitPackage Automation will begin after this package starts. [Optional]
* @param appWaitActivity Automation will begin after this activity starts. [Optional]
* @example
* *.startActivity("com.foo.bar", ".MyActivity", null, null);
*/
public void startActivity(String appPackage, String appActivity, String appWaitPackage, String appWaitActivity)
throws IllegalArgumentException;

/**
* This method should start arbitrary activity during a test. If the activity belongs to
* another application, that application is started and the activity is opened.
*
* @param appPackage The package containing the activity. [Required]
* @param appActivity The activity to start. [Required]
* @example
* *.startActivity("com.foo.bar", ".MyActivity");
*/
public void startActivity(String appPackage, String appActivity)
throws IllegalArgumentException;

}
17 changes: 17 additions & 0 deletions src/main/java/io/appium/java_client/ios/GetsNamedTextField.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.appium.java_client.ios;

import org.openqa.selenium.WebElement;

public interface GetsNamedTextField {
/**
* In iOS apps, named TextFields have the same accessibility Id as their
* containing TableElement. This is a convenience method for getting the
* named TextField, rather than its containing element.
*
* @param name
* accessiblity id of TextField
* @return The textfield with the given accessibility id
*/
public WebElement getNamedTextField(String name);

}
Loading