-
Notifications
You must be signed in to change notification settings - Fork 241
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add app and browser switch tests to demo app
- Loading branch information
Showing
8 changed files
with
406 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
Demo/src/androidTest/java/com/braintreepayments/demo/test/CustomTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package com.braintreepayments.demo.test; | ||
|
||
import android.support.test.runner.AndroidJUnit4; | ||
import android.test.suitebuilder.annotation.LargeTest; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static com.braintreepayments.demo.test.utilities.TestHelper.clearPreferences; | ||
import static com.braintreepayments.demo.test.utilities.TestHelper.ensureEnvironmentIsSandbox; | ||
import static com.braintreepayments.demo.test.utilities.TestHelper.launchDemoApp; | ||
import static com.lukekorth.deviceautomator.AutomatorAction.click; | ||
import static com.lukekorth.deviceautomator.AutomatorAction.setText; | ||
import static com.lukekorth.deviceautomator.AutomatorAssertion.text; | ||
import static com.lukekorth.deviceautomator.DeviceAutomator.onDevice; | ||
import static com.lukekorth.deviceautomator.UiObjectMatcher.withText; | ||
import static com.lukekorth.deviceautomator.UiObjectMatcher.withTextStartingWith; | ||
import static org.hamcrest.CoreMatchers.containsString; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
@LargeTest | ||
public class CustomTest { | ||
|
||
@Before | ||
public void setup() { | ||
clearPreferences(); | ||
launchDemoApp(); | ||
ensureEnvironmentIsSandbox(); | ||
onDevice(withText("Custom")).waitForEnabled().perform(click()); | ||
} | ||
|
||
@Test(timeout = 60000) | ||
public void tokenizesACard() { | ||
onDevice(withText("Card Number")).perform(setText("4111111111111111")); | ||
onDevice(withText("Expiration")).perform(setText("1220")); | ||
onDevice(withText("Purchase")).perform(click()); | ||
onDevice(withTextStartingWith("Card Last Two:")).check(text(containsString("11"))); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
Demo/src/androidTest/java/com/braintreepayments/demo/test/DropInTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package com.braintreepayments.demo.test; | ||
|
||
import android.support.test.runner.AndroidJUnit4; | ||
import android.test.suitebuilder.annotation.LargeTest; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static com.braintreepayments.demo.test.utilities.TestHelper.clearPreferences; | ||
import static com.braintreepayments.demo.test.utilities.TestHelper.ensureEnvironmentIsSandbox; | ||
import static com.braintreepayments.demo.test.utilities.TestHelper.launchDemoApp; | ||
import static com.lukekorth.deviceautomator.AutomatorAction.click; | ||
import static com.lukekorth.deviceautomator.AutomatorAction.setText; | ||
import static com.lukekorth.deviceautomator.AutomatorAssertion.text; | ||
import static com.lukekorth.deviceautomator.DeviceAutomator.onDevice; | ||
import static com.lukekorth.deviceautomator.UiObjectMatcher.withText; | ||
import static com.lukekorth.deviceautomator.UiObjectMatcher.withTextContaining; | ||
import static com.lukekorth.deviceautomator.UiObjectMatcher.withTextStartingWith; | ||
import static org.hamcrest.CoreMatchers.containsString; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
@LargeTest | ||
public class DropInTest { | ||
|
||
@Before | ||
public void setup() { | ||
clearPreferences(); | ||
launchDemoApp(); | ||
ensureEnvironmentIsSandbox(); | ||
onDevice(withText("Drop-In")).waitForEnabled().perform(click()); | ||
} | ||
|
||
@Test(timeout = 60000) | ||
public void tokenizesACard() { | ||
onDevice(withText("Card Number")).perform(setText("4111111111111111")); | ||
onDevice(withText("Expiration")).perform(setText("1220")); | ||
onDevice(withTextContaining("BUY")).perform(click()); | ||
onDevice(withTextStartingWith("Card Last Two:")).check(text(containsString("11"))); | ||
} | ||
} |
129 changes: 129 additions & 0 deletions
129
Demo/src/androidTest/java/com/braintreepayments/demo/test/PayPalTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
package com.braintreepayments.demo.test; | ||
|
||
import android.os.SystemClock; | ||
import android.support.test.filters.SdkSuppress; | ||
import android.support.test.runner.AndroidJUnit4; | ||
import android.test.suitebuilder.annotation.LargeTest; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static com.braintreepayments.demo.test.utilities.TestHelper.clearPreferences; | ||
import static com.braintreepayments.demo.test.utilities.TestHelper.ensureEnvironmentIsSandbox; | ||
import static com.braintreepayments.demo.test.utilities.TestHelper.installPayPalWallet; | ||
import static com.braintreepayments.demo.test.utilities.TestHelper.isAppInstalled; | ||
import static com.braintreepayments.demo.test.utilities.TestHelper.launchDemoApp; | ||
import static com.braintreepayments.demo.test.utilities.TestHelper.uninstallPayPalWallet; | ||
import static com.lukekorth.deviceautomator.AutomatorAction.click; | ||
import static com.lukekorth.deviceautomator.AutomatorAction.setText; | ||
import static com.lukekorth.deviceautomator.AutomatorAssertion.text; | ||
import static com.lukekorth.deviceautomator.DeviceAutomator.onDevice; | ||
import static com.lukekorth.deviceautomator.UiObjectMatcher.withContentDescription; | ||
import static com.lukekorth.deviceautomator.UiObjectMatcher.withText; | ||
import static com.lukekorth.deviceautomator.UiObjectMatcher.withTextContaining; | ||
import static org.hamcrest.Matchers.containsString; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
@LargeTest | ||
public class PayPalTest { | ||
|
||
@Before | ||
public void setup() { | ||
clearPreferences(); | ||
launchDemoApp(); | ||
ensureEnvironmentIsSandbox(); | ||
onDevice(withText("PayPal")).waitForEnabled().perform(click()); | ||
} | ||
|
||
@SdkSuppress(minSdkVersion = 21) | ||
@Test(timeout = 60000) | ||
public void browserSwitch_makesASinglePayment() { | ||
uninstallPayPalWallet(); | ||
|
||
onDevice(withText("Single Payment")).waitForEnabled().perform(click()); | ||
onDevice(withContentDescription("Proceed with Sandbox Purchase")).perform(click()); | ||
|
||
onDevice(withTextContaining("Email:")).check(text(containsString("[email protected]"))); | ||
} | ||
|
||
@SdkSuppress(minSdkVersion = 21) | ||
@Test(timeout = 60000) | ||
public void browserSwitch_makesAFuturePayment() { | ||
uninstallPayPalWallet(); | ||
|
||
onDevice(withText("Future Payment")).waitForEnabled().perform(click()); | ||
onDevice(withContentDescription("Email")).perform(click(), setText("[email protected]")); | ||
onDevice().pressDPadDown().typeText("password"); | ||
onDevice(withContentDescription("Log In")).perform(click()); | ||
onDevice(withContentDescription("Agree")).perform(click()); | ||
|
||
onDevice(withTextContaining("Email:")).check(text(containsString("[email protected]"))); | ||
} | ||
|
||
@SdkSuppress(minSdkVersion = 21) | ||
@Test(timeout = 60000) | ||
public void browserSwitch_makesAFuturePaymentWithAddressScope() { | ||
uninstallPayPalWallet(); | ||
|
||
onDevice(withText("Future Payment (Address Scope)")).waitForEnabled().perform(click()); | ||
onDevice(withContentDescription("Email")).perform(click(), setText("[email protected]")); | ||
onDevice().pressDPadDown().typeText("password"); | ||
onDevice(withContentDescription("Log In")).perform(click()); | ||
onDevice(withContentDescription("Agree")).perform(click()); | ||
|
||
onDevice(withTextContaining("Email:")).check(text(containsString("[email protected]"))); | ||
SystemClock.sleep(10000); | ||
} | ||
|
||
@SdkSuppress(minSdkVersion = 21) | ||
@Test(timeout = 60000) | ||
public void browserSwitch_makesABillingAgreement() { | ||
uninstallPayPalWallet(); | ||
|
||
onDevice(withText("Billing Agreement")).waitForEnabled().perform(click()); | ||
onDevice(withContentDescription("Proceed with Sandbox Purchase")).perform(click()); | ||
|
||
onDevice(withTextContaining("Email:")).check(text(containsString("[email protected]"))); | ||
} | ||
|
||
@Test(timeout = 120000) | ||
public void appSwitch_forSinglePayment() { | ||
installPayPalWallet(); | ||
|
||
onDevice(withText("Single Payment")).waitForEnabled().perform(click()); | ||
|
||
onDevice().checkForegroundAppIs("com.paypal.android.p2pmobile"); | ||
} | ||
|
||
@Test(timeout = 120000) | ||
public void appSwitch_forFuturePayment() { | ||
installPayPalWallet(); | ||
|
||
onDevice(withText("Future Payment")).waitForEnabled().perform(click()); | ||
|
||
onDevice().checkForegroundAppIs("com.paypal.android.p2pmobile"); | ||
} | ||
|
||
@Test(timeout = 120000) | ||
public void appSwitch_forFuturePaymentWithAddressScope() { | ||
installPayPalWallet(); | ||
|
||
onDevice(withText("Future Payment (Address Scope)")).waitForEnabled().perform(click()); | ||
|
||
onDevice().checkForegroundAppIs("com.paypal.android.p2pmobile"); | ||
} | ||
|
||
@Test(timeout = 120000) | ||
public void appSwitch_usesBrowserForBillingAgreement() { | ||
installPayPalWallet(); | ||
|
||
onDevice(withText("Billing Agreement")).waitForEnabled().perform(click()); | ||
|
||
if (isAppInstalled("com.android.chrome")) { | ||
onDevice().checkForegroundAppIs("com.android.chrome"); | ||
} else { | ||
onDevice().checkForegroundAppIs("com.android.browser"); | ||
} | ||
} | ||
} |
51 changes: 51 additions & 0 deletions
51
Demo/src/androidTest/java/com/braintreepayments/demo/test/PaymentButtonTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
package com.braintreepayments.demo.test; | ||
|
||
import android.os.SystemClock; | ||
import android.support.test.filters.SdkSuppress; | ||
import android.support.test.runner.AndroidJUnit4; | ||
import android.test.suitebuilder.annotation.LargeTest; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
|
||
import static com.braintreepayments.demo.test.utilities.TestHelper.clearPreferences; | ||
import static com.braintreepayments.demo.test.utilities.TestHelper.ensureEnvironmentIsSandbox; | ||
import static com.braintreepayments.demo.test.utilities.TestHelper.launchDemoApp; | ||
import static com.braintreepayments.demo.test.utilities.TestHelper.uninstallPayPalWallet; | ||
import static com.lukekorth.deviceautomator.AutomatorAction.click; | ||
import static com.lukekorth.deviceautomator.AutomatorAction.setText; | ||
import static com.lukekorth.deviceautomator.AutomatorAssertion.text; | ||
import static com.lukekorth.deviceautomator.DeviceAutomator.onDevice; | ||
import static com.lukekorth.deviceautomator.UiObjectMatcher.withContentDescription; | ||
import static com.lukekorth.deviceautomator.UiObjectMatcher.withText; | ||
import static com.lukekorth.deviceautomator.UiObjectMatcher.withTextContaining; | ||
import static org.hamcrest.CoreMatchers.containsString; | ||
|
||
@RunWith(AndroidJUnit4.class) | ||
@LargeTest | ||
public class PaymentButtonTest { | ||
|
||
@Before | ||
public void setup() { | ||
clearPreferences(); | ||
launchDemoApp(); | ||
ensureEnvironmentIsSandbox(); | ||
onDevice(withText("Payment Button")).waitForEnabled().perform(click()); | ||
} | ||
|
||
@SdkSuppress(minSdkVersion = 21) | ||
@Test(timeout = 60000) | ||
public void tokenizesPayPal() { | ||
uninstallPayPalWallet(); | ||
|
||
SystemClock.sleep(5000); | ||
onDevice(withContentDescription("Pay with PayPal")).waitForEnabled().perform(click()); | ||
onDevice(withContentDescription("Email")).perform(click(), setText("[email protected]")); | ||
onDevice().pressDPadDown().typeText("password"); | ||
onDevice(withContentDescription("Log In")).perform(click()); | ||
onDevice(withContentDescription("Agree")).perform(click()); | ||
|
||
onDevice(withTextContaining("Email:")).check(text(containsString("[email protected]"))); | ||
} | ||
} |
Oops, something went wrong.