@Test public void onShippingInfoProcessed_whenValidShippingInfoSubmitted_rendersCorrectly() { Intent intent = new Intent(RuntimeEnvironment.application, PaymentFlowActivity.class); PaymentSessionConfig paymentSessionConfig = new PaymentSessionConfig.Builder() .setPrepopulatedShippingInfo(getExampleShippingInfo()) .build(); intent.putExtra(PAYMENT_SESSION_CONFIG, paymentSessionConfig); PaymentSessionData paymentSessionData = new PaymentSessionData(); intent.putExtra(PAYMENT_SESSION_DATA_KEY, paymentSessionData); mActivityController = Robolectric.buildActivity(PaymentFlowActivity.class, intent) .create().start().resume().visible(); PaymentFlowActivity paymentFlowActivity = mActivityController.get(); paymentFlowActivity.onActionSave(); Intent onShippingInfoProcessedValid = new Intent(EVENT_SHIPPING_INFO_PROCESSED); onShippingInfoProcessedValid.putExtra(EXTRA_IS_SHIPPING_INFO_VALID, true); ArrayList<ShippingMethod> shippingMethods = new ArrayList<>(); shippingMethods.add(new ShippingMethod("label", "id", 0, "USD")); onShippingInfoProcessedValid.putExtra(EXTRA_VALID_SHIPPING_METHODS, shippingMethods); LocalBroadcastManager.getInstance(RuntimeEnvironment.application) .sendBroadcast(onShippingInfoProcessedValid); assertEquals(View.VISIBLE, paymentFlowActivity.mProgressBar.getVisibility()); Intent shippingInfoSaved = new Intent(EVENT_SHIPPING_INFO_SAVED); LocalBroadcastManager.getInstance(RuntimeEnvironment.application) .sendBroadcast(shippingInfoSaved); assertEquals(View.GONE, paymentFlowActivity.mProgressBar.getVisibility()); }
@Override protected void onActionSave() { if (mPaymentFlowPagerAdapter.getPageAt( mViewPager.getCurrentItem()).equals(PaymentFlowPagerEnum.SHIPPING_INFO)) { onShippingInfoSubmitted(); } else { onShippingMethodSave(); } }
PaymentFlowActivity extends StripeActivity { @Override protected void onActionSave() { if (mPaymentFlowPagerAdapter.getPageAt( mViewPager.getCurrentItem()).equals(PaymentFlowPagerEnum.SHIPPING_INFO)) { onShippingInfoSubmitted(); } else { onShippingMethodSave(); } } }
PaymentFlowActivity extends StripeActivity { @Override protected void onActionSave() { if (mPaymentFlowPagerAdapter.getPageAt( mViewPager.getCurrentItem()).equals(PaymentFlowPagerEnum.SHIPPING_INFO)) { onShippingInfoSubmitted(); } else { onShippingMethodSave(); } }  }
PaymentFlowActivity extends StripeActivity { @Override protected void onActionSave() { if (mPaymentFlowPagerAdapter.getPageAt( mViewPager.getCurrentItem()).equals(PaymentFlowPagerEnum.SHIPPING_INFO)) { onShippingInfoSubmitted(); } else { onShippingMethodSave(); } }  @Override void onBackPressed(); }
PaymentFlowActivity extends StripeActivity { @Override protected void onActionSave() { if (mPaymentFlowPagerAdapter.getPageAt( mViewPager.getCurrentItem()).equals(PaymentFlowPagerEnum.SHIPPING_INFO)) { onShippingInfoSubmitted(); } else { onShippingMethodSave(); } }  @Override void onBackPressed(); static final String EXTRA_DEFAULT_SHIPPING_METHOD; static final String EXTRA_IS_SHIPPING_INFO_VALID; static final String EXTRA_SHIPPING_INFO_DATA; static final String EXTRA_SHIPPING_INFO_ERROR; static final String EVENT_SHIPPING_INFO_PROCESSED; static final String EVENT_SHIPPING_INFO_SUBMITTED; static final String EXTRA_VALID_SHIPPING_METHODS; }