Loading core/tests/coretests/src/android/view/accessibility/AccessibilityCacheTest.java +26 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertNull; import static org.junit.Assert.fail; import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.anyObject; import static org.mockito.Mockito.doAnswer; Loading @@ -33,6 +34,8 @@ import android.view.View; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import com.google.common.base.Throwables; import org.junit.After; import org.junit.Before; import org.junit.Test; Loading Loading @@ -588,6 +591,29 @@ public class AccessibilityCacheTest { } } @Test public void addSameParentNodeWithDifferentChildNode_whenOriginalChildHasChild_doesntCrash() { AccessibilityNodeInfo parentNodeInfo = getParentNode(); AccessibilityNodeInfo childNodeInfo = getChildNode(); childNodeInfo.addChild(getMockViewWithA11yAndWindowIds(CHILD_VIEW_ID + 1, WINDOW_ID_1)); AccessibilityNodeInfo replacementParentNodeInfo = getNodeWithA11yAndWindowId(PARENT_VIEW_ID, WINDOW_ID_1); replacementParentNodeInfo.addChild( getMockViewWithA11yAndWindowIds(OTHER_CHILD_VIEW_ID, WINDOW_ID_1)); try { mAccessibilityCache.add(parentNodeInfo); mAccessibilityCache.add(childNodeInfo); mAccessibilityCache.add(replacementParentNodeInfo); } catch (IllegalStateException e) { fail("recycle A11yNodeInfo twice" + Throwables.getStackTraceAsString(e)); } finally { parentNodeInfo.recycle(); childNodeInfo.recycle(); replacementParentNodeInfo.recycle(); } } private void assertNodeIsRefreshedWithEventType(int eventType, int contentChangeTypes) { AccessibilityNodeInfo nodeInfo = getNodeWithA11yAndWindowId(SINGLE_VIEW_ID, WINDOW_ID_1); mAccessibilityCache.add(nodeInfo); Loading Loading
core/tests/coretests/src/android/view/accessibility/AccessibilityCacheTest.java +26 −0 Original line number Diff line number Diff line Loading @@ -20,6 +20,7 @@ import static junit.framework.Assert.assertEquals; import static junit.framework.Assert.assertNotNull; import static junit.framework.Assert.assertNull; import static org.junit.Assert.fail; import static org.mockito.Matchers.anyBoolean; import static org.mockito.Matchers.anyObject; import static org.mockito.Mockito.doAnswer; Loading @@ -33,6 +34,8 @@ import android.view.View; import androidx.test.filters.LargeTest; import androidx.test.runner.AndroidJUnit4; import com.google.common.base.Throwables; import org.junit.After; import org.junit.Before; import org.junit.Test; Loading Loading @@ -588,6 +591,29 @@ public class AccessibilityCacheTest { } } @Test public void addSameParentNodeWithDifferentChildNode_whenOriginalChildHasChild_doesntCrash() { AccessibilityNodeInfo parentNodeInfo = getParentNode(); AccessibilityNodeInfo childNodeInfo = getChildNode(); childNodeInfo.addChild(getMockViewWithA11yAndWindowIds(CHILD_VIEW_ID + 1, WINDOW_ID_1)); AccessibilityNodeInfo replacementParentNodeInfo = getNodeWithA11yAndWindowId(PARENT_VIEW_ID, WINDOW_ID_1); replacementParentNodeInfo.addChild( getMockViewWithA11yAndWindowIds(OTHER_CHILD_VIEW_ID, WINDOW_ID_1)); try { mAccessibilityCache.add(parentNodeInfo); mAccessibilityCache.add(childNodeInfo); mAccessibilityCache.add(replacementParentNodeInfo); } catch (IllegalStateException e) { fail("recycle A11yNodeInfo twice" + Throwables.getStackTraceAsString(e)); } finally { parentNodeInfo.recycle(); childNodeInfo.recycle(); replacementParentNodeInfo.recycle(); } } private void assertNodeIsRefreshedWithEventType(int eventType, int contentChangeTypes) { AccessibilityNodeInfo nodeInfo = getNodeWithA11yAndWindowId(SINGLE_VIEW_ID, WINDOW_ID_1); mAccessibilityCache.add(nodeInfo); Loading