use of com.braintreepayments.api.interfaces.BraintreeCancelListener in project braintree_android by braintree.
the class BraintreeFragmentUnitTest method postCancelCallback_postsRequestCodeToListener.
@Test
public void postCancelCallback_postsRequestCodeToListener() throws InvalidArgumentException {
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
final AtomicBoolean wasCalled = new AtomicBoolean(false);
fragment.addListener(new BraintreeCancelListener() {
@Override
public void onCancel(int requestCode) {
assertEquals(42, requestCode);
wasCalled.set(true);
}
});
fragment.postCancelCallback(42);
assertTrue(wasCalled.get());
}
use of com.braintreepayments.api.interfaces.BraintreeCancelListener in project braintree_android by braintree.
the class BraintreeFragmentUnitTest method onActivityResult_postsCancelCallbackWhenResultCodeIsCanceled.
@Test
public void onActivityResult_postsCancelCallbackWhenResultCodeIsCanceled() throws InvalidArgumentException {
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
fragment.addListener(new BraintreeCancelListener() {
@Override
public void onCancel(int requestCode) {
assertEquals(42, requestCode);
mCalled.set(true);
}
});
fragment.onActivityResult(42, Activity.RESULT_CANCELED, null);
assertTrue(mCalled.get());
}
use of com.braintreepayments.api.interfaces.BraintreeCancelListener in project braintree_android by braintree.
the class BraintreeFragmentUnitTest method addAndRemoveListenersAddAndRemoveAllListeners.
@Test
public void addAndRemoveListenersAddAndRemoveAllListeners() throws InvalidArgumentException {
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
ConfigurationListener configurationListener = new ConfigurationListener() {
@Override
public void onConfigurationFetched(Configuration configuration) {
}
};
BraintreeErrorListener braintreeErrorListener = new BraintreeErrorListener() {
@Override
public void onError(Exception error) {
}
};
PaymentMethodNoncesUpdatedListener paymentMethodNoncesUpdatedListener = new PaymentMethodNoncesUpdatedListener() {
@Override
public void onPaymentMethodNoncesUpdated(List<PaymentMethodNonce> paymentMethodNonces) {
}
};
PaymentMethodNonceCreatedListener paymentMethodNonceCreatedListener = new PaymentMethodNonceCreatedListener() {
@Override
public void onPaymentMethodNonceCreated(PaymentMethodNonce paymentMethodNonce) {
}
};
BraintreeCancelListener braintreeCancelListener = new BraintreeCancelListener() {
@Override
public void onCancel(int requestCode) {
}
};
UnionPayListener unionPayListener = new UnionPayListener() {
@Override
public void onCapabilitiesFetched(UnionPayCapabilities capabilities) {
}
@Override
public void onSmsCodeSent(String enrollmentId, boolean smsCodeRequired) {
}
};
AmericanExpressListener americanExpressListener = new AmericanExpressListener() {
@Override
public void onRewardsBalanceFetched(AmericanExpressRewardsBalance rewardsBalance) {
}
};
BraintreePaymentResultListener braintreePaymentResultListener = new BraintreePaymentResultListener() {
@Override
public void onBraintreePaymentResult(BraintreePaymentResult result) {
}
};
fragment.addListener(configurationListener);
fragment.addListener(braintreeErrorListener);
fragment.addListener(paymentMethodNoncesUpdatedListener);
fragment.addListener(paymentMethodNonceCreatedListener);
fragment.addListener(braintreeCancelListener);
fragment.addListener(unionPayListener);
fragment.addListener(americanExpressListener);
fragment.addListener(braintreePaymentResultListener);
assertEquals(8, fragment.getListeners().size());
fragment.removeListener(configurationListener);
fragment.removeListener(braintreeErrorListener);
fragment.removeListener(paymentMethodNoncesUpdatedListener);
fragment.removeListener(paymentMethodNonceCreatedListener);
fragment.removeListener(braintreeCancelListener);
fragment.removeListener(unionPayListener);
fragment.removeListener(americanExpressListener);
fragment.removeListener(braintreePaymentResultListener);
assertEquals(0, fragment.getListeners().size());
}
use of com.braintreepayments.api.interfaces.BraintreeCancelListener in project braintree_android by braintree.
the class ThreeDSecureVerificationTest method performVerification_callsCancelListenerWhenBackIsPressed.
@Test(timeout = 30000)
public void performVerification_callsCancelListenerWhenBackIsPressed() 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(fragment, cardBuilder, TEST_AMOUNT);
waitForView(withId(android.R.id.widget_frame));
pressBack();
mCountDownLatch.await();
}
use of com.braintreepayments.api.interfaces.BraintreeCancelListener in project braintree_android by braintree.
the class BraintreeFragmentUnitTest method addListener_flushesCancelCallback.
@Test
public void addListener_flushesCancelCallback() throws InvalidArgumentException {
BraintreeFragment fragment = BraintreeFragment.newInstance(mActivity, TOKENIZATION_KEY);
fragment.postCancelCallback(42);
fragment.addListener(new BraintreeCancelListener() {
@Override
public void onCancel(int requestCode) {
assertEquals(42, requestCode);
mCalled.set(true);
}
});
assertTrue(mCalled.get());
}
Aggregations