aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYuexi Ma <yuexima@google.com>2021-03-17 16:03:44 -0700
committerYuexi Ma <yuexima@google.com>2021-03-17 16:03:44 -0700
commit9f3a3b2de77cc32df2afe2ad6b6313f3fad4f689 (patch)
tree695f30fbbcdb981d352b86efc4e00964a629c6be
parent55626259d0f0186873acd2315247bcfaf00dc97d (diff)
downloadplatform_test_app_compat_csuite-9f3a3b2de77cc32df2afe2ad6b6313f3fad4f689.tar.gz
platform_test_app_compat_csuite-9f3a3b2de77cc32df2afe2ad6b6313f3fad4f689.tar.bz2
platform_test_app_compat_csuite-9f3a3b2de77cc32df2afe2ad6b6313f3fad4f689.zip
Remove a deprecated option
Test: atest :presubmit Change-Id: I440ee9ead2f487bbfdbf49a4650c7a0c42d98359
-rw-r--r--harness/src/main/java/com/android/compatibility/targetprep/AppSetupPreparer.java25
-rw-r--r--harness/src/test/java/com/android/compatibility/targetprep/AppSetupPreparerTest.java46
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 9445316..8ae4815 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 =