Skip to content
Snippets Groups Projects

Medialibrary stub

Closed Duncan McNamara requested to merge Skantes/vlc-android:tests-rebase into master
3 unresolved threads

Description

This is a work in progress for the medialibrary stub.

VLC-Android can run with the stub, even though there are some things to fix still

Motivation and Context

The goal is the be able to run automated tests on a device / emulated environment that does not have medias.

For that the medialibrary needed to be abstracted to be, at request, replaced by a media datasource with fake medias, and not break the app.

How Has This Been Tested?

This has been tested by running vlc-android with the stub.

Again, this is not completely stable yet. I wanted to publish it, so that it could begin being reviewed, and so that @shivanshs9 could start working with it.

How does it work ?

This abstracts the medialibrary, and all media classes that relied on the native medialibrary.

To choose at run time which implementation to use, there is a ServiceLocator that calls the appropriate implementations' constructor.

Hence instead of calling Folder(...) now you should use ServiceLocator.getAFolder(...) which will return the correct instance.

To set the service locator to return the stub instead of the native medialibrary classes, use:

ServiceLocator.setLocatorMode(ServiceLocator.LocatorMode.TESTS)

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Enhancement (non-breaking change which cleans up / improves existing functionality)
  • Breaking change (fix or feature that would cause existing functionality to change) -> Should not break anything

Still to be done

  • Rename ServiceLocator to MLlocator
  • Add fake medias
  • Fix vlc-android were it will crash without actual media
  • Rename all Aclasses to AbstractClasses
Edited by Geoffrey Métais

Merge request reports

Merge request pipeline #7804 failed

Merge request pipeline failed for 58ff3e09

Approval is optional

Closed by Geoffrey MétaisGeoffrey Métais 5 years ago (Jun 28, 2019 7:26am UTC)

Merge details

  • The changes were not merged into master.

Activity

Filter activity
  • Approvals
  • Assignees & reviewers
  • Comments (from bots)
  • Comments (from users)
  • Commits & branches
  • Edits
  • Labels
  • Lock status
  • Mentions
  • Merge request status
  • Tracking
262 269
263 270 // Test
271 testImplementation project(":medialibrary")
264 272 androidTestImplementation "androidx.test.espresso:espresso-contrib:$rootProject.espressoVersion"
265 273 androidTestImplementation "androidx.test.espresso:espresso-core:$rootProject.espressoVersion"
266 274 testImplementation "junit:junit:$rootProject.ext.junitVersion"
267 275 androidTestImplementation "androidx.room:room-testing:$rootProject.ext.roomVersion"
268 276 testImplementation "androidx.arch.core:core-testing:$rootProject.ext.archVersion"
269 277 androidTestImplementation "androidx.arch.core:core-testing:$rootProject.ext.archVersion"
270 androidTestImplementation "androidx.test:runner:$rootProject.ext.supportTest"
278 androidTestImplementation "androidx.test.ext:junit:$rootProject.ext.supportTest"
271 279 androidTestUtil "androidx.test:orchestrator:$rootProject.ext.supportTest"
272 280 testImplementation "org.mockito:mockito-core:$rootProject.ext.mockito"
273 281 testImplementation "org.powermock:powermock-api-mockito2:$rootProject.ext.powerMock"
274 282 testImplementation "org.powermock:powermock-module-junit4:$rootProject.ext.powerMock"
283 androidTestImplementation 'androidx.test:rules:1.2.0-alpha05'
  • Duncan McNamara added 3 commits

    added 3 commits

    • 985c40ff - Medialibrary: Add stub
    • 00b09d18 - Medialibrary: add ML to ServiceLocator name
    • b05e31f6 - Medialibrary: rename AClasses into AbstractClasses

    Compare with previous version

  • 87
    88 private native AbstractAlbum[] nativeGetAlbums(AbstractMedialibrary ml, long mId, int sort, boolean desc);
    89 private native AbstractArtist[] nativeGetArtists(AbstractMedialibrary ml, long mId, int sort, boolean desc);
    90 private native AbstractMediaWrapper[] nativeGetTracks(AbstractMedialibrary ml, long mId, int sort, boolean desc);
    91
    92 private native AbstractAlbum[] nativeGetPagedAlbums(AbstractMedialibrary ml, long mId, int sort, boolean desc, int nbItems, int offset);
    93 private native AbstractArtist[] nativeGetPagedArtists(AbstractMedialibrary ml, long mId, int sort, boolean desc, int nbItems, int offset);
    94 private native AbstractMediaWrapper[] nativeGetPagedTracks(AbstractMedialibrary ml, long mId, int sort, boolean desc, int nbItems, int offset);
    95 private native int nativeGetTracksCount(AbstractMedialibrary ml, long id);
    96 private native int nativeGetAlbumsCount(AbstractMedialibrary ml, long mId);
    97 private native int nativeGetArtistsCount(AbstractMedialibrary ml, long mId);
    98 private native AbstractAlbum[] nativeSearchAlbums(AbstractMedialibrary ml, long mId, String query, int sort, boolean desc, int nbItems, int offset);
    99 private native AbstractMediaWrapper[] nativeSearch(AbstractMedialibrary ml, long mId, String query, int sort, boolean desc, int nbItems, int offset);
    100 private native int nativeGetSearchCount(AbstractMedialibrary ml, long mId, String query);
    101 private native int nativeGetSearchAlbumCount(AbstractMedialibrary ml, long mId, String query);
    102
  • Duncan McNamara added 45 commits

    added 45 commits

    • b05e31f6...27f02f7e - 34 commits from branch videolan:master
    • 8ee5cd04 - Update JUnit
    • 31f61415 - Medialibrary: move MediaWrapper to AMediaWrapper
    • ead2e2f1 - Medialibrary: move Artist to AArtist
    • fa5fec85 - Medialibrary: move Genre to AGenre
    • d2519832 - Medialibrary: move Album to AAlbum
    • 418bbc70 - Medialibrary: move Folder to AFolder
    • a02ea8a5 - Medialibrary: move Playlist to APlaylist
    • f24fa2a5 - Medialibrary: move Medialibrary to AMedialibrary
    • 18f2fe8c - Medialibrary: Add stub
    • 6711a3e4 - Medialibrary: add ML to ServiceLocator name
    • 58ff3e09 - Medialibrary: rename AClasses into AbstractClasses

    Compare with previous version

  • Geoffrey Métais unmarked as a Work In Progress

    unmarked as a Work In Progress

  • Merged!

  • Please register or sign in to reply
    Loading