summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-team Robot <android-build-team-robot@google.com>2019-02-27 04:13:29 +0000
committerandroid-build-team Robot <android-build-team-robot@google.com>2019-02-27 04:13:29 +0000
commit3e6758b79a12f454bf38493c42abe73e0e7dc2bf (patch)
tree1f5e617294804f673eca5c0c43f3e995c962bbf7
parent664b8f8bd3f3088d21440e08ef28031e4d313844 (diff)
parent2649cf26a18e66ad3bac582f67fc565dc3f0e390 (diff)
downloadcts-pie-qpr3-s1-release.tar.gz
Snap for 5339334 from 2649cf26a18e66ad3bac582f67fc565dc3f0e390 to pi-qpr3-releaseandroid-9.0.0_r44android-9.0.0_r43android-9.0.0_r41android-9.0.0_r40android-9.0.0_r37android-9.0.0_r36pie-qpr3-s1-release
Change-Id: Ie0e135c04ef6529cd09e92a46c8367226bfa49f5
-rwxr-xr-xapps/CtsVerifier/res/values/strings.xml1
-rw-r--r--hostsidetests/appsecurity/test-apps/StorageApp/src/com/android/cts/storageapp/Utils.java4
-rw-r--r--hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java13
-rw-r--r--hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseLauncherAppsTest.java11
-rw-r--r--hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsMultiUserTest.java5
-rw-r--r--hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsProfileTest.java15
-rw-r--r--hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsSingleUserTest.java43
-rw-r--r--hostsidetests/incident/AndroidTest.xml3
-rw-r--r--hostsidetests/securitybulletin/AndroidTest.xml2
-rw-r--r--tests/camera/src/android/hardware/camera2/cts/BurstCaptureTest.java32
-rw-r--r--tests/framework/base/activitymanager/util/src/android/server/am/ActivityManagerTestBase.java6
-rw-r--r--tests/framework/base/windowmanager/src/android/server/wm/LocationOnScreenTests.java21
-rw-r--r--tests/tests/notificationlegacy/AndroidTest.xml29
-rw-r--r--tests/tests/security/AndroidTest.xml2
-rw-r--r--tests/tests/view/src/android/view/cts/surfacevalidator/CapturedActivity.java4
-rw-r--r--tests/tests/webkit/assets/webkit/jsunload.html8
-rw-r--r--tests/tests/webkit/res/layout/webview_layout.xml6
-rw-r--r--tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java55
-rw-r--r--tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java79
19 files changed, 258 insertions, 81 deletions
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index ba36d9248f4..0ccd94a9cd1 100755
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -2494,6 +2494,7 @@ You should be prompted to select credentials; choose the ones you just installed
\n
Navigate to \"Data usage\" page and then into the \"Wi-Fi data usage\" category.\n
Confirm that \"All work apps\" section is present and that it is possible to see the data usage for work (badged) apps.\n
+ (If the section is not present, this might be because work apps have not used Wi-Fi data yet. Ensure that you have used Wi-Fi data on a work app, then repeat these instructions.)\n
\n
Then use the Back button (or navigate back to this app using Recents) to return to this test and mark accordingly.
</string>
diff --git a/hostsidetests/appsecurity/test-apps/StorageApp/src/com/android/cts/storageapp/Utils.java b/hostsidetests/appsecurity/test-apps/StorageApp/src/com/android/cts/storageapp/Utils.java
index 08dc7add514..75915b631df 100644
--- a/hostsidetests/appsecurity/test-apps/StorageApp/src/com/android/cts/storageapp/Utils.java
+++ b/hostsidetests/appsecurity/test-apps/StorageApp/src/com/android/cts/storageapp/Utils.java
@@ -150,7 +150,9 @@ public class Utils {
}
private static long getAllocatedSize(File f) throws Exception {
- return Os.lstat(f.getAbsolutePath()).st_blocks * 512;
+ return Os.lstat(f.getAbsolutePath()).st_blocks * 512 /
+ Os.lstat(f.getAbsolutePath()).st_blksize *
+ Os.lstat(f.getAbsolutePath()).st_blksize ;
}
public static boolean deleteContents(File dir) {
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java
index ef51156a26f..6589b224b58 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseDevicePolicyTest.java
@@ -150,7 +150,18 @@ public class BaseDevicePolicyTest extends DeviceTestCase implements IBuildReceiv
if (mPrimaryUserId != USER_SYSTEM) {
mFixedUsers.add(USER_SYSTEM);
}
- switchUser(mPrimaryUserId);
+
+ if (mHasFeature) {
+ // Switching to primary is only needed when we're testing device admin features.
+ switchUser(mPrimaryUserId);
+ } else {
+ // Otherwise, all the tests can be executed in any of the Android users, so remain in
+ // current user, and don't delete it. This enables testing in secondary users.
+ if (getDevice().getCurrentUser() != mPrimaryUserId) {
+ mFixedUsers.add(getDevice().getCurrentUser());
+ }
+ }
+
removeOwners();
removeTestUsers();
// Unlock keyguard before test
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseLauncherAppsTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseLauncherAppsTest.java
index ed885c5bcb0..53db4137d39 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseLauncherAppsTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/BaseLauncherAppsTest.java
@@ -35,10 +35,9 @@ public class BaseLauncherAppsTest extends BaseDevicePolicyTest {
"com.android.cts.launchertests.support";
protected static final String LAUNCHER_TESTS_SUPPORT_APK = "CtsLauncherAppsTestsSupport.apk";
- protected void installTestApps() throws Exception {
- uninstallTestApps();
- installAppAsUser(LAUNCHER_TESTS_APK, mPrimaryUserId);
- installAppAsUser(LAUNCHER_TESTS_SUPPORT_APK, mPrimaryUserId);
+ protected void installTestApps(int userId) throws Exception {
+ installAppAsUser(LAUNCHER_TESTS_APK, userId);
+ installAppAsUser(LAUNCHER_TESTS_SUPPORT_APK, userId);
}
protected void uninstallTestApps() throws Exception {
@@ -47,8 +46,8 @@ public class BaseLauncherAppsTest extends BaseDevicePolicyTest {
getDevice().uninstallPackage(SIMPLE_APP_PKG);
}
- protected void startCallbackService() throws Exception {
- String command = "am startservice --user " + mPrimaryUserId
+ protected void startCallbackService(int userId) throws Exception {
+ String command = "am startservice --user " + userId
+ " -a " + LAUNCHER_TESTS_SUPPORT_PKG + ".REGISTER_CALLBACK "
+ LAUNCHER_TESTS_SUPPORT_PKG + "/.LauncherCallbackTestsService";
CLog.d("Output for command " + command + ": " + getDevice().executeShellCommand(command));
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsMultiUserTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsMultiUserTest.java
index 9205ff7373b..8ae7184f970 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsMultiUserTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsMultiUserTest.java
@@ -42,7 +42,8 @@ public class LauncherAppsMultiUserTest extends BaseLauncherAppsTest {
if (mMultiUserSupported) {
removeTestUsers();
- installTestApps();
+ uninstallTestApps();
+ installTestApps(mPrimaryUserId);
// Create a secondary user.
mSecondaryUserId = createUser();
mSecondaryUserSerialNumber = Integer.toString(getUserSerialNumber(mSecondaryUserId));
@@ -75,7 +76,7 @@ public class LauncherAppsMultiUserTest extends BaseLauncherAppsTest {
if (!mMultiUserSupported) {
return;
}
- startCallbackService();
+ startCallbackService(mPrimaryUserId);
installAppAsUser(SIMPLE_APP_APK, mPrimaryUserId);
runDeviceTestsAsUser(LAUNCHER_TESTS_PKG,
LAUNCHER_TESTS_CLASS,
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsProfileTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsProfileTest.java
index 1596b3cbd4e..7df242d93fb 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsProfileTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsProfileTest.java
@@ -53,12 +53,9 @@ public class LauncherAppsProfileTest extends BaseLauncherAppsTest {
mMainUserSerialNumber = Integer.toString(getUserSerialNumber(mParentUserId));
startUser(mProfileUserId);
- // Install test APK.
- installTestApps();
-
- // Also install on the managed profile too.
- installAppAsUser(LAUNCHER_TESTS_APK, mProfileUserId);
- installAppAsUser(LAUNCHER_TESTS_SUPPORT_APK, mProfileUserId);
+ // Install test APK on primary user and the managed profile.
+ installTestApps(mPrimaryUserId);
+ installTestApps(mProfileUserId);
}
}
@@ -110,7 +107,7 @@ public class LauncherAppsProfileTest extends BaseLauncherAppsTest {
if (!mHasFeature) {
return;
}
- startCallbackService();
+ startCallbackService(mPrimaryUserId);
installAppAsUser(SIMPLE_APP_APK, mProfileUserId);
runDeviceTestsAsUser(LAUNCHER_TESTS_PKG,
LAUNCHER_TESTS_CLASS,
@@ -123,7 +120,7 @@ public class LauncherAppsProfileTest extends BaseLauncherAppsTest {
return;
}
installAppAsUser(SIMPLE_APP_APK, mProfileUserId);
- startCallbackService();
+ startCallbackService(mPrimaryUserId);
getDevice().uninstallPackage(SIMPLE_APP_PKG);
runDeviceTestsAsUser(LAUNCHER_TESTS_PKG,
LAUNCHER_TESTS_CLASS,
@@ -136,7 +133,7 @@ public class LauncherAppsProfileTest extends BaseLauncherAppsTest {
return;
}
installAppAsUser(SIMPLE_APP_APK, mProfileUserId);
- startCallbackService();
+ startCallbackService(mPrimaryUserId);
installAppAsUser(SIMPLE_APP_APK, mProfileUserId);
runDeviceTestsAsUser(LAUNCHER_TESTS_PKG,
LAUNCHER_TESTS_CLASS,
diff --git a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsSingleUserTest.java b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsSingleUserTest.java
index 0481777f8f9..5d67a468d7d 100644
--- a/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsSingleUserTest.java
+++ b/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/LauncherAppsSingleUserTest.java
@@ -29,6 +29,7 @@ public class LauncherAppsSingleUserTest extends BaseLauncherAppsTest {
private boolean mHasLauncherApps;
private String mSerialNumber;
+ private int mCurrentUserId;
@Override
protected void setUp() throws Exception {
@@ -36,8 +37,10 @@ public class LauncherAppsSingleUserTest extends BaseLauncherAppsTest {
mHasLauncherApps = getDevice().getApiLevel() >= 21;
if (mHasLauncherApps) {
- mSerialNumber = Integer.toString(getUserSerialNumber(USER_SYSTEM));
- installTestApps();
+ mCurrentUserId = getDevice().getCurrentUser();
+ mSerialNumber = Integer.toString(getUserSerialNumber(mCurrentUserId));
+ uninstallTestApps();
+ installTestApps(mCurrentUserId);
}
}
@@ -53,78 +56,78 @@ public class LauncherAppsSingleUserTest extends BaseLauncherAppsTest {
if (!mHasLauncherApps) {
return;
}
- installAppAsUser(SIMPLE_APP_APK, mPrimaryUserId);
+ installAppAsUser(SIMPLE_APP_APK, mCurrentUserId);
runDeviceTestsAsUser(LAUNCHER_TESTS_PKG,
LAUNCHER_TESTS_CLASS, "testSimpleAppInstalledForUser",
- mPrimaryUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber));
+ mCurrentUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber));
}
public void testLauncherCallbackPackageAddedMainUser() throws Exception {
if (!mHasLauncherApps) {
return;
}
- startCallbackService();
- installAppAsUser(SIMPLE_APP_APK, mPrimaryUserId);
+ startCallbackService(mCurrentUserId);
+ installAppAsUser(SIMPLE_APP_APK, mCurrentUserId);
runDeviceTestsAsUser(LAUNCHER_TESTS_PKG,
LAUNCHER_TESTS_CLASS,
"testPackageAddedCallbackForUser",
- mPrimaryUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber));
+ mCurrentUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber));
}
public void testLauncherCallbackPackageRemovedMainUser() throws Exception {
if (!mHasLauncherApps) {
return;
}
- installAppAsUser(SIMPLE_APP_APK, mPrimaryUserId);
- startCallbackService();
+ installAppAsUser(SIMPLE_APP_APK, mCurrentUserId);
+ startCallbackService(mCurrentUserId);
getDevice().uninstallPackage(SIMPLE_APP_PKG);
runDeviceTestsAsUser(LAUNCHER_TESTS_PKG,
LAUNCHER_TESTS_CLASS,
"testPackageRemovedCallbackForUser",
- mPrimaryUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber));
+ mCurrentUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber));
}
public void testLauncherCallbackPackageChangedMainUser() throws Exception {
if (!mHasLauncherApps) {
return;
}
- installAppAsUser(SIMPLE_APP_APK, mPrimaryUserId);
- startCallbackService();
- installAppAsUser(SIMPLE_APP_APK, mPrimaryUserId);
+ installAppAsUser(SIMPLE_APP_APK, mCurrentUserId);
+ startCallbackService(mCurrentUserId);
+ installAppAsUser(SIMPLE_APP_APK, mCurrentUserId);
runDeviceTestsAsUser(LAUNCHER_TESTS_PKG,
LAUNCHER_TESTS_CLASS,
"testPackageChangedCallbackForUser",
- mPrimaryUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber));
+ mCurrentUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber));
}
public void testLauncherNonExportedAppFails() throws Exception {
if (!mHasLauncherApps) {
return;
}
- installAppAsUser(SIMPLE_APP_APK, mPrimaryUserId);
+ installAppAsUser(SIMPLE_APP_APK, mCurrentUserId);
runDeviceTestsAsUser(LAUNCHER_TESTS_PKG,
LAUNCHER_TESTS_CLASS, "testLaunchNonExportActivityFails",
- mPrimaryUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber));
+ mCurrentUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber));
}
public void testLaunchNonExportActivityFails() throws Exception {
if (!mHasLauncherApps) {
return;
}
- installAppAsUser(SIMPLE_APP_APK, mPrimaryUserId);
+ installAppAsUser(SIMPLE_APP_APK, mCurrentUserId);
runDeviceTestsAsUser(LAUNCHER_TESTS_PKG,
LAUNCHER_TESTS_CLASS, "testLaunchNonExportLauncherFails",
- mPrimaryUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber));
+ mCurrentUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber));
}
public void testLaunchMainActivity() throws Exception {
if (!mHasLauncherApps) {
return;
}
- installAppAsUser(SIMPLE_APP_APK, mPrimaryUserId);
+ installAppAsUser(SIMPLE_APP_APK, mCurrentUserId);
runDeviceTestsAsUser(LAUNCHER_TESTS_PKG,
LAUNCHER_TESTS_CLASS, "testLaunchMainActivity",
- mPrimaryUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber));
+ mCurrentUserId, Collections.singletonMap(PARAM_TEST_USER, mSerialNumber));
}
}
diff --git a/hostsidetests/incident/AndroidTest.xml b/hostsidetests/incident/AndroidTest.xml
index 641b516feb8..18a73fa2acd 100644
--- a/hostsidetests/incident/AndroidTest.xml
+++ b/hostsidetests/incident/AndroidTest.xml
@@ -16,6 +16,9 @@
<configuration description="Config for CTS Incident host test cases">
<option name="test-suite-tag" value="cts" />
<option name="config-descriptor:metadata" key="component" value="metrics" />
+ <target_preparer class="com.android.tradefed.targetprep.SwitchUserTargetPreparer">
+ <option name="user-type" value="system" />
+ </target_preparer>
<test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
<option name="jar" value="CtsIncidentHostTestCases.jar" />
</test>
diff --git a/hostsidetests/securitybulletin/AndroidTest.xml b/hostsidetests/securitybulletin/AndroidTest.xml
index ae95f999473..11683fc5381 100644
--- a/hostsidetests/securitybulletin/AndroidTest.xml
+++ b/hostsidetests/securitybulletin/AndroidTest.xml
@@ -183,6 +183,6 @@
<test class="com.android.compatibility.common.tradefed.testtype.JarHostTest" >
<option name="jar" value="CtsSecurityBulletinHostTestCases.jar" />
- <option name="runtime-hint" value="8m40s" />
+ <option name="runtime-hint" value="18m26s" />
</test>
</configuration>
diff --git a/tests/camera/src/android/hardware/camera2/cts/BurstCaptureTest.java b/tests/camera/src/android/hardware/camera2/cts/BurstCaptureTest.java
index b0aae411f29..db2b61627b7 100644
--- a/tests/camera/src/android/hardware/camera2/cts/BurstCaptureTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/BurstCaptureTest.java
@@ -127,6 +127,7 @@ public class BurstCaptureTest extends Camera2SurfaceViewTestCase {
// Create session and start up preview
SimpleCaptureCallback resultListener = new SimpleCaptureCallback();
+ SimpleCaptureCallback burstResultListener = new SimpleCaptureCallback();
ImageDropperListener imageDropper = new ImageDropperListener();
prepareCaptureAndStartPreview(
@@ -214,7 +215,7 @@ public class BurstCaptureTest extends Camera2SurfaceViewTestCase {
if (maxSyncLatency == CameraCharacteristics.SYNC_MAX_LATENCY_PER_FRAME_CONTROL) {
// The locked result we have is already synchronized so start the burst
- mSession.captureBurst(burst, resultListener, mHandler);
+ mSession.captureBurst(burst, burstResultListener, mHandler);
} else {
// Need to get a synchronized result, and may need to start burst later to
// be synchronized correctly
@@ -232,7 +233,7 @@ public class BurstCaptureTest extends Camera2SurfaceViewTestCase {
int requestsNeededToSync = numFramesWaited - pipelineDepth;
for (int i = 0; i < numFramesWaited; i++) {
if (!burstSent && requestsNeededToSync <= 0) {
- mSession.captureBurst(burst, resultListener, mHandler);
+ mSession.captureBurst(burst, burstResultListener, mHandler);
burstSent = true;
}
lockedResult = resultListener.getCaptureResult(MAX_PREVIEW_RESULT_TIMEOUT_MS);
@@ -270,12 +271,14 @@ public class BurstCaptureTest extends Camera2SurfaceViewTestCase {
// Process burst results
int burstIndex = 0;
CaptureResult burstResult =
- resultListener.getCaptureResultForRequest(burst.get(burstIndex),
- maxPipelineDepth + 1);
+ burstResultListener.getCaptureResult(MAX_PREVIEW_RESULT_TIMEOUT_MS);
long prevTimestamp = -1;
final long frameDurationBound = (long)
(minStillFrameDuration * (1 + FRAME_DURATION_MARGIN_FRACTION) );
+ long burstStartTimestamp = burstResult.get(CaptureResult.SENSOR_TIMESTAMP);
+ long burstEndTimeStamp = 0;
+
List<Long> frameDurations = new ArrayList<>();
while(true) {
@@ -307,8 +310,25 @@ public class BurstCaptureTest extends Camera2SurfaceViewTestCase {
// Get next result
burstIndex++;
- if (burstIndex == BURST_SIZE) break;
- burstResult = resultListener.getCaptureResult(MAX_PREVIEW_RESULT_TIMEOUT_MS);
+ if (burstIndex == BURST_SIZE) {
+ burstEndTimeStamp = burstResult.get(CaptureResult.SENSOR_TIMESTAMP);
+ break;
+ }
+ burstResult = burstResultListener.getCaptureResult(MAX_PREVIEW_RESULT_TIMEOUT_MS);
+ }
+
+ // Verify no preview frames interleaved in burst results
+ while (true) {
+ CaptureResult previewResult =
+ resultListener.getCaptureResult(MAX_PREVIEW_RESULT_TIMEOUT_MS);
+ long previewTimestamp = previewResult.get(CaptureResult.SENSOR_TIMESTAMP);
+ if (previewTimestamp >= burstStartTimestamp && previewTimestamp <= burstEndTimeStamp) {
+ fail("Preview frame is interleaved with burst frames! Preview timestamp:" +
+ previewTimestamp + ", burst [" + burstStartTimestamp + ", " +
+ burstEndTimeStamp + "]");
+ } else if (previewTimestamp > burstEndTimeStamp) {
+ break;
+ }
}
// Verify inter-frame durations
diff --git a/tests/framework/base/activitymanager/util/src/android/server/am/ActivityManagerTestBase.java b/tests/framework/base/activitymanager/util/src/android/server/am/ActivityManagerTestBase.java
index 59ea4abfe7d..5c5ac8917ae 100644
--- a/tests/framework/base/activitymanager/util/src/android/server/am/ActivityManagerTestBase.java
+++ b/tests/framework/base/activitymanager/util/src/android/server/am/ActivityManagerTestBase.java
@@ -25,6 +25,7 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
+import static android.content.pm.PackageManager.FEATURE_AUTOMOTIVE;
import static android.content.pm.PackageManager.FEATURE_EMBEDDED;
import static android.content.pm.PackageManager.FEATURE_FREEFORM_WINDOW_MANAGEMENT;
import static android.content.pm.PackageManager.FEATURE_LEANBACK;
@@ -516,7 +517,8 @@ public abstract class ActivityManagerTestBase {
protected boolean supportsInsecureLock() {
return !hasDeviceFeature(FEATURE_LEANBACK)
&& !hasDeviceFeature(FEATURE_WATCH)
- && !hasDeviceFeature(FEATURE_EMBEDDED);
+ && !hasDeviceFeature(FEATURE_EMBEDDED)
+ && !hasDeviceFeature(FEATURE_AUTOMOTIVE);
}
protected boolean isWatch() {
@@ -803,7 +805,7 @@ public abstract class ActivityManagerTestBase {
protected int getDeviceRotation(int displayId) {
final String displays = runCommandAndPrintOutput("dumpsys display displays").trim();
Pattern pattern = Pattern.compile(
- "(mDisplayId=" + displayId + ")([\\s\\S]*)(mOverrideDisplayInfo)(.*)"
+ "(mDisplayId=" + displayId + ")([\\s\\S]*?)(mOverrideDisplayInfo)(.*)"
+ "(rotation)(\\s+)(\\d+)");
Matcher matcher = pattern.matcher(displays);
if (matcher.find()) {
diff --git a/tests/framework/base/windowmanager/src/android/server/wm/LocationOnScreenTests.java b/tests/framework/base/windowmanager/src/android/server/wm/LocationOnScreenTests.java
index 15e9260b8d5..6808973552d 100644
--- a/tests/framework/base/windowmanager/src/android/server/wm/LocationOnScreenTests.java
+++ b/tests/framework/base/windowmanager/src/android/server/wm/LocationOnScreenTests.java
@@ -16,6 +16,7 @@
package android.server.wm;
+import static android.server.wm.LocationOnScreenTests.TestActivity.COLOR_TOLERANCE;
import static android.server.wm.LocationOnScreenTests.TestActivity.EXTRA_LAYOUT_PARAMS;
import static android.server.wm.LocationOnScreenTests.TestActivity.TEST_COLOR_1;
import static android.server.wm.LocationOnScreenTests.TestActivity.TEST_COLOR_2;
@@ -32,6 +33,7 @@ import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.Canvas;
+import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.PixelFormat;
import android.graphics.Point;
@@ -179,14 +181,29 @@ public class LocationOnScreenTests {
}
private boolean isTestColors(Bitmap screenshot, int x, int y) {
- return screenshot.getPixel(x, y) == TEST_COLOR_1
- && screenshot.getPixel(x + 1, y) == TEST_COLOR_2;
+ return sameColorWithinTolerance(screenshot.getPixel(x, y), TEST_COLOR_1)
+ && sameColorWithinTolerance(screenshot.getPixel(x + 1, y), TEST_COLOR_2);
+ }
+
+ /**
+ * Returns whether two colors are considered the same.
+ *
+ * Some tolerance is allowed to compensate for errors introduced when screenshots are scaled.
+ */
+ private static boolean sameColorWithinTolerance(int pixelColor, int testColor) {
+ final Color pColor = Color.valueOf(pixelColor);
+ final Color tColor = Color.valueOf(testColor);
+ return pColor.alpha() == tColor.alpha()
+ && Math.abs(pColor.red() - tColor.red()) <= COLOR_TOLERANCE
+ && Math.abs(pColor.blue() - tColor.blue()) <= COLOR_TOLERANCE
+ && Math.abs(pColor.green() - tColor.green()) <= COLOR_TOLERANCE;
}
public static class TestActivity extends Activity {
static final int TEST_COLOR_1 = 0xff123456;
static final int TEST_COLOR_2 = 0xfffedcba;
+ static final int COLOR_TOLERANCE = 4;
static final String EXTRA_LAYOUT_PARAMS = "extra.layout_params";
private View mView;
private boolean mEnterAnimationComplete;
diff --git a/tests/tests/notificationlegacy/AndroidTest.xml b/tests/tests/notificationlegacy/AndroidTest.xml
new file mode 100644
index 00000000000..3a2a493474b
--- /dev/null
+++ b/tests/tests/notificationlegacy/AndroidTest.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- Copyright (C) 2019 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="Config for CTS Notification legacy test cases">
+ <option name="test-suite-tag" value="cts" />
+ <option name="config-descriptor:metadata" key="component" value="framework" />
+ <target_preparer class="com.android.tradefed.targetprep.suite.SuiteApkInstaller">
+ <option name="cleanup-apks" value="true" />
+ <option name="test-file-name" value="CtsLegacyNotificationTestCases.apk" />
+ </target_preparer>
+ <test class="com.android.tradefed.testtype.AndroidJUnitTest" >
+ <option name="runner" value="android.support.test.runner.AndroidJUnitRunner" />
+ <option name="package" value="android.app.notification.legacy.cts" />
+ <option name="runtime-hint" value="1m0s" />
+ <option name="hidden-api-checks" value="false" />
+ </test>
+</configuration>
diff --git a/tests/tests/security/AndroidTest.xml b/tests/tests/security/AndroidTest.xml
index 5482dd63ac5..a146029c6ba 100644
--- a/tests/tests/security/AndroidTest.xml
+++ b/tests/tests/security/AndroidTest.xml
@@ -22,7 +22,7 @@
</target_preparer>
<test class="com.android.tradefed.testtype.AndroidJUnitTest" >
<option name="package" value="android.security.cts" />
- <option name="runtime-hint" value="1h8m15s" />
+ <option name="runtime-hint" value="1h40m18s" />
<!-- test-timeout unit is ms, value = 15 min -->
<option name="test-timeout" value="900000" />
<option name="hidden-api-checks" value="false" />
diff --git a/tests/tests/view/src/android/view/cts/surfacevalidator/CapturedActivity.java b/tests/tests/view/src/android/view/cts/surfacevalidator/CapturedActivity.java
index 4fc5e044066..ce5ab6e7c9b 100644
--- a/tests/tests/view/src/android/view/cts/surfacevalidator/CapturedActivity.java
+++ b/tests/tests/view/src/android/view/cts/surfacevalidator/CapturedActivity.java
@@ -157,7 +157,7 @@ public class CapturedActivity extends Activity {
}
public long getCaptureDurationMs() {
- return mOnEmbedded ? 100000 : 10000;
+ return mOnEmbedded ? 100000 : 50000;
}
public TestResult runTest(AnimationTestCase animationTestCase) throws Throwable {
@@ -175,7 +175,7 @@ public class CapturedActivity extends Activity {
return testResult;
}
- final long timeOutMs = mOnEmbedded ? 125000 : 25000;
+ final long timeOutMs = mOnEmbedded ? 125000 : 62500;
final long endCaptureDelayMs = START_CAPTURE_DELAY_MS + getCaptureDurationMs();
final long endDelayMs = endCaptureDelayMs + 1000;
diff --git a/tests/tests/webkit/assets/webkit/jsunload.html b/tests/tests/webkit/assets/webkit/jsunload.html
index f016eb7b744..9932ae10d33 100644
--- a/tests/tests/webkit/assets/webkit/jsunload.html
+++ b/tests/tests/webkit/assets/webkit/jsunload.html
@@ -22,9 +22,15 @@
return "this message will be a hardcoded string in chrome.";
}
window.onbeforeunload = fireUnload;
+ window.onload = function() {
+ document.addEventListener("touchend", function() {
+ setTimeout(() => {
+ document.title = "touch received";
+ }, 0);
+ }, false);
+ }
</script>
<body>
javascript unload test
</body>
</html>
-
diff --git a/tests/tests/webkit/res/layout/webview_layout.xml b/tests/tests/webkit/res/layout/webview_layout.xml
index 7a0ed0d1fa1..d266d21305b 100644
--- a/tests/tests/webkit/res/layout/webview_layout.xml
+++ b/tests/tests/webkit/res/layout/webview_layout.xml
@@ -17,9 +17,9 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
- android:layout_height="wrap_content">
+ android:layout_height="match_parent">
<WebView android:id="@+id/web_page"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content" />
+ android:layout_width="match_parent"
+ android:layout_height="match_parent" />
</LinearLayout>
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java b/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java
index 92573d873e9..60c9d25a2c8 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebChromeClientTest.java
@@ -31,9 +31,15 @@ import android.webkit.cts.WebViewOnUiThread.WaitForProgressClient;
import com.android.compatibility.common.util.NullWebViewUtils;
import com.android.compatibility.common.util.PollingCheck;
+import com.google.common.util.concurrent.SettableFuture;
+
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Future;
+import java.util.concurrent.TimeUnit;
public class WebChromeClientTest extends ActivityInstrumentationTestCase2<WebViewCtsActivity> {
private static final long TEST_TIMEOUT = 5000L;
+ private static final String TOUCH_RECEIVED = "touch received";
private CtsTestServer mWebServer;
private WebIconDatabase mIconDb;
@@ -201,11 +207,13 @@ public class WebChromeClientTest extends ActivityInstrumentationTestCase2<WebVie
runWindowTest(false);
}
+ // Note that test is still a little flaky. See b/119468441.
public void testOnJsBeforeUnloadIsCalled() throws Exception {
if (!NullWebViewUtils.isWebViewAvailable()) {
return;
}
+ // Use a default WebChromeClient to listen first page title change.
final MockWebChromeClient webChromeClient = new MockWebChromeClient();
mOnUiThread.setWebChromeClient(webChromeClient);
@@ -215,20 +223,37 @@ public class WebChromeClientTest extends ActivityInstrumentationTestCase2<WebVie
assertFalse(webChromeClient.hadOnJsBeforeUnload());
- mOnUiThread.loadUrlAndWaitForCompletion(mWebServer.getAssetUrl(TestHtmlConstants.JS_UNLOAD_URL));
+ mOnUiThread.loadUrlAndWaitForCompletion(
+ mWebServer.getAssetUrl(TestHtmlConstants.JS_UNLOAD_URL));
+
+ final SettableFuture<String> pageTitleFuture = SettableFuture.create();
+ final SettableFuture<Void> onJsBeforeUnloadFuture = SettableFuture.create();
+ final MockWebChromeClient webChromeClientWaitTitle = new MockWebChromeClient() {
+ @Override
+ public void onReceivedTitle(WebView view, String title) {
+ super.onReceivedTitle(view, title);
+ pageTitleFuture.set(title);
+ }
+
+ @Override
+ public boolean onJsBeforeUnload(
+ WebView view, String url, String message, JsResult result) {
+ boolean ret = super.onJsBeforeUnload(view, url, message, result);
+ onJsBeforeUnloadFuture.set(null);
+ return ret;
+ }
+ };
+ mOnUiThread.setWebChromeClient(webChromeClientWaitTitle);
// Send a user gesture, required for unload to execute since WebView version 60.
tapWebView();
+ assertEquals(TOUCH_RECEIVED, waitForFuture(pageTitleFuture));
// unload should trigger when we try to navigate away
- mOnUiThread.loadUrlAndWaitForCompletion(mWebServer.getAssetUrl(TestHtmlConstants.HELLO_WORLD_URL));
+ mOnUiThread.loadUrlAndWaitForCompletion(
+ mWebServer.getAssetUrl(TestHtmlConstants.HELLO_WORLD_URL));
- new PollingCheck(TEST_TIMEOUT) {
- @Override
- protected boolean check() {
- return webChromeClient.hadOnJsBeforeUnload();
- }
- }.run();
+ waitForFuture(onJsBeforeUnloadFuture);
}
public void testOnJsAlert() throws Exception {
@@ -337,6 +362,20 @@ public class WebChromeClientTest extends ActivityInstrumentationTestCase2<WebVie
getInstrumentation().waitForIdleSync();
}
+ // TODO(ctzsm): Remove this method and replace its usage when we have it in a util class.
+ private static <T> T waitForFuture(Future<T> future) throws Exception {
+ try {
+ return future.get(TEST_TIMEOUT, TimeUnit.MILLISECONDS);
+ } catch (ExecutionException e) {
+ Throwable cause = e.getCause();
+ if (cause instanceof Error)
+ throw(Error) cause;
+ if (cause instanceof RuntimeException)
+ throw(RuntimeException) cause;
+ throw new RuntimeException(cause);
+ }
+ }
+
private class MockWebChromeClient extends WaitForProgressClient {
private boolean mHadOnProgressChanged;
private boolean mHadOnReceivedTitle;
diff --git a/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java b/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
index a9b0d9ed427..d1993dcc5e0 100644
--- a/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
+++ b/tests/tests/webkit/src/android/webkit/cts/WebSettingsTest.java
@@ -105,7 +105,7 @@ public class WebSettingsTest extends ActivityInstrumentationTestCase2<WebViewCts
* compatibility definition (tokens in angle brackets are variables, tokens in square
* brackets are optional):
* <p/>
- * Mozilla/5.0 (Linux; Android <version>; [<devicemodel>;] [Build/<buildID>;] wv)
+ * Mozilla/5.0 (Linux; Android <version>; [<devicemodel>] [Build/<buildID>]; wv)
* AppleWebKit/<major>.<minor> (KHTML, like Gecko) Version/<major>.<minor>
* Chrome/<major>.<minor>.<branch>.<build>[ Mobile] Safari/<major>.<minor>
*/
@@ -113,36 +113,83 @@ public class WebSettingsTest extends ActivityInstrumentationTestCase2<WebViewCts
if (!NullWebViewUtils.isWebViewAvailable()) {
return;
}
- final String actualUserAgentString = mSettings.getUserAgentString();
- Log.i(LOG_TAG, String.format("Checking user agent string %s", actualUserAgentString));
+ checkUserAgentStringHelper(mSettings.getUserAgentString(), true);
+ }
+
+ /**
+ * Verifies that the useragent testing regex is actually correct, because it's very complex.
+ */
+ public void testUserAgentStringTest() {
+ // All test UAs share the same prefix and suffix; only the middle part varies.
+ final String prefix = "Mozilla/5.0 (Linux; Android " + Build.VERSION.RELEASE + "; ";
+ final String suffix = "wv) AppleWebKit/0.0 (KHTML, like Gecko) Version/4.0 Chrome/0.0.0.0 Safari/0.0";
+
+ // Valid cases:
+ // Both model and build present
+ checkUserAgentStringHelper(prefix + Build.MODEL + " Build/" + Build.ID + "; " + suffix, true);
+ // Just model
+ checkUserAgentStringHelper(prefix + Build.MODEL + "; " + suffix, true);
+ // Just build
+ checkUserAgentStringHelper(prefix + "Build/" + Build.ID + "; " + suffix, true);
+ // Neither
+ checkUserAgentStringHelper(prefix + suffix, true);
+
+ // Invalid cases:
+ // No space between model and build
+ checkUserAgentStringHelper(prefix + Build.MODEL + "Build/" + Build.ID + "; " + suffix, false);
+ // No semicolon after model and/or build
+ checkUserAgentStringHelper(prefix + Build.MODEL + " Build/" + Build.ID + suffix, false);
+ checkUserAgentStringHelper(prefix + Build.MODEL + suffix, false);
+ checkUserAgentStringHelper(prefix + "Build/" + Build.ID + suffix, false);
+ // Double semicolon when both omitted
+ checkUserAgentStringHelper(prefix + "; " + suffix, false);
+ }
- String expectedRelease, expectedModel;
+ /**
+ * Helper function to validate that a given useragent string is or is not valid.
+ */
+ private void checkUserAgentStringHelper(final String useragent, boolean shouldMatch) {
+ String expectedRelease;
if ("REL".equals(Build.VERSION.CODENAME)) {
expectedRelease = Pattern.quote(Build.VERSION.RELEASE);
- expectedModel = Pattern.quote(Build.MODEL);
} else {
- // Non-release builds don't include real release version/model, be lenient.
- expectedRelease = expectedModel = "[^;]+";
+ // Non-release builds don't include real release version, be lenient.
+ expectedRelease = "[^;]+";
}
// Build expected regex inserting the appropriate variables, as this is easier to
// understand and get right than matching any possible useragent and comparing the
// variables afterward.
final String patternString =
- Pattern.quote("Mozilla/5.0 (Linux; Android ") + expectedRelease + "; " +
- "(" + expectedModel + "; )?" + // Optional
- "(Build/" + Pattern.quote(Build.ID) + "; )?" + // Optional
- Pattern.quote("wv) ") +
+ // Release version always has a semicolon after it:
+ Pattern.quote("Mozilla/5.0 (Linux; Android ") + expectedRelease + ";" +
+ // Model is optional, but if present must have a space first:
+ "( " + Pattern.quote(Build.MODEL) + ")?" +
+ // Build is optional, but if present must have a space first:
+ "( Build/" + Pattern.quote(Build.ID) + ")?" +
+ // We want a semicolon before the wv token, but we don't want to have two in a row
+ // if both model and build are omitted. Lookbehind assertions ensure either:
+ // - the previous character is a semicolon
+ // - or the previous character is NOT a semicolon AND a semicolon is added here.
+ "((?<=;)|(?<!;);)" +
+ // After that we can just check for " wv)" to finish the platform section:
+ Pattern.quote(" wv) ") +
+ // The rest of the expression is browser tokens and is fairly simple:
"AppleWebKit/\\d+\\.\\d+ " +
Pattern.quote("(KHTML, like Gecko) Version/4.0 ") +
"Chrome/\\d+\\.\\d+\\.\\d+\\.\\d+ " +
"(Mobile )?Safari/\\d+\\.\\d+";
- Log.i(LOG_TAG, String.format("Trying to match pattern %s", patternString));
final Pattern userAgentExpr = Pattern.compile(patternString);
- Matcher patternMatcher = userAgentExpr.matcher(actualUserAgentString);
- assertTrue(String.format("User agent string did not match expected pattern. \nExpected " +
- "pattern:\n%s\nActual:\n%s", patternString, actualUserAgentString),
- patternMatcher.find());
+ Matcher patternMatcher = userAgentExpr.matcher(useragent);
+ if (shouldMatch) {
+ assertTrue(String.format("CDD(3.4.1/C-1-3) User agent string did not match expected pattern. \n" +
+ "Expected pattern:\n%s\nActual:\n%s", patternString, useragent),
+ patternMatcher.find());
+ } else {
+ assertFalse(String.format("Known-bad user agent string incorrectly matched. \n" +
+ "Expected pattern:\n%s\nActual:\n%s", patternString, useragent),
+ patternMatcher.find());
+ }
}
public void testAccessUserAgentString() throws Exception {