FakeMusicMediaSourceController

object FakeMusicMediaSourceController

Controller to send commands to the FakeMusic media source.

The media source can be found in com.tomtom.ivi.appsuite.media.standalone.testingsupport.fakemusic.app.mediaservice. That module creates an APK which needs to be installed 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
@WorkerThread
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
@WorkerThread
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
@WorkerThread
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
@WorkerThread
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
@WorkerThread
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
@WorkerThread
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
@WorkerThread
fun reset(context: Context = testContext)

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

Link copied to clipboard
@WorkerThread
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.