Loading services/tests/servicestests/src/com/android/server/accessibility/AccessibilityWindowManagerWithAccessibilityWindowTest.java +123 −18 Original line number Original line Diff line number Diff line Loading @@ -18,21 +18,23 @@ package com.android.server.accessibility; import static com.android.server.accessibility.AbstractAccessibilityServiceConnection.DISPLAY_TYPE_DEFAULT; import static com.android.server.accessibility.AbstractAccessibilityServiceConnection.DISPLAY_TYPE_DEFAULT; import static com.android.server.accessibility.AccessibilityWindowManagerWithAccessibilityWindowTest.DisplayIdMatcher.displayId; import static com.android.server.accessibility.AccessibilityWindowManagerWithAccessibilityWindowTest.DisplayIdMatcher.displayId; import static com.android.server.accessibility.AccessibilityWindowManagerWithAccessibilityWindowTest.WindowIdMatcher.windowId; import static com.android.server.accessibility.AccessibilityWindowManagerWithAccessibilityWindowTest.WindowChangesMatcher.a11yWindowChanges; import static com.android.server.accessibility.AccessibilityWindowManagerWithAccessibilityWindowTest.WindowChangesMatcher.a11yWindowChanges; import static com.android.server.accessibility.AccessibilityWindowManagerWithAccessibilityWindowTest.WindowIdMatcher.a11yWindowId; import static com.android.server.accessibility.AccessibilityWindowManagerWithAccessibilityWindowTest.EventWindowIdMatcher.eventWindowId; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertNull; import static junit.framework.Assert.assertNull; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.assertTrue; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.anyString; Loading Loading @@ -349,6 +351,88 @@ public class AccessibilityWindowManagerWithAccessibilityWindowTest { } } } } @Test public void onWindowsChanged_shouldNotReportNonTouchableWindow() { final AccessibilityWindow window = mWindows.get(Display.DEFAULT_DISPLAY).get(0); when(window.isTouchable()).thenReturn(false); final int windowId = mA11yWindowManager.findWindowIdLocked( USER_SYSTEM_ID, window.getWindowInfo().token); onAccessibilityWindowsChanged(Display.DEFAULT_DISPLAY, SEND_ON_WINDOW_CHANGES); final List<AccessibilityWindowInfo> a11yWindows = mA11yWindowManager.getWindowListLocked(Display.DEFAULT_DISPLAY); assertThat(a11yWindows, not(hasItem(windowId(windowId)))); } @Test public void onWindowsChanged_shouldReportFocusedNonTouchableWindow() { final AccessibilityWindow window = mWindows.get(Display.DEFAULT_DISPLAY).get( DEFAULT_FOCUSED_INDEX); when(window.isTouchable()).thenReturn(false); final int windowId = mA11yWindowManager.findWindowIdLocked( USER_SYSTEM_ID, window.getWindowInfo().token); onAccessibilityWindowsChanged(Display.DEFAULT_DISPLAY, SEND_ON_WINDOW_CHANGES); final List<AccessibilityWindowInfo> a11yWindows = mA11yWindowManager.getWindowListLocked(Display.DEFAULT_DISPLAY); assertThat(a11yWindows, hasItem(windowId(windowId))); } @Test public void onWindowsChanged_trustedFocusedNonTouchableWindow_shouldNotHideWindowsBelow() { // Make the focused trusted un-touchable window fullscreen. final AccessibilityWindow window = mWindows.get(Display.DEFAULT_DISPLAY).get( DEFAULT_FOCUSED_INDEX); setRegionForMockAccessibilityWindow(window, new Region(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); when(window.isTouchable()).thenReturn(false); when(window.isTrustedOverlay()).thenReturn(true); onAccessibilityWindowsChanged(Display.DEFAULT_DISPLAY, SEND_ON_WINDOW_CHANGES); final List<AccessibilityWindowInfo> a11yWindows = mA11yWindowManager.getWindowListLocked(Display.DEFAULT_DISPLAY); assertThat(a11yWindows, hasSize(NUM_OF_WINDOWS)); } @Test public void onWindowsChanged_accessibilityOverlay_shouldNotHideWindowsBelow() { // Make the a11y overlay window fullscreen. final AccessibilityWindow window = mWindows.get(Display.DEFAULT_DISPLAY).get(0); setRegionForMockAccessibilityWindow(window, new Region(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); when(window.getType()).thenReturn(WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY); onAccessibilityWindowsChanged(Display.DEFAULT_DISPLAY, SEND_ON_WINDOW_CHANGES); final List<AccessibilityWindowInfo> a11yWindows = mA11yWindowManager.getWindowListLocked(Display.DEFAULT_DISPLAY); assertThat(a11yWindows, hasSize(NUM_OF_WINDOWS)); } @Test public void onWindowsChanged_shouldReportFocusedWindowEvenIfOccluded() { // Make the front window fullscreen. final AccessibilityWindow frontWindow = mWindows.get(Display.DEFAULT_DISPLAY).get(0); setRegionForMockAccessibilityWindow(frontWindow, new Region(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); final int frontWindowId = mA11yWindowManager.findWindowIdLocked( USER_SYSTEM_ID, frontWindow.getWindowInfo().token); final AccessibilityWindow focusedWindow = mWindows.get(Display.DEFAULT_DISPLAY).get( DEFAULT_FOCUSED_INDEX); final int focusedWindowId = mA11yWindowManager.findWindowIdLocked( USER_SYSTEM_ID, focusedWindow.getWindowInfo().token); onAccessibilityWindowsChanged(Display.DEFAULT_DISPLAY, SEND_ON_WINDOW_CHANGES); final List<AccessibilityWindowInfo> a11yWindows = mA11yWindowManager.getWindowListLocked(Display.DEFAULT_DISPLAY); assertThat(a11yWindows, hasSize(2)); assertThat(a11yWindows.get(0), windowId(frontWindowId)); assertThat(a11yWindows.get(1), windowId(focusedWindowId)); } @Test @Test public void onWindowsChangedAndForceSend_shouldUpdateWindows() { public void onWindowsChangedAndForceSend_shouldUpdateWindows() { assertNotEquals("new title", assertNotEquals("new title", Loading Loading @@ -631,11 +715,11 @@ public class AccessibilityWindowManagerWithAccessibilityWindowTest { .sendAccessibilityEventForCurrentUserLocked(captor.capture()); .sendAccessibilityEventForCurrentUserLocked(captor.capture()); assertThat(captor.getAllValues().get(0), assertThat(captor.getAllValues().get(0), allOf(displayId(Display.DEFAULT_DISPLAY), allOf(displayId(Display.DEFAULT_DISPLAY), a11yWindowId(currentActiveWindowId), eventWindowId(currentActiveWindowId), a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_ACTIVE))); a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_ACTIVE))); assertThat(captor.getAllValues().get(1), assertThat(captor.getAllValues().get(1), allOf(displayId(Display.DEFAULT_DISPLAY), allOf(displayId(Display.DEFAULT_DISPLAY), a11yWindowId(eventWindowId), eventWindowId(eventWindowId), a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_ACTIVE))); a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_ACTIVE))); } } Loading @@ -661,7 +745,7 @@ public class AccessibilityWindowManagerWithAccessibilityWindowTest { .sendAccessibilityEventForCurrentUserLocked(captor.capture()); .sendAccessibilityEventForCurrentUserLocked(captor.capture()); assertThat(captor.getAllValues().get(0), assertThat(captor.getAllValues().get(0), allOf(displayId(Display.DEFAULT_DISPLAY), allOf(displayId(Display.DEFAULT_DISPLAY), a11yWindowId(eventWindowId), eventWindowId(eventWindowId), a11yWindowChanges( a11yWindowChanges( AccessibilityEvent.WINDOWS_CHANGE_ACCESSIBILITY_FOCUSED))); AccessibilityEvent.WINDOWS_CHANGE_ACCESSIBILITY_FOCUSED))); } } Loading Loading @@ -710,12 +794,12 @@ public class AccessibilityWindowManagerWithAccessibilityWindowTest { .sendAccessibilityEventForCurrentUserLocked(captor.capture()); .sendAccessibilityEventForCurrentUserLocked(captor.capture()); assertThat(captor.getAllValues().get(0), assertThat(captor.getAllValues().get(0), allOf(displayId(initialDisplayId), allOf(displayId(initialDisplayId), a11yWindowId(initialWindowId), eventWindowId(initialWindowId), a11yWindowChanges( a11yWindowChanges( AccessibilityEvent.WINDOWS_CHANGE_ACCESSIBILITY_FOCUSED))); AccessibilityEvent.WINDOWS_CHANGE_ACCESSIBILITY_FOCUSED))); assertThat(captor.getAllValues().get(1), assertThat(captor.getAllValues().get(1), allOf(displayId(eventDisplayId), allOf(displayId(eventDisplayId), a11yWindowId(eventWindowId), eventWindowId(eventWindowId), a11yWindowChanges( a11yWindowChanges( AccessibilityEvent.WINDOWS_CHANGE_ACCESSIBILITY_FOCUSED))); AccessibilityEvent.WINDOWS_CHANGE_ACCESSIBILITY_FOCUSED))); } } Loading Loading @@ -771,11 +855,11 @@ public class AccessibilityWindowManagerWithAccessibilityWindowTest { .sendAccessibilityEventForCurrentUserLocked(captor.capture()); .sendAccessibilityEventForCurrentUserLocked(captor.capture()); assertThat(captor.getAllValues().get(0), assertThat(captor.getAllValues().get(0), allOf(displayId(Display.DEFAULT_DISPLAY), allOf(displayId(Display.DEFAULT_DISPLAY), a11yWindowId(eventWindowId), eventWindowId(eventWindowId), a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_ACTIVE))); a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_ACTIVE))); assertThat(captor.getAllValues().get(1), assertThat(captor.getAllValues().get(1), allOf(displayId(Display.DEFAULT_DISPLAY), allOf(displayId(Display.DEFAULT_DISPLAY), a11yWindowId(currentActiveWindowId), eventWindowId(currentActiveWindowId), a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_ACTIVE))); a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_ACTIVE))); } } Loading Loading @@ -979,7 +1063,7 @@ public class AccessibilityWindowManagerWithAccessibilityWindowTest { .sendAccessibilityEventForCurrentUserLocked(captor.capture()); .sendAccessibilityEventForCurrentUserLocked(captor.capture()); assertThat(captor.getAllValues().get(0), assertThat(captor.getAllValues().get(0), allOf(displayId(Display.DEFAULT_DISPLAY), allOf(displayId(Display.DEFAULT_DISPLAY), a11yWindowId(windowId), eventWindowId(windowId), a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_REMOVED))); a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_REMOVED))); } } Loading @@ -1001,7 +1085,7 @@ public class AccessibilityWindowManagerWithAccessibilityWindowTest { .sendAccessibilityEventForCurrentUserLocked(captor.capture()); .sendAccessibilityEventForCurrentUserLocked(captor.capture()); assertThat(captor.getAllValues().get(0), assertThat(captor.getAllValues().get(0), allOf(displayId(Display.DEFAULT_DISPLAY), allOf(displayId(Display.DEFAULT_DISPLAY), a11yWindowId(windowId), eventWindowId(windowId), a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_ADDED))); a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_ADDED))); } } Loading @@ -1019,7 +1103,7 @@ public class AccessibilityWindowManagerWithAccessibilityWindowTest { .sendAccessibilityEventForCurrentUserLocked(captor.capture()); .sendAccessibilityEventForCurrentUserLocked(captor.capture()); assertThat(captor.getAllValues().get(0), assertThat(captor.getAllValues().get(0), allOf(displayId(Display.DEFAULT_DISPLAY), allOf(displayId(Display.DEFAULT_DISPLAY), a11yWindowId(windowId), eventWindowId(windowId), a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_TITLE))); a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_TITLE))); } } Loading Loading @@ -1173,8 +1257,6 @@ public class AccessibilityWindowManagerWithAccessibilityWindowTest { private AccessibilityWindow createMockAccessibilityWindow(IWindow windowToken, int displayId) { private AccessibilityWindow createMockAccessibilityWindow(IWindow windowToken, int displayId) { final WindowInfo windowInfo = WindowInfo.obtain(); final WindowInfo windowInfo = WindowInfo.obtain(); // TODO(b/325341171): add tests with various kinds of windows such as // changing window types, touchable or not, trusted or not, etc. windowInfo.type = WindowManager.LayoutParams.TYPE_APPLICATION; windowInfo.type = WindowManager.LayoutParams.TYPE_APPLICATION; windowInfo.token = windowToken.asBinder(); windowInfo.token = windowToken.asBinder(); Loading Loading @@ -1235,16 +1317,16 @@ public class AccessibilityWindowManagerWithAccessibilityWindowTest { } } } } static class WindowIdMatcher extends TypeSafeMatcher<AccessibilityEvent> { static class EventWindowIdMatcher extends TypeSafeMatcher<AccessibilityEvent> { private int mWindowId; private int mWindowId; WindowIdMatcher(int windowId) { EventWindowIdMatcher(int windowId) { super(); super(); mWindowId = windowId; mWindowId = windowId; } } static WindowIdMatcher a11yWindowId(int windowId) { static EventWindowIdMatcher eventWindowId(int windowId) { return new WindowIdMatcher(windowId); return new EventWindowIdMatcher(windowId); } } @Override @Override Loading Loading @@ -1280,4 +1362,27 @@ public class AccessibilityWindowManagerWithAccessibilityWindowTest { description.appendText("Matching to window changes " + mWindowChanges); description.appendText("Matching to window changes " + mWindowChanges); } } } } static class WindowIdMatcher extends TypeSafeMatcher<AccessibilityWindowInfo> { private final int mWindowId; WindowIdMatcher(int windowId) { super(); mWindowId = windowId; } static WindowIdMatcher windowId(int windowId) { return new WindowIdMatcher(windowId); } @Override protected boolean matchesSafely(AccessibilityWindowInfo window) { return window.getId() == mWindowId; } @Override public void describeTo(Description description) { description.appendText("Matching to windowId " + mWindowId); } } } } Loading
services/tests/servicestests/src/com/android/server/accessibility/AccessibilityWindowManagerWithAccessibilityWindowTest.java +123 −18 Original line number Original line Diff line number Diff line Loading @@ -18,21 +18,23 @@ package com.android.server.accessibility; import static com.android.server.accessibility.AbstractAccessibilityServiceConnection.DISPLAY_TYPE_DEFAULT; import static com.android.server.accessibility.AbstractAccessibilityServiceConnection.DISPLAY_TYPE_DEFAULT; import static com.android.server.accessibility.AccessibilityWindowManagerWithAccessibilityWindowTest.DisplayIdMatcher.displayId; import static com.android.server.accessibility.AccessibilityWindowManagerWithAccessibilityWindowTest.DisplayIdMatcher.displayId; import static com.android.server.accessibility.AccessibilityWindowManagerWithAccessibilityWindowTest.WindowIdMatcher.windowId; import static com.android.server.accessibility.AccessibilityWindowManagerWithAccessibilityWindowTest.WindowChangesMatcher.a11yWindowChanges; import static com.android.server.accessibility.AccessibilityWindowManagerWithAccessibilityWindowTest.WindowChangesMatcher.a11yWindowChanges; import static com.android.server.accessibility.AccessibilityWindowManagerWithAccessibilityWindowTest.WindowIdMatcher.a11yWindowId; import static com.android.server.accessibility.AccessibilityWindowManagerWithAccessibilityWindowTest.EventWindowIdMatcher.eventWindowId; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertFalse; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertNull; import static junit.framework.Assert.assertNull; import static junit.framework.Assert.assertTrue; import static junit.framework.Assert.assertTrue; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.allOf; import static org.hamcrest.Matchers.hasItem; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.hasSize; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.is; import static org.hamcrest.Matchers.not; import static org.hamcrest.Matchers.not; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertNotEquals; import static org.junit.Assert.assertThat; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.ArgumentMatchers.anyString; Loading Loading @@ -349,6 +351,88 @@ public class AccessibilityWindowManagerWithAccessibilityWindowTest { } } } } @Test public void onWindowsChanged_shouldNotReportNonTouchableWindow() { final AccessibilityWindow window = mWindows.get(Display.DEFAULT_DISPLAY).get(0); when(window.isTouchable()).thenReturn(false); final int windowId = mA11yWindowManager.findWindowIdLocked( USER_SYSTEM_ID, window.getWindowInfo().token); onAccessibilityWindowsChanged(Display.DEFAULT_DISPLAY, SEND_ON_WINDOW_CHANGES); final List<AccessibilityWindowInfo> a11yWindows = mA11yWindowManager.getWindowListLocked(Display.DEFAULT_DISPLAY); assertThat(a11yWindows, not(hasItem(windowId(windowId)))); } @Test public void onWindowsChanged_shouldReportFocusedNonTouchableWindow() { final AccessibilityWindow window = mWindows.get(Display.DEFAULT_DISPLAY).get( DEFAULT_FOCUSED_INDEX); when(window.isTouchable()).thenReturn(false); final int windowId = mA11yWindowManager.findWindowIdLocked( USER_SYSTEM_ID, window.getWindowInfo().token); onAccessibilityWindowsChanged(Display.DEFAULT_DISPLAY, SEND_ON_WINDOW_CHANGES); final List<AccessibilityWindowInfo> a11yWindows = mA11yWindowManager.getWindowListLocked(Display.DEFAULT_DISPLAY); assertThat(a11yWindows, hasItem(windowId(windowId))); } @Test public void onWindowsChanged_trustedFocusedNonTouchableWindow_shouldNotHideWindowsBelow() { // Make the focused trusted un-touchable window fullscreen. final AccessibilityWindow window = mWindows.get(Display.DEFAULT_DISPLAY).get( DEFAULT_FOCUSED_INDEX); setRegionForMockAccessibilityWindow(window, new Region(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); when(window.isTouchable()).thenReturn(false); when(window.isTrustedOverlay()).thenReturn(true); onAccessibilityWindowsChanged(Display.DEFAULT_DISPLAY, SEND_ON_WINDOW_CHANGES); final List<AccessibilityWindowInfo> a11yWindows = mA11yWindowManager.getWindowListLocked(Display.DEFAULT_DISPLAY); assertThat(a11yWindows, hasSize(NUM_OF_WINDOWS)); } @Test public void onWindowsChanged_accessibilityOverlay_shouldNotHideWindowsBelow() { // Make the a11y overlay window fullscreen. final AccessibilityWindow window = mWindows.get(Display.DEFAULT_DISPLAY).get(0); setRegionForMockAccessibilityWindow(window, new Region(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); when(window.getType()).thenReturn(WindowManager.LayoutParams.TYPE_ACCESSIBILITY_OVERLAY); onAccessibilityWindowsChanged(Display.DEFAULT_DISPLAY, SEND_ON_WINDOW_CHANGES); final List<AccessibilityWindowInfo> a11yWindows = mA11yWindowManager.getWindowListLocked(Display.DEFAULT_DISPLAY); assertThat(a11yWindows, hasSize(NUM_OF_WINDOWS)); } @Test public void onWindowsChanged_shouldReportFocusedWindowEvenIfOccluded() { // Make the front window fullscreen. final AccessibilityWindow frontWindow = mWindows.get(Display.DEFAULT_DISPLAY).get(0); setRegionForMockAccessibilityWindow(frontWindow, new Region(0, 0, SCREEN_WIDTH, SCREEN_HEIGHT)); final int frontWindowId = mA11yWindowManager.findWindowIdLocked( USER_SYSTEM_ID, frontWindow.getWindowInfo().token); final AccessibilityWindow focusedWindow = mWindows.get(Display.DEFAULT_DISPLAY).get( DEFAULT_FOCUSED_INDEX); final int focusedWindowId = mA11yWindowManager.findWindowIdLocked( USER_SYSTEM_ID, focusedWindow.getWindowInfo().token); onAccessibilityWindowsChanged(Display.DEFAULT_DISPLAY, SEND_ON_WINDOW_CHANGES); final List<AccessibilityWindowInfo> a11yWindows = mA11yWindowManager.getWindowListLocked(Display.DEFAULT_DISPLAY); assertThat(a11yWindows, hasSize(2)); assertThat(a11yWindows.get(0), windowId(frontWindowId)); assertThat(a11yWindows.get(1), windowId(focusedWindowId)); } @Test @Test public void onWindowsChangedAndForceSend_shouldUpdateWindows() { public void onWindowsChangedAndForceSend_shouldUpdateWindows() { assertNotEquals("new title", assertNotEquals("new title", Loading Loading @@ -631,11 +715,11 @@ public class AccessibilityWindowManagerWithAccessibilityWindowTest { .sendAccessibilityEventForCurrentUserLocked(captor.capture()); .sendAccessibilityEventForCurrentUserLocked(captor.capture()); assertThat(captor.getAllValues().get(0), assertThat(captor.getAllValues().get(0), allOf(displayId(Display.DEFAULT_DISPLAY), allOf(displayId(Display.DEFAULT_DISPLAY), a11yWindowId(currentActiveWindowId), eventWindowId(currentActiveWindowId), a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_ACTIVE))); a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_ACTIVE))); assertThat(captor.getAllValues().get(1), assertThat(captor.getAllValues().get(1), allOf(displayId(Display.DEFAULT_DISPLAY), allOf(displayId(Display.DEFAULT_DISPLAY), a11yWindowId(eventWindowId), eventWindowId(eventWindowId), a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_ACTIVE))); a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_ACTIVE))); } } Loading @@ -661,7 +745,7 @@ public class AccessibilityWindowManagerWithAccessibilityWindowTest { .sendAccessibilityEventForCurrentUserLocked(captor.capture()); .sendAccessibilityEventForCurrentUserLocked(captor.capture()); assertThat(captor.getAllValues().get(0), assertThat(captor.getAllValues().get(0), allOf(displayId(Display.DEFAULT_DISPLAY), allOf(displayId(Display.DEFAULT_DISPLAY), a11yWindowId(eventWindowId), eventWindowId(eventWindowId), a11yWindowChanges( a11yWindowChanges( AccessibilityEvent.WINDOWS_CHANGE_ACCESSIBILITY_FOCUSED))); AccessibilityEvent.WINDOWS_CHANGE_ACCESSIBILITY_FOCUSED))); } } Loading Loading @@ -710,12 +794,12 @@ public class AccessibilityWindowManagerWithAccessibilityWindowTest { .sendAccessibilityEventForCurrentUserLocked(captor.capture()); .sendAccessibilityEventForCurrentUserLocked(captor.capture()); assertThat(captor.getAllValues().get(0), assertThat(captor.getAllValues().get(0), allOf(displayId(initialDisplayId), allOf(displayId(initialDisplayId), a11yWindowId(initialWindowId), eventWindowId(initialWindowId), a11yWindowChanges( a11yWindowChanges( AccessibilityEvent.WINDOWS_CHANGE_ACCESSIBILITY_FOCUSED))); AccessibilityEvent.WINDOWS_CHANGE_ACCESSIBILITY_FOCUSED))); assertThat(captor.getAllValues().get(1), assertThat(captor.getAllValues().get(1), allOf(displayId(eventDisplayId), allOf(displayId(eventDisplayId), a11yWindowId(eventWindowId), eventWindowId(eventWindowId), a11yWindowChanges( a11yWindowChanges( AccessibilityEvent.WINDOWS_CHANGE_ACCESSIBILITY_FOCUSED))); AccessibilityEvent.WINDOWS_CHANGE_ACCESSIBILITY_FOCUSED))); } } Loading Loading @@ -771,11 +855,11 @@ public class AccessibilityWindowManagerWithAccessibilityWindowTest { .sendAccessibilityEventForCurrentUserLocked(captor.capture()); .sendAccessibilityEventForCurrentUserLocked(captor.capture()); assertThat(captor.getAllValues().get(0), assertThat(captor.getAllValues().get(0), allOf(displayId(Display.DEFAULT_DISPLAY), allOf(displayId(Display.DEFAULT_DISPLAY), a11yWindowId(eventWindowId), eventWindowId(eventWindowId), a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_ACTIVE))); a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_ACTIVE))); assertThat(captor.getAllValues().get(1), assertThat(captor.getAllValues().get(1), allOf(displayId(Display.DEFAULT_DISPLAY), allOf(displayId(Display.DEFAULT_DISPLAY), a11yWindowId(currentActiveWindowId), eventWindowId(currentActiveWindowId), a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_ACTIVE))); a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_ACTIVE))); } } Loading Loading @@ -979,7 +1063,7 @@ public class AccessibilityWindowManagerWithAccessibilityWindowTest { .sendAccessibilityEventForCurrentUserLocked(captor.capture()); .sendAccessibilityEventForCurrentUserLocked(captor.capture()); assertThat(captor.getAllValues().get(0), assertThat(captor.getAllValues().get(0), allOf(displayId(Display.DEFAULT_DISPLAY), allOf(displayId(Display.DEFAULT_DISPLAY), a11yWindowId(windowId), eventWindowId(windowId), a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_REMOVED))); a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_REMOVED))); } } Loading @@ -1001,7 +1085,7 @@ public class AccessibilityWindowManagerWithAccessibilityWindowTest { .sendAccessibilityEventForCurrentUserLocked(captor.capture()); .sendAccessibilityEventForCurrentUserLocked(captor.capture()); assertThat(captor.getAllValues().get(0), assertThat(captor.getAllValues().get(0), allOf(displayId(Display.DEFAULT_DISPLAY), allOf(displayId(Display.DEFAULT_DISPLAY), a11yWindowId(windowId), eventWindowId(windowId), a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_ADDED))); a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_ADDED))); } } Loading @@ -1019,7 +1103,7 @@ public class AccessibilityWindowManagerWithAccessibilityWindowTest { .sendAccessibilityEventForCurrentUserLocked(captor.capture()); .sendAccessibilityEventForCurrentUserLocked(captor.capture()); assertThat(captor.getAllValues().get(0), assertThat(captor.getAllValues().get(0), allOf(displayId(Display.DEFAULT_DISPLAY), allOf(displayId(Display.DEFAULT_DISPLAY), a11yWindowId(windowId), eventWindowId(windowId), a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_TITLE))); a11yWindowChanges(AccessibilityEvent.WINDOWS_CHANGE_TITLE))); } } Loading Loading @@ -1173,8 +1257,6 @@ public class AccessibilityWindowManagerWithAccessibilityWindowTest { private AccessibilityWindow createMockAccessibilityWindow(IWindow windowToken, int displayId) { private AccessibilityWindow createMockAccessibilityWindow(IWindow windowToken, int displayId) { final WindowInfo windowInfo = WindowInfo.obtain(); final WindowInfo windowInfo = WindowInfo.obtain(); // TODO(b/325341171): add tests with various kinds of windows such as // changing window types, touchable or not, trusted or not, etc. windowInfo.type = WindowManager.LayoutParams.TYPE_APPLICATION; windowInfo.type = WindowManager.LayoutParams.TYPE_APPLICATION; windowInfo.token = windowToken.asBinder(); windowInfo.token = windowToken.asBinder(); Loading Loading @@ -1235,16 +1317,16 @@ public class AccessibilityWindowManagerWithAccessibilityWindowTest { } } } } static class WindowIdMatcher extends TypeSafeMatcher<AccessibilityEvent> { static class EventWindowIdMatcher extends TypeSafeMatcher<AccessibilityEvent> { private int mWindowId; private int mWindowId; WindowIdMatcher(int windowId) { EventWindowIdMatcher(int windowId) { super(); super(); mWindowId = windowId; mWindowId = windowId; } } static WindowIdMatcher a11yWindowId(int windowId) { static EventWindowIdMatcher eventWindowId(int windowId) { return new WindowIdMatcher(windowId); return new EventWindowIdMatcher(windowId); } } @Override @Override Loading Loading @@ -1280,4 +1362,27 @@ public class AccessibilityWindowManagerWithAccessibilityWindowTest { description.appendText("Matching to window changes " + mWindowChanges); description.appendText("Matching to window changes " + mWindowChanges); } } } } static class WindowIdMatcher extends TypeSafeMatcher<AccessibilityWindowInfo> { private final int mWindowId; WindowIdMatcher(int windowId) { super(); mWindowId = windowId; } static WindowIdMatcher windowId(int windowId) { return new WindowIdMatcher(windowId); } @Override protected boolean matchesSafely(AccessibilityWindowInfo window) { return window.getId() == mWindowId; } @Override public void describeTo(Description description) { description.appendText("Matching to windowId " + mWindowId); } } } }