Skip to content

Commit b9ef941

Browse files
Merge pull request #585 from TikhomirovSergey/master
Addition to the #579
2 parents 68b21a5 + 5e3e39d commit b9ef941

File tree

6 files changed

+54
-40
lines changed

6 files changed

+54
-40
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ This is the Java language binding for writing Appium Tests, conforms to [Mobile
2020
##Changelog##
2121
*5.0.0 (under construction yet)*
2222

23-
- [ENHANCEMENT] Android. API to read the performance data was added. [#562](https://github.com/appium/java-client/pull/562)
24-
- [REFACTOR]. Android. Simplified the activity starting by reducing the number of parameters through POJO clas. Old methods which start activities were marked `@Deprecated`. [#579](https://github.com/appium/java-client/pull/579)
25-
- [BUG FIX]. Issue report:[#574](https://github.com/appium/java-client/issues/574). Fix:[#582](https://github.com/appium/java-client/pull/582)
23+
- **[ENHANCEMENT]** Android. API to read the performance data was added. [#562](https://github.com/appium/java-client/pull/562)
24+
- **[REFACTOR]** Android. Simplified the activity starting by reducing the number of parameters through POJO clas. Old methods which start activities were marked `@Deprecated`. [#579](https://github.com/appium/java-client/pull/579)
25+
- **[BUG FIX]** Issue report:[#574](https://github.com/appium/java-client/issues/574). Fix:[#582](https://github.com/appium/java-client/pull/582)
2626

2727
*5.0.0-BETA3*
2828
[BUG FIX]

docs/The-starting-of-an-Android-app.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,9 @@ StartsActivity startsActivity = new StartsActivity() {
119119
}
120120
};
121121

122-
Activity activity = new Activity("app package goes here", "app activity goes here");
123-
activity.setWaitAppPackage("app wait package goes here");
124-
activity.setWaitAppActivity("app wait activity goes here");
122+
Activity activity = new Activity("app package goes here", "app activity goes here")
123+
.setWaitAppPackage("app wait package goes here");
124+
.setWaitAppActivity("app wait activity goes here");
125125
StartsActivity startsActivity.startActivity(activity);
126126
```
127127

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: 20 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,27 @@ 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+
Predicate<AndroidDriver> predicate = driver -> {
54+
Activity activity = new Activity("com.android.mms",
55+
".ui.ComposeMessageActivity")
56+
.setIntentAction("android.intent.action.SEND")
57+
.setIntentCategory("android.intent.category.DEFAULT")
58+
.setIntentFlags("0x4000000")
59+
.setOptionalIntentArguments("-d \"TestIntent\" -t \"text/plain\"");
60+
driver.startActivity(activity);
61+
return true;
62+
};
63+
assertTrue(predicate.test(driver));
64+
6265
}
6366

6467
@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\"");
68+
final Activity activity = new Activity("com.prgguru.android", ".GreetingActivity")
69+
.setIntentAction("android.intent.action.MAIN")
70+
.setIntentCategory("android.intent.category.DEFAULT")
71+
.setIntentFlags("0x4000000")
72+
.setOptionalIntentArguments("--es \"USERNAME\" \"AppiumIntentTest\" -t \"text/plain\"");
7073
driver.startActivity(activity);
7174
assertEquals(driver.findElementById("com.prgguru.android:id/textView1").getText(),
7275
"Welcome AppiumIntentTest");

0 commit comments

Comments
 (0)