Skip to content
Snippets Groups Projects
Commit 6bdb03c6 authored by Shivansh Saini's avatar Shivansh Saini Committed by Geoffrey Métais
Browse files

UI test: "Add to favorites"


Signed-off-by: default avatarShivansh Saini <shivanshs9@gmail.com>
parent 198d4b2a
No related branches found
No related tags found
1 merge request!214GSoC'19 | Unit & UI tests
......@@ -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) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment