This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class MessageActivity extends DaggerAppCompatActivity { | |
| @Inject | |
| MessageFragment mInjectedFragment; | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.activity_message); | |
| // Set up fragment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| android { | |
| ... | |
| } | |
| compileOptions { | |
| sourceCompatibility JavaVersion.VERSION_1_8 | |
| targetCompatibility JavaVersion.VERSION_1_8 | |
| } | |
| } | |
| dependencies { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Module(includes = ServletRequestAbstractModule.class) | |
| final class ServletRequestModule { | |
| private final HttpServletRequest httpRequest; | |
| @Provides | |
| HttpServletRequestModule(HttpServletRequest httpRequest) { | |
| this.httpRequest = httpRequest; | |
| } | |
| @Module |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Module | |
| public abstract class RegistrationModule { | |
| @ActivityScoped | |
| @Binds | |
| public abstract RegistrationPresenter provideRegPresenter (RegistrationPresenter presenter); | |
| @ActivityScoped | |
| @Provides | |
| static String provideActivityId(RegistrationActivity activity) { | |
| return activity.getIntent().getStringExtra(ID); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Module | |
| public abstract class RegistrationModule { | |
| @ActivityScoped | |
| @Binds | |
| public abstract RegistrationPresenter provideRegPresenter (RegistrationPresenter presenter); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Module | |
| public class RegistrationModule { | |
| @ActivityScoped | |
| @Provides | |
| public RegistrationPresenter provideRegPresenter(RegistrationPresenter presenter) { | |
| return presenter; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| public void contentTest() { | |
| // quick check if the ListView is visible | |
| onView(withId(R.id.list)).check(matches(isDisplayed())); | |
| // click on a certain child view from the loaded list | |
| onData(allOf()).inAdapterView(withId(R.id.list_news)).atPosition(i) | |
| .perform(click()); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| @Test | |
| public void customComponentTest() throws Exception { | |
| CountingIdlingResource componentIdlingResource = testedComponent.getIdlingResourceInTest(); | |
| Espresso.registerIdlingResources(componentIdlingResource); | |
| //perform checks for the specific component below | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Register your Idling Resource before any tests regarding this component | |
| @Before | |
| public void registerIdlingResource() { | |
| IdlingRegistry.getInstance().register(EspressoIdlingResource.getIdlingResource()); | |
| } | |
| // Unregister your Idling Resource so it can be garbage collected and does not leak any memory | |
| @After | |
| public void unregisterIdlingResource() { | |
| IdlingRegistry.getInstance().unregister(EspressoIdlingResource.getIdlingResource()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public void loadData() { | |
| // The network request might be handled in a different thread so make sure Espresso knows | |
| // that the app is busy until the response is handled. | |
| EspressoIdlingResource.increment(); // App is busy until further notice | |
| // let's get the data | |
| mRepository.getData(new LoadDataCallback() { | |
| @Override | |
| public void onDataLoaded(Data data) { | |
| // now that the data has been loaded, we can mark the app as idle |