Merge "Refactors FullScreenMagnificationController#onMagnificationChangedLocked" into tm-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
d62c6e6c7d
@@ -1363,8 +1363,18 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
|
|||||||
* </p>
|
* </p>
|
||||||
*
|
*
|
||||||
* @param displayId The logical display id
|
* @param displayId The logical display id
|
||||||
* @param region the new magnified region, may be empty if
|
* @param region The magnification region.
|
||||||
* magnification is not enabled (e.g. scale is 1)
|
* If the config mode is
|
||||||
|
* {@link MagnificationConfig#MAGNIFICATION_MODE_FULLSCREEN},
|
||||||
|
* it is the region of the screen currently active for magnification.
|
||||||
|
* the returned region will be empty if the magnification is not active
|
||||||
|
* (e.g. scale is 1. And the magnification is active if magnification
|
||||||
|
* gestures are enabled or if a service is running that can control
|
||||||
|
* magnification.
|
||||||
|
* If the config mode is
|
||||||
|
* {@link MagnificationConfig#MAGNIFICATION_MODE_WINDOW},
|
||||||
|
* it is the region of screen projected on the magnification window.
|
||||||
|
* The region will be empty if magnification is not activated.
|
||||||
* @param config The magnification config. That has magnification mode, the new scale and the
|
* @param config The magnification config. That has magnification mode, the new scale and the
|
||||||
* new screen-relative center position
|
* new screen-relative center position
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ import com.android.internal.annotations.GuardedBy;
|
|||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
import com.android.internal.util.function.pooled.PooledLambda;
|
import com.android.internal.util.function.pooled.PooledLambda;
|
||||||
import com.android.server.LocalServices;
|
import com.android.server.LocalServices;
|
||||||
import com.android.server.accessibility.AccessibilityManagerService;
|
|
||||||
import com.android.server.accessibility.AccessibilityTraceManager;
|
import com.android.server.accessibility.AccessibilityTraceManager;
|
||||||
import com.android.server.wm.WindowManagerInternal;
|
import com.android.server.wm.WindowManagerInternal;
|
||||||
|
|
||||||
@@ -374,9 +373,8 @@ public class FullScreenMagnificationController implements
|
|||||||
.setScale(getScale())
|
.setScale(getScale())
|
||||||
.setCenterX(getCenterX())
|
.setCenterX(getCenterX())
|
||||||
.setCenterY(getCenterY()).build();
|
.setCenterY(getCenterY()).build();
|
||||||
mControllerCtx.getAms().notifyMagnificationChanged(mDisplayId,
|
mMagnificationInfoChangedCallback.onFullScreenMagnificationChanged(mDisplayId,
|
||||||
mMagnificationRegion,
|
mMagnificationRegion, config);
|
||||||
config);
|
|
||||||
if (mUnregisterPending && !isMagnifying()) {
|
if (mUnregisterPending && !isMagnifying()) {
|
||||||
unregister(mDeleteAfterUnregister);
|
unregister(mDeleteAfterUnregister);
|
||||||
}
|
}
|
||||||
@@ -665,10 +663,10 @@ public class FullScreenMagnificationController implements
|
|||||||
* FullScreenMagnificationController Constructor
|
* FullScreenMagnificationController Constructor
|
||||||
*/
|
*/
|
||||||
public FullScreenMagnificationController(@NonNull Context context,
|
public FullScreenMagnificationController(@NonNull Context context,
|
||||||
@NonNull AccessibilityManagerService ams, @NonNull Object lock,
|
@NonNull AccessibilityTraceManager traceManager, @NonNull Object lock,
|
||||||
@NonNull MagnificationInfoChangedCallback magnificationInfoChangedCallback,
|
@NonNull MagnificationInfoChangedCallback magnificationInfoChangedCallback,
|
||||||
@NonNull MagnificationScaleProvider scaleProvider) {
|
@NonNull MagnificationScaleProvider scaleProvider) {
|
||||||
this(new ControllerContext(context, ams,
|
this(new ControllerContext(context, traceManager,
|
||||||
LocalServices.getService(WindowManagerInternal.class),
|
LocalServices.getService(WindowManagerInternal.class),
|
||||||
new Handler(context.getMainLooper()),
|
new Handler(context.getMainLooper()),
|
||||||
context.getResources().getInteger(R.integer.config_longAnimTime)), lock,
|
context.getResources().getInteger(R.integer.config_longAnimTime)), lock,
|
||||||
@@ -1521,7 +1519,6 @@ public class FullScreenMagnificationController implements
|
|||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
public static class ControllerContext {
|
public static class ControllerContext {
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
private final AccessibilityManagerService mAms;
|
|
||||||
private final AccessibilityTraceManager mTrace;
|
private final AccessibilityTraceManager mTrace;
|
||||||
private final WindowManagerInternal mWindowManager;
|
private final WindowManagerInternal mWindowManager;
|
||||||
private final Handler mHandler;
|
private final Handler mHandler;
|
||||||
@@ -1531,13 +1528,12 @@ public class FullScreenMagnificationController implements
|
|||||||
* Constructor for ControllerContext.
|
* Constructor for ControllerContext.
|
||||||
*/
|
*/
|
||||||
public ControllerContext(@NonNull Context context,
|
public ControllerContext(@NonNull Context context,
|
||||||
@NonNull AccessibilityManagerService ams,
|
@NonNull AccessibilityTraceManager traceManager,
|
||||||
@NonNull WindowManagerInternal windowManager,
|
@NonNull WindowManagerInternal windowManager,
|
||||||
@NonNull Handler handler,
|
@NonNull Handler handler,
|
||||||
long animationDuration) {
|
long animationDuration) {
|
||||||
mContext = context;
|
mContext = context;
|
||||||
mAms = ams;
|
mTrace = traceManager;
|
||||||
mTrace = ams.getTraceManager();
|
|
||||||
mWindowManager = windowManager;
|
mWindowManager = windowManager;
|
||||||
mHandler = handler;
|
mHandler = handler;
|
||||||
mAnimationDuration = animationDuration;
|
mAnimationDuration = animationDuration;
|
||||||
@@ -1551,14 +1547,6 @@ public class FullScreenMagnificationController implements
|
|||||||
return mContext;
|
return mContext;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @return AccessibilityManagerService
|
|
||||||
*/
|
|
||||||
@NonNull
|
|
||||||
public AccessibilityManagerService getAms() {
|
|
||||||
return mAms;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return AccessibilityTraceManager
|
* @return AccessibilityTraceManager
|
||||||
*/
|
*/
|
||||||
@@ -1632,5 +1620,17 @@ public class FullScreenMagnificationController implements
|
|||||||
* hidden.
|
* hidden.
|
||||||
*/
|
*/
|
||||||
void onImeWindowVisibilityChanged(boolean shown);
|
void onImeWindowVisibilityChanged(boolean shown);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when the magnification spec changed.
|
||||||
|
*
|
||||||
|
* @param displayId The logical display id
|
||||||
|
* @param region The region of the screen currently active for magnification.
|
||||||
|
* The returned region will be empty if the magnification is not active.
|
||||||
|
* @param config The magnification config. That has magnification mode, the new scale and
|
||||||
|
* the new screen-relative center position
|
||||||
|
*/
|
||||||
|
void onFullScreenMagnificationChanged(int displayId, @NonNull Region region,
|
||||||
|
@NonNull MagnificationConfig config);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -405,6 +405,12 @@ public class MagnificationController implements WindowMagnificationManager.Callb
|
|||||||
mAms.notifyMagnificationChanged(displayId, new Region(bounds), config);
|
mAms.notifyMagnificationChanged(displayId, new Region(bounds), config);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onFullScreenMagnificationChanged(int displayId, @NonNull Region region,
|
||||||
|
@NonNull MagnificationConfig config) {
|
||||||
|
mAms.notifyMagnificationChanged(displayId, region, config);
|
||||||
|
}
|
||||||
|
|
||||||
private void disableFullScreenMagnificationIfNeeded(int displayId) {
|
private void disableFullScreenMagnificationIfNeeded(int displayId) {
|
||||||
final FullScreenMagnificationController fullScreenMagnificationController =
|
final FullScreenMagnificationController fullScreenMagnificationController =
|
||||||
getFullScreenMagnificationController();
|
getFullScreenMagnificationController();
|
||||||
@@ -590,7 +596,7 @@ public class MagnificationController implements WindowMagnificationManager.Callb
|
|||||||
synchronized (mLock) {
|
synchronized (mLock) {
|
||||||
if (mFullScreenMagnificationController == null) {
|
if (mFullScreenMagnificationController == null) {
|
||||||
mFullScreenMagnificationController = new FullScreenMagnificationController(mContext,
|
mFullScreenMagnificationController = new FullScreenMagnificationController(mContext,
|
||||||
mAms, mLock, this, mScaleProvider);
|
mAms.getTraceManager(), mLock, this, mScaleProvider);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mFullScreenMagnificationController;
|
return mFullScreenMagnificationController;
|
||||||
|
|||||||
@@ -52,7 +52,6 @@ import android.view.accessibility.MagnificationAnimationCallback;
|
|||||||
import androidx.test.InstrumentationRegistry;
|
import androidx.test.InstrumentationRegistry;
|
||||||
import androidx.test.runner.AndroidJUnit4;
|
import androidx.test.runner.AndroidJUnit4;
|
||||||
|
|
||||||
import com.android.server.accessibility.AccessibilityManagerService;
|
|
||||||
import com.android.server.accessibility.AccessibilityTraceManager;
|
import com.android.server.accessibility.AccessibilityTraceManager;
|
||||||
import com.android.server.accessibility.test.MessageCapturingHandler;
|
import com.android.server.accessibility.test.MessageCapturingHandler;
|
||||||
import com.android.server.wm.WindowManagerInternal;
|
import com.android.server.wm.WindowManagerInternal;
|
||||||
@@ -94,7 +93,6 @@ public class FullScreenMagnificationControllerTest {
|
|||||||
final FullScreenMagnificationController.ControllerContext mMockControllerCtx =
|
final FullScreenMagnificationController.ControllerContext mMockControllerCtx =
|
||||||
mock(FullScreenMagnificationController.ControllerContext.class);
|
mock(FullScreenMagnificationController.ControllerContext.class);
|
||||||
final Context mMockContext = mock(Context.class);
|
final Context mMockContext = mock(Context.class);
|
||||||
final AccessibilityManagerService mMockAms = mock(AccessibilityManagerService.class);
|
|
||||||
final AccessibilityTraceManager mMockTraceManager = mock(AccessibilityTraceManager.class);
|
final AccessibilityTraceManager mMockTraceManager = mock(AccessibilityTraceManager.class);
|
||||||
final WindowManagerInternal mMockWindowManager = mock(WindowManagerInternal.class);
|
final WindowManagerInternal mMockWindowManager = mock(WindowManagerInternal.class);
|
||||||
private final MagnificationAnimationCallback mAnimationCallback = mock(
|
private final MagnificationAnimationCallback mAnimationCallback = mock(
|
||||||
@@ -121,12 +119,10 @@ public class FullScreenMagnificationControllerTest {
|
|||||||
// Pretending ID of the Thread associated with looper as main thread ID in controller
|
// Pretending ID of the Thread associated with looper as main thread ID in controller
|
||||||
when(mMockContext.getMainLooper()).thenReturn(looper);
|
when(mMockContext.getMainLooper()).thenReturn(looper);
|
||||||
when(mMockControllerCtx.getContext()).thenReturn(mMockContext);
|
when(mMockControllerCtx.getContext()).thenReturn(mMockContext);
|
||||||
when(mMockControllerCtx.getAms()).thenReturn(mMockAms);
|
|
||||||
when(mMockControllerCtx.getTraceManager()).thenReturn(mMockTraceManager);
|
when(mMockControllerCtx.getTraceManager()).thenReturn(mMockTraceManager);
|
||||||
when(mMockControllerCtx.getWindowManager()).thenReturn(mMockWindowManager);
|
when(mMockControllerCtx.getWindowManager()).thenReturn(mMockWindowManager);
|
||||||
when(mMockControllerCtx.getHandler()).thenReturn(mMessageCapturingHandler);
|
when(mMockControllerCtx.getHandler()).thenReturn(mMessageCapturingHandler);
|
||||||
when(mMockControllerCtx.getAnimationDuration()).thenReturn(1000L);
|
when(mMockControllerCtx.getAnimationDuration()).thenReturn(1000L);
|
||||||
when(mMockAms.getTraceManager()).thenReturn(mMockTraceManager);
|
|
||||||
initMockWindowManager();
|
initMockWindowManager();
|
||||||
|
|
||||||
mFullScreenMagnificationController = new FullScreenMagnificationController(
|
mFullScreenMagnificationController = new FullScreenMagnificationController(
|
||||||
@@ -357,8 +353,8 @@ public class FullScreenMagnificationControllerTest {
|
|||||||
assertEquals(newCenter.x, mFullScreenMagnificationController.getCenterX(displayId), 0.5);
|
assertEquals(newCenter.x, mFullScreenMagnificationController.getCenterX(displayId), 0.5);
|
||||||
assertEquals(newCenter.y, mFullScreenMagnificationController.getCenterY(displayId), 0.5);
|
assertEquals(newCenter.y, mFullScreenMagnificationController.getCenterY(displayId), 0.5);
|
||||||
assertThat(getCurrentMagnificationSpec(displayId), closeTo(endSpec));
|
assertThat(getCurrentMagnificationSpec(displayId), closeTo(endSpec));
|
||||||
verify(mMockAms).notifyMagnificationChanged(eq(displayId), eq(INITIAL_MAGNIFICATION_REGION),
|
verify(mRequestObserver).onFullScreenMagnificationChanged(eq(displayId),
|
||||||
mConfigCaptor.capture());
|
eq(INITIAL_MAGNIFICATION_REGION), mConfigCaptor.capture());
|
||||||
assertConfigEquals(config, mConfigCaptor.getValue());
|
assertConfigEquals(config, mConfigCaptor.getValue());
|
||||||
verify(mMockValueAnimator).start();
|
verify(mMockValueAnimator).start();
|
||||||
verify(mRequestObserver).onRequestMagnificationSpec(displayId, SERVICE_ID_1);
|
verify(mRequestObserver).onRequestMagnificationSpec(displayId, SERVICE_ID_1);
|
||||||
@@ -501,7 +497,7 @@ public class FullScreenMagnificationControllerTest {
|
|||||||
mMessageCapturingHandler.sendAllMessages();
|
mMessageCapturingHandler.sendAllMessages();
|
||||||
MagnificationConfig config = buildConfig(1.0f, OTHER_MAGNIFICATION_BOUNDS.centerX(),
|
MagnificationConfig config = buildConfig(1.0f, OTHER_MAGNIFICATION_BOUNDS.centerX(),
|
||||||
OTHER_MAGNIFICATION_BOUNDS.centerY());
|
OTHER_MAGNIFICATION_BOUNDS.centerY());
|
||||||
verify(mMockAms).notifyMagnificationChanged(eq(displayId), eq(OTHER_REGION),
|
verify(mRequestObserver).onFullScreenMagnificationChanged(eq(displayId), eq(OTHER_REGION),
|
||||||
mConfigCaptor.capture());
|
mConfigCaptor.capture());
|
||||||
assertConfigEquals(config, mConfigCaptor.getValue());
|
assertConfigEquals(config, mConfigCaptor.getValue());
|
||||||
}
|
}
|
||||||
@@ -655,9 +651,9 @@ public class FullScreenMagnificationControllerTest {
|
|||||||
register(displayId);
|
register(displayId);
|
||||||
zoomIn2xToMiddle(displayId);
|
zoomIn2xToMiddle(displayId);
|
||||||
mMessageCapturingHandler.sendAllMessages();
|
mMessageCapturingHandler.sendAllMessages();
|
||||||
reset(mMockAms);
|
reset(mRequestObserver);
|
||||||
assertTrue(mFullScreenMagnificationController.resetIfNeeded(displayId, false));
|
assertTrue(mFullScreenMagnificationController.resetIfNeeded(displayId, false));
|
||||||
verify(mMockAms).notifyMagnificationChanged(eq(displayId),
|
verify(mRequestObserver).onFullScreenMagnificationChanged(eq(displayId),
|
||||||
eq(INITIAL_MAGNIFICATION_REGION), any(MagnificationConfig.class));
|
eq(INITIAL_MAGNIFICATION_REGION), any(MagnificationConfig.class));
|
||||||
assertFalse(mFullScreenMagnificationController.isMagnifying(displayId));
|
assertFalse(mFullScreenMagnificationController.isMagnifying(displayId));
|
||||||
assertFalse(mFullScreenMagnificationController.resetIfNeeded(displayId, false));
|
assertFalse(mFullScreenMagnificationController.resetIfNeeded(displayId, false));
|
||||||
@@ -676,8 +672,8 @@ public class FullScreenMagnificationControllerTest {
|
|||||||
assertFalse(mFullScreenMagnificationController.reset(displayId, mAnimationCallback));
|
assertFalse(mFullScreenMagnificationController.reset(displayId, mAnimationCallback));
|
||||||
mMessageCapturingHandler.sendAllMessages();
|
mMessageCapturingHandler.sendAllMessages();
|
||||||
|
|
||||||
verify(mMockAms, never()).notifyMagnificationChanged(eq(displayId), any(Region.class),
|
verify(mRequestObserver, never()).onFullScreenMagnificationChanged(eq(displayId),
|
||||||
any(MagnificationConfig.class));
|
any(Region.class), any(MagnificationConfig.class));
|
||||||
verify(mAnimationCallback).onResult(true);
|
verify(mAnimationCallback).onResult(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1072,8 +1068,8 @@ public class FullScreenMagnificationControllerTest {
|
|||||||
when(mMockValueAnimator.getAnimatedFraction()).thenReturn(0.0f);
|
when(mMockValueAnimator.getAnimatedFraction()).thenReturn(0.0f);
|
||||||
mTargetAnimationListener.onAnimationUpdate(mMockValueAnimator);
|
mTargetAnimationListener.onAnimationUpdate(mMockValueAnimator);
|
||||||
verify(mMockWindowManager).setMagnificationSpec(eq(displayId), eq(startSpec));
|
verify(mMockWindowManager).setMagnificationSpec(eq(displayId), eq(startSpec));
|
||||||
verify(mMockAms).notifyMagnificationChanged(eq(displayId), eq(INITIAL_MAGNIFICATION_REGION),
|
verify(mRequestObserver).onFullScreenMagnificationChanged(eq(displayId),
|
||||||
mConfigCaptor.capture());
|
eq(INITIAL_MAGNIFICATION_REGION), mConfigCaptor.capture());
|
||||||
assertConfigEquals(config, mConfigCaptor.getValue());
|
assertConfigEquals(config, mConfigCaptor.getValue());
|
||||||
Mockito.reset(mMockWindowManager);
|
Mockito.reset(mMockWindowManager);
|
||||||
|
|
||||||
@@ -1097,7 +1093,7 @@ public class FullScreenMagnificationControllerTest {
|
|||||||
|
|
||||||
// Animation should have been restarted
|
// Animation should have been restarted
|
||||||
verify(mMockValueAnimator, times(2)).start();
|
verify(mMockValueAnimator, times(2)).start();
|
||||||
verify(mMockAms, times(2)).notifyMagnificationChanged(eq(displayId),
|
verify(mRequestObserver, times(2)).onFullScreenMagnificationChanged(eq(displayId),
|
||||||
eq(INITIAL_MAGNIFICATION_REGION), mConfigCaptor.capture());
|
eq(INITIAL_MAGNIFICATION_REGION), mConfigCaptor.capture());
|
||||||
assertConfigEquals(newConfig, mConfigCaptor.getValue());
|
assertConfigEquals(newConfig, mConfigCaptor.getValue());
|
||||||
|
|
||||||
|
|||||||
@@ -151,8 +151,6 @@ public class FullScreenMagnificationGestureHandlerTest {
|
|||||||
mock(FullScreenMagnificationController.ControllerContext.class);
|
mock(FullScreenMagnificationController.ControllerContext.class);
|
||||||
final WindowManagerInternal mockWindowManager = mock(WindowManagerInternal.class);
|
final WindowManagerInternal mockWindowManager = mock(WindowManagerInternal.class);
|
||||||
when(mockController.getContext()).thenReturn(mContext);
|
when(mockController.getContext()).thenReturn(mContext);
|
||||||
when(mockController.getAms()).thenReturn(mMockAccessibilityManagerService);
|
|
||||||
when(mMockAccessibilityManagerService.getTraceManager()).thenReturn(mMockTraceManager);
|
|
||||||
when(mockController.getTraceManager()).thenReturn(mMockTraceManager);
|
when(mockController.getTraceManager()).thenReturn(mMockTraceManager);
|
||||||
when(mockController.getWindowManager()).thenReturn(mockWindowManager);
|
when(mockController.getWindowManager()).thenReturn(mockWindowManager);
|
||||||
when(mockController.getHandler()).thenReturn(new Handler(mContext.getMainLooper()));
|
when(mockController.getHandler()).thenReturn(new Handler(mContext.getMainLooper()));
|
||||||
|
|||||||
@@ -145,9 +145,10 @@ public class MagnificationControllerTest {
|
|||||||
mCallbackDelegate, mTraceManager, mScaleProvider));
|
mCallbackDelegate, mTraceManager, mScaleProvider));
|
||||||
mMockConnection = new MockWindowMagnificationConnection(true);
|
mMockConnection = new MockWindowMagnificationConnection(true);
|
||||||
mWindowMagnificationManager.setConnection(mMockConnection.getConnection());
|
mWindowMagnificationManager.setConnection(mMockConnection.getConnection());
|
||||||
new FullScreenMagnificationControllerStubber(mScreenMagnificationController);
|
|
||||||
mMagnificationController = new MagnificationController(mService, globalLock, mContext,
|
mMagnificationController = new MagnificationController(mService, globalLock, mContext,
|
||||||
mScreenMagnificationController, mWindowMagnificationManager, mScaleProvider);
|
mScreenMagnificationController, mWindowMagnificationManager, mScaleProvider);
|
||||||
|
new FullScreenMagnificationControllerStubber(mScreenMagnificationController,
|
||||||
|
mMagnificationController);
|
||||||
|
|
||||||
mMagnificationController.setMagnificationCapabilities(
|
mMagnificationController.setMagnificationCapabilities(
|
||||||
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_ALL);
|
Settings.Secure.ACCESSIBILITY_MAGNIFICATION_MODE_ALL);
|
||||||
@@ -450,6 +451,29 @@ public class MagnificationControllerTest {
|
|||||||
assertEquals(DEFAULT_SCALE, actualConfig.getScale(), 0);
|
assertEquals(DEFAULT_SCALE, actualConfig.getScale(), 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void onFullScreenMagnificationChanged_fullScreenEnabled_notifyMagnificationChanged()
|
||||||
|
throws RemoteException {
|
||||||
|
setMagnificationEnabled(MODE_FULLSCREEN);
|
||||||
|
|
||||||
|
final MagnificationConfig config = obtainMagnificationConfig(MODE_FULLSCREEN);
|
||||||
|
mScreenMagnificationController.setScaleAndCenter(TEST_DISPLAY,
|
||||||
|
config.getScale(), config.getCenterX(), config.getCenterY(),
|
||||||
|
true, TEST_SERVICE_ID);
|
||||||
|
|
||||||
|
// The first time is triggered when setting magnification enabled. And the second time is
|
||||||
|
// triggered when calling setScaleAndCenter.
|
||||||
|
final ArgumentCaptor<MagnificationConfig> configCaptor = ArgumentCaptor.forClass(
|
||||||
|
MagnificationConfig.class);
|
||||||
|
verify(mService, times(2)).notifyMagnificationChanged(eq(TEST_DISPLAY),
|
||||||
|
eq(FullScreenMagnificationControllerStubber.MAGNIFICATION_REGION),
|
||||||
|
configCaptor.capture());
|
||||||
|
final MagnificationConfig actualConfig = configCaptor.getValue();
|
||||||
|
assertEquals(config.getCenterX(), actualConfig.getCenterX(), 0);
|
||||||
|
assertEquals(config.getCenterY(), actualConfig.getCenterY(), 0);
|
||||||
|
assertEquals(config.getScale(), actualConfig.getScale(), 0);
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void onAccessibilityActionPerformed_magnifierEnabled_showMagnificationButton()
|
public void onAccessibilityActionPerformed_magnifierEnabled_showMagnificationButton()
|
||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
@@ -679,7 +703,7 @@ public class MagnificationControllerTest {
|
|||||||
throws RemoteException {
|
throws RemoteException {
|
||||||
setMagnificationEnabled(MODE_FULLSCREEN);
|
setMagnificationEnabled(MODE_FULLSCREEN);
|
||||||
mScreenMagnificationController.setScaleAndCenter(TEST_DISPLAY,
|
mScreenMagnificationController.setScaleAndCenter(TEST_DISPLAY,
|
||||||
/* scale= */1, MAGNIFIED_CENTER_X, MAGNIFIED_CENTER_Y,
|
/* scale= */ 1, MAGNIFIED_CENTER_X, MAGNIFIED_CENTER_Y,
|
||||||
true, TEST_SERVICE_ID);
|
true, TEST_SERVICE_ID);
|
||||||
|
|
||||||
mMagnificationController.onFullScreenMagnificationActivationState(TEST_DISPLAY, false);
|
mMagnificationController.onFullScreenMagnificationActivationState(TEST_DISPLAY, false);
|
||||||
@@ -884,6 +908,8 @@ public class MagnificationControllerTest {
|
|||||||
private static class FullScreenMagnificationControllerStubber {
|
private static class FullScreenMagnificationControllerStubber {
|
||||||
private static final Region MAGNIFICATION_REGION = new Region(0, 0, 500, 600);
|
private static final Region MAGNIFICATION_REGION = new Region(0, 0, 500, 600);
|
||||||
private final FullScreenMagnificationController mScreenMagnificationController;
|
private final FullScreenMagnificationController mScreenMagnificationController;
|
||||||
|
private final FullScreenMagnificationController.MagnificationInfoChangedCallback
|
||||||
|
mMagnificationChangedCallback;
|
||||||
private boolean mIsMagnifying = false;
|
private boolean mIsMagnifying = false;
|
||||||
private float mScale = 1.0f;
|
private float mScale = 1.0f;
|
||||||
private float mCenterX = MAGNIFICATION_REGION.getBounds().exactCenterX();
|
private float mCenterX = MAGNIFICATION_REGION.getBounds().exactCenterX();
|
||||||
@@ -891,8 +917,10 @@ public class MagnificationControllerTest {
|
|||||||
private int mServiceId = -1;
|
private int mServiceId = -1;
|
||||||
|
|
||||||
FullScreenMagnificationControllerStubber(
|
FullScreenMagnificationControllerStubber(
|
||||||
FullScreenMagnificationController screenMagnificationController) {
|
FullScreenMagnificationController screenMagnificationController,
|
||||||
|
FullScreenMagnificationController.MagnificationInfoChangedCallback callback) {
|
||||||
mScreenMagnificationController = screenMagnificationController;
|
mScreenMagnificationController = screenMagnificationController;
|
||||||
|
mMagnificationChangedCallback = callback;
|
||||||
stubMethods();
|
stubMethods();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -930,6 +958,14 @@ public class MagnificationControllerTest {
|
|||||||
} else {
|
} else {
|
||||||
reset();
|
reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
final MagnificationConfig config = new MagnificationConfig.Builder().setMode(
|
||||||
|
MODE_FULLSCREEN).setScale(mScale).setCenterX(mCenterX).setCenterY(
|
||||||
|
mCenterY).build();
|
||||||
|
mMagnificationChangedCallback.onFullScreenMagnificationChanged(TEST_DISPLAY,
|
||||||
|
FullScreenMagnificationControllerStubber.MAGNIFICATION_REGION,
|
||||||
|
config);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
doAnswer(setScaleAndCenterStubAnswer).when(
|
doAnswer(setScaleAndCenterStubAnswer).when(
|
||||||
|
|||||||
Reference in New Issue
Block a user