[Android] Tests: update after module refactor

Duncan McNamara git at videolan.org
Wed Jan 29 16:22:07 CET 2020


vlc-android | branch: master | Duncan McNamara <dcn.mcnamara at gmail.com> | Tue Jan 28 11:16:55 2020 +0100| [7189921226863790d3e3a5406ac7bcd5f2148f5e] | committer: Geoffrey Métais

Tests: update after module refactor

This fixes test compilation after the refactor to split
the app into modules

> https://code.videolan.org/videolan/vlc-android/commit/7189921226863790d3e3a5406ac7bcd5f2148f5e
---

 .../org/videolan/moviepedia}/ConvertersTest.kt     |  2 +-
 .../org/videolan/vlc/database/MigrationTest.kt     |  4 +-
 .../vlc/gui/preferences/PreferencesUIUITest.kt     | 13 +-----
 application/vlc-android/build.gradle               |  5 +++
 .../viewmodels/mobile/AudioBrowserViewModelTest.kt |  4 +-
 buildsystem/compile.sh                             |  2 +-
 .../medialibrary/stubs/StubDataSource.java         | 49 +++++++++++++++++++++-
 7 files changed, 61 insertions(+), 18 deletions(-)

diff --git a/application/vlc-android/androidTest/org/videolan/vlc/database/ConvertersTest.kt b/application/moviepedia/src/androidTest/java/org/videolan/moviepedia/ConvertersTest.kt
similarity index 97%
rename from application/vlc-android/androidTest/org/videolan/vlc/database/ConvertersTest.kt
rename to application/moviepedia/src/androidTest/java/org/videolan/moviepedia/ConvertersTest.kt
index 74e66ae42..098911807 100644
--- a/application/vlc-android/androidTest/org/videolan/vlc/database/ConvertersTest.kt
+++ b/application/moviepedia/src/androidTest/java/org/videolan/moviepedia/ConvertersTest.kt
@@ -18,7 +18,7 @@
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
  ******************************************************************************/
 
-package org.videolan.vlc.database
+package org.videolan.moviepedia
 
 import android.net.Uri
 import androidx.test.ext.junit.runners.AndroidJUnit4
diff --git a/application/vlc-android/androidTest/org/videolan/vlc/database/MigrationTest.kt b/application/vlc-android/androidTest/org/videolan/vlc/database/MigrationTest.kt
index d09ba5879..11e7e7f08 100644
--- a/application/vlc-android/androidTest/org/videolan/vlc/database/MigrationTest.kt
+++ b/application/vlc-android/androidTest/org/videolan/vlc/database/MigrationTest.kt
@@ -35,7 +35,7 @@ import org.junit.Rule
 import org.junit.Test
 import org.junit.runner.RunWith
 import org.videolan.libvlc.interfaces.IMedia
-import org.videolan.mobile.app.VLCApplication
+import org.videolan.resources.AppContextProvider
 import org.videolan.vlc.database.helpers.*
 import org.videolan.tools.Settings
 import org.videolan.resources.TYPE_NETWORK_FAV
@@ -102,7 +102,7 @@ class MigrationTest {
 
     @Test fun migrateFrom27() {
         migrationTestHelper.createDatabase(TEST_DB_NAME, 27)
-        val preferences = Settings.getInstance(org.videolan.mobile.app.VLCApplication.appContext).edit()
+        val preferences = Settings.getInstance(AppContextProvider.appContext).edit()
         val fakeCustomDirectories = TestUtil.createCustomDirectories(2)
         // 27_28 migration rule moves the data from prefs to room
         val prefCustomDirectories = fakeCustomDirectories.map { it.path }.reduce{ acc, path -> "$acc:$path" }
diff --git a/application/vlc-android/androidTest/org/videolan/vlc/gui/preferences/PreferencesUIUITest.kt b/application/vlc-android/androidTest/org/videolan/vlc/gui/preferences/PreferencesUIUITest.kt
index d3ddb862b..58139e105 100644
--- a/application/vlc-android/androidTest/org/videolan/vlc/gui/preferences/PreferencesUIUITest.kt
+++ b/application/vlc-android/androidTest/org/videolan/vlc/gui/preferences/PreferencesUIUITest.kt
@@ -9,6 +9,7 @@ import org.hamcrest.Matchers.equalTo
 import org.junit.Rule
 import org.junit.Test
 import org.videolan.tools.*
+import org.videolan.vlc.BuildConfig
 import org.videolan.vlc.PreferenceMatchers.withKey
 import org.videolan.vlc.R
 import org.videolan.vlc.gui.helpers.UiTools
@@ -66,7 +67,7 @@ class PreferencesUIUITest: BasePreferenceUITest() {
 
     @Test
     fun checkLocaleSetting() {
-        val lp = UiTools.getLocalesUsedInProject(context)
+        val lp = LocaleUtils.getLocalesUsedInProject(context, BuildConfig.TRANSLATION_ARRAY, context.getString(R.string.device_default))
         val lpEntries = lp.localeEntries
         val lpValues = lp.localeEntryValues
 
@@ -112,16 +113,6 @@ class PreferencesUIUITest: BasePreferenceUITest() {
         checkToggleWorks(key, settings)
     }
 
-    @Test
-    fun checkVideoInListOrGridSetting_dueRestart() {
-        val key = FORCE_LIST_PORTRAIT
-
-        checkToggleWorks(key, settings)
-
-        intentsTestRule.finishActivity()
-        assertThat(intentsTestRule.activityResult.resultCode, equalTo(RESULT_RESTART))
-    }
-
     @Test
     fun checkShowVideoThumbnailSetting_dueRestart() {
         val key = SHOW_VIDEO_THUMBNAILS
diff --git a/application/vlc-android/build.gradle b/application/vlc-android/build.gradle
index 9703fd67b..0e5d3a97b 100644
--- a/application/vlc-android/build.gradle
+++ b/application/vlc-android/build.gradle
@@ -24,6 +24,10 @@ android {
         into 'assets/lua/meta'
         exclude '**/*.txt'
     }
+    
+    packagingOptions {
+        pickFirst '**/*.so'
+    }
 
     defaultConfig {
 
@@ -84,6 +88,7 @@ android {
         debug {
             buildConfigField "boolean", "BETA", "false"
             buildConfigField "String", "APP_ID", "\"${rootProject.ext.appId}.debug\""
+            multiDexEnabled true
         }
         signedRelease {
             initWith release
diff --git a/application/vlc-android/test/org/videolan/vlc/viewmodels/mobile/AudioBrowserViewModelTest.kt b/application/vlc-android/test/org/videolan/vlc/viewmodels/mobile/AudioBrowserViewModelTest.kt
index deef65b6f..fdfa193f4 100644
--- a/application/vlc-android/test/org/videolan/vlc/viewmodels/mobile/AudioBrowserViewModelTest.kt
+++ b/application/vlc-android/test/org/videolan/vlc/viewmodels/mobile/AudioBrowserViewModelTest.kt
@@ -8,9 +8,9 @@ import org.junit.Test
 import org.videolan.medialibrary.interfaces.media.MediaWrapper
 import org.videolan.medialibrary.stubs.StubDataSource
 import org.videolan.vlc.BaseTest
-import org.videolan.vlc.util.KEY_ARTISTS_SHOW_ALL
+import org.videolan.tools.KEY_ARTISTS_SHOW_ALL
 import org.videolan.resources.MEDIALIBRARY_PAGE_SIZE
-import org.videolan.vlc.util.Settings
+import org.videolan.tools.Settings
 
 @ExperimentalCoroutinesApi
 @ObsoleteCoroutinesApi
diff --git a/buildsystem/compile.sh b/buildsystem/compile.sh
index f96ce3c5a..90b6a7672 100755
--- a/buildsystem/compile.sh
+++ b/buildsystem/compile.sh
@@ -404,7 +404,7 @@ else
     GRADLE_VLC_SRC_DIRS="$GRADLE_VLC_SRC_DIRS" CLI="" GRADLE_ABI=$GRADLE_ABI ./gradlew $TARGET
 
     if [ "$TEST" = 1 ]; then
-        TARGET="vlc-android:install${BUILDTYPE}AndroidTest"
+        TARGET="application:vlc-android:install${BUILDTYPE}AndroidTest"
         GRADLE_VLC_SRC_DIRS="$GRADLE_VLC_SRC_DIRS" CLI="" GRADLE_ABI=$GRADLE_ABI ./gradlew $TARGET
 
         echo -e "\n===================================\nRun following for UI tests:"
diff --git a/medialibrary/src/org/videolan/medialibrary/stubs/StubDataSource.java b/medialibrary/src/org/videolan/medialibrary/stubs/StubDataSource.java
index c8f64ad93..f8273e573 100644
--- a/medialibrary/src/org/videolan/medialibrary/stubs/StubDataSource.java
+++ b/medialibrary/src/org/videolan/medialibrary/stubs/StubDataSource.java
@@ -4,6 +4,8 @@ import android.os.Environment;
 import android.text.TextUtils;
 import android.util.Log;
 
+import androidx.annotation.Nullable;
+
 import org.json.JSONArray;
 import org.json.JSONException;
 import org.json.JSONObject;
@@ -35,6 +37,12 @@ import static org.videolan.medialibrary.interfaces.Medialibrary.SORT_RELEASEDATE
 
 public class StubDataSource {
 
+    public static final String STUBBED_VIDEO_TITLE = "Invincible";
+    public static final String STUBBED_AUDIO_TITLE = "Show Me The Way";
+
+    public static final String STUBBED_VIDEO_EXTENSION = ".mp4";
+    public static final String STUBBED_AUDIO_EXTENSION = ".mp3";
+
     private String TAG = this.getClass().getName();
     ArrayList<MediaWrapper> mVideoMediaWrappers = new ArrayList<>();
     ArrayList<MediaWrapper> mAudioMediaWrappers = new ArrayList<>();
@@ -50,7 +58,7 @@ public class StubDataSource {
 
     private static String baseMrl = Environment.getExternalStorageDirectory().getAbsolutePath() + "/";
 
-    private static AtomicLong uuid = new AtomicLong(2);
+    public static AtomicLong uuid = new AtomicLong(2);
 
     private static StubDataSource mInstance = null;
 
@@ -79,6 +87,45 @@ public class StubDataSource {
         mDevices.clear();
     }
 
+    public void setVideoByCount(int count, @Nullable String folder) {
+        MediaWrapper media;
+        String fileName;
+
+        for (int i = 0; i < count; i++) {
+            fileName = i + " - " + STUBBED_VIDEO_TITLE + STUBBED_AUDIO_EXTENSION;
+            String mrl = baseMrl + ((folder != null) ? folder + "/" : "") + fileName;
+            media = MLServiceLocator.getAbstractMediaWrapper(getUUID().longValue(), mrl, 0L, 18820L, MediaWrapper.TYPE_VIDEO,
+                    fileName, fileName, "", "",
+                    "", "", 416, 304, "", 0, -2,
+                    0, 0, 1509466228L, 0L, true, 1970);
+            addVideo(media);
+        }
+    }
+
+    public void setAudioByCount(int count, @Nullable String folder) {
+        mAudioMediaWrappers.clear();
+        String fileName;
+        MediaWrapper media;
+
+        for (int i = 0; i < count; i++) {
+            fileName = i + " - " + STUBBED_AUDIO_TITLE + STUBBED_AUDIO_EXTENSION;
+            String mrl = baseMrl + ((folder != null) ? folder + "/" : "") + fileName;
+            media = MLServiceLocator.getAbstractMediaWrapper(getUUID().longValue(), mrl, 0L, 280244L, MediaWrapper.TYPE_AUDIO,
+                    i + "-Show Me The Way", fileName, "Peter Frampton", "Rock",
+                    "Shine On CD2", "Peter Frampton",
+                    0, 0, baseMrl + folder + ".jpg",
+                    0, -2, 1, 0,
+                    1547452796L, 0L, true, 1965);
+            addAudio(media, "", 1965, 400, mrl);
+        }
+    }
+
+    public Folder createFolder(String name) {
+        Folder folder = MLServiceLocator.getAbstractFolder(getUUID().longValue(), name, baseMrl + name);
+        mFolders.add(folder);
+        return folder;
+    }
+
     public void init() {
         Artist artist = MLServiceLocator.getAbstractArtist(1L, "", "", "", "");
         addArtistSecure(artist);



More information about the Android mailing list