Skip to content

Commit 3ee2aca

Browse files
author
Mykola Mokhnach
committed
Improve builders code styling
1 parent 061379e commit 3ee2aca

File tree

2 files changed

+37
-18
lines changed

2 files changed

+37
-18
lines changed

src/main/java/io/appium/java_client/touch/OptionsWithRelativePositioning.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
import static com.google.common.base.Preconditions.checkNotNull;
2626

2727
public abstract class OptionsWithRelativePositioning<T extends OptionsWithRelativePositioning<T>>
28-
extends ActionOptions {
28+
extends ActionOptions<T> {
2929
private String elementId = null;
3030
private Point relativeOffset = null;
3131

src/test/java/io/appium/java_client/android/AndroidTouchTest.java

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ public void setUp() throws Exception {
3737
assertEquals("Drag text not empty", "", dragText.getText());
3838

3939
TouchAction dragNDrop = new TouchAction(driver)
40-
.longPress(new LongPressOptions().withElement(dragDot1))
41-
.moveTo(new MoveToOptions().withElement(dragDot3))
40+
.longPress(new LongPressOptions()
41+
.withElement(dragDot1))
42+
.moveTo(new MoveToOptions()
43+
.withElement(dragDot3))
4244
.release();
4345
dragNDrop.perform();
4446
assertNotEquals("Drag text empty", "", dragText.getText());
@@ -54,8 +56,12 @@ public void setUp() throws Exception {
5456
assertEquals("Drag text not empty", "", dragText.getText());
5557

5658
TouchAction dragNDrop = new TouchAction(driver)
57-
.longPress(new LongPressOptions().withElement(dragDot1).withDuration(Duration.ofSeconds(2)))
58-
.moveTo(new MoveToOptions().withElement(dragDot3)).release();
59+
.longPress(new LongPressOptions()
60+
.withElement(dragDot1)
61+
.withDuration(Duration.ofSeconds(2)))
62+
.moveTo(new MoveToOptions()
63+
.withElement(dragDot3))
64+
.release();
5965
dragNDrop.perform();
6066
assertNotEquals("Drag text empty", "", dragText.getText());
6167
}
@@ -73,8 +79,10 @@ public void setUp() throws Exception {
7379
Point center2 = dragDot3.getCenter();
7480

7581
TouchAction dragNDrop = new TouchAction(driver)
76-
.longPress(new LongPressOptions().withAbsoluteOffset(center1.x, center1.y))
77-
.moveTo(new MoveToOptions().withRelativeOffset(center2.x, center2.y))
82+
.longPress(new LongPressOptions()
83+
.withAbsoluteOffset(center1.x, center1.y))
84+
.moveTo(new MoveToOptions()
85+
.withRelativeOffset(center2.x, center2.y))
7886
.release();
7987
dragNDrop.perform();
8088
assertNotEquals("Drag text empty", "", dragText.getText());
@@ -96,7 +104,8 @@ public void setUp() throws Exception {
96104
.longPress(new LongPressOptions()
97105
.withAbsoluteOffset(center1.x, center1.y)
98106
.withDuration(Duration.ofSeconds(2)))
99-
.moveTo(new MoveToOptions().withRelativeOffset(center2.x, center2.y))
107+
.moveTo(new MoveToOptions()
108+
.withRelativeOffset(center2.x, center2.y))
100109
.release();
101110
dragNDrop.perform();
102111
assertNotEquals("Drag text empty", "", dragText.getText());
@@ -108,8 +117,10 @@ public void setUp() throws Exception {
108117
Point point =
109118
driver.findElementById("io.appium.android.apis:id/button_toggle").getLocation();
110119
new TouchAction(driver)
111-
.press(new PressOptions().withAbsoluteOffset(point.x + 20, point.y + 30))
112-
.waitAction(new WaitOptions().withDuration(Duration.ofSeconds(1)))
120+
.press(new PressOptions()
121+
.withAbsoluteOffset(point.x + 20, point.y + 30))
122+
.waitAction(new WaitOptions()
123+
.withDuration(Duration.ofSeconds(1)))
113124
.release()
114125
.perform();
115126
assertEquals("ON" ,driver
@@ -122,7 +133,8 @@ public void setUp() throws Exception {
122133
new TouchAction(driver)
123134
.press(new PressOptions()
124135
.withElement(driver.findElementById("io.appium.android.apis:id/button_toggle")))
125-
.waitAction(new WaitOptions().withDuration(Duration.ofSeconds(1)))
136+
.waitAction(new WaitOptions()
137+
.withDuration(Duration.ofSeconds(1)))
126138
.release()
127139
.perform();
128140
assertEquals("ON" ,driver
@@ -136,9 +148,12 @@ public void setUp() throws Exception {
136148
driver.findElementById("io.appium.android.apis:id/chronometer");
137149

138150
TouchAction startStop = new TouchAction(driver)
139-
.tap(new TapOptions().withElement(driver.findElementById("io.appium.android.apis:id/start")))
140-
.waitAction(new WaitOptions().withDuration(Duration.ofSeconds(2)))
141-
.tap(new TapOptions().withElement(driver.findElementById("io.appium.android.apis:id/stop")));
151+
.tap(new TapOptions()
152+
.withElement(driver.findElementById("io.appium.android.apis:id/start")))
153+
.waitAction(new WaitOptions()
154+
.withDuration(Duration.ofSeconds(2)))
155+
.tap(new TapOptions()
156+
.withElement(driver.findElementById("io.appium.android.apis:id/stop")));
142157

143158
startStop.perform();
144159

@@ -157,7 +172,8 @@ public void setUp() throws Exception {
157172
Point center1 = driver.findElementById("io.appium.android.apis:id/start").getCenter();
158173

159174
TouchAction startStop = new TouchAction(driver)
160-
.tap(new TapOptions().withAbsoluteOffset(center1.x, center1.y))
175+
.tap(new TapOptions()
176+
.withAbsoluteOffset(center1.x, center1.y))
161177
.tap(new TapOptions()
162178
.withElement(driver.findElementById("io.appium.android.apis:id/stop"))
163179
.withRelativeOffset(5, 5));
@@ -181,9 +197,11 @@ public void setUp() throws Exception {
181197
Point center = gallery.getCenter();
182198

183199
TouchAction swipe = new TouchAction(driver)
184-
.press(new PressOptions().withElement(images.get(2))
200+
.press(new PressOptions()
201+
.withElement(images.get(2))
185202
.withRelativeOffset( -10, center.y - location.y))
186-
.waitAction(new WaitOptions().withDuration(Duration.ofSeconds(2)))
203+
.waitAction(new WaitOptions()
204+
.withDuration(Duration.ofSeconds(2)))
187205
.moveTo(new MoveToOptions()
188206
.withElement(gallery)
189207
.withRelativeOffset( 10, center.y - location.y))
@@ -201,7 +219,8 @@ public void setUp() throws Exception {
201219
.withElement(driver.findElementById("io.appium.android.apis:id/button_toggle")))
202220
.waitAction(new WaitOptions().withDuration(Duration.ofSeconds(1)))
203221
.release();
204-
new MultiTouchAction(driver).add(press)
222+
new MultiTouchAction(driver)
223+
.add(press)
205224
.perform();
206225
assertEquals("ON" ,driver
207226
.findElementById("io.appium.android.apis:id/button_toggle").getText());

0 commit comments

Comments
 (0)