IviServiceRule

class IviServiceRule(testLifecycleOwner: TestLifecycleOwner, initialIviServiceTestConfiguration: IviServiceTestConfiguration? = null) : ExternalResource

Rule to setup the initialIviServiceTestConfiguration before starting the test.

During the test execution the configuration can be changed by setting iviServiceTestConfiguration.

The IVI service configurations offered by this class are limited to the main process and thus limited to single process setups only or, when using services in other processes, limited to services that do not need any other non-mocked services. The alternative is to extend the TestApplication and set TestApplication.iviServiceTestConfiguration. A combination is also possible.

To use this rule, the TestApplication class or a class inheriting TestApplication must be used as Android Application class.

Constructors

Link copied to clipboard
fun IviServiceRule(testLifecycleOwner: TestLifecycleOwner, initialIviServiceTestConfiguration: IviServiceTestConfiguration? = null)

Properties

Link copied to clipboard

When set, all existing IVI services are stopped and unregistered. Next the new configuration is applied. The new services are registered (if any) and optionally the services are started.

Functions

Link copied to clipboard
fun <R> createApiWrapper(iviInstanceId: IviInstanceId = IviFunctionalTestCase.defaultIviInstanceId, callback: CreateApiCallback<R>): R

Wrapper around <Service>.createApi() calls.

Link copied to clipboard
fun getServiceIdsWrapper(iviInstanceId: IviInstanceId = IviFunctionalTestCase.defaultIviInstanceId, callback: GetServiceIdsCallback): List<IviServiceId>

Wrapper around <Service>.getServiceIds calls.

Link copied to clipboard
fun hasIviServiceMock(iviServiceMockIdentifier: IviServiceMockIdentifier<*>): Boolean

Returns true when an IVI service mock is available matching the iviServiceMockIdentifier.

fun hasIviServiceMock(iviServiceMockClass: KClass<out AnyIviServiceBase>): Boolean

Returns true when an IVI service mock is available for the iviServiceMockClass instance.

Link copied to clipboard
fun resetServices()

Resets the IVI service manager.

Link copied to clipboard
fun <T : AnyIviServiceBase, R> withIviServiceMockOnMainThread(iviServiceMockIdentifier: IviServiceMockIdentifier<T>, block: T.() -> R): R

Applies block on a mock instance identified by the iviServiceMockIdentifier on the main thread.

fun <T : AnyIviServiceBase, R> withIviServiceMockOnMainThread(iviServiceMockClass: KClass<T>, block: T.() -> R): R

Applies block on the iviServiceMockClass instance on the main thread.

Link copied to clipboard
fun <T : AnyIviServiceBase, R> withIviServiceMockOnTestThread(iviServiceMockIdentifier: IviServiceMockIdentifier<T>, block: T.() -> R): R

Applies block on a mock instance identified by the iviServiceMockIdentifier on the test thread.

fun <T : AnyIviServiceBase, R> withIviServiceMockOnTestThread(iviServiceMockClass: KClass<T>, block: T.() -> R): R

Applies block on the iviServiceMockClass instance on the test thread.

Inherited functions

Link copied to clipboard
open override fun apply(p0: Statement, p1: Description): Statement