Commit c2d6c12d authored by Shivansh Saini's avatar Shivansh Saini

UI test: "Add to favorites"

Signed-off-by: Shivansh Saini's avatarShivansh Saini <shivanshs9@gmail.com>
parent 2af48d13
......@@ -14,6 +14,7 @@ import org.hamcrest.TypeSafeMatcher
class RecyclerViewMatcher(@IdRes private val recyclerViewId: Int) {
var recyclerView: RecyclerView? = null
fun atPosition(position: Int): Matcher<View> {
return atPositionOnView(position, -1)
......@@ -29,9 +30,9 @@ class RecyclerViewMatcher(@IdRes private val recyclerViewId: Int) {
override fun matchesSafely(view: View): Boolean {
if (childView == null) {
val recyclerView = view.rootView.findViewById(recyclerViewId) as RecyclerView
if (recyclerView.id == recyclerViewId) {
childView = recyclerView.findViewHolderForAdapterPosition(position)?.itemView
recyclerView = view.rootView.findViewById(recyclerViewId) as RecyclerView
if (recyclerView!!.id == recyclerViewId) {
childView = recyclerView!!.findViewHolderForAdapterPosition(position)?.itemView
} else {
return false
}
......
......@@ -169,6 +169,26 @@ class FileBrowserFragmentUITest : BaseUITest() {
.check(matches(sizeOfAtLeast(2)))
}
@Test
fun whenAtRoot_addInternalStorageToFavoriteAndCheckListUpdated() {
val rvMatcher = withRecyclerView(R.id.network_list)
onView(rvMatcher.atPosition(1))
.check(matches(isDisplayed()))
val oldCount = rvMatcher.recyclerView?.adapter?.itemCount ?: 0
onView(rvMatcher.atPositionOnView(1, R.id.item_more))
.perform(click())
onView(withRecyclerView(R.id.ctx_list).atPosition(1))
.check(matches(hasDescendant(withText(R.string.favorites_add))))
.perform(click())
onView(withId(R.id.network_list))
.check(matches(sizeOfAtLeast(oldCount + 1)))
}
private fun sizeOfAtLeast(minSize: Int): Matcher<in View> {
return object : TypeSafeMatcher<View>() {
override fun describeTo(description: Description) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment