aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2021-04-09 17:02:29 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2021-04-09 17:02:29 +0000
commit872b4fdd7d202f469d1a597354f5019a0f13da11 (patch)
tree9b5aeda8b8b38354d08896a7df3160e226a09b8c
parent51699daf23be3553a7f78dc42e92fcb2520c0c79 (diff)
parentbee9686969829da92ca7f28dc2d040b372665f1c (diff)
downloadcsuite-872b4fdd7d202f469d1a597354f5019a0f13da11.tar.gz
Snap for 7271644 from bee9686969829da92ca7f28dc2d040b372665f1c to sc-mainline-release
Change-Id: I855296b9d3e550846f60152641fba3cffcdccb4d
-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
-rw-r--r--test_targets/csuite-app-launch/Android.bp (renamed from tests/csuite-app-launch/Android.bp)0
-rw-r--r--test_targets/csuite-app-launch/template.xml (renamed from tests/csuite-app-launch/template.xml)0
-rw-r--r--test_targets/csuite-pre-installed-app-launch/Android.bp22
-rw-r--r--test_targets/csuite-pre-installed-app-launch/template.xml25
-rw-r--r--test_targets/csuite-system-app-launch/Android.bp (renamed from tests/csuite-system-app-launch/Android.bp)0
-rw-r--r--test_targets/csuite-system-app-launch/template.xml (renamed from tests/csuite-system-app-launch/template.xml)0
-rw-r--r--test_targets/csuite-test-package-launch/Android.bp (renamed from tests/csuite-test-package-launch/Android.bp)0
-rw-r--r--test_targets/csuite-test-package-launch/template.xml (renamed from tests/csuite-test-package-launch/template.xml)0
10 files changed, 49 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 =
diff --git a/tests/csuite-app-launch/Android.bp b/test_targets/csuite-app-launch/Android.bp
index 256d9f4..256d9f4 100644
--- a/tests/csuite-app-launch/Android.bp
+++ b/test_targets/csuite-app-launch/Android.bp
diff --git a/tests/csuite-app-launch/template.xml b/test_targets/csuite-app-launch/template.xml
index 52c4611..52c4611 100644
--- a/tests/csuite-app-launch/template.xml
+++ b/test_targets/csuite-app-launch/template.xml
diff --git a/test_targets/csuite-pre-installed-app-launch/Android.bp b/test_targets/csuite-pre-installed-app-launch/Android.bp
new file mode 100644
index 0000000..539306a
--- /dev/null
+++ b/test_targets/csuite-pre-installed-app-launch/Android.bp
@@ -0,0 +1,22 @@
+// Copyright (C) 2021 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+csuite_test {
+ name: "csuite-pre-installed-app-launch",
+ test_config_template: "template.xml"
+}
diff --git a/test_targets/csuite-pre-installed-app-launch/template.xml b/test_targets/csuite-pre-installed-app-launch/template.xml
new file mode 100644
index 0000000..2d20306
--- /dev/null
+++ b/test_targets/csuite-pre-installed-app-launch/template.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2021 The Android Open Source Project
+
+ Licensed under the Apache License, Version 2.0 (the "License");
+ you may not use this file except in compliance with the License.
+ You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing, software
+ distributed under the License is distributed on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions and
+ limitations under the License.
+-->
+<configuration description="Launches an app that exists on the device and check for crashes">
+ <option name="package-name" value="{package}"/>
+ <target_preparer class="com.android.compatibility.targetprep.CheckGmsPreparer"/>
+ <target_preparer class="com.android.tradefed.targetprep.RunCommandTargetPreparer">
+ <option name="run-command" value="input keyevent KEYCODE_WAKEUP"/>
+ <option name="run-command" value="input keyevent KEYCODE_MENU"/>
+ <option name="run-command" value="input keyevent KEYCODE_HOME"/>
+ </target_preparer>
+ <test class="com.android.compatibility.testtype.AppLaunchTest"/>
+</configuration> \ No newline at end of file
diff --git a/tests/csuite-system-app-launch/Android.bp b/test_targets/csuite-system-app-launch/Android.bp
index 2514740..2514740 100644
--- a/tests/csuite-system-app-launch/Android.bp
+++ b/test_targets/csuite-system-app-launch/Android.bp
diff --git a/tests/csuite-system-app-launch/template.xml b/test_targets/csuite-system-app-launch/template.xml
index 4d1181b..4d1181b 100644
--- a/tests/csuite-system-app-launch/template.xml
+++ b/test_targets/csuite-system-app-launch/template.xml
diff --git a/tests/csuite-test-package-launch/Android.bp b/test_targets/csuite-test-package-launch/Android.bp
index 6cdd899..6cdd899 100644
--- a/tests/csuite-test-package-launch/Android.bp
+++ b/test_targets/csuite-test-package-launch/Android.bp
diff --git a/tests/csuite-test-package-launch/template.xml b/test_targets/csuite-test-package-launch/template.xml
index 9c97fd3..9c97fd3 100644
--- a/tests/csuite-test-package-launch/template.xml
+++ b/test_targets/csuite-test-package-launch/template.xml