diff --git a/README.md b/README.md index 407022396..5d4feaac4 100644 --- a/README.md +++ b/README.md @@ -20,9 +20,9 @@ This is the Java language binding for writing Appium Tests, conforms to [Mobile ##Changelog## *5.0.0 (under construction yet)* -- [ENHANCEMENT] Android. API to read the performance data was added. [#562](https://github.com/appium/java-client/pull/562) -- [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) -- [BUG FIX]. Issue report:[#574](https://github.com/appium/java-client/issues/574). Fix:[#582](https://github.com/appium/java-client/pull/582) +- **[ENHANCEMENT]** Android. API to read the performance data was added. [#562](https://github.com/appium/java-client/pull/562) +- **[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) +- **[BUG FIX]** Issue report:[#574](https://github.com/appium/java-client/issues/574). Fix:[#582](https://github.com/appium/java-client/pull/582) *5.0.0-BETA3* [BUG FIX] diff --git a/docs/The-starting-of-an-Android-app.md b/docs/The-starting-of-an-Android-app.md index bca62fc55..944275f30 100644 --- a/docs/The-starting-of-an-Android-app.md +++ b/docs/The-starting-of-an-Android-app.md @@ -119,9 +119,9 @@ StartsActivity startsActivity = new StartsActivity() { } }; -Activity activity = new Activity("app package goes here", "app activity goes here"); -activity.setWaitAppPackage("app wait package goes here"); -activity.setWaitAppActivity("app wait activity goes here"); +Activity activity = new Activity("app package goes here", "app activity goes here") + .setWaitAppPackage("app wait package goes here"); + .setWaitAppActivity("app wait activity goes here"); StartsActivity startsActivity.startActivity(activity); ``` diff --git a/src/main/java/io/appium/java_client/android/Activity.java b/src/main/java/io/appium/java_client/android/Activity.java index ba7236424..790fad11b 100644 --- a/src/main/java/io/appium/java_client/android/Activity.java +++ b/src/main/java/io/appium/java_client/android/Activity.java @@ -64,9 +64,11 @@ public String getAppWaitPackage() { * Sets the app wait package value. * * @param appWaitPackage The app wait package value. + * @return self reference */ - public void setAppWaitPackage(String appWaitPackage) { + public Activity setAppWaitPackage(String appWaitPackage) { this.appWaitPackage = appWaitPackage; + return this; } /** @@ -82,9 +84,11 @@ public String getAppWaitActivity() { * Sets the app wait activity value. * * @param appWaitActivity The app wait activity value. + * @return self reference */ - public void setAppWaitActivity(String appWaitActivity) { + public Activity setAppWaitActivity(String appWaitActivity) { this.appWaitActivity = appWaitActivity; + return this; } /** @@ -100,9 +104,11 @@ public String getIntentAction() { * Sets the intent action value. * * @param intentAction The intent action value. + * @return self reference */ - public void setIntentAction(String intentAction) { + public Activity setIntentAction(String intentAction) { this.intentAction = intentAction; + return this; } /** @@ -118,9 +124,11 @@ public String getIntentCategory() { * Sets the intent category value. * * @param intentCategory The intent category value. + * @return self reference */ - public void setIntentCategory(String intentCategory) { + public Activity setIntentCategory(String intentCategory) { this.intentCategory = intentCategory; + return this; } /** @@ -136,9 +144,11 @@ public String getIntentFlags() { * Sets the intent flags value. * * @param intentFlags The intent flags value. + * @return self reference */ - public void setIntentFlags(String intentFlags) { + public Activity setIntentFlags(String intentFlags) { this.intentFlags = intentFlags; + return this; } /** @@ -154,9 +164,11 @@ public String getOptionalIntentArguments() { * Sets the optional intent arguments value. * * @param optionalIntentArguments The optional intent arguments value. + * @return self reference */ - public void setOptionalIntentArguments(String optionalIntentArguments) { + public Activity setOptionalIntentArguments(String optionalIntentArguments) { this.optionalIntentArguments = optionalIntentArguments; + return this; } /** @@ -172,9 +184,11 @@ public boolean isStopApp() { * Sets the stop app value. * * @param stopApp The stop app value. + * @return self reference */ - public void setStopApp(boolean stopApp) { + public Activity setStopApp(boolean stopApp) { this.stopApp = stopApp; + return this; } @Override public String toString() { diff --git a/src/main/java/io/appium/java_client/android/HasSupportedPerformanceDataType.java b/src/main/java/io/appium/java_client/android/HasSupportedPerformanceDataType.java index e9004daf9..e747acecc 100644 --- a/src/main/java/io/appium/java_client/android/HasSupportedPerformanceDataType.java +++ b/src/main/java/io/appium/java_client/android/HasSupportedPerformanceDataType.java @@ -8,9 +8,6 @@ import java.util.List; -/** - * - */ public interface HasSupportedPerformanceDataType extends ExecutesMethod { /** diff --git a/src/test/java/io/appium/java_client/android/AndroidActivityTest.java b/src/test/java/io/appium/java_client/android/AndroidActivityTest.java index 706b282f0..7d6693944 100644 --- a/src/test/java/io/appium/java_client/android/AndroidActivityTest.java +++ b/src/test/java/io/appium/java_client/android/AndroidActivityTest.java @@ -38,9 +38,9 @@ public class AndroidActivityTest extends BaseAndroidTest { @Test public void startActivityWithWaitingAppTestCase() { final Activity activity = new Activity("io.appium.android.apis", - ".accessibility.AccessibilityNodeProviderActivity"); - activity.setAppWaitPackage("io.appium.android.apis"); - activity.setAppWaitActivity(".accessibility.AccessibilityNodeProviderActivity"); + ".accessibility.AccessibilityNodeProviderActivity") + .setAppWaitPackage("io.appium.android.apis") + .setAppWaitActivity(".accessibility.AccessibilityNodeProviderActivity"); driver.startActivity(activity); assertEquals(driver.currentActivity(), ".accessibility.AccessibilityNodeProviderActivity"); @@ -60,10 +60,10 @@ public class AndroidActivityTest extends BaseAndroidTest { driver.startActivity(activity); assertEquals(driver.currentActivity(), ".accessibility.AccessibilityNodeProviderActivity"); - Activity newActivity = new Activity("com.android.contacts", ".ContactsListActivity"); - newActivity.setAppWaitPackage("com.android.contacts"); - newActivity.setAppWaitActivity(".ContactsListActivity"); - newActivity.setStopApp(false); + Activity newActivity = new Activity("com.android.contacts", ".ContactsListActivity") + .setAppWaitPackage("com.android.contacts") + .setAppWaitActivity(".ContactsListActivity") + .setStopApp(false); driver.startActivity(newActivity); assertEquals(driver.currentActivity(), ".ContactsListActivity"); driver.pressKeyCode(AndroidKeyCode.BACK); diff --git a/src/test/java/io/appium/java_client/android/IntentTest.java b/src/test/java/io/appium/java_client/android/IntentTest.java index cc1be0f16..b32e5db6b 100644 --- a/src/test/java/io/appium/java_client/android/IntentTest.java +++ b/src/test/java/io/appium/java_client/android/IntentTest.java @@ -1,6 +1,7 @@ package io.appium.java_client.android; import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; import io.appium.java_client.remote.MobileCapabilityType; import io.appium.java_client.service.local.AppiumDriverLocalService; @@ -10,6 +11,7 @@ import org.openqa.selenium.remote.DesiredCapabilities; import java.io.File; +import java.util.function.Predicate; public class IntentTest { private static AppiumDriverLocalService service; @@ -47,26 +49,27 @@ public class IntentTest { } - @Test public void startActivityWithIntent() { - final Activity activity = new Activity("com.android.mms", ".ui.ComposeMessageActivity"); - activity.setIntentAction("android.intent.action.SEND"); - activity.setIntentCategory("android.intent.category.DEFAULT"); - activity.setIntentFlags("0x4000000"); - activity.setOptionalIntentArguments("-d \"TestIntent\" -t \"text/plain\""); - driver.startActivity(activity); - try { - Thread.sleep(5000); - } catch (InterruptedException e) { - e.printStackTrace(); - } + @Test public void startActivityWithIntent() throws Exception { + Predicate predicate = driver -> { + Activity activity = new Activity("com.android.mms", + ".ui.ComposeMessageActivity") + .setIntentAction("android.intent.action.SEND") + .setIntentCategory("android.intent.category.DEFAULT") + .setIntentFlags("0x4000000") + .setOptionalIntentArguments("-d \"TestIntent\" -t \"text/plain\""); + driver.startActivity(activity); + return true; + }; + assertTrue(predicate.test(driver)); + } @Test public void startActivityWithDefaultIntentAndDefaultCategoryWithOptionalArgs() { - final Activity activity = new Activity("com.prgguru.android", ".GreetingActivity"); - activity.setIntentAction("android.intent.action.MAIN"); - activity.setIntentCategory("android.intent.category.DEFAULT"); - activity.setIntentFlags("0x4000000"); - activity.setOptionalIntentArguments("--es \"USERNAME\" \"AppiumIntentTest\" -t \"text/plain\""); + final Activity activity = new Activity("com.prgguru.android", ".GreetingActivity") + .setIntentAction("android.intent.action.MAIN") + .setIntentCategory("android.intent.category.DEFAULT") + .setIntentFlags("0x4000000") + .setOptionalIntentArguments("--es \"USERNAME\" \"AppiumIntentTest\" -t \"text/plain\""); driver.startActivity(activity); assertEquals(driver.findElementById("com.prgguru.android:id/textView1").getText(), "Welcome AppiumIntentTest");