[Android] Fix tests compilation

Nicolas Pomepuy git at videolan.org
Thu Sep 7 08:21:02 UTC 2023


vlc-android | branch: master | Nicolas Pomepuy <nicolas at videolabs.io> | Fri Jul 21 11:04:23 2023 +0200| [1442e0f5303d2219d8551950fe1a080e935c448d] | committer: Nicolas Pomepuy

Fix tests compilation

> https://code.videolan.org/videolan/vlc-android/commit/1442e0f5303d2219d8551950fe1a080e935c448d
---

 .../vlc/gui/HeaderMediaListActivityUITest.kt       | 23 ++++++++++----
 .../org/videolan/vlc/gui/PlaylistFragmentUITest.kt | 37 +++++++++++++++-------
 .../gui/preferences/PreferencesSubtitlesUITest.kt  | 15 ---------
 .../java/org/videolan/vlc/util/DpadHelper.kt       |  1 +
 4 files changed, 44 insertions(+), 32 deletions(-)

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 819fd21780..c748f00205 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
@@ -2,18 +2,29 @@ package org.videolan.vlc.gui
 
 import android.content.Intent
 import androidx.test.espresso.Espresso.onView
-import androidx.test.espresso.action.*
+import androidx.test.espresso.action.CoordinatesProvider
+import androidx.test.espresso.action.GeneralLocation
+import androidx.test.espresso.action.GeneralSwipeAction
+import androidx.test.espresso.action.Press
+import androidx.test.espresso.action.Swipe
 import androidx.test.espresso.assertion.ViewAssertions.matches
-import androidx.test.espresso.matcher.ViewMatchers.*
+import androidx.test.espresso.matcher.ViewMatchers.assertThat
+import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
+import androidx.test.espresso.matcher.ViewMatchers.withId
 import androidx.test.rule.ActivityTestRule
 import org.hamcrest.Matchers.equalTo
 import org.junit.Rule
 import org.junit.Test
 import org.videolan.medialibrary.interfaces.Medialibrary
-import org.videolan.vlc.*
+import org.videolan.vlc.BaseUITest
+import org.videolan.vlc.R
 import org.videolan.vlc.databinding.AudioBrowserItemBinding
+import org.videolan.vlc.findFirstPosition
 import org.videolan.vlc.gui.audio.AudioBrowserAdapter
 import org.videolan.vlc.gui.audio.AudioBrowserFragment
+import org.videolan.vlc.sizeOfAtLeast
+import org.videolan.vlc.withMediaItem
+import org.videolan.vlc.withRecyclerView
 
 class HeaderMediaListActivityUITest: BaseUITest() {
     @Rule
@@ -27,9 +38,9 @@ class HeaderMediaListActivityUITest: BaseUITest() {
         Thread.sleep(3 * 1000)
 
         val ml = Medialibrary.getInstance()
-        val pl = ml.createPlaylist("test", true)
-        pl.append(ml.getPagedVideos(Medialibrary.SORT_DEFAULT, false, true, 5, 0).map { it.id })
-        pl.append(ml.getPagedAudio(Medialibrary.SORT_DEFAULT, false, true, 5, 0).map { it.id })
+        val pl = ml.createPlaylist("test", true, false)
+        pl.append(ml.getPagedVideos(Medialibrary.SORT_DEFAULT, false, true, false, 5, 0).map { it.id })
+        pl.append(ml.getPagedAudio(Medialibrary.SORT_DEFAULT, false, true, false, 5, 0).map { it.id })
 
         val intent = Intent().apply {
             putExtra(AudioBrowserFragment.TAG_ITEM, pl)
diff --git a/application/app/src/androidTest/java/org/videolan/vlc/gui/PlaylistFragmentUITest.kt b/application/app/src/androidTest/java/org/videolan/vlc/gui/PlaylistFragmentUITest.kt
index ff568cd33e..07667f34f9 100644
--- a/application/app/src/androidTest/java/org/videolan/vlc/gui/PlaylistFragmentUITest.kt
+++ b/application/app/src/androidTest/java/org/videolan/vlc/gui/PlaylistFragmentUITest.kt
@@ -5,23 +5,38 @@ import android.widget.EditText
 import androidx.test.espresso.Espresso
 import androidx.test.espresso.Espresso.onView
 import androidx.test.espresso.Espresso.openActionBarOverflowOrOptionsMenu
-import androidx.test.espresso.action.ViewActions.*
+import androidx.test.espresso.action.ViewActions.click
+import androidx.test.espresso.action.ViewActions.longClick
+import androidx.test.espresso.action.ViewActions.typeTextIntoFocusedView
 import androidx.test.espresso.assertion.ViewAssertions.matches
-import androidx.test.espresso.contrib.DrawerActions.open
 import androidx.test.espresso.matcher.RootMatchers.isPlatformPopup
-import androidx.test.espresso.matcher.ViewMatchers.*
+import androidx.test.espresso.matcher.ViewMatchers.assertThat
+import androidx.test.espresso.matcher.ViewMatchers.hasDescendant
+import androidx.test.espresso.matcher.ViewMatchers.isDescendantOfA
+import androidx.test.espresso.matcher.ViewMatchers.isDisplayed
+import androidx.test.espresso.matcher.ViewMatchers.withId
+import androidx.test.espresso.matcher.ViewMatchers.withText
 import androidx.test.rule.ActivityTestRule
 import com.google.android.material.internal.NavigationMenuItemView
-import org.hamcrest.Matchers.*
+import org.hamcrest.Matchers.allOf
+import org.hamcrest.Matchers.anyOf
+import org.hamcrest.Matchers.equalTo
+import org.hamcrest.Matchers.instanceOf
+import org.hamcrest.Matchers.notNullValue
 import org.junit.After
 import org.junit.Rule
 import org.junit.Test
 import org.videolan.medialibrary.interfaces.Medialibrary
-import org.videolan.vlc.*
-import org.videolan.vlc.gui.dialogs.SavePlaylistDialog
-import org.videolan.tools.CoroutineContextProvider
+import org.videolan.medialibrary.interfaces.media.Playlist
 import org.videolan.resources.EXTRA_TARGET
+import org.videolan.tools.CoroutineContextProvider
+import org.videolan.vlc.BaseUITest
+import org.videolan.vlc.R
+import org.videolan.vlc.gui.dialogs.SavePlaylistDialog
+import org.videolan.vlc.sizeOfAtLeast
 import org.videolan.vlc.util.TestCoroutineContextProvider
+import org.videolan.vlc.withCount
+import org.videolan.vlc.withRecyclerView
 
 class PlaylistFragmentUITest: BaseUITest() {
     @Rule
@@ -43,14 +58,14 @@ class PlaylistFragmentUITest: BaseUITest() {
 
     @After
     fun resetData() {
-        Medialibrary.getInstance().playlists.map { it.delete() }
+        Medialibrary.getInstance().getPlaylists(Playlist.Type.All, false).map { it.delete() }
     }
 
     private fun createDummyPlaylist() {
         val ml = Medialibrary.getInstance()
-        val pl = ml.createPlaylist(DUMMY_PLAYLIST, true)
-        pl.append(ml.getPagedVideos(Medialibrary.SORT_DEFAULT, false, true, 5, 0).map { it.id })
-        pl.append(ml.getPagedAudio(Medialibrary.SORT_DEFAULT, false, true, 5, 0).map { it.id })
+        val pl = ml.createPlaylist(DUMMY_PLAYLIST, true, false)
+        pl.append(ml.getPagedVideos(Medialibrary.SORT_DEFAULT, false, true, false, 5, 0).map { it.id })
+        pl.append(ml.getPagedAudio(Medialibrary.SORT_DEFAULT, false, true, false, 5, 0).map { it.id })
     }
 
     @Test
diff --git a/application/app/src/androidTest/java/org/videolan/vlc/gui/preferences/PreferencesSubtitlesUITest.kt b/application/app/src/androidTest/java/org/videolan/vlc/gui/preferences/PreferencesSubtitlesUITest.kt
index 0b3f7811dc..ab44ebff7f 100644
--- a/application/app/src/androidTest/java/org/videolan/vlc/gui/preferences/PreferencesSubtitlesUITest.kt
+++ b/application/app/src/androidTest/java/org/videolan/vlc/gui/preferences/PreferencesSubtitlesUITest.kt
@@ -37,17 +37,6 @@ class PreferencesSubtitlesUITest: BasePreferenceUITest() {
         checkModeChanged(key, "10", "16", MAP_SUBTITLE_SIZE)
     }
 
-    @Test
-    fun checkSubtitleColorSetting() {
-        val key = "subtitles_color"
-
-        checkModeChanged(key, "65535", "16777215", MAP_SUBTITLE_COLOR)
-        checkModeChanged(key, "16776960", "16777215", MAP_SUBTITLE_COLOR)
-        checkModeChanged(key, "65280", "16777215", MAP_SUBTITLE_COLOR)
-        checkModeChanged(key, "16711935", "16777215", MAP_SUBTITLE_COLOR)
-        checkModeChanged(key, "12632256", "16777215", MAP_SUBTITLE_COLOR)
-        checkModeChanged(key, "16777215", "16777215", MAP_SUBTITLE_COLOR)
-    }
 
     @Test
     fun checkSubtitleBackgroundSetting() {
@@ -71,10 +60,6 @@ class PreferencesSubtitlesUITest: BasePreferenceUITest() {
 
     companion object {
         val MAP_SUBTITLE_SIZE = mapOf("19" to R.string.subtitles_size_small, "16" to R.string.subtitles_size_normal, "13" to R.string.subtitles_size_big, "10" to R.string.subtitles_size_huge)
-        val MAP_SUBTITLE_COLOR = mapOf(
-                "16777215" to R.string.subtitles_color_white, "12632256" to R.string.subtitles_color_gray, "16711935" to R.string.subtitles_color_pink,
-                "65535" to R.string.subtitles_color_blue, "16776960" to R.string.subtitles_color_yellow, "65280" to R.string.subtitles_color_green
-        )
         val MAP_SUBTITLE_ENCODING = mapOf(
                 "" to "Default (Windows-1252)", "UTF-8" to "Universal (UTF-8)"
         )
diff --git a/application/app/src/androidTest/java/org/videolan/vlc/util/DpadHelper.kt b/application/app/src/androidTest/java/org/videolan/vlc/util/DpadHelper.kt
index b17e8744f6..3db9867395 100644
--- a/application/app/src/androidTest/java/org/videolan/vlc/util/DpadHelper.kt
+++ b/application/app/src/androidTest/java/org/videolan/vlc/util/DpadHelper.kt
@@ -40,6 +40,7 @@ object DpadHelper {
                 Direction.LEFT -> device.pressDPadLeft()
                 Direction.UP -> device.pressDPadUp()
                 Direction.RIGHT -> device.pressDPadRight()
+                else -> {}
             }
             if (i < nbTimes - 1) SystemClock.sleep(300)
         }



More information about the Android mailing list