Skip to content

Commit 3a07643

Browse files
#160 fixed parameter names and comments.
1 parent 166a0cb commit 3a07643

File tree

2 files changed

+161
-157
lines changed

2 files changed

+161
-157
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,82 @@
1-
/*
2-
+Copyright 2014 Appium contributors
3-
+Copyright 2014 Software Freedom Conservancy
4-
+
5-
+Licensed under the Apache License, Version 2.0 (the "License");
6-
+you may not use this file except in compliance with the License.
7-
+You may obtain a copy of the License at
8-
+
9-
+ http://www.apache.org/licenses/LICENSE-2.0
10-
+
11-
+Unless required by applicable law or agreed to in writing, software
12-
+distributed under the License is distributed on an "AS IS" BASIS,
13-
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14-
+See the License for the specific language governing permissions and
15-
+limitations under the License.
16-
+ */
17-
18-
package io.appium.java_client;
19-
20-
import org.openqa.selenium.By;
21-
import org.openqa.selenium.Dimension;
22-
import org.openqa.selenium.Point;
23-
import org.openqa.selenium.WebElement;
24-
import org.openqa.selenium.remote.FileDetector;
25-
import org.openqa.selenium.remote.RemoteWebElement;
26-
27-
import java.util.List;
28-
29-
public abstract class MobileElement extends RemoteWebElement implements FindsByAccessibilityId, TouchableElement {
30-
31-
protected FileDetector fileDetector;
32-
33-
public List<WebElement> findElements(By by) {
34-
return by.findElements(this);
35-
}
36-
37-
public WebElement findElement(By by) {
38-
return by.findElement(this);
39-
}
40-
41-
public WebElement findElementByAccessibilityId(String using) {
42-
return findElement("accessibility id", using);
43-
}
44-
45-
public List<WebElement> findElementsByAccessibilityId(String using) {
46-
return findElements("accessibility id", using);
47-
}
48-
49-
public Point getCenter() {
50-
Point upperLeft = this.getLocation();
51-
Dimension dimensions = this.getSize();
52-
return new Point(upperLeft.getX() + dimensions.getWidth() / 2, upperLeft.getY() + dimensions.getHeight() / 2);
53-
}
54-
55-
@Override
56-
public void pinch() {
57-
((AppiumDriver) parent).pinch(this);
58-
}
59-
60-
@Override
61-
public void tap(int fingers, int duration) {
62-
((AppiumDriver) parent).tap(fingers, this, duration);
63-
}
64-
65-
@Override
66-
public void zoom() {
67-
((AppiumDriver) parent).zoom(this);
68-
}
69-
70-
71-
@Override
72-
public void swipe(SwipeElementDirection direction, int duration) {
73-
direction.swipe((AppiumDriver) parent, this, 0, 0, duration);
74-
}
75-
76-
@Override
77-
public void swipe(SwipeElementDirection direction, int offset1,
78-
int offset2, int duration) throws IllegalCoordinatesException {
79-
direction.swipe((AppiumDriver) parent, this, offset1, offset2, duration);
80-
}
81-
}
1+
/*
2+
+Copyright 2014 Appium contributors
3+
+Copyright 2014 Software Freedom Conservancy
4+
+
5+
+Licensed under the Apache License, Version 2.0 (the "License");
6+
+you may not use this file except in compliance with the License.
7+
+You may obtain a copy of the License at
8+
+
9+
+ http://www.apache.org/licenses/LICENSE-2.0
10+
+
11+
+Unless required by applicable law or agreed to in writing, software
12+
+distributed under the License is distributed on an "AS IS" BASIS,
13+
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
+See the License for the specific language governing permissions and
15+
+limitations under the License.
16+
+ */
17+
18+
package io.appium.java_client;
19+
20+
import org.openqa.selenium.By;
21+
import org.openqa.selenium.Dimension;
22+
import org.openqa.selenium.Point;
23+
import org.openqa.selenium.WebElement;
24+
import org.openqa.selenium.remote.FileDetector;
25+
import org.openqa.selenium.remote.RemoteWebElement;
26+
27+
import java.util.List;
28+
29+
public abstract class MobileElement extends RemoteWebElement implements FindsByAccessibilityId, TouchableElement {
30+
31+
protected FileDetector fileDetector;
32+
33+
public List<WebElement> findElements(By by) {
34+
return by.findElements(this);
35+
}
36+
37+
public WebElement findElement(By by) {
38+
return by.findElement(this);
39+
}
40+
41+
public WebElement findElementByAccessibilityId(String using) {
42+
return findElement("accessibility id", using);
43+
}
44+
45+
public List<WebElement> findElementsByAccessibilityId(String using) {
46+
return findElements("accessibility id", using);
47+
}
48+
49+
public Point getCenter() {
50+
Point upperLeft = this.getLocation();
51+
Dimension dimensions = this.getSize();
52+
return new Point(upperLeft.getX() + dimensions.getWidth() / 2, upperLeft.getY() + dimensions.getHeight() / 2);
53+
}
54+
55+
@Override
56+
public void pinch() {
57+
((AppiumDriver) parent).pinch(this);
58+
}
59+
60+
@Override
61+
public void tap(int fingers, int duration) {
62+
((AppiumDriver) parent).tap(fingers, this, duration);
63+
}
64+
65+
@Override
66+
public void zoom() {
67+
((AppiumDriver) parent).zoom(this);
68+
}
69+
70+
71+
@Override
72+
public void swipe(SwipeElementDirection direction, int duration) {
73+
direction.swipe((AppiumDriver) parent, this, 0, 0, duration);
74+
}
75+
76+
@Override
77+
public void swipe(SwipeElementDirection direction, int offsetFromStartBorder,
78+
int offsetFromEndBorder, int duration) throws IllegalCoordinatesException {
79+
direction.swipe((AppiumDriver) parent, this, offsetFromStartBorder,
80+
offsetFromEndBorder, duration);
81+
}
82+
}
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,79 @@
1-
package io.appium.java_client;
2-
3-
import org.openqa.selenium.WebElement;
4-
5-
/**
6-
* It supposed that mobile elements could be tappable, swipeable, zoomable and so on.
7-
* This interface extends {@link WebElement} and describes this behavior.
8-
*/
9-
public interface TouchableElement extends WebElement {
10-
11-
/**
12-
* Convenience method for pinching the given element.
13-
* "pinching" refers to the action of two appendages pressing the screen and sliding towards each other.
14-
* NOTE:
15-
* This convenience method places the initial touches around the element, if this would happen to place one of them
16-
* off the screen, appium with return an outOfBounds error. In this case, revert to using the MultiTouchAction api
17-
* instead of this method.
18-
*
19-
*/
20-
public void pinch();
21-
22-
/**
23-
* Convenience method for tapping the center of the given element
24-
*
25-
* @param fingers
26-
* number of fingers/appendages to tap with
27-
* @param duration
28-
* how long between pressing down, and lifting fingers/appendages
29-
*/
30-
public void tap(int fingers, int duration);
31-
32-
/**
33-
* Convenience method for "zooming in" on the given element.
34-
* "zooming in" refers to the action of two appendages pressing the screen and sliding away from each other.
35-
* NOTE:
36-
* This convenience method slides touches away from the element, if this would happen to place one of them
37-
* off the screen, appium will return an outOfBounds error. In this case, revert to using the MultiTouchAction api
38-
* instead of this method.
39-
*/
40-
public void zoom();
41-
42-
/**
43-
* Convenience method for swiping on the given element to the given direction
44-
*
45-
* @param direction UP, DOWN, LEFT, RIGHT
46-
*
47-
* @param duration amount of time in milliseconds for the entire swipe action to
48-
* take
49-
*/
50-
public void swipe(SwipeElementDirection direction, int duration);
51-
52-
53-
/**
54-
* Convenience method for swiping on the given element to the given direction
55-
*
56-
* @param direction direction UP, DOWN, LEFT, RIGHT
57-
*
58-
* @param offset1 is the offset from the border of the element. If direction is UP then
59-
* this is offset from the bottom of the element. If direction is DOWN then
60-
* this is offset from the top of the element. If direction is RIGHT then
61-
* this is offset from the left border of the element. If direction is LEFT then
62-
* this is offset from the right border of the element.
63-
*
64-
* @param offset2 is the offset from the border of the element. If direction is UP then
65-
* this is offset from the top of the element. If direction is DOWN then
66-
* this is offset from the bottom of the element. If direction is RIGHT then
67-
* this is offset from the right border of the element. If direction is LEFT then
68-
* this is offset from the left border of the element.
69-
*
70-
* @param duration amount of time in milliseconds for the entire swipe action to
71-
* take
72-
* @throws IllegalCoordinatesException when resulted coordinates are out of the element borders
73-
* or disagree with the given direction
74-
*/
75-
public void swipe(SwipeElementDirection direction, int offset1, int offset2, int duration) throws IllegalCoordinatesException;
76-
}
1+
package io.appium.java_client;
2+
3+
import org.openqa.selenium.WebElement;
4+
5+
/**
6+
* It supposed that mobile elements could be tappable, swipeable, zoomable and so on.
7+
* This interface extends {@link WebElement} and describes this behavior.
8+
*/
9+
public interface TouchableElement extends WebElement {
10+
11+
/**
12+
* Convenience method for pinching the given element.
13+
* "pinching" refers to the action of two appendages pressing the screen and sliding towards each other.
14+
* NOTE:
15+
* This convenience method places the initial touches around the element, if this would happen to place one of them
16+
* off the screen, appium with return an outOfBounds error. In this case, revert to using the MultiTouchAction api
17+
* instead of this method.
18+
*
19+
*/
20+
public void pinch();
21+
22+
/**
23+
* Convenience method for tapping the center of the given element
24+
*
25+
* @param fingers
26+
* number of fingers/appendages to tap with
27+
* @param duration
28+
* how long between pressing down, and lifting fingers/appendages
29+
*/
30+
public void tap(int fingers, int duration);
31+
32+
/**
33+
* Convenience method for "zooming in" on the given element.
34+
* "zooming in" refers to the action of two appendages pressing the screen and sliding away from each other.
35+
* NOTE:
36+
* This convenience method slides touches away from the element, if this would happen to place one of them
37+
* off the screen, appium will return an outOfBounds error. In this case, revert to using the MultiTouchAction api
38+
* instead of this method.
39+
*/
40+
public void zoom();
41+
42+
/**
43+
* Convenience method for swiping on the given element to the given direction
44+
*
45+
* @param direction UP, DOWN, LEFT, RIGHT
46+
*
47+
* @param duration amount of time in milliseconds for the entire swipe action to
48+
* take
49+
*/
50+
public void swipe(SwipeElementDirection direction, int duration);
51+
52+
53+
/**
54+
* Convenience method for swiping on the given element to the given direction
55+
*
56+
* @param direction direction UP, DOWN, LEFT, RIGHT
57+
*
58+
* @param offsetFromEndBorder is the offset from the border of the element where the swiping should be started.
59+
* If direction is UP then
60+
* this is offset from the bottom of the element. If direction is DOWN then
61+
* this is offset from the top of the element. If direction is RIGHT then
62+
* this is offset from the left border of the element. If direction is LEFT then
63+
* this is offset from the right border of the element.
64+
*
65+
* @param offsetFromEndBorder is the offset from the border of the element where the swiping should be finished.
66+
* If direction is UP then
67+
* this is offset from the top of the element. If direction is DOWN then
68+
* this is offset from the bottom of the element. If direction is RIGHT then
69+
* this is offset from the right border of the element. If direction is LEFT then
70+
* this is offset from the left border of the element.
71+
*
72+
* @param duration amount of time in milliseconds for the entire swipe action to
73+
* take
74+
* @throws IllegalCoordinatesException when resulted coordinates are out of the element borders
75+
* or disagree with the given direction
76+
*/
77+
public void swipe(SwipeElementDirection direction, int offsetFromStartBorder,
78+
int offsetFromEndBorder, int duration) throws IllegalCoordinatesException;
79+
}

0 commit comments

Comments
 (0)