Advertisement
Guest User

Untitled

a guest
Dec 9th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. package com.cascer.newfootballapp.feature.search
  2.  
  3. import androidx.recyclerview.widget.RecyclerView
  4. import androidx.test.espresso.Espresso.onView
  5. import androidx.test.espresso.Espresso.pressBack
  6. import androidx.test.espresso.IdlingRegistry
  7. import androidx.test.espresso.action.ViewActions
  8. import androidx.test.espresso.assertion.ViewAssertions.matches
  9. import androidx.test.espresso.contrib.RecyclerViewActions
  10. import androidx.test.espresso.matcher.ViewMatchers
  11. import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
  12. import androidx.test.ext.junit.runners.AndroidJUnit4
  13. import androidx.test.rule.ActivityTestRule
  14. import com.cascer.newfootballapp.R
  15. import com.cascer.newfootballapp.feature.MainActivity
  16. import com.cascer.newfootballapp.utils.EspressoIdlingResource
  17. import org.junit.After
  18. import org.junit.Before
  19. import org.junit.Rule
  20. import org.junit.Test
  21. import org.junit.runner.RunWith
  22.  
  23. @RunWith(AndroidJUnit4::class)
  24. class SearchFragmentInstrumentTest {
  25.  
  26. @Rule
  27. @JvmField
  28. var activityRule = ActivityTestRule(MainActivity::class.java)
  29.  
  30. @Before
  31. fun setUp() {
  32. IdlingRegistry.getInstance().register(EspressoIdlingResource.idlingResource)
  33. }
  34.  
  35. @After
  36. fun tearDown() {
  37. IdlingRegistry.getInstance().unregister(EspressoIdlingResource.idlingResource)
  38. }
  39.  
  40. @Test
  41. fun search() {
  42. onView(ViewMatchers.withId(R.id.et_search_match)).check(matches(isDisplayed()))
  43. onView(ViewMatchers.withId(R.id.et_search_match))
  44. .perform(ViewActions.typeText("liverpool"))
  45. onView(ViewMatchers.withId(R.id.rv_match)).check(matches(isDisplayed()))
  46. onView(ViewMatchers.withId(R.id.rv_match)).perform(
  47. RecyclerViewActions.actionOnItemAtPosition<RecyclerView.ViewHolder>(
  48. 2,
  49. ViewActions.click()
  50. )
  51. )
  52. pressBack()
  53. }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement