Merge "Fix the flaky AccessibilityMagnificationTest#testListener" into tm-dev am: 840f39893e
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/17183452 Change-Id: Id946c5d2857aba66c4e8279d1456c8685993704a
This commit is contained in:
@@ -254,8 +254,8 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
|
|||||||
|
|
||||||
mMirrorViewGeometryVsyncCallback =
|
mMirrorViewGeometryVsyncCallback =
|
||||||
l -> {
|
l -> {
|
||||||
if (isWindowVisible() && mMirrorSurface != null) {
|
if (isWindowVisible() && mMirrorSurface != null && calculateSourceBounds(
|
||||||
calculateSourceBounds(mMagnificationFrame, mScale);
|
mMagnificationFrame, mScale)) {
|
||||||
// The final destination for the magnification surface should be at 0,0
|
// The final destination for the magnification surface should be at 0,0
|
||||||
// since the ViewRootImpl's position will change
|
// since the ViewRootImpl's position will change
|
||||||
mTmpRect.set(0, 0, mMagnificationFrame.width(),
|
mTmpRect.set(0, 0, mMagnificationFrame.width(),
|
||||||
@@ -350,6 +350,7 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
|
|||||||
mMirrorWindowControl.destroyControl();
|
mMirrorWindowControl.destroyControl();
|
||||||
}
|
}
|
||||||
mMirrorViewBounds.setEmpty();
|
mMirrorViewBounds.setEmpty();
|
||||||
|
mSourceBounds.setEmpty();
|
||||||
updateSystemUIStateIfNeeded();
|
updateSystemUIStateIfNeeded();
|
||||||
mContext.unregisterComponentCallbacks(this);
|
mContext.unregisterComponentCallbacks(this);
|
||||||
}
|
}
|
||||||
@@ -728,8 +729,12 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
|
|||||||
/**
|
/**
|
||||||
* Calculates the desired source bounds. This will be the area under from the center of the
|
* Calculates the desired source bounds. This will be the area under from the center of the
|
||||||
* displayFrame, factoring in scale.
|
* displayFrame, factoring in scale.
|
||||||
|
*
|
||||||
|
* @return {@code true} if the source bounds is changed.
|
||||||
*/
|
*/
|
||||||
private void calculateSourceBounds(Rect displayFrame, float scale) {
|
private boolean calculateSourceBounds(Rect displayFrame, float scale) {
|
||||||
|
final Rect oldSourceBounds = mTmpRect;
|
||||||
|
oldSourceBounds.set(mSourceBounds);
|
||||||
int halfWidth = displayFrame.width() / 2;
|
int halfWidth = displayFrame.width() / 2;
|
||||||
int halfHeight = displayFrame.height() / 2;
|
int halfHeight = displayFrame.height() / 2;
|
||||||
int left = displayFrame.left + (halfWidth - (int) (halfWidth / scale));
|
int left = displayFrame.left + (halfWidth - (int) (halfWidth / scale));
|
||||||
@@ -757,6 +762,7 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
|
|||||||
mSourceBounds.offsetTo(mSourceBounds.left,
|
mSourceBounds.offsetTo(mSourceBounds.left,
|
||||||
mWindowBounds.height() - mSourceBounds.height());
|
mWindowBounds.height() - mSourceBounds.height());
|
||||||
}
|
}
|
||||||
|
return !mSourceBounds.equals(oldSourceBounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void calculateMagnificationFrameBoundary() {
|
private void calculateMagnificationFrameBoundary() {
|
||||||
@@ -1079,7 +1085,7 @@ class WindowMagnificationController implements View.OnTouchListener, SurfaceHold
|
|||||||
pw.println(" mMagnificationFrame:"
|
pw.println(" mMagnificationFrame:"
|
||||||
+ (isWindowVisible() ? mMagnificationFrame : "empty"));
|
+ (isWindowVisible() ? mMagnificationFrame : "empty"));
|
||||||
pw.println(" mSourceBounds:"
|
pw.println(" mSourceBounds:"
|
||||||
+ (isWindowVisible() ? mSourceBounds : "empty"));
|
+ (mSourceBounds.isEmpty() ? "empty" : mSourceBounds));
|
||||||
pw.println(" mSystemGestureTop:" + mSystemGestureTop);
|
pw.println(" mSystemGestureTop:" + mSystemGestureTop);
|
||||||
pw.println(" mMagnificationFrameOffsetX:" + mMagnificationFrameOffsetX);
|
pw.println(" mMagnificationFrameOffsetX:" + mMagnificationFrameOffsetX);
|
||||||
pw.println(" mMagnificationFrameOffsetY:" + mMagnificationFrameOffsetY);
|
pw.println(" mMagnificationFrameOffsetY:" + mMagnificationFrameOffsetY);
|
||||||
|
|||||||
@@ -172,17 +172,26 @@ public class WindowMagnificationControllerTest extends SysuiTestCase {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void enableWindowMagnification_notifySourceBoundsChanged() {
|
public void enableWindowMagnification_notifySourceBoundsChanged() {
|
||||||
mInstrumentation.runOnMainSync(() -> {
|
mInstrumentation.runOnMainSync(
|
||||||
mWindowMagnificationController.enableWindowMagnification(Float.NaN, Float.NaN,
|
() -> mWindowMagnificationController.enableWindowMagnification(Float.NaN, Float.NaN,
|
||||||
Float.NaN, /* magnificationFrameOffsetRatioX= */ 0,
|
Float.NaN, /* magnificationFrameOffsetRatioX= */ 0,
|
||||||
/* magnificationFrameOffsetRatioY= */ 0, null);
|
/* magnificationFrameOffsetRatioY= */ 0, null));
|
||||||
});
|
|
||||||
|
|
||||||
// Waits for the surface created
|
// Waits for the surface created
|
||||||
verify(mWindowMagnifierCallback, timeout(LAYOUT_CHANGE_TIMEOUT_MS)).onSourceBoundsChanged(
|
verify(mWindowMagnifierCallback, timeout(LAYOUT_CHANGE_TIMEOUT_MS)).onSourceBoundsChanged(
|
||||||
(eq(mContext.getDisplayId())), any());
|
(eq(mContext.getDisplayId())), any());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void enableWindowMagnification_disabled_notifySourceBoundsChanged() {
|
||||||
|
enableWindowMagnification_notifySourceBoundsChanged();
|
||||||
|
mInstrumentation.runOnMainSync(
|
||||||
|
() -> mWindowMagnificationController.deleteWindowMagnification(null));
|
||||||
|
Mockito.reset(mWindowMagnifierCallback);
|
||||||
|
|
||||||
|
enableWindowMagnification_notifySourceBoundsChanged();
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void enableWindowMagnification_withAnimation_schedulesFrame() {
|
public void enableWindowMagnification_withAnimation_schedulesFrame() {
|
||||||
mInstrumentation.runOnMainSync(() -> {
|
mInstrumentation.runOnMainSync(() -> {
|
||||||
|
|||||||
Reference in New Issue
Block a user