[Android] Fix screenshot tests

Nicolas Pomepuy git at videolan.org
Mon Jul 25 08:51:52 UTC 2022


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Mon Jul 18 15:51:04 2022 +0200| [0c581d5a61ee66f74fe63822116d58c2a2230bd0] | committer: Duncan McNamara

Fix screenshot tests

> https://code.videolan.org/videolan/vlc-android/commit/0c581d5a61ee66f74fe63822116d58c2a2230bd0
---

 .../org/videolan/vlc/PhoneScreenhotsInstrumentedTest.kt     |  8 ++++----
 .../androidTest/java/org/videolan/vlc/UtilAdapterMatcher.kt |  2 +-
 .../org/videolan/vlc/gui/HeaderMediaListActivityUITest.kt   | 13 +++----------
 3 files changed, 8 insertions(+), 15 deletions(-)

diff --git a/application/app/src/androidTest/java/org/videolan/vlc/PhoneScreenhotsInstrumentedTest.kt b/application/app/src/androidTest/java/org/videolan/vlc/PhoneScreenhotsInstrumentedTest.kt
index 83a644155..3d9a417b4 100644
--- a/application/app/src/androidTest/java/org/videolan/vlc/PhoneScreenhotsInstrumentedTest.kt
+++ b/application/app/src/androidTest/java/org/videolan/vlc/PhoneScreenhotsInstrumentedTest.kt
@@ -30,11 +30,11 @@ import android.util.Log
 import androidx.test.espresso.Espresso.onView
 import androidx.test.espresso.Espresso.pressBack
 import androidx.test.espresso.action.ViewActions.click
-import androidx.test.espresso.matcher.ViewMatchers.isRoot
-import androidx.test.espresso.matcher.ViewMatchers.withId
+import androidx.test.espresso.matcher.ViewMatchers.*
 import androidx.test.platform.app.InstrumentationRegistry
 import androidx.test.rule.ActivityTestRule
 import androidx.test.uiautomator.UiDevice
+import org.hamcrest.core.AllOf
 import org.junit.ClassRule
 import org.junit.Rule
 import org.junit.Test
@@ -91,7 +91,7 @@ class PhoneScreenhotsInstrumentedTest : BaseUITest() {
 
     @Test
     fun testTakeScreenshotVideo() {
-        onView(withId(R.id.nav_video))
+        onView(AllOf.allOf(withId(R.id.nav_video), withEffectiveVisibility(Visibility.VISIBLE)))
                 .perform(click())
         Log.d("Espresso", "0")
         waitUntilLoaded { activity.findViewById(R.id.video_grid) }
@@ -128,7 +128,7 @@ class PhoneScreenhotsInstrumentedTest : BaseUITest() {
 
     @Test
     fun testTakeScreenshotBrowser() {
-         onView(withId(R.id.nav_directories))
+        onView(AllOf.allOf(withId(R.id.nav_directories), withEffectiveVisibility(Visibility.VISIBLE)))
                  .perform(click())
          ScreenshotUtil.takeScreenshot(4,"browser")
      }
diff --git a/application/app/src/androidTest/java/org/videolan/vlc/UtilAdapterMatcher.kt b/application/app/src/androidTest/java/org/videolan/vlc/UtilAdapterMatcher.kt
index 6a3e82ba3..cdba41a96 100644
--- a/application/app/src/androidTest/java/org/videolan/vlc/UtilAdapterMatcher.kt
+++ b/application/app/src/androidTest/java/org/videolan/vlc/UtilAdapterMatcher.kt
@@ -57,7 +57,7 @@ fun <D, VH : RecyclerView.ViewHolder> findFirstPosition(adapter: DiffUtilAdapter
     return -1
 }
 
-fun <D, VH : RecyclerView.ViewHolder> findFirstPosition(adapter: PagedListAdapter<D, VH>, vararg matchers: DiffAdapterMatcher<D>): Int  {
+fun <D : Any, VH : RecyclerView.ViewHolder> findFirstPosition(adapter: PagedListAdapter<D, VH>, vararg matchers: DiffAdapterMatcher<D>): Int  {
     val iter = adapter.currentList!!.iterator().withIndex()
     while (iter.hasNext()) {
         val index = iter.next()
diff --git a/application/app/src/androidTest/java/org/videolan/vlc/gui/HeaderMediaListActivityUITest.kt b/application/app/src/androidTest/java/org/videolan/vlc/gui/HeaderMediaListActivityUITest.kt
index ab1211a55..819fd2178 100644
--- a/application/app/src/androidTest/java/org/videolan/vlc/gui/HeaderMediaListActivityUITest.kt
+++ b/application/app/src/androidTest/java/org/videolan/vlc/gui/HeaderMediaListActivityUITest.kt
@@ -1,22 +1,15 @@
 package org.videolan.vlc.gui
 
 import android.content.Intent
-import androidx.test.espresso.Espresso.*
+import androidx.test.espresso.Espresso.onView
 import androidx.test.espresso.action.*
-import androidx.test.espresso.action.ViewActions.*
-import androidx.test.espresso.assertion.ViewAssertions.*
-import androidx.test.espresso.contrib.DrawerActions.*
-import androidx.test.espresso.matcher.RootMatchers.*
+import androidx.test.espresso.assertion.ViewAssertions.matches
 import androidx.test.espresso.matcher.ViewMatchers.*
 import androidx.test.rule.ActivityTestRule
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.ObsoleteCoroutinesApi
-import org.hamcrest.Matchers.*
+import org.hamcrest.Matchers.equalTo
 import org.junit.Rule
 import org.junit.Test
 import org.videolan.medialibrary.interfaces.Medialibrary
-import org.videolan.vlc.BaseUITest
-import org.videolan.vlc.R
 import org.videolan.vlc.*
 import org.videolan.vlc.databinding.AudioBrowserItemBinding
 import org.videolan.vlc.gui.audio.AudioBrowserAdapter



More information about the Android mailing list