Android Open Source - PrettyBundle Activities Test






From Project

Back to project page PrettyBundle.

License

The source code is released under:

Apache License

If you think the Android project PrettyBundle listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.tale.prettybundle.sample;
//from  www.  ja  v  a  2 s  .  co  m
import android.content.Intent;
import android.support.test.InstrumentationRegistry;
import android.widget.Button;
import android.widget.EditText;

import static org.assertj.core.api.Assertions.assertThat;

/**
 * Created by tale on 2/22/15.
 */
public class ActivitiesTest extends BaseActivityUnitTestCase<MainActivity> {

    private Intent launchIntent;

    public ActivitiesTest() {
        super(MainActivity.class);
    }

    @Override public void setUp() throws Exception {
        injectInstrumentation(InstrumentationRegistry.getInstrumentation());
        super.setUp();
        launchIntent = new Intent(getInstrumentation()
                .getTargetContext(), MainActivity.class);
    }

    @Override public void tearDown() throws Exception {
        super.tearDown();
        if (getActivity() != null) {
            getActivity().finish();
        }
    }

    public void testCreateTestStringExtra2Activity_withEnteredExtra() throws Exception {
        startActivity(launchIntent, null, null);

        EditText etExtra1 = (EditText) getActivity().findViewById(R.id.etExtra1);
        EditText etExtra2 = (EditText) getActivity().findViewById(R.id.etExtra2);

        final String extra1 = "extra1";
        final String extra2 = "extra2";

        etExtra1.setText(extra1);
        etExtra2.setText(extra2);

        ((Button) getActivity().findViewById(R.id.btSubmit)).performClick();

        final Intent startedActivityIntent = getStartedActivityIntent();

        final String stringExtra1 = startedActivityIntent.getStringExtra("stringExtra1");
        assertThat(stringExtra1).isEqualTo(extra1);

        final String stringExtra2 = startedActivityIntent.getStringExtra("stringExtra2");
        assertThat(stringExtra2).isEqualTo(extra2);
    }
}




Java Source Code List

com.tale.prettybundle.ExtraBinderProvider.java
com.tale.prettybundle.ExtraBinder.java
com.tale.prettybundle.Extra.java
com.tale.prettybundle.Injector.java
com.tale.prettybundle.PrettyBundle.java
com.tale.prettybundle.internal.ExtraAnnotatedClass.java
com.tale.prettybundle.internal.ExtraClassesGrouped.java
com.tale.prettybundle.internal.ExtraInjectorClassBuilder.java
com.tale.prettybundle.internal.ExtraUtilityClassBuilder.java
com.tale.prettybundle.internal.PrettyBundleProcessor.java
com.tale.prettybundle.internal.SupportedType.java
com.tale.prettybundle.sample.ActivitiesClassTest.java
com.tale.prettybundle.sample.ActivitiesTest.java
com.tale.prettybundle.sample.ApplicationTest.java
com.tale.prettybundle.sample.BaseActivityUnitTestCase.java
com.tale.prettybundle.sample.InjectArrayExtrasTest.java
com.tale.prettybundle.sample.InjectParcelableExtrasTest.java
com.tale.prettybundle.sample.InjectPrimaryTypeExtrasFragmentTest.java
com.tale.prettybundle.sample.InjectPrimaryTypeExtrasTest.java
com.tale.prettybundle.sample.InjectStringExtrasTest.java
com.tale.prettybundle.sample.MainActivity.java
com.tale.prettybundle.sample.MenuActivity.java
com.tale.prettybundle.sample.TestArrayExtrasActivity.java
com.tale.prettybundle.sample.TestExtraOnFragmentActivity.java
com.tale.prettybundle.sample.TestParcelableActivity.java
com.tale.prettybundle.sample.TestPrimaryTypeDisplayActivity.java
com.tale.prettybundle.sample.TestPrimaryTypeSetterActivity.java
com.tale.prettybundle.sample.TestStringExtra1Activity.java
com.tale.prettybundle.sample.TestStringExtra2Activity.java
com.tale.prettybundle.sample.data.Person.java
com.tale.prettybundle.sample.espresso.ExtViewActions.java
com.tale.prettybundle.sample.fragments.TestPrimaryExtraFragment.java
com.tale.prettybundle.sample.services.TestPrimaryTypeService.java