Loading services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java +18 −44 Original line number Diff line number Diff line Loading @@ -67,7 +67,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.pm.ActivityInfo; import android.content.res.Resources; import android.graphics.Point; import android.graphics.Rect; import android.hardware.display.VirtualDisplay; Loading Loading @@ -515,12 +514,8 @@ public class WindowManagerServiceTests extends WindowTestsBase { @Test public void testSetInTouchMode_instrumentedProcessGetPermissionToSwitchTouchMode() { // Disable global touch mode (config_perDisplayFocusEnabled set to true) Resources mockResources = mock(Resources.class); spyOn(mContext); when(mContext.getResources()).thenReturn(mockResources); doReturn(true).when(mockResources).getBoolean( com.android.internal.R.bool.config_perDisplayFocusEnabled); // Enable global touch mode mWm.mPerDisplayFocusEnabled = true; // Get current touch mode state and setup WMS to run setInTouchMode boolean currentTouchMode = mWm.isInTouchMode(DEFAULT_DISPLAY); Loading @@ -539,12 +534,8 @@ public class WindowManagerServiceTests extends WindowTestsBase { @Test public void testSetInTouchMode_nonInstrumentedProcessDontGetPermissionToSwitchTouchMode() { // Disable global touch mode (config_perDisplayFocusEnabled set to true) Resources mockResources = mock(Resources.class); spyOn(mContext); when(mContext.getResources()).thenReturn(mockResources); doReturn(true).when(mockResources).getBoolean( com.android.internal.R.bool.config_perDisplayFocusEnabled); // Enable global touch mode mWm.mPerDisplayFocusEnabled = true; // Get current touch mode state and setup WMS to run setInTouchMode boolean currentTouchMode = mWm.isInTouchMode(DEFAULT_DISPLAY); Loading @@ -563,6 +554,9 @@ public class WindowManagerServiceTests extends WindowTestsBase { @Test public void testSetInTouchMode_multiDisplay_globalTouchModeUpdate() { // Disable global touch mode mWm.mPerDisplayFocusEnabled = false; // Create one extra display final VirtualDisplay virtualDisplay = createVirtualDisplay(/* ownFocus= */ false); final VirtualDisplay virtualDisplayOwnTouchMode = Loading @@ -574,13 +568,6 @@ public class WindowManagerServiceTests extends WindowTestsBase { .count(); assertThat(numberOfGlobalTouchModeDisplays).isAtLeast(2); // Enable global touch mode (config_perDisplayFocusEnabled set to false) Resources mockResources = mock(Resources.class); spyOn(mContext); when(mContext.getResources()).thenReturn(mockResources); doReturn(false).when(mockResources).getBoolean( com.android.internal.R.bool.config_perDisplayFocusEnabled); // Get current touch mode state and setup WMS to run setInTouchMode boolean currentTouchMode = mWm.isInTouchMode(DEFAULT_DISPLAY); int callingPid = Binder.getCallingPid(); Loading @@ -598,18 +585,14 @@ public class WindowManagerServiceTests extends WindowTestsBase { @Test public void testSetInTouchMode_multiDisplay_perDisplayFocus_singleDisplayTouchModeUpdate() { // Enable global touch mode mWm.mPerDisplayFocusEnabled = true; // Create one extra display final VirtualDisplay virtualDisplay = createVirtualDisplay(/* ownFocus= */ false); final int numberOfDisplays = mWm.mRoot.mChildren.size(); assertThat(numberOfDisplays).isAtLeast(2); // Disable global touch mode (config_perDisplayFocusEnabled set to true) Resources mockResources = mock(Resources.class); spyOn(mContext); when(mContext.getResources()).thenReturn(mockResources); doReturn(true).when(mockResources).getBoolean( com.android.internal.R.bool.config_perDisplayFocusEnabled); // Get current touch mode state and setup WMS to run setInTouchMode boolean currentTouchMode = mWm.isInTouchMode(DEFAULT_DISPLAY); int callingPid = Binder.getCallingPid(); Loading @@ -628,18 +611,14 @@ public class WindowManagerServiceTests extends WindowTestsBase { @Test public void testSetInTouchMode_multiDisplay_ownTouchMode_singleDisplayTouchModeUpdate() { // Disable global touch mode mWm.mPerDisplayFocusEnabled = false; // Create one extra display final VirtualDisplay virtualDisplay = createVirtualDisplay(/* ownFocus= */ true); final int numberOfDisplays = mWm.mRoot.mChildren.size(); assertThat(numberOfDisplays).isAtLeast(2); // Enable global touch mode (config_perDisplayFocusEnabled set to false) Resources mockResources = mock(Resources.class); spyOn(mContext); when(mContext.getResources()).thenReturn(mockResources); doReturn(false).when(mockResources).getBoolean( com.android.internal.R.bool.config_perDisplayFocusEnabled); // Get current touch mode state and setup WMS to run setInTouchMode boolean currentTouchMode = mWm.isInTouchMode(DEFAULT_DISPLAY); int callingPid = Binder.getCallingPid(); Loading Loading @@ -667,19 +646,14 @@ public class WindowManagerServiceTests extends WindowTestsBase { } private void testSetInTouchModeOnAllDisplays(boolean perDisplayFocusEnabled) { // Set global touch mode with the value passed as argument. mWm.mPerDisplayFocusEnabled = perDisplayFocusEnabled; // Create a couple of extra displays. // setInTouchModeOnAllDisplays should ignore the ownFocus setting. final VirtualDisplay virtualDisplay = createVirtualDisplay(/* ownFocus= */ false); final VirtualDisplay virtualDisplayOwnFocus = createVirtualDisplay(/* ownFocus= */ true); // Enable or disable global touch mode (config_perDisplayFocusEnabled setting). // setInTouchModeOnAllDisplays should ignore this value. Resources mockResources = mock(Resources.class); spyOn(mContext); when(mContext.getResources()).thenReturn(mockResources); doReturn(perDisplayFocusEnabled).when(mockResources).getBoolean( com.android.internal.R.bool.config_perDisplayFocusEnabled); int callingPid = Binder.getCallingPid(); int callingUid = Binder.getCallingUid(); doReturn(false).when(mWm).checkCallingPermission(anyString(), anyString(), anyBoolean()); Loading services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java +4 −0 Original line number Diff line number Diff line Loading @@ -197,6 +197,8 @@ class WindowTestsBase extends SystemServiceTestsBase { */ private static boolean sOverridesCheckedTestDisplay; private boolean mOriginalPerDisplayFocusEnabled; @BeforeClass public static void setUpOnceBase() { AttributeCache.init(getInstrumentation().getTargetContext()); Loading @@ -208,6 +210,7 @@ class WindowTestsBase extends SystemServiceTestsBase { mSupervisor = mAtm.mTaskSupervisor; mRootWindowContainer = mAtm.mRootWindowContainer; mWm = mSystemServicesTestRule.getWindowManagerService(); mOriginalPerDisplayFocusEnabled = mWm.mPerDisplayFocusEnabled; SystemServicesTestRule.checkHoldsLock(mWm.mGlobalLock); mDefaultDisplay = mWm.mRoot.getDefaultDisplay(); Loading Loading @@ -279,6 +282,7 @@ class WindowTestsBase extends SystemServiceTestsBase { if (mUseFakeSettingsProvider) { FakeSettingsProvider.clearSettingsProvider(); } mWm.mPerDisplayFocusEnabled = mOriginalPerDisplayFocusEnabled; } /** Loading Loading
services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java +18 −44 Original line number Diff line number Diff line Loading @@ -67,7 +67,6 @@ import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; import android.content.pm.ActivityInfo; import android.content.res.Resources; import android.graphics.Point; import android.graphics.Rect; import android.hardware.display.VirtualDisplay; Loading Loading @@ -515,12 +514,8 @@ public class WindowManagerServiceTests extends WindowTestsBase { @Test public void testSetInTouchMode_instrumentedProcessGetPermissionToSwitchTouchMode() { // Disable global touch mode (config_perDisplayFocusEnabled set to true) Resources mockResources = mock(Resources.class); spyOn(mContext); when(mContext.getResources()).thenReturn(mockResources); doReturn(true).when(mockResources).getBoolean( com.android.internal.R.bool.config_perDisplayFocusEnabled); // Enable global touch mode mWm.mPerDisplayFocusEnabled = true; // Get current touch mode state and setup WMS to run setInTouchMode boolean currentTouchMode = mWm.isInTouchMode(DEFAULT_DISPLAY); Loading @@ -539,12 +534,8 @@ public class WindowManagerServiceTests extends WindowTestsBase { @Test public void testSetInTouchMode_nonInstrumentedProcessDontGetPermissionToSwitchTouchMode() { // Disable global touch mode (config_perDisplayFocusEnabled set to true) Resources mockResources = mock(Resources.class); spyOn(mContext); when(mContext.getResources()).thenReturn(mockResources); doReturn(true).when(mockResources).getBoolean( com.android.internal.R.bool.config_perDisplayFocusEnabled); // Enable global touch mode mWm.mPerDisplayFocusEnabled = true; // Get current touch mode state and setup WMS to run setInTouchMode boolean currentTouchMode = mWm.isInTouchMode(DEFAULT_DISPLAY); Loading @@ -563,6 +554,9 @@ public class WindowManagerServiceTests extends WindowTestsBase { @Test public void testSetInTouchMode_multiDisplay_globalTouchModeUpdate() { // Disable global touch mode mWm.mPerDisplayFocusEnabled = false; // Create one extra display final VirtualDisplay virtualDisplay = createVirtualDisplay(/* ownFocus= */ false); final VirtualDisplay virtualDisplayOwnTouchMode = Loading @@ -574,13 +568,6 @@ public class WindowManagerServiceTests extends WindowTestsBase { .count(); assertThat(numberOfGlobalTouchModeDisplays).isAtLeast(2); // Enable global touch mode (config_perDisplayFocusEnabled set to false) Resources mockResources = mock(Resources.class); spyOn(mContext); when(mContext.getResources()).thenReturn(mockResources); doReturn(false).when(mockResources).getBoolean( com.android.internal.R.bool.config_perDisplayFocusEnabled); // Get current touch mode state and setup WMS to run setInTouchMode boolean currentTouchMode = mWm.isInTouchMode(DEFAULT_DISPLAY); int callingPid = Binder.getCallingPid(); Loading @@ -598,18 +585,14 @@ public class WindowManagerServiceTests extends WindowTestsBase { @Test public void testSetInTouchMode_multiDisplay_perDisplayFocus_singleDisplayTouchModeUpdate() { // Enable global touch mode mWm.mPerDisplayFocusEnabled = true; // Create one extra display final VirtualDisplay virtualDisplay = createVirtualDisplay(/* ownFocus= */ false); final int numberOfDisplays = mWm.mRoot.mChildren.size(); assertThat(numberOfDisplays).isAtLeast(2); // Disable global touch mode (config_perDisplayFocusEnabled set to true) Resources mockResources = mock(Resources.class); spyOn(mContext); when(mContext.getResources()).thenReturn(mockResources); doReturn(true).when(mockResources).getBoolean( com.android.internal.R.bool.config_perDisplayFocusEnabled); // Get current touch mode state and setup WMS to run setInTouchMode boolean currentTouchMode = mWm.isInTouchMode(DEFAULT_DISPLAY); int callingPid = Binder.getCallingPid(); Loading @@ -628,18 +611,14 @@ public class WindowManagerServiceTests extends WindowTestsBase { @Test public void testSetInTouchMode_multiDisplay_ownTouchMode_singleDisplayTouchModeUpdate() { // Disable global touch mode mWm.mPerDisplayFocusEnabled = false; // Create one extra display final VirtualDisplay virtualDisplay = createVirtualDisplay(/* ownFocus= */ true); final int numberOfDisplays = mWm.mRoot.mChildren.size(); assertThat(numberOfDisplays).isAtLeast(2); // Enable global touch mode (config_perDisplayFocusEnabled set to false) Resources mockResources = mock(Resources.class); spyOn(mContext); when(mContext.getResources()).thenReturn(mockResources); doReturn(false).when(mockResources).getBoolean( com.android.internal.R.bool.config_perDisplayFocusEnabled); // Get current touch mode state and setup WMS to run setInTouchMode boolean currentTouchMode = mWm.isInTouchMode(DEFAULT_DISPLAY); int callingPid = Binder.getCallingPid(); Loading Loading @@ -667,19 +646,14 @@ public class WindowManagerServiceTests extends WindowTestsBase { } private void testSetInTouchModeOnAllDisplays(boolean perDisplayFocusEnabled) { // Set global touch mode with the value passed as argument. mWm.mPerDisplayFocusEnabled = perDisplayFocusEnabled; // Create a couple of extra displays. // setInTouchModeOnAllDisplays should ignore the ownFocus setting. final VirtualDisplay virtualDisplay = createVirtualDisplay(/* ownFocus= */ false); final VirtualDisplay virtualDisplayOwnFocus = createVirtualDisplay(/* ownFocus= */ true); // Enable or disable global touch mode (config_perDisplayFocusEnabled setting). // setInTouchModeOnAllDisplays should ignore this value. Resources mockResources = mock(Resources.class); spyOn(mContext); when(mContext.getResources()).thenReturn(mockResources); doReturn(perDisplayFocusEnabled).when(mockResources).getBoolean( com.android.internal.R.bool.config_perDisplayFocusEnabled); int callingPid = Binder.getCallingPid(); int callingUid = Binder.getCallingUid(); doReturn(false).when(mWm).checkCallingPermission(anyString(), anyString(), anyBoolean()); Loading
services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java +4 −0 Original line number Diff line number Diff line Loading @@ -197,6 +197,8 @@ class WindowTestsBase extends SystemServiceTestsBase { */ private static boolean sOverridesCheckedTestDisplay; private boolean mOriginalPerDisplayFocusEnabled; @BeforeClass public static void setUpOnceBase() { AttributeCache.init(getInstrumentation().getTargetContext()); Loading @@ -208,6 +210,7 @@ class WindowTestsBase extends SystemServiceTestsBase { mSupervisor = mAtm.mTaskSupervisor; mRootWindowContainer = mAtm.mRootWindowContainer; mWm = mSystemServicesTestRule.getWindowManagerService(); mOriginalPerDisplayFocusEnabled = mWm.mPerDisplayFocusEnabled; SystemServicesTestRule.checkHoldsLock(mWm.mGlobalLock); mDefaultDisplay = mWm.mRoot.getDefaultDisplay(); Loading Loading @@ -279,6 +282,7 @@ class WindowTestsBase extends SystemServiceTestsBase { if (mUseFakeSettingsProvider) { FakeSettingsProvider.clearSettingsProvider(); } mWm.mPerDisplayFocusEnabled = mOriginalPerDisplayFocusEnabled; } /** Loading