@MustBeDocumented
@Retention(value = AnnotationRetention.RUNTIME)
@Target(allowedTargets = [AnnotationTarget.VALUE_PARAMETER])
annotation Device


Qualifier annotation used for multi-device orchestration. Instructs the JUnit 5 extension which connected device characteristics to resolve.

A BackupRestoreController parameter that asks for a serial number, through serial, a binding of role or a system property, gets the device with that serial number. The other controller parameters of a method or constructor each get a matching online device of their own when there are enough: in the order of the parameters, each takes the first free one by serial number, and an earlier parameter moves to another device that matches it if that frees one. A parameter that can't get a device of its own shares the first device that matches it.

A device matches when its API level is api, if set, and from minApi to maxApi: an exact level such as api = 34 matches the same devices as minApi = 34, maxApi = 34. The system properties androidx.test.backup.device.apis, a comma-separated list with an API level for each controller parameter, and androidx.test.backup.device.api, one API level for all of them, replace api but not minApi and maxApi. So for parameters whose ranges don't overlap, use the list. In both, 0 means any API level, as it does for api. A negative value, a minApi above maxApi, or an api or system property outside them fails the test with an IllegalArgumentException.

Summary

Public constructors

Device(role: String, api: Int, serial: String, minApi: Int, maxApi: Int)

Public properties

Int

The API level that matches, exactly, such as 31 or 34.

Int

The highest API level that matches.

Int

The lowest API level that matches.

String

The role of the device in a multi-device test, such as "source" or "target".

String

The specific hardware/emulator serial number to match, or a name that the system property androidx.test.backup.device.serial.<serial> binds to a serial number.

Public constructors

Device

Added in 1.0.0-alpha04
Device(
    role: String = "",
    api: Int = 0,
    serial: String = "",
    minApi: Int = 0,
    maxApi: Int = Integer.MAX_VALUE
)

Public properties

api

val api: Int

The API level that matches, exactly, such as 31 or 34. Defaults to 0 (any API level).

maxApi

val maxApi: Int

The highest API level that matches. Defaults to Integer.MAX_VALUE (no upper bound).

minApi

val minApi: Int

The lowest API level that matches. Defaults to 0 (no lower bound).

role

val role: String

The role of the device in a multi-device test, such as "source" or "target". The system property androidx.test.backup.device.serial.<role> binds the role to the device with that serial number, whatever serial and the other device properties ask for. Without the property, the role doesn't change which device is selected. Defaults to "".

serial

val serial: String

The specific hardware/emulator serial number to match, or a name that the system property androidx.test.backup.device.serial.<serial> binds to a serial number. The system properties androidx.test.backup.device.serials and androidx.test.backup.device.serial take precedence over a literal serial number. Defaults to "" (any match).