Search in sources :

Example 1 with UnitTestListenerActivity

use of com.braintreepayments.api.test.UnitTestListenerActivity in project braintree_android by braintree.

the class BraintreeFragmentUnitTest method onResume_postsConfigurationToCallbackForNewActivity.

@Test
public void onResume_postsConfigurationToCallbackForNewActivity() throws InvalidArgumentException {
    Configuration configuration = new TestConfigurationBuilder().buildConfiguration();
    mockConfigurationManager(configuration);
    UnitTestListenerActivity activity = Robolectric.setupActivity(UnitTestListenerActivity.class);
    BraintreeFragment fragment = BraintreeFragment.newInstance(activity, TOKENIZATION_KEY);
    fragment.onAttach(null);
    fragment.onResume();
    assertEquals(2, activity.configurations.size());
    assertEquals(configuration, activity.configurations.get(0));
    assertEquals(configuration, activity.configurations.get(1));
}
Also used : Configuration(com.braintreepayments.api.models.Configuration) UnitTestListenerActivity(com.braintreepayments.api.test.UnitTestListenerActivity) TestConfigurationBuilder(com.braintreepayments.testutils.TestConfigurationBuilder) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Example 2 with UnitTestListenerActivity

use of com.braintreepayments.api.test.UnitTestListenerActivity in project braintree_android by braintree.

the class BraintreeFragmentUnitTest method onResume_doesNotPostConfigurationToCallbackForTheSameActivity.

@Test
public void onResume_doesNotPostConfigurationToCallbackForTheSameActivity() throws InvalidArgumentException {
    Configuration configuration = new TestConfigurationBuilder().buildConfiguration();
    mockConfigurationManager(configuration);
    UnitTestListenerActivity activity = Robolectric.setupActivity(UnitTestListenerActivity.class);
    BraintreeFragment fragment = BraintreeFragment.newInstance(activity, TOKENIZATION_KEY);
    fragment.onResume();
    assertEquals(1, activity.configurations.size());
    assertEquals(configuration, activity.configurations.get(0));
}
Also used : Configuration(com.braintreepayments.api.models.Configuration) UnitTestListenerActivity(com.braintreepayments.api.test.UnitTestListenerActivity) TestConfigurationBuilder(com.braintreepayments.testutils.TestConfigurationBuilder) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

Configuration (com.braintreepayments.api.models.Configuration)2 UnitTestListenerActivity (com.braintreepayments.api.test.UnitTestListenerActivity)2 TestConfigurationBuilder (com.braintreepayments.testutils.TestConfigurationBuilder)2 Test (org.junit.Test)2 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)2