UiAutomatorTest

public class UiAutomatorTest
extends Object implements IRemoteTest, IDeviceTest, ITestFilterReceiver

java.lang.Object
   ↳ com.android.tradefed.testtype.UiAutomatorTest


Summary

Nested classes

enum UiAutomatorTest.LoggingOption

 

enum UiAutomatorTest.TestFailureAction

 

Fields

protected Collection<ITestLifeCycleReceiver> mListeners

Public constructors

UiAutomatorTest()

Public methods

void addAllExcludeFilters(Set<String> filters)

Adds the Set of filters of which tests to exclude.

void addAllIncludeFilters(Set<String> filters)

Adds the Set of filters of which tests to include.

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 addExcludeFilter(String filter)

Adds a filter of which tests to exclude.

void addIncludeFilter(String filter)

Adds a filter of which tests to include.

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, UiAutomatorTest.TestFailureAction overrideAction)
void onScreenshotAndBugreport(ITestDevice device, ITestInvocationListener listener, String prefix)
void preTestSetup()

Checks if the UI Automator components are present on device

Fields

mListeners

protected Collection<ITestLifeCycleReceiver> mListeners

Public constructors

UiAutomatorTest

public UiAutomatorTest ()

Public methods

addAllExcludeFilters

public void addAllExcludeFilters (Set<String> filters)

Adds the Set of filters of which tests to exclude.

Parameters
filters Set

addAllIncludeFilters

public void addAllIncludeFilters (Set<String> filters)

Adds the Set of filters of which tests to include.

Parameters
filters Set

addClassName

public void addClassName (String className)

Add a test class name to run.

Parameters
className String

addClassNames

public void addClassNames (Collection<String> classNames)

Add a test class name collection to run.

Parameters
classNames Collection

addExcludeFilter

public void addExcludeFilter (String filter)

Adds a filter of which tests to exclude.

Parameters
filter String

addIncludeFilter

public void addIncludeFilter (String filter)

Adds a filter of which tests to include.

Parameters
filter String

addRunArg

public void addRunArg (String key, 
                String value)

Add an argument to provide when running the UI Automator tests

Parameters
key String: the argument name

value String: the argument value

getClassNames

public List<String> getClassNames ()

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

Returns
List<String> list of test class names

getDevice

public ITestDevice getDevice ()

Get the device under test.

Returns
ITestDevice the ITestDevice

getSyncTime

public long getSyncTime ()

Returns
long the time allocated for the tests to sync.

getTestJarPaths

public List<String> getTestJarPaths ()

Returns
List<String> the test jar path.

getTestRunArgMap

public Map<String, String> getTestRunArgMap ()

Returns
Map<String, String> the arguments map to pass to the UiAutomatorRunner.

getTestRunner

public IRemoteAndroidTestRunner getTestRunner ()

Returns
IRemoteAndroidTestRunner the test runner.

isInstrumentationTest

public boolean isInstrumentationTest ()

Returns
boolean

run

public void run (ITestInvocationListener listener)

Runs the tests, and reports result to the listener.

Parameters
listener ITestInvocationListener: the ITestInvocationListener of test results

Throws
DeviceNotAvailableException

setCaptureLogs

public void setCaptureLogs (boolean captureLogs)

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

Retained for compatibility with cts-tradefed

Parameters
captureLogs boolean

setDevice

public void setDevice (ITestDevice device)

Inject the device under test.

Parameters
device ITestDevice: the ITestDevice to use

setLoggingOption

public void setLoggingOption (UiAutomatorTest.LoggingOption loggingOption)

Parameters
loggingOption UiAutomatorTest.LoggingOption

setRunName

public void setRunName (String runName)

Parameters
runName String

setRunnerName

public void setRunnerName (String runnerName)

Parameters
runnerName String

setSyncTime

public void setSyncTime (long syncTime)

Parameters
syncTime long: the time for the tests files to sync.

setTestJarPaths

public void setTestJarPaths (List<String> jarPaths)

Parameters
jarPaths List: the locations of the test jars.

setTestRunArgMap

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

Parameters
runArgMap Map: the arguments to pass to the UiAutomatorRunner.

Protected methods

createTestRunner

protected IRemoteAndroidTestRunner createTestRunner ()

Returns
IRemoteAndroidTestRunner

getRunUtil

protected IRunUtil getRunUtil ()

Returns
IRunUtil

onScreenshotAndBugreport

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

Parameters
device ITestDevice

listener ITestInvocationListener

prefix String

overrideAction UiAutomatorTest.TestFailureAction

onScreenshotAndBugreport

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

Parameters
device ITestDevice

listener ITestInvocationListener

prefix String

preTestSetup

protected void preTestSetup ()

Checks if the UI Automator components are present on device

Throws
DeviceNotAvailableException