Skip to content

Commit 0017758

Browse files
Addition to the #579
The chaining of the activity parameter setting.
1 parent e9a7024 commit 0017758

File tree

4 files changed

+46
-34
lines changed

4 files changed

+46
-34
lines changed

src/main/java/io/appium/java_client/android/Activity.java

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,11 @@ public String getAppWaitPackage() {
6464
* Sets the app wait package value.
6565
*
6666
* @param appWaitPackage The app wait package value.
67+
* @return self reference
6768
*/
68-
public void setAppWaitPackage(String appWaitPackage) {
69+
public Activity setAppWaitPackage(String appWaitPackage) {
6970
this.appWaitPackage = appWaitPackage;
71+
return this;
7072
}
7173

7274
/**
@@ -82,9 +84,11 @@ public String getAppWaitActivity() {
8284
* Sets the app wait activity value.
8385
*
8486
* @param appWaitActivity The app wait activity value.
87+
* @return self reference
8588
*/
86-
public void setAppWaitActivity(String appWaitActivity) {
89+
public Activity setAppWaitActivity(String appWaitActivity) {
8790
this.appWaitActivity = appWaitActivity;
91+
return this;
8892
}
8993

9094
/**
@@ -100,9 +104,11 @@ public String getIntentAction() {
100104
* Sets the intent action value.
101105
*
102106
* @param intentAction The intent action value.
107+
* @return self reference
103108
*/
104-
public void setIntentAction(String intentAction) {
109+
public Activity setIntentAction(String intentAction) {
105110
this.intentAction = intentAction;
111+
return this;
106112
}
107113

108114
/**
@@ -118,9 +124,11 @@ public String getIntentCategory() {
118124
* Sets the intent category value.
119125
*
120126
* @param intentCategory The intent category value.
127+
* @return self reference
121128
*/
122-
public void setIntentCategory(String intentCategory) {
129+
public Activity setIntentCategory(String intentCategory) {
123130
this.intentCategory = intentCategory;
131+
return this;
124132
}
125133

126134
/**
@@ -136,9 +144,11 @@ public String getIntentFlags() {
136144
* Sets the intent flags value.
137145
*
138146
* @param intentFlags The intent flags value.
147+
* @return self reference
139148
*/
140-
public void setIntentFlags(String intentFlags) {
149+
public Activity setIntentFlags(String intentFlags) {
141150
this.intentFlags = intentFlags;
151+
return this;
142152
}
143153

144154
/**
@@ -154,9 +164,11 @@ public String getOptionalIntentArguments() {
154164
* Sets the optional intent arguments value.
155165
*
156166
* @param optionalIntentArguments The optional intent arguments value.
167+
* @return self reference
157168
*/
158-
public void setOptionalIntentArguments(String optionalIntentArguments) {
169+
public Activity setOptionalIntentArguments(String optionalIntentArguments) {
159170
this.optionalIntentArguments = optionalIntentArguments;
171+
return this;
160172
}
161173

162174
/**
@@ -172,9 +184,11 @@ public boolean isStopApp() {
172184
* Sets the stop app value.
173185
*
174186
* @param stopApp The stop app value.
187+
* @return self reference
175188
*/
176-
public void setStopApp(boolean stopApp) {
189+
public Activity setStopApp(boolean stopApp) {
177190
this.stopApp = stopApp;
191+
return this;
178192
}
179193

180194
@Override public String toString() {

src/main/java/io/appium/java_client/android/HasSupportedPerformanceDataType.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88

99
import java.util.List;
1010

11-
/**
12-
*
13-
*/
1411
public interface HasSupportedPerformanceDataType extends ExecutesMethod {
1512

1613
/**

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ public class AndroidActivityTest extends BaseAndroidTest {
3838

3939
@Test public void startActivityWithWaitingAppTestCase() {
4040
final Activity activity = new Activity("io.appium.android.apis",
41-
".accessibility.AccessibilityNodeProviderActivity");
42-
activity.setAppWaitPackage("io.appium.android.apis");
43-
activity.setAppWaitActivity(".accessibility.AccessibilityNodeProviderActivity");
41+
".accessibility.AccessibilityNodeProviderActivity")
42+
.setAppWaitPackage("io.appium.android.apis")
43+
.setAppWaitActivity(".accessibility.AccessibilityNodeProviderActivity");
4444
driver.startActivity(activity);
4545
assertEquals(driver.currentActivity(),
4646
".accessibility.AccessibilityNodeProviderActivity");
@@ -60,10 +60,10 @@ public class AndroidActivityTest extends BaseAndroidTest {
6060
driver.startActivity(activity);
6161
assertEquals(driver.currentActivity(), ".accessibility.AccessibilityNodeProviderActivity");
6262

63-
Activity newActivity = new Activity("com.android.contacts", ".ContactsListActivity");
64-
newActivity.setAppWaitPackage("com.android.contacts");
65-
newActivity.setAppWaitActivity(".ContactsListActivity");
66-
newActivity.setStopApp(false);
63+
Activity newActivity = new Activity("com.android.contacts", ".ContactsListActivity")
64+
.setAppWaitPackage("com.android.contacts")
65+
.setAppWaitActivity(".ContactsListActivity")
66+
.setStopApp(false);
6767
driver.startActivity(newActivity);
6868
assertEquals(driver.currentActivity(), ".ContactsListActivity");
6969
driver.pressKeyCode(AndroidKeyCode.BACK);

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

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package io.appium.java_client.android;
22

33
import static org.junit.Assert.assertEquals;
4+
import static org.junit.Assert.assertTrue;
45

56
import io.appium.java_client.remote.MobileCapabilityType;
67
import io.appium.java_client.service.local.AppiumDriverLocalService;
@@ -10,6 +11,7 @@
1011
import org.openqa.selenium.remote.DesiredCapabilities;
1112

1213
import java.io.File;
14+
import java.util.function.Predicate;
1315

1416
public class IntentTest {
1517
private static AppiumDriverLocalService service;
@@ -47,26 +49,25 @@ public class IntentTest {
4749
}
4850

4951

50-
@Test public void startActivityWithIntent() {
51-
final Activity activity = new Activity("com.android.mms", ".ui.ComposeMessageActivity");
52-
activity.setIntentAction("android.intent.action.SEND");
53-
activity.setIntentCategory("android.intent.category.DEFAULT");
54-
activity.setIntentFlags("0x4000000");
55-
activity.setOptionalIntentArguments("-d \"TestIntent\" -t \"text/plain\"");
56-
driver.startActivity(activity);
57-
try {
58-
Thread.sleep(5000);
59-
} catch (InterruptedException e) {
60-
e.printStackTrace();
61-
}
52+
@Test public void startActivityWithIntent() throws Exception {
53+
assertTrue(((Predicate<AndroidDriver>) driver -> {
54+
final Activity activity = new Activity("com.android.mms", ".ui.ComposeMessageActivity");
55+
activity.setIntentAction("android.intent.action.SEND");
56+
activity.setIntentCategory("android.intent.category.DEFAULT");
57+
activity.setIntentFlags("0x4000000");
58+
activity.setOptionalIntentArguments("-d \"TestIntent\" -t \"text/plain\"");
59+
driver.startActivity(activity);
60+
return true;
61+
}).test(driver));
62+
6263
}
6364

6465
@Test public void startActivityWithDefaultIntentAndDefaultCategoryWithOptionalArgs() {
65-
final Activity activity = new Activity("com.prgguru.android", ".GreetingActivity");
66-
activity.setIntentAction("android.intent.action.MAIN");
67-
activity.setIntentCategory("android.intent.category.DEFAULT");
68-
activity.setIntentFlags("0x4000000");
69-
activity.setOptionalIntentArguments("--es \"USERNAME\" \"AppiumIntentTest\" -t \"text/plain\"");
66+
final Activity activity = new Activity("com.prgguru.android", ".GreetingActivity")
67+
.setIntentAction("android.intent.action.MAIN")
68+
.setIntentCategory("android.intent.category.DEFAULT")
69+
.setIntentFlags("0x4000000")
70+
.setOptionalIntentArguments("--es \"USERNAME\" \"AppiumIntentTest\" -t \"text/plain\"");
7071
driver.startActivity(activity);
7172
assertEquals(driver.findElementById("com.prgguru.android:id/textView1").getText(),
7273
"Welcome AppiumIntentTest");

0 commit comments

Comments
 (0)