FakeMusicMediaSourceController

Controller to send commands to the FakeMusic media source.

The media source can be found in module appsuite_media_standalone_testingsupport_fakemusic, under the package com.tomtom.ivi.appsuite.media.standalone.testingsupport.fakemusic. That module creates an APK which needs to be installed on a device before these commands can succeed.

All commands are sent synchronously. This ensures predictability of test flow, by not requiring the caller to wait for their completion.

Note: All the commands must be called using a background thread. This is due to an Android media framework limitation: even if media callbacks are received by this controller on the specified dispatcher, internally the media framework will only work on the main thread.

Functions

Link copied to clipboard
fun disableSearch(context: Context = testContext): Boolean

Disable search support in the FakeMusic media source. After this, the FakeMusic media source will not allow searching until the next reset.

Link copied to clipboard
fun followCollection(context: Context = testContext, collectionId: String): Boolean

Follow a collectionId. This means that the collection is added to a special library category FakeMusicMediaBrowserServiceInfo.LIBRARY_CATEGORY_ID and library item FakeMusicMediaBrowserServiceInfo.LIBRARY_ITEM_ID.

Link copied to clipboard
fun getLoginState(context: Context = testContext): Boolean

Retrieve whether log in is required to access the FakeMusic media source. If the command cannot be sent, this call throws a RuntimeException.

Link copied to clipboard
fun isLoggedIn(context: Context = testContext): Boolean

Retrieve whether the user is logged in to the FakeMusic media source. If the command cannot be sent, this call throws a RuntimeException.

Link copied to clipboard
fun login(context: Context = testContext): Boolean

Log in to the FakeMusic media source. After this, the contents of the FakeMusic media source will be accessible until logout is called. This call does nothing unless requireLogin is called.

Link copied to clipboard
fun logout(context: Context = testContext): Boolean

Log out from the session, and require a new login action. After this, the contents of the FakeMusic media source will be inaccessible until login is called. This call does nothing until both requireLogin and login are called.

Link copied to clipboard
fun requireLogin(context: Context = testContext)

Start requiring clients to log in to access the FakeMusic media source. If login was not previously called, after this request the contents of the FakeMusic media source will be inaccessible until login is called. This resets, kills, and restarts the FakeMusic media source service.

Link copied to clipboard
fun reset(context: Context = testContext)

Reset the source to the initial state, with no active media.

Link copied to clipboard
fun setCatalog(name: String, catalog: FakeMusicCatalogItem, context: Context = testContext): Boolean

Change the catalog offered by the FakeMusic media source to catalog. The catalog will be used until changed again, or until the next reset.

Link copied to clipboard
fun unfollowCollection(context: Context = testContext, collectionId: String): Boolean

Unfollow a collectionId. This means that the collection is removed from a special library category FakeMusicMediaBrowserServiceInfo.LIBRARY_CATEGORY_ID and library item FakeMusicMediaBrowserServiceInfo.LIBRARY_ITEM_ID.