diff options
author | Dan Shi <dshi@google.com> | 2017-06-20 17:28:12 -0700 |
---|---|---|
committer | Julien Desprez <jdesprez@google.com> | 2017-06-26 15:59:06 +0000 |
commit | c94cfb2de2dfafa5e27e190a5f565cc2d650bee9 (patch) | |
tree | 8a5a80e4db5ff6f39a6dc6a4217361cbe194aa13 /src/com/android/tradefed/targetprep | |
parent | 9cd6c25090e5d949325292a88b77f30049987271 (diff) | |
download | tradefederation-c94cfb2de2dfafa5e27e190a5f565cc2d650bee9.tar.gz |
Support TestAppInstallSetup to run test cases in device-tests.zip
This change is similar to the PushFilePreparer.java change in ag/2203623
It allows TestAppInstallSetup to look for apks located in extracted
device-tests.zip.
Bug: 37630158
Test: unittest, run suite locally
Change-Id: I53646b655faef78c6b30c0a34b28df533ea2f2b5
(cherry picked from commit c781454e7d9dbfd2bf601a62ac70693896093a2d)
Diffstat (limited to 'src/com/android/tradefed/targetprep')
-rw-r--r-- | src/com/android/tradefed/targetprep/PushFilePreparer.java | 23 | ||||
-rw-r--r-- | src/com/android/tradefed/targetprep/TestAppInstallSetup.java | 11 |
2 files changed, 10 insertions, 24 deletions
diff --git a/src/com/android/tradefed/targetprep/PushFilePreparer.java b/src/com/android/tradefed/targetprep/PushFilePreparer.java index 75c28a4bc..414666b15 100644 --- a/src/com/android/tradefed/targetprep/PushFilePreparer.java +++ b/src/com/android/tradefed/targetprep/PushFilePreparer.java @@ -19,7 +19,6 @@ package com.android.tradefed.targetprep; import com.android.ddmlib.IDevice; import com.android.ddmlib.Log; import com.android.tradefed.build.IBuildInfo; -import com.android.tradefed.build.IDeviceBuildInfo; import com.android.tradefed.config.Option; import com.android.tradefed.config.OptionClass; import com.android.tradefed.device.DeviceNotAvailableException; @@ -96,11 +95,12 @@ public class PushFilePreparer implements ITargetCleaner { * * <p>The wrapper function is for unit test to mock the system calls. * + * @param buildInfo the build artifact information * @return a list of {@link File} of directories of the test cases folder of build output, based * on the value of environment variables. */ - List<File> getTestCasesDirs() { - return SystemUtil.getTestCasesDirs(); + List<File> getTestCasesDirs(IBuildInfo buildInfo) { + return SystemUtil.getTestCasesDirs(buildInfo); } /** @@ -118,21 +118,8 @@ public class PushFilePreparer implements ITargetCleaner { return src; } } - List<File> testCasesDirs = getTestCasesDirs(); - - // Search for source file in tests directory if buildInfo is IDeviceBuildInfo. - if (buildInfo instanceof IDeviceBuildInfo) { - IDeviceBuildInfo deviceBuildInfo = (IDeviceBuildInfo) buildInfo; - File testsDir = deviceBuildInfo.getTestsDir(); - // Add all possible paths to the testcases directory list. - if (testsDir != null) { - testCasesDirs.addAll( - Arrays.asList( - testsDir, - FileUtil.getFileForPath(testsDir, HOST_TESTCASES), - FileUtil.getFileForPath(testsDir, TARGET_TESTCASES))); - } - } + + List<File> testCasesDirs = getTestCasesDirs(buildInfo); for (File dir : testCasesDirs) { src = FileUtil.getFileForPath(dir, fileName); if (src != null && src.exists()) { diff --git a/src/com/android/tradefed/targetprep/TestAppInstallSetup.java b/src/com/android/tradefed/targetprep/TestAppInstallSetup.java index eab1b5db3..49e7fb9dc 100644 --- a/src/com/android/tradefed/targetprep/TestAppInstallSetup.java +++ b/src/com/android/tradefed/targetprep/TestAppInstallSetup.java @@ -134,13 +134,12 @@ public class TestAppInstallSetup implements ITargetCleaner, IAbiReceiver { /** * Get a list of {@link File} of the test cases directories * - * <p>The wrapper function is for unit test to mock the system calls. - * + * @param buildInfo the build artifact information * @return a list of {@link File} of directories of the test cases folder of build output, based - * on the value of environment variables. + * on the value of environment variables and the device build info. */ - List<File> getTestCasesDirs() { - return SystemUtil.getTestCasesDirs(); + List<File> getTestCasesDirs(IBuildInfo buildInfo) { + return SystemUtil.getTestCasesDirs(buildInfo); } /** {@inheritDoc} */ @@ -156,7 +155,7 @@ public class TestAppInstallSetup implements ITargetCleaner, IAbiReceiver { } // Force to look for apk files in build ouput's test cases directory. - for (File testCasesDir : getTestCasesDirs()) { + for (File testCasesDir : getTestCasesDirs(buildInfo)) { setAltDir(testCasesDir); } |