[Android] UI test: "Add to favorites"
Shivansh Saini
git at videolan.org
Mon Dec 16 17:52:48 CET 2019
vlc-android | branch: master | Shivansh Saini <shivanshs9 at gmail.com> | Tue Jul 23 09:39:19 2019 +0530| [6bdb03c62eb5478074dfb4335eeadbcd9fbd5ce4] | committer: Geoffrey Métais
UI test: "Add to favorites"
Signed-off-by: Shivansh Saini <shivanshs9 at gmail.com>
> https://code.videolan.org/videolan/vlc-android/commit/6bdb03c62eb5478074dfb4335eeadbcd9fbd5ce4
---
.../androidTest/org/videolan/vlc/UtilViewMatchers.kt | 7 ++++---
.../vlc/gui/browser/FileBrowserFragmentUITest.kt | 20 ++++++++++++++++++++
2 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/vlc-android/androidTest/org/videolan/vlc/UtilViewMatchers.kt b/vlc-android/androidTest/org/videolan/vlc/UtilViewMatchers.kt
index 1cedb4c21..f3acf0b0a 100644
--- a/vlc-android/androidTest/org/videolan/vlc/UtilViewMatchers.kt
+++ b/vlc-android/androidTest/org/videolan/vlc/UtilViewMatchers.kt
@@ -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
}
diff --git a/vlc-android/androidTest/org/videolan/vlc/gui/browser/FileBrowserFragmentUITest.kt b/vlc-android/androidTest/org/videolan/vlc/gui/browser/FileBrowserFragmentUITest.kt
index 34bd1b4a2..d1cdd9108 100644
--- a/vlc-android/androidTest/org/videolan/vlc/gui/browser/FileBrowserFragmentUITest.kt
+++ b/vlc-android/androidTest/org/videolan/vlc/gui/browser/FileBrowserFragmentUITest.kt
@@ -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) {
More information about the Android
mailing list