aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2021-04-08 20:29:18 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2021-04-08 20:29:18 +0000
commite3f75a4abf900d972786c2848d6e99040c1898a8 (patch)
treebf6e2cd26ef4804c0712e16ddd9ffe6e378ace42
parent74cb15d3cf3393283ffba1a2b1c4bac21567a96b (diff)
parent68dc1fea1c6449200a1a39cd754b5e3b6c9c0d01 (diff)
downloadcsuite-e3f75a4abf900d972786c2848d6e99040c1898a8.tar.gz
Merge "Remove a deprecated option" am: 246e353133 am: 187bf7e568 am: 68dc1fea1c
Original change: https://android-review.googlesource.com/c/platform/test/app_compat/csuite/+/1643405 Change-Id: I186e6f407c6e7e4860b133a0d6fc5fc8d13d628e
-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 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 =