diff options
| author | 2023-05-16 07:11:44 +0000 | |
|---|---|---|
| committer | 2023-05-17 05:38:56 +0000 | |
| commit | af2827dd56c8ea9e59d1e95586992dd6555744f5 (patch) | |
| tree | c196a70fc89b1709b9e74f3c6706b17802b02535 | |
| parent | bd8568ac11950c9f9a844cb9ef9df43dc57efc76 (diff) | |
fix(#Magnification): check window magnification supported for context before unit tests
In WindowMagnificationControllerTest, when setUp we add checking whether the window mode is supported. If it's not supported, we can just skip the test to prevent the tests from running on not supported devices.
Bug: 279820875
Test: atest WindowMagnificationControllerTest
abtd on target cf_gwear_x86-userdebug
presubmit
Change-Id: If76ba72c4353ac8d7f3ba98048075800054d9f75
| -rw-r--r-- | packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java index 9c36af3a35e4..31c09b8e7ec4 100644 --- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java +++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/WindowMagnificationControllerTest.java @@ -16,6 +16,7 @@ package com.android.systemui.accessibility; +import static android.content.pm.PackageManager.FEATURE_WINDOW_MAGNIFICATION; import static android.content.res.Configuration.ORIENTATION_LANDSCAPE; import static android.content.res.Configuration.ORIENTATION_PORTRAIT; import static android.content.res.Configuration.ORIENTATION_UNDEFINED; @@ -96,6 +97,7 @@ import com.android.systemui.utils.os.FakeHandler; import com.google.common.util.concurrent.AtomicDouble; import org.junit.After; +import org.junit.Assume; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -147,8 +149,15 @@ public class WindowMagnificationControllerTest extends SysuiTestCase { private View.OnTouchListener mTouchListener; private MotionEventHelper mMotionEventHelper = new MotionEventHelper(); + /** + * return whether window magnification is supported for current test context. + */ + private boolean isWindowModeSupported() { + return getContext().getPackageManager().hasSystemFeature(FEATURE_WINDOW_MAGNIFICATION); + } + @Before - public void setUp() throws RemoteException { + public void setUp() throws Exception { MockitoAnnotations.initMocks(this); mContext = Mockito.spy(getContext()); mHandler = new FakeHandler(TestableLooper.get(this).getLooper()); @@ -202,6 +211,9 @@ public class WindowMagnificationControllerTest extends SysuiTestCase { return null; }).when(mSpyView).setOnTouchListener( any(View.OnTouchListener.class)); + + // skip test if window magnification is not supported to prevent fail results. (b/279820875) + Assume.assumeTrue(isWindowModeSupported()); } @After |