diff options
author | Julien Desprez <jdesprez@google.com> | 2016-11-16 09:16:53 +0000 |
---|---|---|
committer | Julien Desprez <jdesprez@google.com> | 2016-11-17 17:05:44 +0000 |
commit | fdcd78282b27f0a1db863d4f808a136a724a5e53 (patch) | |
tree | a696717bd9f5838ae1d664cbd96785c032756f81 /src | |
parent | 9f1ec886dac8338deb8c829d6b0fa15e2f3ade57 (diff) | |
download | tradefederation-fdcd78282b27f0a1db863d4f808a136a724a5e53.tar.gz |
Add more unit tests
Bug: 32300769
Change-Id: I2bc4f306ca55dfc8143436f9a3f0834bbb21e4ec
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/tradefed/targetprep/AppSetup.java | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/src/com/android/tradefed/targetprep/AppSetup.java b/src/com/android/tradefed/targetprep/AppSetup.java index c2d27e527..a92b15a87 100644 --- a/src/com/android/tradefed/targetprep/AppSetup.java +++ b/src/com/android/tradefed/targetprep/AppSetup.java @@ -26,6 +26,8 @@ import com.android.tradefed.device.ITestDevice; import com.android.tradefed.log.LogUtil.CLog; import com.android.tradefed.util.AaptParser; +import com.google.common.annotations.VisibleForTesting; + import java.io.File; import java.util.ArrayList; import java.util.HashSet; @@ -104,11 +106,11 @@ public class AppSetup implements ITargetPreparer, ITargetCleaner { if (mInstall) { for (VersionedFile apkFile : appBuild.getAppPackageFiles()) { if (mCheckMinSdk) { - AaptParser aaptParser = AaptParser.parse(apkFile.getFile()); + AaptParser aaptParser = doAaptParse(apkFile.getFile()); if (aaptParser == null) { throw new TargetSetupError( String.format("Failed to extract info from '%s' using aapt", - apkFile.toString()), device.getDeviceDescriptor()); + apkFile.getFile().getName()), device.getDeviceDescriptor()); } if (device.getApiLevel() < aaptParser.getSdkVersion()) { CLog.w("Skipping installing apk %s on device %s because " + @@ -135,7 +137,7 @@ public class AppSetup implements ITargetPreparer, ITargetCleaner { } } - if (mPostInstallCmds != null && !mPostInstallCmds.isEmpty()){ + if (!mPostInstallCmds.isEmpty()){ for (String cmd : mPostInstallCmds) { // If the command had any output, the executeShellCommand method will log it at the // VERBOSE level; so no need to do any logging from here. @@ -146,9 +148,17 @@ public class AppSetup implements ITargetPreparer, ITargetCleaner { } } + /** + * Helper to parse an apk file with aapt. + */ + @VisibleForTesting + AaptParser doAaptParse(File apkFile) { + return AaptParser.parse(apkFile); + } + private void addPackageNameToUninstall(File apkFile, ITestDevice device) throws TargetSetupError { - AaptParser aaptParser = AaptParser.parse(apkFile); + AaptParser aaptParser = doAaptParse(apkFile); if (aaptParser == null) { throw new TargetSetupError(String.format("Failed to extract info from '%s' using aapt", apkFile.getAbsolutePath()), device.getDeviceDescriptor()); |