to top
public class

UiAutomatorTest

extends Object
implements IRemoteTest IDeviceTest
java.lang.Object
   ↳ com.android.tradefed.testtype.UiAutomatorTest

Summary

Nested Classes
enum UiAutomatorTest.LoggingOption  
enum UiAutomatorTest.TestFailureAction  
Fields
private Map<String, String> mArgMap @Option(name = "run-arg", description = "Additional test specific arguments to provide.")
private List<String> mClasses @Option(name = "class", description = "test class to run, may be repeated; multiple classess will be run in the same order as provided in command line")
private UiAutomatorTest.TestFailureAction mFailureAction @Option(name = "on-test-failure", description = "sets the action to perform if a test fails")
private boolean mFinalScreenshot @Option(name = "final-screenshot", description = "Take a screenshot at the end of a test")
private boolean mIgnoreSighup @Option(name = "ignore-sighup", description = "allows uiautomator test to ignore SIGHUP signal")
private boolean mInstrumentation @Option(name = "instrumentation", description = "the specified test should be driven with instrumentation.jar-path, runner-path, ignore-sighup are ignored when this is set.")
private List<String> mJarPaths @Option(name = "jar-path", description = "path to jars containing UI Automator test cases and dependencies; May be repeated. If unspecified will use all jars found in /data/local/tmp/")
private UiAutomatorTest.LoggingOption mLoggingOption @Option(name = "capture-logs", description = "capture bugreport and screenshot as specified.")
private String mPackage @Option(name = "package", description = "The manifest package name of the UI test package.Only applies when \'instrumentation\' option is set.")
private String mRunName @Option(name = "run-name", description = "the run name to use when reporting test results.")
private String mRunnerName @Option(name = "runner", description = "The instrumentation based test runner class name to use.Only applies when \'instrumentation\' option is set.")
private String mRunnerPath @Option(name = "runner-path", description = "path to uiautomator runner; may be null and default will be used in this case")
private long mSyncTime @Option(name = "sync-time", description = "time to allow for initial sync, in ms")
private int mTestTimeout @Option(name = "timeout", description = "Aborts the test run if any test takes longer than the specified number of milliseconds. For no timeout, set to 0.")
Public Constructors
UiAutomatorTest()
Public Methods
void addClassName(String className)
Add a test class name to run.
void addClassNames(Collection<String> classNames)
Add a test class name collection to run.
void addRunArg(String key, String value)
Add an argument to provide when running the UI Automator tests
List<String> getClassNames()
Gets the list of test class names that the harness is configured to run
ITestDevice getDevice()
Get the device under test.
long getSyncTime()
List<String> getTestJarPaths()
Map<String, String> getTestRunArgMap()
IRemoteAndroidTestRunner getTestRunner()
boolean isInstrumentationTest()
void run(ITestInvocationListener listener)
Runs the tests, and reports result to the listener.
void setCaptureLogs(boolean captureLogs)
This method is deprecated. use setLoggingOption(LoggingOption) instead.

Retained for compatibility with cts-tradefed

void setDevice(ITestDevice device)
Inject the device under test.
void setLoggingOption(UiAutomatorTest.LoggingOption loggingOption)
void setRunName(String runName)
void setRunnerName(String runnerName)
void setSyncTime(long syncTime)
void setTestJarPaths(List<String> jarPaths)
void setTestRunArgMap(Map<String, String> runArgMap)
Protected Methods
IRemoteAndroidTestRunner createTestRunner()
IRunUtil getRunUtil()
void onScreenshotAndBugreport(ITestDevice device, ITestInvocationListener listener, String prefix)
void onScreenshotAndBugreport(ITestDevice device, ITestInvocationListener listener, String prefix, UiAutomatorTest.TestFailureAction overrideAction)
void preTestSetup()
Checks if the UI Automator components are present on device
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.android.tradefed.testtype.IRemoteTest
From interface com.android.tradefed.testtype.IDeviceTest

Fields

private Map<String, String> mArgMap

private List<String> mClasses

private UiAutomatorTest.TestFailureAction mFailureAction

private boolean mFinalScreenshot

private boolean mIgnoreSighup

private boolean mInstrumentation

private List<String> mJarPaths

private UiAutomatorTest.LoggingOption mLoggingOption

private String mPackage

private String mRunName

private String mRunnerName

private String mRunnerPath

private long mSyncTime

private int mTestTimeout

Public Constructors

public UiAutomatorTest ()

Public Methods

public void addClassName (String className)

Add a test class name to run.

public void addClassNames (Collection<String> classNames)

Add a test class name collection to run.

public void addRunArg (String key, String value)

Add an argument to provide when running the UI Automator tests

Parameters
key the argument name
value the argument value

public List<String> getClassNames ()

Gets the list of test class names that the harness is configured to run

Returns
  • list of test class names

public ITestDevice getDevice ()

Get the device under test.

Returns

public long getSyncTime ()

Returns
  • the time allocated for the tests to sync.

public List<String> getTestJarPaths ()

Returns
  • the test jar path.

public Map<String, String> getTestRunArgMap ()

Returns
  • the arguments map to pass to the UiAutomatorRunner.

public IRemoteAndroidTestRunner getTestRunner ()

Returns
  • the test runner.

public boolean isInstrumentationTest ()

public void run (ITestInvocationListener listener)

Runs the tests, and reports result to the listener.

Parameters
listener the ITestInvocationListener of test results

public void setCaptureLogs (boolean captureLogs)

This method is deprecated.
use setLoggingOption(LoggingOption) instead.

Retained for compatibility with cts-tradefed

public void setDevice (ITestDevice device)

Inject the device under test.

Parameters
device the ITestDevice to use

public void setLoggingOption (UiAutomatorTest.LoggingOption loggingOption)

public void setRunName (String runName)

public void setRunnerName (String runnerName)

public void setSyncTime (long syncTime)

Parameters
syncTime the time for the tests files to sync.

public void setTestJarPaths (List<String> jarPaths)

Parameters
jarPaths the locations of the test jars.

public void setTestRunArgMap (Map<String, String> runArgMap)

Parameters
runArgMap the arguments to pass to the UiAutomatorRunner.

Protected Methods

protected IRemoteAndroidTestRunner createTestRunner ()

protected IRunUtil getRunUtil ()

protected void onScreenshotAndBugreport (ITestDevice device, ITestInvocationListener listener, String prefix)

protected void onScreenshotAndBugreport (ITestDevice device, ITestInvocationListener listener, String prefix, UiAutomatorTest.TestFailureAction overrideAction)

protected void preTestSetup ()

Checks if the UI Automator components are present on device