設備測試運行選項

public class DeviceTestRunOptions
extends Object

java.lang.Object
com.android.tradefed.testtype.junit4.DeviceTestRunOptions


與通過 BaseHostJUnit4Test 運行設備測試相關的選項的構建器類。

概括

公共構造函數

DeviceTestRunOptions (String packageName)

公共方法

DeviceTestRunOptions addExtraListener ( ITestLifeCycleReceiver listener)

向正在運行的檢測添加一個額外的偵聽器。

DeviceTestRunOptions addInstrumentationArg (String key, String value)

添加將傳遞給檢測的參數。

void clearExtraListeners ()
void clearInstrumentationArgs ()

清除之前使用addInstrumentationArg(String, String)設置的所有檢測參數。

String getApkFileName ()

返回 apk 安裝的 apk 文件的名稱。

ITestDevice getDevice ()
getExtraListeners ()
String[] getInstallArgs ()

返回安裝命令的額外選項。

getInstrumentationArgs ()
Long getMaxInstrumentationTimeoutMs ()
Long getMaxTimeToOutputMs ()
String getPackageName ()
String getRunner ()
String getTestClassName ()
String getTestMethodName ()
Long getTestTimeoutMs ()
Integer getUserId ()
boolean isForceQueryable ()

要安裝的 apk 是否應該是可查詢的。

boolean isGrantPermission ()

是否授予apk安裝權限。

boolean isHiddenApiCheckDisabled ()
boolean isIsolatedStorageDisabled ()
boolean isRestartDisabled ()
boolean isTestApiCheckDisabled ()
boolean isWindowAnimationDisabled ()
DeviceTestRunOptions setApkFileName (String apkFileName)

為 apk 安裝設置 apk 文件的名稱。

DeviceTestRunOptions setCheckResults (boolean checkResults)

設置是否應檢查檢測運行的結果並確保沒有發生故障。

DeviceTestRunOptions setDevice ( ITestDevice device)
DeviceTestRunOptions setDisableHiddenApiCheck (boolean disableHiddenApiCheck)

設置是否將 --no-hidden-api-checks 添加到主機端使用的“am instrument”。

DeviceTestRunOptions setDisableIsolatedStorage (boolean disableIsolatedStorage)

設置是否將 --no-isolated-storage 添加到主機端使用的“am instrument”。

DeviceTestRunOptions setDisableRestart (boolean disableRestart)

設置是否將 --no-restart 添加到主機端使用的“am instrument”。

DeviceTestRunOptions setDisableTestApiCheck (boolean disableTestApiCheck)

設置是否將 --no-test-api-access 添加到主機端使用的“am instrument”。

DeviceTestRunOptions setDisableWindowAnimation (boolean disableWindowAnimation)

設置是否將 --no-window-animation 添加到主機端使用的“am instrument”。

DeviceTestRunOptions setForceQueryable (boolean forceQueryable)

如果要安裝的 apk 不可查詢,則設置false

DeviceTestRunOptions setGrantPermission (boolean grantPermission)

授予 apk 安裝權限。

DeviceTestRunOptions setInstallArgs (String... installArgs)

設置安裝命令的額外選項。

DeviceTestRunOptions setMaxInstrumentationTimeoutMs (Long maxInstrumentationTimeoutMs)

設置完整檢測必須運行和完成的最長時間(以毫秒為單位)。

DeviceTestRunOptions setMaxTimeToOutputMs (Long maxTimeToOutputMs)

設置儀器在停止之前可以停止輸出的最長時間(以毫秒為單位)。

DeviceTestRunOptions setRunner (String runner)

設置應該用於運行檢測的檢測運行器。

DeviceTestRunOptions setTestClassName (String testClassName)

設置檢測應該運行的類名。

DeviceTestRunOptions setTestMethodName (String testMethodName)

設置檢測應運行的方法名稱。

DeviceTestRunOptions setTestTimeoutMs (Long testTimeoutMs)

設置測試在被中斷之前可以運行的最長時間(以毫秒為單位)。

DeviceTestRunOptions setUserId (Integer userId)

設置檢測應針對其運行的用戶 ID。

boolean shouldCheckResults ()

公共構造函數

設備測試運行選項

public DeviceTestRunOptions (String packageName)

參數
packageName String

公共方法

添加額外監聽器

public DeviceTestRunOptions addExtraListener (ITestLifeCycleReceiver listener)

向正在運行的檢測添加一個額外的偵聽器。

參數
listener ITestLifeCycleReceiver

退貨
DeviceTestRunOptions

addInstrumentationArg

public DeviceTestRunOptions addInstrumentationArg (String key, 
                String value)

添加將傳遞給檢測的參數。

參數
key String

value String

退貨
DeviceTestRunOptions

clearExtraListeners

public void clearExtraListeners ()

clearInstrumentationArgs

public void clearInstrumentationArgs ()

清除之前使用addInstrumentationArg(String, String)設置的所有檢測參數。

獲取Apk文件名

public String getApkFileName ()

返回 apk 安裝的 apk 文件的名稱。

退貨
String

獲取設備

public ITestDevice getDevice ()

退貨
ITestDevice

getExtraListeners

public  getExtraListeners ()

退貨

獲取安裝參數

public String[] getInstallArgs ()

返回安裝命令的額外選項。

退貨
String[]

getInstrumentationArgs

public  getInstrumentationArgs ()

退貨

getMaxInstrumentationTimeoutMs

public Long getMaxInstrumentationTimeoutMs ()

退貨
Long

getMaxTimeToOutputMs

public Long getMaxTimeToOutputMs ()

退貨
Long

獲取包名

public String getPackageName ()

退貨
String

獲取亞軍

public String getRunner ()

退貨
String

獲取測試類名稱

public String getTestClassName ()

退貨
String

獲取測試方法名稱

public String getTestMethodName ()

退貨
String

getTestTimeoutMs

public Long getTestTimeoutMs ()

退貨
Long

獲取用戶ID

public Integer getUserId ()

退貨
Integer

isForceQueryable

public boolean isForceQueryable ()

要安裝的 apk 是否應該是可查詢的。默認值是true。

退貨
boolean

isGrantPermission

public boolean isGrantPermission ()

是否授予apk安裝權限。

退貨
boolean

isHiddenApiCheckDisabled

public boolean isHiddenApiCheckDisabled ()

退貨
boolean

isIsolatedStorageDisabled

public boolean isIsolatedStorageDisabled ()

退貨
boolean

isRestartDisabled

public boolean isRestartDisabled ()

退貨
boolean

isTestApiCheckDisabled

public boolean isTestApiCheckDisabled ()

退貨
boolean

isWindowAnimationDisabled

public boolean isWindowAnimationDisabled ()

退貨
boolean

設置Apk文件名

public DeviceTestRunOptions setApkFileName (String apkFileName)

為 apk 安裝設置 apk 文件的名稱。

參數
apkFileName String

退貨
DeviceTestRunOptions

設置檢查結果

public DeviceTestRunOptions setCheckResults (boolean checkResults)

設置是否應檢查檢測運行的結果並確保沒有發生故障。

參數
checkResults boolean

退貨
DeviceTestRunOptions

設置設備

public DeviceTestRunOptions setDevice (ITestDevice device)

參數
device ITestDevice

退貨
DeviceTestRunOptions

setDisableHiddenApiCheck

public DeviceTestRunOptions setDisableHiddenApiCheck (boolean disableHiddenApiCheck)

設置是否將 --no-hidden-api-checks 添加到主機端使用的“am instrument”。

參數
disableHiddenApiCheck boolean

退貨
DeviceTestRunOptions

設置禁用隔離存儲

public DeviceTestRunOptions setDisableIsolatedStorage (boolean disableIsolatedStorage)

設置是否將 --no-isolated-storage 添加到主機端使用的“am instrument”。

參數
disableIsolatedStorage boolean

退貨
DeviceTestRunOptions

設置禁用重啟

public DeviceTestRunOptions setDisableRestart (boolean disableRestart)

設置是否將 --no-restart 添加到主機端使用的“am instrument”。

參數
disableRestart boolean

退貨
DeviceTestRunOptions

setDisableTestApiCheck

public DeviceTestRunOptions setDisableTestApiCheck (boolean disableTestApiCheck)

設置是否將 --no-test-api-access 添加到主機端使用的“am instrument”。

參數
disableTestApiCheck boolean

退貨
DeviceTestRunOptions

設置禁用窗口動畫

public DeviceTestRunOptions setDisableWindowAnimation (boolean disableWindowAnimation)

設置是否將 --no-window-animation 添加到主機端使用的“am instrument”。

參數
disableWindowAnimation boolean

退貨
DeviceTestRunOptions

setForceQueryable

public DeviceTestRunOptions setForceQueryable (boolean forceQueryable)

如果要安裝的 apk 不可查詢,則設置false

參數
forceQueryable boolean

退貨
DeviceTestRunOptions

設置授權

public DeviceTestRunOptions setGrantPermission (boolean grantPermission)

授予 apk 安裝權限。

參數
grantPermission boolean

退貨
DeviceTestRunOptions

設置安裝參數

public DeviceTestRunOptions setInstallArgs (String... installArgs)

設置安裝命令的額外選項。

參數
installArgs String

退貨
DeviceTestRunOptions

setMaxInstrumentationTimeoutMs

public DeviceTestRunOptions setMaxInstrumentationTimeoutMs (Long maxInstrumentationTimeoutMs)

設置完整檢測必須運行和完成的最長時間(以毫秒為單位)。設置為 0 表示沒有超時。選修的。

參數
maxInstrumentationTimeoutMs Long

退貨
DeviceTestRunOptions

setMaxTimeToOutputMs

public DeviceTestRunOptions setMaxTimeToOutputMs (Long maxTimeToOutputMs)

設置儀器在停止之前可以停止輸出的最長時間(以毫秒為單位)。設置為 0 表示沒有超時。選修的。

參數
maxTimeToOutputMs Long

退貨
DeviceTestRunOptions

設置運行器

public DeviceTestRunOptions setRunner (String runner)

設置應該用於運行檢測的檢測運行器。默認運行器是“android.support.test.runner.AndroidJUnitRunner”。選修的。

參數
runner String

退貨
DeviceTestRunOptions

設置測試類名稱

public DeviceTestRunOptions setTestClassName (String testClassName)

設置檢測應該運行的類名。儀器將被過濾以僅運行該類。可以與setTestMethodName(String)一起使用。選修的。

參數
testClassName String

退貨
DeviceTestRunOptions

設置測試方法名稱

public DeviceTestRunOptions setTestMethodName (String testMethodName)

設置檢測應運行的方法名稱。需要設置setTestClassName(String)才能正常工作。選修的。

參數
testMethodName String

退貨
DeviceTestRunOptions

setTestTimeoutMs

public DeviceTestRunOptions setTestTimeoutMs (Long testTimeoutMs)

設置測試在被中斷之前可以運行的最長時間(以毫秒為單位)。設置為 0 表示沒有超時。選修的。

參數
testTimeoutMs Long

退貨
DeviceTestRunOptions

設置用戶Id

public DeviceTestRunOptions setUserId (Integer userId)

設置檢測應針對其運行的用戶 ID。選修的。

參數
userId Integer

退貨
DeviceTestRunOptions

應該檢查結果

public boolean shouldCheckResults ()

退貨
boolean