TestAppInstallSetup

public class TestAppInstallSetup
extends BaseTargetPreparer implements ITargetCleaner, IAbiReceiver

java.lang.Object
   ↳ com.android.tradefed.targetprep.BaseTargetPreparer
     ↳ com.android.tradefed.targetprep.TestAppInstallSetup
Known Direct Subclasses
CompanionTestAppInstallSetup A ITargetPreparer that installs one or more apps from a getTestsDir() folder onto an allocated companion device. 
SuiteApkInstaller Installs specified APKs for Suite configuration: either from $ANDROID_TARGET_OUT_TESTCASES variable or the ROOT_DIR in build info. 


A ITargetPreparer that installs one or more apps from a getTestsDir() folder onto device.

This preparer will look in alternate directories if the tests zip does not exist or does not contain the required apk. The search will go in order from the last alternative dir specified to the first.

Summary

Public constructors

TestAppInstallSetup()

Public methods

void addInstallArg(String arg)

Adds one apk installation arg to be used.

void addTestFileName(String fileName)

Adds a file to the list of apks to install

IAbi getAbi()
List<String> getTestsFileName()

Returns a copy of the list of specified test apk names.

void setAbi(IAbi abi)
void setAltDir(File altDir)

Set an alternate directory.

void setAltDirBehavior(AltDirBehavior altDirBehavior)

Set an alternate directory behaviors.

void setCleanApk(boolean shouldClean)

Sets whether or not the installed apk should be cleaned on tearDown

void setShouldGrantPermission(boolean shouldGrant)

If a userId is provided, grantPermission can be set for the apk installation.

void setUp(ITestDevice device, IBuildInfo buildInfo)

Perform the target setup for testing.

void setUserId(int userId)

If the apk should be installed for a particular user, sets the id of the user to install for.

void tearDown(ITestDevice device, IBuildInfo buildInfo, Throwable e)

Perform the target cleanup/teardown after testing.

Protected methods

File getLocalPathForFilename(IBuildInfo buildInfo, String apkFileName, ITestDevice device)

Resolve the actual apk path based on testing artifact information inside build info.

String parsePackageName(File testAppFile, DeviceDescriptor deviceDescriptor)

Get the package name from the test app.

Public constructors

TestAppInstallSetup

TestAppInstallSetup ()

Public methods

addInstallArg

void addInstallArg (String arg)

Adds one apk installation arg to be used.

Parameters
arg String

addTestFileName

void addTestFileName (String fileName)

Adds a file to the list of apks to install

getAbi

IAbi getAbi ()

Returns
IAbi

getTestsFileName

List<String> getTestsFileName ()

Returns a copy of the list of specified test apk names.

Returns
List<String>

setAbi

void setAbi (IAbi abi)

Parameters
abi IAbi

setAltDir

void setAltDir (File altDir)

Set an alternate directory.

Parameters
altDir File

setAltDirBehavior

void setAltDirBehavior (AltDirBehavior altDirBehavior)

Set an alternate directory behaviors.

Parameters
altDirBehavior AltDirBehavior

setCleanApk

void setCleanApk (boolean shouldClean)

Sets whether or not the installed apk should be cleaned on tearDown

Parameters
shouldClean boolean

setShouldGrantPermission

void setShouldGrantPermission (boolean shouldGrant)

If a userId is provided, grantPermission can be set for the apk installation.

Parameters
shouldGrant boolean

setUp

void setUp (ITestDevice device, 
                IBuildInfo buildInfo)

Perform the target setup for testing.

Parameters
device ITestDevice: the ITestDevice to prepare.

buildInfo IBuildInfo: data about the build under test.

Throws
TargetSetupError
DeviceNotAvailableException

setUserId

void setUserId (int userId)

If the apk should be installed for a particular user, sets the id of the user to install for.

Parameters
userId int

tearDown

void tearDown (ITestDevice device, 
                IBuildInfo buildInfo, 
                Throwable e)

Perform the target cleanup/teardown after testing.

Parameters
device ITestDevice: the ITestDevice to prepare.

buildInfo IBuildInfo: data about the build under test.

e Throwable: if the invocation ended with an exception, this will be the exception that was caught at the Invocation level. Otherwise, will be null.

Throws
DeviceNotAvailableException

Protected methods

getLocalPathForFilename

File getLocalPathForFilename (IBuildInfo buildInfo, 
                String apkFileName, 
                ITestDevice device)

Resolve the actual apk path based on testing artifact information inside build info.

Parameters
buildInfo IBuildInfo: build artifact information

apkFileName String: filename of the apk to install

device ITestDevice: the ITestDevice being prepared

Returns
File a File representing the physical apk file on host or null if the file does not exist.

Throws
TargetSetupError

parsePackageName

String parsePackageName (File testAppFile, 
                DeviceDescriptor deviceDescriptor)

Get the package name from the test app.

Parameters
testAppFile File

deviceDescriptor DeviceDescriptor

Returns
String

Throws
TargetSetupError