Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Addition to the #579 #585

Merged
merged 3 commits into from
Feb 28, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 3 additions & 3 deletions docs/The-starting-of-an-Android-app.md
Original file line number Diff line number Diff line change
Expand Up @@ -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);
```

Expand Down
28 changes: 21 additions & 7 deletions src/main/java/io/appium/java_client/android/Activity.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand All @@ -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;
}

/**
Expand All @@ -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;
}

/**
Expand All @@ -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;
}

/**
Expand All @@ -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;
}

/**
Expand All @@ -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;
}

/**
Expand All @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@

import java.util.List;

/**
*
*/
public interface HasSupportedPerformanceDataType extends ExecutesMethod {

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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);
Expand Down
37 changes: 20 additions & 17 deletions src/test/java/io/appium/java_client/android/IntentTest.java
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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<AndroidDriver> 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");
Expand Down