setContentView(R.layout.activity_payment_methods); mProgressBar = findViewById(R.id.payment_methods_progress_bar); mRecyclerView = findViewById(R.id.payment_methods_recycler); View addCardView = findViewById(R.id.payment_methods_add_payment_container); Toolbar toolbar = findViewById(R.id.payment_methods_toolbar); setSupportActionBar(toolbar); if (getSupportActionBar() != null) {
@Before public void setup() { MockitoAnnotations.initMocks(this); Intent intent = PaymentMethodsActivity.newIntent(ApplicationProvider.getApplicationContext()) .putExtra(EXTRA_PROXY_DELAY, true); mPaymentMethodsActivity = createActivity(intent); mPaymentMethodsActivity.setCustomerSessionProxy(mCustomerSessionProxy); mShadowActivity = Shadows.shadowOf(mPaymentMethodsActivity); mProgressBar = mPaymentMethodsActivity.findViewById(R.id.payment_methods_progress_bar); mRecyclerView = mPaymentMethodsActivity.findViewById(R.id.payment_methods_recycler); mAddCardView = mPaymentMethodsActivity.findViewById(R.id.payment_methods_add_payment_container); }
@Test public void onClickAddSourceView_whenStartedFromPaymentSession_launchesActivityWithLog() { Intent intent = PaymentMethodsActivity .newIntent(ApplicationProvider.getApplicationContext()) .putExtra(EXTRA_PROXY_DELAY, true) .putExtra(EXTRA_PAYMENT_SESSION_ACTIVE, true); mPaymentMethodsActivity = createActivity(intent); mPaymentMethodsActivity.setCustomerSessionProxy(mCustomerSessionProxy); mShadowActivity = Shadows.shadowOf(mPaymentMethodsActivity); mAddCardView = mPaymentMethodsActivity.findViewById(R.id.payment_methods_add_payment_container); Customer customer = Customer.fromString(CustomerSessionTest.FIRST_TEST_CUSTOMER_OBJECT); when(mCustomerSessionProxy.getCachedCustomer()).thenReturn(customer); mPaymentMethodsActivity.initializeCustomerSourceData(); mAddCardView.performClick(); ShadowActivity.IntentForResult intentForResult = mShadowActivity.getNextStartedActivityForResult(); assertNotNull(intentForResult); assertEquals(AddSourceActivity.class.getName(), intentForResult.intent.getComponent().getClassName()); assertTrue(intentForResult.intent.hasExtra(EXTRA_PAYMENT_SESSION_ACTIVE)); }