GTest

public class GTest
extends GTestBase implements IDeviceTest

java.lang.Object
   ↳ com.android.tradefed.testtype.GTestBase
     ↳ com.android.tradefed.testtype.GTest


這項測試會在指定裝置上執行原生測試套件。

摘要

公用建構函式

GTest()

公用方法

ITestDevice getDevice()

取得受測裝置。

boolean isRebootBeforeTestEnabled()
void run(TestInformation testInfo, ITestInvocationListener listener)

void setDevice(ITestDevice device)

注入受測裝置。

void setNativeTestDevicePath(String path)

受保護的方法

String createFlagFile(String filter)

建立包含篩選器的檔案,透過 --gtest_flagfile 使用,避免 args 大小受到 OS 限制。

void executeCommandByScript(ITestDevice testDevice, String cmd, IShellOutputReceiver resultParser)

Helper method to run a gtest command from a temporary script, in the case that the command is too long to be run directly by adb.

String getGTestCmdLine(String fullPath, String flags)

Helper method to build the gtest command to run.

String loadFilter(String binaryOnDevice)

定義 get 篩選器方法。

boolean shouldRunFile(String fullPath)

輔助方法,用於判斷是否應執行指定檔案。

公用建構函式

GTest

public GTest ()

公用方法

getDevice

public ITestDevice getDevice ()

取得受測裝置。

傳回
ITestDevice ITestDevice

isRebootBeforeTestEnabled

public boolean isRebootBeforeTestEnabled ()

傳回
boolean

得分

public void run (TestInformation testInfo, 
                ITestInvocationListener listener)

參數
testInfo TestInformation

listener ITestInvocationListener

擲回
DeviceNotAvailableException

setDevice

public void setDevice (ITestDevice device)

注入測試裝置。

參數
device ITestDevice:要使用的 ITestDevice

setNativeTestDevicePath

public void setNativeTestDevicePath (String path)

參數
path String

受保護的方法

createFlagFile

protected String createFlagFile (String filter)

建立檔案,其中包含要透過 --gtest_flagfile 使用的篩選器,避免 args 大小受到 OS 限制。

參數
filter String:篩選器字串

傳回
String 包含篩選器的檔案路徑。

擲回
DeviceNotAvailableException

executeCommandByScript

protected void executeCommandByScript (ITestDevice testDevice, 
                String cmd, 
                IShellOutputReceiver resultParser)

輔助方法:從臨時指令碼執行 gtest 指令,以防指令過長而無法直接透過 adb 執行。

參數
testDevice ITestDevice:要在哪個裝置上執行指令

cmd String:要執行的指令字串

resultParser IShellOutputReceiver:用於讀取測試結果的輸出接收器

擲回
DeviceNotAvailableException

getGTestCmdLine

protected String getGTestCmdLine (String fullPath, 
                String flags)

建構要執行的 gtest 指令的輔助方法。

參數
fullPath String:裝置上 gtest 二進位檔的絕對檔案系統路徑

flags String:gtest 執行標記

傳回
String 要執行的 gtest 的殼層指令列

loadFilter

protected String loadFilter (String binaryOnDevice)

定義 get 篩選器方法。

子類別必須實作如何取得自己的篩選器。

參數
binaryOnDevice String:篩選器檔案的完整路徑。

傳回
String 篩選器字串。

擲回
DeviceNotAvailableException

shouldRunFile

protected boolean shouldRunFile (String fullPath)

輔助方法,用於判斷是否應執行指定檔案。

參數
fullPath String:有問題的檔案完整路徑

傳回
boolean 如果應執行上述檔案,則為 true。