Skip to content

Commit a729d73

Browse files
New interfaces. The beginning of appium#105 fix
1 parent 8666224 commit a729d73

17 files changed

+342
-11
lines changed

src/main/java/io/appium/java_client/AppiumDriver.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ public void sendKeyEvent(int key, Integer metastate) {
170170
/**
171171
* Get the current activity being run on the mobile device
172172
*/
173+
//Should be moved to the subclass (Android)
173174
public String currentActivity() {
174175
Response response = execute(CURRENT_ACTIVITY);
175176
return response.getValue().toString();
@@ -304,6 +305,7 @@ public void runAppInBackground(int seconds) {
304305
* Open the notification shade, on Android devices.
305306
* Android only method.
306307
*/
308+
//Should be moved to the subclass
307309
public void openNotifications() { execute(OPEN_NOTIFICATIONS); }
308310
/**
309311
* Performs a chain of touch actions, which together can be considered an entire gesture.
@@ -541,6 +543,7 @@ public void closeApp() {
541543
* @param intent intent to broadcast
542544
* @param path path to .ec file
543545
*/
546+
//Should be moved to the subclass
544547
public void endTestCoverage(String intent, String path) {
545548
ImmutableMap.Builder builder = ImmutableMap.builder();
546549
builder.put("intent", intent).put("path", path);
@@ -561,6 +564,7 @@ public void lockScreen(int seconds) {
561564
*
562565
* @return true if device is locked. False otherwise
563566
*/
567+
//Should be moved to the subclass
564568
public boolean isLocked() {
565569

566570
Response response = execute(IS_LOCKED);
@@ -659,6 +663,7 @@ private void setSetting(AppiumSetting setting, Object value) {
659663
*
660664
* @param compress ignores unimportant views if true, doesn't ignore otherwise.
661665
*/
666+
//Should be moved to the subclass
662667
public void ignoreUnimportantViews(Boolean compress) {
663668
setSetting(AppiumSetting.IGNORE_UNIMPORTANT_VIEWS, compress);
664669
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
package io.appium.java_client;
2+
3+
public interface DeviceActionShortcuts {
4+
5+
/**
6+
* Hides the keyboard if it is showing.
7+
* On iOS, there are multiple strategies for hiding the keyboard. Defaults to the "tapOutside" strategy (taps outside the keyboard).
8+
* Switch to using hideKeyboard(HideKeyboardStrategy.PRESS_KEY, "Done") if this doesn't work.
9+
*/
10+
public void hideKeyboard();
11+
12+
/**
13+
* Send a key event to the device
14+
*
15+
* @param key code for the key pressed on the device
16+
*
17+
* @see AndroidKeyCode
18+
* @see IOSKeyCode
19+
*/
20+
public void sendKeyEvent(int key);
21+
22+
}

src/main/java/io/appium/java_client/IOSKeyCode.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
package io.appium.java_client;
1919

2020
/**
21-
* Some common key codes for Android Key Events
21+
* Some common key codes for iOS Key Events
2222
*/
2323
public interface IOSKeyCode {
2424

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package io.appium.java_client;
2+
3+
public interface InteractsWithFiles {
4+
5+
/**
6+
*
7+
* @param remotePath
8+
* On Android and iOS, this is either the path to the file
9+
* (relative to the root of the app's file system). On iOS only,
10+
* if path starts with /AppName.app, which will be replaced with
11+
* the application's .app directory
12+
* @return A byte array of Base64 encoded data.
13+
*/
14+
public byte[] pullFile(String remotePath);
15+
16+
/**
17+
* Pull a folder from the simulator/device. Does not work on iOS Real
18+
* Devices, but works on simulators
19+
*
20+
* @param remotePath
21+
* On Android and iOS, this is either the path to the file
22+
* (relative to the root of the app's file system). On iOS only,
23+
* if path starts with /AppName.app, which will be replaced with
24+
* the application's .app directory
25+
* @return A byte array of Base64 encoded data, representing a ZIP ARCHIVE
26+
* of the contents of the requested folder.
27+
*/
28+
public byte[] pullFolder(String remotePath);
29+
30+
}

src/main/java/io/appium/java_client/MobileDriver.java

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,19 +17,13 @@
1717

1818
package io.appium.java_client;
1919

20-
2120
import org.openqa.selenium.ContextAware;
2221
import org.openqa.selenium.WebDriver;
2322
import org.openqa.selenium.remote.Response;
2423

2524
import java.util.Map;
2625

27-
public interface MobileDriver extends WebDriver, ContextAware {
28-
29-
30-
public Response execute(String driverCommand, Map<String, ?> parameters);
31-
32-
public TouchAction performTouchAction(TouchAction touchAction);
33-
34-
public void performMultiTouchAction(MultiTouchAction multiAction);
26+
public interface MobileDriver extends WebDriver, ContextAware,
27+
PerformsTouchActions {
28+
public Response execute(String driverCommand, Map<String, ?> parameters);
3529
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package io.appium.java_client;
2+
3+
public interface PerformsTouchActions {
4+
public TouchAction performTouchAction(TouchAction touchAction);
5+
6+
public void performMultiTouchAction(MultiTouchAction multiAction);
7+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package io.appium.java_client;
2+
3+
public interface ScrollsTo {
4+
5+
public MobileElement scrollTo(String text);
6+
7+
public MobileElement scrollToExact(String text);
8+
9+
}
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
package io.appium.java_client;
2+
3+
import org.openqa.selenium.WebElement;
4+
5+
public interface TouchShortcuts {
6+
7+
/**
8+
* Convenience method for "zooming in" on an element on the screen.
9+
* "zooming in" refers to the action of two appendages pressing the screen and sliding away from each other.
10+
* NOTE:
11+
* This convenience method slides touches away from the element, if this would happen to place one of them
12+
* off the screen, appium will return an outOfBounds error. In this case, revert to using the MultiTouchAction api
13+
* instead of this method.
14+
*
15+
* @param x x coordinate to start zoom on
16+
* @param y y coordinate to start zoom on
17+
*/
18+
public void zoom(int x, int y);
19+
20+
/**
21+
* Convenience method for "zooming in" on an element on the screen.
22+
* "zooming in" refers to the action of two appendages pressing the screen and sliding away from each other.
23+
* NOTE:
24+
* This convenience method slides touches away from the element, if this would happen to place one of them
25+
* off the screen, appium will return an outOfBounds error. In this case, revert to using the MultiTouchAction api
26+
* instead of this method.
27+
*
28+
* @param el The element to pinch
29+
*/
30+
public void zoom(WebElement el);
31+
32+
/**
33+
* Convenience method for tapping a position on the screen
34+
*
35+
* @param fingers
36+
* number of fingers/appendages to tap with
37+
* @param x
38+
* x coordinate
39+
* @param y
40+
* y coordinate
41+
* @param duration
42+
*/
43+
public void tap(int fingers, int x, int y, int duration);
44+
45+
/**
46+
* Convenience method for tapping the center of an element on the screen
47+
*
48+
* @param fingers
49+
* number of fingers/appendages to tap with
50+
* @param element
51+
* element to tap
52+
* @param duration
53+
* how long between pressing down, and lifting fingers/appendages
54+
*/
55+
public void tap(int fingers, WebElement element, int duration);
56+
57+
/**
58+
* Convenience method for swiping across the screen
59+
*
60+
* @param startx
61+
* starting x coordinate
62+
* @param starty
63+
* starting y coordinate
64+
* @param endx
65+
* ending x coordinate
66+
* @param endy
67+
* ending y coordinate
68+
* @param duration
69+
* amount of time in milliseconds for the entire swipe action to
70+
* take
71+
*/
72+
public void swipe(int startx, int starty, int endx, int endy, int duration);
73+
74+
/**
75+
* Convenience method for pinching an element on the screen.
76+
* "pinching" refers to the action of two appendages pressing the screen and sliding towards each other.
77+
* NOTE:
78+
* This convenience method places the initial touches around the element at a distance, if this would happen to place
79+
* one of them off the screen, appium will return an outOfBounds error. In this case, revert to using the
80+
* MultiTouchAction api instead of this method.
81+
*
82+
* @param x x coordinate to terminate the pinch on
83+
* @param y y coordinate to terminate the pinch on
84+
*/
85+
public void pinch(int x, int y);
86+
87+
/**
88+
* Convenience method for pinching an element on the screen.
89+
* "pinching" refers to the action of two appendages pressing the screen and sliding towards each other.
90+
* NOTE:
91+
* This convenience method places the initial touches around the element, if this would happen to place one of them
92+
* off the screen, appium with return an outOfBounds error. In this case, revert to using the MultiTouchAction api
93+
* instead of this method.
94+
*
95+
* @param el The element to pinch
96+
*/
97+
public void pinch(WebElement el);
98+
99+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
package io.appium.java_client.android;
2+
3+
import io.appium.java_client.AndroidKeyCode;
4+
import io.appium.java_client.DeviceActionShortcuts;
5+
6+
public interface AndroidDeviceActionShortcuts extends DeviceActionShortcuts {
7+
/**
8+
* Send a key event along with an Android metastate to an Android device
9+
* Metastates are things like *shift* to get uppercase characters
10+
*
11+
* @param key code for the key pressed on the Android device
12+
* @param metastate metastate for the keypress
13+
*
14+
* @see AndroidKeyCode
15+
* @see AndroidKeyMetastate
16+
*/
17+
public void sendKeyEvent(int key, Integer metastate);
18+
}

src/main/java/io/appium/java_client/AndroidKeyMetastate.java renamed to src/main/java/io/appium/java_client/android/AndroidKeyMetastate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
+limitations under the License.
1616
+ */
1717

18-
package io.appium.java_client;
18+
package io.appium.java_client.android;
1919

2020
/**
2121
* Metastates for Android Key Events

0 commit comments

Comments
 (0)