WindowInsetsLayoutTests: Launch TestActivity in fullscreen mode
To test the system bar insets, WindowInsetsLayoutTests assert that the
activity size matches the size of the display. This is true in
fullscreen windowing mode, but is not necessarily true in other
windowing modes like freeform, where the window size can differ from the
display size.
We launch the TestActivity in fullscreen windowing mode to fulfill the
assumption that the window size will always be the same as the display
size.
Bug: 168783728
Test: atest android.server.wm.WindowInsetsLayoutTests
Change-Id: Ie575fdaf6884497d125ab024b87ed09e085c6502
diff --git a/tests/framework/base/windowmanager/src/android/server/wm/WindowInsetsAnimationImeTests.java b/tests/framework/base/windowmanager/src/android/server/wm/WindowInsetsAnimationImeTests.java
index da7a534..70c299d 100644
--- a/tests/framework/base/windowmanager/src/android/server/wm/WindowInsetsAnimationImeTests.java
+++ b/tests/framework/base/windowmanager/src/android/server/wm/WindowInsetsAnimationImeTests.java
@@ -18,7 +18,6 @@
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.graphics.Insets.NONE;
-import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowInsets.Type.ime;
import static android.view.WindowInsets.Type.navigationBars;
import static android.view.WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS;
@@ -72,8 +71,7 @@
private void initActivity(boolean useFloating) throws Exception {
initMockImeSession(useFloating);
- mActivity = startActivity(TestActivity.class, DEFAULT_DISPLAY, true,
- WINDOWING_MODE_FULLSCREEN);
+ mActivity = startActivityInWindowingMode(TestActivity.class, WINDOWING_MODE_FULLSCREEN);
mRootView = mActivity.getWindow().getDecorView();
}
diff --git a/tests/framework/base/windowmanager/src/android/server/wm/WindowInsetsLayoutTests.java b/tests/framework/base/windowmanager/src/android/server/wm/WindowInsetsLayoutTests.java
index 91e1748..209d2ed 100644
--- a/tests/framework/base/windowmanager/src/android/server/wm/WindowInsetsLayoutTests.java
+++ b/tests/framework/base/windowmanager/src/android/server/wm/WindowInsetsLayoutTests.java
@@ -16,6 +16,7 @@
package android.server.wm;
+import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import static android.view.WindowManager.LayoutParams.FLAG_NOT_FOCUSABLE;
import static android.view.WindowManager.LayoutParams.LAYOUT_IN_DISPLAY_CUTOUT_MODE_ALWAYS;
@@ -39,7 +40,6 @@
import com.android.compatibility.common.util.PollingCheck;
-import org.junit.Ignore;
import org.junit.Test;
/**
@@ -57,7 +57,9 @@
@Test
public void testSetFitInsetsTypes() {
- final TestActivity activity = startActivity(TestActivity.class);
+ // Start the Activity in fullscreen windowing mode for its bounds to match display bounds.
+ final TestActivity activity =
+ startActivityInWindowingMode(TestActivity.class, WINDOWING_MODE_FULLSCREEN);
// Make sure the main window has been laid out.
final View mainWindowRoot = activity.getWindow().getDecorView();
@@ -99,7 +101,9 @@
@Test
public void testSetFitInsetsSides() {
- final TestActivity activity = startActivity(TestActivity.class);
+ // Start the Activity in fullscreen windowing mode for its bounds to match display bounds.
+ final TestActivity activity =
+ startActivityInWindowingMode(TestActivity.class, WINDOWING_MODE_FULLSCREEN);
// Make sure the main window has been laid out.
final View mainWindowRoot = activity.getWindow().getDecorView();
@@ -143,7 +147,9 @@
@Test
public void testSetFitInsetsIgnoringVisibility() {
- final TestActivity activity = startActivity(TestActivity.class);
+ // Start the Activity in fullscreen windowing mode for its bounds to match display bounds.
+ final TestActivity activity =
+ startActivityInWindowingMode(TestActivity.class, WINDOWING_MODE_FULLSCREEN);
// Make sure the main window has been laid out.
final View mainWindowRoot = activity.getWindow().getDecorView();
diff --git a/tests/framework/base/windowmanager/src/android/server/wm/WindowManagerTestBase.java b/tests/framework/base/windowmanager/src/android/server/wm/WindowManagerTestBase.java
index 10e4423..0cf96d8 100644
--- a/tests/framework/base/windowmanager/src/android/server/wm/WindowManagerTestBase.java
+++ b/tests/framework/base/windowmanager/src/android/server/wm/WindowManagerTestBase.java
@@ -37,8 +37,6 @@
import org.junit.Before;
import java.lang.reflect.Array;
-import java.util.ArrayList;
-import java.util.List;
import javax.annotation.concurrent.GuardedBy;
@@ -56,11 +54,20 @@
return startActivity(cls, DEFAULT_DISPLAY);
}
- static <T extends FocusableActivity> T startActivity(Class<T> cls, int displayId,
- boolean hasFocus) {
+ static <T extends FocusableActivity> T startActivity(Class<T> cls, int displayId) {
+ return startActivity(cls, displayId, true /* hasFocus */);
+ }
+
+ static <T extends FocusableActivity> T startActivity(
+ Class<T> cls, int displayId, boolean hasFocus) {
return startActivity(cls, displayId, hasFocus, WINDOWING_MODE_UNDEFINED);
}
+ static <T extends FocusableActivity> T startActivityInWindowingMode(
+ Class<T> cls, int windowingMode) {
+ return startActivity(cls, DEFAULT_DISPLAY, true /* hasFocus */, windowingMode);
+ }
+
static <T extends FocusableActivity> T startActivity(Class<T> cls, int displayId,
boolean hasFocus, int windowingMode) {
final Bundle options;
@@ -82,10 +89,6 @@
return activity[0];
}
- static <T extends FocusableActivity> T startActivity(Class<T> cls, int displayId) {
- return startActivity(cls, displayId, true /* hasFocus */);
- }
-
static class FocusableActivity extends Activity {
private final Object mLockWindowFocus = new Object();