Merge "Make sure saveReentryState works." into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
ad43ac1e9d
@@ -1060,13 +1060,22 @@ public class PipController implements PipTransitionController.PipTransitionCallb
|
||||
/** Save the state to restore to on re-entry. */
|
||||
public void saveReentryState(Rect pipBounds) {
|
||||
float snapFraction = mPipBoundsAlgorithm.getSnapFraction(pipBounds);
|
||||
if (mPipBoundsState.hasUserResizedPip()) {
|
||||
final Rect reentryBounds = mTouchHandler.getUserResizeBounds();
|
||||
final Size reentrySize = new Size(reentryBounds.width(), reentryBounds.height());
|
||||
mPipBoundsState.saveReentryState(reentrySize, snapFraction);
|
||||
} else {
|
||||
|
||||
if (!mPipBoundsState.hasUserResizedPip()) {
|
||||
mPipBoundsState.saveReentryState(null /* bounds */, snapFraction);
|
||||
return;
|
||||
}
|
||||
|
||||
Size reentrySize = new Size(pipBounds.width(), pipBounds.height());
|
||||
|
||||
// TODO: b/279937014 Investigate why userResizeBounds are empty with shell transitions on
|
||||
// fallback to using the userResizeBounds if userResizeBounds are not empty
|
||||
if (!mTouchHandler.getUserResizeBounds().isEmpty()) {
|
||||
Rect userResizeBounds = mTouchHandler.getUserResizeBounds();
|
||||
reentrySize = new Size(userResizeBounds.width(), userResizeBounds.height());
|
||||
}
|
||||
|
||||
mPipBoundsState.saveReentryState(reentrySize, snapFraction);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -268,7 +268,7 @@ public class PipControllerTest extends ShellTestCase {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void saveReentryState_userHasResized_savesSize() {
|
||||
public void saveReentryState_nonEmptyUserResizeBounds_savesSize() {
|
||||
final Rect bounds = new Rect(0, 0, 10, 10);
|
||||
final Rect resizedBounds = new Rect(0, 0, 30, 30);
|
||||
when(mMockPipBoundsAlgorithm.getSnapFraction(bounds)).thenReturn(1.0f);
|
||||
@@ -280,6 +280,19 @@ public class PipControllerTest extends ShellTestCase {
|
||||
verify(mMockPipBoundsState).saveReentryState(new Size(30, 30), 1.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void saveReentryState_emptyUserResizeBounds_savesSize() {
|
||||
final Rect bounds = new Rect(0, 0, 10, 10);
|
||||
final Rect resizedBounds = new Rect(0, 0, 0, 0);
|
||||
when(mMockPipBoundsAlgorithm.getSnapFraction(bounds)).thenReturn(1.0f);
|
||||
when(mMockPipTouchHandler.getUserResizeBounds()).thenReturn(resizedBounds);
|
||||
when(mMockPipBoundsState.hasUserResizedPip()).thenReturn(true);
|
||||
|
||||
mPipController.saveReentryState(bounds);
|
||||
|
||||
verify(mMockPipBoundsState).saveReentryState(new Size(10, 10), 1.0f);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void onDisplayConfigurationChanged_inPip_movePip() {
|
||||
final int displayId = 1;
|
||||
|
||||
Reference in New Issue
Block a user