summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorandroid-build-prod (mdb) <android-build-team-robot@google.com>2019-10-11 20:09:26 +0000
committerGerrit Code Review <noreply-gerritcodereview@google.com>2019-10-11 20:09:26 +0000
commita5956b806edf5b2ed74eb8ffc2adc0a98e986898 (patch)
treeb44292acf617a4de89ab67da20536cff92e6ba5c
parentf193915d1e00ef387b5abcfeb342b19964e1977b (diff)
parentf079f4f906616ccf37fcdf9d9dfdf221fed6809d (diff)
downloadcts-sparse-5935223-L60400000387247683.tar.gz
Merge "Snap for 5934577 from 2de95a59ab6042394c4f1bd0833212a793ec7393 to android10-tests-release" into android10-tests-releasesparse-5935223-L86100000387264045sparse-5935223-L60400000387247683
-rwxr-xr-xapps/CtsVerifier/res/values/strings.xml4
-rw-r--r--tests/camera/src/android/hardware/camera2/cts/StillCaptureTest.java3
-rw-r--r--tests/framework/base/windowmanager/backgroundactivity/Android.mk3
-rw-r--r--tests/framework/base/windowmanager/backgroundactivity/AppA/Android.mk3
-rw-r--r--tests/framework/base/windowmanager/backgroundactivity/AppA/src/android/server/wm/backgroundactivity/appa/SendPendingIntentReceiver.java10
-rw-r--r--tests/framework/base/windowmanager/backgroundactivity/AppA/src/android/server/wm/backgroundactivity/appa/StartBackgroundActivityReceiver.java8
-rw-r--r--tests/framework/base/windowmanager/backgroundactivity/AppB/Android.mk3
-rw-r--r--tests/framework/base/windowmanager/backgroundactivity/AppB/src/android/server/wm/backgroundactivity/appb/StartPendingIntentReceiver.java8
-rw-r--r--tests/framework/base/windowmanager/backgroundactivity/common/Android.mk32
-rw-r--r--tests/framework/base/windowmanager/backgroundactivity/common/src/android/server/wm/backgroundactivity/common/CommonComponents.java42
-rw-r--r--tests/framework/base/windowmanager/backgroundactivity/common/src/android/server/wm/backgroundactivity/common/EventReceiver.java70
-rw-r--r--tests/framework/base/windowmanager/backgroundactivity/src/android/server/wm/BackgroundActivityLaunchTest.java41
-rw-r--r--tests/framework/base/windowmanager/src/android/server/wm/ManifestLayoutTests.java9
-rw-r--r--tests/framework/base/windowmanager/util/src/android/server/wm/WindowManagerState.java4
-rw-r--r--tests/tests/content/src/android/content/cts/AvailableIntentsTest.java12
-rw-r--r--tests/tests/text/src/android/text/method/cts/ScrollingMovementMethodTest.java12
16 files changed, 246 insertions, 18 deletions
diff --git a/apps/CtsVerifier/res/values/strings.xml b/apps/CtsVerifier/res/values/strings.xml
index 3b14b44f794..87276946d1f 100755
--- a/apps/CtsVerifier/res/values/strings.xml
+++ b/apps/CtsVerifier/res/values/strings.xml
@@ -275,13 +275,13 @@
<string name="ble_coc_secure_client_test_list_name">Bluetooth LE CoC Secure Client Test</string>
<string name="ble_coc_secure_client_test_list_info">
The Bluetooth LE CoC test must be done simultaneously on two devices. This device is the client.
- All tests listed here must be done without pairing. Tap \"Bluetooth LE CoC Secure Server Test\" on the other device.
+ All tests listed here must be done with pairing. Tap \"Bluetooth LE CoC Secure Server Test\" on the other device.
\n\nTap \"01 Bluetooth LE CoC Client Test\" on this device, then tap \"01 Bluetooth LE CoC Server Test\" on the other device.
\nWhen the test is complete, move to the next item. You must complete all tests.
</string>
<string name="ble_coc_secure_client_test_info">
The Bluetooth LE CoC test must be done simultaneously on two devices. This device is the client.
- All tests listed here must be done without pairing.
+ All tests listed here must be done with pairing.
</string>
<string name="ble_coc_secure_server_test_list_name">Bluetooth LE CoC Secure Server Test</string>
<string name="ble_coc_secure_server_test_list_info">
diff --git a/tests/camera/src/android/hardware/camera2/cts/StillCaptureTest.java b/tests/camera/src/android/hardware/camera2/cts/StillCaptureTest.java
index e8d28122097..553ced42531 100644
--- a/tests/camera/src/android/hardware/camera2/cts/StillCaptureTest.java
+++ b/tests/camera/src/android/hardware/camera2/cts/StillCaptureTest.java
@@ -1359,6 +1359,9 @@ public class StillCaptureTest extends Camera2SurfaceViewTestCase {
resultListener.getCaptureResultForRequest(request, NUM_RESULTS_WAIT_TIMEOUT);
Image image = imageListener.getImage(CAPTURE_IMAGE_TIMEOUT_MS);
assertNotNull("Unable to acquire next image", image);
+ long resultTs = stillResult.get(CaptureResult.SENSOR_TIMESTAMP);
+ assertTrue("Image timestamp and result timestamp must match!",
+ (resultTs == image.getTimestamp()));
CameraTestUtils.validateImage(image, stillSize.getWidth(), stillSize.getHeight(),
format, null /*filePath*/);
diff --git a/tests/framework/base/windowmanager/backgroundactivity/Android.mk b/tests/framework/base/windowmanager/backgroundactivity/Android.mk
index 3ddcdf08a10..18e466c41a1 100644
--- a/tests/framework/base/windowmanager/backgroundactivity/Android.mk
+++ b/tests/framework/base/windowmanager/backgroundactivity/Android.mk
@@ -29,7 +29,8 @@ LOCAL_STATIC_JAVA_LIBRARIES := \
androidx.test.rules \
cts-wm-util \
cts-wm-app-base \
- cts-core-test-runner-axt
+ cts-core-test-runner-axt \
+ cts-background-activity-common
LOCAL_COMPATIBILITY_SUITE := cts vts general-tests
diff --git a/tests/framework/base/windowmanager/backgroundactivity/AppA/Android.mk b/tests/framework/base/windowmanager/backgroundactivity/AppA/Android.mk
index 08d4f364b31..c3080f9d92f 100644
--- a/tests/framework/base/windowmanager/backgroundactivity/AppA/Android.mk
+++ b/tests/framework/base/windowmanager/backgroundactivity/AppA/Android.mk
@@ -22,7 +22,8 @@ LOCAL_MODULE_TAGS := tests
LOCAL_USE_AAPT2 := true
LOCAL_STATIC_JAVA_LIBRARIES := \
- cts-wm-app-base
+ cts-wm-app-base \
+ cts-background-activity-common
LOCAL_STATIC_ANDROID_LIBRARIES := \
androidx.legacy_legacy-support-v4
diff --git a/tests/framework/base/windowmanager/backgroundactivity/AppA/src/android/server/wm/backgroundactivity/appa/SendPendingIntentReceiver.java b/tests/framework/base/windowmanager/backgroundactivity/AppA/src/android/server/wm/backgroundactivity/appa/SendPendingIntentReceiver.java
index 3647be4a777..7ec1cc93977 100644
--- a/tests/framework/base/windowmanager/backgroundactivity/AppA/src/android/server/wm/backgroundactivity/appa/SendPendingIntentReceiver.java
+++ b/tests/framework/base/windowmanager/backgroundactivity/AppA/src/android/server/wm/backgroundactivity/appa/SendPendingIntentReceiver.java
@@ -23,11 +23,14 @@ import static android.server.wm.backgroundactivity.appa.Components.SendPendingIn
import static android.server.wm.backgroundactivity.appa.Components.StartBackgroundActivityReceiver.START_ACTIVITY_DELAY_MS_EXTRA;
import static android.server.wm.backgroundactivity.appb.Components.APP_B_START_PENDING_INTENT_RECEIVER;
import static android.server.wm.backgroundactivity.appb.Components.StartPendingIntentReceiver.PENDING_INTENT_EXTRA;
+import static android.server.wm.backgroundactivity.common.CommonComponents.EVENT_NOTIFIER_EXTRA;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.os.ResultReceiver;
+import android.server.wm.backgroundactivity.common.CommonComponents.Event;
/**
* Receive broadcast command to create a pendingIntent and send it to AppB.
@@ -38,6 +41,10 @@ public class SendPendingIntentReceiver extends BroadcastReceiver {
public void onReceive(Context context, Intent receivedIntent) {
boolean isBroadcast = receivedIntent.getBooleanExtra(IS_BROADCAST_EXTRA, false);
int startActivityDelayMs = receivedIntent.getIntExtra(START_ACTIVITY_DELAY_MS_EXTRA, 0);
+ ResultReceiver eventNotifier = receivedIntent.getParcelableExtra(EVENT_NOTIFIER_EXTRA);
+ if (eventNotifier != null) {
+ eventNotifier.send(Event.APP_A_SEND_PENDING_INTENT_BROADCAST_RECEIVED, null);
+ }
final PendingIntent pendingIntent;
if (isBroadcast) {
@@ -46,6 +53,7 @@ public class SendPendingIntentReceiver extends BroadcastReceiver {
Intent newIntent = new Intent();
newIntent.setComponent(APP_A_START_ACTIVITY_RECEIVER);
newIntent.putExtra(START_ACTIVITY_DELAY_MS_EXTRA, startActivityDelayMs);
+ newIntent.putExtra(EVENT_NOTIFIER_EXTRA, eventNotifier);
pendingIntent = PendingIntent.getBroadcast(context, 0,
newIntent, PendingIntent.FLAG_UPDATE_CURRENT);
} else {
@@ -53,7 +61,6 @@ public class SendPendingIntentReceiver extends BroadcastReceiver {
Intent newIntent = new Intent();
newIntent.setComponent(APP_A_BACKGROUND_ACTIVITY);
newIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
-
pendingIntent = PendingIntent.getActivity(context, 0,
newIntent, PendingIntent.FLAG_UPDATE_CURRENT);
}
@@ -62,6 +69,7 @@ public class SendPendingIntentReceiver extends BroadcastReceiver {
Intent intent = new Intent();
intent.setComponent(APP_B_START_PENDING_INTENT_RECEIVER);
intent.putExtra(PENDING_INTENT_EXTRA, pendingIntent);
+ intent.putExtra(EVENT_NOTIFIER_EXTRA, eventNotifier);
context.sendBroadcast(intent);
}
}
diff --git a/tests/framework/base/windowmanager/backgroundactivity/AppA/src/android/server/wm/backgroundactivity/appa/StartBackgroundActivityReceiver.java b/tests/framework/base/windowmanager/backgroundactivity/AppA/src/android/server/wm/backgroundactivity/appa/StartBackgroundActivityReceiver.java
index 844dd4f3b6b..0622a45fc5c 100644
--- a/tests/framework/base/windowmanager/backgroundactivity/AppA/src/android/server/wm/backgroundactivity/appa/StartBackgroundActivityReceiver.java
+++ b/tests/framework/base/windowmanager/backgroundactivity/AppA/src/android/server/wm/backgroundactivity/appa/StartBackgroundActivityReceiver.java
@@ -17,11 +17,14 @@
package android.server.wm.backgroundactivity.appa;
import static android.server.wm.backgroundactivity.appa.Components.StartBackgroundActivityReceiver.START_ACTIVITY_DELAY_MS_EXTRA;
+import static android.server.wm.backgroundactivity.common.CommonComponents.EVENT_NOTIFIER_EXTRA;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.os.ResultReceiver;
import android.os.SystemClock;
+import android.server.wm.backgroundactivity.common.CommonComponents.Event;
/**
* A class to help test case to start background activity.
@@ -30,6 +33,11 @@ public class StartBackgroundActivityReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
+ ResultReceiver eventNotifier = intent.getParcelableExtra(EVENT_NOTIFIER_EXTRA);
+ if (eventNotifier != null) {
+ eventNotifier.send(Event.APP_A_START_BACKGROUND_ACTIVITY_BROADCAST_RECEIVED, null);
+ }
+
if (!intent.hasExtra(START_ACTIVITY_DELAY_MS_EXTRA)) {
startActivityNow(context);
return;
diff --git a/tests/framework/base/windowmanager/backgroundactivity/AppB/Android.mk b/tests/framework/base/windowmanager/backgroundactivity/AppB/Android.mk
index 0398b746cf1..d6323703d90 100644
--- a/tests/framework/base/windowmanager/backgroundactivity/AppB/Android.mk
+++ b/tests/framework/base/windowmanager/backgroundactivity/AppB/Android.mk
@@ -22,7 +22,8 @@ LOCAL_MODULE_TAGS := tests
LOCAL_USE_AAPT2 := true
LOCAL_STATIC_JAVA_LIBRARIES := \
- cts-wm-app-base
+ cts-wm-app-base \
+ cts-background-activity-common
LOCAL_STATIC_ANDROID_LIBRARIES := \
androidx.legacy_legacy-support-v4
diff --git a/tests/framework/base/windowmanager/backgroundactivity/AppB/src/android/server/wm/backgroundactivity/appb/StartPendingIntentReceiver.java b/tests/framework/base/windowmanager/backgroundactivity/AppB/src/android/server/wm/backgroundactivity/appb/StartPendingIntentReceiver.java
index 830a61152a7..e8f6991c7c9 100644
--- a/tests/framework/base/windowmanager/backgroundactivity/AppB/src/android/server/wm/backgroundactivity/appb/StartPendingIntentReceiver.java
+++ b/tests/framework/base/windowmanager/backgroundactivity/AppB/src/android/server/wm/backgroundactivity/appb/StartPendingIntentReceiver.java
@@ -17,11 +17,14 @@
package android.server.wm.backgroundactivity.appb;
import static android.server.wm.backgroundactivity.appb.Components.StartPendingIntentReceiver.PENDING_INTENT_EXTRA;
+import static android.server.wm.backgroundactivity.common.CommonComponents.EVENT_NOTIFIER_EXTRA;
import android.app.PendingIntent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
+import android.os.ResultReceiver;
+import android.server.wm.backgroundactivity.common.CommonComponents.Event;
/**
* Receive pending intent from AppA and launch it
@@ -31,6 +34,11 @@ public class StartPendingIntentReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
PendingIntent pendingIntent = intent.getParcelableExtra(PENDING_INTENT_EXTRA);
+ ResultReceiver eventNotifier = intent.getParcelableExtra(EVENT_NOTIFIER_EXTRA);
+ if (eventNotifier != null) {
+ eventNotifier.send(Event.APP_B_START_PENDING_INTENT_BROADCAST_RECEIVED, null);
+ }
+
try {
pendingIntent.send();
} catch (PendingIntent.CanceledException e) {
diff --git a/tests/framework/base/windowmanager/backgroundactivity/common/Android.mk b/tests/framework/base/windowmanager/backgroundactivity/common/Android.mk
new file mode 100644
index 00000000000..a7eaad6ff58
--- /dev/null
+++ b/tests/framework/base/windowmanager/backgroundactivity/common/Android.mk
@@ -0,0 +1,32 @@
+# 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.
+
+LOCAL_PATH:= $(call my-dir)
+
+include $(CLEAR_VARS)
+
+# Don't include this package in any target.
+LOCAL_MODULE_TAGS := tests
+
+LOCAL_SRC_FILES := $(call all-java-files-under, src)
+
+LOCAL_STATIC_JAVA_LIBRARIES := \
+ androidx.annotation_annotation \
+ guava
+
+LOCAL_SDK_VERSION := test_current
+
+LOCAL_MODULE := cts-background-activity-common
+
+include $(BUILD_STATIC_JAVA_LIBRARY)
diff --git a/tests/framework/base/windowmanager/backgroundactivity/common/src/android/server/wm/backgroundactivity/common/CommonComponents.java b/tests/framework/base/windowmanager/backgroundactivity/common/src/android/server/wm/backgroundactivity/common/CommonComponents.java
new file mode 100644
index 00000000000..1981ffb28ec
--- /dev/null
+++ b/tests/framework/base/windowmanager/backgroundactivity/common/src/android/server/wm/backgroundactivity/common/CommonComponents.java
@@ -0,0 +1,42 @@
+/*
+ * 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.
+ */
+
+package android.server.wm.backgroundactivity.common;
+
+import androidx.annotation.IntDef;
+
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+
+/**
+ * Constant-holding class common to AppA, AppB and tests.
+ */
+public class CommonComponents {
+
+ public static final String EVENT_NOTIFIER_EXTRA = "EVENT_NOTIFIER_EXTRA";
+
+ @IntDef({
+ Event.APP_A_SEND_PENDING_INTENT_BROADCAST_RECEIVED,
+ Event.APP_B_START_PENDING_INTENT_BROADCAST_RECEIVED,
+ Event.APP_A_START_BACKGROUND_ACTIVITY_BROADCAST_RECEIVED,
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ public @interface Event {
+ int APP_A_SEND_PENDING_INTENT_BROADCAST_RECEIVED = 0;
+ int APP_B_START_PENDING_INTENT_BROADCAST_RECEIVED = 1;
+ int APP_A_START_BACKGROUND_ACTIVITY_BROADCAST_RECEIVED = 2;
+ }
+}
diff --git a/tests/framework/base/windowmanager/backgroundactivity/common/src/android/server/wm/backgroundactivity/common/EventReceiver.java b/tests/framework/base/windowmanager/backgroundactivity/common/src/android/server/wm/backgroundactivity/common/EventReceiver.java
new file mode 100644
index 00000000000..4812fa6097d
--- /dev/null
+++ b/tests/framework/base/windowmanager/backgroundactivity/common/src/android/server/wm/backgroundactivity/common/EventReceiver.java
@@ -0,0 +1,70 @@
+/*
+ * 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.
+ */
+
+package android.server.wm.backgroundactivity.common;
+
+import static com.google.common.base.Preconditions.checkState;
+
+import android.os.Bundle;
+import android.os.ConditionVariable;
+import android.os.Handler;
+import android.os.Looper;
+import android.os.ResultReceiver;
+import android.server.wm.backgroundactivity.common.CommonComponents.Event;
+
+import java.util.concurrent.TimeoutException;
+
+/**
+ * Class used to register for events sent via IPC using {@link #getNotifier()} parcelable.
+ *
+ * Create an instance for the event of interest, pass {@link #getNotifier()} to the target, either
+ * via some AIDL or intent extra, have the caller call {@link ResultReceiver#send(int, Bundle)},
+ * then finally wait for the event with {@link #waitForEventOrThrow(long)}.
+ */
+public class EventReceiver {
+ private final Handler mHandler = new Handler(Looper.getMainLooper());
+ private final ConditionVariable mEventReceivedVariable = new ConditionVariable(false);
+
+ @Event
+ private final int mEvent;
+
+ public EventReceiver(@Event int event) {
+ mEvent = event;
+ }
+
+ public ResultReceiver getNotifier() {
+ return new ResultReceiver(mHandler) {
+ @Override
+ protected void onReceiveResult(@Event int event, Bundle data) {
+ if (event == mEvent) {
+ mEventReceivedVariable.open();
+ }
+ }
+ };
+ }
+
+ /**
+ * Waits for registered event or throws {@link TimeoutException}.
+ */
+ public void waitForEventOrThrow(long timeoutMs) throws TimeoutException {
+ // Avoid deadlocks
+ checkState(Thread.currentThread() != mHandler.getLooper().getThread());
+
+ if (!mEventReceivedVariable.block(timeoutMs)) {
+ throw new TimeoutException("Timed out waiting for event " + mEvent);
+ }
+ }
+}
diff --git a/tests/framework/base/windowmanager/backgroundactivity/src/android/server/wm/BackgroundActivityLaunchTest.java b/tests/framework/base/windowmanager/backgroundactivity/src/android/server/wm/BackgroundActivityLaunchTest.java
index b1a559f3c3d..d3ff1a1600c 100644
--- a/tests/framework/base/windowmanager/backgroundactivity/src/android/server/wm/BackgroundActivityLaunchTest.java
+++ b/tests/framework/base/windowmanager/backgroundactivity/src/android/server/wm/BackgroundActivityLaunchTest.java
@@ -38,6 +38,7 @@ import static android.server.wm.backgroundactivity.appa.Components.ForegroundAct
import static android.server.wm.backgroundactivity.appa.Components.SendPendingIntentReceiver.IS_BROADCAST_EXTRA;
import static android.server.wm.backgroundactivity.appa.Components.StartBackgroundActivityReceiver.START_ACTIVITY_DELAY_MS_EXTRA;
import static android.server.wm.backgroundactivity.appb.Components.APP_B_FOREGROUND_ACTIVITY;
+import static android.server.wm.backgroundactivity.common.CommonComponents.EVENT_NOTIFIER_EXTRA;
import static com.android.compatibility.common.util.SystemUtil.runShellCommand;
import static com.android.compatibility.common.util.SystemUtil.runWithShellPermissionIdentity;
@@ -54,9 +55,13 @@ import android.app.ActivityTaskManager;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.PackageManager;
+import android.os.ResultReceiver;
import android.os.SystemClock;
import android.platform.test.annotations.Presubmit;
+import android.server.wm.backgroundactivity.common.CommonComponents.Event;
+import android.server.wm.backgroundactivity.common.EventReceiver;
+import androidx.annotation.Nullable;
import androidx.test.InstrumentationRegistry;
import androidx.test.filters.FlakyTest;
@@ -67,6 +72,7 @@ import org.junit.Before;
import org.junit.Test;
import java.util.List;
+import java.util.concurrent.TimeoutException;
/**
* This class covers all test cases for starting/blocking background activities.
@@ -85,6 +91,12 @@ public class BackgroundActivityLaunchTest extends ActivityManagerTestBase {
private static final String TEST_PACKAGE_APP_A = "android.server.wm.backgroundactivity.appa";
private static final String TEST_PACKAGE_APP_B = "android.server.wm.backgroundactivity.appb";
+ /**
+ * Tests can be executed as soon as the device has booted. When that happens the broadcast queue
+ * is long and it takes some time to process the broadcast we just sent.
+ */
+ private static final int BROADCAST_DELIVERY_TIMEOUT_MS = 25000;
+
@Before
public void setUp() throws Exception {
mContext = InstrumentationRegistry.getContext();
@@ -372,9 +384,16 @@ public class BackgroundActivityLaunchTest extends ActivityManagerTestBase {
@Test
public void testPendingIntentBroadcast_appBIsBackground() throws Exception {
+ EventReceiver receiver = new EventReceiver(
+ Event.APP_A_START_BACKGROUND_ACTIVITY_BROADCAST_RECEIVED);
+
// Send pendingIntent from AppA to AppB, and the AppB launch the pending intent to start
// activity in App A
- sendPendingIntentBroadcast(0);
+ sendPendingIntentBroadcast(0, receiver.getNotifier());
+
+ // Waits for final hoop in AppA to start looking for activity, otherwise it could succeed
+ // if the broadcast took long time to get executed (which may happen after boot).
+ receiver.waitForEventOrThrow(BROADCAST_DELIVERY_TIMEOUT_MS);
boolean result = waitForActivityFocused(APP_A_BACKGROUND_ACTIVITY);
assertFalse("Should not able to launch background activity", result);
assertTaskStack(null, APP_A_BACKGROUND_ACTIVITY);
@@ -391,9 +410,16 @@ public class BackgroundActivityLaunchTest extends ActivityManagerTestBase {
String cmdResult = runShellCommand("dpm set-device-owner --user cur "
+ APP_A_SIMPLE_ADMIN_RECEIVER.flattenToString());
assertThat(cmdResult).contains("Success");
+ EventReceiver receiver = new EventReceiver(
+ Event.APP_A_START_BACKGROUND_ACTIVITY_BROADCAST_RECEIVED);
Intent intent = new Intent();
intent.setComponent(APP_A_START_ACTIVITY_RECEIVER);
+ intent.putExtra(EVENT_NOTIFIER_EXTRA, receiver.getNotifier());
+
mContext.sendBroadcast(intent);
+
+ // Waits for final hoop in AppA to start looking for activity
+ receiver.waitForEventOrThrow(BROADCAST_DELIVERY_TIMEOUT_MS);
boolean result = waitForActivityFocused(APP_A_BACKGROUND_ACTIVITY);
assertTrue("Not able to launch background activity", result);
assertTaskStack(new ComponentName[]{APP_A_BACKGROUND_ACTIVITY}, APP_A_BACKGROUND_ACTIVITY);
@@ -414,7 +440,8 @@ public class BackgroundActivityLaunchTest extends ActivityManagerTestBase {
}
}
- private void assertPendingIntentBroadcastTimeoutTest(int delayMs, boolean expectedResult) {
+ private void assertPendingIntentBroadcastTimeoutTest(int delayMs, boolean expectedResult)
+ throws TimeoutException {
// Start AppB foreground activity
Intent intent = new Intent();
intent.setComponent(APP_B_FOREGROUND_ACTIVITY);
@@ -423,10 +450,15 @@ public class BackgroundActivityLaunchTest extends ActivityManagerTestBase {
boolean result = waitForActivityFocused(APP_B_FOREGROUND_ACTIVITY);
assertTrue("Not able to start foreground Activity", result);
assertTaskStack(new ComponentName[]{APP_B_FOREGROUND_ACTIVITY}, APP_B_FOREGROUND_ACTIVITY);
+ EventReceiver receiver = new EventReceiver(
+ Event.APP_A_START_BACKGROUND_ACTIVITY_BROADCAST_RECEIVED);
// Send pendingIntent from AppA to AppB, and the AppB launch the pending intent to start
// activity in App A
- sendPendingIntentBroadcast(delayMs);
+ sendPendingIntentBroadcast(delayMs, receiver.getNotifier());
+
+ // Waits for final hoop in AppA to start looking for activity
+ receiver.waitForEventOrThrow(BROADCAST_DELIVERY_TIMEOUT_MS);
result = waitForActivityFocused(ACTIVITY_FOCUS_TIMEOUT_MS + delayMs,
APP_A_BACKGROUND_ACTIVITY);
assertEquals(expectedResult, result);
@@ -468,13 +500,14 @@ public class BackgroundActivityLaunchTest extends ActivityManagerTestBase {
mContext.sendBroadcast(intent);
}
- private void sendPendingIntentBroadcast(int delayMs) {
+ private void sendPendingIntentBroadcast(int delayMs, @Nullable ResultReceiver eventNotifier) {
Intent intent = new Intent();
intent.setComponent(APP_A_SEND_PENDING_INTENT_RECEIVER);
intent.putExtra(IS_BROADCAST_EXTRA, true);
if (delayMs > 0) {
intent.putExtra(START_ACTIVITY_DELAY_MS_EXTRA, delayMs);
}
+ intent.putExtra(EVENT_NOTIFIER_EXTRA, eventNotifier);
mContext.sendBroadcast(intent);
}
}
diff --git a/tests/framework/base/windowmanager/src/android/server/wm/ManifestLayoutTests.java b/tests/framework/base/windowmanager/src/android/server/wm/ManifestLayoutTests.java
index 40869784c8d..bc348391cb9 100644
--- a/tests/framework/base/windowmanager/src/android/server/wm/ManifestLayoutTests.java
+++ b/tests/framework/base/windowmanager/src/android/server/wm/ManifestLayoutTests.java
@@ -141,22 +141,23 @@ public class ManifestLayoutTests extends ActivityManagerTestBase {
getDisplayAndWindowState(activityName, true);
final Rect containingRect = mWindowState.getContainingFrame();
- final Rect appRect = mDisplay.getAppRect();
+ final Rect displayRect = new Rect(mDisplay.getDisplayRect());
final int expectedWidthPx, expectedHeightPx;
// Evaluate the expected window size in px. If we're using fraction dimensions,
// calculate the size based on the app rect size. Otherwise, convert the expected
// size in dp to px.
if (fraction) {
- expectedWidthPx = (int) (appRect.width() * DEFAULT_WIDTH_FRACTION);
- expectedHeightPx = (int) (appRect.height() * DEFAULT_HEIGHT_FRACTION);
+ expectedWidthPx = (int) (displayRect.width() * DEFAULT_WIDTH_FRACTION);
+ expectedHeightPx = (int) (displayRect.height() * DEFAULT_HEIGHT_FRACTION);
} else {
final int densityDpi = mDisplay.getDpi();
expectedWidthPx = dpToPx(DEFAULT_WIDTH_DP, densityDpi);
expectedHeightPx = dpToPx(DEFAULT_HEIGHT_DP, densityDpi);
}
+ displayRect.top = mDisplay.getStableBounds().top;
verifyFrameSizeAndPosition(
- vGravity, hGravity, expectedWidthPx, expectedHeightPx, containingRect, appRect);
+ vGravity, hGravity, expectedWidthPx, expectedHeightPx, containingRect, displayRect);
}
private void getDisplayAndWindowState(ComponentName activityName, boolean checkFocus)
diff --git a/tests/framework/base/windowmanager/util/src/android/server/wm/WindowManagerState.java b/tests/framework/base/windowmanager/util/src/android/server/wm/WindowManagerState.java
index 0ca27489b6d..0cdcaf257a0 100644
--- a/tests/framework/base/windowmanager/util/src/android/server/wm/WindowManagerState.java
+++ b/tests/framework/base/windowmanager/util/src/android/server/wm/WindowManagerState.java
@@ -799,6 +799,10 @@ public class WindowManagerState {
return mAppRect;
}
+ Rect getStableBounds() {
+ return mStableBounds;
+ }
+
String getName() {
return mName;
}
diff --git a/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java b/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java
index 39ec71381a5..9268f3170bc 100644
--- a/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java
+++ b/tests/tests/content/src/android/content/cts/AvailableIntentsTest.java
@@ -360,10 +360,10 @@ public class AvailableIntentsTest extends AndroidTestCase {
}
public void testUsageAccessSettings() {
- PackageManager packageManager = mContext.getPackageManager();
- if (!packageManager.hasSystemFeature(PackageManager.FEATURE_WATCH)) {
- assertCanBeHandled(new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS));
+ if (!isHandheld()) {
+ return;
}
+ assertCanBeHandled(new Intent(Settings.ACTION_USAGE_ACCESS_SETTINGS));
}
public void testPictureInPictureSettings() {
@@ -421,6 +421,9 @@ public class AvailableIntentsTest extends AndroidTestCase {
@CddTest(requirement = "7.4.2.6/C-1-1")
public void testEasyConnectIntent() {
+ if (!isHandheld()) {
+ return;
+ }
WifiManager manager = mContext.getSystemService(WifiManager.class);
if (manager.isEasyConnectSupported()) {
@@ -454,6 +457,9 @@ public class AvailableIntentsTest extends AndroidTestCase {
}
public void testVoiceInputSettingsIntent() {
+ if (!isHandheld()) {
+ return;
+ }
Intent intent = new Intent(Settings.ACTION_VOICE_INPUT_SETTINGS);
assertCanBeHandled(intent);
}
diff --git a/tests/tests/text/src/android/text/method/cts/ScrollingMovementMethodTest.java b/tests/tests/text/src/android/text/method/cts/ScrollingMovementMethodTest.java
index e19dfe84e73..34ffd767a99 100644
--- a/tests/tests/text/src/android/text/method/cts/ScrollingMovementMethodTest.java
+++ b/tests/tests/text/src/android/text/method/cts/ScrollingMovementMethodTest.java
@@ -263,8 +263,18 @@ public class ScrollingMovementMethodTest {
assertTrue(mTextView.getScrollY() > previousScrollY);
assertTrue(mTextView.getScrollX() < bottom);
+ assertTrue(getActionResult(new ActionRunnerWithResult() {
+ public void run() {
+ // move back up for the next test
+ mResult = method.onTouchEvent(mTextView, mSpannable, MotionEvent.obtain(now, now,
+ MotionEvent.ACTION_MOVE, 0, -distFar, 0));
+ }
+ }));
+
previousScrollY = mTextView.getScrollY();
- final int distTooFar = (int) (-bottom * 10);
+ // further detracting mScaledTouchSlop from (-bottom * 10) so it is guaranteed to be
+ // greater than the touch slop value.
+ final int distTooFar = (int) (-bottom * 10) - mScaledTouchSlop;
assertTrue(getActionResult(new ActionRunnerWithResult() {
public void run() {
// move for long distance