Last active
May 17, 2020 22:06
-
-
Save cdmunoz/b94f616a5cbddc9b2c0753c56823da89 to your computer and use it in GitHub Desktop.
Calling EspressoIdlingResource increment and decrement to from prod code to let Espresso know while runnig UI tests when idling resources are available to continue its execution
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
| //HomeFragment logic and methods | |
| //Calls increment before the query to API | |
| private fun initViewModels() { | |
| if (null == photosViewModel) { | |
| //creates viewModel | |
| //..... | |
| EspressoIdlingResource.increment() | |
| photosViewModel?.loadData() | |
| } | |
| } | |
| private fun initObservers() { | |
| photosViewModel?.getPhotos()?.observe(viewLifecycleOwner, Observer { result -> | |
| when (result) { | |
| is Result.Success -> { | |
| renderList(result.data) | |
| EspressoIdlingResource.decrement() | |
| binding.homePhotosProgressContainer.visibility = View.GONE | |
| binding.homePhotosList.visibility = View.VISIBLE | |
| } | |
| is Result.InProgress -> { | |
| //InProgress logic | |
| } | |
| is Result.Error -> { | |
| //Error logic | |
| } | |
| } | |
| }) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment