GTest

public class GTest
extends GTestBase implements IDeviceTest

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


A Test that runs a native test package on given device.

Summary

Public constructors

GTest()

Public methods

ITestDevice getDevice()

Get the device under test.

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

void setDevice(ITestDevice device)

Inject the device under test.

void setNativeTestDevicePath(String path)

Protected methods

String createFlagFile(String filter)

Create a file containing the filters that will be used via --gtest_flagfile to avoid any OS limitation in args size.

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)

Define get filter method.

boolean shouldRunFile(String fullPath)

Helper method to determine if we should execute a given file.

Public constructors

GTest

public GTest ()

Public methods

getDevice

public ITestDevice getDevice ()

Get the device under test.

Returns
ITestDevice the ITestDevice

isRebootBeforeTestEnabled

public boolean isRebootBeforeTestEnabled ()

Returns
boolean

run

public void run (TestInformation testInfo, 
                ITestInvocationListener listener)

Parameters
testInfo TestInformation

listener ITestInvocationListener

Throws
DeviceNotAvailableException

setDevice

public void setDevice (ITestDevice device)

Inject the device under test.

Parameters
device ITestDevice: the ITestDevice to use

setNativeTestDevicePath

public void setNativeTestDevicePath (String path)

Parameters
path String

Protected methods

createFlagFile

protected String createFlagFile (String filter)

Create a file containing the filters that will be used via --gtest_flagfile to avoid any OS limitation in args size.

Parameters
filter String: The filter string

Returns
String The path to the file containing the filter.

Throws
DeviceNotAvailableException

executeCommandByScript

protected 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.

Parameters
testDevice ITestDevice: the device on which to run the command

cmd String: the command string to run

resultParser IShellOutputReceiver: the output receiver for reading test results

Throws
DeviceNotAvailableException

getGTestCmdLine

protected String getGTestCmdLine (String fullPath, 
                String flags)

Helper method to build the gtest command to run.

Parameters
fullPath String: absolute file system path to gtest binary on device

flags String: gtest execution flags

Returns
String the shell command line to run for the gtest

loadFilter

protected String loadFilter (String binaryOnDevice)

Define get filter method.

Sub class must implement how to get it's own filter.

Parameters
binaryOnDevice String: the full path of the filter file.

Returns
String filter string.

Throws
DeviceNotAvailableException

shouldRunFile

protected boolean shouldRunFile (String fullPath)

Helper method to determine if we should execute a given file.

Parameters
fullPath String: the full path of the file in question

Returns
boolean true if we should execute the said file.