Search in sources :

Example 6 with BraintreeCancelListener

use of com.braintreepayments.api.interfaces.BraintreeCancelListener in project braintree_android by braintree.

the class BraintreeFragmentUnitTest method removeListener_noCancelReceived.

@Test
public void removeListener_noCancelReceived() throws InvalidArgumentException {
    BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
    BraintreeCancelListener listener = new BraintreeCancelListener() {

        @Override
        public void onCancel(int requestCode) {
            fail("Listener was called");
        }
    };
    fragment.addListener(listener);
    fragment.removeListener(listener);
    fragment.postCancelCallback(42);
}
Also used : BraintreeCancelListener(com.braintreepayments.api.interfaces.BraintreeCancelListener) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 7 with BraintreeCancelListener

use of com.braintreepayments.api.interfaces.BraintreeCancelListener in project braintree_android by braintree.

the class ThreeDSecureVerificationTest method performVerification_callsCancelListenerWhenUpIsPressed.

@Test(timeout = 30000)
public void performVerification_callsCancelListenerWhenUpIsPressed() throws InterruptedException {
    CardBuilder cardBuilder = new CardBuilder().cardNumber(THREE_D_SECURE_VERIFICATON).expirationDate("12/30");
    BraintreeFragment fragment = getFragment();
    fragment.addListener(new BraintreeCancelListener() {

        @Override
        public void onCancel(int requestCode) {
            assertEquals(BraintreeRequestCodes.THREE_D_SECURE, requestCode);
            mCountDownLatch.countDown();
        }
    });
    ThreeDSecure.performVerification(getFragment(), cardBuilder, TEST_AMOUNT);
    waitForView(withId(android.R.id.widget_frame));
    onView(withContentDescription("Navigate up")).perform(click());
    mCountDownLatch.await();
}
Also used : CardBuilder(com.braintreepayments.api.models.CardBuilder) BraintreeCancelListener(com.braintreepayments.api.interfaces.BraintreeCancelListener) Test(org.junit.Test)

Aggregations

BraintreeCancelListener (com.braintreepayments.api.interfaces.BraintreeCancelListener)7 Test (org.junit.Test)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)5 CardBuilder (com.braintreepayments.api.models.CardBuilder)2 InvalidArgumentException (com.braintreepayments.api.exceptions.InvalidArgumentException)1 AmericanExpressListener (com.braintreepayments.api.interfaces.AmericanExpressListener)1 BraintreeErrorListener (com.braintreepayments.api.interfaces.BraintreeErrorListener)1 BraintreePaymentResultListener (com.braintreepayments.api.interfaces.BraintreePaymentResultListener)1 ConfigurationListener (com.braintreepayments.api.interfaces.ConfigurationListener)1 PaymentMethodNonceCreatedListener (com.braintreepayments.api.interfaces.PaymentMethodNonceCreatedListener)1 PaymentMethodNoncesUpdatedListener (com.braintreepayments.api.interfaces.PaymentMethodNoncesUpdatedListener)1 UnionPayListener (com.braintreepayments.api.interfaces.UnionPayListener)1 AmericanExpressRewardsBalance (com.braintreepayments.api.models.AmericanExpressRewardsBalance)1 BraintreePaymentResult (com.braintreepayments.api.models.BraintreePaymentResult)1 Configuration (com.braintreepayments.api.models.Configuration)1 PaymentMethodNonce (com.braintreepayments.api.models.PaymentMethodNonce)1 UnionPayCapabilities (com.braintreepayments.api.models.UnionPayCapabilities)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 AtomicBoolean (java.util.concurrent.atomic.AtomicBoolean)1