diff options
| author | Treehugger Robot <treehugger-gerrit@google.com> | 2021-04-08 18:21:59 +0000 |
|---|---|---|
| committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2021-04-08 18:21:59 +0000 |
| commit | 246e353133e757e600fbb0a6522eabc2128cc031 (patch) | |
| tree | bf6e2cd26ef4804c0712e16ddd9ffe6e378ace42 | |
| parent | d98e225ea415a373617e57a3998a909bf97ada22 (diff) | |
| parent | 9f3a3b2de77cc32df2afe2ad6b6313f3fad4f689 (diff) | |
| download | platform_test_app_compat_csuite-246e353133e757e600fbb0a6522eabc2128cc031.tar.gz platform_test_app_compat_csuite-246e353133e757e600fbb0a6522eabc2128cc031.tar.bz2 platform_test_app_compat_csuite-246e353133e757e600fbb0a6522eabc2128cc031.zip | |
Merge "Remove a deprecated option"
| -rw-r--r-- | harness/src/main/java/com/android/compatibility/targetprep/AppSetupPreparer.java | 25 | ||||
| -rw-r--r-- | harness/src/test/java/com/android/compatibility/targetprep/AppSetupPreparerTest.java | 46 |
2 files changed, 2 insertions, 69 deletions
diff --git a/harness/src/main/java/com/android/compatibility/targetprep/AppSetupPreparer.java b/harness/src/main/java/com/android/compatibility/targetprep/AppSetupPreparer.java index 7652fe2..8757996 100644 --- a/harness/src/main/java/com/android/compatibility/targetprep/AppSetupPreparer.java +++ b/harness/src/main/java/com/android/compatibility/targetprep/AppSetupPreparer.java @@ -46,8 +46,6 @@ import java.util.concurrent.TimeUnit; /** A Tradefed preparer that downloads and installs an app on the target device. */ public final class AppSetupPreparer implements ITargetPreparer { - @VisibleForTesting static final String OPTION_CHECK_DEVICE_AVAILABLE = "check-device-available"; - @VisibleForTesting static final String OPTION_WAIT_FOR_DEVICE_AVAILABLE_SECONDS = "wait-for-device-available-seconds"; @@ -91,13 +89,6 @@ public final class AppSetupPreparer implements ITargetPreparer { + "seconds between retries.") private int mExponentialBackoffMultiplierSeconds = 0; - // TODO(yuexima): Remove this option after migrated to using - // OPTION_WAIT_FOR_DEVICE_AVAILABLE_SECONDS - @Option( - name = OPTION_CHECK_DEVICE_AVAILABLE, - description = "Whether to check device avilibility upon setUp failure.") - private boolean mCheckDeviceAvailable = false; - @Option( name = OPTION_WAIT_FOR_DEVICE_AVAILABLE_SECONDS, description = @@ -166,7 +157,7 @@ public final class AppSetupPreparer implements ITargetPreparer { currentException = new TargetSetupError(e.getMessage(), e); } - checkDeviceAvailable(device); + waitForDeviceAvailable(device); if (runCount > mMaxRetry) { throw currentException; } @@ -208,19 +199,7 @@ public final class AppSetupPreparer implements ITargetPreparer { mTestAppInstallSetup.tearDown(testInfo, e); } - private void checkDeviceAvailable(ITestDevice device) throws DeviceNotAvailableException { - if (mCheckDeviceAvailable) { - // Throw an exception for TF to retry the invocation if the device is no longer - // available since retrying would be useless. Ideally we would wait for the device to - // recover but that is currently not supported in TradeFed. - if (device.getProperty("any_key") == null) { - throw new DeviceNotAvailableException( - "getprop command failed. Might have lost connection to the device.", - device.getSerialNumber()); - } - return; - } - + private void waitForDeviceAvailable(ITestDevice device) throws DeviceNotAvailableException { if (mWaitForDeviceAvailableSeconds < 0) { return; } diff --git a/harness/src/test/java/com/android/compatibility/targetprep/AppSetupPreparerTest.java b/harness/src/test/java/com/android/compatibility/targetprep/AppSetupPreparerTest.java index 512c983..a3c8ea7 100644 --- a/harness/src/test/java/com/android/compatibility/targetprep/AppSetupPreparerTest.java +++ b/harness/src/test/java/com/android/compatibility/targetprep/AppSetupPreparerTest.java @@ -234,52 +234,6 @@ public final class AppSetupPreparerTest { } @Test - public void setUp_deviceDisconnectedAndCheckDeviceAvailable_throwsDeviceNotAvailableException() - throws Exception { - AppSetupPreparer preparer = - new PreparerBuilder() - .setInstaller( - mockInstallerThatThrows( - new TargetSetupError("Connection reset by peer."))) - .setOption(AppSetupPreparer.OPTION_CHECK_DEVICE_AVAILABLE, "true") - .build(); - ITestDevice device = createUnavailableDevice(); - - assertThrows( - DeviceNotAvailableException.class, () -> preparer.setUp(device, NULL_BUILD_INFO)); - } - - @Test - public void setUp_deviceConnectedAndCheckDeviceAvailable_doesNotChangeException() - throws Exception { - AppSetupPreparer preparer = - new PreparerBuilder() - .setInstaller( - mockInstallerThatThrows( - new TargetSetupError("Connection reset by peer."))) - .setOption(AppSetupPreparer.OPTION_CHECK_DEVICE_AVAILABLE, "true") - .build(); - ITestDevice device = createAvailableDevice(); - - assertThrows(TargetSetupError.class, () -> preparer.setUp(device, NULL_BUILD_INFO)); - } - - @Test - public void setUp_deviceDisconnectedAndNotCheckDeviceAvailable_doesNotChangeException() - throws Exception { - AppSetupPreparer preparer = - new PreparerBuilder() - .setInstaller( - mockInstallerThatThrows( - new TargetSetupError("Connection reset by peer."))) - .setOption(AppSetupPreparer.OPTION_CHECK_DEVICE_AVAILABLE, "false") - .build(); - ITestDevice device = createUnavailableDevice(); - - assertThrows(TargetSetupError.class, () -> preparer.setUp(device, NULL_BUILD_INFO)); - } - - @Test public void setUp_deviceNotAvailableAndWaitEnabled_throwsDeviceNotAvailableException() throws Exception { AppSetupPreparer preparer = |
