Tests for computeFrameLw docked type scenarios.

Add some computeFrameLw unit tests for non fullscreen
windows. A test a day keeps the chase-list away.

Test: bit FrameworksServicesTests:com.android.server.wm.WindowFrameTests
Change-Id: Ifd7c07f5d174b35aa73b78ddc3432520fb096bf9
This commit is contained in:
Robert Carr
2016-11-03 14:26:58 -07:00
parent 573cccfea7
commit 15dd7efeb7

View File

@@ -66,6 +66,8 @@ public class WindowFrameTests {
class TaskWithBounds extends Task {
final Rect mBounds;
final Rect mInsetBounds = new Rect();
boolean mFullscreenForTest = true;
TaskWithBounds(Rect bounds) {
super(0, mStubStack, 0, sWm, null, null, false);
mBounds = bounds;
@@ -76,11 +78,11 @@ public class WindowFrameTests {
}
@Override
void getTempInsetBounds(Rect outBounds) {
outBounds.setEmpty();
outBounds.set(mInsetBounds);
}
@Override
boolean isFullscreen() {
return true;
return mFullscreenForTest;
}
}
@@ -237,6 +239,41 @@ public class WindowFrameTests {
assertRect(w.mFrame, 600, 600, 900, 900);
}
@Test
public void testLayoutNonfullscreenTask() {
final Rect taskBounds = new Rect(300, 300, 700, 700);
TaskWithBounds task = new TaskWithBounds(taskBounds);
task.mFullscreenForTest = false;
WindowState w = createWindow(task, FILL_PARENT, FILL_PARENT);
w.mAttrs.gravity = Gravity.LEFT | Gravity.TOP;
final Rect pf = new Rect(0, 0, 1000, 1000);
w.computeFrameLw(pf, pf, pf, pf, pf, pf, pf, null);
// For non fullscreen tasks the containing frame is based off the
// task bounds not the parent frame.
assertRect(w.mFrame, 300, 300, 700, 700);
assertRect(w.getContentFrameLw(), 300, 300, 700, 700);
assertRect(w.mContentInsets, 0, 0, 0, 0);
pf.set(0, 0, 1000, 1000);
// We still produce insets against the containing frame the same way.
final Rect cf = new Rect(0, 0, 500, 500);
w.computeFrameLw(pf, pf, pf, cf, cf, pf, cf, null);
assertRect(w.mFrame, 300, 300, 700, 700);
assertRect(w.getContentFrameLw(), 300, 300, 500, 500);
assertRect(w.mContentInsets, 0, 0, 200, 200);
pf.set(0, 0, 1000, 1000);
// However if we set temp inset bounds, the insets will be computed
// as if our window was laid out there, but it will be laid out according to
// the task bounds.
task.mInsetBounds.set(200, 200, 600, 600);
w.computeFrameLw(pf, pf, pf, cf, cf, pf, cf, null);
assertRect(w.mFrame, 300, 300, 700, 700);
assertRect(w.getContentFrameLw(), 300, 300, 600, 600);
assertRect(w.mContentInsets, 0, 0, 100, 100);
}
private WindowState createWindow(Task task, int width, int height) {
final WindowManager.LayoutParams attrs = new WindowManager.LayoutParams(TYPE_APPLICATION);
attrs.width = width;