summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Yunfan Chen <yunfanc@google.com> 2019-01-17 07:01:49 +0000
committer Yunfan Chen <yunfanc@google.com> 2019-01-17 07:01:49 +0000
commitf93c06f43c8b7ae05276f227b22164fe64ec09c4 (patch)
tree9ca6f26ed38cca527223fa3fa0bed0be4acba459
parent0b9b1d420a6aed3284c0cd6e78d5f147e62f2c42 (diff)
Revert "Remove failure test that broke presubmit and build"
This reverts commit 0b9b1d420a6aed3284c0cd6e78d5f147e62f2c42. Reason for revert: The test fail is caused by a non-clean local phone. Clean the data and the test can pass. Change-Id: I5eaf721465aa91720296b427efa30b0dfe8fef63
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java53
1 files changed, 53 insertions, 0 deletions
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java
index cdb578d23725..99be50be642e 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskRecordTests.java
@@ -25,6 +25,13 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
+import static com.android.dx.mockito.inline.extended.ExtendedMockito.any;
+import static com.android.dx.mockito.inline.extended.ExtendedMockito.anyBoolean;
+import static com.android.dx.mockito.inline.extended.ExtendedMockito.anyInt;
+import static com.android.dx.mockito.inline.extended.ExtendedMockito.doAnswer;
+import static com.android.dx.mockito.inline.extended.ExtendedMockito.doCallRealMethod;
+import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
+import static com.android.dx.mockito.inline.extended.ExtendedMockito.mock;
import static com.android.server.wm.WindowContainer.POSITION_TOP;
import static org.hamcrest.Matchers.not;
@@ -46,6 +53,7 @@ import android.platform.test.annotations.Presubmit;
import android.service.voice.IVoiceInteractionSession;
import android.util.Xml;
import android.view.DisplayInfo;
+import android.view.Surface;
import androidx.test.filters.MediumTest;
@@ -276,6 +284,51 @@ public class TaskRecordTests extends ActivityTestsBase {
assertEquals(freeformBounds, task.getBounds());
}
+ @Test
+ public void testUpdatesForcedOrientationInBackground() {
+ final DisplayInfo info = new DisplayInfo();
+ info.logicalWidth = 1920;
+ info.logicalHeight = 1080;
+ final ActivityDisplay display = addNewActivityDisplayAt(info, POSITION_TOP);
+ doCallRealMethod().when(display.mDisplayContent).setDisplayRotation(any());
+ display.mDisplayContent.setDisplayRotation(mock(DisplayRotation.class));
+ doCallRealMethod().when(display.mDisplayContent).onDescendantOrientationChanged(any(),
+ any());
+ doCallRealMethod().when(display.mDisplayContent).setRotation(anyInt());
+ doAnswer(invocation -> {
+ display.mDisplayContent.setRotation(Surface.ROTATION_0);
+ return null;
+ }).when(display.mDisplayContent).updateOrientationFromAppTokens(any(), any(), anyBoolean());
+
+ final ActivityStack stack = new StackBuilder(mRootActivityContainer)
+ .setWindowingMode(WINDOWING_MODE_FULLSCREEN).setDisplay(display).build();
+ final TaskRecord task = stack.getChildAt(0);
+ final ActivityRecord activity = task.getRootActivity();
+
+ // Wire up app window token and task.
+ doCallRealMethod().when(activity.mAppWindowToken).setOrientation(anyInt(), any(), any());
+ doCallRealMethod().when(activity.mAppWindowToken).onDescendantOrientationChanged(any(),
+ any());
+ doReturn(task.mTask).when(activity.mAppWindowToken).getParent();
+
+ // Wire up task and stack.
+ task.mTask.mTaskRecord = task;
+ doCallRealMethod().when(task.mTask).onDescendantOrientationChanged(any(), any());
+ doReturn(stack.getTaskStack()).when(task.mTask).getParent();
+
+ // Wire up stack and display content.
+ doCallRealMethod().when(stack.mTaskStack).onDescendantOrientationChanged(any(), any());
+ doReturn(display.mDisplayContent).when(stack.mTaskStack).getParent();
+
+ activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
+ assertTrue("Bounds of the task should be pillarboxed.",
+ task.getBounds().width() < task.getBounds().height());
+
+ activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
+ assertTrue("Bounds of the task should be fullscreen.",
+ task.getBounds().equals(new Rect(0, 0, 1920, 1080)));
+ }
+
/** Ensures that the alias intent won't have target component resolved. */
@Test
public void testTaskIntentActivityAlias() {